pdfjs-dist 2.0.489 → 2.2.228
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/bower.json +1 -1
- package/build/pdf.js +18515 -11402
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +48266 -37137
- 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 +11350 -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 +587 -242
- 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 +433 -61
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +400 -152
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +560 -268
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1005 -360
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +812 -195
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +4 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- 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 +253 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +15 -15
- package/lib/core/murmurhash3.js +56 -34
- package/lib/core/obj.js +1354 -488
- package/lib/core/operator_list.js +144 -31
- package/lib/core/parser.js +539 -191
- package/lib/core/pattern.js +148 -14
- package/lib/core/pdf_manager.js +323 -133
- package/lib/core/primitives.js +111 -24
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +217 -190
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +450 -133
- package/lib/display/api.js +1597 -784
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +360 -44
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +221 -90
- package/lib/display/font_loader.js +468 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +635 -428
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +81 -31
- package/lib/display/svg.js +1235 -519
- package/lib/display/text_layer.js +153 -29
- package/lib/display/transport_stream.js +345 -94
- 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 +60 -4
- package/lib/pdf.js +36 -14
- 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 +243 -710
- package/lib/test/unit/annotation_spec.js +870 -401
- package/lib/test/unit/api_spec.js +657 -345
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +54 -11
- package/lib/test/unit/clitests_helper.js +10 -8
- package/lib/test/unit/cmap_spec.js +95 -41
- package/lib/test/unit/colorspace_spec.js +115 -63
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +43 -55
- package/lib/test/unit/display_svg_spec.js +34 -18
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +8 -13
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +38 -15
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- 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 +19 -54
- package/lib/test/unit/network_utils_spec.js +91 -14
- package/lib/test/unit/node_stream_spec.js +56 -32
- package/lib/test/unit/parser_spec.js +162 -71
- 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 +53 -20
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +273 -56
- 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 +454 -16
- package/lib/test/unit/unicode_spec.js +18 -15
- package/lib/test/unit/util_spec.js +87 -128
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1290 -588
- package/lib/web/app_options.js +100 -62
- package/lib/web/base_viewer.js +511 -182
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +32 -13
- package/lib/web/firefox_print_service.js +20 -10
- package/lib/web/firefoxcom.js +315 -80
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +28 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +22 -14
- 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 +255 -136
- 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 +138 -77
- package/lib/web/pdf_outline_viewer.js +122 -46
- package/lib/web/pdf_page_view.js +191 -67
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +61 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +141 -81
- 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 +104 -33
- package/lib/web/pdf_thumbnail_viewer.js +66 -26
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +284 -89
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +134 -59
- 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 +79 -11
- package/web/pdf_viewer.js +6107 -3748
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -309
- package/lib/test/unit/dom_utils_spec.js +0 -89
- 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 2019 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,22 +19,24 @@
|
|
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
|
29
|
+
var _app_options = require("./app_options");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _ui_utils = require("./ui_utils");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _app = require("./app");
|
34
|
+
|
35
|
+
var _pdf = require("../pdf");
|
34
36
|
|
35
37
|
function composePage(pdfDocument, pageNumber, size, printContainer) {
|
36
38
|
var canvas = document.createElement('canvas');
|
37
|
-
var PRINT_RESOLUTION = 150;
|
39
|
+
var PRINT_RESOLUTION = _app_options.AppOptions.get('printResolution') || 150;
|
38
40
|
var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
|
39
41
|
canvas.width = Math.floor(size.width * PRINT_UNITS);
|
40
42
|
canvas.height = Math.floor(size.height * PRINT_UNITS);
|
@@ -43,6 +45,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
43
45
|
var canvasWrapper = document.createElement('div');
|
44
46
|
canvasWrapper.appendChild(canvas);
|
45
47
|
printContainer.appendChild(canvasWrapper);
|
48
|
+
|
46
49
|
canvas.mozPrintCallback = function (obj) {
|
47
50
|
var ctx = obj.context;
|
48
51
|
ctx.save();
|
@@ -53,7 +56,10 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
53
56
|
var renderContext = {
|
54
57
|
canvasContext: ctx,
|
55
58
|
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
|
56
|
-
viewport: pdfPage.getViewport(
|
59
|
+
viewport: pdfPage.getViewport({
|
60
|
+
scale: 1,
|
61
|
+
rotation: size.rotation
|
62
|
+
}),
|
57
63
|
intent: 'print'
|
58
64
|
};
|
59
65
|
return pdfPage.render(renderContext).promise;
|
@@ -61,6 +67,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
61
67
|
obj.done();
|
62
68
|
}, function (error) {
|
63
69
|
console.error(error);
|
70
|
+
|
64
71
|
if ('abort' in obj) {
|
65
72
|
obj.abort();
|
66
73
|
} else {
|
@@ -69,17 +76,20 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|
69
76
|
});
|
70
77
|
};
|
71
78
|
}
|
79
|
+
|
72
80
|
function FirefoxPrintService(pdfDocument, pagesOverview, printContainer) {
|
73
81
|
this.pdfDocument = pdfDocument;
|
74
82
|
this.pagesOverview = pagesOverview;
|
75
83
|
this.printContainer = printContainer;
|
76
84
|
}
|
85
|
+
|
77
86
|
FirefoxPrintService.prototype = {
|
78
87
|
layout: function layout() {
|
79
88
|
var pdfDocument = this.pdfDocument;
|
80
89
|
var printContainer = this.printContainer;
|
81
90
|
var body = document.querySelector('body');
|
82
91
|
body.setAttribute('data-pdfjsprinting', true);
|
92
|
+
|
83
93
|
for (var i = 0, ii = this.pagesOverview.length; i < ii; ++i) {
|
84
94
|
composePage(pdfDocument, i + 1, this.pagesOverview[i], printContainer);
|
85
95
|
}
|
@@ -94,8 +104,8 @@ _app.PDFPrintServiceFactory.instance = {
|
|
94
104
|
var value = 'mozPrintCallback' in canvas;
|
95
105
|
return (0, _pdf.shadow)(this, 'supportsPrinting', value);
|
96
106
|
},
|
107
|
+
|
97
108
|
createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer) {
|
98
109
|
return new FirefoxPrintService(pdfDocument, pagesOverview, printContainer);
|
99
110
|
}
|
100
|
-
};
|
101
|
-
exports.FirefoxPrintService = FirefoxPrintService;
|
111
|
+
};
|
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 2019 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);
|
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);
|
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,260 @@ 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, _events = events; _i < _events.length; _i++) {
|
392
|
+
var event = _events[_i];
|
393
|
+
window.addEventListener(event, handleEvent);
|
221
394
|
}
|
222
395
|
})();
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
396
|
+
|
397
|
+
(function listenZoomEvents() {
|
398
|
+
var events = ['zoomin', 'zoomout', 'zoomreset'];
|
399
|
+
|
400
|
+
var handleEvent = function handleEvent(_ref2) {
|
401
|
+
var type = _ref2.type,
|
402
|
+
detail = _ref2.detail;
|
403
|
+
|
404
|
+
if (!_app.PDFViewerApplication.initialized) {
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
|
408
|
+
_app.PDFViewerApplication.eventBus.dispatch(type, {
|
409
|
+
source: window,
|
410
|
+
ignoreDuplicate: type === 'zoomreset' ? true : undefined
|
411
|
+
});
|
412
|
+
};
|
413
|
+
|
414
|
+
for (var _i2 = 0, _events2 = events; _i2 < _events2.length; _i2++) {
|
415
|
+
var event = _events2[_i2];
|
416
|
+
window.addEventListener(event, handleEvent);
|
417
|
+
}
|
418
|
+
})();
|
419
|
+
|
420
|
+
var FirefoxComDataRangeTransport =
|
421
|
+
/*#__PURE__*/
|
422
|
+
function (_PDFDataRangeTranspor) {
|
423
|
+
_inherits(FirefoxComDataRangeTransport, _PDFDataRangeTranspor);
|
424
|
+
|
425
|
+
function FirefoxComDataRangeTransport() {
|
426
|
+
_classCallCheck(this, FirefoxComDataRangeTransport);
|
427
|
+
|
428
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(FirefoxComDataRangeTransport).apply(this, arguments));
|
429
|
+
}
|
430
|
+
|
431
|
+
_createClass(FirefoxComDataRangeTransport, [{
|
432
|
+
key: "requestDataRange",
|
433
|
+
value: function requestDataRange(begin, end) {
|
434
|
+
FirefoxCom.request('requestDataRange', {
|
435
|
+
begin: begin,
|
436
|
+
end: end
|
437
|
+
});
|
438
|
+
}
|
439
|
+
}, {
|
440
|
+
key: "abort",
|
441
|
+
value: function abort() {
|
442
|
+
FirefoxCom.requestSync('abortLoading', null);
|
443
|
+
}
|
444
|
+
}]);
|
445
|
+
|
446
|
+
return FirefoxComDataRangeTransport;
|
447
|
+
}(_pdf.PDFDataRangeTransport);
|
448
|
+
|
236
449
|
_app.PDFViewerApplication.externalServices = {
|
237
450
|
updateFindControlState: function updateFindControlState(data) {
|
238
451
|
FirefoxCom.request('updateFindControlState', data);
|
239
452
|
},
|
453
|
+
updateFindMatchesCount: function updateFindMatchesCount(data) {
|
454
|
+
FirefoxCom.request('updateFindMatchesCount', data);
|
455
|
+
},
|
240
456
|
initPassiveLoading: function initPassiveLoading(callbacks) {
|
241
|
-
var pdfDataRangeTransport
|
457
|
+
var pdfDataRangeTransport;
|
242
458
|
window.addEventListener('message', function windowMessage(e) {
|
243
459
|
if (e.source !== null) {
|
244
460
|
console.warn('Rejected untrusted message from ' + e.origin);
|
245
461
|
return;
|
246
462
|
}
|
463
|
+
|
247
464
|
var args = e.data;
|
248
|
-
|
465
|
+
|
466
|
+
if (_typeof(args) !== 'object' || !('pdfjsLoadAction' in args)) {
|
249
467
|
return;
|
250
468
|
}
|
469
|
+
|
251
470
|
switch (args.pdfjsLoadAction) {
|
252
471
|
case 'supportsRangedLoading':
|
253
|
-
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data);
|
472
|
+
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
|
254
473
|
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
|
255
474
|
break;
|
475
|
+
|
256
476
|
case 'range':
|
257
477
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
258
478
|
break;
|
479
|
+
|
259
480
|
case 'rangeProgress':
|
260
481
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
261
482
|
break;
|
483
|
+
|
262
484
|
case 'progressiveRead':
|
263
485
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
486
|
+
pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
|
264
487
|
break;
|
488
|
+
|
489
|
+
case 'progressiveDone':
|
490
|
+
if (pdfDataRangeTransport) {
|
491
|
+
pdfDataRangeTransport.onDataProgressiveDone();
|
492
|
+
}
|
493
|
+
|
494
|
+
break;
|
495
|
+
|
265
496
|
case 'progress':
|
266
497
|
callbacks.onProgress(args.loaded, args.total);
|
267
498
|
break;
|
499
|
+
|
268
500
|
case 'complete':
|
269
501
|
if (!args.data) {
|
270
502
|
callbacks.onError(args.errorCode);
|
271
503
|
break;
|
272
504
|
}
|
505
|
+
|
273
506
|
callbacks.onOpenWithData(args.data);
|
274
507
|
break;
|
275
508
|
}
|
@@ -297,18 +530,22 @@ _app.PDFViewerApplication.externalServices = {
|
|
297
530
|
var support = FirefoxCom.requestSync('supportsIntegratedFind');
|
298
531
|
return (0, _pdf.shadow)(this, 'supportsIntegratedFind', support);
|
299
532
|
},
|
533
|
+
|
300
534
|
get supportsDocumentFonts() {
|
301
535
|
var support = FirefoxCom.requestSync('supportsDocumentFonts');
|
302
536
|
return (0, _pdf.shadow)(this, 'supportsDocumentFonts', support);
|
303
537
|
},
|
538
|
+
|
304
539
|
get supportsDocumentColors() {
|
305
540
|
var support = FirefoxCom.requestSync('supportsDocumentColors');
|
306
541
|
return (0, _pdf.shadow)(this, 'supportsDocumentColors', support);
|
307
542
|
},
|
543
|
+
|
308
544
|
get supportedMouseWheelZoomModifierKeys() {
|
309
545
|
var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
310
546
|
return (0, _pdf.shadow)(this, 'supportedMouseWheelZoomModifierKeys', support);
|
311
547
|
}
|
548
|
+
|
312
549
|
};
|
313
550
|
document.mozL10n.setExternalLocalizerServices({
|
314
551
|
getLocale: function getLocale() {
|
@@ -317,6 +554,4 @@ document.mozL10n.setExternalLocalizerServices({
|
|
317
554
|
getStrings: function getStrings(key) {
|
318
555
|
return FirefoxCom.requestSync('getStrings', key);
|
319
556
|
}
|
320
|
-
});
|
321
|
-
exports.DownloadManager = DownloadManager;
|
322
|
-
exports.FirefoxCom = FirefoxCom;
|
557
|
+
});
|