Commit Graph

79 Commits

Author SHA1 Message Date
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
Yury Delendik
a18caa730d Adds gulp dist-install command; using pdfjs-dist package in examples. 2017-06-12 10:22:16 -05:00
Jonas Jenwald
4a906955c4 Fix the remaining cases of inconsistent spacing and trailing commas in objects, and enable the comma-dangle and object-curly-spacing ESLint rules
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing

*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.

```diff
diff --git a/gulpfile.js b/gulpfile.js
index d18b9c58..7d47fd8d 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1247,7 +1247,8 @@ gulp.task('gh-pages-git', ['gh-pages-prepare', 'wintersmith'], function () {
   var reason = process.env['PDFJS_UPDATE_REASON'];

   safeSpawnSync('git', ['init'], { cwd: GH_PAGES_DIR, });
-  safeSpawnSync('git', ['remote', 'add', 'origin', REPO], { cwd: GH_PAGES_DIR, });
+  safeSpawnSync('git', ['remote', 'add', 'origin', REPO],
+                { cwd: GH_PAGES_DIR, });
   safeSpawnSync('git', ['add', '-A'], { cwd: GH_PAGES_DIR, });
   safeSpawnSync('git', [
     'commit', '-am', 'gh-pages site created via gulpfile.js script',
```
2017-06-03 23:35:37 +02:00
Jonas Jenwald
45933545f1 Merge pull request #8394 from yurydelendik/l10n
Wraps mozL10n to async calls; splits firefox and generic l10n libs.
2017-05-31 17:31:22 +02:00
Yury Delendik
5438ce9b98 Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
Yury Delendik
bd288df909 Merge pull request #8396 from mukulmishra18/streams-lib
Adds streams-lib polyfill and exports ReadableStream from shared/util.
2017-05-31 08:42:48 -05:00
Jonas Jenwald
7d3a3252b5 Allow specifying the PDFJS_NEXT build flag via an environment variable when running the various gulp commands
After PR 8459, the run-time of the various `gulp` test commands has regressed quite badly on Windows. For me, `gulp test` now takes approximately *twice* as long when run locally on Windows.
The problem seems to be the Babel transpilation step, which takes well over five minutes to run.[1]

For someone like me, who runs tests a lot locally, this slowdown is really hurting the overall development experience.
To get around this I tested setting `PDFJS_NEXT = true` in `gulpfile.js`, since the transpilation step isn't necessary when testing in a modern browser.

However, having to edit `gulpfile.js` every time that I need to run tests isn't very practical. Hence this patch, which adds an environment variable that allows you to disable the transpilation simply by using e.g. `PDFJS_NEXT=true gulp test`.

I hope that this can be considered an acceptable solution, such that I don't need to maintain this patch locally (or worse, edit `gulpfile.js` locally before testing).

