Commit Graph

17776 Commits

Author SHA1 Message Date
Jonas Jenwald
07cca3ddd9 Update l10n files 2023-09-03 10:01:37 +02:00
Jonas Jenwald
92831455bf Update npm packages 2023-09-03 09:59:08 +02:00
Jonas Jenwald
87ea2ed4e2
Merge pull request #16890 from stof/fix_type_generator
[Type-definitions] Fix type generator to support import maps
2023-09-01 12:00:27 +02:00
Christophe Coevoet
46f2c5893d Revert "Temporarily stop running gulp typestest in GitHub Actions"
This reverts commit d9350c3899.
2023-09-01 09:48:39 +02:00
Christophe Coevoet
d0f14b1ce3 Add support for the import map in the type generator
The typescript compiler is now configured to know about the import map
to be able to resolve those imports and find the associated types.
As tsc outputs declaration files using the original module identifiers
and not the resolved ones, tsc-alias is used to post-process the
declaration files by resolving those paths.
2023-09-01 09:48:39 +02:00
Christophe Coevoet
bbf11a5783 Migrate the typescript options to a config file
Some configurations settings like `paths` cannot be provided through CLI
arguments but only in a configuration file. And when using a
configuration file, only a few options (like `--outDir` can still be
provided) through the CLI.
2023-09-01 09:48:34 +02:00
Jonas Jenwald
b5c8849111
Merge pull request #16892 from Snuffleupagus/addLinkAttributes-rm-removeNullCharacters
Stop using `removeNullCharacters` in the `addLinkAttributes` helper function
2023-08-31 21:52:44 +02:00
Jonas Jenwald
c5ee72bb95 Stop using removeNullCharacters in the addLinkAttributes helper function
Using `removeNullCharacters` on the URL should be completely redundant, given the kind of data that we're passing to the `addLinkAttributes` helper function. Note that whenever we're handling a URL, originating in the worker-thread, in the viewer that helper function is always being used.

Furthermore, on the worker-thread all URLs are parsed with the `createValidAbsoluteUrl` helper function, which uses `new URL()` to ensure that a valid URL is obtained. Note that the `URL` constructor will either throw, or in some cases just ignore them, when encountering `\u0000`-characters during parsing.

