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.

Files changed (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. 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 2019 Mozilla Foundation
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('stream', function () {
28
+ describe("stream", function () {
29
29
  beforeEach(function () {
30
30
  jasmine.addMatchers({
31
- toMatchTypedArray: function toMatchTypedArray(util, customEqualityTesters) {
31
+ toMatchTypedArray(util, customEqualityTesters) {
32
32
  return {
33
- compare: function compare(actual, expected) {
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 = 'Array length: ' + actual.length + ', expected: ' + expected.length;
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('PredictorStream', function () {
61
- it('should decode simple predictor data', function () {
62
+ describe("PredictorStream", function () {
63
+ it("should decode simple predictor data", function () {
62
64
  var dict = new _primitives.Dict();
63
- dict.set('Predictor', 12);
64
- dict.set('Colors', 1);
65
- dict.set('BitsPerComponent', 8);
66
- dict.set('Columns', 2);
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
- var clampedResult = predictor.getBytes(6, true);
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 2019 Mozilla Foundation
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.TEST_PDFS_PATH = exports.XRefMock = exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = exports.NodeFileReaderFactory = exports.DOMFileReaderFactory = void 0;
29
+ exports.isEmptyObj = isEmptyObj;
30
+ exports.TEST_PDFS_PATH = exports.XRefMock = exports.NodeFileReaderFactory = exports.DOMFileReaderFactory = void 0;
30
31
 
31
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
32
+ var _primitives = require("../../core/primitives.js");
32
33
 
33
- var _util = require("../../shared/util");
34
+ var _document = require("../../core/document.js");
34
35
 
35
- var _is_node = _interopRequireDefault(require("../../shared/is_node"));
36
+ var _util = require("../../shared/util.js");
36
37
 
37
- var _primitives = require("../../core/primitives");
38
+ var _is_node = require("../../shared/is_node.js");
38
39
 
39
- var _document = require("../../core/document");
40
+ var _stream = require("../../core/stream.js");
40
41
 
41
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
42
+ class DOMFileReaderFactory {
43
+ static async fetch(params) {
44
+ const response = await fetch(params.path);
42
45
 
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 _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
- var DOMFileReaderFactory =
54
- /*#__PURE__*/
55
- function () {
56
- function DOMFileReaderFactory() {
57
- _classCallCheck(this, DOMFileReaderFactory);
50
+ return new Uint8Array(await response.arrayBuffer());
58
51
  }
59
52
 
60
- _createClass(DOMFileReaderFactory, null, [{
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
- var NodeFileReaderFactory =
125
- /*#__PURE__*/
126
- function () {
127
- function NodeFileReaderFactory() {
128
- _classCallCheck(this, NodeFileReaderFactory);
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
- _createClass(NodeFileReaderFactory, null, [{
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
- var TEST_PDFS_PATH = {
175
- dom: '../pdfs/',
176
- node: './test/pdfs/'
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
- var params = Object.create(null);
83
+ const params = Object.create(null);
182
84
 
183
- if ((0, _is_node["default"])()) {
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 (var option in options) {
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
- var NodeCanvasFactory =
197
- /*#__PURE__*/
198
- function () {
199
- function NodeCanvasFactory() {
200
- _classCallCheck(this, NodeCanvasFactory);
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
- _createClass(NodeCanvasFactory, [{
204
- key: "create",
205
- value: function create(width, height) {
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
- var NodeCMapReaderFactory =
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;
248
-
249
- _classCallCheck(this, NodeCMapReaderFactory);
118
+ return _primitives.Ref.get(this._newRefNum++, 0);
119
+ }
250
120
 
251
- this.baseUrl = baseUrl;
252
- this.isCompressed = isCompressed;
121
+ resetNewRef() {
122
+ this.newRef = null;
253
123
  }
254
124
 
255
- _createClass(NodeCMapReaderFactory, [{
256
- key: "fetch",
257
- value: function () {
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
- this._map = Object.create(null);
129
+ fetchAsync(ref) {
130
+ return Promise.resolve(this.fetch(ref));
131
+ }
334
132
 
335
- for (var key in array) {
336
- var obj = array[key];
337
- this._map[obj.ref.toString()] = obj.data;
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
- _createClass(XRefMock, [{
342
- key: "fetch",
343
- value: function fetch(ref) {
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
- return XRefMock;
368
- }();
145
+ }
369
146
 
370
147
  exports.XRefMock = XRefMock;
371
148
 
372
149
  function createIdFactory(pageIndex) {
373
- var page = new _document.Page({
374
- pdfManager: {
375
- get docId() {
376
- return 'd0';
377
- }
378
-
379
- },
380
- pageIndex: pageIndex
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.idFactory;
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 2019 Mozilla Foundation
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
- 'use strict';
22
+ "use strict";
23
23
 
24
- var TestReporter = function TestReporter(browser, appPath) {
24
+ var TestReporter = function (browser) {
25
25
  function send(action, json, cb) {
26
26
  var r = new XMLHttpRequest();
27
- r.open('POST', action, true);
28
- r.setRequestHeader('Content-Type', 'application/json');
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['browser'] = browser;
42
+ json.browser = browser;
43
43
  r.send(JSON.stringify(json));
44
44
  }
45
45
 
46
46
  function sendInfo(message) {
47
- send('/info', {
48
- message: 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: status,
55
- description: description
54
+ status,
55
+ description
56
56
  };
57
57
 
58
- if (typeof error !== 'undefined') {
59
- message['error'] = error;
58
+ if (typeof error !== "undefined") {
59
+ message.error = error;
60
60
  }
61
61
 
62
- send('/submit_task_results', message);
62
+ send("/submit_task_results", message);
63
63
  }
64
64
 
65
65
  function sendQuitRequest() {
66
- send('/tellMeToQuit?path=' + escape(appPath), {});
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
- sendInfo('Started tests for ' + browser + '.');
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('TEST-PASSED', result.description);
96
+ sendResult("TEST-PASSED", result.description);
85
97
  } else {
86
- var failedMessages = '';
87
- var items = result.failedExpectations;
98
+ let failedMessages = "";
88
99
 
89
- for (var i = 0, ii = items.length; i < ii; i++) {
90
- failedMessages += items[i].message + ' ';
100
+ for (const item of result.failedExpectations) {
101
+ failedMessages += `${item.message} `;
91
102
  }
92
103
 
93
- sendResult('TEST-UNEXPECTED-FAIL', result.description, failedMessages);
104
+ sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
94
105
  }
95
106
  };
96
107