Commit Graph

62 Commits

Author SHA1 Message Date
Calixte Denizet
29de9bdce6 Format json files in using prettier 2024-01-16 19:40:25 +01:00
Jonas Jenwald
c5a69544af Update npm packages 2024-01-06 10:09:12 +01:00
Jonas Jenwald
3793a56116 Update npm packages 2023-12-23 12:29:51 +01:00
Calixte Denizet
ff23d37fa2 [Editor] Add a color picker with predefined colors for highlighting text (bug 1866434)
The doorhanger for highlighting has a basic color picker composed of 5 predefined colors
to set the default color to use.
These colors can be changed thanks to a preference for now but it's something which could
be changed in the Firefox settings in the future.
Each highlight has in its own toolbar a color picker to just change its color.
The different color pickers are so similar (modulo few differences in their styles) that
this patch introduces a new class ColorPicker which provides a color picker component
which could be reused in future editors.
All in all, a large part of this patch is dedicated to color picker itself and its style
and the rest is almost a matter of wiring the component.
2023-12-05 23:27:22 +01:00
Tim van der Meij
7381515e20
Update dependencies to the most recent versions 2023-11-25 17:25:35 +01:00
Calixte Denizet
53101b379b Restore the option to set light/dark mode for chromium and generic builds 2023-11-18 21:32:25 +01:00
Jonas Jenwald
1f9533bae9 Re-factor the L10n-implementations to use lowercase language-codes internally
This is consistent with the implementation used in the (now removed) webL10n-library, and by only using lowercase language-codes internally in the `L10n`-implementations we should avoid future issues e.g. when users manually set the `locale`-option (in the default viewer).
2023-11-13 21:06:03 +01:00
Tim van der Meij
8157f39c62
Introduce a GitHub Actions workflow for running the font tests
This commit migrates the font tests away from the bots. Not only are the
font tests broken on the Windows bot since some time, they also run on
Python 2 (end of life since January 2020) and `ttx` 3.19.0 (released in
November 2017). The latter is installed via a submodule, which requires
more complicated logic for finding and running `ttx`.

We solve the issues by implementing a modern workflow that installs the
most recent stable Python and `ttx` (`fonttools` package) versions. This
simplifies the `ttx` driver code as well because it can now assume `ttx`
is available on the path (just like we do for e.g. `node` invocations).
GitHub Actions takes care of creating a virtual environment with
`fonttools` in it so that the `ttx`  entrypoint is available. Locally
the font tests can be run in a similar way by creating and sourcing a
virtual environment with `fonttools` in it before running the font
tests, and a README file is included with instructions for doing so.
2023-11-12 17:48:04 +01:00
Tim van der Meij
69452bb60e
Implement optionally running the tests in headless mode
This commit prepares for running the font tests on GitHub Actions where
we can't spin up headful browsers because there are no display
capabilities on the workers. This will also be useful for porting other
test targets to GitHub Actions at a later time, as well as running the
tests locally in headless mode.
2023-11-12 17:48:04 +01:00
Jonas Jenwald
5687326046 Clean-up the CI workflow a bit
After recent PRs the size and scope of the CI workflow is now reduced, and this patch tries to simplify things further. More specifically we can directly specify the gulp-tasks in the workflow, and thus clean-up the `gulpfile` a tiny bit.

Note that this will technically be slower, since the tests are now run in series (rather than in parallel), however `gulp externaltest` runs so quickly that it really won't matter in practice.
2023-11-12 13:48:02 +01:00
Jonas Jenwald
d89ca97887 Move gulp typestest to a separate GitHub Actions workflow
This way we introduce more parallelism in the GitHub Actions tests, which should reduce overall runtime and thus cannot hurt.
2023-11-12 13:27:29 +01:00
Tim van der Meij
e0e5be2c62
Merge pull request #17267 from Snuffleupagus/lint-workflow
Move linting to a separate GitHub Actions workflow
2023-11-12 13:08:26 +01:00
Tim van der Meij
290b483167
Merge pull request #17255 from Snuffleupagus/issue-17228
Ensure that the viewer waits for the library to complete loading (issue 17228)
2023-11-12 13:02:34 +01:00
Tim van der Meij
2869b63800
Merge pull request #17252 from tamuratak/to_mts
Rename *.d.ts to *.d.mts
2023-11-12 13:00:44 +01:00
Jonas Jenwald
2f70369d02 Move linting to a separate GitHub Actions workflow
This way we introduce more parallelism in the GitHub Actions tests, which should reduce overall runtime and thus cannot hurt.
2023-11-12 10:21:29 +01:00
Takashi Tamura
61ed77cfb4 Rename *.d.ts to *.d.mts. Close #17241
Add a type test for legacy.

