pdfjs-dist 2.0.943 → 2.4.456
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/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- 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 +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -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/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- 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 +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
package/lib/web/interfaces.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.
|
@@ -19,234 +19,107 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
}();
|
127
|
-
|
128
|
-
var IPDFTextLayerFactory = function () {
|
129
|
-
function IPDFTextLayerFactory() {
|
130
|
-
_classCallCheck(this, IPDFTextLayerFactory);
|
131
|
-
}
|
132
|
-
|
133
|
-
_createClass(IPDFTextLayerFactory, [{
|
134
|
-
key: 'createTextLayerBuilder',
|
135
|
-
value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
|
136
|
-
var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
137
|
-
}
|
138
|
-
}]);
|
139
|
-
|
140
|
-
return IPDFTextLayerFactory;
|
141
|
-
}();
|
142
|
-
|
143
|
-
var IPDFAnnotationLayerFactory = function () {
|
144
|
-
function IPDFAnnotationLayerFactory() {
|
145
|
-
_classCallCheck(this, IPDFAnnotationLayerFactory);
|
146
|
-
}
|
147
|
-
|
148
|
-
_createClass(IPDFAnnotationLayerFactory, [{
|
149
|
-
key: 'createAnnotationLayerBuilder',
|
150
|
-
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
|
151
|
-
var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
152
|
-
var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
153
|
-
var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
154
|
-
}
|
155
|
-
}]);
|
156
|
-
|
157
|
-
return IPDFAnnotationLayerFactory;
|
158
|
-
}();
|
159
|
-
|
160
|
-
var IL10n = function () {
|
161
|
-
function IL10n() {
|
162
|
-
_classCallCheck(this, IL10n);
|
163
|
-
}
|
164
|
-
|
165
|
-
_createClass(IL10n, [{
|
166
|
-
key: 'getLanguage',
|
167
|
-
value: function () {
|
168
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
169
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
170
|
-
while (1) {
|
171
|
-
switch (_context.prev = _context.next) {
|
172
|
-
case 0:
|
173
|
-
case 'end':
|
174
|
-
return _context.stop();
|
175
|
-
}
|
176
|
-
}
|
177
|
-
}, _callee, this);
|
178
|
-
}));
|
179
|
-
|
180
|
-
function getLanguage() {
|
181
|
-
return _ref2.apply(this, arguments);
|
182
|
-
}
|
183
|
-
|
184
|
-
return getLanguage;
|
185
|
-
}()
|
186
|
-
}, {
|
187
|
-
key: 'getDirection',
|
188
|
-
value: function () {
|
189
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
190
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
191
|
-
while (1) {
|
192
|
-
switch (_context2.prev = _context2.next) {
|
193
|
-
case 0:
|
194
|
-
case 'end':
|
195
|
-
return _context2.stop();
|
196
|
-
}
|
197
|
-
}
|
198
|
-
}, _callee2, this);
|
199
|
-
}));
|
200
|
-
|
201
|
-
function getDirection() {
|
202
|
-
return _ref3.apply(this, arguments);
|
203
|
-
}
|
204
|
-
|
205
|
-
return getDirection;
|
206
|
-
}()
|
207
|
-
}, {
|
208
|
-
key: 'get',
|
209
|
-
value: function () {
|
210
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(key, args, fallback) {
|
211
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
212
|
-
while (1) {
|
213
|
-
switch (_context3.prev = _context3.next) {
|
214
|
-
case 0:
|
215
|
-
case 'end':
|
216
|
-
return _context3.stop();
|
217
|
-
}
|
218
|
-
}
|
219
|
-
}, _callee3, this);
|
220
|
-
}));
|
221
|
-
|
222
|
-
function get(_x6, _x7, _x8) {
|
223
|
-
return _ref4.apply(this, arguments);
|
224
|
-
}
|
225
|
-
|
226
|
-
return get;
|
227
|
-
}()
|
228
|
-
}, {
|
229
|
-
key: 'translate',
|
230
|
-
value: function () {
|
231
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) {
|
232
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
233
|
-
while (1) {
|
234
|
-
switch (_context4.prev = _context4.next) {
|
235
|
-
case 0:
|
236
|
-
case 'end':
|
237
|
-
return _context4.stop();
|
238
|
-
}
|
239
|
-
}
|
240
|
-
}, _callee4, this);
|
241
|
-
}));
|
242
|
-
|
243
|
-
function translate(_x9) {
|
244
|
-
return _ref5.apply(this, arguments);
|
245
|
-
}
|
246
|
-
|
247
|
-
return translate;
|
248
|
-
}()
|
249
|
-
}]);
|
250
|
-
|
251
|
-
return IL10n;
|
252
|
-
}();
|
22
|
+
"use strict";
|
23
|
+
|
24
|
+
Object.defineProperty(exports, "__esModule", {
|
25
|
+
value: true
|
26
|
+
});
|
27
|
+
exports.IL10n = exports.IPDFAnnotationLayerFactory = exports.IPDFTextLayerFactory = exports.IRenderableView = exports.IPDFHistory = exports.IPDFLinkService = void 0;
|
28
|
+
|
29
|
+
class IPDFLinkService {
|
30
|
+
get pagesCount() {}
|
31
|
+
|
32
|
+
get page() {}
|
33
|
+
|
34
|
+
set page(value) {}
|
35
|
+
|
36
|
+
get rotation() {}
|
37
|
+
|
38
|
+
set rotation(value) {}
|
39
|
+
|
40
|
+
get externalLinkEnabled() {}
|
41
|
+
|
42
|
+
set externalLinkEnabled(value) {}
|
43
|
+
|
44
|
+
navigateTo(dest) {}
|
45
|
+
|
46
|
+
getDestinationHash(dest) {}
|
47
|
+
|
48
|
+
getAnchorUrl(hash) {}
|
49
|
+
|
50
|
+
setHash(hash) {}
|
51
|
+
|
52
|
+
executeNamedAction(action) {}
|
53
|
+
|
54
|
+
cachePageRef(pageNum, pageRef) {}
|
55
|
+
|
56
|
+
isPageVisible(pageNumber) {}
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
exports.IPDFLinkService = IPDFLinkService;
|
61
|
+
|
62
|
+
class IPDFHistory {
|
63
|
+
initialize({
|
64
|
+
fingerprint,
|
65
|
+
resetHistory = false,
|
66
|
+
updateUrl = false
|
67
|
+
}) {}
|
68
|
+
|
69
|
+
reset() {}
|
70
|
+
|
71
|
+
push({
|
72
|
+
namedDest = null,
|
73
|
+
explicitDest,
|
74
|
+
pageNumber
|
75
|
+
}) {}
|
76
|
+
|
77
|
+
pushCurrentPosition() {}
|
78
|
+
|
79
|
+
back() {}
|
80
|
+
|
81
|
+
forward() {}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
exports.IPDFHistory = IPDFHistory;
|
86
|
+
|
87
|
+
class IRenderableView {
|
88
|
+
get renderingId() {}
|
89
|
+
|
90
|
+
get renderingState() {}
|
91
|
+
|
92
|
+
draw() {}
|
93
|
+
|
94
|
+
resume() {}
|
95
|
+
|
96
|
+
}
|
97
|
+
|
98
|
+
exports.IRenderableView = IRenderableView;
|
99
|
+
|
100
|
+
class IPDFTextLayerFactory {
|
101
|
+
createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
exports.IPDFTextLayerFactory = IPDFTextLayerFactory;
|
106
|
+
|
107
|
+
class IPDFAnnotationLayerFactory {
|
108
|
+
createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = "", renderInteractiveForms = false, l10n = undefined) {}
|
109
|
+
|
110
|
+
}
|
111
|
+
|
112
|
+
exports.IPDFAnnotationLayerFactory = IPDFAnnotationLayerFactory;
|
113
|
+
|
114
|
+
class IL10n {
|
115
|
+
async getLanguage() {}
|
116
|
+
|
117
|
+
async getDirection() {}
|
118
|
+
|
119
|
+
async get(key, args, fallback) {}
|
120
|
+
|
121
|
+
async translate(element) {}
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
exports.IL10n = IL10n;
|
@@ -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.
|
@@ -19,262 +19,108 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.OverlayManager =
|
28
|
-
|
29
|
-
var _regenerator = require('babel-runtime/regenerator');
|
30
|
-
|
31
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
32
|
-
|
33
|
-
var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
34
|
-
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
36
|
-
|
37
|
-
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
38
|
-
|
39
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
40
|
-
|
41
|
-
var OverlayManager = function () {
|
42
|
-
function OverlayManager() {
|
43
|
-
_classCallCheck(this, OverlayManager);
|
27
|
+
exports.OverlayManager = void 0;
|
44
28
|
|
29
|
+
class OverlayManager {
|
30
|
+
constructor() {
|
45
31
|
this._overlays = {};
|
46
32
|
this._active = null;
|
47
33
|
this._keyDownBound = this._keyDown.bind(this);
|
48
34
|
}
|
49
35
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(name, element) {
|
54
|
-
var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
55
|
-
var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
56
|
-
var container;
|
57
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
58
|
-
while (1) {
|
59
|
-
switch (_context.prev = _context.next) {
|
60
|
-
case 0:
|
61
|
-
container = void 0;
|
62
|
-
|
63
|
-
if (!(!name || !element || !(container = element.parentNode))) {
|
64
|
-
_context.next = 5;
|
65
|
-
break;
|
66
|
-
}
|
67
|
-
|
68
|
-
throw new Error('Not enough parameters.');
|
69
|
-
|
70
|
-
case 5:
|
71
|
-
if (!this._overlays[name]) {
|
72
|
-
_context.next = 7;
|
73
|
-
break;
|
74
|
-
}
|
75
|
-
|
76
|
-
throw new Error('The overlay is already registered.');
|
77
|
-
|
78
|
-
case 7:
|
79
|
-
this._overlays[name] = {
|
80
|
-
element: element,
|
81
|
-
container: container,
|
82
|
-
callerCloseMethod: callerCloseMethod,
|
83
|
-
canForceClose: canForceClose
|
84
|
-
};
|
85
|
-
|
86
|
-
case 8:
|
87
|
-
case 'end':
|
88
|
-
return _context.stop();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}, _callee, this);
|
92
|
-
}));
|
93
|
-
|
94
|
-
function register(_x3, _x4) {
|
95
|
-
return _ref.apply(this, arguments);
|
96
|
-
}
|
97
|
-
|
98
|
-
return register;
|
99
|
-
}()
|
100
|
-
}, {
|
101
|
-
key: 'unregister',
|
102
|
-
value: function () {
|
103
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(name) {
|
104
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
105
|
-
while (1) {
|
106
|
-
switch (_context2.prev = _context2.next) {
|
107
|
-
case 0:
|
108
|
-
if (this._overlays[name]) {
|
109
|
-
_context2.next = 4;
|
110
|
-
break;
|
111
|
-
}
|
112
|
-
|
113
|
-
throw new Error('The overlay does not exist.');
|
114
|
-
|
115
|
-
case 4:
|
116
|
-
if (!(this._active === name)) {
|
117
|
-
_context2.next = 6;
|
118
|
-
break;
|
119
|
-
}
|
120
|
-
|
121
|
-
throw new Error('The overlay cannot be removed while it is active.');
|
122
|
-
|
123
|
-
case 6:
|
124
|
-
delete this._overlays[name];
|
125
|
-
|
126
|
-
case 7:
|
127
|
-
case 'end':
|
128
|
-
return _context2.stop();
|
129
|
-
}
|
130
|
-
}
|
131
|
-
}, _callee2, this);
|
132
|
-
}));
|
133
|
-
|
134
|
-
function unregister(_x5) {
|
135
|
-
return _ref2.apply(this, arguments);
|
136
|
-
}
|
137
|
-
|
138
|
-
return unregister;
|
139
|
-
}()
|
140
|
-
}, {
|
141
|
-
key: 'open',
|
142
|
-
value: function () {
|
143
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name) {
|
144
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
145
|
-
while (1) {
|
146
|
-
switch (_context3.prev = _context3.next) {
|
147
|
-
case 0:
|
148
|
-
if (this._overlays[name]) {
|
149
|
-
_context3.next = 4;
|
150
|
-
break;
|
151
|
-
}
|
152
|
-
|
153
|
-
throw new Error('The overlay does not exist.');
|
154
|
-
|
155
|
-
case 4:
|
156
|
-
if (!this._active) {
|
157
|
-
_context3.next = 14;
|
158
|
-
break;
|
159
|
-
}
|
160
|
-
|
161
|
-
if (!this._overlays[name].canForceClose) {
|
162
|
-
_context3.next = 9;
|
163
|
-
break;
|
164
|
-
}
|
165
|
-
|
166
|
-
this._closeThroughCaller();
|
167
|
-
_context3.next = 14;
|
168
|
-
break;
|
36
|
+
get active() {
|
37
|
+
return this._active;
|
38
|
+
}
|
169
39
|
|
170
|
-
|
171
|
-
|
172
|
-
_context3.next = 13;
|
173
|
-
break;
|
174
|
-
}
|
40
|
+
async register(name, element, callerCloseMethod = null, canForceClose = false) {
|
41
|
+
let container;
|
175
42
|
|
176
|
-
|
43
|
+
if (!name || !element || !(container = element.parentNode)) {
|
44
|
+
throw new Error("Not enough parameters.");
|
45
|
+
} else if (this._overlays[name]) {
|
46
|
+
throw new Error("The overlay is already registered.");
|
47
|
+
}
|
177
48
|
|
178
|
-
|
179
|
-
|
49
|
+
this._overlays[name] = {
|
50
|
+
element,
|
51
|
+
container,
|
52
|
+
callerCloseMethod,
|
53
|
+
canForceClose
|
54
|
+
};
|
55
|
+
}
|
180
56
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
57
|
+
async unregister(name) {
|
58
|
+
if (!this._overlays[name]) {
|
59
|
+
throw new Error("The overlay does not exist.");
|
60
|
+
} else if (this._active === name) {
|
61
|
+
throw new Error("The overlay cannot be removed while it is active.");
|
62
|
+
}
|
186
63
|
|
187
|
-
|
188
|
-
|
189
|
-
return _context3.stop();
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}, _callee3, this);
|
193
|
-
}));
|
64
|
+
delete this._overlays[name];
|
65
|
+
}
|
194
66
|
|
195
|
-
|
196
|
-
|
67
|
+
async open(name) {
|
68
|
+
if (!this._overlays[name]) {
|
69
|
+
throw new Error("The overlay does not exist.");
|
70
|
+
} else if (this._active) {
|
71
|
+
if (this._overlays[name].canForceClose) {
|
72
|
+
this._closeThroughCaller();
|
73
|
+
} else if (this._active === name) {
|
74
|
+
throw new Error("The overlay is already active.");
|
75
|
+
} else {
|
76
|
+
throw new Error("Another overlay is currently active.");
|
197
77
|
}
|
78
|
+
}
|
198
79
|
|
199
|
-
|
200
|
-
}()
|
201
|
-
}, {
|
202
|
-
key: 'close',
|
203
|
-
value: function () {
|
204
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name) {
|
205
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
206
|
-
while (1) {
|
207
|
-
switch (_context4.prev = _context4.next) {
|
208
|
-
case 0:
|
209
|
-
if (this._overlays[name]) {
|
210
|
-
_context4.next = 4;
|
211
|
-
break;
|
212
|
-
}
|
80
|
+
this._active = name;
|
213
81
|
|
214
|
-
|
82
|
+
this._overlays[this._active].element.classList.remove("hidden");
|
215
83
|
|
216
|
-
|
217
|
-
if (this._active) {
|
218
|
-
_context4.next = 8;
|
219
|
-
break;
|
220
|
-
}
|
84
|
+
this._overlays[this._active].container.classList.remove("hidden");
|
221
85
|
|
222
|
-
|
86
|
+
window.addEventListener("keydown", this._keyDownBound);
|
87
|
+
}
|
223
88
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
89
|
+
async close(name) {
|
90
|
+
if (!this._overlays[name]) {
|
91
|
+
throw new Error("The overlay does not exist.");
|
92
|
+
} else if (!this._active) {
|
93
|
+
throw new Error("The overlay is currently not active.");
|
94
|
+
} else if (this._active !== name) {
|
95
|
+
throw new Error("Another overlay is currently active.");
|
96
|
+
}
|
229
97
|
|
230
|
-
|
98
|
+
this._overlays[this._active].container.classList.add("hidden");
|
231
99
|
|
232
|
-
|
233
|
-
this._overlays[this._active].container.classList.add('hidden');
|
234
|
-
this._overlays[this._active].element.classList.add('hidden');
|
235
|
-
this._active = null;
|
236
|
-
window.removeEventListener('keydown', this._keyDownBound);
|
100
|
+
this._overlays[this._active].element.classList.add("hidden");
|
237
101
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
}
|
242
|
-
}
|
243
|
-
}, _callee4, this);
|
244
|
-
}));
|
102
|
+
this._active = null;
|
103
|
+
window.removeEventListener("keydown", this._keyDownBound);
|
104
|
+
}
|
245
105
|
|
246
|
-
|
247
|
-
|
248
|
-
|
106
|
+
_keyDown(evt) {
|
107
|
+
if (this._active && evt.keyCode === 27) {
|
108
|
+
this._closeThroughCaller();
|
249
109
|
|
250
|
-
|
251
|
-
}()
|
252
|
-
}, {
|
253
|
-
key: '_keyDown',
|
254
|
-
value: function _keyDown(evt) {
|
255
|
-
if (this._active && evt.keyCode === 27) {
|
256
|
-
this._closeThroughCaller();
|
257
|
-
evt.preventDefault();
|
258
|
-
}
|
110
|
+
evt.preventDefault();
|
259
111
|
}
|
260
|
-
}
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
}
|
266
|
-
if (this._active) {
|
267
|
-
this.close(this._active);
|
268
|
-
}
|
112
|
+
}
|
113
|
+
|
114
|
+
_closeThroughCaller() {
|
115
|
+
if (this._overlays[this._active].callerCloseMethod) {
|
116
|
+
this._overlays[this._active].callerCloseMethod();
|
269
117
|
}
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
return this._active;
|
118
|
+
|
119
|
+
if (this._active) {
|
120
|
+
this.close(this._active);
|
274
121
|
}
|
275
|
-
}
|
122
|
+
}
|
276
123
|
|
277
|
-
|
278
|
-
}();
|
124
|
+
}
|
279
125
|
|
280
126
|
exports.OverlayManager = OverlayManager;
|