20871 Commits

Author SHA1 Message Date
Jonas Jenwald
97a42486f5 Improve how the PDF.js version/commit information is exposed in the *built* files
To make it easier to tell which PDF.js version/commit that the *built* files correspond to, they have (since many years) included `pdfjsVersion` and `pdfjsBuild` constants with that information.

As currently implemented this has a few shortcomings:
 - It requires manually adding the code, with its preprocessor statements, in all relevant files.

 - It requires ESLint disable statements, since it's obviously unused code.

 - Being unused, this code is removed in the minified builds.

 - This information would be more appropriate as comments, however Babel discards all comments during building.

 - It would be helpful to have this information at the top of the *built* files, however it's being moved during building.

To address all of these issues, we'll instead utilize Webpack to insert the version/commit information as a comment placed just after the license header.
2025-05-19 15:01:05 +02:00
Tim van der Meij
819671d42f
Merge pull request #19949 from timvandermeij/intermittent-stamp-undo
Fix intermittent failure in the stamp editor's undo-related integration tests
2025-05-18 15:17:41 +02:00
Tim van der Meij
6355dd7ded
Fix intermittent failure in the stamp editor's undo-related integration tests
The clipboard, used via the `copyImage` helper function, is a shared
resource, so access to it cannot happen concurrently because it could
result in tests overwriting each other's contents. Most tests using
the clipboard are therefore run sequentially, but only the stamp
editor's undo-related tests weren't, so this commit fixes the issue
by running those tests sequentially too.
2025-05-18 14:36:19 +02:00
Tim van der Meij
f6e4b1cf4a
Merge pull request #19945 from Snuffleupagus/NetworkStream-rm-Node-Error
Remove Node.js-specific checks when using the Fetch API
2025-05-18 12:05:13 +02:00
Tim van der Meij
30bba5f165
Merge pull request #19944 from Snuffleupagus/PDFDataRangeTransport-private-fields
Use private fields in the `PDFDataRangeTransport` class
2025-05-18 12:01:03 +02:00
Jonas Jenwald
a882195e9b Remove Node.js-specific checks when using the Fetch API
Given that Node.js has full support for the Fetch API since version 21, see the "History" data at https://nodejs.org/api/globals.html#fetch, it seems unnecessary for us to manually check for various globals before using it.

Since our primary development target is browsers in general, and Firefox in particular, being able to remove Node.js-specific compatibility code is always helpful.

Note that we still, for now, support Node.js version 20 and if the relevant globals are not available then Errors will instead be thrown from within the `PDFFetchStream` class.
2025-05-18 10:49:02 +02:00
Jonas Jenwald
99b23ea1f6 Use private fields in the PDFDataRangeTransport class 2025-05-18 10:16:46 +02:00
Jonas Jenwald
f72f240699
Merge pull request #19939 from Snuffleupagus/disableWorker-clear-workerPort
Ensure that the viewer clears the `workerPort` option when using "fake" workers
2025-05-18 08:38:48 +02:00
Tim van der Meij
23f269b353
Merge pull request #19942 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2025-05-17 20:41:48 +02:00
Tim van der Meij
91679ece4b
Merge pull request #19943 from Snuffleupagus/PDFWorker-create
Replace `PDFWorker.fromPort` with a generic `PDFWorker.create` method
2025-05-17 19:12:38 +02:00
Jonas Jenwald
fc697b3602 Utilize private fields and methods more in the PDFWorker class
This replaces, wherever possible, the old semi-private fields and methods with actually private ones.
2025-05-17 18:05:49 +02:00
Jonas Jenwald
ab672f0b77 Replace PDFWorker.fromPort with a generic PDFWorker.create method
This allows us to simply invoke `PDFWorker.create` unconditionally from the `getDocument` function, without having to manually check if a global `workerPort` is available first.
2025-05-17 16:13:41 +02:00
Tim van der Meij
1e4ba0b8bf
Update translations to the most recent versions 2025-05-17 15:58:38 +02:00
Tim van der Meij
d297e44f3f
Update dependencies to the most recent versions 2025-05-17 15:50:54 +02:00
Tim van der Meij
278fc064eb
Merge pull request #19917 from Snuffleupagus/unicorn-59-rule-updates
Add a couple of new `eslint-plugin-unicorn` rules
2025-05-17 13:55:52 +02:00
Jonas Jenwald
b81b9ce00d Add a couple of new eslint-plugin-unicorn rules
The recent `eslint-plugin-unicorn` update added, and replaced, a few rules that seem useful for us; please refer to https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v59.0.0

