Remove unnecessary function names in the src/core/worker.js
file
Currently *some* functions in this file have names while others don't, and in a few cases the names are no longer entirely accurate. For the relevant functions there should really be no need to name them, and if memory serves this was originally done since browsers (many years ago) didn't always handle anonymous functions correctly in stack traces.
This commit is contained in:
parent
c7d6ab2f71
commit
a2a200175f
@ -68,7 +68,7 @@ class WorkerTask {
|
|||||||
class WorkerMessageHandler {
|
class WorkerMessageHandler {
|
||||||
static setup(handler, port) {
|
static setup(handler, port) {
|
||||||
let testMessageProcessed = false;
|
let testMessageProcessed = false;
|
||||||
handler.on("test", function wphSetupTest(data) {
|
handler.on("test", function (data) {
|
||||||
if (testMessageProcessed) {
|
if (testMessageProcessed) {
|
||||||
return; // we already processed 'test' message once
|
return; // we already processed 'test' message once
|
||||||
}
|
}
|
||||||
@ -78,11 +78,11 @@ class WorkerMessageHandler {
|
|||||||
handler.send("test", data instanceof Uint8Array);
|
handler.send("test", data instanceof Uint8Array);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("configure", function wphConfigure(data) {
|
handler.on("configure", function (data) {
|
||||||
setVerbosityLevel(data.verbosity);
|
setVerbosityLevel(data.verbosity);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetDocRequest", function wphSetupDoc(data) {
|
handler.on("GetDocRequest", function (data) {
|
||||||
return WorkerMessageHandler.createDocumentHandler(data, port);
|
return WorkerMessageHandler.createDocumentHandler(data, port);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -427,7 +427,7 @@ class WorkerMessageHandler {
|
|||||||
.then(pdfManagerReady, onFailure);
|
.then(pdfManagerReady, onFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.on("GetPage", function wphSetupGetPage(data) {
|
handler.on("GetPage", function (data) {
|
||||||
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
pdfManager.ensure(page, "rotate"),
|
pdfManager.ensure(page, "rotate"),
|
||||||
@ -445,28 +445,28 @@ class WorkerMessageHandler {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetPageIndex", function wphSetupGetPageIndex(data) {
|
handler.on("GetPageIndex", function (data) {
|
||||||
const pageRef = Ref.get(data.num, data.gen);
|
const pageRef = Ref.get(data.num, data.gen);
|
||||||
return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
|
return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetDestinations", function wphSetupGetDestinations(data) {
|
handler.on("GetDestinations", function (data) {
|
||||||
return pdfManager.ensureCatalog("destinations");
|
return pdfManager.ensureCatalog("destinations");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetDestination", function wphSetupGetDestination(data) {
|
handler.on("GetDestination", function (data) {
|
||||||
return pdfManager.ensureCatalog("getDestination", [data.id]);
|
return pdfManager.ensureCatalog("getDestination", [data.id]);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetPageLabels", function wphSetupGetPageLabels(data) {
|
handler.on("GetPageLabels", function (data) {
|
||||||
return pdfManager.ensureCatalog("pageLabels");
|
return pdfManager.ensureCatalog("pageLabels");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetPageLayout", function wphSetupGetPageLayout(data) {
|
handler.on("GetPageLayout", function (data) {
|
||||||
return pdfManager.ensureCatalog("pageLayout");
|
return pdfManager.ensureCatalog("pageLayout");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetPageMode", function wphSetupGetPageMode(data) {
|
handler.on("GetPageMode", function (data) {
|
||||||
return pdfManager.ensureCatalog("pageMode");
|
return pdfManager.ensureCatalog("pageMode");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -478,15 +478,15 @@ class WorkerMessageHandler {
|
|||||||
return pdfManager.ensureCatalog("openAction");
|
return pdfManager.ensureCatalog("openAction");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetAttachments", function wphSetupGetAttachments(data) {
|
handler.on("GetAttachments", function (data) {
|
||||||
return pdfManager.ensureCatalog("attachments");
|
return pdfManager.ensureCatalog("attachments");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetJavaScript", function wphSetupGetJavaScript(data) {
|
handler.on("GetJavaScript", function (data) {
|
||||||
return pdfManager.ensureCatalog("javaScript");
|
return pdfManager.ensureCatalog("javaScript");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetDocJSActions", function wphSetupGetDocJSActions(data) {
|
handler.on("GetDocJSActions", function (data) {
|
||||||
return pdfManager.ensureCatalog("jsActions");
|
return pdfManager.ensureCatalog("jsActions");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ class WorkerMessageHandler {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetOutline", function wphSetupGetOutline(data) {
|
handler.on("GetOutline", function (data) {
|
||||||
return pdfManager.ensureCatalog("documentOutline");
|
return pdfManager.ensureCatalog("documentOutline");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -508,18 +508,18 @@ class WorkerMessageHandler {
|
|||||||
return pdfManager.ensureCatalog("permissions");
|
return pdfManager.ensureCatalog("permissions");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetMetadata", function wphSetupGetMetadata(data) {
|
handler.on("GetMetadata", function (data) {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
pdfManager.ensureDoc("documentInfo"),
|
pdfManager.ensureDoc("documentInfo"),
|
||||||
pdfManager.ensureCatalog("metadata"),
|
pdfManager.ensureCatalog("metadata"),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetMarkInfo", function wphSetupGetMarkInfo(data) {
|
handler.on("GetMarkInfo", function (data) {
|
||||||
return pdfManager.ensureCatalog("markInfo");
|
return pdfManager.ensureCatalog("markInfo");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetData", function wphSetupGetData(data) {
|
handler.on("GetData", function (data) {
|
||||||
return pdfManager.requestLoadedStream().then(function (stream) {
|
return pdfManager.requestLoadedStream().then(function (stream) {
|
||||||
return stream.bytes;
|
return stream.bytes;
|
||||||
});
|
});
|
||||||
@ -694,7 +694,7 @@ class WorkerMessageHandler {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) {
|
handler.on("GetOperatorList", function (data, sink) {
|
||||||
const pageIndex = data.pageIndex;
|
const pageIndex = data.pageIndex;
|
||||||
pdfManager.getPage(pageIndex).then(function (page) {
|
pdfManager.getPage(pageIndex).then(function (page) {
|
||||||
const task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
|
const task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
|
||||||
@ -739,7 +739,7 @@ class WorkerMessageHandler {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetTextContent", function wphExtractText(data, sink) {
|
handler.on("GetTextContent", function (data, sink) {
|
||||||
const pageIndex = data.pageIndex;
|
const pageIndex = data.pageIndex;
|
||||||
|
|
||||||
pdfManager.getPage(pageIndex).then(function (page) {
|
pdfManager.getPage(pageIndex).then(function (page) {
|
||||||
@ -783,7 +783,7 @@ class WorkerMessageHandler {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("GetStructTree", function wphGetStructTree(data) {
|
handler.on("GetStructTree", function (data) {
|
||||||
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
||||||
return pdfManager.ensure(page, "getStructTree");
|
return pdfManager.ensure(page, "getStructTree");
|
||||||
});
|
});
|
||||||
@ -793,11 +793,11 @@ class WorkerMessageHandler {
|
|||||||
return pdfManager.fontFallback(data.id, handler);
|
return pdfManager.fontFallback(data.id, handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("Cleanup", function wphCleanup(data) {
|
handler.on("Cleanup", function (data) {
|
||||||
return pdfManager.cleanup(/* manuallyTriggered = */ true);
|
return pdfManager.cleanup(/* manuallyTriggered = */ true);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("Terminate", function wphTerminate(data) {
|
handler.on("Terminate", function (data) {
|
||||||
terminated = true;
|
terminated = true;
|
||||||
|
|
||||||
const waitOn = [];
|
const waitOn = [];
|
||||||
@ -828,7 +828,7 @@ class WorkerMessageHandler {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("Ready", function wphReady(data) {
|
handler.on("Ready", function (data) {
|
||||||
setupDoc(docParams);
|
setupDoc(docParams);
|
||||||
docParams = null; // we don't need docParams anymore -- saving memory.
|
docParams = null; // we don't need docParams anymore -- saving memory.
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user