Compare commits

..

No commits in common. "d97b65378ff1f00eaa209e28dd4f7ce51bfe20a3" and "b070a502c33aa08788e31e8f2afb675df1405374" have entirely different histories.

4 changed files with 35 additions and 29 deletions

View File

@ -491,8 +491,7 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
function createMainBundle(defines) {
const mainFileConfig = createWebpackConfig(defines, {
filename:
defines.MINIFIED && !defines.MOZCENTRAL ? "pdf.min.mjs" : "pdf.mjs",
filename: defines.MINIFIED ? "pdf.min.mjs" : "pdf.mjs",
library: {
type: "module",
},
@ -572,10 +571,7 @@ function createSandboxBundle(defines, extraOptions = undefined) {
function createWorkerBundle(defines) {
const workerFileConfig = createWebpackConfig(defines, {
filename:
defines.MINIFIED && !defines.MOZCENTRAL
? "pdf.worker.min.mjs"
: "pdf.worker.mjs",
filename: defines.MINIFIED ? "pdf.worker.min.mjs" : "pdf.worker.mjs",
library: {
type: "module",
},
@ -1392,7 +1388,7 @@ gulp.task(
gulp.series(
createBuildNumber,
function scriptingMozcentral() {
const defines = { ...DEFINES, MOZCENTRAL: true, MINIFIED: true };
const defines = { ...DEFINES, MOZCENTRAL: true };
return buildDefaultPreferences(defines, "mozcentral/");
},
async function prefsMozcentral() {
@ -1401,7 +1397,7 @@ gulp.task(
function createMozcentral() {
console.log();
console.log("### Building mozilla-central extension");
const defines = { ...DEFINES, MOZCENTRAL: true, MINIFIED: true };
const defines = { ...DEFINES, MOZCENTRAL: 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.3",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz",
"integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==",
"version": "6.21.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz",
"integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==",
"dev": true,
"license": "MIT",
"engines": {

View File

@ -688,16 +688,20 @@ class PDFDocumentLoadingTask {
async destroy() {
this.destroyed = true;
try {
if (this._worker?.port) {
this._worker._pendingDestroy = true;
}
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
await this._transport?.destroy();
} catch (ex) {
if (this._worker?.port) {
delete this._worker._pendingDestroy;
} 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;
}
throw ex;
}
this._transport = null;
@ -2097,7 +2101,7 @@ class PDFWorker {
static #isWorkerDisabled = false;
static #workerPorts = new WeakMap();
static #workerPorts;
static {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
@ -2155,11 +2159,14 @@ class PDFWorker {
this._webWorker = null;
this._messageHandler = null;
if (port) {
if (PDFWorker.#workerPorts.has(port)) {
if (
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
port
) {
if (PDFWorker.#workerPorts?.has(port)) {
throw new Error("Cannot use more than one PDFWorker per port.");
}
PDFWorker.#workerPorts.set(port, this);
(PDFWorker.#workerPorts ||= new WeakMap()).set(port, this);
this._initializeFromPort(port);
return;
}
@ -2199,6 +2206,9 @@ 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 () {
@ -2353,7 +2363,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();
@ -2365,10 +2375,13 @@ 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,10 +502,7 @@ const defaultOptions = {
workerPort: {
/** @type {Object} */
value:
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
? globalThis.pdfjsPreloadedWorker
: null,
value: null,
kind: OptionKind.WORKER,
},
workerSrc: {