Skip to content

Commit 80c0b5b

Browse files
committed
Update unified and pdfjs
1 parent 88d2ce2 commit 80c0b5b

File tree

121 files changed

+3811
-3658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3811
-3658
lines changed

dev/editviewer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
parser.add_argument('-v', '--viewer', help=f'Path to extension viewer/ folder, end without `/`', type=str)
77
args = parser.parse_args()
88

9-
with open(args.web + '/viewer.html', 'rt') as fin:
10-
with open(args.viewer + '/viewer.html', 'wt') as fout:
9+
with open(args.web + '/viewer.html', 'rt', encoding='utf-8') as fin:
10+
with open(args.viewer + '/viewer.html', 'wt', encoding='utf-8') as fout:
1111
for line in fin:
1212
fout.write(
1313
line.replace('''<title>PDF.js viewer</title>''', '''<meta http-equiv="Content-Security-Policy" content="default-src 'self'; base-uri 'none'; connect-src 'self' ws://127.0.0.1:*; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:;">\n <title>PDF.js viewer</title>''')
@@ -16,8 +16,8 @@
1616
.replace('''<script src="viewer.js"></script>''', '''<script src="out/viewer/latexworkshop.js" type="module"></script>''')
1717
)
1818

19-
with open(args.web + '/viewer.js', 'rt') as fin:
20-
with open(args.viewer + '/viewer.js', 'wt') as fout:
19+
with open(args.web + '/viewer.js', 'rt', encoding='utf-8') as fin:
20+
with open(args.viewer + '/viewer.js', 'wt', encoding='utf-8') as fout:
2121
for line in fin:
2222
fout.write(
2323
line.replace('''this.setTitle(title);''', '''// this.setTitle(title);''')
@@ -32,7 +32,7 @@
3232
.replace('''(!event.shiftKey || window.chrome || window.opera)) {''', '''(!event.shiftKey || window.chrome || window.opera)) {\n if (window.parent !== window) {\n return;\n }''')
3333
.replace('''console.error(`webviewerloaded: ''', '''// console.error(`webviewerloaded: ''')
3434
.replace('''console.log(`PDF ${pdfDocument.''', '''// console.log(`PDF ${pdfDocument.''')
35-
.replace('''pdfjsLib = require("../build/pdf.js");''','''pdfjsLib = require("./build/pdf.js");''')
35+
# .replace('''pdfjsLib = require("../build/pdf.js");''','''pdfjsLib = require("./build/pdf.js");''')
3636
.replace('''value: "../build/pdf.worker.js",''', '''value: "./build/pdf.worker.js",''')
3737
.replace('''parent.document.dispatchEvent(event);''', '''parent.document.dispatchEvent(event); \n document.dispatchEvent(event);''')
3838
)

dev/viewer/viewer.html.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/../web/viewer.html b/../viewer/viewer.html
2-
index b1c8711e..852a7a75 100644
2+
index 5763b86d..6adbd130 100644
33
--- a/../web/viewer.html
44
+++ b/../viewer/viewer.html
55
@@ -25,15 +25,17 @@ See https://github.com/adobe-type-tools/cmap-resources

