pdfjs-dist 2.1.266 → 2.5.207
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/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8382 -18492
- 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 +20417 -29816
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25688 -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 +58239 -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 +403 -0
- package/es5/web/pdf_viewer.js +7742 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1475 -4897
- 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 +750 -899
- 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 +235 -183
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +447 -542
- package/lib/core/cmap.js +222 -264
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +573 -660
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +1103 -868
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +570 -491
- package/lib/core/function.js +291 -288
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +145 -149
- package/lib/core/image_utils.js +170 -0
- 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 +284 -232
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2929 -2929
- package/lib/core/murmurhash3.js +90 -101
- package/lib/core/obj.js +1183 -1157
- package/lib/core/operator_list.js +99 -67
- package/lib/core/parser.js +972 -911
- package/lib/core/pattern.js +87 -70
- package/lib/core/pdf_manager.js +150 -315
- package/lib/core/primitives.js +83 -56
- 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 +87 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +193 -390
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +741 -972
- package/lib/display/api.js +1500 -1791
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +165 -165
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +515 -0
- package/lib/display/fetch_stream.js +183 -298
- package/lib/display/font_loader.js +273 -413
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +266 -359
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +285 -458
- package/lib/display/pattern_helper.js +113 -65
- package/lib/display/svg.js +1166 -901
- package/lib/display/text_layer.js +156 -132
- package/lib/display/transport_stream.js +262 -278
- 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 +40 -37
- package/lib/pdf.js +226 -59
- 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 +266 -416
- package/lib/test/unit/annotation_spec.js +1555 -701
- package/lib/test/unit/api_spec.js +802 -604
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +84 -69
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +74 -76
- package/lib/test/unit/colorspace_spec.js +166 -161
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +20 -22
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +16 -21
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +83 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +46 -30
- package/lib/test/unit/message_handler_spec.js +173 -159
- 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 +13 -61
- package/lib/test/unit/network_utils_spec.js +183 -119
- package/lib/test/unit/node_stream_spec.js +78 -92
- package/lib/test/unit/parser_spec.js +172 -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 +140 -125
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +131 -143
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +297 -459
- package/lib/test/unit/unicode_spec.js +38 -38
- package/lib/test/unit/util_spec.js +121 -305
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1328 -1214
- package/lib/web/app_options.js +105 -107
- package/lib/web/base_viewer.js +824 -838
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +39 -55
- package/lib/web/firefox_print_service.js +37 -27
- package/lib/web/firefoxcom.js +212 -363
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +32 -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 +113 -131
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +221 -306
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +491 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +140 -175
- package/lib/web/pdf_page_view.js +452 -523
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +84 -108
- package/lib/web/pdf_sidebar.js +276 -306
- 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 +82 -286
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +282 -339
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +267 -420
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +35 -25
- package/web/pdf_viewer.js +3489 -4855
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -494
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/lib/test/unit/dom_utils_spec.js +0 -89
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,180 @@ 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
|
-
function () {
|
114
|
-
function DownloadManager(options) {
|
115
|
-
_classCallCheck(this, DownloadManager);
|
116
|
-
|
89
|
+
class DownloadManager {
|
90
|
+
constructor(options) {
|
117
91
|
this.disableCreateObjectURL = false;
|
118
92
|
}
|
119
93
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
});
|
127
|
-
}
|
128
|
-
}, {
|
129
|
-
key: "downloadData",
|
130
|
-
value: function downloadData(data, filename, contentType) {
|
131
|
-
var blobUrl = (0, _pdf.createObjectURL)(data, contentType);
|
132
|
-
FirefoxCom.request('download', {
|
133
|
-
blobUrl: blobUrl,
|
134
|
-
originalUrl: blobUrl,
|
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);
|
94
|
+
downloadUrl(url, filename) {
|
95
|
+
FirefoxCom.request("download", {
|
96
|
+
originalUrl: url,
|
97
|
+
filename
|
98
|
+
});
|
99
|
+
}
|
174
100
|
|
175
|
-
|
101
|
+
downloadData(data, filename, contentType) {
|
102
|
+
const blobUrl = URL.createObjectURL(new Blob([data], {
|
103
|
+
type: contentType
|
104
|
+
}));
|
105
|
+
|
106
|
+
const onResponse = err => {
|
107
|
+
URL.revokeObjectURL(blobUrl);
|
108
|
+
};
|
109
|
+
|
110
|
+
FirefoxCom.request("download", {
|
111
|
+
blobUrl,
|
112
|
+
originalUrl: blobUrl,
|
113
|
+
filename,
|
114
|
+
isAttachment: true
|
115
|
+
}, onResponse);
|
176
116
|
}
|
177
117
|
|
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, this);
|
198
|
-
}));
|
118
|
+
download(blob, url, filename) {
|
119
|
+
const blobUrl = URL.createObjectURL(blob);
|
199
120
|
|
200
|
-
|
201
|
-
|
121
|
+
const onResponse = err => {
|
122
|
+
if (err && this.onerror) {
|
123
|
+
this.onerror(err);
|
202
124
|
}
|
203
125
|
|
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, this);
|
229
|
-
}));
|
230
|
-
|
231
|
-
function _readFromStorage(_x2) {
|
232
|
-
return _readFromStorage2.apply(this, arguments);
|
233
|
-
}
|
126
|
+
URL.revokeObjectURL(blobUrl);
|
127
|
+
};
|
234
128
|
|
235
|
-
|
236
|
-
|
237
|
-
|
129
|
+
FirefoxCom.request("download", {
|
130
|
+
blobUrl,
|
131
|
+
originalUrl: url,
|
132
|
+
filename
|
133
|
+
}, onResponse);
|
134
|
+
}
|
238
135
|
|
239
|
-
|
240
|
-
}(_preferences.BasePreferences);
|
136
|
+
}
|
241
137
|
|
242
|
-
|
243
|
-
/*#__PURE__*/
|
244
|
-
function () {
|
245
|
-
function MozL10n(mozL10n) {
|
246
|
-
_classCallCheck(this, MozL10n);
|
138
|
+
exports.DownloadManager = DownloadManager;
|
247
139
|
|
248
|
-
|
140
|
+
class FirefoxPreferences extends _preferences.BasePreferences {
|
141
|
+
async _writeToStorage(prefObj) {
|
142
|
+
return new Promise(function (resolve) {
|
143
|
+
FirefoxCom.request("setPreferences", prefObj, resolve);
|
144
|
+
});
|
249
145
|
}
|
250
146
|
|
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
|
-
}));
|
147
|
+
async _readFromStorage(prefObj) {
|
148
|
+
return new Promise(function (resolve) {
|
149
|
+
FirefoxCom.request("getPreferences", prefObj, function (prefStr) {
|
150
|
+
const readPrefs = JSON.parse(prefStr);
|
151
|
+
resolve(readPrefs);
|
152
|
+
});
|
153
|
+
});
|
154
|
+
}
|
296
155
|
|
297
|
-
|
298
|
-
return _getDirection.apply(this, arguments);
|
299
|
-
}
|
156
|
+
}
|
300
157
|
|
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
|
-
}));
|
158
|
+
class MozL10n {
|
159
|
+
constructor(mozL10n) {
|
160
|
+
this.mozL10n = mozL10n;
|
161
|
+
}
|
322
162
|
|
323
|
-
|
324
|
-
|
325
|
-
|
163
|
+
async getLanguage() {
|
164
|
+
return this.mozL10n.getLanguage();
|
165
|
+
}
|
326
166
|
|
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
|
-
}));
|
167
|
+
async getDirection() {
|
168
|
+
return this.mozL10n.getDirection();
|
169
|
+
}
|
348
170
|
|
349
|
-
|
350
|
-
|
351
|
-
|
171
|
+
async get(property, args, fallback) {
|
172
|
+
return this.mozL10n.get(property, args, fallback);
|
173
|
+
}
|
352
174
|
|
353
|
-
|
354
|
-
|
355
|
-
}
|
175
|
+
async translate(element) {
|
176
|
+
this.mozL10n.translate(element);
|
177
|
+
}
|
356
178
|
|
357
|
-
|
358
|
-
}();
|
179
|
+
}
|
359
180
|
|
360
181
|
(function listenFindEvents() {
|
361
|
-
|
362
|
-
|
363
|
-
var handleEvent = function handleEvent(_ref) {
|
364
|
-
var type = _ref.type,
|
365
|
-
detail = _ref.detail;
|
182
|
+
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"];
|
366
183
|
|
184
|
+
const handleEvent = function ({
|
185
|
+
type,
|
186
|
+
detail
|
187
|
+
}) {
|
367
188
|
if (!_app.PDFViewerApplication.initialized) {
|
368
189
|
return;
|
369
190
|
}
|
370
191
|
|
371
|
-
if (type ===
|
372
|
-
_app.PDFViewerApplication.eventBus.dispatch(
|
192
|
+
if (type === "findbarclose") {
|
193
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
373
194
|
source: window
|
374
195
|
});
|
375
196
|
|
376
197
|
return;
|
377
198
|
}
|
378
199
|
|
379
|
-
_app.PDFViewerApplication.eventBus.dispatch(
|
200
|
+
_app.PDFViewerApplication.eventBus.dispatch("find", {
|
380
201
|
source: window,
|
381
|
-
type: type.substring(
|
202
|
+
type: type.substring("find".length),
|
382
203
|
query: detail.query,
|
383
204
|
phraseSearch: true,
|
384
205
|
caseSensitive: !!detail.caseSensitive,
|
@@ -388,85 +209,104 @@ function () {
|
|
388
209
|
});
|
389
210
|
};
|
390
211
|
|
391
|
-
for (
|
392
|
-
var event = events[_i];
|
212
|
+
for (const event of events) {
|
393
213
|
window.addEventListener(event, handleEvent);
|
394
214
|
}
|
395
215
|
})();
|
396
216
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
217
|
+
(function listenZoomEvents() {
|
218
|
+
const events = ["zoomin", "zoomout", "zoomreset"];
|
219
|
+
|
220
|
+
const handleEvent = function ({
|
221
|
+
type,
|
222
|
+
detail
|
223
|
+
}) {
|
224
|
+
if (!_app.PDFViewerApplication.initialized) {
|
225
|
+
return;
|
226
|
+
}
|
401
227
|
|
402
|
-
|
403
|
-
|
228
|
+
if (type === "zoomreset" && _app.PDFViewerApplication.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
|
229
|
+
return;
|
230
|
+
}
|
404
231
|
|
405
|
-
|
232
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
233
|
+
source: window
|
234
|
+
});
|
235
|
+
};
|
236
|
+
|
237
|
+
for (const event of events) {
|
238
|
+
window.addEventListener(event, handleEvent);
|
406
239
|
}
|
240
|
+
})();
|
407
241
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
}
|
416
|
-
}, {
|
417
|
-
key: "abort",
|
418
|
-
value: function abort() {
|
419
|
-
FirefoxCom.requestSync('abortLoading', null);
|
420
|
-
}
|
421
|
-
}]);
|
242
|
+
class FirefoxComDataRangeTransport extends _pdf.PDFDataRangeTransport {
|
243
|
+
requestDataRange(begin, end) {
|
244
|
+
FirefoxCom.request("requestDataRange", {
|
245
|
+
begin,
|
246
|
+
end
|
247
|
+
});
|
248
|
+
}
|
422
249
|
|
423
|
-
|
424
|
-
|
250
|
+
abort() {
|
251
|
+
FirefoxCom.requestSync("abortLoading", null);
|
252
|
+
}
|
425
253
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
254
|
+
}
|
255
|
+
|
256
|
+
class FirefoxExternalServices extends _app.DefaultExternalServices {
|
257
|
+
static updateFindControlState(data) {
|
258
|
+
FirefoxCom.request("updateFindControlState", data);
|
259
|
+
}
|
260
|
+
|
261
|
+
static updateFindMatchesCount(data) {
|
262
|
+
FirefoxCom.request("updateFindMatchesCount", data);
|
263
|
+
}
|
264
|
+
|
265
|
+
static initPassiveLoading(callbacks) {
|
266
|
+
let pdfDataRangeTransport;
|
267
|
+
window.addEventListener("message", function windowMessage(e) {
|
436
268
|
if (e.source !== null) {
|
437
|
-
console.warn(
|
269
|
+
console.warn("Rejected untrusted message from " + e.origin);
|
438
270
|
return;
|
439
271
|
}
|
440
272
|
|
441
|
-
|
273
|
+
const args = e.data;
|
442
274
|
|
443
|
-
if (
|
275
|
+
if (typeof args !== "object" || !("pdfjsLoadAction" in args)) {
|
444
276
|
return;
|
445
277
|
}
|
446
278
|
|
447
279
|
switch (args.pdfjsLoadAction) {
|
448
|
-
case
|
449
|
-
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data);
|
280
|
+
case "supportsRangedLoading":
|
281
|
+
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
|
450
282
|
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
|
451
283
|
break;
|
452
284
|
|
453
|
-
case
|
285
|
+
case "range":
|
454
286
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
455
287
|
break;
|
456
288
|
|
457
|
-
case
|
289
|
+
case "rangeProgress":
|
458
290
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
459
291
|
break;
|
460
292
|
|
461
|
-
case
|
293
|
+
case "progressiveRead":
|
462
294
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
295
|
+
pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
|
296
|
+
break;
|
297
|
+
|
298
|
+
case "progressiveDone":
|
299
|
+
if (pdfDataRangeTransport) {
|
300
|
+
pdfDataRangeTransport.onDataProgressiveDone();
|
301
|
+
}
|
302
|
+
|
463
303
|
break;
|
464
304
|
|
465
|
-
case
|
305
|
+
case "progress":
|
466
306
|
callbacks.onProgress(args.loaded, args.total);
|
467
307
|
break;
|
468
308
|
|
469
|
-
case
|
309
|
+
case "complete":
|
470
310
|
if (!args.data) {
|
471
311
|
callbacks.onError(args.errorCode);
|
472
312
|
break;
|
@@ -476,51 +316,60 @@ _app.PDFViewerApplication.externalServices = {
|
|
476
316
|
break;
|
477
317
|
}
|
478
318
|
});
|
479
|
-
FirefoxCom.requestSync(
|
480
|
-
}
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
319
|
+
FirefoxCom.requestSync("initPassiveLoading", null);
|
320
|
+
}
|
321
|
+
|
322
|
+
static fallback(data, callback) {
|
323
|
+
FirefoxCom.request("fallback", data, callback);
|
324
|
+
}
|
325
|
+
|
326
|
+
static reportTelemetry(data) {
|
327
|
+
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
|
328
|
+
}
|
329
|
+
|
330
|
+
static createDownloadManager(options) {
|
488
331
|
return new DownloadManager(options);
|
489
|
-
}
|
490
|
-
|
332
|
+
}
|
333
|
+
|
334
|
+
static createPreferences() {
|
491
335
|
return new FirefoxPreferences();
|
492
|
-
}
|
493
|
-
|
494
|
-
|
336
|
+
}
|
337
|
+
|
338
|
+
static createL10n(options) {
|
339
|
+
const mozL10n = document.mozL10n;
|
495
340
|
return new MozL10n(mozL10n);
|
496
|
-
}
|
341
|
+
}
|
497
342
|
|
498
|
-
get supportsIntegratedFind() {
|
499
|
-
|
500
|
-
return (0, _pdf.shadow)(this,
|
501
|
-
}
|
343
|
+
static get supportsIntegratedFind() {
|
344
|
+
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
345
|
+
return (0, _pdf.shadow)(this, "supportsIntegratedFind", support);
|
346
|
+
}
|
502
347
|
|
503
|
-
get supportsDocumentFonts() {
|
504
|
-
|
505
|
-
return (0, _pdf.shadow)(this,
|
506
|
-
}
|
348
|
+
static get supportsDocumentFonts() {
|
349
|
+
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
350
|
+
return (0, _pdf.shadow)(this, "supportsDocumentFonts", support);
|
351
|
+
}
|
507
352
|
|
508
|
-
get
|
509
|
-
|
510
|
-
return (0, _pdf.shadow)(this,
|
511
|
-
}
|
353
|
+
static get supportedMouseWheelZoomModifierKeys() {
|
354
|
+
const support = FirefoxCom.requestSync("supportedMouseWheelZoomModifierKeys");
|
355
|
+
return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", support);
|
356
|
+
}
|
512
357
|
|
513
|
-
get
|
514
|
-
|
515
|
-
return (0, _pdf.shadow)(this,
|
358
|
+
static get isInAutomation() {
|
359
|
+
const isInAutomation = FirefoxCom.requestSync("isInAutomation");
|
360
|
+
return (0, _pdf.shadow)(this, "isInAutomation", isInAutomation);
|
516
361
|
}
|
517
362
|
|
518
|
-
}
|
363
|
+
}
|
364
|
+
|
365
|
+
_app.PDFViewerApplication.externalServices = FirefoxExternalServices;
|
519
366
|
document.mozL10n.setExternalLocalizerServices({
|
520
|
-
getLocale
|
521
|
-
return FirefoxCom.requestSync(
|
367
|
+
getLocale() {
|
368
|
+
return FirefoxCom.requestSync("getLocale", null);
|
522
369
|
},
|
523
|
-
|
524
|
-
|
370
|
+
|
371
|
+
getStrings(key) {
|
372
|
+
return FirefoxCom.requestSync("getStrings", key);
|
525
373
|
}
|
374
|
+
|
526
375
|
});
|