Note that none of the following rules required any code-changes:
 - Replace `no-array-push-push` with `prefer-single-call`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-single-call.md

 - Add `no-unnecessary-slice-end`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-slice-end.md

 - Add `no-unnecessary-array-flat-depth`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-array-flat-depth.md

 - Add `no-unnecessary-array-splice-count`, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-array-splice-count.md
2025-05-17 13:49:11 +02:00
Tim van der Meij
b05351ceae
Merge pull request #19937 from studystill/master
chore: remove redundant word in comment
2025-05-17 13:34:39 +02:00
Tim van der Meij
57cbaae8e4
Merge pull request #19916 from Snuffleupagus/prefer-import-meta-properties
Enable the `unicorn/prefer-import-meta-properties` ESLint plugin rule
2025-05-17 13:33:48 +02:00
Jonas Jenwald
eef1e3e87f Ensure that the viewer clears the workerPort option when using "fake" workers
Without this "fake" workers may be ignored in the API, which isn't really what you want when manually providing the `disableWorker=true` hash parameter. (Note that this requires the `pdfBugEnabled` option/preference to be set as well.)

Also, after the changes in PR 19810 we can just load the "fake" worker directly in development mode and don't need to manually assign it to the global scope.
2025-05-17 11:41:33 +02:00
studystill
b585937340 chore: remove redundant word in comment
Signed-off-by: studystill <chenghuiyue@outlook.com>
2025-05-16 15:16:26 +08:00
Jonas Jenwald
13c9995455 Enable the unicorn/prefer-import-meta-properties ESLint plugin rule
Given that we require Node.js versions `>=20.16.0 || >=22.3.0` using this should be fine, based on the "History" data in https://nodejs.org/api/esm.html#importmetadirname respectively https://nodejs.org/api/esm.html#importmetafilename.

