Commit Graph

120 Commits

Author SHA1 Message Date
Tim van der Meij
b9b8cef04b
Merge pull request #10293 from wojtekmaj/babel-7
Upgrade to Babel 7
2018-11-23 23:36:58 +01:00
Wojciech Maj
b46ec5195f Update Babel to 7.x
Update configuration to work with Babel 7
Explicitly require globals - eslint-plugin-mozilla needs it, but doesn't require it on its own.
Fix Regexp to match Babel 7's inlined _interopRequireDefault
2018-11-23 14:32:17 +01:00
Wojciech Maj
01727e0fcc Replace UglifyJS with Terser 2018-11-23 12:18:36 +01:00
Tim van der Meij
2b5bc6bcec
Hide the beta version button on the website if there is only a stable version 2018-10-27 20:57:01 +02:00
Jonas Jenwald
694afcd60b Ensure that the built PdfJsDefaultPreferences.jsm file won't be affected/touched during tree-wide ESLint rule changes in mozilla-central (PR 9571 follow-up)
Also updates the edit warning, such that the wording is more consistent.
2018-08-28 23:46:54 +02:00
Jonas Jenwald
099ed08852 Add support for async/await using Babel
For proof-of-concept, this patch converts a couple of `Promise` returning methods to use `async` instead.
Please note that the `generic` build, based on this patch, has been successfully testing in IE11 (i.e. the viewer loads and nothing is obviously broken).

Being able to use modern JavaScript features like `async`/`await` is a huge plus, but there's one (obvious) side-effect: The size of the built files will increase slightly (unless `SKIP_BABEL == true`). That's unavoidable, but seems like a small price to pay in the grand scheme of things.

