Skip to content

Commit

Permalink
Update PDF.js to v4.0.189
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuratak committed Nov 6, 2023
1 parent b7ec824 commit 7227d63
Show file tree
Hide file tree
Showing 234 changed files with 45,472 additions and 40,505 deletions.
99 changes: 55 additions & 44 deletions dev/viewer/viewer.js.diff → dev/viewer/viewer.mjs.diff
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
--- ../tmp/pdfjs-3.11/web/viewer.js 2023-09-24 19:37:24.000000000 +0900
+++ viewer/viewer.js 2023-09-28 07:56:46.000000000 +0900
@@ -43,10 +43,10 @@
exports.GenericCom = GenericCom;
class GenericPreferences extends _preferences.BasePreferences {
async _writeToStorage(prefObj) {
- localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
+ // localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
}
async _readFromStorage(prefObj) {
- return JSON.parse(localStorage.getItem("pdfjs.preferences"));
+ return // JSON.parse(localStorage.getItem("pdfjs.preferences"));
}
}
class GenericExternalServices extends _app.DefaultExternalServices {
@@ -683,7 +683,7 @@
title = url;
}
}
- this.setTitle(title);
+ // this.setTitle(title);
},
setTitle(title = this._title) {
this._title = title;
@@ -5155,7 +5155,7 @@
--- ../tmp/pdfjs-4.0/web/viewer.mjs 2023-11-05 18:06:24
+++ viewer/viewer.mjs 2023-11-06 10:18:29
@@ -2539,7 +2539,7 @@
PENDING: 3
};
exports.FindState = FindState;
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": "-",
@@ -7755,7 +7755,7 @@
\ No newline at end of file
@@ -5136,7 +5136,7 @@
this.#dispatchEvent();
return;
}
Expand All @@ -40,16 +19,28 @@
if (!this.isInitialEventDispatched) {
this.#dispatchEvent();
}
@@ -8655,7 +8655,7 @@
this.#annotationEditorMode = options.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.NONE;
\ No newline at end of file
@@ -6948,7 +6948,7 @@
if (typeof console !== "undefined") {
const locale = bundle.locales[0];
const ids = Array.from(missingIds).join(", ");
- console.warn(`[fluent] Missing translations in ${locale}: ${ids}`);
+ // console.warn(`[fluent] Missing translations in ${locale}: ${ids}`);
}
}
if (!hasAtLeastOneBundle && typeof console !== "undefined") {
\ No newline at end of file
@@ -9089,7 +9089,7 @@
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;
if (options.useOnlyCssZoom) {
console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
options.maxCanvasPixels = 0;
@@ -12516,10 +12516,10 @@
this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || NullL10n;
\ No newline at end of file
@@ -11034,10 +11034,10 @@
}
async _writeToStorage() {
const databaseStr = JSON.stringify(this.database);
Expand All @@ -62,16 +53,34 @@
}
async set(name, val) {
await this._initializedPromise;
@@ -13365,7 +13365,7 @@
function getL10nData(key, args, fallback) {
var data = gL10nData[key];
if (!data) {
- console.warn('#' + key + ' is undefined.');
+ // console.warn('#' + key + ' is undefined.');
if (!fallback) {
return null;
\ No newline at end of file
@@ -11597,7 +11597,7 @@
title = url;
}
@@ -13801,6 +13801,9 @@
}
- this.setTitle(title);
+ // this.setTitle(title);
},
setTitle(title = this._title) {
this._title = title;
\ No newline at end of file
@@ -13630,11 +13630,11 @@
const GenericCom = {};
class GenericPreferences extends BasePreferences {
async _writeToStorage(prefObj) {
- localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
+ // localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
}
async _readFromStorage(prefObj) {
- return {
- prefs: JSON.parse(localStorage.getItem("pdfjs.preferences"))
+ return {
+ prefs: undefined // JSON.parse(localStorage.getItem("pdfjs.preferences"))
};
}
}
\ No newline at end of file
@@ -13884,6 +13884,9 @@
}
window.addEventListener("keydown", function (event) {
if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
Expand All @@ -81,12 +90,14 @@
window.print();
event.preventDefault();
event.stopImmediatePropagation();
@@ -14081,7 +14084,7 @@
\ No newline at end of file
@@ -14079,7 +14082,7 @@
try {
parent.document.dispatchEvent(event);
} catch (ex) {
- console.error(`webviewerloaded: ${ex}`);
+ // console.error(`webviewerloaded: ${ex}`);
document.dispatchEvent(event);
}
_app.PDFViewerApplication.run(config);
PDFViewerApplication.run(config);
\ No newline at end of file
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@
"latex-utensils": "6.2.0",
"mathjax-full": "3.2.2",
"micromatch": "4.0.5",
"pdfjs-dist": "3.11.174",
"pdfjs-dist": "4.0.189",
"workerpool": "6.5.0",
"ws": "8.14.2"
},
Expand Down
4 changes: 2 additions & 2 deletions resources/snippetview/pdfrenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ window.addEventListener('message', async (event) => {

// https://github.com/microsoft/vscode/issues/87282#issuecomment-919464403
const pdfWorkerJsBlob = new Promise(async resolve => {
const result = await fetch(pdfjsDistUri + '/build/pdf.worker.js');
const result = await fetch(pdfjsDistUri + '/build/pdf.worker.mjs');
const blob = await result.blob();
resolve(blob);
})

async function createPdfWorker() {
const blob = await pdfWorkerJsBlob;
const blobUrl = URL.createObjectURL(blob);
pdfjsLib.GlobalWorkerOptions.workerPort = new Worker(blobUrl);
pdfjsLib.GlobalWorkerOptions.workerPort = new Worker(blobUrl, { type: 'module' });
}

async function renderPdfFile(url, opts) {
Expand Down
2 changes: 1 addition & 1 deletion resources/snippetview/snippetview.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script nonce="%VSCODE_NONCE%">
var pdfjsDistUri = '%VSCODE_PDFJS_DIST%';
</script>
<script src="%VSCODE_PDFJS_DIST%/build/pdf.js" nonce="%VSCODE_NONCE%" defer></script>
<script src="%VSCODE_PDFJS_DIST%/build/pdf.mjs" nonce="%VSCODE_NONCE%" type="module"></script>
<script src="%VSCODE_RES%/snippetview/pdfrenderer.js" nonce="%VSCODE_NONCE%" type="module"></script>
<link rel="stylesheet" href="%VSCODE_RES%/snippetview/snippetview.css">
</head>
Expand Down
4 changes: 2 additions & 2 deletions viewer/components/appconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AppConfig {
}

async setupAppOptions() {
const workerPort = new Worker('/build/pdf.worker.js')
const workerPort = new Worker('/build/pdf.worker.mjs', { type: 'module' })
const params = await this.paramsPromise
const color = isPrefersColorSchemeDark() ? params.color.dark : params.color.light
const options = {
Expand All @@ -44,7 +44,7 @@ export class AppConfig {
sidebarViewOnLoad: 0,
standardFontDataUrl: '/standard_fonts/',
workerPort,
workerSrc: '/build/pdf.worker.js',
workerSrc: '/build/pdf.worker.mjs',
forcePageColors: true,
...color
}
Expand Down
4 changes: 2 additions & 2 deletions viewer/latextoybox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ class LateXToyboxPdfViewer implements ILatexToyboxPdfViewer {

// Defines pdfjsLib globally.
// @ts-expect-error
await import('/build/pdf.js')
await import('/build/pdf.mjs')

const extension = new LateXToyboxPdfViewer()
await extension.waitSetupAppOptionsReady()

// Defines PDFViewerApplication, PDFViewerApplicationOptions, and PDFViewerApplicationConstants globally.
// @ts-expect-error
await import('/viewer.js')
await import('/viewer.mjs')
Loading

0 comments on commit 7227d63

Please sign in to comment.