Merge pull request #15943 from Snuffleupagus/deprecate-direct-PDFDataRangeTransport

[api-minor] Deprecate calling `getDocument` directly with a `PDFDataRangeTransport`-instance
This commit is contained in:
Tim van der Meij 2023-01-21 13:50:20 +01:00 committed by GitHub
commit a27d7ba524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -233,8 +233,7 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
*/
/**
* @typedef { string | URL | TypedArray | ArrayBuffer |
* PDFDataRangeTransport | DocumentInitParameters
* @typedef { string | URL | TypedArray | ArrayBuffer | DocumentInitParameters
* } GetDocumentParameters
*/
@ -258,7 +257,14 @@ function getDocument(src) {
source = { url: src };
} else if (isArrayBuffer(src)) {
source = { data: src };
} else if (src instanceof PDFDataRangeTransport) {
} else if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
src instanceof PDFDataRangeTransport
) {
deprecated(
"`PDFDataRangeTransport`-instance, " +
"please use a parameter object with `range`-property instead."
);
source = { range: src };
} else {
if (typeof src !== "object") {

View File

@ -3265,7 +3265,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
});
};
const loadingTask = getDocument(transport);
const loadingTask = getDocument({ range: transport });
const pdfDocument = await loadingTask.promise;
expect(pdfDocument.numPages).toEqual(14);
@ -3310,7 +3310,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
});
};
const loadingTask = getDocument(transport);
const loadingTask = getDocument({ range: transport });
const pdfDocument = await loadingTask.promise;
expect(pdfDocument.numPages).toEqual(14);