---
[1] This can also be observed on the Windows bot, but it seems fine on Linux.
2017-05-31 14:50:49 +02:00
Yury Delendik
66c8893815 Removes last UMDs from the modules. 2017-05-31 07:14:17 -05:00
Yury Delendik
b66b705ed7 Using pre-built code for testing. 2017-05-30 22:06:21 +02:00
Jonas Jenwald
957dc40ddf Replace a couple of leftover make.js references with gulpfile.js in docs/comments
Also updates a `console.log` statement in the `gulp importl10n` command (since I forgot it in a previous patch, and it didn't seem necessary with a separate patch for it).
2017-05-19 23:45:54 +02:00
Mukul Mishra
c9f44f30e5 Adds streams-lib polyfill and exports ReadableStream from shared/util.
Added test for ReadableStream.

Adds ref-implementation license-header in streams-lib
and change gulp task to copy external/streams/ in build/
external/streams/ and build/dist/external/streams folder.

Adds README.md and LICENSE.md
2017-05-20 00:26:34 +05:30
Yury Delendik
996805f953 Produces source maps for built files. 2017-05-05 08:15:21 -05:00
Yury Delendik
c9d3c20e2c Fix esprima tests. 2017-05-04 08:24:44 -05:00
Yury Delendik
2ac410625b Fixes shell parameters quoting after #8349 2017-05-03 08:17:31 -05:00
Tim van der Meij
0c99429291 Merge pull request #8349 from timvandermeij/remove-make
Migrate `make.js` to `gulpfile.js`
2017-05-02 01:12:56 +02:00
Tim van der Meij
f748407b26
Remove make.js and the target fetching in gulpfile.js
Note that we have to use `fs.writeFileSync` since `.to()` is not
available anymore. Moreover, introduce `safeSpawnSync` to make sure that
we check the return codes of the spawned processes properly.
2017-05-02 01:00:52 +02:00
Tim van der Meij
145c0cea39
Remove unused Gulp target for testing
To run the regression tests, developers use `gulp browsertest` and the
bot uses `gulp bottest`. We're not passing the `noreftest` option
anywhere in the code (probably because the `bottest` command takes care
of this already), so we should remove this.
2017-05-02 00:47:53 +02:00
Tim van der Meij
19cc9bcded
Port the mozcentraldiff target to Gulp 2017-05-02 00:47:51 +02:00
Tim van der Meij
74854fb4cc
Port the mozcentralbaseline target to Gulp
The baseline fix is dead code since three years, so we can safely remove
it.
2017-05-02 00:45:52 +02:00
Jonas Jenwald
7560f12a17 Enable the object-shorthand ESLint rule
Please see http://eslint.org/docs/rules/object-shorthand.

Unfortunately, based on commit 9276d1dcd9, it seems that we still need to maintain compatibility with old Node.js versions, hence certain files/directories that are executed in Node.js are currently exempt from this rule.

Furthermore, since the files specific to the Chromium extension are not run through Babel, the `/extensions/chromium/` directory is also exempt from this rule.
2017-04-30 11:13:34 +02:00
Yury Delendik
140dd0f15b Removes builder.build(). 2017-04-28 12:47:20 -05:00
Yury Delendik
9276d1dcd9 Allow older versions on node.js to run gulpfile. 2017-04-28 09:20:21 -05:00
Jonas Jenwald
b3582ccbad Add the commit hash to the README.mozilla file (issue 8347) 2017-04-27 23:01:22 +02:00
Jonas Jenwald
ae04cf1c37 Enable running the ui_utils unit-tests on Travis
With the exception of just one test-case, all the current `ui_utils` unit-tests can run successfully on Node.js (since most of them doesn't rely on the DOM).

To get this working, I had to first of all add a new `LIB` build flag such that `gulp lib` produces a `web/pdfjs.js` file that is able to load `pdf.js` successfully.
Second of all, since neither `document` nor `navigator` is available in Node.js, `web/ui_utils.js` was adjusted slightly to avoid errors.
2017-04-25 13:37:56 +02:00
Jonas Jenwald
a77130a0c2 Remove the signchromium target from make.js
According to the IRC discussion starting at http://logs.glob.uno/?c=mozilla%23pdfjs&s=18+Apr+2017&e=18+Apr+2017#c59676, and in particular http://logs.glob.uno/?c=mozilla%23pdfjs&s=18+Apr+2017&e=18+Apr+2017#c59682, this build target is unused and can thus be removed.
2017-04-19 23:13:16 +02:00
Yury Delendik
1d30cea914 Moves dist and minifiedpost tragets from make.js. 2017-04-18 14:00:53 -05:00
Tim van der Meij
27c3c33eec Merge pull request #8288 from yurydelendik/mv-make-web
Moves 'web' target to the gulpfile.
2017-04-15 00:03:29 +02:00
Yury Delendik
89df5ef033 Moves 'web' target to the gulpfile. 2017-04-14 16:57:53 -05:00
Yury Delendik
5855c0a8be Allow to convert (some of) ES6 code to ES5. 2017-04-14 14:39:25 -05:00
Yury Delendik
46646a9dd1 Merge pull request #8131 from timvandermeij/remove-umd-validation
ES6 modules: remove UMD header validation
2017-04-13 10:49:41 -05:00
Georg Fritzsche
4e8cd2b7d3 Rename PdfJsTelemetry-addon.jsm to PdfJsTelemetry-stub.jsm
And remove unused linting comments.
2017-04-12 13:11:04 +02:00
Yury Delendik
31f8875614 Merge pull request #8157 from Snuffleupagus/api-RenderTask-cancel-Error
[api-minor] Reject the `RenderTask` with an actual `Error`, instead of just a `string`, when rendering is cancelled
2017-04-04 09:38:47 -05:00
Andrew McCreight
d804881151 Split bootstrap script.
pdfjschildbootstrap.js will always be run, but
pdfjschildbootstrap-enabled.js will only be run if PdfJs.enabled is
true. This will let us avoid some work in the child process in the
next patch.

This will need to be landed in the mozilla-central repository at the
same time as a change to nsBrowserGlue.js. See bug 1352218.
2017-03-31 13:22:39 -07:00
Yury Delendik
25873e92f0 Enable babel translation to enable ES module support. 2017-03-27 07:25:09 -05:00
Jonas Jenwald
6d672c4ba6 [api-minor] Add a pdfjsNext parameter, and PDFJS_NEXT build flag, to allow backwards incompatible API changes 2017-03-13 18:43:43 +01:00
Tim van der Meij
5eb090f288
ES6 modules: remove UMD header validation
This patch is another step towards enabling Babel. Since we're moving
towards ES6 modules, we will not be using UMD headers anymore, so we can
remove the validation.
2017-03-04 21:43:25 +01:00
Jonas Jenwald
af44ef15f7 Don't include web/compatibility.js in the output for gulp lib (PR 8120 follow-up)
First of all, `compatibility.js` is already available in `lib/shared/compatibility.js`. Second of all, as can be seen in 9142301f35 (diff-9432ebaa58e10ab02874fcb86f689caa), the `lib/web/compatibility.js` file cannot work since the `require` statement isn't compatible with the output of `gulp lib`.
2017-03-04 18:34:28 +01:00
Yury Delendik
39e8ad24f7 Creates 'lib' for the 'dist' build target. 2017-03-03 16:37:58 -06:00
Brendan Dahl
8be4db1c34 Add gulp task to generate refs. 2017-02-24 16:59:01 -08:00
Yury Delendik
facefb0c79 Move compatibility code to the shared/compatibility.js. 2017-02-23 19:18:44 -06:00
Tim van der Meij
cada411af4 Merge pull request #8091 from timvandermeij/gulp-baseline
Gulp: migrate `baseline` target from `make.js`
2017-02-22 00:31:43 +01:00
Tim van der Meij
0f4e6fdb9d
Gulp: migrate baseline target from make.js 2017-02-21 23:50:57 +01:00