Merge pull request #16293 from Snuffleupagus/Node-18
[api-minor] Update the minimum supported Node.js version to 18
This commit is contained in:
commit
7ecb3236f0
4
external/.eslintrc
vendored
4
external/.eslintrc
vendored
@ -6,8 +6,4 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"rules": {
|
|
||||||
"unicorn/prefer-at": "off",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
2
external/builder/builder.js
vendored
2
external/builder/builder.js
vendored
@ -72,7 +72,7 @@ function preprocess(inFilename, outFilename, defines) {
|
|||||||
? outFilename
|
? outFilename
|
||||||
: function (line) {
|
: function (line) {
|
||||||
if (!line || AllWhitespaceRegexp.test(line)) {
|
if (!line || AllWhitespaceRegexp.test(line)) {
|
||||||
const prevLine = out[out.length - 1];
|
const prevLine = out.at(-1);
|
||||||
if (!prevLine || AllWhitespaceRegexp.test(prevLine)) {
|
if (!prevLine || AllWhitespaceRegexp.test(prevLine)) {
|
||||||
return; // Avoid adding consecutive blank lines.
|
return; // Avoid adding consecutive blank lines.
|
||||||
}
|
}
|
||||||
|
4
external/builder/preprocessor2.js
vendored
4
external/builder/preprocessor2.js
vendored
@ -244,8 +244,8 @@ function postprocessNode(ctx, node) {
|
|||||||
const block = node.body;
|
const block = node.body;
|
||||||
if (
|
if (
|
||||||
block.body.length > 0 &&
|
block.body.length > 0 &&
|
||||||
block.body[block.body.length - 1].type === "ReturnStatement" &&
|
block.body.at(-1).type === "ReturnStatement" &&
|
||||||
!block.body[block.body.length - 1].argument
|
!block.body.at(-1).argument
|
||||||
) {
|
) {
|
||||||
// Function body ends with return without arg -- removing it.
|
// Function body ends with return without arg -- removing it.
|
||||||
block.body.pop();
|
block.body.pop();
|
||||||
|
2
external/cmapscompress/compress.js
vendored
2
external/cmapscompress/compress.js
vendored
@ -215,7 +215,7 @@ function parseCMap(binaryData) {
|
|||||||
},
|
},
|
||||||
readHexSigned(size) {
|
readHexSigned(size) {
|
||||||
const num = this.readHexNumber(size);
|
const num = this.readHexNumber(size);
|
||||||
const sign = fromHexDigit(num[num.length - 1]) & 1 ? 15 : 0;
|
const sign = fromHexDigit(num.at(-1)) & 1 ? 15 : 0;
|
||||||
let c = 0;
|
let c = 0;
|
||||||
let result = "";
|
let result = "";
|
||||||
for (const digit of num) {
|
for (const digit of num) {
|
||||||
|
5
external/cmapscompress/optimize.js
vendored
5
external/cmapscompress/optimize.js
vendored
@ -151,10 +151,7 @@ exports.optimizeCMap = function (data) {
|
|||||||
const maxDistance = 100,
|
const maxDistance = 100,
|
||||||
minItems = 10,
|
minItems = 10,
|
||||||
itemsPerBucket = 50;
|
itemsPerBucket = 50;
|
||||||
if (
|
if (subitems.length > minItems && codes.at(-1) - codes[0] > maxDistance) {
|
||||||
subitems.length > minItems &&
|
|
||||||
codes[codes.length - 1] - codes[0] > maxDistance
|
|
||||||
) {
|
|
||||||
const gapsCount = Math.max(2, (subitems.length / itemsPerBucket) | 0);
|
const gapsCount = Math.max(2, (subitems.length / itemsPerBucket) | 0);
|
||||||
const gaps = [];
|
const gaps = [];
|
||||||
for (let q = 0; q < gapsCount; q++) {
|
for (let q = 0; q < gapsCount; q++) {
|
||||||
|
@ -80,7 +80,7 @@ const ENV_TARGETS = [
|
|||||||
"Chrome >= 88",
|
"Chrome >= 88",
|
||||||
"Firefox ESR",
|
"Firefox ESR",
|
||||||
"Safari >= 14.1",
|
"Safari >= 14.1",
|
||||||
"Node >= 16",
|
"Node >= 18",
|
||||||
"> 1%",
|
"> 1%",
|
||||||
"not IE > 0",
|
"not IE > 0",
|
||||||
"not dead",
|
"not dead",
|
||||||
@ -2165,10 +2165,7 @@ function packageJson() {
|
|||||||
license: DIST_LICENSE,
|
license: DIST_LICENSE,
|
||||||
optionalDependencies: {
|
optionalDependencies: {
|
||||||
canvas: "^2.11.2",
|
canvas: "^2.11.2",
|
||||||
},
|
|
||||||
dependencies: {
|
|
||||||
"path2d-polyfill": "^2.0.1",
|
"path2d-polyfill": "^2.0.1",
|
||||||
"web-streams-polyfill": "^3.2.1",
|
|
||||||
},
|
},
|
||||||
browser: {
|
browser: {
|
||||||
canvas: false,
|
canvas: false,
|
||||||
@ -2184,7 +2181,7 @@ function packageJson() {
|
|||||||
url: DIST_REPO_URL,
|
url: DIST_REPO_URL,
|
||||||
},
|
},
|
||||||
engines: {
|
engines: {
|
||||||
node: ">=16",
|
node: ">=18",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
18
package-lock.json
generated
18
package-lock.json
generated
@ -62,14 +62,13 @@
|
|||||||
"typogr": "^0.6.8",
|
"typogr": "^0.6.8",
|
||||||
"vinyl": "^3.0.0",
|
"vinyl": "^3.0.0",
|
||||||
"vinyl-fs": "^3.0.3",
|
"vinyl-fs": "^3.0.3",
|
||||||
"web-streams-polyfill": "^3.2.1",
|
|
||||||
"webpack": "^5.80.0",
|
"webpack": "^5.80.0",
|
||||||
"webpack-stream": "^7.0.0",
|
"webpack-stream": "^7.0.0",
|
||||||
"wintersmith": "^2.5.0",
|
"wintersmith": "^2.5.0",
|
||||||
"yargs": "^17.7.1"
|
"yargs": "^17.7.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@ampproject/remapping": {
|
"node_modules/@ampproject/remapping": {
|
||||||
@ -18622,15 +18621,6 @@
|
|||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/web-streams-polyfill": {
|
|
||||||
"version": "3.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
|
||||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
@ -33566,12 +33556,6 @@
|
|||||||
"graceful-fs": "^4.1.2"
|
"graceful-fs": "^4.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"web-streams-polyfill": {
|
|
||||||
"version": "3.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
|
||||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"webidl-conversions": {
|
"webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
"typogr": "^0.6.8",
|
"typogr": "^0.6.8",
|
||||||
"vinyl": "^3.0.0",
|
"vinyl": "^3.0.0",
|
||||||
"vinyl-fs": "^3.0.3",
|
"vinyl-fs": "^3.0.3",
|
||||||
"web-streams-polyfill": "^3.2.1",
|
|
||||||
"webpack": "^5.80.0",
|
"webpack": "^5.80.0",
|
||||||
"webpack-stream": "^7.0.0",
|
"webpack-stream": "^7.0.0",
|
||||||
"wintersmith": "^2.5.0",
|
"wintersmith": "^2.5.0",
|
||||||
@ -69,7 +68,7 @@
|
|||||||
"url": "git://github.com/mozilla/pdf.js.git"
|
"url": "git://github.com/mozilla/pdf.js.git"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
}
|
}
|
||||||
|
@ -129,24 +129,6 @@ class WorkerMessageHandler {
|
|||||||
"; thus breaking e.g. `for...in` iteration of `Array`s."
|
"; thus breaking e.g. `for...in` iteration of `Array`s."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that (primarily) Node.js users won't accidentally attempt to use
|
|
||||||
// a non-translated/non-polyfilled build of the library, since that would
|
|
||||||
// quickly fail anyway because of missing functionality.
|
|
||||||
if (
|
|
||||||
(isNodeJS && typeof Path2D === "undefined") ||
|
|
||||||
typeof ReadableStream === "undefined"
|
|
||||||
) {
|
|
||||||
const partialMsg =
|
|
||||||
"The browser/environment lacks native support for critical " +
|
|
||||||
"functionality used by the PDF.js library " +
|
|
||||||
"(e.g. `Path2D` and/or `ReadableStream`); ";
|
|
||||||
|
|
||||||
if (isNodeJS) {
|
|
||||||
throw new Error(partialMsg + "please use a `legacy`-build instead.");
|
|
||||||
}
|
|
||||||
throw new Error(partialMsg + "please update to a supported browser.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const workerHandlerName = docId + "_worker";
|
const workerHandlerName = docId + "_worker";
|
||||||
let handler = new MessageHandler(workerHandlerName, docId, port);
|
let handler = new MessageHandler(workerHandlerName, docId, port);
|
||||||
|
@ -36,17 +36,7 @@ import { isNodeJS } from "./is_node.js";
|
|||||||
polyfillPath2D(globalThis);
|
polyfillPath2D(globalThis);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Support: Node.js<18.0.0
|
// Support: Chrome<92, Safari<15.4
|
||||||
(function checkReadableStream() {
|
|
||||||
if (globalThis.ReadableStream || !isNodeJS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
globalThis.ReadableStream = __non_webpack_require__(
|
|
||||||
"web-streams-polyfill/dist/ponyfill.js"
|
|
||||||
).ReadableStream;
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Support: Firefox<90, Chrome<92, Safari<15.4, Node.js<16.6.0
|
|
||||||
(function checkArrayAt() {
|
(function checkArrayAt() {
|
||||||
if (Array.prototype.at) {
|
if (Array.prototype.at) {
|
||||||
return;
|
return;
|
||||||
@ -54,7 +44,7 @@ import { isNodeJS } from "./is_node.js";
|
|||||||
require("core-js/es/array/at.js");
|
require("core-js/es/array/at.js");
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Support: Firefox<90, Chrome<92, Safari<15.4, Node.js<16.6.0
|
// Support: Chrome<92, Safari<15.4
|
||||||
(function checkTypedArrayAt() {
|
(function checkTypedArrayAt() {
|
||||||
if (Uint8Array.prototype.at) {
|
if (Uint8Array.prototype.at) {
|
||||||
return;
|
return;
|
||||||
@ -62,13 +52,8 @@ import { isNodeJS } from "./is_node.js";
|
|||||||
require("core-js/es/typed-array/at.js");
|
require("core-js/es/typed-array/at.js");
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Support: Firefox<94, Chrome<98, Safari<15.4, Node.js<17.0.0
|
// Support: Chrome<98, Safari<15.4
|
||||||
(function checkStructuredClone() {
|
(function checkStructuredClone() {
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
|
|
||||||
// The current image decoders are synchronous, hence `structuredClone`
|
|
||||||
// shouldn't need to be polyfilled for the IMAGE_DECODERS build target.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (globalThis.structuredClone) {
|
if (globalThis.structuredClone) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* eslint-disable no-var, unicorn/prefer-at */
|
/* eslint-disable no-var */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -750,9 +750,7 @@ function refTestPostHandler(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var isDone =
|
var isDone = taskResults.at(-1) && taskResults.at(-1)[lastPageNum - 1];
|
||||||
taskResults[taskResults.length - 1] &&
|
|
||||||
taskResults[taskResults.length - 1][lastPageNum - 1];
|
|
||||||
if (isDone) {
|
if (isDone) {
|
||||||
checkRefTestResults(browser, id, taskResults);
|
checkRefTestResults(browser, id, taskResults);
|
||||||
session.remaining--;
|
session.remaining--;
|
||||||
|
Loading…
Reference in New Issue
Block a user