Skip to content

Re-factor loadAndEnablePDFBug and PDFBug.init #13905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const PDFViewerApplication = {
AppOptions.set("fontExtraProperties", true);

const enabled = params.get("pdfbug").split(",");
waitOn.push(loadAndEnablePDFBug(enabled));
waitOn.push(initPDFBug(enabled));
}
// It is not possible to change locale for the (various) extension builds.
if (
Expand Down Expand Up @@ -2139,17 +2139,15 @@ async function loadFakeWorker() {
}
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
window.pdfjsWorker = await import("pdfjs/core/worker.js");
return undefined;
return;
}
return loadScript(PDFWorker.workerSrc);
await loadScript(PDFWorker.workerSrc);
}

function loadAndEnablePDFBug(enabledTabs) {
const appConfig = PDFViewerApplication.appConfig;
return loadScript(appConfig.debuggerScriptPath).then(function () {
PDFBug.enable(enabledTabs);
PDFBug.init({ OPS }, appConfig.mainContainer);
});
async function initPDFBug(enabledTabs) {
const { debuggerScriptPath, mainContainer } = PDFViewerApplication.appConfig;
await loadScript(debuggerScriptPath);
PDFBug.init({ OPS }, mainContainer, enabledTabs);
}

function reportPageStatsPDFBug({ pageNumber }) {
Expand Down
11 changes: 4 additions & 7 deletions web/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ window.PDFBug = (function PDFBugClosure() {
});
}
},
init(pdfjsLib, container) {
init(pdfjsLib, container, ids) {
this.enable(ids);
/*
* Basic Layout:
* PDFBug
Expand Down Expand Up @@ -589,12 +590,8 @@ window.PDFBug = (function PDFBugClosure() {
tool.init(pdfjsLib);
} else {
panel.textContent =
tool.name +
" is disabled. To enable add " +
' "' +
tool.id +
'" to the pdfBug parameter ' +
"and refresh (separate multiple by commas).";
`${tool.name} is disabled. To enable add "${tool.id}" to ` +
"the pdfBug parameter and refresh (separate multiple by commas).";
}
buttons.push(panelButton);
}
Expand Down