Merge pull request #12563 from Snuffleupagus/rm-SystemJS-worker

[api-minor] Remove SystemJS usage, in development mode, from the worker
This commit is contained in:
Jonas Jenwald 2023-05-03 23:57:17 +02:00 committed by GitHub
commit f31b320113
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 5054 additions and 5528 deletions

View file

@ -21,7 +21,6 @@ import {
AbortException,
AnnotationMode,
assert,
createPromiseCapability,
getVerbosityLevel,
info,
InvalidPDFException,
@ -29,6 +28,7 @@ import {
MAX_IMAGE_SIZE_TO_CACHE,
MissingPDFException,
PasswordException,
PromiseCapability,
RenderingIntentFlag,
setVerbosityLevel,
shadow,
@ -588,7 +588,7 @@ class PDFDocumentLoadingTask {
static #docId = 0;
constructor() {
this._capability = createPromiseCapability();
this._capability = new PromiseCapability();
this._transport = null;
this._worker = null;
@ -675,7 +675,7 @@ class PDFDataRangeTransport {
this._progressListeners = [];
this._progressiveReadListeners = [];
this._progressiveDoneListeners = [];
this._readyCapability = createPromiseCapability();
this._readyCapability = new PromiseCapability();
}
/**
@ -1460,7 +1460,7 @@ class PDFPageProxy {
// If there's no displayReadyCapability yet, then the operatorList
// was never requested before. Make the request and create the promise.
if (!intentState.displayReadyCapability) {
intentState.displayReadyCapability = createPromiseCapability();
intentState.displayReadyCapability = new PromiseCapability();
intentState.operatorList = {
fnArray: [],
argsArray: [],
@ -1578,7 +1578,7 @@ class PDFPageProxy {
if (!intentState.opListReadCapability) {
opListTask = Object.create(null);
opListTask.operatorListChanged = operatorListChanged;
intentState.opListReadCapability = createPromiseCapability();
intentState.opListReadCapability = new PromiseCapability();
(intentState.renderTasks ||= new Set()).add(opListTask);
intentState.operatorList = {
fnArray: [],
@ -2054,7 +2054,7 @@ class PDFWorker {
this.destroyed = false;
this.verbosity = verbosity;
this._readyCapability = createPromiseCapability();
this._readyCapability = new PromiseCapability();
this._port = null;
this._webWorker = null;
this._messageHandler = null;
@ -2130,12 +2130,9 @@ class PDFWorker {
);
}
// Some versions of FF can't create a worker on localhost, see:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
const worker =
typeof PDFJSDev === "undefined" &&
!workerSrc.endsWith("/build/pdf.worker.js") &&
!workerSrc.endsWith("/src/worker_loader.js")
!workerSrc.endsWith("/build/pdf.worker.js")
? new Worker(workerSrc, { type: "module" })
: new Worker(workerSrc);
const messageHandler = new MessageHandler("main", "worker", worker);
@ -2391,7 +2388,7 @@ class WorkerTransport {
this._networkStream = networkStream;
this._fullReader = null;
this._lastProgress = null;
this.downloadInfoCapability = createPromiseCapability();
this.downloadInfoCapability = new PromiseCapability();
this.setupMessageHandler();
@ -2490,7 +2487,7 @@ class WorkerTransport {
}
this.destroyed = true;
this.destroyCapability = createPromiseCapability();
this.destroyCapability = new PromiseCapability();
if (this._passwordCapability) {
this._passwordCapability.reject(
@ -2584,7 +2581,7 @@ class WorkerTransport {
});
messageHandler.on("ReaderHeadersReady", data => {
const headersCapability = createPromiseCapability();
const headersCapability = new PromiseCapability();
const fullReader = this._fullReader;
fullReader.headersReady.then(() => {
// If stream or range are disabled, it's our only way to report
@ -2699,7 +2696,7 @@ class WorkerTransport {
});
messageHandler.on("PasswordRequest", exception => {
this._passwordCapability = createPromiseCapability();
this._passwordCapability = new PromiseCapability();
if (loadingTask.onPassword) {
const updatePassword = password => {
@ -3120,7 +3117,7 @@ class PDFObjects {
return obj;
}
return (this.#objs[objId] = {
capability: createPromiseCapability(),
capability: new PromiseCapability(),
data: null,
});
}
@ -3280,7 +3277,7 @@ class InternalRenderTask {
this._useRequestAnimationFrame =
useRequestAnimationFrame === true && typeof window !== "undefined";
this.cancelled = false;
this.capability = createPromiseCapability();
this.capability = new PromiseCapability();
this.task = new RenderTask(this);
// caching this-bound methods
this._cancelBound = this.cancel.bind(this);
@ -3360,9 +3357,7 @@ class InternalRenderTask {
operatorListChanged() {
if (!this.graphicsReady) {
if (!this.graphicsReadyCallback) {
this.graphicsReadyCallback = this._continueBound;
}
this.graphicsReadyCallback ||= this._continueBound;
return;
}
this.stepper?.updateOperatorList(this.operatorList);