Hence it should be *impossible* for a valid URL to contain `\u0000`-characters and we can thus simplify the viewer-code a tiny bit. The use of `removeNullCharacters` is most likely a left-over from back when `new URL()` wasn't generally available in browsers.
2023-08-31 20:10:50 +02:00
Jonas Jenwald
9190445a21
Merge pull request #16891 from Snuffleupagus/structElement-removeNullCharacters
Ignore null-chars when using structTree-data in the viewer
2023-08-31 18:09:04 +02:00
Jonas Jenwald
b159cc9e4b
Merge pull request #16888 from stof/fix_jsdoc_types
Fix JSDoc types
2023-08-31 16:36:09 +02:00
Jonas Jenwald
284f32f50b Ignore null-chars when using structTree-data in the viewer
Testing the `tagged_stamp.pdf` document locally in the viewer, I noticed that e.g. the /Alt entry for the StampAnnotation contains "Secondary text for stamp\u0000".
Elsewhere in the viewer we're skipping null-chars and it's easy enough to do that in the `StructTreeLayerBuilder` class as well. (Note that we generally let the API itself return the data as-is.)
2023-08-31 16:29:10 +02:00
calixteman
14b2a31e78
Merge pull request #16889 from calixteman/fix_aria_controls_id
Fix the id used in aria-controls used to make a relationship between the popup and its parent
2023-08-31 16:06:11 +02:00
Calixte Denizet
e7229854bd Fix the id used in aria-controls used to make a relationship between the popup and its parent 2023-08-31 15:48:32 +02:00
calixteman
20b0be973c
Merge pull request #16886 from calixteman/struct_tree_annotation
Add tagged annotations in the structure tree (bug 1850797)
2023-08-31 14:05:55 +02:00
Christophe Coevoet
f84f2646f4 Fix JSDoc types
This fixes invalid type references (either due to invalid paths for the
import or missing imports) in the JS doc, as well as some missing or
invalid parameter names for @param annotations.
2023-08-31 13:09:52 +02:00
Calixte Denizet
d185db2b70 Add tagged annotations in the structure tree (bug 1850797) 2023-08-31 12:35:32 +02:00
Tim van der Meij
92f7653cfb
Merge pull request #16876 from timvandermeij/bump
Bump versions in `pdfjs.config`
2023-08-27 18:09:29 +02:00
Tim van der Meij
fd32a53a86
Bump versions in pdfjs.config 2023-08-27 18:04:05 +02:00
Tim van der Meij
e142baecb1
Merge pull request #16875 from Snuffleupagus/more-optional-chaining-4
Introduce more optional chaining in the code-base
2023-08-27 11:16:56 +02:00
Jonas Jenwald
ec3d2be761 Introduce more optional chaining in the code-base
Also, use logical OR assignment a bit more.
2023-08-26 10:52:23 +02:00
Jonas Jenwald
598421b11f
Merge pull request #16856 from Snuffleupagus/limit-lineEndings
Exclude `lineEndings`, in Annotation-data, in MOZCENTRAL builds (PR 14899 follow-up)
2023-08-24 15:58:32 +02:00
calixteman
62a294bb52
Merge pull request #16864 from calixteman/issue16863
Don't reset all fields when the resetForm argument is an array
2023-08-24 09:56:11 -04:00
Calixte Denizet
24b480fabe Don't reset all fields when the resetForm argument is an array
correctly set the readonly property in the annotation layer and set the default checkbox value to Off when none is provided.
2023-08-24 09:10:27 -04:00
calixteman
08f26be7b4
Merge pull request #16862 from calixteman/revert_1838855
Revert fix for bug 1838855 (bug 1849876)
2023-08-23 13:23:59 -04:00
Calixte Denizet
ee3ac35e05 Revert fix for bug 1838855 (bug 1849876)
The issue described in the mentioned bug is reall because
Acrobat is rendering the XFA instead of the Acroform.
The original patch just tried to workaround the issue but it
induces some regressions.
2023-08-23 12:34:41 -04:00
Jonas Jenwald
847da21c95
Merge pull request #16858 from Snuffleupagus/stamp-aria-controls
Add the "aria-controls" attribute to the StampEditor toolbar-button
2023-08-23 17:17:52 +02:00
Jonas Jenwald
6da4fe5778
Merge pull request #16860 from Snuffleupagus/editorconfig-mjs
Add the `.mjs` file-extension to the EditorConfig
2023-08-23 17:16:50 +02:00
Jonas Jenwald
89779b3f6c Add the .mjs file-extension to the EditorConfig
Given that this file-extension is used for JavaScript modules, those files should obviously be formatted just like any "normal" JS file.
2023-08-23 11:22:25 +02:00
Jonas Jenwald
de52c98ddf Add the "aria-controls" attribute to the StampEditor toolbar-button
Given that the other Editor toolbar-buttons use this attribute, it seems that the StampEditor should as well.
2023-08-22 10:05:21 +02:00
Jonas Jenwald
cd181eb746 Exclude lineEndings, in Annotation-data, in MOZCENTRAL builds (PR 14899 follow-up)
This was added in PR 14899, over a year ago, however it's still completely unused in the PDF.js library/viewer. In hindsight I think that it was a mistake to add unused functionality, and the issue should probably have been WONTFIXed instead, however we probably can't just remove it now.
Thanks to the pre-processor, we can at least exclude this code in the *built-in* Firefox PDF Viewer.
2023-08-21 10:15:04 +02:00
Tim van der Meij
a7d829155b
Merge pull request #16852 from Snuffleupagus/less-workerPort
Initialize the `PDFWorker.#workerPorts` WeakMap lazily
2023-08-20 12:45:41 +02:00
Jonas Jenwald
988ce2820b Initialize the PDFWorker.#workerPorts WeakMap lazily
By default this WeakMap isn't needed, and it's simple enough to initialize it lazily instead.
2023-08-19 16:18:38 +02:00
Jonas Jenwald
2993c7725b [Firefox] Exclude more workerPort related code in MOZCENTRAL builds
Given that this code is (and has always been) unused in the Firefox PDF Viewer, we don't need to include it in that build-target.
2023-08-19 15:52:00 +02:00
Tim van der Meij
5828ac0ee3
Merge pull request #16834 from Snuffleupagus/globalWorkerPort-parallel-test
Add a unit-test for the "correct" way of using the global `workerPort` in parallel (PR 16830 follow-up)
2023-08-19 13:38:16 +02:00
Tim van der Meij
05fa7dcc7e
Merge pull request #16850 from Snuffleupagus/update-packages
Update packages and translations
2023-08-19 13:33:48 +02:00
Jonas Jenwald
d762986bb0 Update l10n files 2023-08-19 09:30:41 +02:00
Jonas Jenwald
4d19db0b19 Re-format the code to account for prettier and globals updates
The `prettier` update slightly changed the formatting of some await-expressions; please see https://github.com/prettier/prettier/blob/main/CHANGELOG.md#302

