Add support for modern ECMAScript class
features
With ESLint 8 we should now finally be able to start using modern `class` features, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields However, while both ESLint and Acorn now support this, it unfortunately turns out that Escodegen (which we use during building) still lack the necessary support. Looking at https://github.com/estools/escodegen there's not been any updates since last year, and there's also open PRs adding support for these new `class` features. To avoid blocking usage of these `class` features in the PDF.js code-base, in particular *private* fields/methods, this patch thus proposes that we (hopefully temporarily) switch to an `escodegen` fork that has the necessary support; please see https://www.npmjs.com/package/@javascript-obfuscator/escodegen While I have no reason to doubt the security of the `escodegen` fork, this patch nonetheless pins the version number. Furthermore, I've also diffed the output of the two `.js`-files in this forked package against the original files without finding anything that looks immediately "dangerous".
This commit is contained in:
parent
38e5360533
commit
00f8fab8a5
@ -1,6 +1,6 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2021,
|
||||
"ecmaVersion": 2022,
|
||||
"sourceType": "module",
|
||||
},
|
||||
|
||||
|
@ -24,8 +24,8 @@ Feel free to stop by our [Matrix room](https://chat.mozilla.org/#/room/#pdfjs:mo
|
||||
### Online demo
|
||||
|
||||
Please note that the "Modern browsers" version assumes native support for
|
||||
features such as e.g. `async`/`await`, `ReadableStream`, optional chaining, and
|
||||
nullish coalescing.
|
||||
features such as e.g. `async`/`await`, `ReadableStream`, optional chaining,
|
||||
nullish coalescing, and private `class` fields/methods.
|
||||
|
||||
+ Modern browsers: https://mozilla.github.io/pdf.js/web/viewer.html
|
||||
|
||||
|
4
external/builder/preprocessor2.js
vendored
4
external/builder/preprocessor2.js
vendored
@ -1,14 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
const acorn = require("acorn");
|
||||
const escodegen = require("escodegen");
|
||||
const escodegen = require("@javascript-obfuscator/escodegen");
|
||||
const vm = require("vm");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const PDFJS_PREPROCESSOR_NAME = "PDFJSDev";
|
||||
const ROOT_PREFIX = "$ROOT/";
|
||||
const ACORN_ECMA_VERSION = 2021;
|
||||
const ACORN_ECMA_VERSION = 2022;
|
||||
|
||||
function isLiteral(obj, value) {
|
||||
return obj.type === "Literal" && obj.value === value;
|
||||
|
5
external/dist/README.md
vendored
5
external/dist/README.md
vendored
@ -8,7 +8,8 @@ This is a pre-built version of the PDF.js source code. It is automatically
|
||||
generated by the build scripts.
|
||||
|
||||
For usage with older browsers or environments, without support for modern
|
||||
features such as e.g. `async`/`await`, `ReadableStream`, optional chaining, and
|
||||
nullish coalescing; please see the `legacy` folder.
|
||||
features such as e.g. `async`/`await`, `ReadableStream`, optional chaining,
|
||||
nullish coalescing, and private `class` fields/methods; please see the `legacy`
|
||||
folder.
|
||||
|
||||
See https://github.com/mozilla/pdf.js for learning and contributing.
|
||||
|
@ -1375,7 +1375,7 @@ gulp.task("jsdoc", function (done) {
|
||||
gulp.task("types", function (done) {
|
||||
console.log("### Generating TypeScript definitions using `tsc`");
|
||||
const args = [
|
||||
"target ES2020",
|
||||
"target ESNext",
|
||||
"allowJS",
|
||||
"declaration",
|
||||
`outDir ${TYPES_DIR}`,
|
||||
|
43
package-lock.json
generated
43
package-lock.json
generated
@ -1774,6 +1774,25 @@
|
||||
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
|
||||
"dev": true
|
||||
},
|
||||
"@javascript-obfuscator/escodegen": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@javascript-obfuscator/escodegen/-/escodegen-2.2.2.tgz",
|
||||
"integrity": "sha512-0VoGJun/lpGEPv8J8R8fpwt1iAGyctUjHTQoYoCbKY2rcGc6d+NycrqSMo61vRXhZiTnHgud1UF8dOI7UAPdTw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@javascript-obfuscator/estraverse": "^5.3.0",
|
||||
"esprima": "^4.0.1",
|
||||
"esutils": "^2.0.2",
|
||||
"optionator": "^0.8.1",
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"@javascript-obfuscator/estraverse": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@javascript-obfuscator/estraverse/-/estraverse-5.3.0.tgz",
|
||||
"integrity": "sha512-SxIFtV5/wlXYS7G3zLVj7CddLolX8Bm/hr68fiyNL3MyG2k4FwF9B5Z5GTpVLhw2EELYNwyoYBvFlR4gGnQPdw==",
|
||||
"dev": true
|
||||
},
|
||||
"@mapbox/node-pre-gyp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.5.tgz",
|
||||
@ -4333,27 +4352,6 @@
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
},
|
||||
"escodegen": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz",
|
||||
"integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"esprima": "^4.0.1",
|
||||
"estraverse": "^5.2.0",
|
||||
"esutils": "^2.0.2",
|
||||
"optionator": "^0.8.1",
|
||||
"source-map": "~0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"estraverse": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
|
||||
"integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslint": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.0.1.tgz",
|
||||
@ -6576,7 +6574,8 @@
|
||||
},
|
||||
"yargs-parser": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.0.tgz",
|
||||
"integrity": "sha1-J17PDX/+Bcd+ZOfIbkzZS/DhIoo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"camelcase": "^3.0.0"
|
||||
|
@ -14,7 +14,7 @@
|
||||
"cross-env": "^7.0.3",
|
||||
"dommatrix": "^0.0.6",
|
||||
"es-module-shims": "^1.3.0",
|
||||
"escodegen": "^2.0.0",
|
||||
"@javascript-obfuscator/escodegen": "2.2.2",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-fetch-options": "^0.0.5",
|
||||
|
@ -6,14 +6,14 @@
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es5",
|
||||
"module": "es2015",
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"baseUrl": "./",
|
||||
"strict": true,
|
||||
"types": [],
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
"ESNext",
|
||||
"DOM"
|
||||
],
|
||||
"paths": {
|
||||
"pdfjs-dist": ["../../build/typestest"],
|
||||
|
Loading…
Reference in New Issue
Block a user