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,17 +19,30 @@
|
|
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.OverlayManager = void 0;
|
27
28
|
|
28
|
-
var
|
29
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
30
|
+
|
31
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
32
|
+
|
33
|
+
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); } }
|
34
|
+
|
35
|
+
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); }); }; }
|
29
36
|
|
30
37
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
31
38
|
|
32
|
-
var
|
39
|
+
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); } }
|
40
|
+
|
41
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
42
|
+
|
43
|
+
var OverlayManager =
|
44
|
+
/*#__PURE__*/
|
45
|
+
function () {
|
33
46
|
function OverlayManager() {
|
34
47
|
_classCallCheck(this, OverlayManager);
|
35
48
|
|
@@ -39,108 +52,245 @@ var OverlayManager = function () {
|
|
39
52
|
}
|
40
53
|
|
41
54
|
_createClass(OverlayManager, [{
|
42
|
-
key:
|
43
|
-
value: function
|
44
|
-
var
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
key: "register",
|
56
|
+
value: function () {
|
57
|
+
var _register = _asyncToGenerator(
|
58
|
+
/*#__PURE__*/
|
59
|
+
_regenerator["default"].mark(function _callee(name, element) {
|
60
|
+
var callerCloseMethod,
|
61
|
+
canForceClose,
|
62
|
+
container,
|
63
|
+
_args = arguments;
|
64
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
65
|
+
while (1) {
|
66
|
+
switch (_context.prev = _context.next) {
|
67
|
+
case 0:
|
68
|
+
callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
|
69
|
+
canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
|
70
|
+
|
71
|
+
if (!(!name || !element || !(container = element.parentNode))) {
|
72
|
+
_context.next = 6;
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
|
76
|
+
throw new Error('Not enough parameters.');
|
77
|
+
|
78
|
+
case 6:
|
79
|
+
if (!this._overlays[name]) {
|
80
|
+
_context.next = 8;
|
81
|
+
break;
|
82
|
+
}
|
83
|
+
|
84
|
+
throw new Error('The overlay is already registered.');
|
85
|
+
|
86
|
+
case 8:
|
87
|
+
this._overlays[name] = {
|
88
|
+
element: element,
|
89
|
+
container: container,
|
90
|
+
callerCloseMethod: callerCloseMethod,
|
91
|
+
canForceClose: canForceClose
|
92
|
+
};
|
93
|
+
|
94
|
+
case 9:
|
95
|
+
case "end":
|
96
|
+
return _context.stop();
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}, _callee, this);
|
100
|
+
}));
|
101
|
+
|
102
|
+
function register(_x, _x2) {
|
103
|
+
return _register.apply(this, arguments);
|
104
|
+
}
|
105
|
+
|
106
|
+
return register;
|
107
|
+
}()
|
65
108
|
}, {
|
66
|
-
key:
|
67
|
-
value: function
|
68
|
-
var
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
109
|
+
key: "unregister",
|
110
|
+
value: function () {
|
111
|
+
var _unregister = _asyncToGenerator(
|
112
|
+
/*#__PURE__*/
|
113
|
+
_regenerator["default"].mark(function _callee2(name) {
|
114
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
115
|
+
while (1) {
|
116
|
+
switch (_context2.prev = _context2.next) {
|
117
|
+
case 0:
|
118
|
+
if (this._overlays[name]) {
|
119
|
+
_context2.next = 4;
|
120
|
+
break;
|
121
|
+
}
|
122
|
+
|
123
|
+
throw new Error('The overlay does not exist.');
|
124
|
+
|
125
|
+
case 4:
|
126
|
+
if (!(this._active === name)) {
|
127
|
+
_context2.next = 6;
|
128
|
+
break;
|
129
|
+
}
|
130
|
+
|
131
|
+
throw new Error('The overlay cannot be removed while it is active.');
|
132
|
+
|
133
|
+
case 6:
|
134
|
+
delete this._overlays[name];
|
135
|
+
|
136
|
+
case 7:
|
137
|
+
case "end":
|
138
|
+
return _context2.stop();
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}, _callee2, this);
|
142
|
+
}));
|
143
|
+
|
144
|
+
function unregister(_x3) {
|
145
|
+
return _unregister.apply(this, arguments);
|
146
|
+
}
|
147
|
+
|
148
|
+
return unregister;
|
149
|
+
}()
|
80
150
|
}, {
|
81
|
-
key:
|
82
|
-
value: function
|
83
|
-
var
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
151
|
+
key: "open",
|
152
|
+
value: function () {
|
153
|
+
var _open = _asyncToGenerator(
|
154
|
+
/*#__PURE__*/
|
155
|
+
_regenerator["default"].mark(function _callee3(name) {
|
156
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
157
|
+
while (1) {
|
158
|
+
switch (_context3.prev = _context3.next) {
|
159
|
+
case 0:
|
160
|
+
if (this._overlays[name]) {
|
161
|
+
_context3.next = 4;
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
|
165
|
+
throw new Error('The overlay does not exist.');
|
166
|
+
|
167
|
+
case 4:
|
168
|
+
if (!this._active) {
|
169
|
+
_context3.next = 14;
|
170
|
+
break;
|
171
|
+
}
|
172
|
+
|
173
|
+
if (!this._overlays[name].canForceClose) {
|
174
|
+
_context3.next = 9;
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
|
178
|
+
this._closeThroughCaller();
|
179
|
+
|
180
|
+
_context3.next = 14;
|
181
|
+
break;
|
182
|
+
|
183
|
+
case 9:
|
184
|
+
if (!(this._active === name)) {
|
185
|
+
_context3.next = 13;
|
186
|
+
break;
|
187
|
+
}
|
188
|
+
|
189
|
+
throw new Error('The overlay is already active.');
|
190
|
+
|
191
|
+
case 13:
|
192
|
+
throw new Error('Another overlay is currently active.');
|
193
|
+
|
194
|
+
case 14:
|
195
|
+
this._active = name;
|
196
|
+
|
197
|
+
this._overlays[this._active].element.classList.remove('hidden');
|
198
|
+
|
199
|
+
this._overlays[this._active].container.classList.remove('hidden');
|
200
|
+
|
201
|
+
window.addEventListener('keydown', this._keyDownBound);
|
202
|
+
|
203
|
+
case 18:
|
204
|
+
case "end":
|
205
|
+
return _context3.stop();
|
206
|
+
}
|
95
207
|
}
|
96
|
-
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
208
|
+
}, _callee3, this);
|
209
|
+
}));
|
210
|
+
|
211
|
+
function open(_x4) {
|
212
|
+
return _open.apply(this, arguments);
|
213
|
+
}
|
214
|
+
|
215
|
+
return open;
|
216
|
+
}()
|
104
217
|
}, {
|
105
|
-
key:
|
106
|
-
value: function
|
107
|
-
var
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
218
|
+
key: "close",
|
219
|
+
value: function () {
|
220
|
+
var _close = _asyncToGenerator(
|
221
|
+
/*#__PURE__*/
|
222
|
+
_regenerator["default"].mark(function _callee4(name) {
|
223
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
224
|
+
while (1) {
|
225
|
+
switch (_context4.prev = _context4.next) {
|
226
|
+
case 0:
|
227
|
+
if (this._overlays[name]) {
|
228
|
+
_context4.next = 4;
|
229
|
+
break;
|
230
|
+
}
|
231
|
+
|
232
|
+
throw new Error('The overlay does not exist.');
|
233
|
+
|
234
|
+
case 4:
|
235
|
+
if (this._active) {
|
236
|
+
_context4.next = 8;
|
237
|
+
break;
|
238
|
+
}
|
239
|
+
|
240
|
+
throw new Error('The overlay is currently not active.');
|
241
|
+
|
242
|
+
case 8:
|
243
|
+
if (!(this._active !== name)) {
|
244
|
+
_context4.next = 10;
|
245
|
+
break;
|
246
|
+
}
|
247
|
+
|
248
|
+
throw new Error('Another overlay is currently active.');
|
249
|
+
|
250
|
+
case 10:
|
251
|
+
this._overlays[this._active].container.classList.add('hidden');
|
252
|
+
|
253
|
+
this._overlays[this._active].element.classList.add('hidden');
|
254
|
+
|
255
|
+
this._active = null;
|
256
|
+
window.removeEventListener('keydown', this._keyDownBound);
|
257
|
+
|
258
|
+
case 14:
|
259
|
+
case "end":
|
260
|
+
return _context4.stop();
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}, _callee4, this);
|
264
|
+
}));
|
265
|
+
|
266
|
+
function close(_x5) {
|
267
|
+
return _close.apply(this, arguments);
|
268
|
+
}
|
269
|
+
|
270
|
+
return close;
|
271
|
+
}()
|
124
272
|
}, {
|
125
|
-
key:
|
273
|
+
key: "_keyDown",
|
126
274
|
value: function _keyDown(evt) {
|
127
275
|
if (this._active && evt.keyCode === 27) {
|
128
276
|
this._closeThroughCaller();
|
277
|
+
|
129
278
|
evt.preventDefault();
|
130
279
|
}
|
131
280
|
}
|
132
281
|
}, {
|
133
|
-
key:
|
282
|
+
key: "_closeThroughCaller",
|
134
283
|
value: function _closeThroughCaller() {
|
135
284
|
if (this._overlays[this._active].callerCloseMethod) {
|
136
285
|
this._overlays[this._active].callerCloseMethod();
|
137
286
|
}
|
287
|
+
|
138
288
|
if (this._active) {
|
139
289
|
this.close(this._active);
|
140
290
|
}
|
141
291
|
}
|
142
292
|
}, {
|
143
|
-
key:
|
293
|
+
key: "active",
|
144
294
|
get: function get() {
|
145
295
|
return this._active;
|
146
296
|
}
|
@@ -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,26 @@
|
|
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.PasswordPrompt =
|
27
|
+
exports.PasswordPrompt = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _ui_utils = require("./ui_utils");
|
30
30
|
|
31
|
-
var
|
32
|
-
|
33
|
-
var _pdf = require('../pdf');
|
31
|
+
var _pdf = require("../pdf");
|
34
32
|
|
35
33
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
36
34
|
|
37
|
-
var
|
35
|
+
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); } }
|
36
|
+
|
37
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
38
|
+
|
39
|
+
var PasswordPrompt =
|
40
|
+
/*#__PURE__*/
|
41
|
+
function () {
|
38
42
|
function PasswordPrompt(options, overlayManager) {
|
39
43
|
var _this = this;
|
40
44
|
|
@@ -63,25 +67,28 @@ var PasswordPrompt = function () {
|
|
63
67
|
}
|
64
68
|
|
65
69
|
_createClass(PasswordPrompt, [{
|
66
|
-
key:
|
70
|
+
key: "open",
|
67
71
|
value: function open() {
|
68
72
|
var _this2 = this;
|
69
73
|
|
70
74
|
this.overlayManager.open(this.overlayName).then(function () {
|
71
75
|
_this2.input.focus();
|
72
|
-
|
76
|
+
|
77
|
+
var promptString;
|
78
|
+
|
73
79
|
if (_this2.reason === _pdf.PasswordResponses.INCORRECT_PASSWORD) {
|
74
80
|
promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
|
75
81
|
} else {
|
76
82
|
promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
|
77
83
|
}
|
84
|
+
|
78
85
|
promptString.then(function (msg) {
|
79
86
|
_this2.label.textContent = msg;
|
80
87
|
});
|
81
88
|
});
|
82
89
|
}
|
83
90
|
}, {
|
84
|
-
key:
|
91
|
+
key: "close",
|
85
92
|
value: function close() {
|
86
93
|
var _this3 = this;
|
87
94
|
|
@@ -90,16 +97,17 @@ var PasswordPrompt = function () {
|
|
90
97
|
});
|
91
98
|
}
|
92
99
|
}, {
|
93
|
-
key:
|
100
|
+
key: "verify",
|
94
101
|
value: function verify() {
|
95
102
|
var password = this.input.value;
|
103
|
+
|
96
104
|
if (password && password.length > 0) {
|
97
105
|
this.close();
|
98
|
-
|
106
|
+
this.updateCallback(password);
|
99
107
|
}
|
100
108
|
}
|
101
109
|
}, {
|
102
|
-
key:
|
110
|
+
key: "setUpdateCallback",
|
103
111
|
value: function setUpdateCallback(updateCallback, reason) {
|
104
112
|
this.updateCallback = updateCallback;
|
105
113
|
this.reason = reason;
|
@@ -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,20 +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.PDFAttachmentViewer =
|
27
|
+
exports.PDFAttachmentViewer = void 0;
|
28
28
|
|
29
|
-
var
|
30
|
-
|
31
|
-
var _pdf = require('../pdf');
|
29
|
+
var _pdf = require("../pdf");
|
32
30
|
|
33
31
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
34
32
|
|
35
|
-
var
|
33
|
+
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); } }
|
34
|
+
|
35
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
36
|
+
|
37
|
+
var PDFAttachmentViewer =
|
38
|
+
/*#__PURE__*/
|
39
|
+
function () {
|
36
40
|
function PDFAttachmentViewer(_ref) {
|
37
41
|
var container = _ref.container,
|
38
42
|
eventBus = _ref.eventBus,
|
@@ -48,72 +52,82 @@ var PDFAttachmentViewer = function () {
|
|
48
52
|
}
|
49
53
|
|
50
54
|
_createClass(PDFAttachmentViewer, [{
|
51
|
-
key:
|
55
|
+
key: "reset",
|
52
56
|
value: function reset() {
|
53
57
|
var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
54
|
-
|
55
58
|
this.attachments = null;
|
56
59
|
this.container.textContent = '';
|
60
|
+
|
57
61
|
if (!keepRenderedCapability) {
|
58
62
|
this._renderedCapability = (0, _pdf.createPromiseCapability)();
|
59
63
|
}
|
60
64
|
}
|
61
65
|
}, {
|
62
|
-
key:
|
66
|
+
key: "_dispatchEvent",
|
63
67
|
value: function _dispatchEvent(attachmentsCount) {
|
64
68
|
this._renderedCapability.resolve();
|
69
|
+
|
65
70
|
this.eventBus.dispatch('attachmentsloaded', {
|
66
71
|
source: this,
|
67
72
|
attachmentsCount: attachmentsCount
|
68
73
|
});
|
69
74
|
}
|
70
75
|
}, {
|
71
|
-
key:
|
76
|
+
key: "_bindPdfLink",
|
72
77
|
value: function _bindPdfLink(button, content, filename) {
|
73
78
|
if (this.downloadManager.disableCreateObjectURL) {
|
74
79
|
throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
|
75
80
|
}
|
76
|
-
|
81
|
+
|
82
|
+
var blobUrl;
|
83
|
+
|
77
84
|
button.onclick = function () {
|
78
85
|
if (!blobUrl) {
|
79
86
|
blobUrl = (0, _pdf.createObjectURL)(content, 'application/pdf');
|
80
87
|
}
|
81
|
-
|
88
|
+
|
89
|
+
var viewerUrl;
|
82
90
|
viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
|
83
91
|
window.open(viewerUrl);
|
84
92
|
return false;
|
85
93
|
};
|
86
94
|
}
|
87
95
|
}, {
|
88
|
-
key:
|
96
|
+
key: "_bindLink",
|
89
97
|
value: function _bindLink(button, content, filename) {
|
90
98
|
var _this = this;
|
91
99
|
|
92
100
|
button.onclick = function () {
|
93
101
|
_this.downloadManager.downloadData(content, filename, '');
|
102
|
+
|
94
103
|
return false;
|
95
104
|
};
|
96
105
|
}
|
97
106
|
}, {
|
98
|
-
key:
|
107
|
+
key: "render",
|
99
108
|
value: function render(_ref2) {
|
100
109
|
var attachments = _ref2.attachments,
|
101
110
|
_ref2$keepRenderedCap = _ref2.keepRenderedCapability,
|
102
|
-
keepRenderedCapability = _ref2$keepRenderedCap ===
|
103
|
-
|
111
|
+
keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
|
104
112
|
var attachmentsCount = 0;
|
113
|
+
|
105
114
|
if (this.attachments) {
|
106
115
|
this.reset(keepRenderedCapability === true);
|
107
116
|
}
|
117
|
+
|
108
118
|
this.attachments = attachments || null;
|
119
|
+
|
109
120
|
if (!attachments) {
|
110
121
|
this._dispatchEvent(attachmentsCount);
|
122
|
+
|
111
123
|
return;
|
112
124
|
}
|
125
|
+
|
113
126
|
var names = Object.keys(attachments).sort(function (a, b) {
|
114
127
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
115
128
|
});
|
116
129
|
attachmentsCount = names.length;
|
130
|
+
|
117
131
|
for (var i = 0; i < attachmentsCount; i++) {
|
118
132
|
var item = attachments[names[i]];
|
119
133
|
var filename = (0, _pdf.removeNullCharacters)((0, _pdf.getFilenameFromUrl)(item.filename));
|
@@ -121,18 +135,21 @@ var PDFAttachmentViewer = function () {
|
|
121
135
|
div.className = 'attachmentsItem';
|
122
136
|
var button = document.createElement('button');
|
123
137
|
button.textContent = filename;
|
138
|
+
|
124
139
|
if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
|
125
140
|
this._bindPdfLink(button, item.content, filename);
|
126
141
|
} else {
|
127
142
|
this._bindLink(button, item.content, filename);
|
128
143
|
}
|
144
|
+
|
129
145
|
div.appendChild(button);
|
130
146
|
this.container.appendChild(div);
|
131
147
|
}
|
148
|
+
|
132
149
|
this._dispatchEvent(attachmentsCount);
|
133
150
|
}
|
134
151
|
}, {
|
135
|
-
key:
|
152
|
+
key: "_appendAttachment",
|
136
153
|
value: function _appendAttachment(_ref3) {
|
137
154
|
var _this2 = this;
|
138
155
|
|
@@ -142,6 +159,7 @@ var PDFAttachmentViewer = function () {
|
|
142
159
|
|
143
160
|
this._renderedCapability.promise.then(function () {
|
144
161
|
var attachments = _this2.attachments;
|
162
|
+
|
145
163
|
if (!attachments) {
|
146
164
|
attachments = Object.create(null);
|
147
165
|
} else {
|
@@ -151,10 +169,12 @@ var PDFAttachmentViewer = function () {
|
|
151
169
|
}
|
152
170
|
}
|
153
171
|
}
|
172
|
+
|
154
173
|
attachments[id] = {
|
155
174
|
filename: filename,
|
156
175
|
content: content
|
157
176
|
};
|
177
|
+
|
158
178
|
_this2.render({
|
159
179
|
attachments: attachments,
|
160
180
|
keepRenderedCapability: true
|