- https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution
2023-11-12 07:30:36 +09:00
Calixte Denizet
334f0eb060 [Editor] Add a toolbar to selected editors with a button to delete it (bug 1863763) 2023-11-10 15:19:43 +01:00
Jonas Jenwald
823d375b8b Ensure that the viewer waits for the library to complete loading (issue 17228)
This should *hopefully* fix 17228, by tweaking the build scripts to give the GENERIC viewer something to await to avoid breaking third-party users of the standalone viewer components.
2023-11-10 13:22:49 +01:00
Jonas Jenwald
e0898a7ee3 Update npm packages
The new major version of `gulp-zip` shouldn't be a problem, given the changes listed in https://github.com/sindresorhus/gulp-zip/releases/tag/v6.0.0
2023-11-04 09:47:31 +01:00
Jonas Jenwald
eebc230cf1 [Firefox] Fetch browser preferences/options together with the viewer preferences (bug 1862192)
Currently we *synchronously* fetch a number of browser preferences/options, from the platform code, during the viewer respectively PDF document initialization paths.
This seems unnecessary, and we can re-factor the code to instead include the relevant data when fetching the regular viewer preferences.
2023-10-31 15:32:01 +01:00
Tim van der Meij
ecba5b7c6d
Update dependencies to the most recent versions 2023-10-29 14:22:30 +01:00
Jonas Jenwald
d7b39fe696 Update the webpack example to account for outputting of JavaScript modules (PR 17055 follow-up)
*Please note:* While following the steps in the README still works with this patch, in the sense that the example runs and successfully renders a PDF document, I unfortunately cannot tell if it illustrates Webpack best practices.
2023-10-28 10:26:34 +02:00
Calixte Denizet
31cfec63c3 Update locale on *.ftl change 2023-10-23 14:03:31 +02:00
Jonas Jenwald
f07675a6a8 [api-minor] Re-factor NullL10n and remove the hard-coded l10n strings (PR 17115 follow-up)
*Please note:* These changes only affect the GENERIC build, since `NullL10n` is only a stub elsewhere (see PR 17135).

After the changes in PR 17115, which modernized and improved l10n-handling, the `NullL10n`-implementation is no longer a good fallback for the "proper" `L10n`-classes.
To improve this situation, especially for the *standalone* viewer-components, this patch makes the following changes:
 - Let the `NullL10n`-implementation extend an actual `L10n`-class, which is constant and lazily initialized, to ensure that it works *exactly* like the "proper" ones.

 - Automatically bundle the "en-US" l10n-strings in the build, via the pre-processor, such that we don't need to remember to manually update them.

 - Ensure that the *standalone* viewer-components register their DOM-elements for translation, similar to the default viewer, since this will allow future code improvements by using "data-l10n-id"/"data-l10n-args" in most (if not all) parts of the viewer.

 - Remove the `NullL10n` from the `AnnotationLayer`, to avoid affecting bundle size too much.
   For third-party users that access the `AnnotationLayer`, as exposed in the main PDF.js library, they'll now need to *manually* register it for translation. (However, the *standalone* viewer-components still works given the point above.)
