pdfjs-dist 2.0.943 → 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/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- 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 +25500 -26628
- 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 +2887 -4094
- 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 +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- 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 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
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.
|
@@ -19,324 +19,180 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.FirefoxCom = exports.DownloadManager =
|
27
|
+
exports.FirefoxCom = exports.DownloadManager = void 0;
|
28
28
|
|
29
|
-
|
29
|
+
require("../extensions/firefox/tools/l10n.js");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _pdf = require("../pdf");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _app = require("./app.js");
|
34
34
|
|
35
|
-
var
|
35
|
+
var _preferences = require("./preferences.js");
|
36
36
|
|
37
|
-
require(
|
38
|
-
|
39
|
-
var _pdf = require('../pdf');
|
40
|
-
|
41
|
-
var _preferences = require('./preferences');
|
42
|
-
|
43
|
-
var _app = require('./app');
|
44
|
-
|
45
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
46
|
-
|
47
|
-
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
48
|
-
|
49
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
50
|
-
|
51
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
52
|
-
|
53
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
37
|
+
var _ui_utils = require("./ui_utils.js");
|
54
38
|
|
55
39
|
{
|
56
|
-
throw new Error('Module "
|
40
|
+
throw new Error('Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.');
|
57
41
|
}
|
58
|
-
|
42
|
+
|
43
|
+
const FirefoxCom = function FirefoxComClosure() {
|
59
44
|
return {
|
60
|
-
requestSync
|
61
|
-
|
45
|
+
requestSync(action, data) {
|
46
|
+
const request = document.createTextNode("");
|
62
47
|
document.documentElement.appendChild(request);
|
63
|
-
|
64
|
-
sender.initCustomEvent(
|
65
|
-
action
|
66
|
-
data
|
48
|
+
const sender = document.createEvent("CustomEvent");
|
49
|
+
sender.initCustomEvent("pdf.js.message", true, false, {
|
50
|
+
action,
|
51
|
+
data,
|
67
52
|
sync: true
|
68
53
|
});
|
69
54
|
request.dispatchEvent(sender);
|
70
|
-
|
55
|
+
const response = sender.detail.response;
|
71
56
|
document.documentElement.removeChild(request);
|
72
57
|
return response;
|
73
58
|
},
|
74
|
-
|
75
|
-
|
59
|
+
|
60
|
+
request(action, data, callback) {
|
61
|
+
const request = document.createTextNode("");
|
62
|
+
|
76
63
|
if (callback) {
|
77
|
-
document.addEventListener(
|
78
|
-
|
79
|
-
|
64
|
+
document.addEventListener("pdf.js.response", function listener(event) {
|
65
|
+
const node = event.target;
|
66
|
+
const response = event.detail.response;
|
80
67
|
document.documentElement.removeChild(node);
|
81
|
-
document.removeEventListener(
|
68
|
+
document.removeEventListener("pdf.js.response", listener);
|
82
69
|
return callback(response);
|
83
70
|
});
|
84
71
|
}
|
72
|
+
|
85
73
|
document.documentElement.appendChild(request);
|
86
|
-
|
87
|
-
sender.initCustomEvent(
|
88
|
-
action
|
89
|
-
data
|
74
|
+
const sender = document.createEvent("CustomEvent");
|
75
|
+
sender.initCustomEvent("pdf.js.message", true, false, {
|
76
|
+
action,
|
77
|
+
data,
|
90
78
|
sync: false,
|
91
79
|
responseExpected: !!callback
|
92
80
|
});
|
93
81
|
return request.dispatchEvent(sender);
|
94
82
|
}
|
83
|
+
|
95
84
|
};
|
96
85
|
}();
|
97
86
|
|
98
|
-
|
99
|
-
function DownloadManager(options) {
|
100
|
-
_classCallCheck(this, DownloadManager);
|
87
|
+
exports.FirefoxCom = FirefoxCom;
|
101
88
|
|
89
|
+
class DownloadManager {
|
90
|
+
constructor(options) {
|
102
91
|
this.disableCreateObjectURL = false;
|
103
92
|
}
|
104
93
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
});
|
112
|
-
}
|
113
|
-
}, {
|
114
|
-
key: 'downloadData',
|
115
|
-
value: function downloadData(data, filename, contentType) {
|
116
|
-
var blobUrl = (0, _pdf.createObjectURL)(data, contentType);
|
117
|
-
FirefoxCom.request('download', {
|
118
|
-
blobUrl: blobUrl,
|
119
|
-
originalUrl: blobUrl,
|
120
|
-
filename: filename,
|
121
|
-
isAttachment: true
|
122
|
-
});
|
123
|
-
}
|
124
|
-
}, {
|
125
|
-
key: 'download',
|
126
|
-
value: function download(blob, url, filename) {
|
127
|
-
var _this = this;
|
128
|
-
|
129
|
-
var blobUrl = _pdf.URL.createObjectURL(blob);
|
130
|
-
var onResponse = function onResponse(err) {
|
131
|
-
if (err && _this.onerror) {
|
132
|
-
_this.onerror(err);
|
133
|
-
}
|
134
|
-
_pdf.URL.revokeObjectURL(blobUrl);
|
135
|
-
};
|
136
|
-
FirefoxCom.request('download', {
|
137
|
-
blobUrl: blobUrl,
|
138
|
-
originalUrl: url,
|
139
|
-
filename: filename
|
140
|
-
}, onResponse);
|
141
|
-
}
|
142
|
-
}]);
|
143
|
-
|
144
|
-
return DownloadManager;
|
145
|
-
}();
|
146
|
-
|
147
|
-
var FirefoxPreferences = function (_BasePreferences) {
|
148
|
-
_inherits(FirefoxPreferences, _BasePreferences);
|
149
|
-
|
150
|
-
function FirefoxPreferences() {
|
151
|
-
_classCallCheck(this, FirefoxPreferences);
|
94
|
+
downloadUrl(url, filename) {
|
95
|
+
FirefoxCom.request("download", {
|
96
|
+
originalUrl: url,
|
97
|
+
filename
|
98
|
+
});
|
99
|
+
}
|
152
100
|
|
153
|
-
|
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
|
+
});
|
154
109
|
}
|
155
110
|
|
156
|
-
|
157
|
-
|
158
|
-
value: function () {
|
159
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) {
|
160
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
161
|
-
while (1) {
|
162
|
-
switch (_context.prev = _context.next) {
|
163
|
-
case 0:
|
164
|
-
return _context.abrupt('return', new Promise(function (resolve) {
|
165
|
-
FirefoxCom.request('setPreferences', prefObj, resolve);
|
166
|
-
}));
|
167
|
-
|
168
|
-
case 1:
|
169
|
-
case 'end':
|
170
|
-
return _context.stop();
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}, _callee, this);
|
174
|
-
}));
|
111
|
+
download(blob, url, filename) {
|
112
|
+
const blobUrl = URL.createObjectURL(blob);
|
175
113
|
|
176
|
-
|
177
|
-
|
114
|
+
const onResponse = err => {
|
115
|
+
if (err && this.onerror) {
|
116
|
+
this.onerror(err);
|
178
117
|
}
|
179
118
|
|
180
|
-
|
181
|
-
}
|
182
|
-
}, {
|
183
|
-
key: '_readFromStorage',
|
184
|
-
value: function () {
|
185
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) {
|
186
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
187
|
-
while (1) {
|
188
|
-
switch (_context2.prev = _context2.next) {
|
189
|
-
case 0:
|
190
|
-
return _context2.abrupt('return', new Promise(function (resolve) {
|
191
|
-
FirefoxCom.request('getPreferences', prefObj, function (prefStr) {
|
192
|
-
var readPrefs = JSON.parse(prefStr);
|
193
|
-
resolve(readPrefs);
|
194
|
-
});
|
195
|
-
}));
|
196
|
-
|
197
|
-
case 1:
|
198
|
-
case 'end':
|
199
|
-
return _context2.stop();
|
200
|
-
}
|
201
|
-
}
|
202
|
-
}, _callee2, this);
|
203
|
-
}));
|
204
|
-
|
205
|
-
function _readFromStorage(_x2) {
|
206
|
-
return _ref2.apply(this, arguments);
|
207
|
-
}
|
119
|
+
URL.revokeObjectURL(blobUrl);
|
120
|
+
};
|
208
121
|
|
209
|
-
|
210
|
-
|
211
|
-
|
122
|
+
FirefoxCom.request("download", {
|
123
|
+
blobUrl,
|
124
|
+
originalUrl: url,
|
125
|
+
filename
|
126
|
+
}, onResponse);
|
127
|
+
}
|
212
128
|
|
213
|
-
|
214
|
-
}(_preferences.BasePreferences);
|
129
|
+
}
|
215
130
|
|
216
|
-
|
217
|
-
function MozL10n(mozL10n) {
|
218
|
-
_classCallCheck(this, MozL10n);
|
131
|
+
exports.DownloadManager = DownloadManager;
|
219
132
|
|
220
|
-
|
133
|
+
class FirefoxPreferences extends _preferences.BasePreferences {
|
134
|
+
async _writeToStorage(prefObj) {
|
135
|
+
return new Promise(function (resolve) {
|
136
|
+
FirefoxCom.request("setPreferences", prefObj, resolve);
|
137
|
+
});
|
221
138
|
}
|
222
139
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
return _context3.abrupt('return', this.mozL10n.getLanguage());
|
232
|
-
|
233
|
-
case 1:
|
234
|
-
case 'end':
|
235
|
-
return _context3.stop();
|
236
|
-
}
|
237
|
-
}
|
238
|
-
}, _callee3, this);
|
239
|
-
}));
|
240
|
-
|
241
|
-
function getLanguage() {
|
242
|
-
return _ref3.apply(this, arguments);
|
243
|
-
}
|
244
|
-
|
245
|
-
return getLanguage;
|
246
|
-
}()
|
247
|
-
}, {
|
248
|
-
key: 'getDirection',
|
249
|
-
value: function () {
|
250
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
|
251
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
252
|
-
while (1) {
|
253
|
-
switch (_context4.prev = _context4.next) {
|
254
|
-
case 0:
|
255
|
-
return _context4.abrupt('return', this.mozL10n.getDirection());
|
256
|
-
|
257
|
-
case 1:
|
258
|
-
case 'end':
|
259
|
-
return _context4.stop();
|
260
|
-
}
|
261
|
-
}
|
262
|
-
}, _callee4, this);
|
263
|
-
}));
|
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
|
+
}
|
264
148
|
|
265
|
-
|
266
|
-
return _ref4.apply(this, arguments);
|
267
|
-
}
|
149
|
+
}
|
268
150
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
value: function () {
|
274
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(property, args, fallback) {
|
275
|
-
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
276
|
-
while (1) {
|
277
|
-
switch (_context5.prev = _context5.next) {
|
278
|
-
case 0:
|
279
|
-
return _context5.abrupt('return', this.mozL10n.get(property, args, fallback));
|
280
|
-
|
281
|
-
case 1:
|
282
|
-
case 'end':
|
283
|
-
return _context5.stop();
|
284
|
-
}
|
285
|
-
}
|
286
|
-
}, _callee5, this);
|
287
|
-
}));
|
151
|
+
class MozL10n {
|
152
|
+
constructor(mozL10n) {
|
153
|
+
this.mozL10n = mozL10n;
|
154
|
+
}
|
288
155
|
|
289
|
-
|
290
|
-
|
291
|
-
|
156
|
+
async getLanguage() {
|
157
|
+
return this.mozL10n.getLanguage();
|
158
|
+
}
|
292
159
|
|
293
|
-
|
294
|
-
|
295
|
-
}
|
296
|
-
key: 'translate',
|
297
|
-
value: function () {
|
298
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6(element) {
|
299
|
-
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
300
|
-
while (1) {
|
301
|
-
switch (_context6.prev = _context6.next) {
|
302
|
-
case 0:
|
303
|
-
this.mozL10n.translate(element);
|
304
|
-
|
305
|
-
case 1:
|
306
|
-
case 'end':
|
307
|
-
return _context6.stop();
|
308
|
-
}
|
309
|
-
}
|
310
|
-
}, _callee6, this);
|
311
|
-
}));
|
160
|
+
async getDirection() {
|
161
|
+
return this.mozL10n.getDirection();
|
162
|
+
}
|
312
163
|
|
313
|
-
|
314
|
-
|
315
|
-
|
164
|
+
async get(property, args, fallback) {
|
165
|
+
return this.mozL10n.get(property, args, fallback);
|
166
|
+
}
|
316
167
|
|
317
|
-
|
318
|
-
|
319
|
-
}
|
168
|
+
async translate(element) {
|
169
|
+
this.mozL10n.translate(element);
|
170
|
+
}
|
320
171
|
|
321
|
-
|
322
|
-
}();
|
172
|
+
}
|
323
173
|
|
324
174
|
(function listenFindEvents() {
|
325
|
-
|
326
|
-
var handleEvent = function handleEvent(_ref7) {
|
327
|
-
var type = _ref7.type,
|
328
|
-
detail = _ref7.detail;
|
175
|
+
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"];
|
329
176
|
|
177
|
+
const handleEvent = function ({
|
178
|
+
type,
|
179
|
+
detail
|
180
|
+
}) {
|
330
181
|
if (!_app.PDFViewerApplication.initialized) {
|
331
182
|
return;
|
332
183
|
}
|
333
|
-
|
334
|
-
|
184
|
+
|
185
|
+
if (type === "findbarclose") {
|
186
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
187
|
+
source: window
|
188
|
+
});
|
189
|
+
|
335
190
|
return;
|
336
191
|
}
|
337
|
-
|
192
|
+
|
193
|
+
_app.PDFViewerApplication.eventBus.dispatch("find", {
|
338
194
|
source: window,
|
339
|
-
type: type.substring(
|
195
|
+
type: type.substring("find".length),
|
340
196
|
query: detail.query,
|
341
197
|
phraseSearch: true,
|
342
198
|
caseSensitive: !!detail.caseSensitive,
|
@@ -345,146 +201,163 @@ var MozL10n = function () {
|
|
345
201
|
findPrevious: !!detail.findPrevious
|
346
202
|
});
|
347
203
|
};
|
348
|
-
var _iteratorNormalCompletion = true;
|
349
|
-
var _didIteratorError = false;
|
350
|
-
var _iteratorError = undefined;
|
351
204
|
|
352
|
-
|
353
|
-
|
354
|
-
|
205
|
+
for (const event of events) {
|
206
|
+
window.addEventListener(event, handleEvent);
|
207
|
+
}
|
208
|
+
})();
|
209
|
+
|
210
|
+
(function listenZoomEvents() {
|
211
|
+
const events = ["zoomin", "zoomout", "zoomreset"];
|
355
212
|
|
356
|
-
|
213
|
+
const handleEvent = function ({
|
214
|
+
type,
|
215
|
+
detail
|
216
|
+
}) {
|
217
|
+
if (!_app.PDFViewerApplication.initialized) {
|
218
|
+
return;
|
357
219
|
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
} finally {
|
362
|
-
try {
|
363
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
364
|
-
_iterator.return();
|
365
|
-
}
|
366
|
-
} finally {
|
367
|
-
if (_didIteratorError) {
|
368
|
-
throw _iteratorError;
|
369
|
-
}
|
220
|
+
|
221
|
+
if (type === "zoomreset" && _app.PDFViewerApplication.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
|
222
|
+
return;
|
370
223
|
}
|
224
|
+
|
225
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
226
|
+
source: window
|
227
|
+
});
|
228
|
+
};
|
229
|
+
|
230
|
+
for (const event of events) {
|
231
|
+
window.addEventListener(event, handleEvent);
|
371
232
|
}
|
372
233
|
})();
|
373
234
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
235
|
+
class FirefoxComDataRangeTransport extends _pdf.PDFDataRangeTransport {
|
236
|
+
requestDataRange(begin, end) {
|
237
|
+
FirefoxCom.request("requestDataRange", {
|
238
|
+
begin,
|
239
|
+
end
|
240
|
+
});
|
241
|
+
}
|
379
242
|
|
380
|
-
|
243
|
+
abort() {
|
244
|
+
FirefoxCom.requestSync("abortLoading", null);
|
381
245
|
}
|
382
246
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
});
|
390
|
-
}
|
391
|
-
}, {
|
392
|
-
key: 'abort',
|
393
|
-
value: function abort() {
|
394
|
-
FirefoxCom.requestSync('abortLoading', null);
|
395
|
-
}
|
396
|
-
}]);
|
247
|
+
}
|
248
|
+
|
249
|
+
class FirefoxExternalServices extends _app.DefaultExternalServices {
|
250
|
+
static updateFindControlState(data) {
|
251
|
+
FirefoxCom.request("updateFindControlState", data);
|
252
|
+
}
|
397
253
|
|
398
|
-
|
399
|
-
|
254
|
+
static updateFindMatchesCount(data) {
|
255
|
+
FirefoxCom.request("updateFindMatchesCount", data);
|
256
|
+
}
|
400
257
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
},
|
405
|
-
updateFindMatchesCount: function updateFindMatchesCount(data) {
|
406
|
-
FirefoxCom.request('updateFindMatchesCount', data);
|
407
|
-
},
|
408
|
-
initPassiveLoading: function initPassiveLoading(callbacks) {
|
409
|
-
var pdfDataRangeTransport = void 0;
|
410
|
-
window.addEventListener('message', function windowMessage(e) {
|
258
|
+
static initPassiveLoading(callbacks) {
|
259
|
+
let pdfDataRangeTransport;
|
260
|
+
window.addEventListener("message", function windowMessage(e) {
|
411
261
|
if (e.source !== null) {
|
412
|
-
console.warn(
|
262
|
+
console.warn("Rejected untrusted message from " + e.origin);
|
413
263
|
return;
|
414
264
|
}
|
415
|
-
|
416
|
-
|
265
|
+
|
266
|
+
const args = e.data;
|
267
|
+
|
268
|
+
if (typeof args !== "object" || !("pdfjsLoadAction" in args)) {
|
417
269
|
return;
|
418
270
|
}
|
271
|
+
|
419
272
|
switch (args.pdfjsLoadAction) {
|
420
|
-
case
|
421
|
-
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data);
|
273
|
+
case "supportsRangedLoading":
|
274
|
+
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
|
422
275
|
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
|
423
276
|
break;
|
424
|
-
|
277
|
+
|
278
|
+
case "range":
|
425
279
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
426
280
|
break;
|
427
|
-
|
281
|
+
|
282
|
+
case "rangeProgress":
|
428
283
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
429
284
|
break;
|
430
|
-
|
285
|
+
|
286
|
+
case "progressiveRead":
|
431
287
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
288
|
+
pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
|
289
|
+
break;
|
290
|
+
|
291
|
+
case "progressiveDone":
|
292
|
+
if (pdfDataRangeTransport) {
|
293
|
+
pdfDataRangeTransport.onDataProgressiveDone();
|
294
|
+
}
|
295
|
+
|
432
296
|
break;
|
433
|
-
|
297
|
+
|
298
|
+
case "progress":
|
434
299
|
callbacks.onProgress(args.loaded, args.total);
|
435
300
|
break;
|
436
|
-
|
301
|
+
|
302
|
+
case "complete":
|
437
303
|
if (!args.data) {
|
438
304
|
callbacks.onError(args.errorCode);
|
439
305
|
break;
|
440
306
|
}
|
307
|
+
|
441
308
|
callbacks.onOpenWithData(args.data);
|
442
309
|
break;
|
443
310
|
}
|
444
311
|
});
|
445
|
-
FirefoxCom.requestSync(
|
446
|
-
}
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
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) {
|
454
324
|
return new DownloadManager(options);
|
455
|
-
}
|
456
|
-
|
325
|
+
}
|
326
|
+
|
327
|
+
static createPreferences() {
|
457
328
|
return new FirefoxPreferences();
|
458
|
-
}
|
459
|
-
|
460
|
-
|
329
|
+
}
|
330
|
+
|
331
|
+
static createL10n(options) {
|
332
|
+
const mozL10n = document.mozL10n;
|
461
333
|
return new MozL10n(mozL10n);
|
462
|
-
}
|
334
|
+
}
|
463
335
|
|
464
|
-
get supportsIntegratedFind() {
|
465
|
-
|
466
|
-
return (0, _pdf.shadow)(this,
|
467
|
-
}
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
478
|
-
return (0, _pdf.shadow)(this, 'supportedMouseWheelZoomModifierKeys', support);
|
336
|
+
static get supportsIntegratedFind() {
|
337
|
+
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
338
|
+
return (0, _pdf.shadow)(this, "supportsIntegratedFind", support);
|
339
|
+
}
|
340
|
+
|
341
|
+
static get supportsDocumentFonts() {
|
342
|
+
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
343
|
+
return (0, _pdf.shadow)(this, "supportsDocumentFonts", support);
|
344
|
+
}
|
345
|
+
|
346
|
+
static get supportedMouseWheelZoomModifierKeys() {
|
347
|
+
const support = FirefoxCom.requestSync("supportedMouseWheelZoomModifierKeys");
|
348
|
+
return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", support);
|
479
349
|
}
|
480
|
-
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
_app.PDFViewerApplication.externalServices = FirefoxExternalServices;
|
481
354
|
document.mozL10n.setExternalLocalizerServices({
|
482
|
-
getLocale
|
483
|
-
return FirefoxCom.requestSync(
|
355
|
+
getLocale() {
|
356
|
+
return FirefoxCom.requestSync("getLocale", null);
|
484
357
|
},
|
485
|
-
|
486
|
-
|
358
|
+
|
359
|
+
getStrings(key) {
|
360
|
+
return FirefoxCom.requestSync("getStrings", key);
|
487
361
|
}
|
488
|
-
|
489
|
-
|
490
|
-
exports.FirefoxCom = FirefoxCom;
|
362
|
+
|
363
|
+
});
|