1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00
Commit graph

19191 commits

Author SHA1 Message Date
Calixte Denizet
43be717ce3 Clean up before closing the tab in integration tests 2024-06-18 14:23:19 +02:00
Jonas Jenwald
22ca7d52d3 Ensure that dependencies are added to the operatorList for locally cached images (issue 18259) 2024-06-18 12:25:53 +02:00
Jonas Jenwald
0981716bfa Only use the l10n fallback bundle when normal ftl-file fetching failed (issue 18264) 2024-06-18 11:54:49 +02:00
calixteman
06800cd966
Merge pull request #18255 from calixteman/disable_hwa_only_for_mc
Only disable HWA in m-c build and for local dev
2024-06-16 21:47:34 +02:00
Tim van der Meij
56c396556f
Merge pull request #18257 from calixteman/update_openjpeg_1
Update jpx decoder
2024-06-16 20:44:26 +02:00
Tim van der Meij
ff44c3be1f
Merge pull request #18258 from timvandermeij/release-reproducible
Implement reproducibility for the release builds
2024-06-16 20:39:38 +02:00
Tim van der Meij
44e0fae9d1
Implement reproducibility for the release builds
The release builds are currently not reproducible because ZIP files
record the modification date of files generated during the build
process, meaning that two builds from identical source code, made
at different times, result in different output.

This is undesirable because it makes detecting differences in the output
harder, for instance recently during the Gulp 5 efforts, because the
modification date differences are irrelevant and could obscure actually
important differences in the output during e.g. code changes. Moreover,
reprodicibility of build artifacts has become increasingly important;
please refer to the Reproducible Builds initiative at
https://reproducible-builds.org (note the "Why does it matter?" section
specifically) and https://reproducible-builds.org/docs/timestamps which
further explains the problem of timestamps in build artifacts.

This commit fixes the issue by configuring the ZIP file creation to use
the (fixed) date of the last Git commit for which the release is being
made. With this the build is fully reproducible so that identical source
code builds result in bit-by-bit identical output artifacts.

To improve readability we convert the compression method to take a
parameter object and use template strings where useful.
2024-06-16 20:32:55 +02:00
Calixte Denizet
7255b75ee9 Update jpx decoder
The decoder has been updated to reduce the number of copies after
having decoded an image:
b4ba3b3090
2024-06-16 19:05:26 +02:00
Jonas Jenwald
7b0c0347d0
Merge pull request #18254 from Snuffleupagus/force-save
Ensure that saving, in the viewer, works for partially loaded documents
2024-06-16 17:26:26 +02:00
Tim van der Meij
ee94391794
Merge pull request #18256 from timvandermeij/jsdoc-reproducible
Implement reproducibility for the JSDoc builds
2024-06-16 16:08:56 +02:00
Tim van der Meij
9d0002555d
Implement reproducibility for the JSDoc builds
The JSDoc builds are currently not reproducible because a timestamp is
included in the output, meaning that two builds from identical source
code, made at different times, result in different output.

This is undesirable because it makes diffing the output difficult, for
instance recently during the Gulp 5 efforts, because the timestamp
differences are irrelevant and could obscure actually important
differences in the output during e.g. code changes. Moreover,
reprodicibility of build artifacts has become increasingly important;
please refer to the Reproducible Builds initiative at
https://reproducible-builds.org (note the "Why does it matter?" section
specifically) and https://reproducible-builds.org/docs/timestamps which
further explains the problem of timestamps in build artifacts.

This commit fixes the issue by configuring JSDoc to not include the
timestamps in the output. It's not relevant for end users and without it
the build is fully reproducible so that identical source code builds
result in bit-by-bit identical output artifacts.

Note that this option sadly can only be set via a configuration file,
and not via the command line parameters like we used to have, so for
consistency we also move the other options into the configuration file
so they are all in one place and the Gulpfile becomes a bit simpler.
2024-06-16 15:10:34 +02:00
calixteman
f8acd33527
Merge pull request #18253 from calixteman/bug1539074
Compute correctly the unitsPerEm value from the fontMatrix when converting a font (bug 1539074)
2024-06-16 12:17:10 +02:00
Calixte Denizet
52a06e64f6 Only disable HWA in m-c build and for local dev
This way, we keep pdf.js working as before except for Firefox.
2024-06-16 12:14:33 +02:00
Jonas Jenwald
f4912db2ae Remove the _ensureDownloadComplete helper method in web/app.js
After the previous commit this method has only a single call-site, hence we can inline the needed part of that check directly in `PDFViewerApplication.download` instead.
2024-06-15 18:00:18 +02:00
Jonas Jenwald
7c5e9cf8be Ensure that saving, in the viewer, works for partially loaded documents
Currently saving a modified PDF document may fail *intermittently*, if it's triggered before the entire document has been downloaded.
When saving was originally added we only supported forms, and such PDF documents are usually small/simple enough for this issue to be difficult to trigger. However, with editing-support now available as well it's possible to modify much larger documents and this issue thus becomes easier to trigger.