Please also see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-import-meta-properties.md
2025-05-16 07:47:08 +02:00
Jonas Jenwald
d97b65378f
Merge pull request #19933 from mozilla/dependabot/npm_and_yarn/undici-6.21.3
Bump undici from 6.21.1 to 6.21.3
2025-05-15 23:28:00 +02:00
calixteman
f4a3e47018
Merge pull request #19935 from calixteman/bug1966721
Use the worker created in the child actor (bug 1966721)
2025-05-15 21:21:06 +02:00
Calixte Denizet
f01b13d332 Use the worker created in the child actor (bug 1966721) 2025-05-15 21:17:44 +02:00
Jonas Jenwald
b3ccc55c1d
Merge pull request #19936 from Snuffleupagus/workerPort-firefox
Allow using the `workerPort` option in Firefox
2025-05-15 21:09:08 +02:00
calixteman
be463f0e0c
Merge pull request #19934 from calixteman/minify
Minify the js code when building for Firefox (bug 1965003)
2025-05-15 20:11:11 +02:00
Jonas Jenwald
e5e9d18289 Allow using the workerPort option in Firefox 2025-05-15 19:30:43 +02:00
Calixte Denizet
8129ccc9a7 Minify the js code when building for Firefox (bug 1965003)
It helps to improve the loading time in the worker by around 25% on Windows, Mac and Android.
2025-05-15 19:01:52 +02:00
dependabot[bot]
64c1e07f22
Bump undici from 6.21.1 to 6.21.3
Bumps [undici](https://github.com/nodejs/undici) from 6.21.1 to 6.21.3.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.21.1...v6.21.3)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.21.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-15 15:23:50 +00:00
Jonas Jenwald
b070a502c3
Merge pull request #19929 from Snuffleupagus/bug-1966086
Prefer the /Metadata, when available, in the document properties dialog (bug 1966086)
2025-05-15 15:54:42 +02:00
Jonas Jenwald
ab89773e49 Prefer the /Metadata, when available, in the document properties dialog (bug 1966086) 2025-05-15 15:12:09 +02:00
Jonas Jenwald
d4d0081ac9
Merge pull request #19923 from nicolo-ribaudo/fix-new-url
Remove unused OpenJPEG wasm fallback logic
2025-05-14 08:11:37 +02:00
Marco Castelluccio
2ed959d75a
Merge pull request #19897 from Snuffleupagus/ci-Node-24
Run CI tests in Node.js version 24
2025-05-14 00:09:06 +02:00
calixteman
a4b5b7c4bb
Merge pull request #19925 from calixteman/bug1962819
[Editor] Keep aspect ratio when rescaling an image before being processed for a signature (bug 1962819)
2025-05-13 20:07:11 +02:00
Nicolò Ribaudo
aebe0cb67f
Remove unused OpenJPEG wasm fallback logic
Emscripten generates code that allows the caller to provide the Wasm
module (thorugh Module.instantiateWasm), with a fallback in case
.instantiateWasm is not provided. We always define instantiateWasm, so
we can hard-code the check and let our dead code elimination logic
remove the unused fallback.

This commit also improved the dead code elimination logic so that if
a function declaration becomes unused as a result of removing dead
code, the function itself is removed.
2025-05-13 19:38:17 +02:00
Calixte Denizet
d6605674dd [Editor] Keep aspect ratio when rescaling an image before being processed for a signature (bug 1962819) 2025-05-13 19:12:17 +02:00
calixteman
2bb8099831
Merge pull request #19924 from calixteman/update_qcms
Update qcms build
2025-05-13 17:49:54 +02:00
Calixte Denizet
09f0af5b83 Update qcms build
It's a follow-up of https://github.com/mozilla/pdf.js.qcms/pull/1.
2025-05-13 16:44:18 +02:00
Jonas Jenwald
5e3d26601e
Merge pull request #19922 from nicolo-ribaudo/vite-ignore-minified
Preserve webpack/vite ignore comments when minifying
2025-05-13 14:54:17 +02:00
Nicolò Ribaudo
ff432c39f9
Preserve webpack/vite ignore comments when minifying
They were removed in the minified build, but the code that made the comments necessary was still there (just minified). This commit updates the Terser config to preserve them.

The default value of Terser's `comments` option is [`/@preserve|@copyright|@lic|@cc_on|^\**!/i`](d528103b7c/lib/output.js (L178C12-L178C53)), however the only type of comment it was actually matching in our case is `@lic`, for the license header in minified files. Thus the new regexp is `/@lic|webpackIgnore|@vite-ignore/i`.
2025-05-13 12:52:29 +02:00
Jonas Jenwald
3f1ecc1ba9
Merge pull request #19915 from Snuffleupagus/OutputScale-capPixels
Reduce duplication when computing the maximum canvas pixels
2025-05-10 21:47:52 +02:00
Jonas Jenwald
d5c534fb83 Reduce duplication when computing the maximum canvas pixels
*This is something that occurred to me when reviewing the latest PDF.js update in mozilla-central.*

Currently we duplicate essentially the same code in both the `OutputScale.prototype.limitCanvas` and `PDFPageDetailView.prototype.update` methods, which seems unnecessary, and to avoid that we introduce a new `OutputScale.capPixels` method that is used to compute the maximum canvas pixels.
2025-05-10 20:12:38 +02:00
calixteman
ca05a0dbfc
Merge pull request #19911 from calixteman/issue19753
Decode appearance keys of checkboxes
2025-05-10 15:01:22 +02:00
Jonas Jenwald
5f4bfe1fb9
Merge pull request #19913 from Snuffleupagus/openAction-array-validate
Improve validation in the `Catalog.prototype.openAction` getter
2025-05-10 14:53:48 +02:00
Jonas Jenwald
f26f984fa0 Improve validation in the Catalog.prototype.openAction getter
When the /OpenAction data is an Array we're currently using it as-is which could theoretically cause problems in corrupt PDF documents, hence we ensure that a "raw" destination is actually valid. (This change is covered by existing unit-tests.)

*Note:* In the Dictionary case we're using the `Catalog.parseDestDictionary` method, which already handles all of the necessary validation.
2025-05-10 11:51:58 +02:00
Calixte Denizet
49a098cb5d Decode appearance keys of checkboxes 2025-05-09 21:46:17 +02:00
calixteman
293506ada7
Merge pull request #19903 from Snuffleupagus/shorten-fieldObjects-getter
Shorten the `PDFDocument.prototype.fieldObjects` getter slightly
2025-05-09 15:49:51 +02:00
calixteman
ff0d9b13a7
Merge pull request #19902 from Snuffleupagus/core-document-shorten
Shorten the code in the `src/core/document.js` file
2025-05-09 15:48:49 +02:00
calixteman
a806f00ea1
Merge pull request #19755 from calixteman/reduce_canvas_size
Add a pref in order to cap the canvas area to a factor of the window one (bug 1958015)
2025-05-09 15:47:42 +02:00
Calixte Denizet
1225c1e39a Add a pref in order to cap the canvas area to a factor of the window one (bug 1958015)
This way it helps to reduce the overall canvas dimensions and make the rendering faster.
The drawback is that when scrolling, the page can be blurry in waiting for the rendering.

The default value is 200% on desktop and will be 100% for GeckoView.
2025-05-09 13:57:16 +02:00