pdfjs-dist 2.0.487 → 2.1.266
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/bower.json +1 -1
- package/build/pdf.js +15564 -9476
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +46644 -36309
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11430 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +406 -131
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +376 -53
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +387 -149
- package/lib/core/cmap.js +310 -75
- package/lib/core/colorspace.js +874 -594
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +545 -260
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +725 -147
- package/lib/core/font_renderer.js +360 -91
- package/lib/core/fonts.js +791 -186
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +3 -2
- package/lib/core/image.js +168 -61
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +252 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +4 -4
- package/lib/core/murmurhash3.js +24 -6
- package/lib/core/obj.js +1137 -475
- package/lib/core/operator_list.js +108 -6
- package/lib/core/parser.js +321 -68
- package/lib/core/pattern.js +145 -13
- package/lib/core/pdf_manager.js +321 -133
- package/lib/core/primitives.js +75 -22
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +10 -10
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +31 -4
- package/lib/core/worker.js +210 -66
- package/lib/display/annotation_layer.js +361 -123
- package/lib/display/api.js +1454 -729
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +324 -29
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/dom_utils.js +226 -41
- package/lib/display/fetch_stream.js +208 -84
- package/lib/display/font_loader.js +465 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +216 -51
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +352 -169
- package/lib/display/pattern_helper.js +58 -7
- package/lib/display/svg.js +242 -29
- package/lib/display/text_layer.js +132 -18
- package/lib/display/transport_stream.js +171 -42
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +57 -4
- package/lib/pdf.js +21 -4
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +295 -650
- package/lib/test/unit/annotation_spec.js +629 -345
- package/lib/test/unit/api_spec.js +555 -253
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +40 -11
- package/lib/test/unit/clitests_helper.js +9 -7
- package/lib/test/unit/cmap_spec.js +80 -26
- package/lib/test/unit/colorspace_spec.js +99 -52
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +41 -53
- package/lib/test/unit/display_svg_spec.js +33 -17
- package/lib/test/unit/document_spec.js +3 -3
- package/lib/test/unit/dom_utils_spec.js +9 -9
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +34 -9
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +31 -18
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +20 -5
- package/lib/test/unit/network_utils_spec.js +41 -14
- package/lib/test/unit/node_stream_spec.js +51 -27
- package/lib/test/unit/parser_spec.js +35 -8
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +24 -4
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +90 -27
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +8 -6
- package/lib/test/unit/ui_utils_spec.js +452 -14
- package/lib/test/unit/unicode_spec.js +14 -11
- package/lib/test/unit/util_spec.js +131 -9
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1240 -582
- package/lib/web/app_options.js +71 -41
- package/lib/web/base_viewer.js +508 -179
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -13
- package/lib/web/firefox_print_service.js +17 -9
- package/lib/web/firefoxcom.js +283 -79
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +26 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +21 -13
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +80 -30
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +137 -76
- package/lib/web/pdf_outline_viewer.js +73 -22
- package/lib/web/pdf_page_view.js +196 -63
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +57 -11
- package/lib/web/pdf_rendering_queue.js +27 -5
- package/lib/web/pdf_sidebar.js +120 -67
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +103 -32
- package/lib/web/pdf_thumbnail_viewer.js +64 -24
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +275 -80
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +162 -65
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +58 -1
- package/web/pdf_viewer.js +6346 -3919
- package/web/pdf_viewer.js.map +1 -1
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
@@ -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 2018 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,18 +19,18 @@
|
|
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.FirefoxPrintService =
|
27
|
+
exports.FirefoxPrintService = FirefoxPrintService;
|
28
28
|
|
29
|
-
var _ui_utils = require(
|
29
|
+
var _ui_utils = require("./ui_utils");
|
30
30
|
|
31
|
-
var _app = require(
|
31
|
+
var _app = require("./app");
|
32
32
|
|
33
|
-
var _pdf = require(
|
33
|
+
var _pdf = require("../pdf");
|
34
34
|
|
35
35
|
function composePage(pdfDocument, pageNumber, size, printContainer) {
|
36
36
|
var canvas = document.createElement('canvas');
|
@@ -43,6 +43,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
43
43
|
var canvasWrapper = document.createElement('div');
|
44
44
|
canvasWrapper.appendChild(canvas);
|
45
45
|
printContainer.appendChild(canvasWrapper);
|
46
|
+
|
46
47
|
canvas.mozPrintCallback = function (obj) {
|
47
48
|
var ctx = obj.context;
|
48
49
|
ctx.save();
|
@@ -53,7 +54,10 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
53
54
|
var renderContext = {
|
54
55
|
canvasContext: ctx,
|
55
56
|
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
|
56
|
-
viewport: pdfPage.getViewport(
|
57
|
+
viewport: pdfPage.getViewport({
|
58
|
+
scale: 1,
|
59
|
+
rotation: size.rotation
|
60
|
+
}),
|
57
61
|
intent: 'print'
|
58
62
|
};
|
59
63
|
return pdfPage.render(renderContext).promise;
|
@@ -61,6 +65,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
61
65
|
obj.done();
|
62
66
|
}, function (error) {
|
63
67
|
console.error(error);
|
68
|
+
|
64
69
|
if ('abort' in obj) {
|
65
70
|
obj.abort();
|
66
71
|
} else {
|
@@ -69,17 +74,20 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
69
74
|
});
|
70
75
|
};
|
71
76
|
}
|
77
|
+
|
72
78
|
function FirefoxPrintService(pdfDocument, pagesOverview, printContainer) {
|
73
79
|
this.pdfDocument = pdfDocument;
|
74
80
|
this.pagesOverview = pagesOverview;
|
75
81
|
this.printContainer = printContainer;
|
76
82
|
}
|
83
|
+
|
77
84
|
FirefoxPrintService.prototype = {
|
78
85
|
layout: function layout() {
|
79
86
|
var pdfDocument = this.pdfDocument;
|
80
87
|
var printContainer = this.printContainer;
|
81
88
|
var body = document.querySelector('body');
|
82
89
|
body.setAttribute('data-pdfjsprinting', true);
|
90
|
+
|
83
91
|
for (var i = 0, ii = this.pagesOverview.length; i < ii; ++i) {
|
84
92
|
composePage(pdfDocument, i + 1, this.pagesOverview[i], printContainer);
|
85
93
|
}
|
@@ -94,8 +102,8 @@ _app.PDFPrintServiceFactory.instance = {
|
|
94
102
|
var value = 'mozPrintCallback' in canvas;
|
95
103
|
return (0, _pdf.shadow)(this, 'supportsPrinting', value);
|
96
104
|
},
|
105
|
+
|
97
106
|
createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer) {
|
98
107
|
return new FirefoxPrintService(pdfDocument, pagesOverview, printContainer);
|
99
108
|
}
|
100
|
-
};
|
101
|
-
exports.FirefoxPrintService = FirefoxPrintService;
|
109
|
+
};
|
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 2018 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,34 +19,51 @@
|
|
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
|
-
var
|
29
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
30
30
|
|
31
|
-
|
31
|
+
require("../extensions/firefox/tools/l10n");
|
32
32
|
|
33
|
-
require(
|
33
|
+
var _pdf = require("../pdf");
|
34
34
|
|
35
|
-
var
|
35
|
+
var _preferences = require("./preferences");
|
36
36
|
|
37
|
-
var
|
37
|
+
var _app = require("./app");
|
38
38
|
|
39
|
-
|
39
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
40
40
|
|
41
|
-
function
|
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
42
|
|
43
|
-
function
|
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); }
|
44
56
|
|
45
57
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
46
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; }
|
62
|
+
|
47
63
|
{
|
48
64
|
throw new Error('Module "pdfjs-web/firefoxcom" shall not be used outside ' + 'FIREFOX and MOZCENTRAL builds.');
|
49
65
|
}
|
66
|
+
|
50
67
|
var FirefoxCom = function FirefoxComClosure() {
|
51
68
|
return {
|
52
69
|
requestSync: function requestSync(action, data) {
|
@@ -65,6 +82,7 @@ var FirefoxCom = function FirefoxComClosure() {
|
|
65
82
|
},
|
66
83
|
request: function request(action, data, callback) {
|
67
84
|
var request = document.createTextNode('');
|
85
|
+
|
68
86
|
if (callback) {
|
69
87
|
document.addEventListener('pdf.js.response', function listener(event) {
|
70
88
|
var node = event.target;
|
@@ -74,6 +92,7 @@ var FirefoxCom = function FirefoxComClosure() {
|
|
74
92
|
return callback(response);
|
75
93
|
});
|
76
94
|
}
|
95
|
+
|
77
96
|
document.documentElement.appendChild(request);
|
78
97
|
var sender = document.createEvent('CustomEvent');
|
79
98
|
sender.initCustomEvent('pdf.js.message', true, false, {
|
@@ -87,7 +106,11 @@ var FirefoxCom = function FirefoxComClosure() {
|
|
87
106
|
};
|
88
107
|
}();
|
89
108
|
|
90
|
-
|
109
|
+
exports.FirefoxCom = FirefoxCom;
|
110
|
+
|
111
|
+
var DownloadManager =
|
112
|
+
/*#__PURE__*/
|
113
|
+
function () {
|
91
114
|
function DownloadManager(options) {
|
92
115
|
_classCallCheck(this, DownloadManager);
|
93
116
|
|
@@ -95,7 +118,7 @@ var DownloadManager = function () {
|
|
95
118
|
}
|
96
119
|
|
97
120
|
_createClass(DownloadManager, [{
|
98
|
-
key:
|
121
|
+
key: "downloadUrl",
|
99
122
|
value: function downloadUrl(url, filename) {
|
100
123
|
FirefoxCom.request('download', {
|
101
124
|
originalUrl: url,
|
@@ -103,7 +126,7 @@ var DownloadManager = function () {
|
|
103
126
|
});
|
104
127
|
}
|
105
128
|
}, {
|
106
|
-
key:
|
129
|
+
key: "downloadData",
|
107
130
|
value: function downloadData(data, filename, contentType) {
|
108
131
|
var blobUrl = (0, _pdf.createObjectURL)(data, contentType);
|
109
132
|
FirefoxCom.request('download', {
|
@@ -114,17 +137,20 @@ var DownloadManager = function () {
|
|
114
137
|
});
|
115
138
|
}
|
116
139
|
}, {
|
117
|
-
key:
|
140
|
+
key: "download",
|
118
141
|
value: function download(blob, url, filename) {
|
119
142
|
var _this = this;
|
120
143
|
|
121
|
-
var blobUrl = URL.createObjectURL(blob);
|
144
|
+
var blobUrl = _pdf.URL.createObjectURL(blob);
|
145
|
+
|
122
146
|
var onResponse = function onResponse(err) {
|
123
147
|
if (err && _this.onerror) {
|
124
148
|
_this.onerror(err);
|
125
149
|
}
|
126
|
-
|
150
|
+
|
151
|
+
_pdf.URL.revokeObjectURL(blobUrl);
|
127
152
|
};
|
153
|
+
|
128
154
|
FirefoxCom.request('download', {
|
129
155
|
blobUrl: blobUrl,
|
130
156
|
originalUrl: url,
|
@@ -136,38 +162,86 @@ var DownloadManager = function () {
|
|
136
162
|
return DownloadManager;
|
137
163
|
}();
|
138
164
|
|
139
|
-
|
165
|
+
exports.DownloadManager = DownloadManager;
|
166
|
+
|
167
|
+
var FirefoxPreferences =
|
168
|
+
/*#__PURE__*/
|
169
|
+
function (_BasePreferences) {
|
140
170
|
_inherits(FirefoxPreferences, _BasePreferences);
|
141
171
|
|
142
172
|
function FirefoxPreferences() {
|
143
173
|
_classCallCheck(this, FirefoxPreferences);
|
144
174
|
|
145
|
-
return _possibleConstructorReturn(this, (FirefoxPreferences
|
175
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(FirefoxPreferences).apply(this, arguments));
|
146
176
|
}
|
147
177
|
|
148
178
|
_createClass(FirefoxPreferences, [{
|
149
|
-
key:
|
150
|
-
value: function
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
179
|
+
key: "_writeToStorage",
|
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
|
+
}));
|
199
|
+
|
200
|
+
function _writeToStorage(_x) {
|
201
|
+
return _writeToStorage2.apply(this, arguments);
|
202
|
+
}
|
203
|
+
|
204
|
+
return _writeToStorage;
|
205
|
+
}()
|
155
206
|
}, {
|
156
|
-
key:
|
157
|
-
value: function
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
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
|
+
}
|
234
|
+
|
235
|
+
return _readFromStorage;
|
236
|
+
}()
|
165
237
|
}]);
|
166
238
|
|
167
239
|
return FirefoxPreferences;
|
168
240
|
}(_preferences.BasePreferences);
|
169
241
|
|
170
|
-
var MozL10n =
|
242
|
+
var MozL10n =
|
243
|
+
/*#__PURE__*/
|
244
|
+
function () {
|
171
245
|
function MozL10n(mozL10n) {
|
172
246
|
_classCallCheck(this, MozL10n);
|
173
247
|
|
@@ -175,101 +249,229 @@ var MozL10n = function () {
|
|
175
249
|
}
|
176
250
|
|
177
251
|
_createClass(MozL10n, [{
|
178
|
-
key:
|
179
|
-
value: function
|
180
|
-
|
181
|
-
|
252
|
+
key: "getLanguage",
|
253
|
+
value: function () {
|
254
|
+
var _getLanguage = _asyncToGenerator(
|
255
|
+
/*#__PURE__*/
|
256
|
+
_regenerator.default.mark(function _callee3() {
|
257
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
258
|
+
while (1) {
|
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
|
+
}()
|
182
277
|
}, {
|
183
|
-
key:
|
184
|
-
value: function
|
185
|
-
|
186
|
-
|
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
|
+
}));
|
296
|
+
|
297
|
+
function getDirection() {
|
298
|
+
return _getDirection.apply(this, arguments);
|
299
|
+
}
|
300
|
+
|
301
|
+
return getDirection;
|
302
|
+
}()
|
187
303
|
}, {
|
188
|
-
key:
|
189
|
-
value: function
|
190
|
-
|
191
|
-
|
304
|
+
key: "get",
|
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
|
+
}));
|
322
|
+
|
323
|
+
function get(_x3, _x4, _x5) {
|
324
|
+
return _get.apply(this, arguments);
|
325
|
+
}
|
326
|
+
|
327
|
+
return get;
|
328
|
+
}()
|
192
329
|
}, {
|
193
|
-
key:
|
194
|
-
value: function
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
+
}));
|
348
|
+
|
349
|
+
function translate(_x6) {
|
350
|
+
return _translate.apply(this, arguments);
|
351
|
+
}
|
352
|
+
|
353
|
+
return translate;
|
354
|
+
}()
|
198
355
|
}]);
|
199
356
|
|
200
357
|
return MozL10n;
|
201
358
|
}();
|
202
359
|
|
203
360
|
(function listenFindEvents() {
|
204
|
-
var events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange'];
|
205
|
-
|
361
|
+
var events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange', 'findentirewordchange', 'findbarclose'];
|
362
|
+
|
363
|
+
var handleEvent = function handleEvent(_ref) {
|
364
|
+
var type = _ref.type,
|
365
|
+
detail = _ref.detail;
|
366
|
+
|
206
367
|
if (!_app.PDFViewerApplication.initialized) {
|
207
368
|
return;
|
208
369
|
}
|
370
|
+
|
371
|
+
if (type === 'findbarclose') {
|
372
|
+
_app.PDFViewerApplication.eventBus.dispatch('findbarclose', {
|
373
|
+
source: window
|
374
|
+
});
|
375
|
+
|
376
|
+
return;
|
377
|
+
}
|
378
|
+
|
209
379
|
_app.PDFViewerApplication.eventBus.dispatch('find', {
|
210
380
|
source: window,
|
211
|
-
type:
|
212
|
-
query:
|
381
|
+
type: type.substring('find'.length),
|
382
|
+
query: detail.query,
|
213
383
|
phraseSearch: true,
|
214
|
-
caseSensitive: !!
|
215
|
-
|
216
|
-
|
384
|
+
caseSensitive: !!detail.caseSensitive,
|
385
|
+
entireWord: !!detail.entireWord,
|
386
|
+
highlightAll: !!detail.highlightAll,
|
387
|
+
findPrevious: !!detail.findPrevious
|
217
388
|
});
|
218
389
|
};
|
219
|
-
|
220
|
-
|
390
|
+
|
391
|
+
for (var _i = 0; _i < events.length; _i++) {
|
392
|
+
var event = events[_i];
|
393
|
+
window.addEventListener(event, handleEvent);
|
221
394
|
}
|
222
395
|
})();
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
FirefoxComDataRangeTransport
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
396
|
+
|
397
|
+
var FirefoxComDataRangeTransport =
|
398
|
+
/*#__PURE__*/
|
399
|
+
function (_PDFDataRangeTranspor) {
|
400
|
+
_inherits(FirefoxComDataRangeTransport, _PDFDataRangeTranspor);
|
401
|
+
|
402
|
+
function FirefoxComDataRangeTransport() {
|
403
|
+
_classCallCheck(this, FirefoxComDataRangeTransport);
|
404
|
+
|
405
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(FirefoxComDataRangeTransport).apply(this, arguments));
|
406
|
+
}
|
407
|
+
|
408
|
+
_createClass(FirefoxComDataRangeTransport, [{
|
409
|
+
key: "requestDataRange",
|
410
|
+
value: function requestDataRange(begin, end) {
|
411
|
+
FirefoxCom.request('requestDataRange', {
|
412
|
+
begin: begin,
|
413
|
+
end: end
|
414
|
+
});
|
415
|
+
}
|
416
|
+
}, {
|
417
|
+
key: "abort",
|
418
|
+
value: function abort() {
|
419
|
+
FirefoxCom.requestSync('abortLoading', null);
|
420
|
+
}
|
421
|
+
}]);
|
422
|
+
|
423
|
+
return FirefoxComDataRangeTransport;
|
424
|
+
}(_pdf.PDFDataRangeTransport);
|
425
|
+
|
236
426
|
_app.PDFViewerApplication.externalServices = {
|
237
427
|
updateFindControlState: function updateFindControlState(data) {
|
238
428
|
FirefoxCom.request('updateFindControlState', data);
|
239
429
|
},
|
430
|
+
updateFindMatchesCount: function updateFindMatchesCount(data) {
|
431
|
+
FirefoxCom.request('updateFindMatchesCount', data);
|
432
|
+
},
|
240
433
|
initPassiveLoading: function initPassiveLoading(callbacks) {
|
241
|
-
var pdfDataRangeTransport
|
434
|
+
var pdfDataRangeTransport;
|
242
435
|
window.addEventListener('message', function windowMessage(e) {
|
243
436
|
if (e.source !== null) {
|
244
437
|
console.warn('Rejected untrusted message from ' + e.origin);
|
245
438
|
return;
|
246
439
|
}
|
440
|
+
|
247
441
|
var args = e.data;
|
248
|
-
|
442
|
+
|
443
|
+
if (_typeof(args) !== 'object' || !('pdfjsLoadAction' in args)) {
|
249
444
|
return;
|
250
445
|
}
|
446
|
+
|
251
447
|
switch (args.pdfjsLoadAction) {
|
252
448
|
case 'supportsRangedLoading':
|
253
449
|
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data);
|
254
450
|
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
|
255
451
|
break;
|
452
|
+
|
256
453
|
case 'range':
|
257
454
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
258
455
|
break;
|
456
|
+
|
259
457
|
case 'rangeProgress':
|
260
458
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
261
459
|
break;
|
460
|
+
|
262
461
|
case 'progressiveRead':
|
263
462
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
264
463
|
break;
|
464
|
+
|
265
465
|
case 'progress':
|
266
466
|
callbacks.onProgress(args.loaded, args.total);
|
267
467
|
break;
|
468
|
+
|
268
469
|
case 'complete':
|
269
470
|
if (!args.data) {
|
270
471
|
callbacks.onError(args.errorCode);
|
271
472
|
break;
|
272
473
|
}
|
474
|
+
|
273
475
|
callbacks.onOpenWithData(args.data);
|
274
476
|
break;
|
275
477
|
}
|
@@ -297,18 +499,22 @@ _app.PDFViewerApplication.externalServices = {
|
|
297
499
|
var support = FirefoxCom.requestSync('supportsIntegratedFind');
|
298
500
|
return (0, _pdf.shadow)(this, 'supportsIntegratedFind', support);
|
299
501
|
},
|
502
|
+
|
300
503
|
get supportsDocumentFonts() {
|
301
504
|
var support = FirefoxCom.requestSync('supportsDocumentFonts');
|
302
505
|
return (0, _pdf.shadow)(this, 'supportsDocumentFonts', support);
|
303
506
|
},
|
507
|
+
|
304
508
|
get supportsDocumentColors() {
|
305
509
|
var support = FirefoxCom.requestSync('supportsDocumentColors');
|
306
510
|
return (0, _pdf.shadow)(this, 'supportsDocumentColors', support);
|
307
511
|
},
|
512
|
+
|
308
513
|
get supportedMouseWheelZoomModifierKeys() {
|
309
514
|
var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
310
515
|
return (0, _pdf.shadow)(this, 'supportedMouseWheelZoomModifierKeys', support);
|
311
516
|
}
|
517
|
+
|
312
518
|
};
|
313
519
|
document.mozL10n.setExternalLocalizerServices({
|
314
520
|
getLocale: function getLocale() {
|
@@ -317,6 +523,4 @@ document.mozL10n.setExternalLocalizerServices({
|
|
317
523
|
getStrings: function getStrings(key) {
|
318
524
|
return FirefoxCom.requestSync('getStrings', key);
|
319
525
|
}
|
320
|
-
});
|
321
|
-
exports.DownloadManager = DownloadManager;
|
322
|
-
exports.FirefoxCom = FirefoxCom;
|
526
|
+
});
|