pdfjs-dist 2.6.347 → 2.7.570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/README.md +3 -3
- package/bower.json +1 -1
- package/build/pdf.js +2050 -1087
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +18219 -10436
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.d.ts +1 -0
- package/es5/build/pdf.js +6623 -6654
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +1 -1
- package/es5/build/pdf.worker.js +20815 -13888
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +1 -1
- package/es5/image_decoders/pdf.image_decoders.js +3817 -4946
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -1
- package/es5/image_decoders/pdf.image_decoders.min.js +1 -1
- package/es5/web/pdf_viewer.css +18 -15
- package/es5/web/pdf_viewer.js +1094 -514
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +774 -168
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +556 -108
- package/lib/core/cff_parser.js +7 -1
- package/lib/core/charsets.js +1 -1
- package/lib/core/cmap.js +20 -1
- package/lib/core/core_utils.js +162 -3
- package/lib/core/crypto.js +1 -1
- package/lib/core/default_appearance.js +132 -0
- package/lib/core/document.js +115 -9
- package/lib/core/encodings.js +1 -1
- package/lib/core/evaluator.js +168 -74
- package/lib/core/fonts.js +97 -11
- package/lib/core/function.js +5 -10
- package/lib/core/glyphlist.js +11 -4529
- package/lib/core/image_utils.js +30 -1
- package/lib/core/jpg.js +1 -1
- package/lib/core/jpx.js +5 -5
- package/lib/core/murmurhash3.js +1 -1
- package/lib/core/obj.js +123 -39
- package/lib/core/pattern.js +4 -4
- package/lib/core/primitives.js +24 -5
- package/lib/core/standard_fonts.js +1 -1
- package/lib/core/stream.js +5 -1
- package/lib/core/unicode.js +15 -1387
- package/lib/core/worker.js +58 -17
- package/lib/core/writer.js +68 -4
- package/lib/display/annotation_layer.js +712 -119
- package/lib/display/annotation_storage.js +21 -4
- package/lib/display/api.js +88 -18
- package/lib/display/canvas.js +414 -375
- package/lib/display/display_utils.js +11 -4
- package/lib/display/fetch_stream.js +3 -3
- package/lib/display/font_loader.js +2 -3
- package/lib/display/metadata.js +54 -20
- package/lib/display/node_stream.js +1 -1
- package/lib/display/optional_content_config.js +1 -1
- package/lib/display/pattern_helper.js +109 -113
- package/lib/display/svg.js +5 -5
- package/lib/display/text_layer.js +54 -54
- package/lib/display/transport_stream.js +4 -4
- package/lib/display/webgl.js +65 -68
- package/lib/examples/node/domstubs.js +9 -4
- package/lib/pdf.js +2 -2
- package/lib/pdf.sandbox.js +311 -0
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/scripting_utils.js +84 -0
- package/lib/shared/util.js +129 -14
- package/lib/{display → shared}/xml_parser.js +112 -4
- package/lib/test/unit/annotation_spec.js +831 -109
- package/lib/test/unit/annotation_storage_spec.js +28 -10
- package/lib/test/unit/api_spec.js +190 -160
- package/lib/test/unit/bidi_spec.js +6 -6
- package/lib/test/unit/cff_parser_spec.js +73 -73
- package/lib/test/unit/clitests_helper.js +2 -0
- package/lib/test/unit/cmap_spec.js +48 -74
- package/lib/test/unit/core_utils_spec.js +34 -0
- package/lib/test/unit/crypto_spec.js +162 -199
- package/lib/test/unit/custom_spec.js +7 -18
- package/lib/test/unit/default_appearance_spec.js +54 -0
- package/lib/test/unit/display_svg_spec.js +24 -19
- package/lib/test/unit/display_utils_spec.js +1 -1
- package/lib/test/unit/document_spec.js +187 -20
- package/lib/test/unit/evaluator_spec.js +30 -30
- package/lib/test/unit/function_spec.js +165 -165
- package/lib/test/unit/jasmine-boot.js +52 -53
- package/lib/test/unit/metadata_spec.js +2 -2
- package/lib/test/unit/murmurhash3_spec.js +29 -16
- package/lib/test/unit/network_spec.js +21 -21
- package/lib/test/unit/pdf_find_controller_spec.js +131 -69
- package/lib/test/unit/pdf_find_utils_spec.js +10 -10
- package/lib/test/unit/scripting_spec.js +1104 -0
- package/lib/test/unit/stream_spec.js +8 -8
- package/lib/test/unit/test_utils.js +16 -19
- package/lib/test/unit/testreporter.js +11 -4
- package/lib/test/unit/type1_parser_spec.js +23 -23
- package/lib/test/unit/ui_utils_spec.js +78 -35
- package/lib/test/unit/unicode_spec.js +7 -7
- package/lib/test/unit/util_spec.js +26 -3
- package/lib/test/unit/writer_spec.js +16 -1
- package/lib/test/unit/xml_spec.js +117 -0
- package/lib/web/annotation_layer_builder.js +18 -6
- package/lib/web/app.js +579 -161
- package/lib/web/app_options.js +14 -0
- package/lib/web/base_tree_viewer.js +50 -0
- package/lib/web/base_viewer.js +350 -14
- package/lib/web/chromecom.js +9 -1
- package/lib/web/debugger.js +1 -2
- package/lib/web/download_manager.js +0 -15
- package/lib/web/firefox_print_service.js +6 -4
- package/lib/web/firefoxcom.js +84 -69
- package/lib/web/generic_scripting.js +55 -0
- package/lib/web/genericcom.js +9 -1
- package/lib/web/grab_to_pan.js +1 -1
- package/lib/web/interfaces.js +9 -3
- package/lib/web/pdf_attachment_viewer.js +1 -3
- package/lib/web/pdf_cursor_tools.js +20 -13
- package/lib/web/pdf_document_properties.js +48 -61
- package/lib/web/pdf_find_bar.js +1 -3
- package/lib/web/pdf_find_controller.js +58 -12
- package/lib/web/pdf_history.js +43 -21
- package/lib/web/pdf_layer_viewer.js +1 -9
- package/lib/web/pdf_link_service.js +108 -78
- package/lib/web/pdf_outline_viewer.js +166 -10
- package/lib/web/pdf_page_view.js +14 -14
- package/lib/web/pdf_presentation_mode.js +21 -31
- package/lib/web/pdf_rendering_queue.js +8 -1
- package/lib/web/pdf_sidebar.js +62 -107
- package/lib/web/pdf_sidebar_resizer.js +11 -21
- package/lib/web/pdf_single_page_viewer.js +8 -0
- package/lib/web/pdf_thumbnail_view.js +26 -26
- package/lib/web/pdf_thumbnail_viewer.js +13 -2
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/pdf_viewer.js +3 -1
- package/lib/web/preferences.js +33 -44
- package/lib/web/text_layer_builder.js +2 -9
- package/lib/web/ui_utils.js +78 -46
- package/lib/web/viewer_compatibility.js +1 -2
- package/package.json +4 -1
- package/types/display/annotation_layer.d.ts +18 -3
- package/types/display/api.d.ts +110 -54
- package/types/display/canvas.d.ts +1 -1
- package/types/display/display_utils.d.ts +96 -95
- package/types/display/fetch_stream.d.ts +2 -2
- package/types/display/metadata.d.ts +4 -0
- package/types/display/pattern_helper.d.ts +1 -1
- package/types/display/text_layer.d.ts +7 -7
- package/types/display/transport_stream.d.ts +1 -1
- package/types/shared/scripting_utils.d.ts +12 -0
- package/types/shared/util.d.ts +281 -250
- package/types/shared/xml_parser.d.ts +64 -0
- package/web/pdf_viewer.css +18 -15
- package/web/pdf_viewer.js +809 -408
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -1
- package/types/display/xml_parser.d.ts +0 -35
package/lib/web/preferences.js
CHANGED
@@ -28,56 +28,45 @@ exports.BasePreferences = void 0;
|
|
28
28
|
|
29
29
|
var _app_options = require("./app_options.js");
|
30
30
|
|
31
|
-
let defaultPreferences = null;
|
32
|
-
|
33
|
-
function getDefaultPreferences() {
|
34
|
-
if (!defaultPreferences) {
|
35
|
-
defaultPreferences = Promise.resolve({
|
36
|
-
"cursorToolOnLoad": 0,
|
37
|
-
"defaultZoomValue": "",
|
38
|
-
"disablePageLabels": false,
|
39
|
-
"enablePermissions": false,
|
40
|
-
"enablePrintAutoRotate": false,
|
41
|
-
"enableWebGL": false,
|
42
|
-
"externalLinkTarget": 0,
|
43
|
-
"historyUpdateUrl": false,
|
44
|
-
"ignoreDestinationZoom": false,
|
45
|
-
"pdfBugEnabled": false,
|
46
|
-
"renderer": "canvas",
|
47
|
-
"renderInteractiveForms": true,
|
48
|
-
"sidebarViewOnLoad": -1,
|
49
|
-
"scrollModeOnLoad": -1,
|
50
|
-
"spreadModeOnLoad": -1,
|
51
|
-
"textLayerMode": 1,
|
52
|
-
"useOnlyCssZoom": false,
|
53
|
-
"viewOnLoad": 0,
|
54
|
-
"disableAutoFetch": false,
|
55
|
-
"disableFontFace": false,
|
56
|
-
"disableRange": false,
|
57
|
-
"disableStream": false
|
58
|
-
});
|
59
|
-
}
|
60
|
-
|
61
|
-
return defaultPreferences;
|
62
|
-
}
|
63
|
-
|
64
31
|
class BasePreferences {
|
65
32
|
constructor() {
|
66
33
|
if (this.constructor === BasePreferences) {
|
67
34
|
throw new Error("Cannot initialize BasePreferences.");
|
68
35
|
}
|
69
36
|
|
70
|
-
this
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
37
|
+
Object.defineProperty(this, "defaults", {
|
38
|
+
value: Object.freeze({
|
39
|
+
"cursorToolOnLoad": 0,
|
40
|
+
"defaultZoomValue": "",
|
41
|
+
"disablePageLabels": false,
|
42
|
+
"enablePermissions": false,
|
43
|
+
"enablePrintAutoRotate": false,
|
44
|
+
"enableScripting": false,
|
45
|
+
"enableWebGL": false,
|
46
|
+
"externalLinkTarget": 0,
|
47
|
+
"historyUpdateUrl": false,
|
48
|
+
"ignoreDestinationZoom": false,
|
49
|
+
"pdfBugEnabled": false,
|
50
|
+
"renderer": "canvas",
|
51
|
+
"renderInteractiveForms": true,
|
52
|
+
"sidebarViewOnLoad": -1,
|
53
|
+
"scrollModeOnLoad": -1,
|
54
|
+
"spreadModeOnLoad": -1,
|
55
|
+
"textLayerMode": 1,
|
56
|
+
"useOnlyCssZoom": false,
|
57
|
+
"viewerCssTheme": 0,
|
58
|
+
"viewOnLoad": 0,
|
59
|
+
"disableAutoFetch": false,
|
60
|
+
"disableFontFace": false,
|
61
|
+
"disableRange": false,
|
62
|
+
"disableStream": false
|
63
|
+
}),
|
64
|
+
writable: false,
|
65
|
+
enumerable: true,
|
66
|
+
configurable: false
|
67
|
+
});
|
68
|
+
this.prefs = Object.assign(Object.create(null), this.defaults);
|
69
|
+
this._initializedPromise = this._readFromStorage(this.defaults).then(prefs => {
|
81
70
|
if (!prefs) {
|
82
71
|
return;
|
83
72
|
}
|
@@ -24,7 +24,7 @@
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.
|
27
|
+
exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
|
28
28
|
|
29
29
|
var _pdf = require("../pdf");
|
30
30
|
|
@@ -140,13 +140,11 @@ class TextLayerBuilder {
|
|
140
140
|
}
|
141
141
|
|
142
142
|
const {
|
143
|
-
findController,
|
144
143
|
textContentItemsStr
|
145
144
|
} = this;
|
146
145
|
let i = 0,
|
147
146
|
iIndex = 0;
|
148
147
|
const end = textContentItemsStr.length - 1;
|
149
|
-
const queryLen = findController.state.query.length;
|
150
148
|
const result = [];
|
151
149
|
|
152
150
|
for (let m = 0, mm = matches.length; m < mm; m++) {
|
@@ -167,12 +165,7 @@ class TextLayerBuilder {
|
|
167
165
|
offset: matchIdx - iIndex
|
168
166
|
}
|
169
167
|
};
|
170
|
-
|
171
|
-
if (matchesLength) {
|
172
|
-
matchIdx += matchesLength[m];
|
173
|
-
} else {
|
174
|
-
matchIdx += queryLen;
|
175
|
-
}
|
168
|
+
matchIdx += matchesLength[m];
|
176
169
|
|
177
170
|
while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
|
178
171
|
iIndex += textContentItemsStr[i].length;
|
package/lib/web/ui_utils.js
CHANGED
@@ -24,28 +24,28 @@
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
+
exports.approximateFraction = approximateFraction;
|
28
|
+
exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
|
29
|
+
exports.binarySearchFirstItem = binarySearchFirstItem;
|
30
|
+
exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
|
31
|
+
exports.getOutputScale = getOutputScale;
|
32
|
+
exports.getPageSizeInches = getPageSizeInches;
|
33
|
+
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
34
|
+
exports.getVisibleElements = getVisibleElements;
|
35
|
+
exports.isPortraitOrientation = isPortraitOrientation;
|
27
36
|
exports.isValidRotation = isValidRotation;
|
28
37
|
exports.isValidScrollMode = isValidScrollMode;
|
29
38
|
exports.isValidSpreadMode = isValidSpreadMode;
|
30
|
-
exports.
|
31
|
-
exports.clamp = clamp;
|
32
|
-
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
39
|
+
exports.moveToEndOfArray = moveToEndOfArray;
|
33
40
|
exports.noContextMenuHandler = noContextMenuHandler;
|
41
|
+
exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
42
|
+
exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
|
34
43
|
exports.parseQueryString = parseQueryString;
|
35
|
-
exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
|
36
|
-
exports.getVisibleElements = getVisibleElements;
|
37
44
|
exports.roundToDivide = roundToDivide;
|
38
|
-
exports.getPageSizeInches = getPageSizeInches;
|
39
|
-
exports.approximateFraction = approximateFraction;
|
40
|
-
exports.getOutputScale = getOutputScale;
|
41
45
|
exports.scrollIntoView = scrollIntoView;
|
42
|
-
exports.watchScroll = watchScroll;
|
43
|
-
exports.binarySearchFirstItem = binarySearchFirstItem;
|
44
|
-
exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
|
45
|
-
exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
46
46
|
exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
|
47
|
-
exports.
|
48
|
-
exports.WaitOnType = exports.
|
47
|
+
exports.watchScroll = watchScroll;
|
48
|
+
exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
|
49
49
|
const CSS_UNITS = 96.0 / 72.0;
|
50
50
|
exports.CSS_UNITS = CSS_UNITS;
|
51
51
|
const DEFAULT_SCALE_VALUE = "auto";
|
@@ -64,6 +64,7 @@ const SCROLLBAR_PADDING = 40;
|
|
64
64
|
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
65
65
|
const VERTICAL_PADDING = 5;
|
66
66
|
exports.VERTICAL_PADDING = VERTICAL_PADDING;
|
67
|
+
const LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
|
67
68
|
const PresentationModeState = {
|
68
69
|
UNKNOWN: 0,
|
69
70
|
NORMAL: 1,
|
@@ -71,6 +72,15 @@ const PresentationModeState = {
|
|
71
72
|
FULLSCREEN: 3
|
72
73
|
};
|
73
74
|
exports.PresentationModeState = PresentationModeState;
|
75
|
+
const SidebarView = {
|
76
|
+
UNKNOWN: -1,
|
77
|
+
NONE: 0,
|
78
|
+
THUMBS: 1,
|
79
|
+
OUTLINE: 2,
|
80
|
+
ATTACHMENTS: 3,
|
81
|
+
LAYERS: 4
|
82
|
+
};
|
83
|
+
exports.SidebarView = SidebarView;
|
74
84
|
const RendererType = {
|
75
85
|
CANVAS: "canvas",
|
76
86
|
SVG: "svg"
|
@@ -129,7 +139,7 @@ exports.NullL10n = NullL10n;
|
|
129
139
|
|
130
140
|
function getOutputScale(ctx) {
|
131
141
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
132
|
-
const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.
|
142
|
+
const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
133
143
|
const pixelRatio = devicePixelRatio / backingStoreRatio;
|
134
144
|
return {
|
135
145
|
sx: pixelRatio,
|
@@ -352,7 +362,13 @@ function backtrackBeforeAllVisibleElements(index, views, top) {
|
|
352
362
|
return index;
|
353
363
|
}
|
354
364
|
|
355
|
-
function getVisibleElements(
|
365
|
+
function getVisibleElements({
|
366
|
+
scrollEl,
|
367
|
+
views,
|
368
|
+
sortByVisibility = false,
|
369
|
+
horizontal = false,
|
370
|
+
rtl = false
|
371
|
+
}) {
|
356
372
|
const top = scrollEl.scrollTop,
|
357
373
|
bottom = top + scrollEl.clientHeight;
|
358
374
|
const left = scrollEl.scrollLeft,
|
@@ -364,15 +380,16 @@ function getVisibleElements(scrollEl, views, sortByVisibility = false, horizonta
|
|
364
380
|
return elementBottom > top;
|
365
381
|
}
|
366
382
|
|
367
|
-
function
|
383
|
+
function isElementNextAfterViewHorizontally(view) {
|
368
384
|
const element = view.div;
|
369
|
-
const
|
370
|
-
|
385
|
+
const elementLeft = element.offsetLeft + element.clientLeft;
|
386
|
+
const elementRight = elementLeft + element.clientWidth;
|
387
|
+
return rtl ? elementLeft < right : elementRight > left;
|
371
388
|
}
|
372
389
|
|
373
390
|
const visible = [],
|
374
391
|
numViews = views.length;
|
375
|
-
let firstVisibleElementInd =
|
392
|
+
let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
|
376
393
|
|
377
394
|
if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
|
378
395
|
firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
|
@@ -404,13 +421,16 @@ function getVisibleElements(scrollEl, views, sortByVisibility = false, horizonta
|
|
404
421
|
|
405
422
|
const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
|
406
423
|
const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
|
407
|
-
const
|
424
|
+
const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
|
425
|
+
fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
|
426
|
+
const percent = fractionHeight * fractionWidth * 100 | 0;
|
408
427
|
visible.push({
|
409
428
|
id: view.id,
|
410
429
|
x: currentWidth,
|
411
430
|
y: currentHeight,
|
412
431
|
view,
|
413
|
-
percent
|
432
|
+
percent,
|
433
|
+
widthPercent: fractionWidth * 100 | 0
|
414
434
|
});
|
415
435
|
}
|
416
436
|
|
@@ -461,8 +481,8 @@ function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
|
|
461
481
|
return defaultFilename;
|
462
482
|
}
|
463
483
|
|
464
|
-
const reURI = /^(?:(?:[^:]+:)?\/\/[
|
465
|
-
const reFilename = /[
|
484
|
+
const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
485
|
+
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
466
486
|
const splitURI = reURI.exec(url);
|
467
487
|
let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
|
468
488
|
|
@@ -579,15 +599,17 @@ class EventBus {
|
|
579
599
|
this._listeners = Object.create(null);
|
580
600
|
}
|
581
601
|
|
582
|
-
on(eventName, listener) {
|
602
|
+
on(eventName, listener, options = null) {
|
583
603
|
this._on(eventName, listener, {
|
584
|
-
external: true
|
604
|
+
external: true,
|
605
|
+
once: options?.once
|
585
606
|
});
|
586
607
|
}
|
587
608
|
|
588
|
-
off(eventName, listener) {
|
609
|
+
off(eventName, listener, options = null) {
|
589
610
|
this._off(eventName, listener, {
|
590
|
-
external: true
|
611
|
+
external: true,
|
612
|
+
once: options?.once
|
591
613
|
});
|
592
614
|
}
|
593
615
|
|
@@ -600,16 +622,17 @@ class EventBus {
|
|
600
622
|
|
601
623
|
const args = Array.prototype.slice.call(arguments, 1);
|
602
624
|
let externalListeners;
|
603
|
-
eventListeners.slice(0).forEach(
|
625
|
+
eventListeners.slice(0).forEach(({
|
604
626
|
listener,
|
605
|
-
external
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
627
|
+
external,
|
628
|
+
once
|
629
|
+
}) => {
|
630
|
+
if (once) {
|
631
|
+
this._off(eventName, listener);
|
632
|
+
}
|
611
633
|
|
612
|
-
|
634
|
+
if (external) {
|
635
|
+
(externalListeners || (externalListeners = [])).push(listener);
|
613
636
|
return;
|
614
637
|
}
|
615
638
|
|
@@ -617,7 +640,7 @@ class EventBus {
|
|
617
640
|
});
|
618
641
|
|
619
642
|
if (externalListeners) {
|
620
|
-
externalListeners.forEach(
|
643
|
+
externalListeners.forEach(listener => {
|
621
644
|
listener.apply(null, args);
|
622
645
|
});
|
623
646
|
externalListeners = null;
|
@@ -625,15 +648,13 @@ class EventBus {
|
|
625
648
|
}
|
626
649
|
|
627
650
|
_on(eventName, listener, options = null) {
|
628
|
-
|
629
|
-
|
630
|
-
if (!eventListeners) {
|
631
|
-
this._listeners[eventName] = eventListeners = [];
|
632
|
-
}
|
651
|
+
var _this$_listeners;
|
633
652
|
|
653
|
+
const eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
|
634
654
|
eventListeners.push({
|
635
655
|
listener,
|
636
|
-
external:
|
656
|
+
external: options?.external === true,
|
657
|
+
once: options?.once === true
|
637
658
|
});
|
638
659
|
}
|
639
660
|
|
@@ -708,7 +729,8 @@ class ProgressBar {
|
|
708
729
|
const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
709
730
|
|
710
731
|
if (scrollbarWidth > 0) {
|
711
|
-
|
732
|
+
const doc = document.documentElement;
|
733
|
+
doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, `${scrollbarWidth}px`);
|
712
734
|
}
|
713
735
|
}
|
714
736
|
|
@@ -719,7 +741,6 @@ class ProgressBar {
|
|
719
741
|
|
720
742
|
this.visible = false;
|
721
743
|
this.bar.classList.add("hidden");
|
722
|
-
document.body.classList.remove("loadingInProgress");
|
723
744
|
}
|
724
745
|
|
725
746
|
show() {
|
@@ -728,7 +749,6 @@ class ProgressBar {
|
|
728
749
|
}
|
729
750
|
|
730
751
|
this.visible = true;
|
731
|
-
document.body.classList.add("loadingInProgress");
|
732
752
|
this.bar.classList.remove("hidden");
|
733
753
|
}
|
734
754
|
|
@@ -753,4 +773,16 @@ function moveToEndOfArray(arr, condition) {
|
|
753
773
|
for (let read = 0; write < len; ++read, ++write) {
|
754
774
|
arr[write] = moved[read];
|
755
775
|
}
|
776
|
+
}
|
777
|
+
|
778
|
+
function getActiveOrFocusedElement() {
|
779
|
+
let curRoot = document;
|
780
|
+
let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
|
781
|
+
|
782
|
+
while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
|
783
|
+
curRoot = curActiveOrFocused.shadowRoot;
|
784
|
+
curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
|
785
|
+
}
|
786
|
+
|
787
|
+
return curActiveOrFocused;
|
756
788
|
}
|
@@ -31,12 +31,11 @@ const compatibilityParams = Object.create(null);
|
|
31
31
|
const platform = typeof navigator !== "undefined" && navigator.platform || "";
|
32
32
|
const maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
|
33
33
|
const isAndroid = /Android/.test(userAgent);
|
34
|
-
const isIE = /Trident/.test(userAgent);
|
35
34
|
const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
|
36
35
|
const isIOSChrome = /CriOS/.test(userAgent);
|
37
36
|
|
38
37
|
(function checkOnBlobSupport() {
|
39
|
-
if (
|
38
|
+
if (isIOSChrome) {
|
40
39
|
compatibilityParams.disableCreateObjectURL = true;
|
41
40
|
}
|
42
41
|
})();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "pdfjs-dist",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.7.570",
|
4
4
|
"main": "build/pdf.js",
|
5
5
|
"types": "types/pdf.d.ts",
|
6
6
|
"description": "Generic build of Mozilla's PDF.js library.",
|
@@ -12,6 +12,9 @@
|
|
12
12
|
"homepage": "http://mozilla.github.io/pdf.js/",
|
13
13
|
"bugs": "https://github.com/mozilla/pdf.js/issues",
|
14
14
|
"license": "Apache-2.0",
|
15
|
+
"peerDependencies": {
|
16
|
+
"worker-loader": "^3.0.7"
|
17
|
+
},
|
15
18
|
"browser": {
|
16
19
|
"canvas": false,
|
17
20
|
"fs": false,
|
@@ -5,14 +5,17 @@ export type AnnotationElementParameters = {
|
|
5
5
|
viewport: any;
|
6
6
|
linkService: any;
|
7
7
|
downloadManager: any;
|
8
|
-
annotationStorage?: AnnotationStorage;
|
8
|
+
annotationStorage?: AnnotationStorage | undefined;
|
9
9
|
/**
|
10
10
|
* - Path for image resources, mainly
|
11
11
|
* for annotation icons. Include trailing slash.
|
12
12
|
*/
|
13
|
-
imageResourcesPath?: string;
|
13
|
+
imageResourcesPath?: string | undefined;
|
14
14
|
renderInteractiveForms: boolean;
|
15
15
|
svgFactory: Object;
|
16
|
+
enableScripting?: boolean | undefined;
|
17
|
+
hasJSActions?: boolean | undefined;
|
18
|
+
mouseState?: Object | undefined;
|
16
19
|
};
|
17
20
|
export type AnnotationLayerParameters = {
|
18
21
|
viewport: any;
|
@@ -25,8 +28,17 @@ export type AnnotationLayerParameters = {
|
|
25
28
|
* - Path for image resources, mainly
|
26
29
|
* for annotation icons. Include trailing slash.
|
27
30
|
*/
|
28
|
-
imageResourcesPath?: string;
|
31
|
+
imageResourcesPath?: string | undefined;
|
29
32
|
renderInteractiveForms: boolean;
|
33
|
+
/**
|
34
|
+
* - Enable embedded script execution.
|
35
|
+
*/
|
36
|
+
enableScripting?: boolean | undefined;
|
37
|
+
/**
|
38
|
+
* - Some fields have JS actions.
|
39
|
+
* The default value is `false`.
|
40
|
+
*/
|
41
|
+
hasJSActions?: boolean | undefined;
|
30
42
|
};
|
31
43
|
/**
|
32
44
|
* @typedef {Object} AnnotationLayerParameters
|
@@ -39,6 +51,9 @@ export type AnnotationLayerParameters = {
|
|
39
51
|
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
40
52
|
* for annotation icons. Include trailing slash.
|
41
53
|
* @property {boolean} renderInteractiveForms
|
54
|
+
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
55
|
+
* @property {boolean} [hasJSActions] - Some fields have JS actions.
|
56
|
+
* The default value is `false`.
|
42
57
|
*/
|
43
58
|
export class AnnotationLayer {
|
44
59
|
/**
|