2023-10-20 21:49:33 +02:00
Jonas Jenwald
c60401a765
Merge pull request #17133 from Snuffleupagus/rm-builder-merge
Use object destructuring, rather than the `merge` helper, in the gulpfile
2023-10-19 15:41:40 +02:00
Jonas Jenwald
69ad0d9861 Only bundle NullL10n in GENERIC builds (bug 1859818) 2023-10-19 13:51:00 +02:00
Calixte Denizet
66982a2a11 [api-minor] Move to Fluent for the localization (bug 1858715)
- For the generic viewer we use @fluent/dom and @fluent/bundle
- For the builtin pdf viewer in Firefox, we set a localization url
  and then we rely on document.l10n which is a DOMLocalization object.
2023-10-19 11:20:41 +02:00
Jonas Jenwald
ae664ea8e0 Use object destructuring, rather than the merge helper, in the gulpfile
This helper function was originally added in PR 1953, eleven years ago, at which point object destructuring didn't exist.
2023-10-18 13:49:26 +02:00
Tim van der Meij
5c45dfa0ae
Merge pull request #17119 from timvandermeij/updates
Update translations/dependencies to the most recent versions and fix dependency vulnerabilities
2023-10-14 14:36:25 +02:00
Tim van der Meij
58e4fcdc6f
Remove obsolete src/shared/{cffStandardStrings,fonts_utils}.js files
Those files only contain old debugging code that is not used/imported
anywhere anymore, which is generating code scanning alerts. Moreover,
they rely on globals/platform-specific code and don't import/export
logic properly.
2023-10-14 14:07:49 +02:00
Tim van der Meij
e1307fdba8
Update dependencies to the most recent versions 2023-10-14 13:50:19 +02:00
Jonas Jenwald
38245500fd Output JavaScript modules for the LIB build-target (PR 17055 follow-up)
This *finally* allows us to mark the entire PDF.js library as a "module", which should thus conclude the (multi-year) effort to re-factor and improve how we import files/resources in the code-base.

This also means that the `gulp ci-test` target, which is what's run in GitHub Actions, now uses JavaScript modules since that's supported in modern Node.js versions.
2023-10-13 18:54:33 +02:00
Jonas Jenwald
6ac3da0d1f Rename web/debugger.js since it's actually a JavaScript module (PR 17055 follow-up)
It's been loaded as a JavaScript module for a long time, and given that the file is bundled as-is (without building) it seems reasonable to just change the file extension now.
2023-10-08 13:16:42 +02:00
Jonas Jenwald
8bd3cc0313 [api-minor] Stop polyfilling structuredClone in legacy builds
Comparing the currently supported browsers/environments, see [the FAQ](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support) and the [MDN compatibility data](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility), the `structuredClone` polyfill is *only* needed in Google Chrome versions < 98. Because of some limitations in the core-js polyfill we're currently forced to special-case the `transfer` handling to prevent bugs, and it'd be nice to avoid that.

Note that `structuredClone`, with transfers, is only used in two spots:
 - The `LoopbackPort` class, which is only used with fake workers. Given that fake workers should *never* be used in browsers, breaking that edge-case in older Google Chrome versions seem fine.
 - The `AnnotationStorage` class, when Stamp-annotations have been added to the document. Given that Google Chrome isn't the main focus of development, breaking *part* of the editing-functionality in older Google Chrome versions should hopefully be acceptable.
2023-10-07 16:52:47 +02:00
Jonas Jenwald
4b489cd4e6 Output pdf.scripting.js as a JavaScript module (PR 17055 follow-up)
To avoid problems with `export` statements in the QuickJS Javascript Engine, we can work-around that by *explicitly* exposing `pdfjsScripting` globally instead.
2023-10-07 15:27:26 +02:00
Jonas Jenwald
927e50f5d4 [api-major] Output JavaScript modules in the builds (issue 10317)
At this point in time all browsers, and also Node.js, support standard `import`/`export` statements and we can now finally consider outputting modern JavaScript modules in the builds.[1]

In order for this to work we can *only* use proper `import`/`export` statements throughout the main code-base, and (as expected) our Node.js support made this much more complicated since both the official builds and the GitHub Actions-based tests must keep working.[2]
One remaining issue is that the `pdf.scripting.js` file cannot be built as a JavaScript module, since doing so breaks PDF scripting.

