Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../assets/pdf/build
File: script.js
intentState.renderTasks.delete(internalRenderTask);
[16000] Fix | Delete
if (this._maybeCleanupAfterRender || intentPrint) {
[16001] Fix | Delete
this.#pendingCleanup = true;
[16002] Fix | Delete
}
[16003] Fix | Delete
this.#tryCleanup(!intentPrint);
[16004] Fix | Delete
if (error) {
[16005] Fix | Delete
internalRenderTask.capability.reject(error);
[16006] Fix | Delete
this._abortOperatorList({
[16007] Fix | Delete
intentState,
[16008] Fix | Delete
reason: error instanceof Error ? error : new Error(error)
[16009] Fix | Delete
});
[16010] Fix | Delete
} else {
[16011] Fix | Delete
internalRenderTask.capability.resolve();
[16012] Fix | Delete
}
[16013] Fix | Delete
if (this._stats) {
[16014] Fix | Delete
this._stats.timeEnd("Rendering");
[16015] Fix | Delete
this._stats.timeEnd("Overall");
[16016] Fix | Delete
if (globalThis.Stats?.enabled) {
[16017] Fix | Delete
globalThis.Stats.add(this.pageNumber, this._stats);
[16018] Fix | Delete
}
[16019] Fix | Delete
}
[16020] Fix | Delete
};
[16021] Fix | Delete
const internalRenderTask = new InternalRenderTask({
[16022] Fix | Delete
callback: complete,
[16023] Fix | Delete
params: {
[16024] Fix | Delete
canvasContext,
[16025] Fix | Delete
viewport,
[16026] Fix | Delete
transform,
[16027] Fix | Delete
background
[16028] Fix | Delete
},
[16029] Fix | Delete
objs: this.objs,
[16030] Fix | Delete
commonObjs: this.commonObjs,
[16031] Fix | Delete
annotationCanvasMap,
[16032] Fix | Delete
operatorList: intentState.operatorList,
[16033] Fix | Delete
pageIndex: this._pageIndex,
[16034] Fix | Delete
canvasFactory: this._transport.canvasFactory,
[16035] Fix | Delete
filterFactory: this._transport.filterFactory,
[16036] Fix | Delete
useRequestAnimationFrame: !intentPrint,
[16037] Fix | Delete
pdfBug: this._pdfBug,
[16038] Fix | Delete
pageColors
[16039] Fix | Delete
});
[16040] Fix | Delete
(intentState.renderTasks ||= new Set()).add(internalRenderTask);
[16041] Fix | Delete
const renderTask = internalRenderTask.task;
[16042] Fix | Delete
Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {
[16043] Fix | Delete
if (this.destroyed) {
[16044] Fix | Delete
complete();
[16045] Fix | Delete
return;
[16046] Fix | Delete
}
[16047] Fix | Delete
this._stats?.time("Rendering");
[16048] Fix | Delete
if (!(optionalContentConfig.renderingIntent & renderingIntent)) {
[16049] Fix | Delete
throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` " + "and `PDFDocumentProxy.getOptionalContentConfig` methods.");
[16050] Fix | Delete
}
[16051] Fix | Delete
internalRenderTask.initializeGraphics({
[16052] Fix | Delete
transparency,
[16053] Fix | Delete
optionalContentConfig
[16054] Fix | Delete
});
[16055] Fix | Delete
internalRenderTask.operatorListChanged();
[16056] Fix | Delete
}).catch(complete);
[16057] Fix | Delete
return renderTask;
[16058] Fix | Delete
}
[16059] Fix | Delete
getOperatorList({
[16060] Fix | Delete
intent = "display",
[16061] Fix | Delete
annotationMode = AnnotationMode.ENABLE,
[16062] Fix | Delete
printAnnotationStorage = null
[16063] Fix | Delete
} = {}) {
[16064] Fix | Delete
function operatorListChanged() {
[16065] Fix | Delete
if (intentState.operatorList.lastChunk) {
[16066] Fix | Delete
intentState.opListReadCapability.resolve(intentState.operatorList);
[16067] Fix | Delete
intentState.renderTasks.delete(opListTask);
[16068] Fix | Delete
}
[16069] Fix | Delete
}
[16070] Fix | Delete
const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage, true);
[16071] Fix | Delete
let intentState = this._intentStates.get(intentArgs.cacheKey);
[16072] Fix | Delete
if (!intentState) {
[16073] Fix | Delete
intentState = Object.create(null);
[16074] Fix | Delete
this._intentStates.set(intentArgs.cacheKey, intentState);
[16075] Fix | Delete
}
[16076] Fix | Delete
let opListTask;
[16077] Fix | Delete
if (!intentState.opListReadCapability) {
[16078] Fix | Delete
opListTask = Object.create(null);
[16079] Fix | Delete
opListTask.operatorListChanged = operatorListChanged;
[16080] Fix | Delete
intentState.opListReadCapability = Promise.withResolvers();
[16081] Fix | Delete
(intentState.renderTasks ||= new Set()).add(opListTask);
[16082] Fix | Delete
intentState.operatorList = {
[16083] Fix | Delete
fnArray: [],
[16084] Fix | Delete
argsArray: [],
[16085] Fix | Delete
lastChunk: false,
[16086] Fix | Delete
separateAnnots: null
[16087] Fix | Delete
};
[16088] Fix | Delete
this._stats?.time("Page Request");
[16089] Fix | Delete
this._pumpOperatorList(intentArgs);
[16090] Fix | Delete
}
[16091] Fix | Delete
return intentState.opListReadCapability.promise;
[16092] Fix | Delete
}
[16093] Fix | Delete
streamTextContent({
[16094] Fix | Delete
includeMarkedContent = false,
[16095] Fix | Delete
disableNormalization = false
[16096] Fix | Delete
} = {}) {
[16097] Fix | Delete
const TEXT_CONTENT_CHUNK_SIZE = 100;
[16098] Fix | Delete
return this._transport.messageHandler.sendWithStream("GetTextContent", {
[16099] Fix | Delete
pageIndex: this._pageIndex,
[16100] Fix | Delete
includeMarkedContent: includeMarkedContent === true,
[16101] Fix | Delete
disableNormalization: disableNormalization === true
[16102] Fix | Delete
}, {
[16103] Fix | Delete
highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
[16104] Fix | Delete
size(textContent) {
[16105] Fix | Delete
return textContent.items.length;
[16106] Fix | Delete
}
[16107] Fix | Delete
});
[16108] Fix | Delete
}
[16109] Fix | Delete
getTextContent(params = {}) {
[16110] Fix | Delete
if (this._transport._htmlForXfa) {
[16111] Fix | Delete
return this.getXfa().then(xfa => XfaText.textContent(xfa));
[16112] Fix | Delete
}
[16113] Fix | Delete
const readableStream = this.streamTextContent(params);
[16114] Fix | Delete
return new Promise(function (resolve, reject) {
[16115] Fix | Delete
function pump() {
[16116] Fix | Delete
reader.read().then(function ({
[16117] Fix | Delete
value,
[16118] Fix | Delete
done
[16119] Fix | Delete
}) {
[16120] Fix | Delete
if (done) {
[16121] Fix | Delete
resolve(textContent);
[16122] Fix | Delete
return;
[16123] Fix | Delete
}
[16124] Fix | Delete
textContent.lang ??= value.lang;
[16125] Fix | Delete
Object.assign(textContent.styles, value.styles);
[16126] Fix | Delete
textContent.items.push(...value.items);
[16127] Fix | Delete
pump();
[16128] Fix | Delete
}, reject);
[16129] Fix | Delete
}
[16130] Fix | Delete
const reader = readableStream.getReader();
[16131] Fix | Delete
const textContent = {
[16132] Fix | Delete
items: [],
[16133] Fix | Delete
styles: Object.create(null),
[16134] Fix | Delete
lang: null
[16135] Fix | Delete
};
[16136] Fix | Delete
pump();
[16137] Fix | Delete
});
[16138] Fix | Delete
}
[16139] Fix | Delete
getStructTree() {
[16140] Fix | Delete
return this._transport.getStructTree(this._pageIndex);
[16141] Fix | Delete
}
[16142] Fix | Delete
_destroy() {
[16143] Fix | Delete
this.destroyed = true;
[16144] Fix | Delete
const waitOn = [];
[16145] Fix | Delete
for (const intentState of this._intentStates.values()) {
[16146] Fix | Delete
this._abortOperatorList({
[16147] Fix | Delete
intentState,
[16148] Fix | Delete
reason: new Error("Page was destroyed."),
[16149] Fix | Delete
force: true
[16150] Fix | Delete
});
[16151] Fix | Delete
if (intentState.opListReadCapability) {
[16152] Fix | Delete
continue;
[16153] Fix | Delete
}
[16154] Fix | Delete
for (const internalRenderTask of intentState.renderTasks) {
[16155] Fix | Delete
waitOn.push(internalRenderTask.completed);
[16156] Fix | Delete
internalRenderTask.cancel();
[16157] Fix | Delete
}
[16158] Fix | Delete
}
[16159] Fix | Delete
this.objs.clear();
[16160] Fix | Delete
this.#pendingCleanup = false;
[16161] Fix | Delete
this.#abortDelayedCleanup();
[16162] Fix | Delete
return Promise.all(waitOn);
[16163] Fix | Delete
}
[16164] Fix | Delete
cleanup(resetStats = false) {
[16165] Fix | Delete
this.#pendingCleanup = true;
[16166] Fix | Delete
const success = this.#tryCleanup(false);
[16167] Fix | Delete
if (resetStats && success) {
[16168] Fix | Delete
this._stats &&= new StatTimer();
[16169] Fix | Delete
}
[16170] Fix | Delete
return success;
[16171] Fix | Delete
}
[16172] Fix | Delete
#tryCleanup(delayed = false) {
[16173] Fix | Delete
this.#abortDelayedCleanup();
[16174] Fix | Delete
if (!this.#pendingCleanup || this.destroyed) {
[16175] Fix | Delete
return false;
[16176] Fix | Delete
}
[16177] Fix | Delete
if (delayed) {
[16178] Fix | Delete
this.#delayedCleanupTimeout = setTimeout(() => {
[16179] Fix | Delete
this.#delayedCleanupTimeout = null;
[16180] Fix | Delete
this.#tryCleanup(false);
[16181] Fix | Delete
}, DELAYED_CLEANUP_TIMEOUT);
[16182] Fix | Delete
return false;
[16183] Fix | Delete
}
[16184] Fix | Delete
for (const {
[16185] Fix | Delete
renderTasks,
[16186] Fix | Delete
operatorList
[16187] Fix | Delete
} of this._intentStates.values()) {
[16188] Fix | Delete
if (renderTasks.size > 0 || !operatorList.lastChunk) {
[16189] Fix | Delete
return false;
[16190] Fix | Delete
}
[16191] Fix | Delete
}
[16192] Fix | Delete
this._intentStates.clear();
[16193] Fix | Delete
this.objs.clear();
[16194] Fix | Delete
this.#pendingCleanup = false;
[16195] Fix | Delete
return true;
[16196] Fix | Delete
}
[16197] Fix | Delete
#abortDelayedCleanup() {
[16198] Fix | Delete
if (this.#delayedCleanupTimeout) {
[16199] Fix | Delete
clearTimeout(this.#delayedCleanupTimeout);
[16200] Fix | Delete
this.#delayedCleanupTimeout = null;
[16201] Fix | Delete
}
[16202] Fix | Delete
}
[16203] Fix | Delete
_startRenderPage(transparency, cacheKey) {
[16204] Fix | Delete
const intentState = this._intentStates.get(cacheKey);
[16205] Fix | Delete
if (!intentState) {
[16206] Fix | Delete
return;
[16207] Fix | Delete
}
[16208] Fix | Delete
this._stats?.timeEnd("Page Request");
[16209] Fix | Delete
intentState.displayReadyCapability?.resolve(transparency);
[16210] Fix | Delete
}
[16211] Fix | Delete
_renderPageChunk(operatorListChunk, intentState) {
[16212] Fix | Delete
for (let i = 0, ii = operatorListChunk.length; i < ii; i++) {
[16213] Fix | Delete
intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
[16214] Fix | Delete
intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
[16215] Fix | Delete
}
[16216] Fix | Delete
intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
[16217] Fix | Delete
intentState.operatorList.separateAnnots = operatorListChunk.separateAnnots;
[16218] Fix | Delete
for (const internalRenderTask of intentState.renderTasks) {
[16219] Fix | Delete
internalRenderTask.operatorListChanged();
[16220] Fix | Delete
}
[16221] Fix | Delete
if (operatorListChunk.lastChunk) {
[16222] Fix | Delete
this.#tryCleanup(true);
[16223] Fix | Delete
}
[16224] Fix | Delete
}
[16225] Fix | Delete
_pumpOperatorList({
[16226] Fix | Delete
renderingIntent,
[16227] Fix | Delete
cacheKey,
[16228] Fix | Delete
annotationStorageSerializable
[16229] Fix | Delete
}) {
[16230] Fix | Delete
const {
[16231] Fix | Delete
map,
[16232] Fix | Delete
transfer
[16233] Fix | Delete
} = annotationStorageSerializable;
[16234] Fix | Delete
const readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", {
[16235] Fix | Delete
pageIndex: this._pageIndex,
[16236] Fix | Delete
intent: renderingIntent,
[16237] Fix | Delete
cacheKey,
[16238] Fix | Delete
annotationStorage: map
[16239] Fix | Delete
}, transfer);
[16240] Fix | Delete
const reader = readableStream.getReader();
[16241] Fix | Delete
const intentState = this._intentStates.get(cacheKey);
[16242] Fix | Delete
intentState.streamReader = reader;
[16243] Fix | Delete
const pump = () => {
[16244] Fix | Delete
reader.read().then(({
[16245] Fix | Delete
value,
[16246] Fix | Delete
done
[16247] Fix | Delete
}) => {
[16248] Fix | Delete
if (done) {
[16249] Fix | Delete
intentState.streamReader = null;
[16250] Fix | Delete
return;
[16251] Fix | Delete
}
[16252] Fix | Delete
if (this._transport.destroyed) {
[16253] Fix | Delete
return;
[16254] Fix | Delete
}
[16255] Fix | Delete
this._renderPageChunk(value, intentState);
[16256] Fix | Delete
pump();
[16257] Fix | Delete
}, reason => {
[16258] Fix | Delete
intentState.streamReader = null;
[16259] Fix | Delete
if (this._transport.destroyed) {
[16260] Fix | Delete
return;
[16261] Fix | Delete
}
[16262] Fix | Delete
if (intentState.operatorList) {
[16263] Fix | Delete
intentState.operatorList.lastChunk = true;
[16264] Fix | Delete
for (const internalRenderTask of intentState.renderTasks) {
[16265] Fix | Delete
internalRenderTask.operatorListChanged();
[16266] Fix | Delete
}
[16267] Fix | Delete
this.#tryCleanup(true);
[16268] Fix | Delete
}
[16269] Fix | Delete
if (intentState.displayReadyCapability) {
[16270] Fix | Delete
intentState.displayReadyCapability.reject(reason);
[16271] Fix | Delete
} else if (intentState.opListReadCapability) {
[16272] Fix | Delete
intentState.opListReadCapability.reject(reason);
[16273] Fix | Delete
} else {
[16274] Fix | Delete
throw reason;
[16275] Fix | Delete
}
[16276] Fix | Delete
});
[16277] Fix | Delete
};
[16278] Fix | Delete
pump();
[16279] Fix | Delete
}
[16280] Fix | Delete
_abortOperatorList({
[16281] Fix | Delete
intentState,
[16282] Fix | Delete
reason,
[16283] Fix | Delete
force = false
[16284] Fix | Delete
}) {
[16285] Fix | Delete
if (!intentState.streamReader) {
[16286] Fix | Delete
return;
[16287] Fix | Delete
}
[16288] Fix | Delete
if (intentState.streamReaderCancelTimeout) {
[16289] Fix | Delete
clearTimeout(intentState.streamReaderCancelTimeout);
[16290] Fix | Delete
intentState.streamReaderCancelTimeout = null;
[16291] Fix | Delete
}
[16292] Fix | Delete
if (!force) {
[16293] Fix | Delete
if (intentState.renderTasks.size > 0) {
[16294] Fix | Delete
return;
[16295] Fix | Delete
}
[16296] Fix | Delete
if (reason instanceof RenderingCancelledException) {
[16297] Fix | Delete
let delay = RENDERING_CANCELLED_TIMEOUT;
[16298] Fix | Delete
if (reason.extraDelay > 0 && reason.extraDelay < 1000) {
[16299] Fix | Delete
delay += reason.extraDelay;
[16300] Fix | Delete
}
[16301] Fix | Delete
intentState.streamReaderCancelTimeout = setTimeout(() => {
[16302] Fix | Delete
intentState.streamReaderCancelTimeout = null;
[16303] Fix | Delete
this._abortOperatorList({
[16304] Fix | Delete
intentState,
[16305] Fix | Delete
reason,
[16306] Fix | Delete
force: true
[16307] Fix | Delete
});
[16308] Fix | Delete
}, delay);
[16309] Fix | Delete
return;
[16310] Fix | Delete
}
[16311] Fix | Delete
}
[16312] Fix | Delete
intentState.streamReader.cancel(new AbortException(reason.message)).catch(() => {});
[16313] Fix | Delete
intentState.streamReader = null;
[16314] Fix | Delete
if (this._transport.destroyed) {
[16315] Fix | Delete
return;
[16316] Fix | Delete
}
[16317] Fix | Delete
for (const [curCacheKey, curIntentState] of this._intentStates) {
[16318] Fix | Delete
if (curIntentState === intentState) {
[16319] Fix | Delete
this._intentStates.delete(curCacheKey);
[16320] Fix | Delete
break;
[16321] Fix | Delete
}
[16322] Fix | Delete
}
[16323] Fix | Delete
this.cleanup();
[16324] Fix | Delete
}
[16325] Fix | Delete
get stats() {
[16326] Fix | Delete
return this._stats;
[16327] Fix | Delete
}
[16328] Fix | Delete
}
[16329] Fix | Delete
class LoopbackPort {
[16330] Fix | Delete
#listeners = new Set();
[16331] Fix | Delete
#deferred = Promise.resolve();
[16332] Fix | Delete
postMessage(obj, transfer) {
[16333] Fix | Delete
const event = {
[16334] Fix | Delete
data: structuredClone(obj, transfer ? {
[16335] Fix | Delete
transfer
[16336] Fix | Delete
} : null)
[16337] Fix | Delete
};
[16338] Fix | Delete
this.#deferred.then(() => {
[16339] Fix | Delete
for (const listener of this.#listeners) {
[16340] Fix | Delete
listener.call(this, event);
[16341] Fix | Delete
}
[16342] Fix | Delete
});
[16343] Fix | Delete
}
[16344] Fix | Delete
addEventListener(name, listener) {
[16345] Fix | Delete
this.#listeners.add(listener);
[16346] Fix | Delete
}
[16347] Fix | Delete
removeEventListener(name, listener) {
[16348] Fix | Delete
this.#listeners.delete(listener);
[16349] Fix | Delete
}
[16350] Fix | Delete
terminate() {
[16351] Fix | Delete
this.#listeners.clear();
[16352] Fix | Delete
}
[16353] Fix | Delete
}
[16354] Fix | Delete
const PDFWorkerUtil = {
[16355] Fix | Delete
isWorkerDisabled: false,
[16356] Fix | Delete
fakeWorkerId: 0
[16357] Fix | Delete
};
[16358] Fix | Delete
{
[16359] Fix | Delete
if (isNodeJS) {
[16360] Fix | Delete
PDFWorkerUtil.isWorkerDisabled = true;
[16361] Fix | Delete
GlobalWorkerOptions.workerSrc ||= "./pdf.worker.js";
[16362] Fix | Delete
}
[16363] Fix | Delete
PDFWorkerUtil.isSameOrigin = function (baseUrl, otherUrl) {
[16364] Fix | Delete
let base;
[16365] Fix | Delete
try {
[16366] Fix | Delete
base = new URL(baseUrl);
[16367] Fix | Delete
if (!base.origin || base.origin === "null") {
[16368] Fix | Delete
return false;
[16369] Fix | Delete
}
[16370] Fix | Delete
} catch {
[16371] Fix | Delete
return false;
[16372] Fix | Delete
}
[16373] Fix | Delete
const other = new URL(otherUrl, base);
[16374] Fix | Delete
return base.origin === other.origin;
[16375] Fix | Delete
};
[16376] Fix | Delete
PDFWorkerUtil.createCDNWrapper = function (url) {
[16377] Fix | Delete
const wrapper = `await import("${url}");`;
[16378] Fix | Delete
return URL.createObjectURL(new Blob([wrapper], {
[16379] Fix | Delete
type: "text/javascript"
[16380] Fix | Delete
}));
[16381] Fix | Delete
};
[16382] Fix | Delete
}
[16383] Fix | Delete
class PDFWorker {
[16384] Fix | Delete
static #workerPorts;
[16385] Fix | Delete
constructor({
[16386] Fix | Delete
name = null,
[16387] Fix | Delete
port = null,
[16388] Fix | Delete
verbosity = getVerbosityLevel()
[16389] Fix | Delete
} = {}) {
[16390] Fix | Delete
this.name = name;
[16391] Fix | Delete
this.destroyed = false;
[16392] Fix | Delete
this.verbosity = verbosity;
[16393] Fix | Delete
this._readyCapability = Promise.withResolvers();
[16394] Fix | Delete
this._port = null;
[16395] Fix | Delete
this._webWorker = null;
[16396] Fix | Delete
this._messageHandler = null;
[16397] Fix | Delete
if (port) {
[16398] Fix | Delete
if (PDFWorker.#workerPorts?.has(port)) {
[16399] Fix | Delete
throw new Error("Cannot use more than one PDFWorker per port.");
[16400] Fix | Delete
}
[16401] Fix | Delete
(PDFWorker.#workerPorts ||= new WeakMap()).set(port, this);
[16402] Fix | Delete
this._initializeFromPort(port);
[16403] Fix | Delete
return;
[16404] Fix | Delete
}
[16405] Fix | Delete
this._initialize();
[16406] Fix | Delete
}
[16407] Fix | Delete
get promise() {
[16408] Fix | Delete
if (isNodeJS) {
[16409] Fix | Delete
return Promise.all([NodePackages.promise, this._readyCapability.promise]);
[16410] Fix | Delete
}
[16411] Fix | Delete
return this._readyCapability.promise;
[16412] Fix | Delete
}
[16413] Fix | Delete
get port() {
[16414] Fix | Delete
return this._port;
[16415] Fix | Delete
}
[16416] Fix | Delete
get messageHandler() {
[16417] Fix | Delete
return this._messageHandler;
[16418] Fix | Delete
}
[16419] Fix | Delete
_initializeFromPort(port) {
[16420] Fix | Delete
this._port = port;
[16421] Fix | Delete
this._messageHandler = new MessageHandler("main", "worker", port);
[16422] Fix | Delete
this._messageHandler.on("ready", function () {});
[16423] Fix | Delete
this._readyCapability.resolve();
[16424] Fix | Delete
this._messageHandler.send("configure", {
[16425] Fix | Delete
verbosity: this.verbosity
[16426] Fix | Delete
});
[16427] Fix | Delete
}
[16428] Fix | Delete
_initialize() {
[16429] Fix | Delete
if (!PDFWorkerUtil.isWorkerDisabled && !PDFWorker.#mainThreadWorkerMessageHandler) {
[16430] Fix | Delete
let {
[16431] Fix | Delete
workerSrc
[16432] Fix | Delete
} = PDFWorker;
[16433] Fix | Delete
try {
[16434] Fix | Delete
if (!PDFWorkerUtil.isSameOrigin(window.location.href, workerSrc)) {
[16435] Fix | Delete
workerSrc = PDFWorkerUtil.createCDNWrapper(new URL(workerSrc, window.location).href);
[16436] Fix | Delete
}
[16437] Fix | Delete
const worker = new Worker(workerSrc, {
[16438] Fix | Delete
type: "module"
[16439] Fix | Delete
});
[16440] Fix | Delete
const messageHandler = new MessageHandler("main", "worker", worker);
[16441] Fix | Delete
const terminateEarly = () => {
[16442] Fix | Delete
worker.removeEventListener("error", onWorkerError);
[16443] Fix | Delete
messageHandler.destroy();
[16444] Fix | Delete
worker.terminate();
[16445] Fix | Delete
if (this.destroyed) {
[16446] Fix | Delete
this._readyCapability.reject(new Error("Worker was destroyed"));
[16447] Fix | Delete
} else {
[16448] Fix | Delete
this._setupFakeWorker();
[16449] Fix | Delete
}
[16450] Fix | Delete
};
[16451] Fix | Delete
const onWorkerError = () => {
[16452] Fix | Delete
if (!this._webWorker) {
[16453] Fix | Delete
terminateEarly();
[16454] Fix | Delete
}
[16455] Fix | Delete
};
[16456] Fix | Delete
worker.addEventListener("error", onWorkerError);
[16457] Fix | Delete
messageHandler.on("test", data => {
[16458] Fix | Delete
worker.removeEventListener("error", onWorkerError);
[16459] Fix | Delete
if (this.destroyed) {
[16460] Fix | Delete
terminateEarly();
[16461] Fix | Delete
return;
[16462] Fix | Delete
}
[16463] Fix | Delete
if (data) {
[16464] Fix | Delete
this._messageHandler = messageHandler;
[16465] Fix | Delete
this._port = worker;
[16466] Fix | Delete
this._webWorker = worker;
[16467] Fix | Delete
this._readyCapability.resolve();
[16468] Fix | Delete
messageHandler.send("configure", {
[16469] Fix | Delete
verbosity: this.verbosity
[16470] Fix | Delete
});
[16471] Fix | Delete
} else {
[16472] Fix | Delete
this._setupFakeWorker();
[16473] Fix | Delete
messageHandler.destroy();
[16474] Fix | Delete
worker.terminate();
[16475] Fix | Delete
}
[16476] Fix | Delete
});
[16477] Fix | Delete
messageHandler.on("ready", data => {
[16478] Fix | Delete
worker.removeEventListener("error", onWorkerError);
[16479] Fix | Delete
if (this.destroyed) {
[16480] Fix | Delete
terminateEarly();
[16481] Fix | Delete
return;
[16482] Fix | Delete
}
[16483] Fix | Delete
try {
[16484] Fix | Delete
sendTest();
[16485] Fix | Delete
} catch {
[16486] Fix | Delete
this._setupFakeWorker();
[16487] Fix | Delete
}
[16488] Fix | Delete
});
[16489] Fix | Delete
const sendTest = () => {
[16490] Fix | Delete
const testObj = new Uint8Array();
[16491] Fix | Delete
messageHandler.send("test", testObj, [testObj.buffer]);
[16492] Fix | Delete
};
[16493] Fix | Delete
sendTest();
[16494] Fix | Delete
return;
[16495] Fix | Delete
} catch {
[16496] Fix | Delete
info("The worker has been disabled.");
[16497] Fix | Delete
}
[16498] Fix | Delete
}
[16499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function