Merge pull request #16779 from Snuffleupagus/deprecate-getJavaScript

[api-minor] Deprecate the `PDFDocumentProxy.getJavaScript` method
This commit is contained in:
Jonas Jenwald 2023-08-01 20:58:36 +02:00 committed by GitHub
commit e6728f94f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 58 deletions

View file

@ -760,6 +760,26 @@ class PDFDocumentProxy {
this._pdfInfo = pdfInfo;
this._transport = transport;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
Object.defineProperty(this, "getJavaScript", {
value: () => {
deprecated(
"`PDFDocumentProxy.getJavaScript`, " +
"please use `PDFDocumentProxy.getJSActions` instead."
);
return this.getJSActions().then(js => {
if (!js) {
return js;
}
const jsArr = [];
for (const name in js) {
jsArr.push(...js[name]);
}
return jsArr;
});
},
});
}
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
// For testing purposes.
Object.defineProperty(this, "getXFADatasets", {
@ -917,19 +937,10 @@ class PDFDocumentProxy {
return this._transport.getAttachments();
}
/**
* @returns {Promise<Array<string> | null>} A promise that is resolved with
* an {Array} of all the JavaScript strings in the name tree, or `null`
* if no JavaScript exists.
*/
getJavaScript() {
return this._transport.getJavaScript();
}
/**
* @returns {Promise<Object | null>} A promise that is resolved with
* an {Object} with the JavaScript actions:
* - from the name tree (like getJavaScript);
* - from the name tree.
* - from A or AA entries in the catalog dictionary.
* , or `null` if no JavaScript exists.
*/
@ -3016,10 +3027,6 @@ class WorkerTransport {
return this.messageHandler.sendWithPromise("GetAttachments", null);
}
getJavaScript() {
return this.messageHandler.sendWithPromise("GetJavaScript", null);
}
getDocJSActions() {
return this.#cacheSimpleMethod("GetDocJSActions");
}