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/firefoxcom.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,359 +26,177 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.FirefoxCom = exports.DownloadManager = void 0;
|
28
28
|
|
29
|
-
|
29
|
+
require("../extensions/firefox/tools/l10n.js");
|
30
30
|
|
31
|
-
require("
|
31
|
+
var _app = require("./app.js");
|
32
32
|
|
33
33
|
var _pdf = require("../pdf");
|
34
34
|
|
35
|
-
var _preferences = require("./preferences");
|
35
|
+
var _preferences = require("./preferences.js");
|
36
36
|
|
37
|
-
var
|
38
|
-
|
39
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
40
|
-
|
41
|
-
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); }
|
42
|
-
|
43
|
-
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); } }
|
44
|
-
|
45
|
-
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); }); }; }
|
46
|
-
|
47
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
48
|
-
|
49
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
50
|
-
|
51
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
52
|
-
|
53
|
-
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); }
|
54
|
-
|
55
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
56
|
-
|
57
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
58
|
-
|
59
|
-
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); } }
|
60
|
-
|
61
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
37
|
+
var _ui_utils = require("./ui_utils.js");
|
62
38
|
|
63
39
|
{
|
64
|
-
throw new Error('Module "
|
40
|
+
throw new Error('Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.');
|
65
41
|
}
|
66
42
|
|
67
|
-
|
43
|
+
const FirefoxCom = function FirefoxComClosure() {
|
68
44
|
return {
|
69
|
-
requestSync
|
70
|
-
|
45
|
+
requestSync(action, data) {
|
46
|
+
const request = document.createTextNode("");
|
71
47
|
document.documentElement.appendChild(request);
|
72
|
-
|
73
|
-
sender.initCustomEvent(
|
74
|
-
action
|
75
|
-
data
|
48
|
+
const sender = document.createEvent("CustomEvent");
|
49
|
+
sender.initCustomEvent("pdf.js.message", true, false, {
|
50
|
+
action,
|
51
|
+
data,
|
76
52
|
sync: true
|
77
53
|
});
|
78
54
|
request.dispatchEvent(sender);
|
79
|
-
|
55
|
+
const response = sender.detail.response;
|
80
56
|
document.documentElement.removeChild(request);
|
81
57
|
return response;
|
82
58
|
},
|
83
|
-
|
84
|
-
|
59
|
+
|
60
|
+
request(action, data, callback) {
|
61
|
+
const request = document.createTextNode("");
|
85
62
|
|
86
63
|
if (callback) {
|
87
|
-
document.addEventListener(
|
88
|
-
|
89
|
-
|
64
|
+
document.addEventListener("pdf.js.response", function listener(event) {
|
65
|
+
const node = event.target;
|
66
|
+
const response = event.detail.response;
|
90
67
|
document.documentElement.removeChild(node);
|
91
|
-
document.removeEventListener(
|
68
|
+
document.removeEventListener("pdf.js.response", listener);
|
92
69
|
return callback(response);
|
93
70
|
});
|
94
71
|
}
|
95
72
|
|
96
73
|
document.documentElement.appendChild(request);
|
97
|
-
|
98
|
-
sender.initCustomEvent(
|
99
|
-
action
|
100
|
-
data
|
74
|
+
const sender = document.createEvent("CustomEvent");
|
75
|
+
sender.initCustomEvent("pdf.js.message", true, false, {
|
76
|
+
action,
|
77
|
+
data,
|
101
78
|
sync: false,
|
102
79
|
responseExpected: !!callback
|
103
80
|
});
|
104
81
|
return request.dispatchEvent(sender);
|
105
82
|
}
|
83
|
+
|
106
84
|
};
|
107
85
|
}();
|
108
86
|
|
109
87
|
exports.FirefoxCom = FirefoxCom;
|
110
88
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
this.disableCreateObjectURL = false;
|
89
|
+
class DownloadManager {
|
90
|
+
downloadUrl(url, filename) {
|
91
|
+
FirefoxCom.request("download", {
|
92
|
+
originalUrl: url,
|
93
|
+
filename
|
94
|
+
});
|
118
95
|
}
|
119
96
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
filename: filename,
|
136
|
-
isAttachment: true
|
137
|
-
});
|
138
|
-
}
|
139
|
-
}, {
|
140
|
-
key: "download",
|
141
|
-
value: function download(blob, url, filename) {
|
142
|
-
var _this = this;
|
143
|
-
|
144
|
-
var blobUrl = _pdf.URL.createObjectURL(blob);
|
145
|
-
|
146
|
-
var onResponse = function onResponse(err) {
|
147
|
-
if (err && _this.onerror) {
|
148
|
-
_this.onerror(err);
|
149
|
-
}
|
150
|
-
|
151
|
-
_pdf.URL.revokeObjectURL(blobUrl);
|
152
|
-
};
|
153
|
-
|
154
|
-
FirefoxCom.request('download', {
|
155
|
-
blobUrl: blobUrl,
|
156
|
-
originalUrl: url,
|
157
|
-
filename: filename
|
158
|
-
}, onResponse);
|
159
|
-
}
|
160
|
-
}]);
|
161
|
-
|
162
|
-
return DownloadManager;
|
163
|
-
}();
|
164
|
-
|
165
|
-
exports.DownloadManager = DownloadManager;
|
166
|
-
|
167
|
-
var FirefoxPreferences =
|
168
|
-
/*#__PURE__*/
|
169
|
-
function (_BasePreferences) {
|
170
|
-
_inherits(FirefoxPreferences, _BasePreferences);
|
171
|
-
|
172
|
-
function FirefoxPreferences() {
|
173
|
-
_classCallCheck(this, FirefoxPreferences);
|
174
|
-
|
175
|
-
return _possibleConstructorReturn(this, _getPrototypeOf(FirefoxPreferences).apply(this, arguments));
|
97
|
+
downloadData(data, filename, contentType) {
|
98
|
+
const blobUrl = URL.createObjectURL(new Blob([data], {
|
99
|
+
type: contentType
|
100
|
+
}));
|
101
|
+
|
102
|
+
const onResponse = err => {
|
103
|
+
URL.revokeObjectURL(blobUrl);
|
104
|
+
};
|
105
|
+
|
106
|
+
FirefoxCom.request("download", {
|
107
|
+
blobUrl,
|
108
|
+
originalUrl: blobUrl,
|
109
|
+
filename,
|
110
|
+
isAttachment: true
|
111
|
+
}, onResponse);
|
176
112
|
}
|
177
113
|
|
178
|
-
|
179
|
-
|
180
|
-
value: function () {
|
181
|
-
var _writeToStorage2 = _asyncToGenerator(
|
182
|
-
/*#__PURE__*/
|
183
|
-
_regenerator["default"].mark(function _callee(prefObj) {
|
184
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
185
|
-
while (1) {
|
186
|
-
switch (_context.prev = _context.next) {
|
187
|
-
case 0:
|
188
|
-
return _context.abrupt("return", new Promise(function (resolve) {
|
189
|
-
FirefoxCom.request('setPreferences', prefObj, resolve);
|
190
|
-
}));
|
191
|
-
|
192
|
-
case 1:
|
193
|
-
case "end":
|
194
|
-
return _context.stop();
|
195
|
-
}
|
196
|
-
}
|
197
|
-
}, _callee);
|
198
|
-
}));
|
114
|
+
download(blob, url, filename, sourceEventType = "download") {
|
115
|
+
const blobUrl = URL.createObjectURL(blob);
|
199
116
|
|
200
|
-
|
201
|
-
|
117
|
+
const onResponse = err => {
|
118
|
+
if (err && this.onerror) {
|
119
|
+
this.onerror(err);
|
202
120
|
}
|
203
121
|
|
204
|
-
|
205
|
-
}
|
206
|
-
}, {
|
207
|
-
key: "_readFromStorage",
|
208
|
-
value: function () {
|
209
|
-
var _readFromStorage2 = _asyncToGenerator(
|
210
|
-
/*#__PURE__*/
|
211
|
-
_regenerator["default"].mark(function _callee2(prefObj) {
|
212
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
213
|
-
while (1) {
|
214
|
-
switch (_context2.prev = _context2.next) {
|
215
|
-
case 0:
|
216
|
-
return _context2.abrupt("return", new Promise(function (resolve) {
|
217
|
-
FirefoxCom.request('getPreferences', prefObj, function (prefStr) {
|
218
|
-
var readPrefs = JSON.parse(prefStr);
|
219
|
-
resolve(readPrefs);
|
220
|
-
});
|
221
|
-
}));
|
222
|
-
|
223
|
-
case 1:
|
224
|
-
case "end":
|
225
|
-
return _context2.stop();
|
226
|
-
}
|
227
|
-
}
|
228
|
-
}, _callee2);
|
229
|
-
}));
|
230
|
-
|
231
|
-
function _readFromStorage(_x2) {
|
232
|
-
return _readFromStorage2.apply(this, arguments);
|
233
|
-
}
|
122
|
+
URL.revokeObjectURL(blobUrl);
|
123
|
+
};
|
234
124
|
|
235
|
-
|
236
|
-
|
237
|
-
|
125
|
+
FirefoxCom.request("download", {
|
126
|
+
blobUrl,
|
127
|
+
originalUrl: url,
|
128
|
+
filename,
|
129
|
+
sourceEventType
|
130
|
+
}, onResponse);
|
131
|
+
}
|
238
132
|
|
239
|
-
|
240
|
-
}(_preferences.BasePreferences);
|
133
|
+
}
|
241
134
|
|
242
|
-
|
243
|
-
/*#__PURE__*/
|
244
|
-
function () {
|
245
|
-
function MozL10n(mozL10n) {
|
246
|
-
_classCallCheck(this, MozL10n);
|
135
|
+
exports.DownloadManager = DownloadManager;
|
247
136
|
|
248
|
-
|
137
|
+
class FirefoxPreferences extends _preferences.BasePreferences {
|
138
|
+
async _writeToStorage(prefObj) {
|
139
|
+
return new Promise(function (resolve) {
|
140
|
+
FirefoxCom.request("setPreferences", prefObj, resolve);
|
141
|
+
});
|
249
142
|
}
|
250
143
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
switch (_context3.prev = _context3.next) {
|
260
|
-
case 0:
|
261
|
-
return _context3.abrupt("return", this.mozL10n.getLanguage());
|
262
|
-
|
263
|
-
case 1:
|
264
|
-
case "end":
|
265
|
-
return _context3.stop();
|
266
|
-
}
|
267
|
-
}
|
268
|
-
}, _callee3, this);
|
269
|
-
}));
|
270
|
-
|
271
|
-
function getLanguage() {
|
272
|
-
return _getLanguage.apply(this, arguments);
|
273
|
-
}
|
274
|
-
|
275
|
-
return getLanguage;
|
276
|
-
}()
|
277
|
-
}, {
|
278
|
-
key: "getDirection",
|
279
|
-
value: function () {
|
280
|
-
var _getDirection = _asyncToGenerator(
|
281
|
-
/*#__PURE__*/
|
282
|
-
_regenerator["default"].mark(function _callee4() {
|
283
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
284
|
-
while (1) {
|
285
|
-
switch (_context4.prev = _context4.next) {
|
286
|
-
case 0:
|
287
|
-
return _context4.abrupt("return", this.mozL10n.getDirection());
|
288
|
-
|
289
|
-
case 1:
|
290
|
-
case "end":
|
291
|
-
return _context4.stop();
|
292
|
-
}
|
293
|
-
}
|
294
|
-
}, _callee4, this);
|
295
|
-
}));
|
144
|
+
async _readFromStorage(prefObj) {
|
145
|
+
return new Promise(function (resolve) {
|
146
|
+
FirefoxCom.request("getPreferences", prefObj, function (prefStr) {
|
147
|
+
const readPrefs = JSON.parse(prefStr);
|
148
|
+
resolve(readPrefs);
|
149
|
+
});
|
150
|
+
});
|
151
|
+
}
|
296
152
|
|
297
|
-
|
298
|
-
return _getDirection.apply(this, arguments);
|
299
|
-
}
|
153
|
+
}
|
300
154
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
value: function () {
|
306
|
-
var _get = _asyncToGenerator(
|
307
|
-
/*#__PURE__*/
|
308
|
-
_regenerator["default"].mark(function _callee5(property, args, fallback) {
|
309
|
-
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
310
|
-
while (1) {
|
311
|
-
switch (_context5.prev = _context5.next) {
|
312
|
-
case 0:
|
313
|
-
return _context5.abrupt("return", this.mozL10n.get(property, args, fallback));
|
314
|
-
|
315
|
-
case 1:
|
316
|
-
case "end":
|
317
|
-
return _context5.stop();
|
318
|
-
}
|
319
|
-
}
|
320
|
-
}, _callee5, this);
|
321
|
-
}));
|
155
|
+
class MozL10n {
|
156
|
+
constructor(mozL10n) {
|
157
|
+
this.mozL10n = mozL10n;
|
158
|
+
}
|
322
159
|
|
323
|
-
|
324
|
-
|
325
|
-
|
160
|
+
async getLanguage() {
|
161
|
+
return this.mozL10n.getLanguage();
|
162
|
+
}
|
326
163
|
|
327
|
-
|
328
|
-
|
329
|
-
}
|
330
|
-
key: "translate",
|
331
|
-
value: function () {
|
332
|
-
var _translate = _asyncToGenerator(
|
333
|
-
/*#__PURE__*/
|
334
|
-
_regenerator["default"].mark(function _callee6(element) {
|
335
|
-
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
336
|
-
while (1) {
|
337
|
-
switch (_context6.prev = _context6.next) {
|
338
|
-
case 0:
|
339
|
-
this.mozL10n.translate(element);
|
340
|
-
|
341
|
-
case 1:
|
342
|
-
case "end":
|
343
|
-
return _context6.stop();
|
344
|
-
}
|
345
|
-
}
|
346
|
-
}, _callee6, this);
|
347
|
-
}));
|
164
|
+
async getDirection() {
|
165
|
+
return this.mozL10n.getDirection();
|
166
|
+
}
|
348
167
|
|
349
|
-
|
350
|
-
|
351
|
-
|
168
|
+
async get(property, args, fallback) {
|
169
|
+
return this.mozL10n.get(property, args, fallback);
|
170
|
+
}
|
352
171
|
|
353
|
-
|
354
|
-
|
355
|
-
}
|
172
|
+
async translate(element) {
|
173
|
+
this.mozL10n.translate(element);
|
174
|
+
}
|
356
175
|
|
357
|
-
|
358
|
-
}();
|
176
|
+
}
|
359
177
|
|
360
178
|
(function listenFindEvents() {
|
361
|
-
|
362
|
-
|
363
|
-
var handleEvent = function handleEvent(_ref) {
|
364
|
-
var type = _ref.type,
|
365
|
-
detail = _ref.detail;
|
179
|
+
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"];
|
366
180
|
|
181
|
+
const handleEvent = function ({
|
182
|
+
type,
|
183
|
+
detail
|
184
|
+
}) {
|
367
185
|
if (!_app.PDFViewerApplication.initialized) {
|
368
186
|
return;
|
369
187
|
}
|
370
188
|
|
371
|
-
if (type ===
|
372
|
-
_app.PDFViewerApplication.eventBus.dispatch(
|
189
|
+
if (type === "findbarclose") {
|
190
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
373
191
|
source: window
|
374
192
|
});
|
375
193
|
|
376
194
|
return;
|
377
195
|
}
|
378
196
|
|
379
|
-
_app.PDFViewerApplication.eventBus.dispatch(
|
197
|
+
_app.PDFViewerApplication.eventBus.dispatch("find", {
|
380
198
|
source: window,
|
381
|
-
type: type.substring(
|
199
|
+
type: type.substring("find".length),
|
382
200
|
query: detail.query,
|
383
201
|
phraseSearch: true,
|
384
202
|
caseSensitive: !!detail.caseSensitive,
|
@@ -388,116 +206,121 @@ function () {
|
|
388
206
|
});
|
389
207
|
};
|
390
208
|
|
391
|
-
for (
|
392
|
-
var event = _events[_i];
|
209
|
+
for (const event of events) {
|
393
210
|
window.addEventListener(event, handleEvent);
|
394
211
|
}
|
395
212
|
})();
|
396
213
|
|
397
214
|
(function listenZoomEvents() {
|
398
|
-
|
399
|
-
|
400
|
-
var handleEvent = function handleEvent(_ref2) {
|
401
|
-
var type = _ref2.type,
|
402
|
-
detail = _ref2.detail;
|
215
|
+
const events = ["zoomin", "zoomout", "zoomreset"];
|
403
216
|
|
217
|
+
const handleEvent = function ({
|
218
|
+
type,
|
219
|
+
detail
|
220
|
+
}) {
|
404
221
|
if (!_app.PDFViewerApplication.initialized) {
|
405
222
|
return;
|
406
223
|
}
|
407
224
|
|
225
|
+
if (type === "zoomreset" && _app.PDFViewerApplication.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
|
226
|
+
return;
|
227
|
+
}
|
228
|
+
|
408
229
|
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
409
|
-
source: window
|
410
|
-
ignoreDuplicate: type === 'zoomreset' ? true : undefined
|
230
|
+
source: window
|
411
231
|
});
|
412
232
|
};
|
413
233
|
|
414
|
-
for (
|
415
|
-
var event = _events2[_i2];
|
234
|
+
for (const event of events) {
|
416
235
|
window.addEventListener(event, handleEvent);
|
417
236
|
}
|
418
237
|
})();
|
419
238
|
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
239
|
+
(function listenSaveEvent() {
|
240
|
+
const handleEvent = function ({
|
241
|
+
type,
|
242
|
+
detail
|
243
|
+
}) {
|
244
|
+
if (!_app.PDFViewerApplication.initialized) {
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
|
248
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
249
|
+
source: window
|
250
|
+
});
|
251
|
+
};
|
252
|
+
|
253
|
+
window.addEventListener("save", handleEvent);
|
254
|
+
})();
|
424
255
|
|
425
|
-
|
426
|
-
|
256
|
+
class FirefoxComDataRangeTransport extends _pdf.PDFDataRangeTransport {
|
257
|
+
requestDataRange(begin, end) {
|
258
|
+
FirefoxCom.request("requestDataRange", {
|
259
|
+
begin,
|
260
|
+
end
|
261
|
+
});
|
262
|
+
}
|
427
263
|
|
428
|
-
|
264
|
+
abort() {
|
265
|
+
FirefoxCom.requestSync("abortLoading", null);
|
429
266
|
}
|
430
267
|
|
431
|
-
|
432
|
-
key: "requestDataRange",
|
433
|
-
value: function requestDataRange(begin, end) {
|
434
|
-
FirefoxCom.request('requestDataRange', {
|
435
|
-
begin: begin,
|
436
|
-
end: end
|
437
|
-
});
|
438
|
-
}
|
439
|
-
}, {
|
440
|
-
key: "abort",
|
441
|
-
value: function abort() {
|
442
|
-
FirefoxCom.requestSync('abortLoading', null);
|
443
|
-
}
|
444
|
-
}]);
|
268
|
+
}
|
445
269
|
|
446
|
-
|
447
|
-
|
270
|
+
class FirefoxExternalServices extends _app.DefaultExternalServices {
|
271
|
+
static updateFindControlState(data) {
|
272
|
+
FirefoxCom.request("updateFindControlState", data);
|
273
|
+
}
|
448
274
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
initPassiveLoading: function initPassiveLoading(callbacks) {
|
457
|
-
var pdfDataRangeTransport;
|
458
|
-
window.addEventListener('message', function windowMessage(e) {
|
275
|
+
static updateFindMatchesCount(data) {
|
276
|
+
FirefoxCom.request("updateFindMatchesCount", data);
|
277
|
+
}
|
278
|
+
|
279
|
+
static initPassiveLoading(callbacks) {
|
280
|
+
let pdfDataRangeTransport;
|
281
|
+
window.addEventListener("message", function windowMessage(e) {
|
459
282
|
if (e.source !== null) {
|
460
|
-
console.warn(
|
283
|
+
console.warn("Rejected untrusted message from " + e.origin);
|
461
284
|
return;
|
462
285
|
}
|
463
286
|
|
464
|
-
|
287
|
+
const args = e.data;
|
465
288
|
|
466
|
-
if (
|
289
|
+
if (typeof args !== "object" || !("pdfjsLoadAction" in args)) {
|
467
290
|
return;
|
468
291
|
}
|
469
292
|
|
470
293
|
switch (args.pdfjsLoadAction) {
|
471
|
-
case
|
294
|
+
case "supportsRangedLoading":
|
472
295
|
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
|
473
296
|
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
|
474
297
|
break;
|
475
298
|
|
476
|
-
case
|
299
|
+
case "range":
|
477
300
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
478
301
|
break;
|
479
302
|
|
480
|
-
case
|
303
|
+
case "rangeProgress":
|
481
304
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
482
305
|
break;
|
483
306
|
|
484
|
-
case
|
307
|
+
case "progressiveRead":
|
485
308
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
486
309
|
pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
|
487
310
|
break;
|
488
311
|
|
489
|
-
case
|
312
|
+
case "progressiveDone":
|
490
313
|
if (pdfDataRangeTransport) {
|
491
314
|
pdfDataRangeTransport.onDataProgressiveDone();
|
492
315
|
}
|
493
316
|
|
494
317
|
break;
|
495
318
|
|
496
|
-
case
|
319
|
+
case "progress":
|
497
320
|
callbacks.onProgress(args.loaded, args.total);
|
498
321
|
break;
|
499
322
|
|
500
|
-
case
|
323
|
+
case "complete":
|
501
324
|
if (!args.data) {
|
502
325
|
callbacks.onError(args.errorCode);
|
503
326
|
break;
|
@@ -507,51 +330,60 @@ _app.PDFViewerApplication.externalServices = {
|
|
507
330
|
break;
|
508
331
|
}
|
509
332
|
});
|
510
|
-
FirefoxCom.requestSync(
|
511
|
-
}
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
333
|
+
FirefoxCom.requestSync("initPassiveLoading", null);
|
334
|
+
}
|
335
|
+
|
336
|
+
static fallback(data, callback) {
|
337
|
+
FirefoxCom.request("fallback", data, callback);
|
338
|
+
}
|
339
|
+
|
340
|
+
static reportTelemetry(data) {
|
341
|
+
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
|
342
|
+
}
|
343
|
+
|
344
|
+
static createDownloadManager(options) {
|
519
345
|
return new DownloadManager(options);
|
520
|
-
}
|
521
|
-
|
346
|
+
}
|
347
|
+
|
348
|
+
static createPreferences() {
|
522
349
|
return new FirefoxPreferences();
|
523
|
-
}
|
524
|
-
|
525
|
-
|
350
|
+
}
|
351
|
+
|
352
|
+
static createL10n(options) {
|
353
|
+
const mozL10n = document.mozL10n;
|
526
354
|
return new MozL10n(mozL10n);
|
527
|
-
}
|
355
|
+
}
|
528
356
|
|
529
|
-
get supportsIntegratedFind() {
|
530
|
-
|
531
|
-
return (0, _pdf.shadow)(this,
|
532
|
-
}
|
357
|
+
static get supportsIntegratedFind() {
|
358
|
+
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
359
|
+
return (0, _pdf.shadow)(this, "supportsIntegratedFind", support);
|
360
|
+
}
|
533
361
|
|
534
|
-
get supportsDocumentFonts() {
|
535
|
-
|
536
|
-
return (0, _pdf.shadow)(this,
|
537
|
-
}
|
362
|
+
static get supportsDocumentFonts() {
|
363
|
+
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
364
|
+
return (0, _pdf.shadow)(this, "supportsDocumentFonts", support);
|
365
|
+
}
|
538
366
|
|
539
|
-
get
|
540
|
-
|
541
|
-
return (0, _pdf.shadow)(this,
|
542
|
-
}
|
367
|
+
static get supportedMouseWheelZoomModifierKeys() {
|
368
|
+
const support = FirefoxCom.requestSync("supportedMouseWheelZoomModifierKeys");
|
369
|
+
return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", support);
|
370
|
+
}
|
543
371
|
|
544
|
-
get
|
545
|
-
|
546
|
-
return (0, _pdf.shadow)(this,
|
372
|
+
static get isInAutomation() {
|
373
|
+
const isInAutomation = FirefoxCom.requestSync("isInAutomation");
|
374
|
+
return (0, _pdf.shadow)(this, "isInAutomation", isInAutomation);
|
547
375
|
}
|
548
376
|
|
549
|
-
}
|
377
|
+
}
|
378
|
+
|
379
|
+
_app.PDFViewerApplication.externalServices = FirefoxExternalServices;
|
550
380
|
document.mozL10n.setExternalLocalizerServices({
|
551
|
-
getLocale
|
552
|
-
return FirefoxCom.requestSync(
|
381
|
+
getLocale() {
|
382
|
+
return FirefoxCom.requestSync("getLocale", null);
|
553
383
|
},
|
554
|
-
|
555
|
-
|
384
|
+
|
385
|
+
getStrings(key) {
|
386
|
+
return FirefoxCom.requestSync("getStrings", key);
|
556
387
|
}
|
388
|
+
|
557
389
|
});
|