Remove the compatibility checks in WorkerMessageHandler.createDocumentHandler

For some time these checks have only targeted Node.js environments, since the features in question exist in all supported browsers (even when a `legacy`-build is used).

Now that we've updated the minimum supported Node.js version to 18, a number of polyfills are thus (finally) no longer necessary in that environment. Hence for certain *basic* functionality, such as e.g. text-extraction, it's now possible to use either a modern- or a `legacy`-build of the PDF.js library in Node.js environments.

*Please note:* For e.g. canvas-rendering in Node.js environments it's still necessary to use a `legacy`-build, since that functionality requires various polyfills.
This commit is contained in:
Jonas Jenwald 2023-04-14 21:32:09 +02:00
parent ed8be6f882
commit 1753e321cd
2 changed files with 0 additions and 16 deletions

View File

@ -2165,8 +2165,6 @@ function packageJson() {
license: DIST_LICENSE,
optionalDependencies: {
canvas: "^2.11.2",
},
dependencies: {
"path2d-polyfill": "^2.0.1",
},
browser: {

View File

@ -129,20 +129,6 @@ class WorkerMessageHandler {
"; thus breaking e.g. `for...in` iteration of `Array`s."
);
}
// Ensure that (primarily) Node.js users won't accidentally attempt to use
// a non-translated/non-polyfilled build of the library, since that would
// quickly fail anyway because of missing functionality.
if (isNodeJS && typeof Path2D === "undefined") {
const partialMsg =
"The browser/environment lacks native support for critical " +
"functionality used by the PDF.js library (e.g. `Path2D`); ";
if (isNodeJS) {
throw new Error(partialMsg + "please use a `legacy`-build instead.");
}
throw new Error(partialMsg + "please update to a supported browser.");
}
}
const workerHandlerName = docId + "_worker";
let handler = new MessageHandler(workerHandlerName, docId, port);