pdfjs-dist 2.2.228 → 2.6.347
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 +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +1144 -927
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
package/lib/web/ui_utils.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -28,7 +28,7 @@ exports.isValidRotation = isValidRotation;
|
|
28
28
|
exports.isValidScrollMode = isValidScrollMode;
|
29
29
|
exports.isValidSpreadMode = isValidSpreadMode;
|
30
30
|
exports.isPortraitOrientation = isPortraitOrientation;
|
31
|
-
exports.
|
31
|
+
exports.clamp = clamp;
|
32
32
|
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
33
33
|
exports.noContextMenuHandler = noContextMenuHandler;
|
34
34
|
exports.parseQueryString = parseQueryString;
|
@@ -41,197 +41,96 @@ exports.getOutputScale = getOutputScale;
|
|
41
41
|
exports.scrollIntoView = scrollIntoView;
|
42
42
|
exports.watchScroll = watchScroll;
|
43
43
|
exports.binarySearchFirstItem = binarySearchFirstItem;
|
44
|
+
exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
|
44
45
|
exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
45
46
|
exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
|
46
47
|
exports.moveToEndOfArray = moveToEndOfArray;
|
47
|
-
exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
|
48
|
-
|
49
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
50
|
-
|
51
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
52
|
-
|
53
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
54
|
-
|
55
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
56
|
-
|
57
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
58
|
-
|
59
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
60
|
-
|
61
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
62
|
-
|
63
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
64
|
-
|
65
|
-
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
66
|
-
|
67
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
68
|
-
|
69
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
70
|
-
|
71
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
72
|
-
|
73
|
-
var CSS_UNITS = 96.0 / 72.0;
|
48
|
+
exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = exports.AutoPrintRegExp = void 0;
|
49
|
+
const CSS_UNITS = 96.0 / 72.0;
|
74
50
|
exports.CSS_UNITS = CSS_UNITS;
|
75
|
-
|
51
|
+
const DEFAULT_SCALE_VALUE = "auto";
|
76
52
|
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
77
|
-
|
53
|
+
const DEFAULT_SCALE = 1.0;
|
78
54
|
exports.DEFAULT_SCALE = DEFAULT_SCALE;
|
79
|
-
|
55
|
+
const MIN_SCALE = 0.1;
|
80
56
|
exports.MIN_SCALE = MIN_SCALE;
|
81
|
-
|
57
|
+
const MAX_SCALE = 10.0;
|
82
58
|
exports.MAX_SCALE = MAX_SCALE;
|
83
|
-
|
59
|
+
const UNKNOWN_SCALE = 0;
|
84
60
|
exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
|
85
|
-
|
61
|
+
const MAX_AUTO_SCALE = 1.25;
|
86
62
|
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
|
87
|
-
|
63
|
+
const SCROLLBAR_PADDING = 40;
|
88
64
|
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
89
|
-
|
65
|
+
const VERTICAL_PADDING = 5;
|
90
66
|
exports.VERTICAL_PADDING = VERTICAL_PADDING;
|
91
|
-
|
67
|
+
const PresentationModeState = {
|
92
68
|
UNKNOWN: 0,
|
93
69
|
NORMAL: 1,
|
94
70
|
CHANGING: 2,
|
95
71
|
FULLSCREEN: 3
|
96
72
|
};
|
97
73
|
exports.PresentationModeState = PresentationModeState;
|
98
|
-
|
99
|
-
CANVAS:
|
100
|
-
SVG:
|
74
|
+
const RendererType = {
|
75
|
+
CANVAS: "canvas",
|
76
|
+
SVG: "svg"
|
101
77
|
};
|
102
78
|
exports.RendererType = RendererType;
|
103
|
-
|
79
|
+
const TextLayerMode = {
|
104
80
|
DISABLE: 0,
|
105
81
|
ENABLE: 1,
|
106
82
|
ENABLE_ENHANCE: 2
|
107
83
|
};
|
108
84
|
exports.TextLayerMode = TextLayerMode;
|
109
|
-
|
85
|
+
const ScrollMode = {
|
110
86
|
UNKNOWN: -1,
|
111
87
|
VERTICAL: 0,
|
112
88
|
HORIZONTAL: 1,
|
113
89
|
WRAPPED: 2
|
114
90
|
};
|
115
91
|
exports.ScrollMode = ScrollMode;
|
116
|
-
|
92
|
+
const SpreadMode = {
|
117
93
|
UNKNOWN: -1,
|
118
94
|
NONE: 0,
|
119
95
|
ODD: 1,
|
120
96
|
EVEN: 2
|
121
97
|
};
|
122
98
|
exports.SpreadMode = SpreadMode;
|
99
|
+
const AutoPrintRegExp = /\bprint\s*\(/;
|
100
|
+
exports.AutoPrintRegExp = AutoPrintRegExp;
|
123
101
|
|
124
102
|
function formatL10nValue(text, args) {
|
125
103
|
if (!args) {
|
126
104
|
return text;
|
127
105
|
}
|
128
106
|
|
129
|
-
return text.replace(/\{\{\s*(\w+)\s*\}\}/g,
|
130
|
-
return name in args ? args[name] :
|
107
|
+
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
|
108
|
+
return name in args ? args[name] : "{{" + name + "}}";
|
131
109
|
});
|
132
110
|
}
|
133
111
|
|
134
|
-
|
135
|
-
getLanguage
|
136
|
-
|
137
|
-
|
138
|
-
_regenerator["default"].mark(function _callee() {
|
139
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
140
|
-
while (1) {
|
141
|
-
switch (_context.prev = _context.next) {
|
142
|
-
case 0:
|
143
|
-
return _context.abrupt("return", 'en-us');
|
144
|
-
|
145
|
-
case 1:
|
146
|
-
case "end":
|
147
|
-
return _context.stop();
|
148
|
-
}
|
149
|
-
}
|
150
|
-
}, _callee);
|
151
|
-
}));
|
112
|
+
const NullL10n = {
|
113
|
+
async getLanguage() {
|
114
|
+
return "en-us";
|
115
|
+
},
|
152
116
|
|
153
|
-
|
154
|
-
|
155
|
-
|
117
|
+
async getDirection() {
|
118
|
+
return "ltr";
|
119
|
+
},
|
156
120
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
var _getDirection = _asyncToGenerator(
|
161
|
-
/*#__PURE__*/
|
162
|
-
_regenerator["default"].mark(function _callee2() {
|
163
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
164
|
-
while (1) {
|
165
|
-
switch (_context2.prev = _context2.next) {
|
166
|
-
case 0:
|
167
|
-
return _context2.abrupt("return", 'ltr');
|
168
|
-
|
169
|
-
case 1:
|
170
|
-
case "end":
|
171
|
-
return _context2.stop();
|
172
|
-
}
|
173
|
-
}
|
174
|
-
}, _callee2);
|
175
|
-
}));
|
121
|
+
async get(property, args, fallback) {
|
122
|
+
return formatL10nValue(fallback, args);
|
123
|
+
},
|
176
124
|
|
177
|
-
|
178
|
-
return _getDirection.apply(this, arguments);
|
179
|
-
}
|
125
|
+
async translate(element) {}
|
180
126
|
|
181
|
-
return getDirection;
|
182
|
-
}(),
|
183
|
-
get: function () {
|
184
|
-
var _get = _asyncToGenerator(
|
185
|
-
/*#__PURE__*/
|
186
|
-
_regenerator["default"].mark(function _callee3(property, args, fallback) {
|
187
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
188
|
-
while (1) {
|
189
|
-
switch (_context3.prev = _context3.next) {
|
190
|
-
case 0:
|
191
|
-
return _context3.abrupt("return", formatL10nValue(fallback, args));
|
192
|
-
|
193
|
-
case 1:
|
194
|
-
case "end":
|
195
|
-
return _context3.stop();
|
196
|
-
}
|
197
|
-
}
|
198
|
-
}, _callee3);
|
199
|
-
}));
|
200
|
-
|
201
|
-
function get(_x, _x2, _x3) {
|
202
|
-
return _get.apply(this, arguments);
|
203
|
-
}
|
204
|
-
|
205
|
-
return get;
|
206
|
-
}(),
|
207
|
-
translate: function () {
|
208
|
-
var _translate = _asyncToGenerator(
|
209
|
-
/*#__PURE__*/
|
210
|
-
_regenerator["default"].mark(function _callee4(element) {
|
211
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
212
|
-
while (1) {
|
213
|
-
switch (_context4.prev = _context4.next) {
|
214
|
-
case 0:
|
215
|
-
case "end":
|
216
|
-
return _context4.stop();
|
217
|
-
}
|
218
|
-
}
|
219
|
-
}, _callee4);
|
220
|
-
}));
|
221
|
-
|
222
|
-
function translate(_x4) {
|
223
|
-
return _translate.apply(this, arguments);
|
224
|
-
}
|
225
|
-
|
226
|
-
return translate;
|
227
|
-
}()
|
228
127
|
};
|
229
128
|
exports.NullL10n = NullL10n;
|
230
129
|
|
231
130
|
function getOutputScale(ctx) {
|
232
|
-
|
233
|
-
|
234
|
-
|
131
|
+
const devicePixelRatio = window.devicePixelRatio || 1;
|
132
|
+
const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
133
|
+
const pixelRatio = devicePixelRatio / backingStoreRatio;
|
235
134
|
return {
|
236
135
|
sx: pixelRatio,
|
237
136
|
sy: pixelRatio,
|
@@ -239,19 +138,18 @@ function getOutputScale(ctx) {
|
|
239
138
|
};
|
240
139
|
}
|
241
140
|
|
242
|
-
function scrollIntoView(element, spot) {
|
243
|
-
|
244
|
-
var parent = element.offsetParent;
|
141
|
+
function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
|
142
|
+
let parent = element.offsetParent;
|
245
143
|
|
246
144
|
if (!parent) {
|
247
|
-
console.error(
|
145
|
+
console.error("offsetParent is not set -- cannot scroll");
|
248
146
|
return;
|
249
147
|
}
|
250
148
|
|
251
|
-
|
252
|
-
|
149
|
+
let offsetY = element.offsetTop + element.clientTop;
|
150
|
+
let offsetX = element.offsetLeft + element.clientLeft;
|
253
151
|
|
254
|
-
while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow ===
|
152
|
+
while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
|
255
153
|
if (parent.dataset._scaleY) {
|
256
154
|
offsetY /= parent.dataset._scaleY;
|
257
155
|
offsetX /= parent.dataset._scaleX;
|
@@ -281,23 +179,23 @@ function scrollIntoView(element, spot) {
|
|
281
179
|
}
|
282
180
|
|
283
181
|
function watchScroll(viewAreaElement, callback) {
|
284
|
-
|
182
|
+
const debounceScroll = function (evt) {
|
285
183
|
if (rAF) {
|
286
184
|
return;
|
287
185
|
}
|
288
186
|
|
289
187
|
rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
|
290
188
|
rAF = null;
|
291
|
-
|
292
|
-
|
189
|
+
const currentX = viewAreaElement.scrollLeft;
|
190
|
+
const lastX = state.lastX;
|
293
191
|
|
294
192
|
if (currentX !== lastX) {
|
295
193
|
state.right = currentX > lastX;
|
296
194
|
}
|
297
195
|
|
298
196
|
state.lastX = currentX;
|
299
|
-
|
300
|
-
|
197
|
+
const currentY = viewAreaElement.scrollTop;
|
198
|
+
const lastY = state.lastY;
|
301
199
|
|
302
200
|
if (currentY !== lastY) {
|
303
201
|
state.down = currentY > lastY;
|
@@ -308,26 +206,26 @@ function watchScroll(viewAreaElement, callback) {
|
|
308
206
|
});
|
309
207
|
};
|
310
208
|
|
311
|
-
|
209
|
+
const state = {
|
312
210
|
right: true,
|
313
211
|
down: true,
|
314
212
|
lastX: viewAreaElement.scrollLeft,
|
315
213
|
lastY: viewAreaElement.scrollTop,
|
316
214
|
_eventHandler: debounceScroll
|
317
215
|
};
|
318
|
-
|
319
|
-
viewAreaElement.addEventListener(
|
216
|
+
let rAF = null;
|
217
|
+
viewAreaElement.addEventListener("scroll", debounceScroll, true);
|
320
218
|
return state;
|
321
219
|
}
|
322
220
|
|
323
221
|
function parseQueryString(query) {
|
324
|
-
|
325
|
-
|
222
|
+
const parts = query.split("&");
|
223
|
+
const params = Object.create(null);
|
326
224
|
|
327
|
-
for (
|
328
|
-
|
329
|
-
|
330
|
-
|
225
|
+
for (let i = 0, ii = parts.length; i < ii; ++i) {
|
226
|
+
const param = parts[i].split("=");
|
227
|
+
const key = param[0].toLowerCase();
|
228
|
+
const value = param.length > 1 ? param[1] : null;
|
331
229
|
params[decodeURIComponent(key)] = decodeURIComponent(value);
|
332
230
|
}
|
333
231
|
|
@@ -335,10 +233,10 @@ function parseQueryString(query) {
|
|
335
233
|
}
|
336
234
|
|
337
235
|
function binarySearchFirstItem(items, condition) {
|
338
|
-
|
339
|
-
|
236
|
+
let minIndex = 0;
|
237
|
+
let maxIndex = items.length - 1;
|
340
238
|
|
341
|
-
if (
|
239
|
+
if (maxIndex < 0 || !condition(items[maxIndex])) {
|
342
240
|
return items.length;
|
343
241
|
}
|
344
242
|
|
@@ -347,8 +245,8 @@ function binarySearchFirstItem(items, condition) {
|
|
347
245
|
}
|
348
246
|
|
349
247
|
while (minIndex < maxIndex) {
|
350
|
-
|
351
|
-
|
248
|
+
const currentIndex = minIndex + maxIndex >> 1;
|
249
|
+
const currentItem = items[currentIndex];
|
352
250
|
|
353
251
|
if (condition(currentItem)) {
|
354
252
|
maxIndex = currentIndex;
|
@@ -365,8 +263,8 @@ function approximateFraction(x) {
|
|
365
263
|
return [x, 1];
|
366
264
|
}
|
367
265
|
|
368
|
-
|
369
|
-
|
266
|
+
const xinv = 1 / x;
|
267
|
+
const limit = 8;
|
370
268
|
|
371
269
|
if (xinv > limit) {
|
372
270
|
return [1, limit];
|
@@ -374,15 +272,15 @@ function approximateFraction(x) {
|
|
374
272
|
return [1, xinv];
|
375
273
|
}
|
376
274
|
|
377
|
-
|
378
|
-
|
275
|
+
const x_ = x > 1 ? xinv : x;
|
276
|
+
let a = 0,
|
379
277
|
b = 1,
|
380
278
|
c = 1,
|
381
279
|
d = 1;
|
382
280
|
|
383
281
|
while (true) {
|
384
|
-
|
385
|
-
|
282
|
+
const p = a + c,
|
283
|
+
q = b + d;
|
386
284
|
|
387
285
|
if (q > limit) {
|
388
286
|
break;
|
@@ -397,7 +295,7 @@ function approximateFraction(x) {
|
|
397
295
|
}
|
398
296
|
}
|
399
297
|
|
400
|
-
|
298
|
+
let result;
|
401
299
|
|
402
300
|
if (x_ - a / b < c / d - x_) {
|
403
301
|
result = x_ === x ? [a, b] : [b, a];
|
@@ -409,24 +307,19 @@ function approximateFraction(x) {
|
|
409
307
|
}
|
410
308
|
|
411
309
|
function roundToDivide(x, div) {
|
412
|
-
|
310
|
+
const r = x % div;
|
413
311
|
return r === 0 ? x : Math.round(x - r + div);
|
414
312
|
}
|
415
313
|
|
416
|
-
function getPageSizeInches(
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
y2 = _view[3];
|
426
|
-
|
427
|
-
var changeOrientation = rotate % 180 !== 0;
|
428
|
-
var width = (x2 - x1) / 72 * userUnit;
|
429
|
-
var height = (y2 - y1) / 72 * userUnit;
|
314
|
+
function getPageSizeInches({
|
315
|
+
view,
|
316
|
+
userUnit,
|
317
|
+
rotate
|
318
|
+
}) {
|
319
|
+
const [x1, y1, x2, y2] = view;
|
320
|
+
const changeOrientation = rotate % 180 !== 0;
|
321
|
+
const width = (x2 - x1) / 72 * userUnit;
|
322
|
+
const height = (y2 - y1) / 72 * userUnit;
|
430
323
|
return {
|
431
324
|
width: changeOrientation ? height : width,
|
432
325
|
height: changeOrientation ? width : height
|
@@ -438,15 +331,15 @@ function backtrackBeforeAllVisibleElements(index, views, top) {
|
|
438
331
|
return index;
|
439
332
|
}
|
440
333
|
|
441
|
-
|
442
|
-
|
334
|
+
let elt = views[index].div;
|
335
|
+
let pageTop = elt.offsetTop + elt.clientTop;
|
443
336
|
|
444
337
|
if (pageTop >= top) {
|
445
338
|
elt = views[index - 1].div;
|
446
339
|
pageTop = elt.offsetTop + elt.clientTop;
|
447
340
|
}
|
448
341
|
|
449
|
-
for (
|
342
|
+
for (let i = index - 2; i >= 0; --i) {
|
450
343
|
elt = views[i].div;
|
451
344
|
|
452
345
|
if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
|
@@ -459,45 +352,43 @@ function backtrackBeforeAllVisibleElements(index, views, top) {
|
|
459
352
|
return index;
|
460
353
|
}
|
461
354
|
|
462
|
-
function getVisibleElements(scrollEl, views) {
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
var left = scrollEl.scrollLeft,
|
468
|
-
right = left + scrollEl.clientWidth;
|
355
|
+
function getVisibleElements(scrollEl, views, sortByVisibility = false, horizontal = false) {
|
356
|
+
const top = scrollEl.scrollTop,
|
357
|
+
bottom = top + scrollEl.clientHeight;
|
358
|
+
const left = scrollEl.scrollLeft,
|
359
|
+
right = left + scrollEl.clientWidth;
|
469
360
|
|
470
361
|
function isElementBottomAfterViewTop(view) {
|
471
|
-
|
472
|
-
|
362
|
+
const element = view.div;
|
363
|
+
const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
|
473
364
|
return elementBottom > top;
|
474
365
|
}
|
475
366
|
|
476
367
|
function isElementRightAfterViewLeft(view) {
|
477
|
-
|
478
|
-
|
368
|
+
const element = view.div;
|
369
|
+
const elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
|
479
370
|
return elementRight > left;
|
480
371
|
}
|
481
372
|
|
482
|
-
|
483
|
-
|
484
|
-
|
373
|
+
const visible = [],
|
374
|
+
numViews = views.length;
|
375
|
+
let firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
|
485
376
|
|
486
377
|
if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
|
487
378
|
firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
|
488
379
|
}
|
489
380
|
|
490
|
-
|
381
|
+
let lastEdge = horizontal ? right : -1;
|
491
382
|
|
492
|
-
for (
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
383
|
+
for (let i = firstVisibleElementInd; i < numViews; i++) {
|
384
|
+
const view = views[i],
|
385
|
+
element = view.div;
|
386
|
+
const currentWidth = element.offsetLeft + element.clientLeft;
|
387
|
+
const currentHeight = element.offsetTop + element.clientTop;
|
388
|
+
const viewWidth = element.clientWidth,
|
389
|
+
viewHeight = element.clientHeight;
|
390
|
+
const viewRight = currentWidth + viewWidth;
|
391
|
+
const viewBottom = currentHeight + viewHeight;
|
501
392
|
|
502
393
|
if (lastEdge === -1) {
|
503
394
|
if (viewBottom >= bottom) {
|
@@ -511,24 +402,24 @@ function getVisibleElements(scrollEl, views) {
|
|
511
402
|
continue;
|
512
403
|
}
|
513
404
|
|
514
|
-
|
515
|
-
|
516
|
-
|
405
|
+
const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
|
406
|
+
const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
|
407
|
+
const percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
|
517
408
|
visible.push({
|
518
409
|
id: view.id,
|
519
410
|
x: currentWidth,
|
520
411
|
y: currentHeight,
|
521
|
-
view
|
522
|
-
percent
|
412
|
+
view,
|
413
|
+
percent
|
523
414
|
});
|
524
415
|
}
|
525
416
|
|
526
|
-
|
527
|
-
|
417
|
+
const first = visible[0],
|
418
|
+
last = visible[visible.length - 1];
|
528
419
|
|
529
420
|
if (sortByVisibility) {
|
530
421
|
visible.sort(function (a, b) {
|
531
|
-
|
422
|
+
const pc = a.percent - b.percent;
|
532
423
|
|
533
424
|
if (Math.abs(pc) > 0.001) {
|
534
425
|
return -pc;
|
@@ -539,8 +430,8 @@ function getVisibleElements(scrollEl, views) {
|
|
539
430
|
}
|
540
431
|
|
541
432
|
return {
|
542
|
-
first
|
543
|
-
last
|
433
|
+
first,
|
434
|
+
last,
|
544
435
|
views: visible
|
545
436
|
};
|
546
437
|
}
|
@@ -550,37 +441,35 @@ function noContextMenuHandler(evt) {
|
|
550
441
|
}
|
551
442
|
|
552
443
|
function isDataSchema(url) {
|
553
|
-
|
554
|
-
|
444
|
+
let i = 0;
|
445
|
+
const ii = url.length;
|
555
446
|
|
556
|
-
while (i < ii && url[i].trim() ===
|
447
|
+
while (i < ii && url[i].trim() === "") {
|
557
448
|
i++;
|
558
449
|
}
|
559
450
|
|
560
|
-
return url.substring(i, i + 5).toLowerCase() ===
|
451
|
+
return url.substring(i, i + 5).toLowerCase() === "data:";
|
561
452
|
}
|
562
453
|
|
563
|
-
function getPDFFileNameFromURL(url) {
|
564
|
-
|
565
|
-
|
566
|
-
if (typeof url !== 'string') {
|
454
|
+
function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
|
455
|
+
if (typeof url !== "string") {
|
567
456
|
return defaultFilename;
|
568
457
|
}
|
569
458
|
|
570
459
|
if (isDataSchema(url)) {
|
571
|
-
console.warn(
|
460
|
+
console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
|
572
461
|
return defaultFilename;
|
573
462
|
}
|
574
463
|
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
464
|
+
const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
465
|
+
const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
466
|
+
const splitURI = reURI.exec(url);
|
467
|
+
let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
|
579
468
|
|
580
469
|
if (suggestedFilename) {
|
581
470
|
suggestedFilename = suggestedFilename[0];
|
582
471
|
|
583
|
-
if (suggestedFilename.includes(
|
472
|
+
if (suggestedFilename.includes("%")) {
|
584
473
|
try {
|
585
474
|
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
|
586
475
|
} catch (ex) {}
|
@@ -590,18 +479,23 @@ function getPDFFileNameFromURL(url) {
|
|
590
479
|
return suggestedFilename || defaultFilename;
|
591
480
|
}
|
592
481
|
|
593
|
-
function
|
594
|
-
|
595
|
-
|
482
|
+
function normalizeWheelEventDirection(evt) {
|
483
|
+
let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
484
|
+
const angle = Math.atan2(evt.deltaY, evt.deltaX);
|
596
485
|
|
597
486
|
if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
|
598
487
|
delta = -delta;
|
599
488
|
}
|
600
489
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
490
|
+
return delta;
|
491
|
+
}
|
492
|
+
|
493
|
+
function normalizeWheelEventDelta(evt) {
|
494
|
+
let delta = normalizeWheelEventDirection(evt);
|
495
|
+
const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
|
496
|
+
const MOUSE_DOM_DELTA_LINE_MODE = 1;
|
497
|
+
const MOUSE_PIXELS_PER_LINE = 30;
|
498
|
+
const MOUSE_LINES_PER_PAGE = 30;
|
605
499
|
|
606
500
|
if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
|
607
501
|
delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
|
@@ -628,25 +522,25 @@ function isPortraitOrientation(size) {
|
|
628
522
|
return size.width <= size.height;
|
629
523
|
}
|
630
524
|
|
631
|
-
|
632
|
-
EVENT:
|
633
|
-
TIMEOUT:
|
525
|
+
const WaitOnType = {
|
526
|
+
EVENT: "event",
|
527
|
+
TIMEOUT: "timeout"
|
634
528
|
};
|
635
529
|
exports.WaitOnType = WaitOnType;
|
636
530
|
|
637
|
-
function waitOnEventOrTimeout(
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
531
|
+
function waitOnEventOrTimeout({
|
532
|
+
target,
|
533
|
+
name,
|
534
|
+
delay = 0
|
535
|
+
}) {
|
642
536
|
return new Promise(function (resolve, reject) {
|
643
|
-
if (
|
644
|
-
throw new Error(
|
537
|
+
if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
|
538
|
+
throw new Error("waitOnEventOrTimeout - invalid parameters.");
|
645
539
|
}
|
646
540
|
|
647
541
|
function handler(type) {
|
648
542
|
if (target instanceof EventBus) {
|
649
|
-
target.
|
543
|
+
target._off(name, eventHandler);
|
650
544
|
} else {
|
651
545
|
target.removeEventListener(name, eventHandler);
|
652
546
|
}
|
@@ -658,237 +552,196 @@ function waitOnEventOrTimeout(_ref2) {
|
|
658
552
|
resolve(type);
|
659
553
|
}
|
660
554
|
|
661
|
-
|
555
|
+
const eventHandler = handler.bind(null, WaitOnType.EVENT);
|
662
556
|
|
663
557
|
if (target instanceof EventBus) {
|
664
|
-
target.
|
558
|
+
target._on(name, eventHandler);
|
665
559
|
} else {
|
666
560
|
target.addEventListener(name, eventHandler);
|
667
561
|
}
|
668
562
|
|
669
|
-
|
670
|
-
|
563
|
+
const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
|
564
|
+
const timeout = setTimeout(timeoutHandler, delay);
|
671
565
|
});
|
672
566
|
}
|
673
567
|
|
674
|
-
|
675
|
-
if (typeof window === 'undefined') {
|
676
|
-
setTimeout(resolve, 20);
|
677
|
-
return;
|
678
|
-
}
|
679
|
-
|
568
|
+
const animationStarted = new Promise(function (resolve) {
|
680
569
|
window.requestAnimationFrame(resolve);
|
681
570
|
});
|
682
571
|
exports.animationStarted = animationStarted;
|
683
572
|
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
function EventBus() {
|
688
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
689
|
-
_ref3$dispatchToDOM = _ref3.dispatchToDOM,
|
690
|
-
dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
|
691
|
-
|
692
|
-
_classCallCheck(this, EventBus);
|
573
|
+
function dispatchDOMEvent(eventName, args = null) {
|
574
|
+
throw new Error("Not implemented: dispatchDOMEvent");
|
575
|
+
}
|
693
576
|
|
577
|
+
class EventBus {
|
578
|
+
constructor(options) {
|
694
579
|
this._listeners = Object.create(null);
|
695
|
-
this._dispatchToDOM = dispatchToDOM === true;
|
696
580
|
}
|
697
581
|
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
if (!eventListeners) {
|
704
|
-
eventListeners = [];
|
705
|
-
this._listeners[eventName] = eventListeners;
|
706
|
-
}
|
582
|
+
on(eventName, listener) {
|
583
|
+
this._on(eventName, listener, {
|
584
|
+
external: true
|
585
|
+
});
|
586
|
+
}
|
707
587
|
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
var eventListeners = this._listeners[eventName];
|
714
|
-
var i;
|
588
|
+
off(eventName, listener) {
|
589
|
+
this._off(eventName, listener, {
|
590
|
+
external: true
|
591
|
+
});
|
592
|
+
}
|
715
593
|
|
716
|
-
|
717
|
-
|
718
|
-
}
|
594
|
+
dispatch(eventName) {
|
595
|
+
const eventListeners = this._listeners[eventName];
|
719
596
|
|
720
|
-
|
597
|
+
if (!eventListeners || eventListeners.length === 0) {
|
598
|
+
return;
|
721
599
|
}
|
722
|
-
}, {
|
723
|
-
key: "dispatch",
|
724
|
-
value: function dispatch(eventName) {
|
725
|
-
var eventListeners = this._listeners[eventName];
|
726
600
|
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
601
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
602
|
+
let externalListeners;
|
603
|
+
eventListeners.slice(0).forEach(function ({
|
604
|
+
listener,
|
605
|
+
external
|
606
|
+
}) {
|
607
|
+
if (external) {
|
608
|
+
if (!externalListeners) {
|
609
|
+
externalListeners = [];
|
732
610
|
}
|
733
611
|
|
612
|
+
externalListeners.push(listener);
|
734
613
|
return;
|
735
614
|
}
|
736
615
|
|
737
|
-
|
738
|
-
|
616
|
+
listener.apply(null, args);
|
617
|
+
});
|
618
|
+
|
619
|
+
if (externalListeners) {
|
620
|
+
externalListeners.forEach(function (listener) {
|
739
621
|
listener.apply(null, args);
|
740
622
|
});
|
741
|
-
|
742
|
-
if (this._dispatchToDOM) {
|
743
|
-
this._dispatchDOMEvent(eventName, args);
|
744
|
-
}
|
623
|
+
externalListeners = null;
|
745
624
|
}
|
746
|
-
}
|
747
|
-
key: "_dispatchDOMEvent",
|
748
|
-
value: function _dispatchDOMEvent(eventName) {
|
749
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
750
|
-
var details = Object.create(null);
|
751
|
-
|
752
|
-
if (args && args.length > 0) {
|
753
|
-
var obj = args[0];
|
754
|
-
|
755
|
-
for (var key in obj) {
|
756
|
-
var value = obj[key];
|
757
|
-
|
758
|
-
if (key === 'source') {
|
759
|
-
if (value === window || value === document) {
|
760
|
-
return;
|
761
|
-
}
|
625
|
+
}
|
762
626
|
|
763
|
-
|
764
|
-
|
627
|
+
_on(eventName, listener, options = null) {
|
628
|
+
let eventListeners = this._listeners[eventName];
|
765
629
|
|
766
|
-
|
767
|
-
|
768
|
-
}
|
769
|
-
|
770
|
-
var event = document.createEvent('CustomEvent');
|
771
|
-
event.initCustomEvent(eventName, true, true, details);
|
772
|
-
document.dispatchEvent(event);
|
630
|
+
if (!eventListeners) {
|
631
|
+
this._listeners[eventName] = eventListeners = [];
|
773
632
|
}
|
774
|
-
}]);
|
775
633
|
|
776
|
-
|
777
|
-
|
634
|
+
eventListeners.push({
|
635
|
+
listener,
|
636
|
+
external: (options && options.external) === true
|
637
|
+
});
|
638
|
+
}
|
778
639
|
|
779
|
-
|
780
|
-
|
640
|
+
_off(eventName, listener, options = null) {
|
641
|
+
const eventListeners = this._listeners[eventName];
|
781
642
|
|
782
|
-
|
783
|
-
|
643
|
+
if (!eventListeners) {
|
644
|
+
return;
|
645
|
+
}
|
784
646
|
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
647
|
+
for (let i = 0, ii = eventListeners.length; i < ii; i++) {
|
648
|
+
if (eventListeners[i].listener === listener) {
|
649
|
+
eventListeners.splice(i, 1);
|
650
|
+
return;
|
651
|
+
}
|
652
|
+
}
|
789
653
|
}
|
790
654
|
|
791
|
-
return globalEventBus;
|
792
655
|
}
|
793
656
|
|
657
|
+
exports.EventBus = EventBus;
|
658
|
+
|
794
659
|
function clamp(v, min, max) {
|
795
660
|
return Math.min(Math.max(v, min), max);
|
796
661
|
}
|
797
662
|
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
width = _ref4.width,
|
805
|
-
units = _ref4.units;
|
806
|
-
|
807
|
-
_classCallCheck(this, ProgressBar);
|
808
|
-
|
663
|
+
class ProgressBar {
|
664
|
+
constructor(id, {
|
665
|
+
height,
|
666
|
+
width,
|
667
|
+
units
|
668
|
+
} = {}) {
|
809
669
|
this.visible = true;
|
810
|
-
this.div = document.querySelector(id +
|
670
|
+
this.div = document.querySelector(id + " .progress");
|
811
671
|
this.bar = this.div.parentNode;
|
812
672
|
this.height = height || 100;
|
813
673
|
this.width = width || 100;
|
814
|
-
this.units = units ||
|
674
|
+
this.units = units || "%";
|
815
675
|
this.div.style.height = this.height + this.units;
|
816
676
|
this.percent = 0;
|
817
677
|
}
|
818
678
|
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
this.div.style.width = this.width + this.units;
|
825
|
-
return;
|
826
|
-
}
|
827
|
-
|
828
|
-
this.div.classList.remove('indeterminate');
|
829
|
-
var progressSize = this.width * this._percent / 100;
|
830
|
-
this.div.style.width = progressSize + this.units;
|
679
|
+
_updateBar() {
|
680
|
+
if (this._indeterminate) {
|
681
|
+
this.div.classList.add("indeterminate");
|
682
|
+
this.div.style.width = this.width + this.units;
|
683
|
+
return;
|
831
684
|
}
|
832
|
-
}, {
|
833
|
-
key: "setWidth",
|
834
|
-
value: function setWidth(viewer) {
|
835
|
-
if (!viewer) {
|
836
|
-
return;
|
837
|
-
}
|
838
685
|
|
839
|
-
|
840
|
-
|
686
|
+
this.div.classList.remove("indeterminate");
|
687
|
+
const progressSize = this.width * this._percent / 100;
|
688
|
+
this.div.style.width = progressSize + this.units;
|
689
|
+
}
|
841
690
|
|
842
|
-
|
843
|
-
|
844
|
-
|
691
|
+
get percent() {
|
692
|
+
return this._percent;
|
693
|
+
}
|
694
|
+
|
695
|
+
set percent(val) {
|
696
|
+
this._indeterminate = isNaN(val);
|
697
|
+
this._percent = clamp(val, 0, 100);
|
698
|
+
|
699
|
+
this._updateBar();
|
700
|
+
}
|
701
|
+
|
702
|
+
setWidth(viewer) {
|
703
|
+
if (!viewer) {
|
704
|
+
return;
|
845
705
|
}
|
846
|
-
}, {
|
847
|
-
key: "hide",
|
848
|
-
value: function hide() {
|
849
|
-
if (!this.visible) {
|
850
|
-
return;
|
851
|
-
}
|
852
706
|
|
853
|
-
|
854
|
-
|
855
|
-
|
707
|
+
const container = viewer.parentNode;
|
708
|
+
const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
709
|
+
|
710
|
+
if (scrollbarWidth > 0) {
|
711
|
+
this.bar.style.width = `calc(100% - ${scrollbarWidth}px)`;
|
856
712
|
}
|
857
|
-
}
|
858
|
-
key: "show",
|
859
|
-
value: function show() {
|
860
|
-
if (this.visible) {
|
861
|
-
return;
|
862
|
-
}
|
713
|
+
}
|
863
714
|
|
864
|
-
|
865
|
-
|
866
|
-
|
715
|
+
hide() {
|
716
|
+
if (!this.visible) {
|
717
|
+
return;
|
867
718
|
}
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
this._updateBar();
|
719
|
+
|
720
|
+
this.visible = false;
|
721
|
+
this.bar.classList.add("hidden");
|
722
|
+
document.body.classList.remove("loadingInProgress");
|
723
|
+
}
|
724
|
+
|
725
|
+
show() {
|
726
|
+
if (this.visible) {
|
727
|
+
return;
|
878
728
|
}
|
879
|
-
}]);
|
880
729
|
|
881
|
-
|
882
|
-
|
730
|
+
this.visible = true;
|
731
|
+
document.body.classList.add("loadingInProgress");
|
732
|
+
this.bar.classList.remove("hidden");
|
733
|
+
}
|
734
|
+
|
735
|
+
}
|
883
736
|
|
884
737
|
exports.ProgressBar = ProgressBar;
|
885
738
|
|
886
739
|
function moveToEndOfArray(arr, condition) {
|
887
|
-
|
888
|
-
|
889
|
-
|
740
|
+
const moved = [],
|
741
|
+
len = arr.length;
|
742
|
+
let write = 0;
|
890
743
|
|
891
|
-
for (
|
744
|
+
for (let read = 0; read < len; ++read) {
|
892
745
|
if (condition(arr[read])) {
|
893
746
|
moved.push(arr[read]);
|
894
747
|
} else {
|
@@ -897,7 +750,7 @@ function moveToEndOfArray(arr, condition) {
|
|
897
750
|
}
|
898
751
|
}
|
899
752
|
|
900
|
-
for (
|
901
|
-
arr[write] = moved[
|
753
|
+
for (let read = 0; write < len; ++read, ++write) {
|
754
|
+
arr[write] = moved[read];
|
902
755
|
}
|
903
756
|
}
|