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/pdf_viewer.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.
|
@@ -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
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
super._scrollIntoView({
|
60
|
+
pageDiv,
|
61
|
+
pageSpot,
|
62
|
+
pageNumber
|
63
|
+
});
|
64
|
+
}
|
59
65
|
|
60
|
-
|
61
|
-
|
66
|
+
_getVisiblePages() {
|
67
|
+
if (this.isInPresentationMode) {
|
68
|
+
return this._getCurrentVisiblePage();
|
69
|
+
}
|
62
70
|
|
63
|
-
return
|
71
|
+
return super._getVisiblePages();
|
64
72
|
}
|
65
73
|
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
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 (
|
147
|
-
|
87
|
+
if (page.id === currentId) {
|
88
|
+
stillFullyVisible = true;
|
89
|
+
break;
|
148
90
|
}
|
149
|
-
|
150
|
-
this._setCurrentPageNumber(currentId);
|
151
91
|
}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
return (0, _pdf.shadow)(this, '_setDocumentViewerElement', this.viewer);
|
92
|
+
|
93
|
+
if (!stillFullyVisible) {
|
94
|
+
currentId = visiblePages[0].id;
|
156
95
|
}
|
157
|
-
}]);
|
158
96
|
|
159
|
-
|
160
|
-
}
|
97
|
+
this._setCurrentPageNumber(currentId);
|
98
|
+
}
|
99
|
+
|
100
|
+
}
|
161
101
|
|
162
102
|
exports.PDFViewer = PDFViewer;
|
package/lib/web/preferences.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.
|
@@ -26,23 +26,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.BasePreferences = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _app_options = require("./app_options.js");
|
30
30
|
|
31
|
-
|
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":
|
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
|
-
|
78
|
-
|
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(
|
67
|
+
throw new Error("Cannot initialize BasePreferences.");
|
87
68
|
}
|
88
69
|
|
89
70
|
this.prefs = null;
|
90
|
-
this._initializedPromise = getDefaultPreferences().then(
|
91
|
-
Object.defineProperty(
|
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
|
-
|
98
|
-
return
|
99
|
-
}).then(
|
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 (
|
105
|
-
|
106
|
-
|
85
|
+
for (const name in prefs) {
|
86
|
+
const defaultValue = this.defaults[name],
|
87
|
+
prefValue = prefs[name];
|
107
88
|
|
108
|
-
if (defaultValue === undefined ||
|
89
|
+
if (defaultValue === undefined || typeof prefValue !== typeof defaultValue) {
|
109
90
|
continue;
|
110
91
|
}
|
111
92
|
|
112
|
-
|
93
|
+
this.prefs[name] = prefValue;
|
113
94
|
}
|
114
95
|
});
|
115
96
|
}
|
116
97
|
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
156
|
-
|
157
|
-
|
158
|
-
}
|
159
|
-
}
|
160
|
-
}, _callee2);
|
161
|
-
}));
|
102
|
+
async _readFromStorage(prefObj) {
|
103
|
+
throw new Error("Not implemented: _readFromStorage");
|
104
|
+
}
|
162
105
|
|
163
|
-
|
164
|
-
|
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
|
-
|
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
|
-
|
183
|
-
|
184
|
-
|
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
|
-
|
187
|
-
|
188
|
-
return _context3.stop();
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}, _callee3, this);
|
192
|
-
}));
|
122
|
+
const valueType = typeof value;
|
123
|
+
const defaultType = typeof defaultValue;
|
193
124
|
|
194
|
-
|
195
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
318
|
-
|
141
|
+
async get(name) {
|
142
|
+
await this._initializedPromise;
|
143
|
+
const defaultValue = this.defaults[name];
|
319
144
|
|
320
|
-
|
321
|
-
|
322
|
-
|
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
|
-
|
329
|
-
return
|
150
|
+
if (prefValue !== undefined) {
|
151
|
+
return prefValue;
|
330
152
|
}
|
153
|
+
}
|
331
154
|
|
332
|
-
|
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
|
-
|
363
|
-
|
364
|
-
|
158
|
+
async getAll() {
|
159
|
+
await this._initializedPromise;
|
160
|
+
return Object.assign(Object.create(null), this.defaults, this.prefs);
|
161
|
+
}
|
365
162
|
|
366
|
-
|
367
|
-
}();
|
163
|
+
}
|
368
164
|
|
369
165
|
exports.BasePreferences = BasePreferences;
|