Commit Graph

17655 Commits

Author SHA1 Message Date
Jonas Jenwald
e81c084a92
Merge pull request #16703 from Snuffleupagus/babel-corejs
[api-minor] Let Babel handle the necessary `core-js` polyfills automatically
2023-07-17 19:45:06 +02:00
Jonas Jenwald
3a886e7264 Move the isNodeJS-helper into the src/shared/util.js file
With the changes in the previous patch the `isNodeJS`-helper no longer needs to live in its own file, which helps get rid of a closure in the *built* files.
2023-07-17 16:42:25 +02:00
Jonas Jenwald
67303b16f1 [api-minor] Let Babel handle the necessary core-js polyfills automatically
In the last couple of years we've been quicker to remove support for older browsers/environments, which means that at this point in time we don't bundle that many polyfills. (The polyfills are also generally simpler nowadays, ever since we removed support for e.g. Internet Explorer.)
Rather than having to *manually* handle the polyfills, we can actually let Babel take care of bundling the necessary polyfills for us; please refer to https://babeljs.io/docs/babel-preset-env

The only exception here is the Node.js-specific compatibility-code, which is moved into the `src/display/node_utils.js` file. This ought to be fine since workers are not available/used in Node.js-environments.

*Please note:* For the `legacy`-builds this will increase the size of the *built* files, however that seems like a very small price to pay in order to simplify maintenance of the general PDF.js library.
2023-07-17 16:42:08 +02:00
calixteman
9db65ad083
Merge pull request #16702 from calixteman/editor_2_decimals
[Editor] Use 2 decimals for editor positions and dimensions
2023-07-17 15:43:26 +02:00
Calixte Denizet
983b269e26 [Editor] Use 2 decimals for editor positions and dimensions
I noticed that after adding an image in issue16278.pdf, the image was constantly
resizing itself.
It appears that it's because of rounding errors.
2023-07-17 15:08:09 +02:00
calixteman
67e19171c4
Merge pull request #16689 from calixteman/bug1843303
[Editor] Avoid to have some part of an editor outside its page (bug 1843303)
2023-07-17 14:59:21 +02:00
Calixte Denizet
a8867cf68a [Editor] Avoid to have some part of an editor outside its page (bug 1843303) 2023-07-17 14:27:15 +02:00
Jonas Jenwald
717c766a42
Merge pull request #16701 from Snuffleupagus/gv-fix-toolbar-l10n
[GeckoView] Fix l10n of the download toolbar-button (PR 16340 follow-up)
2023-07-17 13:16:49 +02:00
Jonas Jenwald
8614621d8d [GeckoView] Fix l10n of the download toolbar-button (PR 16340 follow-up)
Localization of this button broke in PR 16340, which I assume was completely accidental, since the download-button now tries to access a l10n-id that was removed some time ago (see PR 15617).
Note how loading even the development viewer, i.e. http://localhost:8888/web/viewer-geckoview.html#locale=en-US, currently logs l10n-warnings on the `master` branch.
2023-07-17 11:47:11 +02:00
Tim van der Meij
d03a8d0efc
Merge pull request #16687 from Snuffleupagus/rm-more-require
Re-factor the `PDFScriptingManager`-class for the viewer-components
2023-07-16 15:16:07 +02:00
Tim van der Meij
8765306203
Merge pull request #16697 from Snuffleupagus/eslint-more-unicorn
Enable more ESLint `unicorn` plugin rules
2023-07-16 15:10:35 +02:00
Jonas Jenwald
9660ca53af Enable more ESLint unicorn plugin rules
- `prefer-array-some`, which didn't require any code changes; please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md

 - `prefer-modern-math-apis`, which should be fine given the currently supported browsers; please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md
2023-07-16 09:24:14 +02:00
Jonas Jenwald
bad4bfffdf Remove the require from the web/pdfjs.js
Having a `require` in this file has never made sense in e.g. the Firefox PDF Viewer and shouldn't really be necessary.
Possibly the idea was to facilitate some kind of third-party bundling, however the *built* `pdf.js` file has always exposed the API-contents globally.
2023-07-16 08:51:46 +02:00
Jonas Jenwald
86a868189c Re-factor the PDFScriptingManager-class for the viewer-components
Currently this class contains a few "special" code-paths for the COMPONENTS build-target, which normally wouldn't be a problem. However, in this particular case that means accessing code that we don't want to include unconditionally in all builds.
This is currently implemented using build-time `require`-calls which we nowadays want to avoid, and we should strive to remove all such cases from the code-base. (Generally speaking `import` is the future, and build-tools may not always play well with a mix of both formats.)

