Skip to content

Commit

Permalink
Remove the compatibility checks in `WorkerMessageHandler.createDocume…
Browse files Browse the repository at this point in the history
…ntHandler`

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.
  • Loading branch information
Snuffleupagus committed Apr 22, 2023
1 parent 329e70e commit 39e9794
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
2 changes: 0 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2195,8 +2195,6 @@ function packageJson() {
license: DIST_LICENSE,
optionalDependencies: {
canvas: "^2.11.2",
},
dependencies: {
"path2d-polyfill": "^2.0.1",
},
browser: {
Expand Down
14 changes: 0 additions & 14 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 39e9794

Please sign in to comment.