chore(pdfjs): address requested changes

This commit is contained in:
Elian Doran 2025-12-30 01:37:44 +02:00
parent 2304407986
commit 51b0eb74a5
No known key found for this signature in database
3 changed files with 4 additions and 16 deletions

View File

@ -99,7 +99,7 @@ function useStyleInjection(iframeRef: RefObject<HTMLIFrameElement>) {
function getRootCssVariables() {
const styles = getComputedStyle(document.documentElement);
const vars = {};
const vars: Record<string, string> = {};
for (let i = 0; i < styles.length; i++) {
const prop = styles[i];
@ -111,7 +111,7 @@ function getRootCssVariables() {
return vars;
}
function cssVarsToString(vars) {
function cssVarsToString(vars: Record<string, string>) {
return `:root {\n${Object.entries(vars)
.map(([k, v]) => ` ${k}: ${v};`)
.join('\n')}\n}`;

View File

@ -1,9 +1,6 @@
import interceptPersistence from "./persistence";
const LOG_EVENT_BUS = false;
async function main() {
console.log("Hi");
interceptPersistence(getCustomAppOptions());
// Wait for the PDF viewer application to be available.
@ -66,15 +63,4 @@ function manageSave() {
});
}
function patchEventBus() {
const eventBus = window.PDFViewerApplication.eventBus;
const originalDispatch = eventBus.dispatch.bind(eventBus);
eventBus.dispatch = (type: string, data?: any) => {
console.log("PDF.js event:", type, data);
return originalDispatch(type, data);
};
}
main();
console.log("Custom script loaded");

View File

@ -1,4 +1,6 @@
export default function interceptViewHistory(customOptions?: object) {
// We need to monkey-patch the localStorage used by PDF.js to store view history.
// Other attempts to intercept the history saving/loading (like overriding methods on PDFViewerApplication) have failed.
const originalSetItem = Storage.prototype.setItem;
Storage.prototype.setItem = function (key: string, value: string) {
if (key === "pdfjs.history") {