dev/viewer/viewer.js.diff

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/../web/viewer.js b/../viewer/viewer.js
2-
index 5cdd7d2b..fbbf8403 100644
2+
index 2043b5a4..eadaa52e 100644
33
--- a/../web/viewer.js
44
+++ b/../viewer/viewer.js
55
@@ -43,10 +43,10 @@ const GenericCom = {};
@@ -15,7 +15,7 @@ index 5cdd7d2b..fbbf8403 100644
1515
}
1616
}
1717
class GenericExternalServices extends _app.DefaultExternalServices {
18-
@@ -686,7 +686,7 @@ const PDFViewerApplication = {
18+
@@ -683,7 +683,7 @@ const PDFViewerApplication = {
1919
title = url;
2020
}
2121
}
@@ -24,7 +24,7 @@ index 5cdd7d2b..fbbf8403 100644
2424
},
2525
setTitle(title = this._title) {
2626
this._title = title;
27-
@@ -1160,7 +1160,7 @@ const PDFViewerApplication = {
27+
@@ -1152,7 +1152,7 @@ const PDFViewerApplication = {
2828
this.metadata = metadata;
2929
this._contentDispositionFilename ??= contentDispositionFilename;
3030
this._contentLength ??= contentLength;
@@ -33,16 +33,7 @@ index 5cdd7d2b..fbbf8403 100644
3333
let pdfTitle = info.Title;
3434
const metadataTitle = metadata?.get("dc:title");
3535
if (metadataTitle) {
36-
@@ -2984,7 +2984,7 @@ let pdfjsLib;
37-
if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
38-
pdfjsLib = window["pdfjs-dist/build/pdf"];
39-
} else {
40-
- pdfjsLib = require("../build/pdf.js");
41-
+ pdfjsLib = require("./build/pdf.js");
42-
}
43-
module.exports = pdfjsLib;
44-
45-
@@ -3197,7 +3197,7 @@ const defaultOptions = {
36+
@@ -3184,7 +3184,7 @@ const defaultOptions = {
4637
kind: OptionKind.WORKER
4738
},
4839
workerSrc: {
@@ -51,7 +42,7 @@ index 5cdd7d2b..fbbf8403 100644
5142
kind: OptionKind.WORKER
5243
}
5344
};
54-
@@ -4904,7 +4904,7 @@ const FindState = {
45+
@@ -5155,7 +5155,7 @@ const FindState = {
5546
};
5647
exports.FindState = FindState;
5748
const FIND_TIMEOUT = 250;
@@ -60,7 +51,7 @@ index 5cdd7d2b..fbbf8403 100644
6051
const MATCH_SCROLL_OFFSET_LEFT = -400;
6152
const CHARACTERS_TO_NORMALIZE = {
6253
"\u2010": "-",
63-
@@ -7483,7 +7483,7 @@ class PDFSidebar {
54+
@@ -7755,7 +7755,7 @@ class PDFSidebar {
6455
this.#dispatchEvent();
6556
return;
6657
}
@@ -69,16 +60,16 @@ index 5cdd7d2b..fbbf8403 100644
6960
if (!this.isInitialEventDispatched) {
7061
this.#dispatchEvent();
7162
}
72-
@@ -8381,7 +8381,7 @@ class PDFViewer {
63+
@@ -8655,7 +8655,7 @@ class PDFViewer {
7364
this.#annotationEditorMode = options.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.NONE;
7465
this.imageResourcesPath = options.imageResourcesPath || "";
7566
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
7667
- this.removePageBorders = options.removePageBorders || false;
7768
+ this.removePageBorders = options.removePageBorders || true;
78-
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
79-
this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
80-
this.maxCanvasPixels = options.maxCanvasPixels;
81-
@@ -12204,10 +12204,10 @@ class ViewHistory {
69+
if (options.useOnlyCssZoom) {
70+
console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");
71+
options.maxCanvasPixels = 0;
72+
@@ -12516,10 +12516,10 @@ class ViewHistory {
8273
}
8374
async _writeToStorage() {
8475
const databaseStr = JSON.stringify(this.database);
@@ -91,7 +82,7 @@ index 5cdd7d2b..fbbf8403 100644
9182
}
9283
async set(name, val) {
9384
await this._initializedPromise;
94-
@@ -13055,7 +13055,7 @@ document.webL10n = function (window, document) {
85+
@@ -13365,7 +13365,7 @@ document.webL10n = function (window, document) {
9586
function getL10nData(key, args, fallback) {
9687
var data = gL10nData[key];
9788
if (!data) {
@@ -100,7 +91,7 @@ index 5cdd7d2b..fbbf8403 100644
10091
if (!fallback) {
10192
return null;
10293
}
103-
@@ -13491,6 +13491,9 @@ function renderProgress(index, total, l10n) {
94+
@@ -13801,6 +13801,9 @@ function renderProgress(index, total, l10n) {
10495
}
10596
window.addEventListener("keydown", function (event) {
10697
if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
@@ -110,7 +101,7 @@ index 5cdd7d2b..fbbf8403 100644
110101
window.print();
111102
event.preventDefault();
112103
event.stopImmediatePropagation();
113-
@@ -13758,9 +13761,10 @@ function webViewerLoad() {
104+
@@ -14079,9 +14082,10 @@ function webViewerLoad() {
114105
}
115106
});
116107
try {

0 commit comments

Comments
 (0)