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.

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