We can easily improve things here by using sub-classing for the COMPONENTS build-target, and then use the ability to re-name when exporting (to avoid breaking existing code).
2023-07-16 08:51:46 +02:00
Jonas Jenwald
337cba736e [ESM] Remove the remaining require from the gulpfile 2023-07-16 08:51:46 +02:00
Jonas Jenwald
bd67f7841f
Merge pull request #16695 from Snuffleupagus/tests-NaN
Ensure that a test-suite that runs no tests is treated as a failure
2023-07-16 08:32:43 +02:00
Jonas Jenwald
22c0bf4ec2
Merge pull request #16693 from Snuffleupagus/update-packages
Update packages and translations
2023-07-16 08:21:13 +02:00
Jonas Jenwald
b019c13b33 Ensure that a test-suite that runs no tests is treated as a failure
Occasionally some test-suites may fail to start on the bots, however that's not correctly reflected in the botio-output posted to GitHub which makes it easy to accidentally overlook this situation.
Looking at the raw logs when that happens they always seem to contain a line such as `Run NaN tests` which means that we should be able to easily make this situation a *failure* as intended.
2023-07-15 12:03:47 +02:00
Jonas Jenwald
b05c2e0343 Update l10n files 2023-07-15 10:44:39 +02:00
Jonas Jenwald
f84657d837 Address formatting changes from Prettier version 3 2023-07-15 10:44:39 +02:00
Jonas Jenwald
1a4bfd2fc3 Update npm packages
Note that while some packages increased the *major* version, it doesn't appear to cause any breakage as far as I can tell.
2023-07-15 10:44:30 +02:00
calixteman
ee373b313b
Merge pull request #16690 from calixteman/stamp_resize
[Editor] Resize the image when the page is zoomed
2023-07-14 12:16:44 +02:00
Calixte Denizet
5a692b2c33 [Editor] Resize the image when the page is zoomed
In order to reproduce the issue:
 - scale down the image
 - zoom the page and the image is pixellated
So this patch allow to redraw the image when zooming.
2023-07-13 20:36:23 +02:00
calixteman
36fc34ebe8
Merge pull request #16686 from calixteman/bug1843255
[Editor] Always use the data url when loading a SVG in order to avoid CSP issue (bug 1843255)
2023-07-13 15:12:49 +02:00
Calixte Denizet
ed42577d9c [Editor] Always use the data url when loading a SVG in order to avoid CSP issue (bug 1843255) 2023-07-13 14:10:28 +02:00
Jonas Jenwald
762d86a59e
Merge pull request #16683 from Snuffleupagus/app-isOffscreenCanvasSupported
Access the `isOffscreenCanvasSupported` option *once* in `PDFViewerApplication._initializeViewerComponents`
2023-07-12 21:44:34 +02:00
Jonas Jenwald
b449da31ca
Merge pull request #16678 from Snuffleupagus/writeStream-tweaks
Tweak the `writeStream` implementation slightly
2023-07-12 21:43:01 +02:00
Jonas Jenwald
040d5bb294
Merge pull request #16675 from Snuffleupagus/pr-16659-followup
Re-enable editing, if necessary, when exiting PresentationMode (PR 16659 follow-up)
2023-07-12 21:41:43 +02:00
calixteman
46cec96900
Merge pull request #16642 from calixteman/issue16633
[Editor] Try to make the position of an edited FreeText the more accurated as possible
2023-07-12 21:08:16 +02:00
Calixte Denizet
944c68ee85 [Editor] Try to make the position of an edited FreeText the more accurated as possible
- Take into account the page translation,
- Take into account the correct translation for the editor border,
- Take into account the position of the first glyph in the annotation,
- Take into account the rotation of the editor.

Close #16633.
2023-07-12 19:53:57 +02:00
Jonas Jenwald
7e04ca395f Access the isOffscreenCanvasSupported option *once* in PDFViewerApplication._initializeViewerComponents
There's no good reason for getting this option multiple times in the same method. Also, we can slightly re-factor how the `editorStampButton` is made visible.
2023-07-12 17:33:20 +02:00
Jonas Jenwald
5cfe792349 Tweak the writeStream implementation slightly
- Do the /Filter and /DecodeParms lookup in parallel, since that ought to be a *tiny* bit more efficient.
 - Avoid code-duplication when `CompressionStream` isn't supported, since we already have a fallback code-path at the end of the function.