Note that my initial goal was to try and split these changes into a couple of commits, however that unfortunately didn't really work since it turned out to be difficult for smaller patches to work correctly and pass (all) tests that way.[3]
This is a classic case of every change requiring a couple of other changes, with each of those changes requiring further changes in turn and the size/scope quickly increasing as a result.

One possible "issue" with these changes is that we'll now only output JavaScript modules in the builds, which could perhaps be a problem with older tools. However it unfortunately seems far too complicated/time-consuming for us to attempt to support both the old and modern module formats, hence the alternative would be to do "nothing" here and just keep our "old" builds.[4]

---
[1] The final blocker was module support in workers in Firefox, which was implemented in Firefox 114; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility

[2] It's probably possible to further improve/simplify especially the Node.js-specific code, but it does appear to work as-is.

[3] Having partially "broken" patches, that fail tests, as part of the commit history is *really not* a good idea in general.

[4] Outputting JavaScript modules was first requested almost five years ago, see issue 10317, and nowadays there *should* be much better support for JavaScript modules in various tools.
2023-10-07 09:31:08 +02:00
Jonas Jenwald
8158628a90 [api-minor] Stop building a minified default viewer
The minified default viewer has never been distributed in either official releases or through pdfjs-dist, which means that it's most likely unused, and it's has never been tested nor actively maintained.
2023-10-06 12:12:30 +02:00
Jonas Jenwald
3ced0dec1b [api-major] Remove the SVG back-end (PR 15173 follow-up)
This has been deprecated since version `2.15.349`, which is a year ago.
Removing this will also simplify some upcoming changes, specifically outputting of JavaScript modules in the builds.
2023-10-01 23:14:29 +02:00
Calixte Denizet
0d9aef1a5e Add alt-text svg images to the dist (issue #17044) 2023-10-01 16:47:34 +02:00
Jonas Jenwald
7413546e16 Remove comments from the *built* CSS files
The old pre-processor used for CSS, and HTML, files leaves comments intact which unnecessarily contributes to the overall size of the *built* CSS files (note that the built JavaScript files don't include comments).
Rather than trying to "hack" comment removal into the pre-processor it seems easier to use a PostCSS plugin instead. The one potential issue is that it also affects *some* whitespaces, and it's not clear to me if this'll work with the various CSS-related tests that run in mozilla-central.

Please refer to https://www.npmjs.com/package/postcss-discard-comments for additional information.
2023-09-26 13:38:26 +02:00
Jonas Jenwald
5711d0f95d [GeckoView] Exclude annotation_editor_layer_builder.css in the build (issue 16994)
Given the limitations of the old pre-processor that's used for CSS/HTML files, this unfortunately isn't as "easy" to implement as it is for JavaScript code.
Since this is the first case where we've wanted to do conditional CSS imports, rather than trying to completely re-write the pre-processor, this patch settles for handling it explicitly in the `expandCssImports` function.
2023-09-21 15:51:33 +02:00
Jonas Jenwald
e2b7896826 [GeckoView] Avoid bundling the AltTextManager class, since it's unused 2023-09-21 12:51:34 +02:00
Tim van der Meij
f42d70a24e
Update packages 2023-09-09 17:53:43 +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
c5ebfa51a7 Update npm packages 2023-08-19 09:08:11 +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
1810191be2 Remove the src/core/ Babel excludes, since they no longer seem necessary
- The `src/core/unicode.js` exclude ought to have become unnecessary already with PR 16200, which significantly shortened and simplified that file.
 - The `src/core/glyphlist.js` exclude no longer seems necessary in practice either, possibly because of improvements in Babel.
2023-08-12 10:09:03 +02:00
Calixte Denizet
aa71619c2d [Editor] Fix the resizing of an editor when it's rotated (bug 1847268)
There are 2 rotation we've to deal with: the viewer one and the editor one.
The previous implementation was a bit complex and having to deal with these
rotation would have potentially increase it.
So this patch aims to simplify the implementation and deal with all the possible
cases.
The main idea is to transform the mouse deltas according to the rotations and then
apply the resizing in the page coordinates system.
2023-08-08 12:54:12 +02:00