-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[api-minor] Remove the closure from the PDFWorker
class, in the src/display/api.js
file
#13882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api-minor] Remove the closure from the PDFWorker
class, in the src/display/api.js
file
#13882
Conversation
4a0b732
to
78ddb42
Compare
…c/display/api.js` file This patch removes the only remaining closure in the `src/display/api.js` file, utilizing a similar approach as used in lots of other parts of the code-base, which results in a small decrease in the size of the *build* `pdf.js` file. Given that `PDFWorker` is exposed through the *public* API, this complicates things somewhat since there's a couple of worker-related properties that really should stay *private*. Initially, while working on PR 13813, I believed that we'd need support for private (static) class fields in order to get rid of this closure, however I've managed to come up with what's hopefully deemed an acceptable work-around here. Furthermore, some helper functions were simply moved into the `PDFWorker` class as static methods, thus simplifying the overall implementation (e.g. we don't need to manually cache the Promise in the `PDFWorker._setupFakeWorkerGlobal`-method). Finally, as part of this re-factoring a number of missing JSDoc-comments were added which *together* with the removal of the closure significantly improves the `gulp jsdoc` output for the `PDFWorker` class. *Please note:* This patch is tagged with `api-minor` since it deprecates `PDFWorker.getWorkerSrc()` in favor of the shorter `PDFWorker.workerSrc`, with the fallback limited to `GENERIC` builds.
78ddb42
to
1cf9405
Compare
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/31db561b8574bdf/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://3.101.106.178:8877/e4d225ec7d6f395/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/31db561b8574bdf/output.txt Total script time: 33.65 mins
Image differences available at: http://54.67.70.0:8877/31db561b8574bdf/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://3.101.106.178:8877/e4d225ec7d6f395/output.txt Total script time: 39.00 mins
Image differences available at: http://3.101.106.178:8877/e4d225ec7d6f395/reftest-analyzer.html#web=eq.log |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/be53d16d3ec4cd5/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/be53d16d3ec4cd5/output.txt Total script time: 5.24 mins Published |
Looks good to me; thank you for doing this! |
This patch removes the only remaining closure in the
src/display/api.js
file, utilizing a similar approach as used in lots of other parts of the code-base, which results in a small decrease in the size of the buildpdf.js
file.Given that
PDFWorker
is exposed through the public API, this complicates things somewhat since there's a couple of worker-related properties that really should stay private. Initially, while working on PR #13813, I believed that we'd need support for private (static) class fields in order to get rid of this closure, however I've managed to come up with what's hopefully deemed an acceptable work-around here.Furthermore, some helper functions were simply moved into the
PDFWorker
class as static methods, thus simplifying the overall implementation (e.g. we don't need to manually cache the Promise in thePDFWorker._setupFakeWorkerGlobal
-method).Finally, as part of this re-factoring a number of missing JSDoc-comments were added which together with the removal of the closure significantly improves the
gulp jsdoc
output for thePDFWorker
class.Please note: This patch is tagged with
api-minor
since it deprecatesPDFWorker.getWorkerSrc()
in favor of the shorterPDFWorker.workerSrc
, with the fallback limited toGENERIC
builds.