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.

Files changed (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -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 2019 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.
@@ -26,137 +26,77 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.PDFViewer = void 0;
28
28
 
29
- var _base_viewer = require("./base_viewer");
29
+ var _base_viewer = require("./base_viewer.js");
30
30
 
31
31
  var _pdf = require("../pdf");
32
32
 
33
- 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); }
34
-
35
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
-
37
- 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); } }
38
-
39
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
40
-
41
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
42
-
43
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
44
-
45
- function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
46
-
47
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
48
-
49
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
50
-
51
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
33
+ class PDFViewer extends _base_viewer.BaseViewer {
34
+ get _viewerElement() {
35
+ return (0, _pdf.shadow)(this, "_viewerElement", this.viewer);
36
+ }
52
37
 
53
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
38
+ _scrollIntoView({
39
+ pageDiv,
40
+ pageSpot = null,
41
+ pageNumber = null
42
+ }) {
43
+ if (!pageSpot && !this.isInPresentationMode) {
44
+ const left = pageDiv.offsetLeft + pageDiv.clientLeft;
45
+ const right = left + pageDiv.clientWidth;
46
+ const {
47
+ scrollLeft,
48
+ clientWidth
49
+ } = this.container;
50
+
51
+ if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
52
+ pageSpot = {
53
+ left: 0,
54
+ top: 0
55
+ };
56
+ }
57
+ }
54
58
 
55
- var PDFViewer =
56
- /*#__PURE__*/
57
- function (_BaseViewer) {
58
- _inherits(PDFViewer, _BaseViewer);
59
+ super._scrollIntoView({
60
+ pageDiv,
61
+ pageSpot,
62
+ pageNumber
63
+ });
64
+ }
59
65
 
60
- function PDFViewer() {
61
- _classCallCheck(this, PDFViewer);
66
+ _getVisiblePages() {
67
+ if (this.isInPresentationMode) {
68
+ return this._getCurrentVisiblePage();
69
+ }
62
70
 
63
- return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
71
+ return super._getVisiblePages();
64
72
  }
65
73
 
66
- _createClass(PDFViewer, [{
67
- key: "_scrollIntoView",
68
- value: function _scrollIntoView(_ref) {
69
- var pageDiv = _ref.pageDiv,
70
- _ref$pageSpot = _ref.pageSpot,
71
- pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
72
- _ref$pageNumber = _ref.pageNumber,
73
- pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
74
-
75
- if (!pageSpot && !this.isInPresentationMode) {
76
- var left = pageDiv.offsetLeft + pageDiv.clientLeft;
77
- var right = left + pageDiv.clientWidth;
78
- var _this$container = this.container,
79
- scrollLeft = _this$container.scrollLeft,
80
- clientWidth = _this$container.clientWidth;
81
-
82
- if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
83
- pageSpot = {
84
- left: 0,
85
- top: 0
86
- };
87
- }
88
- }
89
-
90
- _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
91
- pageDiv: pageDiv,
92
- pageSpot: pageSpot,
93
- pageNumber: pageNumber
94
- });
74
+ _updateHelper(visiblePages) {
75
+ if (this.isInPresentationMode) {
76
+ return;
95
77
  }
96
- }, {
97
- key: "_getVisiblePages",
98
- value: function _getVisiblePages() {
99
- if (this.isInPresentationMode) {
100
- return this._getCurrentVisiblePage();
101
- }
102
78
 
103
- return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
104
- }
105
- }, {
106
- key: "_updateHelper",
107
- value: function _updateHelper(visiblePages) {
108
- if (this.isInPresentationMode) {
109
- return;
110
- }
79
+ let currentId = this._currentPageNumber;
80
+ let stillFullyVisible = false;
111
81
 
112
- var currentId = this._currentPageNumber;
113
- var stillFullyVisible = false;
114
- var _iteratorNormalCompletion = true;
115
- var _didIteratorError = false;
116
- var _iteratorError = undefined;
117
-
118
- try {
119
- for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
120
- var page = _step.value;
121
-
122
- if (page.percent < 100) {
123
- break;
124
- }
125
-
126
- if (page.id === currentId) {
127
- stillFullyVisible = true;
128
- break;
129
- }
130
- }
131
- } catch (err) {
132
- _didIteratorError = true;
133
- _iteratorError = err;
134
- } finally {
135
- try {
136
- if (!_iteratorNormalCompletion && _iterator["return"] != null) {
137
- _iterator["return"]();
138
- }
139
- } finally {
140
- if (_didIteratorError) {
141
- throw _iteratorError;
142
- }
143
- }
82
+ for (const page of visiblePages) {
83
+ if (page.percent < 100) {
84
+ break;
144
85
  }
145
86
 
146
- if (!stillFullyVisible) {
147
- currentId = visiblePages[0].id;
87
+ if (page.id === currentId) {
88
+ stillFullyVisible = true;
89
+ break;
148
90
  }
149
-
150
- this._setCurrentPageNumber(currentId);
151
91
  }
152
- }, {
153
- key: "_setDocumentViewerElement",
154
- get: function get() {
155
- return (0, _pdf.shadow)(this, '_setDocumentViewerElement', this.viewer);
92
+
93
+ if (!stillFullyVisible) {
94
+ currentId = visiblePages[0].id;
156
95
  }
157
- }]);
158
96
 
159
- return PDFViewer;
160
- }(_base_viewer.BaseViewer);
97
+ this._setCurrentPageNumber(currentId);
98
+ }
99
+
100
+ }
161
101
 
162
102
  exports.PDFViewer = PDFViewer;
@@ -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 2019 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.
@@ -26,23 +26,9 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.BasePreferences = void 0;
28
28
 
29
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
29
+ var _app_options = require("./app_options.js");
30
30
 
31
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
32
-
33
- 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); } }
34
-
35
- 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); }); }; }
36
-
37
- 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); }
38
-
39
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
40
-
41
- 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); } }
42
-
43
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
44
-
45
- var defaultPreferences = null;
31
+ let defaultPreferences = null;
46
32
 