Finally, note that the `chromium` build target was changed to no longer skip Babel translation, since the Chrome extension still supports version `49` of the browser (where native `async` support isn't available).
2018-08-19 16:54:11 +02:00
Brendan Dahl
482ea2af32 Fail when MD5 of test files fails on bots. 2018-08-03 17:48:47 -07:00
Erik Nijland
26c734e493
fix(browser): zlib is not available in browser 2018-07-26 12:01:10 +02:00
Jonas Jenwald
a9ce4e8417 Stop exposing the URL polyfill in the global scope
This moves/exposes the `URL` polyfill similarily to the existing `ReadableStream` polyfill, rather than exposing it globally, to avoid interfering with any "outside" code.
Both the `URL` and `ReadableStream` polyfills are now exposed on the `pdfjsLib` object, such that they are accessible to the viewer components.
Furthermore, the `no-restricted-globals` ESLint rule is also enabled to prevent accidental usage of the native `URL`/`ReadableStream` implementations directly in the `src/` and `web/` folders; see also https://eslint.org/docs/rules/no-restricted-globals

Addresses the remaining TODO in https://github.com/mozilla/pdf.js/projects/6
2018-07-04 09:16:28 +02:00
RonLek
efb8f54fa1 Error Handling for Downloaded Files 2018-06-29 21:52:10 +05:30
Tim van der Meij
14b69a4c1c
Merge pull request #9729 from Snuffleupagus/gulp-image_decoders
Add a `gulp image_decoders` command to package the image decoders (i.e. jpg.js, jpx.js, jbig2.js) separately, and publish them in pdfjs-dist
2018-06-26 23:27:32 +02:00
eugenesqr
331ac8ae74 removed safari compatibility check 2018-06-21 12:57:56 +03:00
Jonas Jenwald
303537bcb1 Add a gulp image_decoders command to allow packaging/distributing the image decoders (i.e. jpg.js, jpx.js, jbig2.js) separately from the main PDF.js library
Please note that the standalone `pdf.image_decoders.js` file will be including the complete `src/shared/util.js` file, despite only using parts of it.[1] This was done *purposely*, to not negatively impact the readability/maintainability of the core PDF.js code.

Furthermore, to ensure that the compatibility is the same in the regular PDF.js library *and* in the the standalone image decoders, `src/shared/compatibility.js` was included as well.

To (hopefully) prevent future complaints about the size of the built `pdf.image_decoders.js` file, a few existing async-related polyfills are being skipped (since all of the image decoders are completely synchronous).
Obviously this required adding a couple of pre-processor statements, but given that these are all limited to "compatibility" code, I think this might be OK!?

---
[1] However, please note that previous commits moved `PageViewport` and `MessageHandler` out of `src/shared/util.js` which reduced its size.
2018-06-16 17:56:54 +02:00
Jonas Jenwald
4b69bb7fe9 Add a TESTING build option, to enable using non-production/test-only code-paths
Since the tests (currently) run with the `pdf.worker.js` file built, i.e. with `PRODUCTION = true` set, there's no simple way to add e.g. `assert` calls for both non-production *and* test-only builds without also affecting PRODUCTION builds.
2018-06-12 11:01:32 +02:00
Tim van der Meij
76337fdc49
Merge pull request #9777 from Snuffleupagus/PageViewport-MessageHandler-cleanup
Various `PageViewport` and `MessageHandler` cleanup
2018-06-04 23:28:41 +02:00
Tim van der Meij
3e5ec41045
Remove dead code in the gh-pages-prepare task in the Gulpfile 2018-06-04 22:54:28 +02:00
Jonas Jenwald
f486051d77 Explicitly list the ignored files in the src/shared/ folder, for the gulp lib build target
To avoid having to manually update the "shared files" list in `gulpfile.js`, whenever any changes are made to the file structure in the `src/shared/` folder, let's simply list the files we do *not* want instead.
Given that the excluded files have been consistent ever since the `lib` build target was added, this patch should help avoid unnecessary churn in `gulpfile.js` in the future.
2018-06-04 12:53:07 +02:00
Tim van der Meij
a816ee5c25
Upgrade to Webpack 4 2018-06-02 20:28:36 +02:00
Tim van der Meij
32de419a88
Remove the gulp extension build target 2018-06-02 19:56:09 +02:00
Brendan Dahl
548b4ca208 Fix webpack exclude path on windows. 2018-05-29 17:43:02 -07:00
Abhimanyu Vashisht
58612f869a Replace deprecated new Buffer(string) constructor with Buffer.from(string) 2018-05-20 20:42:50 +05:30
Wojciech Maj
acd1fa4c4f Configure Autoprefixer 2018-04-04 23:02:26 +02:00
Wojciech Maj
ed67c1d6aa Introduce autoprefixer to gulp process 2018-04-04 00:26:01 +02:00
Brendan Dahl
121e43685f Remove the Firefox extension building code.
Firefox no longer supports this legacy extension and it is a pain to
sync changes from here and mozilla central.
2018-03-30 16:27:50 -07:00
Tim van der Meij
6cc0efe1cc
Merge pull request #9576 from timvandermeij/versions
Update packages
2018-03-25 17:52:26 +02:00
Tim van der Meij
95de23e6e3
Update packages
Jasmine had a major version bump and required a few minor changes in our
booting code. Most notably, using `pending` in a `describe` block is no
longer supported, so we can only return early there. On the positive
side, the unit tests now run in a random order by default, which
eliminates any dependencies between unit tests.

Note that upgrading to Webpack 4 is out of scope for this patch since
the bots cannot work well with the newly generated bundles (both
browsers on both bots do not react within 120 seconds). Webpack 4 is not
faster for us than Webpack 3, so for now there is no need to upgrade.
2018-03-25 16:59:50 +02:00
Brendan Dahl
0aa31a493b Add new line to default preferences. 2018-03-20 16:36:37 -07:00
Brendan Dahl
63c7aee112
Merge pull request #9565 from brendandahl/new-name
Rename the globals to shorter names.
2018-03-20 13:49:04 -07:00
Brendan Dahl
01bff1a81d Rename the globals to shorter names.
pdfjsDistBuildPdf=pdfjsLib
pdfjsDistWebPdfViewer=pdfjsViewer
pdfjsDistBuildPdfWorker=pdfjsWorker
2018-03-16 11:08:56 -07:00
Jonas Jenwald
76250b923f [Firefox addon] Refactor bundling of the default_preferences.json file 2018-03-16 16:46:57 +01:00
Jonas Jenwald
b8606abbc1 [api-major] Completely remove the global PDFJS object 2018-03-01 18:13:27 +01:00
Rob Wu
9d55a1edc7 Ignore managed prefs documented as "Deprecated."
Deprecated keys are removed from web/default_preferences.json,
but still maintained in managed_preferences.json.
2018-02-22 14:40:30 +01:00
Jonas Jenwald
c56f3f04dd [api-major] Remove the SINGLE_FILE build target
Please note that this build target, and the resulting `build/pdf.combined.js` file, is equivalent to setting the `PDFJS.disableWorker` option to `true` which is a performance footgun.
2018-01-29 14:44:44 +01:00
Jonas Jenwald
0e1b5589e7 Restore the btoa/atob polyfills for Node.js
These were removed in PR 9170, since they were unused in the browsers that we'll support in PDF.js version `2.0`.
However looking at the output of Travis, where a subset of the unit-tests are run using Node.js, there's warnings about `btoa` being undefined. This doesn't appear to cause any errors, which probably explains why we didn't notice this before (despite PR 9201).
2018-01-13 01:31:05 +01:00
Tim van der Meij
d688b8ea31
Stop using the deprecated gulp-util module
The `gulp-util` module is now deprecated and authors are asked to stop
using it (refer to https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 for
more information).

PDF.js does not rely on it that much, fortunately, so it's relatively
easy for us to remove the dependency. This patch does that by making the
following changes:

- Require `gulp-zip` version 4.1.0 or higher since they already removed
  their `gulp-util` dependency in that version.
- Replace `gulp-util.log` with the `fancylog` module as recommended in
  the article above.
- Replace `gulp-util.File` with the `Vinyl` module as recommended in the
  article above.

The only change I had to make for Vinyl is removing the `base` and `cwd`
lines since they may not be empty strings anymore. This way we fall back
to the defaults Vinyl provides, which for us doesn't matter since we
move the file afterwards anyway. Moreover, I used `vfs` for `vinyl-fs`
in the `Gulpfile` to avoid confusion with `vinyl` (which is also how the
documentation names the variable).

This is all we can do on our side; the other modules that still use
`gulp-util` must be updated upstream.
2017-12-30 20:13:52 +01:00
Soumya Himanish Mohapatra
95ad956f68 PDFjs now compatible with Librejs 2017-12-19 15:13:50 +05:30
Michaël De Boey
e3324d45bc
'worker-loader' requires 'webpack' as peerDependency 2017-12-07 23:10:12 +01:00
Jonas Jenwald
f0c98a7ab0 [api-major] Stop bundling, and also remove, the web/compatibility.js file in pdfjs-dist
As suggested in PR 8102.
2017-10-31 22:32:43 +01:00
Yury Delendik
b4e25fb2e8 Merge remote-tracking branch 'mozilla/version-2.0' into v2 2017-10-27 14:01:45 -05:00
Tim van der Meij
7d7edd9cc6
[api-major] Remove the PDFJS_NEXT option
Nothing uses this option anymore, so setting it is a no-op now. We can
safely remove it.

Use `SKIP_BABEL` (instead of `PDFJS_NEXT`) now if you want to skip Babel
translation for a build.
2017-10-16 23:16:51 +02:00
Jonas Jenwald
04b46831c1 Enable the --report-unused-disable-directives ESLint command line option
This option was added in [version `4.8.0` of ESLint](https://github.com/eslint/eslint/releases/tag/v4.8.0), which is already listed as the minimum version in our `package.json` file; please refer to https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives for additional details.

Despite the caveat listed in the link above, I still think that using this option makes sense since it will help ensure that no longer necessary disable statements are removed.
2017-10-15 13:45:12 +02:00
Tim van der Meij
0733b54e10
Update all packages to the most recent version
To support this, the following changes have to be made as well:

- Ignore `package-lock.json` since NPM creates it, but we should not
  have it in the repository.
- Switch from `babel-preset-es2015` to `babel-preset-env` to resolve
  the deprecation warning in the test logs. The latter is more recent
  and flexible, but should be the same functionality-wise.
- `transform` now needs to have the `utf-8` encoding option provided.
  If not given, it will call the callback with a `Buffer` object,
  which results in an unhandled promise rejection since what is
  returned from the callback is a string, not a `Buffer`.
2017-09-30 16:26:24 +02:00
Jonas Jenwald
1a3c6f7d9a Simplify the disabling of Node polyfills, in gulpfile.js, since we're now using Webpack 3.x
Webpack was updated a while back, but we apparently forgot to update `gulpfile.js` as well.
2017-09-29 21:45:14 +02:00
Jonas Jenwald
1ebbdc253a Use the SimpleLinkService when running "annotations" reference tests
Rather than (basically) duplicating the `SimpleLinkService` in `test/driver.js`, with potential test failuires if you forget to update the test mock, it seems much nicer to just re-use the viewer component.

Note that `SimpleLinkService` is already bundled into the `build/components/pdf_viewer.js` file. Hence we only need to expose it similar to the other viewer components in that file, and make sure that the `gulp components` command runs as part of the test-setup.
2017-09-12 15:24:46 +02:00
Jonas Jenwald
70e80322da Update the gulp minified command to use uglify-es
By updating to uglify-es, rather than uglify-js, the minifier *itself* now supports ES6 code. This means that it's now possible to minify code built with `PDFJS_NEXT = true` set, i.e. with Babel transpilation disabled, which wasn't the case previously.

Note that uglify-es is based on the API of uglify-js v3, which differs from the one that we previously used.
Of particular importance is the fact that it's no longer possible to provide a path to a file for minification, but one must instead directly provide the source of the file.

For more information, please see https://github.com/mishoo/UglifyJS2/tree/harmony
2017-08-27 15:31:04 +02:00
Yury Delendik
4e6ae18f19 Disable node libs in pdfjs-dist package.json 2017-08-24 10:57:18 -05:00
Yury Delendik
57bc3296f4 Moves global scope out of shared/util. 2017-08-22 18:20:52 -05:00
Yury Delendik
01b47d9012 Use streams-lib as polyfill 2017-07-28 11:54:33 -05:00
Rob Wu
01f03fe393 Optimize PNG compression in SVG backend on Node.js
Use the environment's zlib implementation if available to get
reasonably-sized SVG files when an XObject image is converted to PNG.
The generated PNG is not optimal because we do not use a PNG predictor.
Futher, when our SVG backend is run in a browser, the generated PNG
images will still be unnecessarily large (though the use of blob:-URLs
when available should reduce the impact on memory usage). If we want to
optimize PNG images in browsers too, we can either try to use a DEFLATE
library such as pako, or re-use our XObject image painting logic in
src/display/canvas.js. This potential improvement is not implemented by
this commit

Tested with:

- Node.js 8.1.3 (uses zlib)
- Node.js 0.11.12 (uses zlib)
- Node.js 0.10.48 (falls back to inferior existing implementation).
- Chrome 59.0.3071.86
- Firefox 54.0

Tests:

Unit test on Node.js:

```
$ gulp lib
$ JASMINE_CONFIG_PATH=test/unit/clitests.json node ./node_modules/.bin/jasmine --filter=SVG
```

Unit test in browser: Run `gulp server` and open
http://localhost:8888/test/unit/unit_test.html?spec=SVGGraphics

To verify that the patch works as desired,

```
$ node examples/node/pdf2svg.js test/pdfs/xobject-image.pdf
$ du -b svgdump/xobject-image-1.svg
 # ^ Calculates the file size. Confirm that the size is small
 #   (784 instead of 80664 bytes).
```
2017-07-10 18:56:57 +02:00
Rob Wu
742ed3d1c9 Remove __pdfjsdev_webpack__, use webpack options
`__pdfjsdev_webpack__` was used to skip evaluating part of an AST,
in order to not mangle some `require` symbols.
This commit removes `__pdfjsdev_webpack__`, and:

- Uses `__non_webpack_require__` when one wants the output to
  contain `require` instead of `__webpack_require__`.
- Adds options to the webpack config to prevent "polyfills" for
  some Node.js-specific APIs to be added.
- Use `// eslint-disable-next-line no-undef` instead of `/* globals ... */`
  for variables that are not meant to be used globally.
2017-07-09 16:35:48 +02:00