Merge pull request #16738 from Snuffleupagus/debugger-import
Re-factor how the `debugger` accesses API-functionality
This commit is contained in:
commit
7448e89d1f
@ -46,7 +46,6 @@ import {
|
|||||||
isPdfFile,
|
isPdfFile,
|
||||||
loadScript,
|
loadScript,
|
||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
OPS,
|
|
||||||
PDFWorker,
|
PDFWorker,
|
||||||
PromiseCapability,
|
PromiseCapability,
|
||||||
shadow,
|
shadow,
|
||||||
@ -375,7 +374,7 @@ const PDFViewerApplication = {
|
|||||||
const enabled = params.get("pdfbug").split(",");
|
const enabled = params.get("pdfbug").split(",");
|
||||||
try {
|
try {
|
||||||
await loadPDFBug(this);
|
await loadPDFBug(this);
|
||||||
this._PDFBug.init({ OPS }, mainContainer, enabled);
|
this._PDFBug.init(mainContainer, enabled);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.error(`_parseHashParams: "${ex.message}".`);
|
console.error(`_parseHashParams: "${ex.message}".`);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let opMap;
|
const { OPS } = globalThis.pdfjsLib || (await import("pdfjs-lib"));
|
||||||
|
|
||||||
|
const opMap = Object.create(null);
|
||||||
|
for (const key in OPS) {
|
||||||
|
opMap[OPS[key]] = key;
|
||||||
|
}
|
||||||
|
|
||||||
const FontInspector = (function FontInspectorClosure() {
|
const FontInspector = (function FontInspectorClosure() {
|
||||||
let fonts;
|
let fonts;
|
||||||
@ -63,7 +68,7 @@ const FontInspector = (function FontInspectorClosure() {
|
|||||||
name: "Font Inspector",
|
name: "Font Inspector",
|
||||||
panel: null,
|
panel: null,
|
||||||
manager: null,
|
manager: null,
|
||||||
init(pdfjsLib) {
|
init() {
|
||||||
const panel = this.panel;
|
const panel = this.panel;
|
||||||
const tmp = document.createElement("button");
|
const tmp = document.createElement("button");
|
||||||
tmp.addEventListener("click", resetSelection);
|
tmp.addEventListener("click", resetSelection);
|
||||||
@ -160,7 +165,7 @@ const StepperManager = (function StepperManagerClosure() {
|
|||||||
name: "Stepper",
|
name: "Stepper",
|
||||||
panel: null,
|
panel: null,
|
||||||
manager: null,
|
manager: null,
|
||||||
init(pdfjsLib) {
|
init() {
|
||||||
const self = this;
|
const self = this;
|
||||||
stepperControls = document.createElement("div");
|
stepperControls = document.createElement("div");
|
||||||
stepperChooser = document.createElement("select");
|
stepperChooser = document.createElement("select");
|
||||||
@ -173,11 +178,6 @@ const StepperManager = (function StepperManagerClosure() {
|
|||||||
if (sessionStorage.getItem("pdfjsBreakPoints")) {
|
if (sessionStorage.getItem("pdfjsBreakPoints")) {
|
||||||
breakPoints = JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"));
|
breakPoints = JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"));
|
||||||
}
|
}
|
||||||
|
|
||||||
opMap = Object.create(null);
|
|
||||||
for (const key in pdfjsLib.OPS) {
|
|
||||||
opMap[pdfjsLib.OPS[key]] = key;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
cleanup() {
|
cleanup() {
|
||||||
stepperChooser.textContent = "";
|
stepperChooser.textContent = "";
|
||||||
@ -457,7 +457,7 @@ const Stats = (function Stats() {
|
|||||||
name: "Stats",
|
name: "Stats",
|
||||||
panel: null,
|
panel: null,
|
||||||
manager: null,
|
manager: null,
|
||||||
init(pdfjsLib) {},
|
init() {},
|
||||||
enabled: false,
|
enabled: false,
|
||||||
active: false,
|
active: false,
|
||||||
// Stats specific functions.
|
// Stats specific functions.
|
||||||
@ -521,7 +521,7 @@ const PDFBug = (function PDFBugClosure() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
init(pdfjsLib, container, ids) {
|
init(container, ids) {
|
||||||
this.loadCSS();
|
this.loadCSS();
|
||||||
this.enable(ids);
|
this.enable(ids);
|
||||||
/*
|
/*
|
||||||
@ -561,7 +561,7 @@ const PDFBug = (function PDFBugClosure() {
|
|||||||
tool.panel = panel;
|
tool.panel = panel;
|
||||||
tool.manager = this;
|
tool.manager = this;
|
||||||
if (tool.enabled) {
|
if (tool.enabled) {
|
||||||
tool.init(pdfjsLib);
|
tool.init();
|
||||||
} else {
|
} else {
|
||||||
panel.textContent =
|
panel.textContent =
|
||||||
`${tool.name} is disabled. To enable add "${tool.id}" to ` +
|
`${tool.name} is disabled. To enable add "${tool.id}" to ` +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user