Compare commits

...

8 Commits

Author SHA1 Message Date
Jonas Jenwald
d97b65378f
Merge pull request #19933 from mozilla/dependabot/npm_and_yarn/undici-6.21.3
Bump undici from 6.21.1 to 6.21.3
2025-05-15 23:28:00 +02:00
calixteman
f4a3e47018
Merge pull request #19935 from calixteman/bug1966721
Use the worker created in the child actor (bug 1966721)
2025-05-15 21:21:06 +02:00
Calixte Denizet
f01b13d332 Use the worker created in the child actor (bug 1966721) 2025-05-15 21:17:44 +02:00
Jonas Jenwald
b3ccc55c1d
Merge pull request #19936 from Snuffleupagus/workerPort-firefox
Allow using the `workerPort` option in Firefox
2025-05-15 21:09:08 +02:00
calixteman
be463f0e0c
Merge pull request #19934 from calixteman/minify
Minify the js code when building for Firefox (bug 1965003)
2025-05-15 20:11:11 +02:00
Jonas Jenwald
e5e9d18289 Allow using the workerPort option in Firefox 2025-05-15 19:30:43 +02:00
Calixte Denizet
8129ccc9a7 Minify the js code when building for Firefox (bug 1965003)
It helps to improve the loading time in the worker by around 25% on Windows, Mac and Android.
2025-05-15 19:01:52 +02:00
dependabot[bot]
64c1e07f22
Bump undici from 6.21.1 to 6.21.3
Bumps [undici](https://github.com/nodejs/undici) from 6.21.1 to 6.21.3.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.21.1...v6.21.3)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.21.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-15 15:23:50 +00:00
4 changed files with 30 additions and 36 deletions

View File

@ -491,7 +491,8 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
function createMainBundle(defines) {
const mainFileConfig = createWebpackConfig(defines, {
filename: defines.MINIFIED ? "pdf.min.mjs" : "pdf.mjs",
filename:
defines.MINIFIED && !defines.MOZCENTRAL ? "pdf.min.mjs" : "pdf.mjs",
library: {
type: "module",
},
@ -571,7 +572,10 @@ function createSandboxBundle(defines, extraOptions = undefined) {
function createWorkerBundle(defines) {
const workerFileConfig = createWebpackConfig(defines, {
filename: defines.MINIFIED ? "pdf.worker.min.mjs" : "pdf.worker.mjs",
filename:
defines.MINIFIED && !defines.MOZCENTRAL
? "pdf.worker.min.mjs"
: "pdf.worker.mjs",
library: {
type: "module",
},
@ -1388,7 +1392,7 @@ gulp.task(
gulp.series(
createBuildNumber,
function scriptingMozcentral() {
const defines = { ...DEFINES, MOZCENTRAL: true };
const defines = { ...DEFINES, MOZCENTRAL: true, MINIFIED: true };
return buildDefaultPreferences(defines, "mozcentral/");
},
async function prefsMozcentral() {
@ -1397,7 +1401,7 @@ gulp.task(
function createMozcentral() {
console.log();
console.log("### Building mozilla-central extension");
const defines = { ...DEFINES, MOZCENTRAL: true };
const defines = { ...DEFINES, MOZCENTRAL: true, MINIFIED: true };
const gvDefines = { ...defines, GECKOVIEW: true };
const MOZCENTRAL_DIR = BUILD_DIR + "mozcentral/",

6
package-lock.json generated
View File

@ -12099,9 +12099,9 @@
}
},
"node_modules/undici": {
"version": "6.21.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz",
"integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==",
"version": "6.21.3",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz",
"integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==",
"dev": true,
"license": "MIT",
"engines": {

View File

@ -688,20 +688,16 @@ class PDFDocumentLoadingTask {
async destroy() {
this.destroyed = true;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
await this._transport?.destroy();
} else {
try {
if (this._worker?.port) {
this._worker._pendingDestroy = true;
}
await this._transport?.destroy();
} catch (ex) {
if (this._worker?.port) {
delete this._worker._pendingDestroy;
}
throw ex;
try {
if (this._worker?.port) {
this._worker._pendingDestroy = true;
}
await this._transport?.destroy();
} catch (ex) {
if (this._worker?.port) {
delete this._worker._pendingDestroy;
}
throw ex;
}
this._transport = null;
@ -2101,7 +2097,7 @@ class PDFWorker {
static #isWorkerDisabled = false;
static #workerPorts;
static #workerPorts = new WeakMap();
static {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
@ -2159,14 +2155,11 @@ class PDFWorker {
this._webWorker = null;
this._messageHandler = null;
if (
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
port
) {
if (PDFWorker.#workerPorts?.has(port)) {
if (port) {
if (PDFWorker.#workerPorts.has(port)) {
throw new Error("Cannot use more than one PDFWorker per port.");
}
(PDFWorker.#workerPorts ||= new WeakMap()).set(port, this);
PDFWorker.#workerPorts.set(port, this);
this._initializeFromPort(port);
return;
}
@ -2206,9 +2199,6 @@ class PDFWorker {
}
_initializeFromPort(port) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Not implemented: _initializeFromPort");
}
this._port = port;
this._messageHandler = new MessageHandler("main", "worker", port);
this._messageHandler.on("ready", function () {
@ -2363,7 +2353,7 @@ class PDFWorker {
this._webWorker?.terminate();
this._webWorker = null;
PDFWorker.#workerPorts?.delete(this._port);
PDFWorker.#workerPorts.delete(this._port);
this._port = null;
this._messageHandler?.destroy();
@ -2375,13 +2365,10 @@ class PDFWorker {
* @returns {PDFWorker}
*/
static fromPort(params) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Not implemented: fromPort");
}
if (!params?.port) {
throw new Error("PDFWorker.fromPort - invalid method signature.");
}
const cachedPort = this.#workerPorts?.get(params.port);
const cachedPort = this.#workerPorts.get(params.port);
if (cachedPort) {
if (cachedPort._pendingDestroy) {
throw new Error(

View File

@ -502,7 +502,10 @@ const defaultOptions = {
workerPort: {
/** @type {Object} */
value: null,
value:
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
? globalThis.pdfjsPreloadedWorker
: null,
kind: OptionKind.WORKER,
},
workerSrc: {