The `globals` update removed the need for some eslint-disable statements; please see https://github.com/sindresorhus/globals/releases/tag/v13.21.0
2023-08-19 09:30:34 +02:00
Jonas Jenwald
c5ebfa51a7 Update npm packages 2023-08-19 09:08:11 +02:00
Jonas Jenwald
60581c427e
Merge pull request #16844 from Snuffleupagus/StampEditor-isEmpty
Update the `StampEditor.isEmpty` method to handle File (PR 16828 follow-up)
2023-08-18 20:40:09 +02:00
Jonas Jenwald
520397e1e8
Merge pull request #16840 from Snuffleupagus/Stamp-#getBitmapFetched
Add a helper method to reduce duplication in `StampEditor.#getBitmap`
2023-08-18 20:38:55 +02:00
Jonas Jenwald
d513899fc7 Update the StampEditor.isEmpty method to handle File (PR 16828 follow-up)
After the changes in PR 16828 the `StampEditor` can now be initialized with a File, in addition to a URL, hence it seems that the `isEmpty` method ought to take that property into account as well.

Looking at this I also noticed that the assignment in the constructor may cause the `this.#bitmapUrl`/`this.#bitmapFile` fields be `undefined` which "breaks" the comparisons in the `isEmpty` method.
We could obviously fix those specific cases, but it seemed overall safer (with future changes) to just update the `isEmpty` method to be less sensitive to exactly how these fields are initialized and reset.
2023-08-17 09:25:58 +02:00
Jonas Jenwald
df9cb772d9 Add a helper method to reduce duplication in StampEditor.#getBitmap
Currently we're repeating virtually the same code *four times* when fetching the bitmap-data, which seems unnecessary.

Also, ensure that the `#bitmapPromise` is always `null`ed by moving that into the `StampEditor.#getBitmapDone` method.
2023-08-17 08:36:07 +02:00
Jonas Jenwald
c72cb5436d
Merge pull request #16835 from Snuffleupagus/improve-Annotation-compression-test
Improve the "write a new annotation, save the pdf and check that the text content is correct" unit-test (PR 16559 follow-up)
2023-08-15 16:44:18 +02:00
Jonas Jenwald
29b2050ac2 Improve the "write a new annotation, save the pdf and check that the text content is correct" unit-test (PR 16559 follow-up)
Currently this unit-test will pass just fine if compression is disabled, e.g. by commenting out the relevant code in the `src/core/writer.js` file.
While we don't have a simple way of *directly* checking that the Annotation text-content is compressed, we can however use the resulting file-size as a fairly good proxy. (Note that if compression is disabled the file-size is more than doubled.)
2023-08-15 15:12:17 +02:00
Jonas Jenwald
2422492ee3 Add a unit-test for the "correct" way of using the global workerPort in parallel (PR 16830 follow-up)
Please note that for performance reasons it's not really advised to use the same worker-thread *in parallel* for parsing multiple PDF documents, since they will then unnecessarily compete for resources.
However, given that it's still possible to do that e.g. when using the global `workerPort` it probably won't hurt to add a unit-test for this particular situation.
2023-08-15 12:45:54 +02:00
Tim van der Meij
8cf2f6d352
Merge pull request #16830 from Snuffleupagus/issue-16777-2
Avoid using the global `workerPort` when destruction has started, but not yet finished (issue 16777)
2023-08-13 12:18:28 +02:00
Tim van der Meij
43ab1d2da7
Merge pull request #16831 from Snuffleupagus/rm-no-babel-preset
Remove the "no-babel-preset" comment used with the LIB build-target (PR 16829 follow-up)
2023-08-13 12:09:43 +02:00
Jonas Jenwald
6669a99299 Remove the "no-babel-preset" comment used with the LIB build-target (PR 16829 follow-up)
Similar to the changes in PR 16829, this no longer seems necessary now.
2023-08-13 08:55:58 +02:00
Jonas Jenwald
66437917db Avoid using the global workerPort when destruction has started, but not yet finished (issue 16777)
Given that the `PDFDocumentLoadingTask.destroy()`-method is documented as being asynchronous, you thus need to await its completion before attempting to load a new PDF document when using the global `workerPort`.
If you don't await destruction as intended then a new `getDocument`-call can remain pending indefinitely, without any kind of indication of the problem, as shown in the issue.

In order to improve the current situation, without unnecessarily complicating the API-implementation, we'll now throw during the `getDocument`-call if the global `workerPort` is in the process of being destroyed.
This part of the code-base has apparently never been covered by any tests, hence the patch adds unit-tests for both the *correct* usage (awaiting destruction) as well as the specific case outlined in the issue.
2023-08-12 21:21:50 +02:00
Tim van der Meij
690b873897
Merge pull request #16829 from Snuffleupagus/gulpfile-rm-src-babel-excludes
Remove the `src/core/` Babel excludes, since they no longer seem necessary
2023-08-12 13:35:31 +02:00