47
33
  function getDefaultPreferences() {
48
34
  if (!defaultPreferences) {
@@ -50,14 +36,15 @@ function getDefaultPreferences() {
50
36
  "cursorToolOnLoad": 0,
51
37
  "defaultZoomValue": "",
52
38
  "disablePageLabels": false,
39
+ "enablePermissions": false,
53
40
  "enablePrintAutoRotate": false,
54
41
  "enableWebGL": false,
55
- "eventBusDispatchToDOM": false,
56
42
  "externalLinkTarget": 0,
57
43
  "historyUpdateUrl": false,
44
+ "ignoreDestinationZoom": false,
58
45
  "pdfBugEnabled": false,
59
46
  "renderer": "canvas",
60
- "renderInteractiveForms": false,
47
+ "renderInteractiveForms": true,
61
48
  "sidebarViewOnLoad": -1,
62
49
  "scrollModeOnLoad": -1,
63
50
  "spreadModeOnLoad": -1,
@@ -74,296 +61,105 @@ function getDefaultPreferences() {
74
61
  return defaultPreferences;
75
62
  }
76
63
 
77
- var BasePreferences =
78
- /*#__PURE__*/
79
- function () {
80
- function BasePreferences() {
81
- var _this = this;
82
-
83
- _classCallCheck(this, BasePreferences);
84
-
64
+ class BasePreferences {
65
+ constructor() {
85
66
  if (this.constructor === BasePreferences) {
86
- throw new Error('Cannot initialize BasePreferences.');
67
+ throw new Error("Cannot initialize BasePreferences.");
87
68
  }
88
69
 
89
70
  this.prefs = null;
90
- this._initializedPromise = getDefaultPreferences().then(function (defaults) {
91
- Object.defineProperty(_this, 'defaults', {
71
+ this._initializedPromise = getDefaultPreferences().then(defaults => {
72
+ Object.defineProperty(this, "defaults", {
92
73
  value: Object.freeze(defaults),
93
74
  writable: false,
94
75
  enumerable: true,
95
76
  configurable: false
96
77
  });
97
- _this.prefs = Object.assign(Object.create(null), defaults);
98
- return _this._readFromStorage(defaults);
99
- }).then(function (prefs) {
78
+ this.prefs = Object.assign(Object.create(null), defaults);
79
+ return this._readFromStorage(defaults);
80
+ }).then(prefs => {
100
81
  if (!prefs) {
101
82
  return;
102
83
  }
103
84
 
104
- for (var name in prefs) {
105
- var defaultValue = _this.defaults[name],
106
- prefValue = prefs[name];
85
+ for (const name in prefs) {
86
+ const defaultValue = this.defaults[name],
87
+ prefValue = prefs[name];
107
88
 
108
- if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
89
+ if (defaultValue === undefined || typeof prefValue !== typeof defaultValue) {
109
90
  continue;
110
91
  }
111
92
 
112
- _this.prefs[name] = prefValue;
93
+ this.prefs[name] = prefValue;
113
94
  }
114
95
  });
115
96
  }
116
97
 
117
- _createClass(BasePreferences, [{
118
- key: "_writeToStorage",
119
- value: function () {
120
- var _writeToStorage2 = _asyncToGenerator(
121
- /*#__PURE__*/
122
- _regenerator["default"].mark(function _callee(prefObj) {
123
- return _regenerator["default"].wrap(function _callee$(_context) {
124
- while (1) {
125
- switch (_context.prev = _context.next) {
126
- case 0:
127
- throw new Error('Not implemented: _writeToStorage');
128
-
129
- case 1:
130
- case "end":
131
- return _context.stop();
132
- }
133
- }
134
- }, _callee);
135
- }));
136
-
137
- function _writeToStorage(_x) {
138
- return _writeToStorage2.apply(this, arguments);
139
- }
140
-
141
- return _writeToStorage;
142
- }()
143
- }, {
144
- key: "_readFromStorage",
145
- value: function () {
146
- var _readFromStorage2 = _asyncToGenerator(
147
- /*#__PURE__*/
148
- _regenerator["default"].mark(function _callee2(prefObj) {
149
- return _regenerator["default"].wrap(function _callee2$(_context2) {
150
- while (1) {
151
- switch (_context2.prev = _context2.next) {
152
- case 0:
153
- throw new Error('Not implemented: _readFromStorage');
98
+ async _writeToStorage(prefObj) {
99
+ throw new Error("Not implemented: _writeToStorage");
100
+ }
154
101
 
155
- case 1:
156
- case "end":
157
- return _context2.stop();
158
- }
159
- }
160
- }, _callee2);
161
- }));
102
+ async _readFromStorage(prefObj) {
103
+ throw new Error("Not implemented: _readFromStorage");
104
+ }
162
105
 
163
- function _readFromStorage(_x2) {
164
- return _readFromStorage2.apply(this, arguments);
165
- }
106
+ async reset() {
107
+ await this._initializedPromise;
108
+ this.prefs = Object.assign(Object.create(null), this.defaults);
109
+ return this._writeToStorage(this.defaults);
110
+ }
166
111
 
167
- return _readFromStorage;
168
- }()
169
- }, {
170
- key: "reset",
171
- value: function () {
172
- var _reset = _asyncToGenerator(
173
- /*#__PURE__*/
174
- _regenerator["default"].mark(function _callee3() {
175
- return _regenerator["default"].wrap(function _callee3$(_context3) {
176
- while (1) {
177
- switch (_context3.prev = _context3.next) {
178
- case 0:
179
- _context3.next = 2;
180
- return this._initializedPromise;
112
+ async set(name, value) {
113
+ await this._initializedPromise;
114
+ const defaultValue = this.defaults[name];
181
115
 
182
- case 2:
183
- this.prefs = Object.assign(Object.create(null), this.defaults);
184
- return _context3.abrupt("return", this._writeToStorage(this.defaults));
116
+ if (defaultValue === undefined) {
117
+ throw new Error(`Set preference: "${name}" is undefined.`);
118
+ } else if (value === undefined) {
119
+ throw new Error("Set preference: no value is specified.");
120
+ }
185
121
 
186
- case 4:
187
- case "end":
188
- return _context3.stop();
189
- }
190
- }
191
- }, _callee3, this);
192
- }));
122
+ const valueType = typeof value;
123
+ const defaultType = typeof defaultValue;
193
124
 
194
- function reset() {
195
- return _reset.apply(this, arguments);
125
+ if (valueType !== defaultType) {
126
+ if (valueType === "number" && defaultType === "string") {
127
+ value = value.toString();
128
+ } else {
129
+ throw new Error(`Set preference: "${value}" is a ${valueType}, ` + `expected a ${defaultType}.`);
196
130
  }
197
-
198
- return reset;
199
- }()
200
- }, {
201
- key: "set",
202
- value: function () {
203
- var _set = _asyncToGenerator(
204
- /*#__PURE__*/
205
- _regenerator["default"].mark(function _callee4(name, value) {
206
- var defaultValue, valueType, defaultType;
207
- return _regenerator["default"].wrap(function _callee4$(_context4) {
208
- while (1) {
209
- switch (_context4.prev = _context4.next) {
210
- case 0:
211
- _context4.next = 2;
212
- return this._initializedPromise;
213
-
214
- case 2:
215
- defaultValue = this.defaults[name];
216
-
217
- if (!(defaultValue === undefined)) {
218
- _context4.next = 7;
219
- break;
220
- }
221
-
222
- throw new Error("Set preference: \"".concat(name, "\" is undefined."));
223
-
224
- case 7:
225
- if (!(value === undefined)) {
226
- _context4.next = 9;
227
- break;
228
- }
229
-
230
- throw new Error('Set preference: no value is specified.');
231
-
232
- case 9:
233
- valueType = _typeof(value);
234
- defaultType = _typeof(defaultValue);
235
-
236
- if (!(valueType !== defaultType)) {
237
- _context4.next = 19;
238
- break;
239
- }
240
-
241
- if (!(valueType === 'number' && defaultType === 'string')) {
242
- _context4.next = 16;
243
- break;
244
- }
245
-
246
- value = value.toString();
247
- _context4.next = 17;
248
- break;
249
-
250
- case 16:
251
- throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
252
-
253
- case 17:
254
- _context4.next = 21;
255
- break;
256
-
257
- case 19:
258
- if (!(valueType === 'number' && !Number.isInteger(value))) {
259
- _context4.next = 21;
260
- break;
261
- }
262
-
263
- throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
264
-
265
- case 21:
266
- this.prefs[name] = value;
267
- return _context4.abrupt("return", this._writeToStorage(this.prefs));
268
-
269
- case 23:
270
- case "end":
271
- return _context4.stop();
272
- }
273
- }
274
- }, _callee4, this);
275
- }));
276
-
277
- function set(_x3, _x4) {
278
- return _set.apply(this, arguments);
131
+ } else {
132
+ if (valueType === "number" && !Number.isInteger(value)) {
133
+ throw new Error(`Set preference: "${value}" must be an integer.`);
279
134
  }
135
+ }
280
136
 
281
- return set;
282
- }()
283
- }, {
284
- key: "get",
285
- value: function () {
286
- var _get = _asyncToGenerator(
287
- /*#__PURE__*/
288
- _regenerator["default"].mark(function _callee5(name) {
289
- var defaultValue, prefValue;
290
- return _regenerator["default"].wrap(function _callee5$(_context5) {
291
- while (1) {
292
- switch (_context5.prev = _context5.next) {
293
- case 0:
294
- _context5.next = 2;
295
- return this._initializedPromise;
296
-
297
- case 2:
298
- defaultValue = this.defaults[name];
299
-
300
- if (!(defaultValue === undefined)) {
301
- _context5.next = 7;
302
- break;
303
- }
304
-
305
- throw new Error("Get preference: \"".concat(name, "\" is undefined."));
306
-
307
- case 7:
308
- prefValue = this.prefs[name];
309
-
310
- if (!(prefValue !== undefined)) {
311
- _context5.next = 10;
312
- break;
313
- }
314
-
315
- return _context5.abrupt("return", prefValue);
137
+ this.prefs[name] = value;
138
+ return this._writeToStorage(this.prefs);
139
+ }
316
140
 
317
- case 10:
318
- return _context5.abrupt("return", defaultValue);
141
+ async get(name) {
142
+ await this._initializedPromise;
143
+ const defaultValue = this.defaults[name];
319
144
 
320
- case 11:
321
- case "end":
322
- return _context5.stop();
323
- }
324
- }
325
- }, _callee5, this);
326
- }));
145
+ if (defaultValue === undefined) {
146
+ throw new Error(`Get preference: "${name}" is undefined.`);
147
+ } else {
148
+ const prefValue = this.prefs[name];
327
149
 
328
- function get(_x5) {
329
- return _get.apply(this, arguments);
150
+ if (prefValue !== undefined) {
151
+ return prefValue;
330
152
  }
153
+ }
331
154
 
332
- return get;
333
- }()
334
- }, {
335
- key: "getAll",
336
- value: function () {
337
- var _getAll = _asyncToGenerator(
338
- /*#__PURE__*/
339
- _regenerator["default"].mark(function _callee6() {
340
- return _regenerator["default"].wrap(function _callee6$(_context6) {
341
- while (1) {
342
- switch (_context6.prev = _context6.next) {
343
- case 0:
344
- _context6.next = 2;
345
- return this._initializedPromise;
346
-
347
- case 2:
348
- return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
349
-
350
- case 3:
351
- case "end":
352
- return _context6.stop();
353
- }
354
- }
355
- }, _callee6, this);
356
- }));
357
-
358
- function getAll() {
359
- return _getAll.apply(this, arguments);
360
- }
155
+ return defaultValue;
156
+ }
361
157
 
362
- return getAll;
363
- }()
364
- }]);
158
+ async getAll() {
159
+ await this._initializedPromise;
160
+ return Object.assign(Object.create(null), this.defaults, this.prefs);
161
+ }
365
162
 
366
- return BasePreferences;
367
- }();
163
+ }
368
164
 
369
165
  exports.BasePreferences = BasePreferences;