pdfjs-dist 2.2.228 → 2.6.347
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 +8816 -19300
- 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 +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -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/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- 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 +1144 -927
- 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 +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- 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 +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- 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 +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- 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 +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- 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 +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -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 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- 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 +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
@@ -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.
|
@@ -26,358 +26,145 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.buildGetDocumentParams = buildGetDocumentParams;
|
28
28
|
exports.createIdFactory = createIdFactory;
|
29
|
-
exports.
|
29
|
+
exports.isEmptyObj = isEmptyObj;
|
30
|
+
exports.TEST_PDFS_PATH = exports.XRefMock = exports.NodeFileReaderFactory = exports.DOMFileReaderFactory = void 0;
|
30
31
|
|
31
|
-
var
|
32
|
+
var _primitives = require("../../core/primitives.js");
|
32
33
|
|
33
|
-
var
|
34
|
+
var _document = require("../../core/document.js");
|
34
35
|
|
35
|
-
var
|
36
|
+
var _util = require("../../shared/util.js");
|
36
37
|
|
37
|
-
var
|
38
|
+
var _is_node = require("../../shared/is_node.js");
|
38
39
|
|
39
|
-
var
|
40
|
+
var _stream = require("../../core/stream.js");
|
40
41
|
|
41
|
-
|
42
|
+
class DOMFileReaderFactory {
|
43
|
+
static async fetch(params) {
|
44
|
+
const response = await fetch(params.path);
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
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; }
|
46
|
+
if (!response.ok) {
|
47
|
+
throw new Error(response.statusText);
|
48
|
+
}
|
52
49
|
|
53
|
-
|
54
|
-
/*#__PURE__*/
|
55
|
-
function () {
|
56
|
-
function DOMFileReaderFactory() {
|
57
|
-
_classCallCheck(this, DOMFileReaderFactory);
|
50
|
+
return new Uint8Array(await response.arrayBuffer());
|
58
51
|
}
|
59
52
|
|
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
|
-
}();
|
53
|
+
}
|
121
54
|
|
122
55
|
exports.DOMFileReaderFactory = DOMFileReaderFactory;
|
123
56
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
57
|
+
class NodeFileReaderFactory {
|
58
|
+
static async fetch(params) {
|
59
|
+
const fs = require("fs");
|
60
|
+
|
61
|
+
return new Promise((resolve, reject) => {
|
62
|
+
fs.readFile(params.path, (error, data) => {
|
63
|
+
if (error || !data) {
|
64
|
+
reject(error || new Error(`Empty file for: ${params.path}`));
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
resolve(new Uint8Array(data));
|
69
|
+
});
|
70
|
+
});
|
129
71
|
}
|
130
72
|
|
131
|
-
|
132
|
-
key: "fetch",
|
133
|
-
value: function () {
|
134
|
-
var _fetch2 = _asyncToGenerator(
|
135
|
-
/*#__PURE__*/
|
136
|
-
_regenerator["default"].mark(function _callee2(params) {
|
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
|
-
}
|
165
|
-
|
166
|
-
return fetch;
|
167
|
-
}()
|
168
|
-
}]);
|
169
|
-
|
170
|
-
return NodeFileReaderFactory;
|
171
|
-
}();
|
73
|
+
}
|
172
74
|
|
173
75
|
exports.NodeFileReaderFactory = NodeFileReaderFactory;
|
174
|
-
|
175
|
-
dom:
|
176
|
-
node:
|
76
|
+
const TEST_PDFS_PATH = {
|
77
|
+
dom: "../pdfs/",
|
78
|
+
node: "./test/pdfs/"
|
177
79
|
};
|
178
80
|
exports.TEST_PDFS_PATH = TEST_PDFS_PATH;
|
179
81
|
|
180
82
|
function buildGetDocumentParams(filename, options) {
|
181
|
-
|
83
|
+
const params = Object.create(null);
|
182
84
|
|
183
|
-
if (
|
85
|
+
if (_is_node.isNodeJS) {
|
184
86
|
params.url = TEST_PDFS_PATH.node + filename;
|
185
87
|
} else {
|
186
88
|
params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
|
187
89
|
}
|
188
90
|
|
189
|
-
for (
|
91
|
+
for (const option in options) {
|
190
92
|
params[option] = options[option];
|
191
93
|
}
|
192
94
|
|
193
95
|
return params;
|
194
96
|
}
|
195
97
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
98
|
+
class XRefMock {
|
99
|
+
constructor(array) {
|
100
|
+
this._map = Object.create(null);
|
101
|
+
this.stats = {
|
102
|
+
streamTypes: Object.create(null),
|
103
|
+
fontTypes: Object.create(null)
|
104
|
+
};
|
105
|
+
this._newRefNum = null;
|
106
|
+
|
107
|
+
for (const key in array) {
|
108
|
+
const obj = array[key];
|
109
|
+
this._map[obj.ref.toString()] = obj.data;
|
110
|
+
}
|
201
111
|
}
|
202
112
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
(0, _util.assert)(width > 0 && height > 0, 'Invalid canvas size');
|
207
|
-
|
208
|
-
var Canvas = require('canvas');
|
209
|
-
|
210
|
-
var canvas = Canvas.createCanvas(width, height);
|
211
|
-
return {
|
212
|
-
canvas: canvas,
|
213
|
-
context: canvas.getContext('2d')
|
214
|
-
};
|
113
|
+
getNewRef() {
|
114
|
+
if (this._newRefNum === null) {
|
115
|
+
this._newRefNum = Object.keys(this._map).length;
|
215
116
|
}
|
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
|
-
}]);
|
234
|
-
|
235
|
-
return NodeCanvasFactory;
|
236
|
-
}();
|
237
|
-
|
238
|
-
exports.NodeCanvasFactory = NodeCanvasFactory;
|
239
117
|
|
240
|
-
|
241
|
-
|
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;
|
248
|
-
|
249
|
-
_classCallCheck(this, NodeCMapReaderFactory);
|
118
|
+
return _primitives.Ref.get(this._newRefNum++, 0);
|
119
|
+
}
|
250
120
|
|
251
|
-
|
252
|
-
this.
|
121
|
+
resetNewRef() {
|
122
|
+
this.newRef = null;
|
253
123
|
}
|
254
124
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
var _fetch3 = _asyncToGenerator(
|
259
|
-
/*#__PURE__*/
|
260
|
-
_regenerator["default"].mark(function _callee3(_ref3) {
|
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
|
-
}
|
317
|
-
|
318
|
-
return fetch;
|
319
|
-
}()
|
320
|
-
}]);
|
321
|
-
|
322
|
-
return NodeCMapReaderFactory;
|
323
|
-
}();
|
324
|
-
|
325
|
-
exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
|
326
|
-
|
327
|
-
var XRefMock =
|
328
|
-
/*#__PURE__*/
|
329
|
-
function () {
|
330
|
-
function XRefMock(array) {
|
331
|
-
_classCallCheck(this, XRefMock);
|
125
|
+
fetch(ref) {
|
126
|
+
return this._map[ref.toString()];
|
127
|
+
}
|
332
128
|
|
333
|
-
|
129
|
+
fetchAsync(ref) {
|
130
|
+
return Promise.resolve(this.fetch(ref));
|
131
|
+
}
|
334
132
|
|
335
|
-
|
336
|
-
|
337
|
-
|
133
|
+
fetchIfRef(obj) {
|
134
|
+
if (!(0, _primitives.isRef)(obj)) {
|
135
|
+
return obj;
|
338
136
|
}
|
137
|
+
|
138
|
+
return this.fetch(obj);
|
339
139
|
}
|
340
140
|
|
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
|
-
}
|
357
|
-
|
358
|
-
return this.fetch(obj);
|
359
|
-
}
|
360
|
-
}, {
|
361
|
-
key: "fetchIfRefAsync",
|
362
|
-
value: function fetchIfRefAsync(obj) {
|
363
|
-
return Promise.resolve(this.fetchIfRef(obj));
|
364
|
-
}
|
365
|
-
}]);
|
141
|
+
fetchIfRefAsync(obj) {
|
142
|
+
return Promise.resolve(this.fetchIfRef(obj));
|
143
|
+
}
|
366
144
|
|
367
|
-
|
368
|
-
}();
|
145
|
+
}
|
369
146
|
|
370
147
|
exports.XRefMock = XRefMock;
|
371
148
|
|
372
149
|
function createIdFactory(pageIndex) {
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
150
|
+
const pdfManager = {
|
151
|
+
get docId() {
|
152
|
+
return "d0";
|
153
|
+
}
|
154
|
+
|
155
|
+
};
|
156
|
+
const stream = new _stream.StringStream("Dummy_PDF_data");
|
157
|
+
const pdfDocument = new _document.PDFDocument(pdfManager, stream);
|
158
|
+
const page = new _document.Page({
|
159
|
+
pdfManager: pdfDocument.pdfManager,
|
160
|
+
xref: pdfDocument.xref,
|
161
|
+
pageIndex,
|
162
|
+
globalIdFactory: pdfDocument._globalIdFactory
|
381
163
|
});
|
382
|
-
return page.
|
164
|
+
return page._localIdFactory;
|
165
|
+
}
|
166
|
+
|
167
|
+
function isEmptyObj(obj) {
|
168
|
+
(0, _util.assert)(typeof obj === "object" && obj !== null, "isEmptyObj - invalid argument.");
|
169
|
+
return Object.keys(obj).length === 0;
|
383
170
|
}
|
@@ -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) {
|
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?browser=${escape(browser)}`, {});
|
67
67
|
}
|
68
68
|
|
69
69
|
this.now = function () {
|
@@ -72,25 +72,36 @@ var TestReporter = function TestReporter(browser, appPath) {
|
|
72
72
|
|
73
73
|
this.jasmineStarted = function (suiteInfo) {
|
74
74
|
this.runnerStartTime = this.now();
|
75
|
-
|
75
|
+
const total = suiteInfo.totalSpecsDefined;
|
76
|
+
const seed = suiteInfo.order.seed;
|
77
|
+
sendInfo(`Started ${total} tests for ${browser} with seed ${seed}.`);
|
76
78
|
};
|
77
79
|
|
78
|
-
this.suiteStarted = function (result) {
|
80
|
+
this.suiteStarted = function (result) {
|
81
|
+
if (result.failedExpectations.length > 0) {
|
82
|
+
let failedMessages = "";
|
83
|
+
|
84
|
+
for (const item of result.failedExpectations) {
|
85
|
+
failedMessages += `${item.message} `;
|
86
|
+
}
|
87
|
+
|
88
|
+
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
89
|
+
}
|
90
|
+
};
|
79
91
|
|
80
92
|
this.specStarted = function (result) {};
|
81
93
|
|
82
94
|
this.specDone = function (result) {
|
83
95
|
if (result.failedExpectations.length === 0) {
|
84
|
-
sendResult(
|
96
|
+
sendResult("TEST-PASSED", result.description);
|
85
97
|
} else {
|
86
|
-
|
87
|
-
var items = result.failedExpectations;
|
98
|
+
let failedMessages = "";
|
88
99
|
|
89
|
-
for (
|
90
|
-
failedMessages +=
|
100
|
+
for (const item of result.failedExpectations) {
|
101
|
+
failedMessages += `${item.message} `;
|
91
102
|
}
|
92
103
|
|
93
|
-
sendResult(
|
104
|
+
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
94
105
|
}
|
95
106
|
};
|
96
107
|
|