pdfjs-dist 2.3.200 → 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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +6499 -17971
- 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 +19303 -29896
- 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 +1333 -4839
- 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 +683 -1066
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +196 -193
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +441 -569
- package/lib/core/cmap.js +220 -279
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +59 -80
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +564 -673
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +983 -889
- package/lib/core/font_renderer.js +128 -171
- package/lib/core/fonts.js +451 -400
- package/lib/core/function.js +289 -285
- package/lib/core/glyphlist.js +4527 -4527
- package/lib/core/image.js +138 -117
- package/lib/core/image_utils.js +46 -63
- package/lib/core/jbig2.js +324 -332
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +133 -24
- package/lib/core/jpg.js +238 -210
- package/lib/core/jpx.js +158 -157
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1111 -1302
- package/lib/core/operator_list.js +55 -42
- package/lib/core/parser.js +956 -987
- package/lib/core/pattern.js +69 -69
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +45 -77
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +83 -77
- package/lib/core/type1_parser.js +78 -68
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +148 -196
- package/lib/core/worker_stream.js +101 -210
- package/lib/display/annotation_layer.js +733 -1155
- package/lib/display/api.js +1539 -1928
- package/lib/display/api_compatibility.js +10 -8
- package/lib/display/canvas.js +159 -158
- package/lib/display/content_disposition.js +36 -55
- package/lib/display/display_utils.js +298 -551
- package/lib/display/fetch_stream.js +181 -305
- package/lib/display/font_loader.js +273 -416
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +376 -511
- package/lib/display/network_utils.js +20 -19
- package/lib/display/node_stream.js +276 -460
- package/lib/display/pattern_helper.js +76 -44
- package/lib/display/svg.js +1137 -1405
- package/lib/display/text_layer.js +75 -82
- package/lib/display/transport_stream.js +236 -374
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +22 -21
- package/lib/pdf.worker.js +5 -5
- package/lib/shared/compatibility.js +2 -251
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +222 -194
- package/lib/shared/util.js +269 -405
- package/lib/test/unit/annotation_spec.js +1089 -1014
- package/lib/test/unit/api_spec.js +617 -544
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +63 -62
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +84 -86
- package/lib/test/unit/colorspace_spec.js +154 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +22 -24
- package/lib/test/unit/display_svg_spec.js +35 -36
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +16 -16
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +81 -95
- package/lib/test/unit/fetch_stream_spec.js +30 -30
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +172 -162
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +12 -12
- package/lib/test/unit/network_utils_spec.js +152 -152
- package/lib/test/unit/node_stream_spec.js +74 -90
- package/lib/test/unit/parser_spec.js +107 -113
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +117 -115
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +119 -285
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +41 -41
- package/lib/test/unit/ui_utils_spec.js +318 -426
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +122 -143
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1166 -1196
- package/lib/web/app_options.js +61 -77
- package/lib/web/base_viewer.js +804 -850
- package/lib/web/chromecom.js +164 -249
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +38 -57
- package/lib/web/firefox_print_service.js +35 -30
- package/lib/web/firefoxcom.js +175 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -258
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +105 -130
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +227 -376
- package/lib/web/pdf_find_bar.js +137 -171
- package/lib/web/pdf_find_controller.js +492 -549
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +395 -406
- package/lib/web/pdf_link_service.js +302 -349
- package/lib/web/pdf_outline_viewer.js +148 -209
- package/lib/web/pdf_page_view.js +449 -507
- package/lib/web/pdf_presentation_mode.js +304 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +264 -304
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +66 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -317
- package/lib/web/toolbar.js +216 -211
- package/lib/web/ui_utils.js +303 -404
- package/lib/web/view_history.js +49 -222
- package/lib/web/viewer_compatibility.js +7 -5
- package/package.json +2 -9
- package/web/pdf_viewer.css +25 -18
- package/web/pdf_viewer.js +3481 -4764
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/lib/shared/streams_polyfill.js +0 -43
@@ -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.
|
@@ -21,21 +21,21 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _stream = require("../../core/stream");
|
24
|
+
var _stream = require("../../core/stream.js");
|
25
25
|
|
26
|
-
var _primitives = require("../../core/primitives");
|
26
|
+
var _primitives = require("../../core/primitives.js");
|
27
27
|
|
28
|
-
describe(
|
28
|
+
describe("stream", function () {
|
29
29
|
beforeEach(function () {
|
30
30
|
jasmine.addMatchers({
|
31
|
-
toMatchTypedArray
|
31
|
+
toMatchTypedArray(util, customEqualityTesters) {
|
32
32
|
return {
|
33
|
-
compare
|
33
|
+
compare(actual, expected) {
|
34
34
|
var result = {};
|
35
35
|
|
36
36
|
if (actual.length !== expected.length) {
|
37
37
|
result.pass = false;
|
38
|
-
result.message =
|
38
|
+
result.message = "Array length: " + actual.length + ", expected: " + expected.length;
|
39
39
|
return result;
|
40
40
|
}
|
41
41
|
|
@@ -53,23 +53,25 @@ describe('stream', function () {
|
|
53
53
|
|
54
54
|
return result;
|
55
55
|
}
|
56
|
+
|
56
57
|
};
|
57
58
|
}
|
59
|
+
|
58
60
|
});
|
59
61
|
});
|
60
|
-
describe(
|
61
|
-
it(
|
62
|
+
describe("PredictorStream", function () {
|
63
|
+
it("should decode simple predictor data", function () {
|
62
64
|
var dict = new _primitives.Dict();
|
63
|
-
dict.set(
|
64
|
-
dict.set(
|
65
|
-
dict.set(
|
66
|
-
dict.set(
|
65
|
+
dict.set("Predictor", 12);
|
66
|
+
dict.set("Colors", 1);
|
67
|
+
dict.set("BitsPerComponent", 8);
|
68
|
+
dict.set("Columns", 2);
|
67
69
|
var input = new _stream.Stream(new Uint8Array([2, 100, 3, 2, 1, 255, 2, 1, 255]), 0, 9, dict);
|
68
70
|
var predictor = new _stream.PredictorStream(input, 9, dict);
|
69
71
|
var result = predictor.getBytes(6);
|
70
72
|
expect(result).toMatchTypedArray(new Uint8Array([100, 3, 101, 2, 102, 1]));
|
71
73
|
predictor.reset();
|
72
|
-
|
74
|
+
const clampedResult = predictor.getBytes(6, true);
|
73
75
|
expect(clampedResult).toEqual(new Uint8ClampedArray([100, 3, 101, 2, 102, 1]));
|
74
76
|
});
|
75
77
|
});
|
@@ -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.
|
@@ -28,356 +28,190 @@ exports.buildGetDocumentParams = buildGetDocumentParams;
|
|
28
28
|
exports.createIdFactory = createIdFactory;
|
29
29
|
exports.TEST_PDFS_PATH = exports.XRefMock = exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = exports.NodeFileReaderFactory = exports.DOMFileReaderFactory = void 0;
|
30
30
|
|
31
|
-
var
|
31
|
+
var _util = require("../../shared/util.js");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _is_node = require("../../shared/is_node.js");
|
34
34
|
|
35
|
-
var
|
35
|
+
var _primitives = require("../../core/primitives.js");
|
36
36
|
|
37
|
-
var
|
37
|
+
var _document = require("../../core/document.js");
|
38
38
|
|
39
|
-
|
39
|
+
class DOMFileReaderFactory {
|
40
|
+
static async fetch(params) {
|
41
|
+
const response = await fetch(params.path);
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
48
|
-
|
49
|
-
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); } }
|
50
|
-
|
51
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
43
|
+
if (!response.ok) {
|
44
|
+
throw new Error(response.statusText);
|
45
|
+
}
|
52
46
|
|
53
|
-
|
54
|
-
/*#__PURE__*/
|
55
|
-
function () {
|
56
|
-
function DOMFileReaderFactory() {
|
57
|
-
_classCallCheck(this, DOMFileReaderFactory);
|
47
|
+
return new Uint8Array((await response.arrayBuffer()));
|
58
48
|
}
|
59
49
|
|
60
|
-
|
61
|
-
key: "fetch",
|
62
|
-
value: function (_fetch) {
|
63
|
-
function fetch(_x) {
|
64
|
-
return _fetch.apply(this, arguments);
|
65
|
-
}
|
66
|
-
|
67
|
-
fetch.toString = function () {
|
68
|
-
return _fetch.toString();
|
69
|
-
};
|
70
|
-
|
71
|
-
return fetch;
|
72
|
-
}(
|
73
|
-
/*#__PURE__*/
|
74
|
-
function () {
|
75
|
-
var _ref = _asyncToGenerator(
|
76
|
-
/*#__PURE__*/
|
77
|
-
_regenerator["default"].mark(function _callee(params) {
|
78
|
-
var response;
|
79
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
80
|
-
while (1) {
|
81
|
-
switch (_context.prev = _context.next) {
|
82
|
-
case 0:
|
83
|
-
_context.next = 2;
|
84
|
-
return fetch(params.path);
|
85
|
-
|
86
|
-
case 2:
|
87
|
-
response = _context.sent;
|
88
|
-
|
89
|
-
if (response.ok) {
|
90
|
-
_context.next = 5;
|
91
|
-
break;
|
92
|
-
}
|
93
|
-
|
94
|
-
throw new Error(response.statusText);
|
95
|
-
|
96
|
-
case 5:
|
97
|
-
_context.t0 = Uint8Array;
|
98
|
-
_context.next = 8;
|
99
|
-
return response.arrayBuffer();
|
100
|
-
|
101
|
-
case 8:
|
102
|
-
_context.t1 = _context.sent;
|
103
|
-
return _context.abrupt("return", new _context.t0(_context.t1));
|
104
|
-
|
105
|
-
case 10:
|
106
|
-
case "end":
|
107
|
-
return _context.stop();
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}, _callee);
|
111
|
-
}));
|
112
|
-
|
113
|
-
return function (_x2) {
|
114
|
-
return _ref.apply(this, arguments);
|
115
|
-
};
|
116
|
-
}())
|
117
|
-
}]);
|
118
|
-
|
119
|
-
return DOMFileReaderFactory;
|
120
|
-
}();
|
50
|
+
}
|
121
51
|
|
122
52
|
exports.DOMFileReaderFactory = DOMFileReaderFactory;
|
123
53
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
function NodeFileReaderFactory() {
|
128
|
-
_classCallCheck(this, NodeFileReaderFactory);
|
129
|
-
}
|
54
|
+
class NodeFileReaderFactory {
|
55
|
+
static async fetch(params) {
|
56
|
+
const fs = require("fs");
|
130
57
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
var fs;
|
138
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
139
|
-
while (1) {
|
140
|
-
switch (_context2.prev = _context2.next) {
|
141
|
-
case 0:
|
142
|
-
fs = require('fs');
|
143
|
-
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
144
|
-
fs.readFile(params.path, function (error, data) {
|
145
|
-
if (error || !data) {
|
146
|
-
reject(error || new Error("Empty file for: ".concat(params.path)));
|
147
|
-
return;
|
148
|
-
}
|
149
|
-
|
150
|
-
resolve(new Uint8Array(data));
|
151
|
-
});
|
152
|
-
}));
|
153
|
-
|
154
|
-
case 2:
|
155
|
-
case "end":
|
156
|
-
return _context2.stop();
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}, _callee2);
|
160
|
-
}));
|
161
|
-
|
162
|
-
function fetch(_x3) {
|
163
|
-
return _fetch2.apply(this, arguments);
|
164
|
-
}
|
58
|
+
return new Promise((resolve, reject) => {
|
59
|
+
fs.readFile(params.path, (error, data) => {
|
60
|
+
if (error || !data) {
|
61
|
+
reject(error || new Error(`Empty file for: ${params.path}`));
|
62
|
+
return;
|
63
|
+
}
|
165
64
|
|
166
|
-
|
167
|
-
|
168
|
-
|
65
|
+
resolve(new Uint8Array(data));
|
66
|
+
});
|
67
|
+
});
|
68
|
+
}
|
169
69
|
|
170
|
-
|
171
|
-
}();
|
70
|
+
}
|
172
71
|
|
173
72
|
exports.NodeFileReaderFactory = NodeFileReaderFactory;
|
174
|
-
|
175
|
-
dom:
|
176
|
-
node:
|
73
|
+
const TEST_PDFS_PATH = {
|
74
|
+
dom: "../pdfs/",
|
75
|
+
node: "./test/pdfs/"
|
177
76
|
};
|
178
77
|
exports.TEST_PDFS_PATH = TEST_PDFS_PATH;
|
179
78
|
|
180
79
|
function buildGetDocumentParams(filename, options) {
|
181
|
-
|
80
|
+
const params = Object.create(null);
|
182
81
|
|
183
|
-
if (
|
82
|
+
if (_is_node.isNodeJS) {
|
184
83
|
params.url = TEST_PDFS_PATH.node + filename;
|
185
84
|
} else {
|
186
85
|
params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
|
187
86
|
}
|
188
87
|
|
189
|
-
for (
|
88
|
+
for (const option in options) {
|
190
89
|
params[option] = options[option];
|
191
90
|
}
|
192
91
|
|
193
92
|
return params;
|
194
93
|
}
|
195
94
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
function NodeCanvasFactory() {
|
200
|
-
_classCallCheck(this, NodeCanvasFactory);
|
201
|
-
}
|
202
|
-
|
203
|
-
_createClass(NodeCanvasFactory, [{
|
204
|
-
key: "create",
|
205
|
-
value: function create(width, height) {
|
206
|
-
(0, _util.assert)(width > 0 && height > 0, 'Invalid canvas size');
|
95
|
+
class NodeCanvasFactory {
|
96
|
+
create(width, height) {
|
97
|
+
(0, _util.assert)(width > 0 && height > 0, "Invalid canvas size");
|
207
98
|
|
208
|
-
|
99
|
+
const Canvas = require("canvas");
|
209
100
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
}, {
|
217
|
-
key: "reset",
|
218
|
-
value: function reset(canvasAndContext, width, height) {
|
219
|
-
(0, _util.assert)(canvasAndContext.canvas, 'Canvas is not specified');
|
220
|
-
(0, _util.assert)(width > 0 && height > 0, 'Invalid canvas size');
|
221
|
-
canvasAndContext.canvas.width = width;
|
222
|
-
canvasAndContext.canvas.height = height;
|
223
|
-
}
|
224
|
-
}, {
|
225
|
-
key: "destroy",
|
226
|
-
value: function destroy(canvasAndContext) {
|
227
|
-
(0, _util.assert)(canvasAndContext.canvas, 'Canvas is not specified');
|
228
|
-
canvasAndContext.canvas.width = 0;
|
229
|
-
canvasAndContext.canvas.height = 0;
|
230
|
-
canvasAndContext.canvas = null;
|
231
|
-
canvasAndContext.context = null;
|
232
|
-
}
|
233
|
-
}]);
|
101
|
+
const canvas = Canvas.createCanvas(width, height);
|
102
|
+
return {
|
103
|
+
canvas,
|
104
|
+
context: canvas.getContext("2d")
|
105
|
+
};
|
106
|
+
}
|
234
107
|
|
235
|
-
|
236
|
-
|
108
|
+
reset(canvasAndContext, width, height) {
|
109
|
+
(0, _util.assert)(canvasAndContext.canvas, "Canvas is not specified");
|
110
|
+
(0, _util.assert)(width > 0 && height > 0, "Invalid canvas size");
|
111
|
+
canvasAndContext.canvas.width = width;
|
112
|
+
canvasAndContext.canvas.height = height;
|
113
|
+
}
|
237
114
|
|
238
|
-
|
115
|
+
destroy(canvasAndContext) {
|
116
|
+
(0, _util.assert)(canvasAndContext.canvas, "Canvas is not specified");
|
117
|
+
canvasAndContext.canvas.width = 0;
|
118
|
+
canvasAndContext.canvas.height = 0;
|
119
|
+
canvasAndContext.canvas = null;
|
120
|
+
canvasAndContext.context = null;
|
121
|
+
}
|
239
122
|
|
240
|
-
|
241
|
-
/*#__PURE__*/
|
242
|
-
function () {
|
243
|
-
function NodeCMapReaderFactory(_ref2) {
|
244
|
-
var _ref2$baseUrl = _ref2.baseUrl,
|
245
|
-
baseUrl = _ref2$baseUrl === void 0 ? null : _ref2$baseUrl,
|
246
|
-
_ref2$isCompressed = _ref2.isCompressed,
|
247
|
-
isCompressed = _ref2$isCompressed === void 0 ? false : _ref2$isCompressed;
|
123
|
+
}
|
248
124
|
|
249
|
-
|
125
|
+
exports.NodeCanvasFactory = NodeCanvasFactory;
|
250
126
|
|
127
|
+
class NodeCMapReaderFactory {
|
128
|
+
constructor({
|
129
|
+
baseUrl = null,
|
130
|
+
isCompressed = false
|
131
|
+
}) {
|
251
132
|
this.baseUrl = baseUrl;
|
252
133
|
this.isCompressed = isCompressed;
|
253
134
|
}
|
254
135
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
var _this = this;
|
262
|
-
|
263
|
-
var name, url, compressionType;
|
264
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
265
|
-
while (1) {
|
266
|
-
switch (_context3.prev = _context3.next) {
|
267
|
-
case 0:
|
268
|
-
name = _ref3.name;
|
269
|
-
|
270
|
-
if (this.baseUrl) {
|
271
|
-
_context3.next = 3;
|
272
|
-
break;
|
273
|
-
}
|
274
|
-
|
275
|
-
throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
|
276
|
-
|
277
|
-
case 3:
|
278
|
-
if (name) {
|
279
|
-
_context3.next = 5;
|
280
|
-
break;
|
281
|
-
}
|
282
|
-
|
283
|
-
throw new Error('CMap name must be specified.');
|
284
|
-
|
285
|
-
case 5:
|
286
|
-
url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
|
287
|
-
compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
|
288
|
-
return _context3.abrupt("return", new Promise(function (resolve, reject) {
|
289
|
-
var fs = require('fs');
|
290
|
-
|
291
|
-
fs.readFile(url, function (error, data) {
|
292
|
-
if (error || !data) {
|
293
|
-
reject(new Error(error));
|
294
|
-
return;
|
295
|
-
}
|
296
|
-
|
297
|
-
resolve({
|
298
|
-
cMapData: new Uint8Array(data),
|
299
|
-
compressionType: compressionType
|
300
|
-
});
|
301
|
-
});
|
302
|
-
})["catch"](function (reason) {
|
303
|
-
throw new Error("Unable to load ".concat(_this.isCompressed ? 'binary ' : '') + "CMap at: ".concat(url));
|
304
|
-
}));
|
305
|
-
|
306
|
-
case 8:
|
307
|
-
case "end":
|
308
|
-
return _context3.stop();
|
309
|
-
}
|
310
|
-
}
|
311
|
-
}, _callee3, this);
|
312
|
-
}));
|
313
|
-
|
314
|
-
function fetch(_x4) {
|
315
|
-
return _fetch3.apply(this, arguments);
|
316
|
-
}
|
136
|
+
async fetch({
|
137
|
+
name
|
138
|
+
}) {
|
139
|
+
if (!this.baseUrl) {
|
140
|
+
throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
|
141
|
+
}
|
317
142
|
|
318
|
-
|
319
|
-
|
320
|
-
|
143
|
+
if (!name) {
|
144
|
+
throw new Error("CMap name must be specified.");
|
145
|
+
}
|
321
146
|
|
322
|
-
|
323
|
-
|
147
|
+
const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
|
148
|
+
const compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
|
149
|
+
return new Promise((resolve, reject) => {
|
150
|
+
const fs = require("fs");
|
151
|
+
|
152
|
+
fs.readFile(url, (error, data) => {
|
153
|
+
if (error || !data) {
|
154
|
+
reject(new Error(error));
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
|
158
|
+
resolve({
|
159
|
+
cMapData: new Uint8Array(data),
|
160
|
+
compressionType
|
161
|
+
});
|
162
|
+
});
|
163
|
+
}).catch(reason => {
|
164
|
+
throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}` + `CMap at: ${url}`);
|
165
|
+
});
|
166
|
+
}
|
324
167
|
|
325
|
-
|
168
|
+
}
|
326
169
|
|
327
|
-
|
328
|
-
/*#__PURE__*/
|
329
|
-
function () {
|
330
|
-
function XRefMock(array) {
|
331
|
-
_classCallCheck(this, XRefMock);
|
170
|
+
exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
|
332
171
|
|
172
|
+
class XRefMock {
|
173
|
+
constructor(array) {
|
333
174
|
this._map = Object.create(null);
|
334
175
|
|
335
|
-
for (
|
336
|
-
|
176
|
+
for (const key in array) {
|
177
|
+
const obj = array[key];
|
337
178
|
this._map[obj.ref.toString()] = obj.data;
|
338
179
|
}
|
339
180
|
}
|
340
181
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
return this._map[ref.toString()];
|
345
|
-
}
|
346
|
-
}, {
|
347
|
-
key: "fetchAsync",
|
348
|
-
value: function fetchAsync(ref) {
|
349
|
-
return Promise.resolve(this.fetch(ref));
|
350
|
-
}
|
351
|
-
}, {
|
352
|
-
key: "fetchIfRef",
|
353
|
-
value: function fetchIfRef(obj) {
|
354
|
-
if (!(0, _primitives.isRef)(obj)) {
|
355
|
-
return obj;
|
356
|
-
}
|
182
|
+
fetch(ref) {
|
183
|
+
return this._map[ref.toString()];
|
184
|
+
}
|
357
185
|
|
358
|
-
|
359
|
-
|
360
|
-
}
|
361
|
-
|
362
|
-
|
363
|
-
|
186
|
+
fetchAsync(ref) {
|
187
|
+
return Promise.resolve(this.fetch(ref));
|
188
|
+
}
|
189
|
+
|
190
|
+
fetchIfRef(obj) {
|
191
|
+
if (!(0, _primitives.isRef)(obj)) {
|
192
|
+
return obj;
|
364
193
|
}
|
365
|
-
}]);
|
366
194
|
|
367
|
-
|
368
|
-
}
|
195
|
+
return this.fetch(obj);
|
196
|
+
}
|
197
|
+
|
198
|
+
fetchIfRefAsync(obj) {
|
199
|
+
return Promise.resolve(this.fetchIfRef(obj));
|
200
|
+
}
|
201
|
+
|
202
|
+
}
|
369
203
|
|
370
204
|
exports.XRefMock = XRefMock;
|
371
205
|
|
372
206
|
function createIdFactory(pageIndex) {
|
373
|
-
|
207
|
+
const page = new _document.Page({
|
374
208
|
pdfManager: {
|
375
209
|
get docId() {
|
376
|
-
return
|
210
|
+
return "d0";
|
377
211
|
}
|
378
212
|
|
379
213
|
},
|
380
|
-
pageIndex
|
214
|
+
pageIndex
|
381
215
|
});
|
382
216
|
return page.idFactory;
|
383
217
|
}
|
@@ -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,13 +19,13 @@
|
|
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
|
-
var TestReporter = function
|
24
|
+
var TestReporter = function (browser, appPath) {
|
25
25
|
function send(action, json, cb) {
|
26
26
|
var r = new XMLHttpRequest();
|
27
|
-
r.open(
|
28
|
-
r.setRequestHeader(
|
27
|
+
r.open("POST", action, true);
|
28
|
+
r.setRequestHeader("Content-Type", "application/json");
|
29
29
|
|
30
30
|
r.onreadystatechange = function sendTaskResultOnreadystatechange(e) {
|
31
31
|
if (r.readyState === 4) {
|
@@ -39,31 +39,31 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
39
39
|
}
|
40
40
|
};
|
41
41
|
|
42
|
-
json[
|
42
|
+
json["browser"] = browser;
|
43
43
|
r.send(JSON.stringify(json));
|
44
44
|
}
|
45
45
|
|
46
46
|
function sendInfo(message) {
|
47
|
-
send(
|
48
|
-
message
|
47
|
+
send("/info", {
|
48
|
+
message
|
49
49
|
});
|
50
50
|
}
|
51
51
|
|
52
52
|
function sendResult(status, description, error) {
|
53
53
|
var message = {
|
54
|
-
status
|
55
|
-
description
|
54
|
+
status,
|
55
|
+
description
|
56
56
|
};
|
57
57
|
|
58
|
-
if (typeof error !==
|
59
|
-
message[
|
58
|
+
if (typeof error !== "undefined") {
|
59
|
+
message["error"] = error;
|
60
60
|
}
|
61
61
|
|
62
|
-
send(
|
62
|
+
send("/submit_task_results", message);
|
63
63
|
}
|
64
64
|
|
65
65
|
function sendQuitRequest() {
|
66
|
-
send(
|
66
|
+
send("/tellMeToQuit?path=" + escape(appPath), {});
|
67
67
|
}
|
68
68
|
|
69
69
|
this.now = function () {
|
@@ -72,7 +72,7 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
72
72
|
|
73
73
|
this.jasmineStarted = function (suiteInfo) {
|
74
74
|
this.runnerStartTime = this.now();
|
75
|
-
sendInfo(
|
75
|
+
sendInfo("Started tests for " + browser + ".");
|
76
76
|
};
|
77
77
|
|
78
78
|
this.suiteStarted = function (result) {};
|
@@ -81,16 +81,16 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
81
81
|
|
82
82
|
this.specDone = function (result) {
|
83
83
|
if (result.failedExpectations.length === 0) {
|
84
|
-
sendResult(
|
84
|
+
sendResult("TEST-PASSED", result.description);
|
85
85
|
} else {
|
86
|
-
var failedMessages =
|
86
|
+
var failedMessages = "";
|
87
87
|
var items = result.failedExpectations;
|
88
88
|
|
89
89
|
for (var i = 0, ii = items.length; i < ii; i++) {
|
90
|
-
failedMessages += items[i].message +
|
90
|
+
failedMessages += items[i].message + " ";
|
91
91
|
}
|
92
92
|
|
93
|
-
sendResult(
|
93
|
+
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
94
94
|
}
|
95
95
|
};
|
96
96
|
|