One way to reproduce this issue *consistently* is to:
 - Open http://localhost:8888/web/viewer.html?file=/test/pdfs/pdf.pdf#disableHistory=true&disableStream=true&disableAutoFetch=true
 - Add an annotation on the first page, it doesn't matter what kind.
 - Save the document.
 - Open the resulting document, and notice that with the `master` branch the annotation is missing.
2024-06-15 17:58:58 +02:00
Calixte Denizet
d1452206d9 Compute correctly the unitsPerEm value from the fontMatrix when converting a font (bug 1539074) 2024-06-15 17:51:34 +02:00
Tim van der Meij
2effc96021
Merge pull request #18250 from Snuffleupagus/api-misc-fixes
Improve some old code in the `src/display/api.js` file
2024-06-15 15:46:44 +02:00
Tim van der Meij
ebb2db7be1
Merge pull request #18251 from timvandermeij/docs-api-inline
Include the generated API documentation directly on the API page
2024-06-15 15:34:27 +02:00
Tim van der Meij
e30dda5261
Include the generated API documentation directly on the API page
This should make the API documentation slightly quicker to access for
users by removing an extra click. Moreover, it makes the API
documentation blend in with the rest of the website/theme (one of the
points in #6526).

Fixes #18249.
2024-06-15 15:13:01 +02:00
Jonas Jenwald
f3f88eecb4 Use an AbortController to remove the temporary "error" handler for the worker 2024-06-15 14:35:32 +02:00
Jonas Jenwald
2d0e08f1c8 Introduce a helper method for resolving the PDFWorker promise
This avoids having to repeat the same code multiple times, since besides resolving the promise we also need to send the "configure" message to the worker-thread.
2024-06-15 14:35:30 +02:00
Jonas Jenwald
8d4456172b Reduce duplication when handling the "test" message from the worker
The feature-testing on the worker-thread has been simplified in previous pull requests, which means that we can simplify this main-thread handler as well.
2024-06-15 14:35:28 +02:00
Jonas Jenwald
0a36b667e4 Use an early return in PDFWorker.prototype._initialize when workers are disabled
This helps reduce overall indentation in the method, thus leading to slightly less code.
Also, remove an old comment referring to Chrome 15 since that's no longer relevant now.
2024-06-15 14:35:12 +02:00
Jonas Jenwald
d6612b3427 Remove some now redundant validation in getDocument
Given that we now check/validate all options properly this old code can be simplified.
2024-06-15 14:35:10 +02:00
Tim van der Meij
831a526c10
Merge pull request #18248 from timvandermeij/metalsmith
Replace Wintersmith with Metalsmith
2024-06-15 12:19:35 +02:00
Tim van der Meij
ce7cdf4670
Replace Wintersmith with Metalsmith
Wintersmith is no longer maintained given that the most recent version
is from six years ago, and all vulnerabilities that NPM reports
originate from Wintersmith's dependencies. Metalsmith, and its plugins,
on the other hand have recently had releases and don't have known
vulnerabilities. In fact, the number of reported vulnerabilities by NPM
even goes down to zero with this patch applied.

This commit therefore replaces Wintersmith with Metalsmith by providing
a transparent drop-in replacement, in a way that requires the least
amount of changes to the code and the generated output.

Note that this patch does update our versions of jQuery, Bootstrap and
the Highlight.js theme because the previous versions were very outdated
and didn't work correctly with Metalsmith. Moreover, those old versions
contained vulnerabilities that are hereby fixed.

Fixes #18198.
2024-06-14 20:37:13 +02:00
Tim van der Meij
7279ce6bad
Merge pull request #18247 from timvandermeij/readme
Don't recommend installing `gulp-cli` globally in the README and on the website
2024-06-14 20:26:12 +02:00
Tim van der Meij
0348559ef8
Don't recommend installing gulp-cli globally in the README and on the website
It's recommended to always install dependencies locally in the project
folder because global dependencies can easily conflict with other
projects and, because they are not managed by the project, diverge from
versions defined in e.g. `package.json`. Previously we installed
`gulp-cli` globally because at the time we lacked a convenient mechanism
to use Gulp otherwise, but nowadays NPM provides the `npx` command for
that purpose and recommends using it over global installations (see
https://docs.npmjs.com/downloading-and-installing-packages-globally
and PR #17489 that provided the ground work for using it).

This commit therefore updates our README and website to no longer recommend
installing `gulp-cli` globally but instead installing it locally from the
already existing entries in `package.json` like all other dependencies
we use. Not only does this remove the special-casing for `gulp-cli`
which simplifies the installation procedure, it also ensures that the
version ranges provided in `package.json` are respected.

This change is similar to the change in commit 92de2b7.

Fixes #18232.
Fixes 98ef8a1.
2024-06-14 18:41:44 +02:00
Tim van der Meij
aa68b8b4b3
Merge pull request #18234 from calixteman/improve_date_parsing
Improve date parsing in the js sandbox
2024-06-14 18:25:36 +02:00
Tim van der Meij
f9693b4d16
Merge pull request #18244 from Snuffleupagus/CSS-copyAll
Improve how the wait-cursor is toggled when copying all text
2024-06-14 18:23:03 +02:00
Tim van der Meij
f00152bf92
Merge pull request #18246 from calixteman/fix_js_error
Fix an query with an empty selector in integration tests
2024-06-14 18:20:44 +02:00
Calixte Denizet
c14c3cfc9f Improve date parsing in the js sandbox
If for example dd:mm is failing we just try with d:m which is equivalent
to the regex /d{1,2}:m{1,2}/. This way it allows the user to forget the
0 for the first days/months.
2024-06-14 17:21:50 +02:00
Calixte Denizet
6d1f7e806e Fix an query with an empty selector in integration tests
In looking the logs from Chrome bidi tests I noticed a js syntax error
which is fixed thanks to this patch.
2024-06-14 16:43:41 +02:00
calixteman
e3caa3c6ee
Merge pull request #18243 from calixteman/disable_ui_when_saving
Display a wait cursor when saving
2024-06-14 10:48:18 +02:00
Jonas Jenwald
97686c410c Improve how the wait-cursor is toggled when copying all text
- Use a CSS rule to display the wait-cursor during copying. Since copying may take a little while in long documents, there's a theoretical risk that something else could change the cursor in the meantime and just resetting to the saved-cursor could thus be incorrect.

 - Remove the `interruptCopyCondition` listener with an AbortController, since that's slightly shorter code.
2024-06-14 10:06:27 +02:00
Calixte Denizet
5ae936eb87 Display a wait cursor when saving
When the document is a bit long to save (for example in modifying a large document)
we must have something indicating that pdf.js is doing something.
2024-06-13 22:54:52 +02:00
Tim van der Meij
47791a4c80
Merge pull request #18236 from Snuffleupagus/rm-downloadUrl
Remove the `DownloadManager.downloadUrl` method
2024-06-13 15:44:42 +02:00
calixteman
f8ffc5baeb
Merge pull request #18238 from calixteman/disable_gpu
Add an option to enable/disable hardware acceleration (bug 1902012)
2024-06-12 19:27:07 +02:00
Calixte Denizet
ff6180a4c9 Add an option to enable/disable hardware acceleration (bug 1902012) 2024-06-12 18:41:07 +02:00
Jonas Jenwald
42999e5bef Remove the DownloadManager.downloadUrl method
This method has only a single call-site in the viewer, since it's used as a fallback, and the functionality can be moved into the `DownloadManager.download` method instead.
2024-06-12 13:27:45 +02:00
calixteman
341ff40e74
Merge pull request #18231 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-06-11 16:44:02 +02:00
Tim van der Meij
e0a01328f3
Update translations to the most recent versions 2024-06-11 15:13:06 +02:00
Tim van der Meij
8273dcaa81
Fix vulnerabilities in dependency versions
This patch is generated automatically using `npm audit fix`.
2024-06-11 15:11:07 +02:00
Tim van der Meij
866b948226
Update dependencies to the most recent versions 2024-06-11 15:10:22 +02:00
calixteman
361b54ec13
Merge pull request #18228 from calixteman/bug1899804
Don't display annotations with a PMD (barcode stuff) entry (bug 1899804)
2024-06-10 21:47:34 +02:00
Calixte Denizet
e3faa40f0f Don't display annotations with a PMD (barcode stuff) entry (bug 1899804)
There's no specification for that (even if it's possible to have an idea from
the xfa specs) so we just want to hide them in order to avoid to display something
wrong.
2024-06-10 21:01:37 +02:00
calixteman
bb73d2a922
Merge pull request #18219 from calixteman/jpx_fix_big_image
Update our OpenJPEG decoder in order to fix a malloc failure due to big image (bug 1901253)
2024-06-08 14:22:18 +02:00
Calixte Denizet
61398066b9 Update our OpenJPEG decoder in order to fix a malloc failure due to big image (bug 1901253)
It has been fixed in:
5ef68089b5
2024-06-07 17:38:35 +02:00
calixteman
c770e94e36
Merge pull request #18214 from calixteman/bug1900907
[Editor] Support dragging & dropping images on a pdf (bug 1900907)
2024-06-07 15:40:14 +02:00
Calixte Denizet
412e03e576 [Editor] Support dragging & dropping images on a pdf (bug 1900907) 2024-06-07 14:26:01 +02:00