diff --git a/.jshintignore b/.eslintignore
similarity index 62%
rename from .jshintignore
rename to .eslintignore
index 55fba529..bc3e05a1 100644
--- a/.jshintignore
+++ b/.eslintignore
@@ -3,15 +3,14 @@ l10n/
docs/
node_modules/
examples/
+external/bcmaps/
external/webL10n/
-external/shelljs/
-external/jpgjs/
-external/jasmine/
external/cmapscompress/
-external/importL10n/
-shared/
+external/builder/fixtures/
+external/builder/fixtures_esprima/
test/tmp/
test/features/
+test/pdfs/
test/resources/
test/font/*_spec.js
*~/
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 00000000..d034a3ce
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,136 @@
+{
+ "parserOptions": {
+ "ecmaVersion": 5,
+ },
+
+ "env": {
+ "browser": true,
+ "es6": true,
+ "worker": true,
+ "amd": true,
+ },
+
+ globals: {
+ "PDFJSDev": false,
+ "exports": false,
+ "SystemJS": false,
+ },
+
+ "rules": {
+ // Possible errors
+ "no-cond-assign": ["error", "except-parens"],
+ "no-constant-condition": ["error", { "checkLoops": false, }],
+ "no-dupe-args": "error",
+ "no-dupe-keys": "error",
+ "no-duplicate-case": "error",
+ "no-empty": ["error", { "allowEmptyCatch": true, }],
+ "no-ex-assign": "error",
+ "no-extra-boolean-cast": "error",
+ "no-extra-semi": "error",
+ "no-func-assign": "error",
+ "no-inner-declarations": ["error", "functions"],
+ "no-invalid-regexp": "error",
+ "no-irregular-whitespace": "error",
+ "no-obj-calls": "error",
+ "no-regex-spaces": "error",
+ "no-sparse-arrays": "error",
+ "no-unexpected-multiline": "error",
+ "no-unreachable": "error",
+ "no-unsafe-finally": "error",
+ "no-unsafe-negation": "error",
+ "use-isnan": "error",
+ "valid-typeof": ["error", { "requireStringLiterals": true, }],
+
+ // Best Practices
+ "accessor-pairs": ["error", { "setWithoutGet": true, }],
+ "curly": ["error", "all"],
+ "eqeqeq": ["error", "always"],
+ "no-caller": "error",
+ "no-else-return": "error",
+ "no-empty-pattern": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-fallthrough": "error",
+ "no-floating-decimal": "error",
+ "no-global-assign": "error",
+ "no-implied-eval": "error",
+ "no-iterator": "error",
+ "no-lone-blocks": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-new-func": "error",
+ "no-new-wrappers": "error",
+ "no-new": "error",
+ "no-octal-escape": "error",
+ "no-octal": "error",
+ "no-redeclare": "error",
+ "no-self-assign": "error",
+ "no-self-compare": "error",
+ "no-unused-expressions": "error",
+ "no-unused-labels": "error",
+ "no-useless-call": "error",
+ "no-useless-concat": "error",
+ "wrap-iife": ["error", "any"],
+ "yoda": ["error", "never", { "onlyEquality": true, }],
+
+ // Strict Mode
+ "strict": ["error", "global"],
+
+ // Variables
+ "no-catch-shadow": "error",
+ "no-delete-var": "error",
+ "no-label-var": "error",
+ "no-shadow-restricted-names": "error",
+ "no-undef-init": "error",
+ "no-undef": ["error", { "typeof": true, }],
+ "no-unused-vars": ["error", {
+ "vars": "local",
+ "args": "none",
+ }],
+
+ // Stylistic Issues
+ "array-bracket-spacing": ["error", "never"],
+ "block-spacing": ["error", "always"],
+ "brace-style": ["error", "1tbs", {
+ "allowSingleLine": false,
+ }],
+ "comma-spacing": ["error", { "before": false, "after": true, }],
+ "comma-style": ["error", "last"],
+ "eol-last": "error",
+ "func-call-spacing": ["error", "never"],
+ "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict", }],
+ "keyword-spacing": ["error", { "before": true, "after": true, }],
+ "linebreak-style": ["error", "unix"],
+ "max-len": ["error", 80],
+ "new-cap": ["error", { "newIsCap": true, "capIsNew": false, }],
+ "new-parens": "error",
+ "no-array-constructor": "error",
+ "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 0, "maxBOF": 1, }],
+ "no-new-object": "error",
+ "no-tabs": "error",
+ "no-trailing-spaces": ["error", { "skipBlankLines": false, }],
+ "no-whitespace-before-property": "error",
+ "operator-linebreak": ["error", "after", { "overrides": { ":": "ignore", } }],
+ "quotes": ["error", "single"],
+ "semi-spacing": ["error", { "before": false, "after": true, }],
+ "semi": ["error", "always"],
+ "space-before-blocks": ["error", "always"],
+ "space-before-function-paren": ["error", { "anonymous": "ignore", "named": "never", }],
+ "space-in-parens": ["error", "never"],
+ "space-infix-ops": ["error", { "int32Hint": false }],
+ "space-unary-ops": ["error", { "words": true, "nonwords": false, }],
+ "spaced-comment": ["error", "always", {
+ "line": {
+ "exceptions": ["//", "#else", "#endif"],
+ "markers": ["#if", "#elif", "#include", "#expand", "#error"],
+ },
+ "block": {
+ "balanced": true,
+ }
+ }],
+
+ // ECMAScript 6
+ },
+}
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index e383650a..dcb4715c 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -4,7 +4,7 @@ The issues are used to track both bugs filed by users and specific work items fo
If the issue is related to errors produced by a specific PDF, please always include the PDF by providing a URL where contributors can download it. Without a PDF for reproduction, such issues will be closed. We understand that many PDFs contain sensitive information, however having a PDF is essential to resolving the issue and building our regression testing suite. If possible, try creating a reduced example exhibiting the problem but not containing sensitive data. Also small PDFs are best suited for our regression testing. If an important issue only shows on sensitive PDFs, contributors might be willing to accept these PDFs via a secure exchange.
-The issue tracking system is designed to record a single technical problem. A bug report is something where a developer/contributor can work on. The GitHub issue tracker is not a good place for general, not well thought out or unworkable ideas. Most likely a discussion-type issue will not be addressed for a long time or closed as invalid. The best place is our dev-pdf-js@lists.mozilla.org mailing list. You can subscribe to it using http://lists.mozilla.org or Google Groups. This way you will reach not only developers. As an alternative, you can join our weekly engineering meeting to discuss new ideas for the project.
+The issue tracking system is designed to record a single technical problem. A bug report is something where a developer/contributor can work on. The GitHub issue tracker is not a good place for general, not well thought out or unworkable ideas. Most likely a discussion-type issue will not be addressed for a long time or closed as invalid. The best place for general discussions is our #pdfjs IRC channel on irc.mozilla.org.
If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us on the IRC channel -- keep in mind that just code snippets won't help us troubleshoot the problem.
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 19c53a41..00000000
--- a/.jshintrc
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- // Environments
- "browser": true,
- "devel": true,
- "worker": true,
- "predef": [
- "Promise",
- "require",
- "define",
- "exports"
- ],
-
- // Enforcing
- "maxlen": 80,
- "quotmark": "single",
- "trailing": true,
- "curly": true,
- "undef": true,
- "noarg": true,
- "nonbsp": true,
- "eqeqeq": true,
-
- // Relaxing
- "boss": true,
- "funcscope": true,
- "globalstrict": true,
- "loopfunc": true,
- "maxerr": 1000,
- "nonstandard": true,
- "sub": true,
- "validthis": true
-}
diff --git a/.travis.yml b/.travis.yml
index 907c45e6..0c0c23f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,11 @@
language: node_js
node_js:
- - "0.12"
-before_install:
+ - node
+cache:
+ directories:
+ - node_modules
+install:
+ - npm install -g npm@latest
- npm install -g gulp-cli
+ - npm install
+ - npm update
diff --git a/README.md b/README.md
index 15811c7c..50283730 100644
--- a/README.md
+++ b/README.md
@@ -9,31 +9,33 @@ rendering PDFs.
## Contributing
PDF.js is an open source project and always looking for more contributors. To
-get involved checkout:
+get involved, visit:
-+ [Issue Reporting Guide](https://github.com/mozilla/pdf.js/blob/master/CONTRIBUTING.md)
++ [Issue Reporting Guide](https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md)
+ [Code Contribution Guide](https://github.com/mozilla/pdf.js/wiki/Contributing)
+ [Frequently Asked Questions](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions)
+ [Good Beginner Bugs](https://github.com/mozilla/pdf.js/issues?direction=desc&labels=5-good-beginner-bug&page=1&sort=created&state=open)
-+ [Priorities](https://github.com/mozilla/pdf.js/milestones)
-+ [Attend a Public Meeting](https://github.com/mozilla/pdf.js/wiki/Weekly-Public-Meetings)
++ [Projects](https://github.com/mozilla/pdf.js/projects)
-For further questions or guidance feel free to stop by #pdfjs on
-irc.mozilla.org.
+Feel free to stop by #pdfjs on irc.mozilla.org for questions or guidance.
## Getting Started
### Online demo
-+ http://mozilla.github.io/pdf.js/web/viewer.html
++ https://mozilla.github.io/pdf.js/web/viewer.html
### Browser Extensions
-#### Firefox and Seamonkey
+#### Firefox (and Seamonkey)
-PDF.js is built into version 19+ of Firefox, however the extension is still available:
+PDF.js is built into version 19+ of Firefox, however one extension is still available:
-+ [Development Version](http://mozilla.github.io/pdf.js/extensions/firefox/pdf.js.xpi) - This version is updated every time new code is merged into the PDF.js codebase. This should be quite stable but still might break from time to time. This version is also reported to work when installed as extension in Seamonkey 2.39.
++ [Development Version](http://mozilla.github.io/pdf.js/extensions/firefox/pdf.js.xpi) - This extension is mainly intended for developers/testers, and it is updated every time new code is merged into the PDF.js codebase. It should be quite stable, but might break from time to time.
+
+ + Please note that the extension is *not* guaranteed to be compatible with Firefox versions that are *older* than the current ESR version, see the [Release Calendar](https://wiki.mozilla.org/RapidRelease/Calendar#Past_branch_dates).
+
+ + The extension should also work in Seamonkey, provided that it is based on a Firefox version as above (see [Which version of Firefox does SeaMonkey 2.x correspond with?](https://wiki.mozilla.org/SeaMonkey/FAQ#General)), but we do *not* guarantee compatibility.
#### Chrome
@@ -75,8 +77,8 @@ It is also possible to view all test PDF files on the right side by opening
## Building PDF.js
-In order to bundle all `src/` files into two productions scripts and build the generic
-viewer, issue:
+In order to bundle all `src/` files into two production scripts and build the generic
+viewer, run:
$ gulp generic
@@ -86,15 +88,21 @@ be loaded by `pdf.js`. If you want to support more browsers than Firefox you'll
to include `compatibility.js` from `build/generic/web/`. The PDF.js files are large and
should be minified for production.
+## Using PDF.js in a web application
+
+To use PDF.js in a web application you can choose to use a pre-built version of the library
+or to build it from source. We supply pre-built versions for usage with NPM and Bower under
+the `pdfjs-dist` name. For more information and examples please refer to the
+[wiki page](https://github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website) on this subject.
+
## Learning
-You can play with the PDF.js API directly from your browser through the live
+You can play with the PDF.js API directly from your browser using the live
demos below:
-+ [Hello world](http://mozilla.github.io/pdf.js/examples/learning/helloworld.html)
-+ [Simple reader with prev/next page controls](http://mozilla.github.io/pdf.js/examples/learning/prevnext.html)
++ [Interactive examples](http://mozilla.github.io/pdf.js/examples/index.html#interactive-examples)
-The repo contains a hello world example that you can run locally:
+The repository contains a hello world example that you can run locally:
+ [examples/helloworld/](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/)
@@ -103,12 +111,7 @@ contributor Julian Viereck:
+ http://www.youtube.com/watch?v=Iv15UY-4Fg8
-You can read more about PDF.js here:
-
-+ http://andreasgal.com/2011/06/15/pdf-js/
-+ http://blog.mozilla.com/cjones/2011/06/15/overview-of-pdf-js-guts/
-
-Even more learning resources can be found at:
+More learning resources can be found at:
+ https://github.com/mozilla/pdf.js/wiki/Additional-Learning-Resources
@@ -122,19 +125,10 @@ Talk to us on IRC:
+ #pdfjs on irc.mozilla.org
-Join our mailing list:
+File an issue:
-+ dev-pdf-js@lists.mozilla.org
-
-Subscribe either using lists.mozilla.org or Google Groups:
-
-+ https://lists.mozilla.org/listinfo/dev-pdf-js
-+ https://groups.google.com/group/mozilla.dev.pdf-js/topics
++ https://github.com/mozilla/pdf.js/issues/new
Follow us on twitter: @pdfjs
+ http://twitter.com/#!/pdfjs
-
-Weekly Public Meetings
-
-+ https://github.com/mozilla/pdf.js/wiki/Weekly-Public-Meetings
diff --git a/docs/contents/examples/index.md b/docs/contents/examples/index.md
index 418bc207..f50b69ea 100644
--- a/docs/contents/examples/index.md
+++ b/docs/contents/examples/index.md
@@ -61,3 +61,25 @@ var viewport = page.getViewport(1);
var scale = desiredWidth / viewport.width;
var scaledViewport = page.getViewport(scale);
```
+
+## Interactive examples
+
+### Hello World with document load error handling
+
+The example demonstrates how promises can be used to handle errors during loading.
+It also demonstrates how to wait until page loaded and rendered.
+
+
+
+### Hello World using base64 encoded PDF
+
+The PDF.js can accept any decoded base64 data as an array.
+
+
+
+### Previous/Next example
+
+The same canvas cannot be used to perform to draw two pages at the same time --
+the example demonstrate how to wait on previous operation to be complete.
+
+
diff --git a/docs/contents/index.md b/docs/contents/index.md
index 7acd0436..aaabe1e9 100644
--- a/docs/contents/index.md
+++ b/docs/contents/index.md
@@ -10,5 +10,5 @@ template: layout.jade