pdfjs-dist 2.3.200 → 2.4.456
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +6499 -17971
- 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 +19303 -29896
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1333 -4839
- 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 +683 -1066
- 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 +196 -193
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +441 -569
- package/lib/core/cmap.js +220 -279
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +59 -80
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +564 -673
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +983 -889
- package/lib/core/font_renderer.js +128 -171
- package/lib/core/fonts.js +451 -400
- package/lib/core/function.js +289 -285
- package/lib/core/glyphlist.js +4527 -4527
- package/lib/core/image.js +138 -117
- package/lib/core/image_utils.js +46 -63
- package/lib/core/jbig2.js +324 -332
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +133 -24
- package/lib/core/jpg.js +238 -210
- package/lib/core/jpx.js +158 -157
- 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 +1111 -1302
- package/lib/core/operator_list.js +55 -42
- package/lib/core/parser.js +956 -987
- package/lib/core/pattern.js +69 -69
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +45 -77
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +83 -77
- package/lib/core/type1_parser.js +78 -68
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +148 -196
- package/lib/core/worker_stream.js +101 -210
- package/lib/display/annotation_layer.js +733 -1155
- package/lib/display/api.js +1539 -1928
- package/lib/display/api_compatibility.js +10 -8
- package/lib/display/canvas.js +159 -158
- package/lib/display/content_disposition.js +36 -55
- package/lib/display/display_utils.js +298 -551
- package/lib/display/fetch_stream.js +181 -305
- package/lib/display/font_loader.js +273 -416
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +376 -511
- package/lib/display/network_utils.js +20 -19
- package/lib/display/node_stream.js +276 -460
- package/lib/display/pattern_helper.js +76 -44
- package/lib/display/svg.js +1137 -1405
- package/lib/display/text_layer.js +75 -82
- package/lib/display/transport_stream.js +236 -374
- 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 +22 -21
- package/lib/pdf.worker.js +5 -5
- package/lib/shared/compatibility.js +2 -251
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +222 -194
- package/lib/shared/util.js +269 -405
- package/lib/test/unit/annotation_spec.js +1089 -1014
- package/lib/test/unit/api_spec.js +617 -544
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +63 -62
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +84 -86
- package/lib/test/unit/colorspace_spec.js +154 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +22 -24
- package/lib/test/unit/display_svg_spec.js +35 -36
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +16 -16
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +81 -95
- package/lib/test/unit/fetch_stream_spec.js +30 -30
- 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 +172 -162
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +12 -12
- package/lib/test/unit/network_utils_spec.js +152 -152
- package/lib/test/unit/node_stream_spec.js +74 -90
- package/lib/test/unit/parser_spec.js +107 -113
- 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 +117 -115
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +119 -285
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +41 -41
- package/lib/test/unit/ui_utils_spec.js +318 -426
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +122 -143
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1166 -1196
- package/lib/web/app_options.js +61 -77
- package/lib/web/base_viewer.js +804 -850
- package/lib/web/chromecom.js +164 -249
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +38 -57
- package/lib/web/firefox_print_service.js +35 -30
- package/lib/web/firefoxcom.js +175 -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 -258
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +105 -130
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +227 -376
- package/lib/web/pdf_find_bar.js +137 -171
- package/lib/web/pdf_find_controller.js +492 -549
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +395 -406
- package/lib/web/pdf_link_service.js +302 -349
- package/lib/web/pdf_outline_viewer.js +148 -209
- package/lib/web/pdf_page_view.js +449 -507
- package/lib/web/pdf_presentation_mode.js +304 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +264 -304
- 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 +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +66 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -317
- package/lib/web/toolbar.js +216 -211
- package/lib/web/ui_utils.js +303 -404
- package/lib/web/view_history.js +49 -222
- package/lib/web/viewer_compatibility.js +7 -5
- package/package.json +2 -9
- package/web/pdf_viewer.css +25 -18
- package/web/pdf_viewer.js +3481 -4764
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/lib/shared/streams_polyfill.js +0 -43
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,351 +26,163 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.FirefoxCom = exports.DownloadManager = void 0;
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
require("../extensions/firefox/tools/l10n");
|
29
|
+
require("../extensions/firefox/tools/l10n.js");
|
32
30
|
|
33
31
|
var _pdf = require("../pdf");
|
34
32
|
|
35
|
-
var
|
36
|
-
|
37
|
-
var _ui_utils = require("./ui_utils");
|
38
|
-
|
39
|
-
var _app = require("./app");
|
40
|
-
|
41
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
42
|
-
|
43
|
-
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); }
|
44
|
-
|
45
|
-
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); } }
|
46
|
-
|
47
|
-
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); }); }; }
|
48
|
-
|
49
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
50
|
-
|
51
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
52
|
-
|
53
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
54
|
-
|
55
|
-
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); }
|
56
|
-
|
57
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
58
|
-
|
59
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
33
|
+
var _app = require("./app.js");
|
60
34
|
|
61
|
-
|
35
|
+
var _preferences = require("./preferences.js");
|
62
36
|
|
63
|
-
|
37
|
+
var _ui_utils = require("./ui_utils.js");
|
64
38
|
|
65
39
|
{
|
66
|
-
throw new Error('Module "
|
40
|
+
throw new Error('Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.');
|
67
41
|
}
|
68
42
|
|
69
|
-
|
43
|
+
const FirefoxCom = function FirefoxComClosure() {
|
70
44
|
return {
|
71
|
-
requestSync
|
72
|
-
|
45
|
+
requestSync(action, data) {
|
46
|
+
const request = document.createTextNode("");
|
73
47
|
document.documentElement.appendChild(request);
|
74
|
-
|
75
|
-
sender.initCustomEvent(
|
76
|
-
action
|
77
|
-
data
|
48
|
+
const sender = document.createEvent("CustomEvent");
|
49
|
+
sender.initCustomEvent("pdf.js.message", true, false, {
|
50
|
+
action,
|
51
|
+
data,
|
78
52
|
sync: true
|
79
53
|
});
|
80
54
|
request.dispatchEvent(sender);
|
81
|
-
|
55
|
+
const response = sender.detail.response;
|
82
56
|
document.documentElement.removeChild(request);
|
83
57
|
return response;
|
84
58
|
},
|
85
|
-
|
86
|
-
|
59
|
+
|
60
|
+
request(action, data, callback) {
|
61
|
+
const request = document.createTextNode("");
|
87
62
|
|
88
63
|
if (callback) {
|
89
|
-
document.addEventListener(
|
90
|
-
|
91
|
-
|
64
|
+
document.addEventListener("pdf.js.response", function listener(event) {
|
65
|
+
const node = event.target;
|
66
|
+
const response = event.detail.response;
|
92
67
|
document.documentElement.removeChild(node);
|
93
|
-
document.removeEventListener(
|
68
|
+
document.removeEventListener("pdf.js.response", listener);
|
94
69
|
return callback(response);
|
95
70
|
});
|
96
71
|
}
|
97
72
|
|
98
73
|
document.documentElement.appendChild(request);
|
99
|
-
|
100
|
-
sender.initCustomEvent(
|
101
|
-
action
|
102
|
-
data
|
74
|
+
const sender = document.createEvent("CustomEvent");
|
75
|
+
sender.initCustomEvent("pdf.js.message", true, false, {
|
76
|
+
action,
|
77
|
+
data,
|
103
78
|
sync: false,
|
104
79
|
responseExpected: !!callback
|
105
80
|
});
|
106
81
|
return request.dispatchEvent(sender);
|
107
82
|
}
|
83
|
+
|
108
84
|
};
|
109
85
|
}();
|
110
86
|
|
111
87
|
exports.FirefoxCom = FirefoxCom;
|
112
88
|
|
113
|
-
|
114
|
-
|
115
|
-
function () {
|
116
|
-
function DownloadManager(options) {
|
117
|
-
_classCallCheck(this, DownloadManager);
|
118
|
-
|
89
|
+
class DownloadManager {
|
90
|
+
constructor(options) {
|
119
91
|
this.disableCreateObjectURL = false;
|
120
92
|
}
|
121
93
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
});
|
129
|
-
}
|
130
|
-
}, {
|
131
|
-
key: "downloadData",
|
132
|
-
value: function downloadData(data, filename, contentType) {
|
133
|
-
var blobUrl = (0, _pdf.createObjectURL)(data, contentType);
|
134
|
-
FirefoxCom.request('download', {
|
135
|
-
blobUrl: blobUrl,
|
136
|
-
originalUrl: blobUrl,
|
137
|
-
filename: filename,
|
138
|
-
isAttachment: true
|
139
|
-
});
|
140
|
-
}
|
141
|
-
}, {
|
142
|
-
key: "download",
|
143
|
-
value: function download(blob, url, filename) {
|
144
|
-
var _this = this;
|
145
|
-
|
146
|
-
var blobUrl = URL.createObjectURL(blob);
|
147
|
-
|
148
|
-
var onResponse = function onResponse(err) {
|
149
|
-
if (err && _this.onerror) {
|
150
|
-
_this.onerror(err);
|
151
|
-
}
|
152
|
-
|
153
|
-
URL.revokeObjectURL(blobUrl);
|
154
|
-
};
|
155
|
-
|
156
|
-
FirefoxCom.request('download', {
|
157
|
-
blobUrl: blobUrl,
|
158
|
-
originalUrl: url,
|
159
|
-
filename: filename
|
160
|
-
}, onResponse);
|
161
|
-
}
|
162
|
-
}]);
|
163
|
-
|
164
|
-
return DownloadManager;
|
165
|
-
}();
|
166
|
-
|
167
|
-
exports.DownloadManager = DownloadManager;
|
168
|
-
|
169
|
-
var FirefoxPreferences =
|
170
|
-
/*#__PURE__*/
|
171
|
-
function (_BasePreferences) {
|
172
|
-
_inherits(FirefoxPreferences, _BasePreferences);
|
173
|
-
|
174
|
-
function FirefoxPreferences() {
|
175
|
-
_classCallCheck(this, FirefoxPreferences);
|
94
|
+
downloadUrl(url, filename) {
|
95
|
+
FirefoxCom.request("download", {
|
96
|
+
originalUrl: url,
|
97
|
+
filename
|
98
|
+
});
|
99
|
+
}
|
176
100
|
|
177
|
-
|
101
|
+
downloadData(data, filename, contentType) {
|
102
|
+
const blobUrl = (0, _pdf.createObjectURL)(data, contentType);
|
103
|
+
FirefoxCom.request("download", {
|
104
|
+
blobUrl,
|
105
|
+
originalUrl: blobUrl,
|
106
|
+
filename,
|
107
|
+
isAttachment: true
|
108
|
+
});
|
178
109
|
}
|
179
110
|
|
180
|
-
|
181
|
-
|
182
|
-
value: function () {
|
183
|
-
var _writeToStorage2 = _asyncToGenerator(
|
184
|
-
/*#__PURE__*/
|
185
|
-
_regenerator["default"].mark(function _callee(prefObj) {
|
186
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
187
|
-
while (1) {
|
188
|
-
switch (_context.prev = _context.next) {
|
189
|
-
case 0:
|
190
|
-
return _context.abrupt("return", new Promise(function (resolve) {
|
191
|
-
FirefoxCom.request('setPreferences', prefObj, resolve);
|
192
|
-
}));
|
193
|
-
|
194
|
-
case 1:
|
195
|
-
case "end":
|
196
|
-
return _context.stop();
|
197
|
-
}
|
198
|
-
}
|
199
|
-
}, _callee);
|
200
|
-
}));
|
111
|
+
download(blob, url, filename) {
|
112
|
+
const blobUrl = URL.createObjectURL(blob);
|
201
113
|
|
202
|
-
|
203
|
-
|
114
|
+
const onResponse = err => {
|
115
|
+
if (err && this.onerror) {
|
116
|
+
this.onerror(err);
|
204
117
|
}
|
205
118
|
|
206
|
-
|
207
|
-
}
|
208
|
-
}, {
|
209
|
-
key: "_readFromStorage",
|
210
|
-
value: function () {
|
211
|
-
var _readFromStorage2 = _asyncToGenerator(
|
212
|
-
/*#__PURE__*/
|
213
|
-
_regenerator["default"].mark(function _callee2(prefObj) {
|
214
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
215
|
-
while (1) {
|
216
|
-
switch (_context2.prev = _context2.next) {
|
217
|
-
case 0:
|
218
|
-
return _context2.abrupt("return", new Promise(function (resolve) {
|
219
|
-
FirefoxCom.request('getPreferences', prefObj, function (prefStr) {
|
220
|
-
var readPrefs = JSON.parse(prefStr);
|
221
|
-
resolve(readPrefs);
|
222
|
-
});
|
223
|
-
}));
|
224
|
-
|
225
|
-
case 1:
|
226
|
-
case "end":
|
227
|
-
return _context2.stop();
|
228
|
-
}
|
229
|
-
}
|
230
|
-
}, _callee2);
|
231
|
-
}));
|
119
|
+
URL.revokeObjectURL(blobUrl);
|
120
|
+
};
|
232
121
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
}]);
|
122
|
+
FirefoxCom.request("download", {
|
123
|
+
blobUrl,
|
124
|
+
originalUrl: url,
|
125
|
+
filename
|
126
|
+
}, onResponse);
|
127
|
+
}
|
240
128
|
|
241
|
-
|
242
|
-
}(_preferences.BasePreferences);
|
129
|
+
}
|
243
130
|
|
244
|
-
|
245
|
-
/*#__PURE__*/
|
246
|
-
function () {
|
247
|
-
function MozL10n(mozL10n) {
|
248
|
-
_classCallCheck(this, MozL10n);
|
131
|
+
exports.DownloadManager = DownloadManager;
|
249
132
|
|
250
|
-
|
133
|
+
class FirefoxPreferences extends _preferences.BasePreferences {
|
134
|
+
async _writeToStorage(prefObj) {
|
135
|
+
return new Promise(function (resolve) {
|
136
|
+
FirefoxCom.request("setPreferences", prefObj, resolve);
|
137
|
+
});
|
251
138
|
}
|
252
139
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
switch (_context3.prev = _context3.next) {
|
262
|
-
case 0:
|
263
|
-
return _context3.abrupt("return", this.mozL10n.getLanguage());
|
264
|
-
|
265
|
-
case 1:
|
266
|
-
case "end":
|
267
|
-
return _context3.stop();
|
268
|
-
}
|
269
|
-
}
|
270
|
-
}, _callee3, this);
|
271
|
-
}));
|
272
|
-
|
273
|
-
function getLanguage() {
|
274
|
-
return _getLanguage.apply(this, arguments);
|
275
|
-
}
|
276
|
-
|
277
|
-
return getLanguage;
|
278
|
-
}()
|
279
|
-
}, {
|
280
|
-
key: "getDirection",
|
281
|
-
value: function () {
|
282
|
-
var _getDirection = _asyncToGenerator(
|
283
|
-
/*#__PURE__*/
|
284
|
-
_regenerator["default"].mark(function _callee4() {
|
285
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
286
|
-
while (1) {
|
287
|
-
switch (_context4.prev = _context4.next) {
|
288
|
-
case 0:
|
289
|
-
return _context4.abrupt("return", this.mozL10n.getDirection());
|
290
|
-
|
291
|
-
case 1:
|
292
|
-
case "end":
|
293
|
-
return _context4.stop();
|
294
|
-
}
|
295
|
-
}
|
296
|
-
}, _callee4, this);
|
297
|
-
}));
|
140
|
+
async _readFromStorage(prefObj) {
|
141
|
+
return new Promise(function (resolve) {
|
142
|
+
FirefoxCom.request("getPreferences", prefObj, function (prefStr) {
|
143
|
+
const readPrefs = JSON.parse(prefStr);
|
144
|
+
resolve(readPrefs);
|
145
|
+
});
|
146
|
+
});
|
147
|
+
}
|
298
148
|
|
299
|
-
|
300
|
-
return _getDirection.apply(this, arguments);
|
301
|
-
}
|
149
|
+
}
|
302
150
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
value: function () {
|
308
|
-
var _get = _asyncToGenerator(
|
309
|
-
/*#__PURE__*/
|
310
|
-
_regenerator["default"].mark(function _callee5(property, args, fallback) {
|
311
|
-
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
312
|
-
while (1) {
|
313
|
-
switch (_context5.prev = _context5.next) {
|
314
|
-
case 0:
|
315
|
-
return _context5.abrupt("return", this.mozL10n.get(property, args, fallback));
|
316
|
-
|
317
|
-
case 1:
|
318
|
-
case "end":
|
319
|
-
return _context5.stop();
|
320
|
-
}
|
321
|
-
}
|
322
|
-
}, _callee5, this);
|
323
|
-
}));
|
151
|
+
class MozL10n {
|
152
|
+
constructor(mozL10n) {
|
153
|
+
this.mozL10n = mozL10n;
|
154
|
+
}
|
324
155
|
|
325
|
-
|
326
|
-
|
327
|
-
|
156
|
+
async getLanguage() {
|
157
|
+
return this.mozL10n.getLanguage();
|
158
|
+
}
|
328
159
|
|
329
|
-
|
330
|
-
|
331
|
-
}
|
332
|
-
key: "translate",
|
333
|
-
value: function () {
|
334
|
-
var _translate = _asyncToGenerator(
|
335
|
-
/*#__PURE__*/
|
336
|
-
_regenerator["default"].mark(function _callee6(element) {
|
337
|
-
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
338
|
-
while (1) {
|
339
|
-
switch (_context6.prev = _context6.next) {
|
340
|
-
case 0:
|
341
|
-
this.mozL10n.translate(element);
|
342
|
-
|
343
|
-
case 1:
|
344
|
-
case "end":
|
345
|
-
return _context6.stop();
|
346
|
-
}
|
347
|
-
}
|
348
|
-
}, _callee6, this);
|
349
|
-
}));
|
160
|
+
async getDirection() {
|
161
|
+
return this.mozL10n.getDirection();
|
162
|
+
}
|
350
163
|
|
351
|
-
|
352
|
-
|
353
|
-
|
164
|
+
async get(property, args, fallback) {
|
165
|
+
return this.mozL10n.get(property, args, fallback);
|
166
|
+
}
|
354
167
|
|
355
|
-
|
356
|
-
|
357
|
-
}
|
168
|
+
async translate(element) {
|
169
|
+
this.mozL10n.translate(element);
|
170
|
+
}
|
358
171
|
|
359
|
-
|
360
|
-
}();
|
172
|
+
}
|
361
173
|
|
362
174
|
(function listenFindEvents() {
|
363
|
-
|
364
|
-
|
365
|
-
var handleEvent = function handleEvent(_ref) {
|
366
|
-
var type = _ref.type,
|
367
|
-
detail = _ref.detail;
|
175
|
+
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"];
|
368
176
|
|
177
|
+
const handleEvent = function ({
|
178
|
+
type,
|
179
|
+
detail
|
180
|
+
}) {
|
369
181
|
if (!_app.PDFViewerApplication.initialized) {
|
370
182
|
return;
|
371
183
|
}
|
372
184
|
|
373
|
-
if (type ===
|
185
|
+
if (type === "findbarclose") {
|
374
186
|
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
375
187
|
source: window
|
376
188
|
});
|
@@ -378,9 +190,9 @@ function () {
|
|
378
190
|
return;
|
379
191
|
}
|
380
192
|
|
381
|
-
_app.PDFViewerApplication.eventBus.dispatch(
|
193
|
+
_app.PDFViewerApplication.eventBus.dispatch("find", {
|
382
194
|
source: window,
|
383
|
-
type: type.substring(
|
195
|
+
type: type.substring("find".length),
|
384
196
|
query: detail.query,
|
385
197
|
phraseSearch: true,
|
386
198
|
caseSensitive: !!detail.caseSensitive,
|
@@ -390,24 +202,23 @@ function () {
|
|
390
202
|
});
|
391
203
|
};
|
392
204
|
|
393
|
-
for (
|
394
|
-
var event = _events[_i];
|
205
|
+
for (const event of events) {
|
395
206
|
window.addEventListener(event, handleEvent);
|
396
207
|
}
|
397
208
|
})();
|
398
209
|
|
399
210
|
(function listenZoomEvents() {
|
400
|
-
|
401
|
-
|
402
|
-
var handleEvent = function handleEvent(_ref2) {
|
403
|
-
var type = _ref2.type,
|
404
|
-
detail = _ref2.detail;
|
211
|
+
const events = ["zoomin", "zoomout", "zoomreset"];
|
405
212
|
|
213
|
+
const handleEvent = function ({
|
214
|
+
type,
|
215
|
+
detail
|
216
|
+
}) {
|
406
217
|
if (!_app.PDFViewerApplication.initialized) {
|
407
218
|
return;
|
408
219
|
}
|
409
220
|
|
410
|
-
if (type ===
|
221
|
+
if (type === "zoomreset" && _app.PDFViewerApplication.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
|
411
222
|
return;
|
412
223
|
}
|
413
224
|
|
@@ -416,93 +227,79 @@ function () {
|
|
416
227
|
});
|
417
228
|
};
|
418
229
|
|
419
|
-
for (
|
420
|
-
var event = _events2[_i2];
|
230
|
+
for (const event of events) {
|
421
231
|
window.addEventListener(event, handleEvent);
|
422
232
|
}
|
423
233
|
})();
|
424
234
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
235
|
+
class FirefoxComDataRangeTransport extends _pdf.PDFDataRangeTransport {
|
236
|
+
requestDataRange(begin, end) {
|
237
|
+
FirefoxCom.request("requestDataRange", {
|
238
|
+
begin,
|
239
|
+
end
|
240
|
+
});
|
241
|
+
}
|
432
242
|
|
433
|
-
|
243
|
+
abort() {
|
244
|
+
FirefoxCom.requestSync("abortLoading", null);
|
434
245
|
}
|
435
246
|
|
436
|
-
|
437
|
-
key: "requestDataRange",
|
438
|
-
value: function requestDataRange(begin, end) {
|
439
|
-
FirefoxCom.request('requestDataRange', {
|
440
|
-
begin: begin,
|
441
|
-
end: end
|
442
|
-
});
|
443
|
-
}
|
444
|
-
}, {
|
445
|
-
key: "abort",
|
446
|
-
value: function abort() {
|
447
|
-
FirefoxCom.requestSync('abortLoading', null);
|
448
|
-
}
|
449
|
-
}]);
|
247
|
+
}
|
450
248
|
|
451
|
-
|
452
|
-
|
249
|
+
class FirefoxExternalServices extends _app.DefaultExternalServices {
|
250
|
+
static updateFindControlState(data) {
|
251
|
+
FirefoxCom.request("updateFindControlState", data);
|
252
|
+
}
|
453
253
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
initPassiveLoading: function initPassiveLoading(callbacks) {
|
462
|
-
var pdfDataRangeTransport;
|
463
|
-
window.addEventListener('message', function windowMessage(e) {
|
254
|
+
static updateFindMatchesCount(data) {
|
255
|
+
FirefoxCom.request("updateFindMatchesCount", data);
|
256
|
+
}
|
257
|
+
|
258
|
+
static initPassiveLoading(callbacks) {
|
259
|
+
let pdfDataRangeTransport;
|
260
|
+
window.addEventListener("message", function windowMessage(e) {
|
464
261
|
if (e.source !== null) {
|
465
|
-
console.warn(
|
262
|
+
console.warn("Rejected untrusted message from " + e.origin);
|
466
263
|
return;
|
467
264
|
}
|
468
265
|
|
469
|
-
|
266
|
+
const args = e.data;
|
470
267
|
|
471
|
-
if (
|
268
|
+
if (typeof args !== "object" || !("pdfjsLoadAction" in args)) {
|
472
269
|
return;
|
473
270
|
}
|
474
271
|
|
475
272
|
switch (args.pdfjsLoadAction) {
|
476
|
-
case
|
273
|
+
case "supportsRangedLoading":
|
477
274
|
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
|
478
275
|
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
|
479
276
|
break;
|
480
277
|
|
481
|
-
case
|
278
|
+
case "range":
|
482
279
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
483
280
|
break;
|
484
281
|
|
485
|
-
case
|
282
|
+
case "rangeProgress":
|
486
283
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
487
284
|
break;
|
488
285
|
|
489
|
-
case
|
286
|
+
case "progressiveRead":
|
490
287
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
491
288
|
pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
|
492
289
|
break;
|
493
290
|
|
494
|
-
case
|
291
|
+
case "progressiveDone":
|
495
292
|
if (pdfDataRangeTransport) {
|
496
293
|
pdfDataRangeTransport.onDataProgressiveDone();
|
497
294
|
}
|
498
295
|
|
499
296
|
break;
|
500
297
|
|
501
|
-
case
|
298
|
+
case "progress":
|
502
299
|
callbacks.onProgress(args.loaded, args.total);
|
503
300
|
break;
|
504
301
|
|
505
|
-
case
|
302
|
+
case "complete":
|
506
303
|
if (!args.data) {
|
507
304
|
callbacks.onError(args.errorCode);
|
508
305
|
break;
|
@@ -512,51 +309,55 @@ _app.PDFViewerApplication.externalServices = {
|
|
512
309
|
break;
|
513
310
|
}
|
514
311
|
});
|
515
|
-
FirefoxCom.requestSync(
|
516
|
-
}
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
312
|
+
FirefoxCom.requestSync("initPassiveLoading", null);
|
313
|
+
}
|
314
|
+
|
315
|
+
static fallback(data, callback) {
|
316
|
+
FirefoxCom.request("fallback", data, callback);
|
317
|
+
}
|
318
|
+
|
319
|
+
static reportTelemetry(data) {
|
320
|
+
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
|
321
|
+
}
|
322
|
+
|
323
|
+
static createDownloadManager(options) {
|
524
324
|
return new DownloadManager(options);
|
525
|
-
}
|
526
|
-
|
325
|
+
}
|
326
|
+
|
327
|
+
static createPreferences() {
|
527
328
|
return new FirefoxPreferences();
|
528
|
-
}
|
529
|
-
createL10n: function createL10n(options) {
|
530
|
-
var mozL10n = document.mozL10n;
|
531
|
-
return new MozL10n(mozL10n);
|
532
|
-
},
|
329
|
+
}
|
533
330
|
|
534
|
-
|
535
|
-
|
536
|
-
return
|
537
|
-
}
|
331
|
+
static createL10n(options) {
|
332
|
+
const mozL10n = document.mozL10n;
|
333
|
+
return new MozL10n(mozL10n);
|
334
|
+
}
|
538
335
|
|
539
|
-
get
|
540
|
-
|
541
|
-
return (0, _pdf.shadow)(this,
|
542
|
-
}
|
336
|
+
static get supportsIntegratedFind() {
|
337
|
+
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
338
|
+
return (0, _pdf.shadow)(this, "supportsIntegratedFind", support);
|
339
|
+
}
|
543
340
|
|
544
|
-
get
|
545
|
-
|
546
|
-
return (0, _pdf.shadow)(this,
|
547
|
-
}
|
341
|
+
static get supportsDocumentFonts() {
|
342
|
+
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
343
|
+
return (0, _pdf.shadow)(this, "supportsDocumentFonts", support);
|
344
|
+
}
|
548
345
|
|
549
|
-
get supportedMouseWheelZoomModifierKeys() {
|
550
|
-
|
551
|
-
return (0, _pdf.shadow)(this,
|
346
|
+
static get supportedMouseWheelZoomModifierKeys() {
|
347
|
+
const support = FirefoxCom.requestSync("supportedMouseWheelZoomModifierKeys");
|
348
|
+
return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", support);
|
552
349
|
}
|
553
350
|
|
554
|
-
}
|
351
|
+
}
|
352
|
+
|
353
|
+
_app.PDFViewerApplication.externalServices = FirefoxExternalServices;
|
555
354
|
document.mozL10n.setExternalLocalizerServices({
|
556
|
-
getLocale
|
557
|
-
return FirefoxCom.requestSync(
|
355
|
+
getLocale() {
|
356
|
+
return FirefoxCom.requestSync("getLocale", null);
|
558
357
|
},
|
559
|
-
|
560
|
-
|
358
|
+
|
359
|
+
getStrings(key) {
|
360
|
+
return FirefoxCom.requestSync("getStrings", key);
|
561
361
|
}
|
362
|
+
|
562
363
|
});
|