2023-07-12 13:24:02 +02:00
Jonas Jenwald
7daa6b5fd8 Re-enable editing, if necessary, when exiting PresentationMode (PR 16659 follow-up)
This regressed in PR 16659, when the signature of the `PDFViewer.annotationEditorMode`-setter was changed, and it currently leads to an Error being thrown when exiting PresentationMode.
2023-07-11 22:34:20 +02:00
Jonas Jenwald
73d650af3e
Merge pull request #16669 from Snuffleupagus/esm-builder
[ESM] Convert the `external/builder/`-folder to use standard modules
2023-07-11 12:29:33 +02:00
Jonas Jenwald
5174232326 [ESM] Convert the external/builder/-folder to use standard modules 2023-07-11 11:38:59 +02:00
Jonas Jenwald
bcf14a49c0
Merge pull request #16668 from Snuffleupagus/esm-gulpfile
[ESM] Convert the `gulpfile` to use standard modules
2023-07-11 11:38:24 +02:00
calixteman
09d1be72f4
Merge pull request #16672 from calixteman/cheat_editorStamp_svg
[Editor] Cheat the stamp editor icon to make a linter in m-c happy
2023-07-11 09:59:32 +02:00
Calixte Denizet
414ea4a365 [Editor] Cheat the stamp editor icon to make a linter in m-c happy
At some point we won't use this icon anymore in the build-in pdf viewer
but we'll the one already in the m-c tree.
2023-07-10 21:18:05 +02:00
Jonas Jenwald
0bc9012b8f [ESM] Convert the gulpfile to use standard modules
This is a necessary intermediate step to allow converting files in the `external/builder/` folder.
2023-07-09 15:58:19 +02:00
Tim van der Meij
35202ec0f3
Merge pull request #16671 from Snuffleupagus/esm-parseDefaultPreferences
[ESM] Convert the "default preferences"-handling to use `import()` syntax
2023-07-09 15:38:30 +02:00
Tim van der Meij
1972b7311b
Merge pull request #16667 from Snuffleupagus/esm-cmaps
[ESM] Convert the "cmaps"-task to use `import()` syntax
2023-07-09 15:33:57 +02:00
Tim van der Meij
c0cc7f3eca
Merge pull request #16666 from Snuffleupagus/esm-wintersmith
[ESM] Convert the "wintersmith"-task to use `import()` syntax
2023-07-09 15:32:10 +02:00
Tim van der Meij
5a8ecbf560
Merge pull request #16665 from Snuffleupagus/esm-test
[ESM] Convert *most* of `test`-folder to use standard modules
2023-07-09 15:30:13 +02:00
Jonas Jenwald
6c601d3922 [ESM] Convert the "default preferences"-handling to use import() syntax
Unfortunately I wasn't able to come up with a *simple* way to just replace the synchronous `require`-call, since we need to ensure that the default preferences are available when bundling starts.
Hence this patch adds a new intermediate parsing-step in all the relevant gulp-tasks, but this shouldn't affect build-times noticeable since the amount of extra parsing is very small.

*Please note:* It's very possible that there's a better way to handle this, however I figured that unblocking further ESM-work is more important than a "perfect" solution.
2023-07-09 11:54:11 +02:00
Tim van der Meij
3efb276695
Merge pull request #16664 from Snuffleupagus/esm-terser
[ESM] Convert `parseMinified` to use `import()` syntax
2023-07-08 19:43:02 +02:00
Tim van der Meij
656c6d86fc
Merge pull request #16663 from Snuffleupagus/esm-importL10n
[ESM] Convert the `external/importL10n`-folder to use standard modules
2023-07-08 19:40:52 +02:00
Jonas Jenwald
f012fc5e70 [ESM] Convert the "cmaps"-task to use import() syntax 2023-07-08 18:52:58 +02:00
Tim van der Meij
42edc4d895
Merge pull request #16630 from Rob--W/crx-url-hash-init
Correct recognition of fragments at document load
2023-07-08 14:05:33 +02:00
Tim van der Meij
1567d022d9
Merge pull request #16631 from Rob--W/crx-remove-old-chrome-compat-code
[CRX] Drop code supporting ancient Chrome versions
2023-07-08 14:02:30 +02:00
Jonas Jenwald
ac3661972b [ESM] Convert the "wintersmith"-task to use import() syntax 2023-07-08 13:50:19 +02:00