Skip to content

Commit

Permalink
Update pdf.js to v4.0.269
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Dec 13, 2023
1 parent 7457501 commit d7e3a4b
Show file tree
Hide file tree
Showing 51 changed files with 14,354 additions and 12,836 deletions.
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ node_modules/commander/

node_modules/pdfjs-dist/build/*.min.js
node_modules/pdfjs-dist/build/*.min.mjs
node_modules/pdfjs-dist/build/*.sandbox.*
node_modules/pdfjs-dist/legacy/
node_modules/pdfjs-dist/image_decoders/
node_modules/pdfjs-dist/lib/
Expand Down
6 changes: 1 addition & 5 deletions dev/editviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
.replace('''console.error(`webviewerloaded: ''', '''// console.error(`webviewerloaded: ''')
.replace('''//# sourceMappingURL=viewer.mjs.map''', '''''')
.replace('''console.log(`PDF ${pdfDocument.''', '''// console.log(`PDF ${pdfDocument.''')
.replace('''value: "../build/pdf.worker.mjs",''', '''value: "./build/pdf.worker.mjs",''')
.replace('''value: "../build/pdf.sandbox.mjs",''', '''value: "./build/pdf.sandbox.mjs",''')
.replace('''value: "../web/cmaps/",''', '''value: "../cmaps/",''')
.replace('''value: "../web/standard_fonts/",''', '''value: "../standard_fonts/",''')
.replace('''parent.document.dispatchEvent(event);''', '''parent.document.dispatchEvent(event); \n document.dispatchEvent(event);''')
# .replace('''parent.document.dispatchEvent(event);''', '''parent.document.dispatchEvent(event); \n document.dispatchEvent(event);''')
)

os.system(f'git diff --no-index {args.web}/viewer.html {args.viewer}/viewer.html > {args.viewer}/../dev/viewer/viewer.html.diff')
Expand Down
20 changes: 15 additions & 5 deletions dev/viewer/viewer.html.diff
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/../web/viewer.html b/viewer/viewer.html
index 263f6246..b3d67daf 100644
--- a/../web/viewer.html
+++ b/viewer/viewer.html
@@ -25,15 +25,17 @@ See https://github.com/adobe-type-tools/cmap-resources
diff --git a/../../web/viewer.html b/../viewer/viewer.html
index 45380d45..5ad7b08e 100644
--- a/../../web/viewer.html
+++ b/../viewer/viewer.html
@@ -25,15 +25,18 @@ See https://github.com/adobe-type-tools/cmap-resources
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
Expand All @@ -19,6 +19,16 @@ index 263f6246..b3d67daf 100644

- <script src="viewer.mjs" type="module"></script>
+ <script src="out/viewer/latexworkshop.js" type="module"></script>
+ <script src="viewer/viewer.mjs" type="module"></script>
</head>

<body tabindex="1">
@@ -254,7 +257,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="11" data-l10n-id="pdfjs-toggle-sidebar-button" aria-expanded="false" aria-controls="sidebarContainer">
<span data-l10n-id="pdfjs-toggle-sidebar-button-label">Toggle Sidebar</span>
</button>
- <div class="toolbarButtonSpacer"></div>
+ <!-- <div class="toolbarButtonSpacer"></div> -->
<button id="viewFind" class="toolbarButton" title="Find in Document" tabindex="12" data-l10n-id="pdfjs-findbar-button" aria-expanded="false" aria-controls="findbar">
<span data-l10n-id="pdfjs-findbar-button-label">Find</span>
</button>
136 changes: 57 additions & 79 deletions dev/viewer/viewer.mjs.diff
Original file line number Diff line number Diff line change
@@ -1,44 +1,8 @@
diff --git a/../web/viewer.mjs b/viewer/viewer.mjs
index 1326dc12..038d4c53 100644
--- a/../web/viewer.mjs
+++ b/viewer/viewer.mjs
@@ -795,7 +795,7 @@ const defaultOptions = {
kind: OptionKind.WORKER
},
workerSrc: {
- value: "../build/pdf.worker.mjs",
+ value: "./build/pdf.worker.mjs",
kind: OptionKind.WORKER
}
};
@@ -813,7 +813,7 @@ const defaultOptions = {
kind: OptionKind.VIEWER
};
defaultOptions.sandboxBundleSrc = {
- value: "../build/pdf.sandbox.mjs",
+ value: "./build/pdf.sandbox.mjs",
kind: OptionKind.VIEWER
};
}
@@ -2539,7 +2539,7 @@ const FindState = {
PENDING: 3
};
const FIND_TIMEOUT = 250;
-const MATCH_SCROLL_OFFSET_TOP = -50;
+const MATCH_SCROLL_OFFSET_TOP = -100;
const MATCH_SCROLL_OFFSET_LEFT = -400;
const CHARACTERS_TO_NORMALIZE = {
"\u2010": "-",
@@ -5136,7 +5136,7 @@ class PDFSidebar {
this.#dispatchEvent();
return;
}
- this.switchView(view, true);
+ this.switchView(view, false);
if (!this.isInitialEventDispatched) {
this.#dispatchEvent();
}
@@ -6948,7 +6948,7 @@ class Localization {
diff --git a/../../web/viewer.mjs b/../viewer/viewer.mjs
index c28e89f8..629241fd 100644
--- a/../../web/viewer.mjs
+++ b/../viewer/viewer.mjs
@@ -1121,7 +1121,7 @@ class Localization {
if (typeof console !== "undefined") {
const locale = bundle.locales[0];
const ids = Array.from(missingIds).join(", ");
Expand All @@ -47,29 +11,7 @@ index 1326dc12..038d4c53 100644
}
}
if (!hasAtLeastOneBundle && typeof console !== "undefined") {
@@ -9089,7 +9089,7 @@ class PDFViewer {
this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE;
this.imageResourcesPath = options.imageResourcesPath || "";
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
- this.removePageBorders = options.removePageBorders || false;
+ this.removePageBorders = options.removePageBorders || true;
this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || NullL10n;
@@ -11034,10 +11034,10 @@ class ViewHistory {
}
async _writeToStorage() {
const databaseStr = JSON.stringify(this.database);
- localStorage.setItem("pdfjs.history", databaseStr);
+ // localStorage.setItem("pdfjs.history", databaseStr);
}
async _readFromStorage() {
- return localStorage.getItem("pdfjs.history");
+ return // localStorage.getItem("pdfjs.history");
}
async set(name, val) {
await this._initializedPromise;
@@ -11597,7 +11597,7 @@ const PDFViewerApplication = {
@@ -2534,7 +2534,7 @@ const PDFViewerApplication = {
title = url;
}
}
Expand All @@ -78,18 +20,18 @@ index 1326dc12..038d4c53 100644
},
setTitle(title = this._title) {
this._title = title;
@@ -12049,7 +12049,7 @@ const PDFViewerApplication = {
@@ -2986,7 +2986,7 @@ const PDFViewerApplication = {
this.metadata = metadata;
this._contentDispositionFilename ??= contentDispositionFilename;
this._contentLength ??= contentLength;
- console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${version || "?"} [${build || "?"}])`);
+ // console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${version || "?"} [${build || "?"}])`);
- console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} [${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"}])`);
+ // console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.version || "?"} [${pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.build || "?"}])`);
let pdfTitle = info.Title;
const metadataTitle = metadata?.get("dc:title");
if (metadataTitle) {
@@ -13630,11 +13630,11 @@ class GenericScripting {
@@ -4974,11 +4974,11 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_app
const GenericCom = {};
class GenericPreferences extends BasePreferences {
class GenericPreferences extends _preferences_js__WEBPACK_IMPORTED_MODULE_2__.BasePreferences {
async _writeToStorage(prefObj) {
- localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
+ // localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
Expand All @@ -101,7 +43,16 @@ index 1326dc12..038d4c53 100644
};
}
}
@@ -13884,6 +13884,9 @@ function renderProgress(index, total) {
@@ -6138,7 +6138,7 @@ const FindState = {
PENDING: 3
};
const FIND_TIMEOUT = 250;
-const MATCH_SCROLL_OFFSET_TOP = -50;
+const MATCH_SCROLL_OFFSET_TOP = -100;
const MATCH_SCROLL_OFFSET_LEFT = -400;
const CHARACTERS_TO_NORMALIZE = {
"\u2010": "-",
@@ -9604,6 +9604,9 @@ function renderProgress(index, total) {
}
window.addEventListener("keydown", function (event) {
if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
Expand All @@ -111,22 +62,49 @@ index 1326dc12..038d4c53 100644
window.print();
event.preventDefault();
event.stopImmediatePropagation();
@@ -14077,9 +14080,10 @@ function webViewerLoad() {
@@ -10224,7 +10227,7 @@ class PDFSidebar {
this.#dispatchEvent();
return;
}
});
- this.switchView(view, true);
+ this.switchView(view, false);
if (!this.isInitialEventDispatched) {
this.#dispatchEvent();
}
@@ -11123,7 +11126,7 @@ class PDFViewer {
this.#annotationEditorMode = options.annotationEditorMode ?? pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.NONE;
this.imageResourcesPath = options.imageResourcesPath || "";
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
- this.removePageBorders = options.removePageBorders || false;
+ this.removePageBorders = options.removePageBorders || true;
this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || web_l10n_utils__WEBPACK_IMPORTED_MODULE_2__.NullL10n;
@@ -14576,10 +14579,10 @@ class ViewHistory {
}
async _writeToStorage() {
const databaseStr = JSON.stringify(this.database);
- localStorage.setItem("pdfjs.history", databaseStr);
+ // localStorage.setItem("pdfjs.history", databaseStr);
}
async _readFromStorage() {
- return localStorage.getItem("pdfjs.history");
+ return // localStorage.getItem("pdfjs.history");
}
async set(name, val) {
await this._initializedPromise;
@@ -14783,7 +14786,7 @@ function webViewerLoad() {
try {
- parent.document.dispatchEvent(event);
+ parent.document.dispatchEvent(event);
+ document.dispatchEvent(event);
parent.document.dispatchEvent(event);
} catch (ex) {
- console.error(`webviewerloaded: ${ex}`);
+ // console.error(`webviewerloaded: ${ex}`);
document.dispatchEvent(event);
}
PDFViewerApplication.run(config);
@@ -14096,4 +14100,3 @@ var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFVi
var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions;
export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };
_app_js__WEBPACK_IMPORTED_MODULE_5__.PDFViewerApplication.run(config);
@@ -15006,4 +15009,3 @@ __webpack_async_result__();
/******/ export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };
/******/

-//# sourceMappingURL=viewer.mjs.map
\ No newline at end of file
Loading

0 comments on commit d7e3a4b

Please sign in to comment.