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.

Files changed (185) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +6499 -17971
  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 +19303 -29896
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +25473 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  13. package/es5/build/pdf.worker.js +57878 -0
  14. package/es5/build/pdf.worker.js.map +1 -0
  15. package/es5/web/images/annotation-check.svg +11 -0
  16. package/es5/web/images/annotation-comment.svg +16 -0
  17. package/es5/web/images/annotation-help.svg +26 -0
  18. package/es5/web/images/annotation-insert.svg +10 -0
  19. package/es5/web/images/annotation-key.svg +11 -0
  20. package/es5/web/images/annotation-newparagraph.svg +11 -0
  21. package/es5/web/images/annotation-noicon.svg +7 -0
  22. package/es5/web/images/annotation-note.svg +42 -0
  23. package/es5/web/images/annotation-paragraph.svg +16 -0
  24. package/es5/web/images/loading-icon.gif +0 -0
  25. package/es5/web/images/shadow.png +0 -0
  26. package/es5/web/images/texture.png +0 -0
  27. package/es5/web/pdf_viewer.css +407 -0
  28. package/es5/web/pdf_viewer.js +7757 -0
  29. package/es5/web/pdf_viewer.js.map +1 -0
  30. package/image_decoders/pdf.image_decoders.js +1333 -4839
  31. package/image_decoders/pdf.image_decoders.js.map +1 -1
  32. package/image_decoders/pdf.image_decoders.min.js +22 -1
  33. package/lib/README.md +7 -0
  34. package/lib/core/annotation.js +683 -1066
  35. package/lib/core/arithmetic_decoder.js +81 -97
  36. package/lib/core/bidi.js +54 -46
  37. package/lib/core/ccitt.js +88 -81
  38. package/lib/core/ccitt_stream.js +15 -14
  39. package/lib/core/cff_parser.js +196 -193
  40. package/lib/core/charsets.js +4 -4
  41. package/lib/core/chunked_stream.js +441 -569
  42. package/lib/core/cmap.js +220 -279
  43. package/lib/core/colorspace.js +699 -863
  44. package/lib/core/core_utils.js +59 -80
  45. package/lib/core/crypto.js +379 -437
  46. package/lib/core/document.js +564 -673
  47. package/lib/core/encodings.js +15 -15
  48. package/lib/core/evaluator.js +983 -889
  49. package/lib/core/font_renderer.js +128 -171
  50. package/lib/core/fonts.js +451 -400
  51. package/lib/core/function.js +289 -285
  52. package/lib/core/glyphlist.js +4527 -4527
  53. package/lib/core/image.js +138 -117
  54. package/lib/core/image_utils.js +46 -63
  55. package/lib/core/jbig2.js +324 -332
  56. package/lib/core/jbig2_stream.js +18 -17
  57. package/lib/core/jpeg_stream.js +133 -24
  58. package/lib/core/jpg.js +238 -210
  59. package/lib/core/jpx.js +158 -157
  60. package/lib/core/jpx_stream.js +28 -28
  61. package/lib/core/metrics.js +2928 -2928
  62. package/lib/core/murmurhash3.js +87 -102
  63. package/lib/core/obj.js +1111 -1302
  64. package/lib/core/operator_list.js +55 -42
  65. package/lib/core/parser.js +956 -987
  66. package/lib/core/pattern.js +69 -69
  67. package/lib/core/pdf_manager.js +149 -316
  68. package/lib/core/primitives.js +45 -77
  69. package/lib/core/ps_parser.js +175 -214
  70. package/lib/core/standard_fonts.js +237 -236
  71. package/lib/core/stream.js +83 -77
  72. package/lib/core/type1_parser.js +78 -68
  73. package/lib/core/unicode.js +1654 -1654
  74. package/lib/core/worker.js +148 -196
  75. package/lib/core/worker_stream.js +101 -210
  76. package/lib/display/annotation_layer.js +733 -1155
  77. package/lib/display/api.js +1539 -1928
  78. package/lib/display/api_compatibility.js +10 -8
  79. package/lib/display/canvas.js +159 -158
  80. package/lib/display/content_disposition.js +36 -55
  81. package/lib/display/display_utils.js +298 -551
  82. package/lib/display/fetch_stream.js +181 -305
  83. package/lib/display/font_loader.js +273 -416
  84. package/lib/display/metadata.js +86 -98
  85. package/lib/display/network.js +376 -511
  86. package/lib/display/network_utils.js +20 -19
  87. package/lib/display/node_stream.js +276 -460
  88. package/lib/display/pattern_helper.js +76 -44
  89. package/lib/display/svg.js +1137 -1405
  90. package/lib/display/text_layer.js +75 -82
  91. package/lib/display/transport_stream.js +236 -374
  92. package/lib/display/webgl.js +70 -83
  93. package/lib/display/worker_options.js +3 -3
  94. package/lib/display/xml_parser.js +303 -392
  95. package/lib/examples/node/domstubs.js +37 -37
  96. package/lib/pdf.js +22 -21
  97. package/lib/pdf.worker.js +5 -5
  98. package/lib/shared/compatibility.js +2 -251
  99. package/lib/shared/is_node.js +7 -6
  100. package/lib/shared/message_handler.js +222 -194
  101. package/lib/shared/util.js +269 -405
  102. package/lib/test/unit/annotation_spec.js +1089 -1014
  103. package/lib/test/unit/api_spec.js +617 -544
  104. package/lib/test/unit/bidi_spec.js +7 -7
  105. package/lib/test/unit/cff_parser_spec.js +63 -62
  106. package/lib/test/unit/clitests_helper.js +7 -9
  107. package/lib/test/unit/cmap_spec.js +84 -86
  108. package/lib/test/unit/colorspace_spec.js +154 -154
  109. package/lib/test/unit/core_utils_spec.js +125 -105
  110. package/lib/test/unit/crypto_spec.js +181 -181
  111. package/lib/test/unit/custom_spec.js +22 -24
  112. package/lib/test/unit/display_svg_spec.js +35 -36
  113. package/lib/test/unit/display_utils_spec.js +139 -149
  114. package/lib/test/unit/document_spec.js +16 -16
  115. package/lib/test/unit/encodings_spec.js +12 -34
  116. package/lib/test/unit/evaluator_spec.js +81 -95
  117. package/lib/test/unit/fetch_stream_spec.js +30 -30
  118. package/lib/test/unit/function_spec.js +206 -204
  119. package/lib/test/unit/jasmine-boot.js +48 -32
  120. package/lib/test/unit/message_handler_spec.js +172 -162
  121. package/lib/test/unit/metadata_spec.js +69 -69
  122. package/lib/test/unit/murmurhash3_spec.js +12 -12
  123. package/lib/test/unit/network_spec.js +12 -12
  124. package/lib/test/unit/network_utils_spec.js +152 -152
  125. package/lib/test/unit/node_stream_spec.js +74 -90
  126. package/lib/test/unit/parser_spec.js +107 -113
  127. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  128. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  129. package/lib/test/unit/pdf_history_spec.js +32 -32
  130. package/lib/test/unit/primitives_spec.js +117 -115
  131. package/lib/test/unit/stream_spec.js +16 -14
  132. package/lib/test/unit/test_utils.js +119 -285
  133. package/lib/test/unit/testreporter.js +19 -19
  134. package/lib/test/unit/type1_parser_spec.js +41 -41
  135. package/lib/test/unit/ui_utils_spec.js +318 -426
  136. package/lib/test/unit/unicode_spec.js +42 -42
  137. package/lib/test/unit/util_spec.js +122 -143
  138. package/lib/web/annotation_layer_builder.js +66 -103
  139. package/lib/web/app.js +1166 -1196
  140. package/lib/web/app_options.js +61 -77
  141. package/lib/web/base_viewer.js +804 -850
  142. package/lib/web/chromecom.js +164 -249
  143. package/lib/web/debugger.js +149 -205
  144. package/lib/web/download_manager.js +38 -57
  145. package/lib/web/firefox_print_service.js +35 -30
  146. package/lib/web/firefoxcom.js +175 -374
  147. package/lib/web/genericcom.js +26 -108
  148. package/lib/web/genericl10n.js +24 -153
  149. package/lib/web/grab_to_pan.js +30 -30
  150. package/lib/web/interfaces.js +80 -258
  151. package/lib/web/overlay_manager.js +70 -246
  152. package/lib/web/password_prompt.js +38 -64
  153. package/lib/web/pdf_attachment_viewer.js +105 -130
  154. package/lib/web/pdf_cursor_tools.js +75 -102
  155. package/lib/web/pdf_document_properties.js +227 -376
  156. package/lib/web/pdf_find_bar.js +137 -171
  157. package/lib/web/pdf_find_controller.js +492 -549
  158. package/lib/web/pdf_find_utils.js +13 -13
  159. package/lib/web/pdf_history.js +395 -406
  160. package/lib/web/pdf_link_service.js +302 -349
  161. package/lib/web/pdf_outline_viewer.js +148 -209
  162. package/lib/web/pdf_page_view.js +449 -507
  163. package/lib/web/pdf_presentation_mode.js +304 -357
  164. package/lib/web/pdf_print_service.js +90 -104
  165. package/lib/web/pdf_rendering_queue.js +87 -108
  166. package/lib/web/pdf_sidebar.js +264 -304
  167. package/lib/web/pdf_sidebar_resizer.js +92 -119
  168. package/lib/web/pdf_single_page_viewer.js +77 -126
  169. package/lib/web/pdf_thumbnail_view.js +276 -297
  170. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  171. package/lib/web/pdf_viewer.component.js +20 -21
  172. package/lib/web/pdf_viewer.js +55 -115
  173. package/lib/web/preferences.js +66 -273
  174. package/lib/web/secondary_toolbar.js +164 -196
  175. package/lib/web/text_layer_builder.js +284 -317
  176. package/lib/web/toolbar.js +216 -211
  177. package/lib/web/ui_utils.js +303 -404
  178. package/lib/web/view_history.js +49 -222
  179. package/lib/web/viewer_compatibility.js +7 -5
  180. package/package.json +2 -9
  181. package/web/pdf_viewer.css +25 -18
  182. package/web/pdf_viewer.js +3481 -4764
  183. package/web/pdf_viewer.js.map +1 -1
  184. package/webpack.js +14 -5
  185. 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 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.
@@ -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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
31
+ var _util = require("../../shared/util.js");
32
32
 
33
- var _util = require("../../shared/util");
33
+ var _is_node = require("../../shared/is_node.js");
34
34
 
35
- var _is_node = _interopRequireDefault(require("../../shared/is_node"));
35
+ var _primitives = require("../../core/primitives.js");
36
36
 
37
- var _primitives = require("../../core/primitives");
37
+ var _document = require("../../core/document.js");
38
38
 
39
- var _document = require("../../core/document");
39
+ class DOMFileReaderFactory {
40
+ static async fetch(params) {
41
+ const response = await fetch(params.path);
40
42
 
41
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
42
-
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; }
43
+ if (!response.ok) {
44
+ throw new Error(response.statusText);
45
+ }
52
46
 
53
- var DOMFileReaderFactory =
54
- /*#__PURE__*/
55
- function () {
56
- function DOMFileReaderFactory() {
57
- _classCallCheck(this, DOMFileReaderFactory);
47
+ return new Uint8Array((await response.arrayBuffer()));
58
48
  }
59
49
 
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
- }();
50
+ }
121
51
 
122
52
  exports.DOMFileReaderFactory = DOMFileReaderFactory;
123
53
 
124
- var NodeFileReaderFactory =
125
- /*#__PURE__*/
126
- function () {
127
- function NodeFileReaderFactory() {
128
- _classCallCheck(this, NodeFileReaderFactory);
129
- }
54
+ class NodeFileReaderFactory {
55
+ static async fetch(params) {
56
+ const fs = require("fs");
130
57
 
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
- }
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
- return fetch;
167
- }()
168
- }]);
65
+ resolve(new Uint8Array(data));
66
+ });
67
+ });
68
+ }
169
69
 
170
- return NodeFileReaderFactory;
171
- }();
70
+ }
172
71
 
173
72
  exports.NodeFileReaderFactory = NodeFileReaderFactory;
174
- var TEST_PDFS_PATH = {
175
- dom: '../pdfs/',
176
- node: './test/pdfs/'
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
- var params = Object.create(null);
80
+ const params = Object.create(null);
182
81
 
183
- if ((0, _is_node["default"])()) {
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 (var option in options) {
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
- var NodeCanvasFactory =
197
- /*#__PURE__*/
198
- function () {
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
- var Canvas = require('canvas');
99
+ const Canvas = require("canvas");
209
100
 
210
- var canvas = Canvas.createCanvas(width, height);
211
- return {
212
- canvas: canvas,
213
- context: canvas.getContext('2d')
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
- return NodeCanvasFactory;
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
- exports.NodeCanvasFactory = NodeCanvasFactory;
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
- 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;
123
+ }
248
124
 
249
- _classCallCheck(this, NodeCMapReaderFactory);
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
- _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
- }
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
- return fetch;
319
- }()
320
- }]);
143
+ if (!name) {
144
+ throw new Error("CMap name must be specified.");
145
+ }
321
146
 
322
- return NodeCMapReaderFactory;
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
- exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
168
+ }
326
169
 
327
- var XRefMock =
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 (var key in array) {
336
- var obj = array[key];
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
- _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
- }
182
+ fetch(ref) {
183
+ return this._map[ref.toString()];
184
+ }
357
185
 
358
- return this.fetch(obj);
359
- }
360
- }, {
361
- key: "fetchIfRefAsync",
362
- value: function fetchIfRefAsync(obj) {
363
- return Promise.resolve(this.fetchIfRef(obj));
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
- return XRefMock;
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
- var page = new _document.Page({
207
+ const page = new _document.Page({
374
208
  pdfManager: {
375
209
  get docId() {
376
- return 'd0';
210
+ return "d0";
377
211
  }
378
212
 
379
213
  },
380
- pageIndex: 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 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, appPath) {
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?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('Started tests for ' + browser + '.');
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('TEST-PASSED', result.description);
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('TEST-UNEXPECTED-FAIL', result.description, failedMessages);
93
+ sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
94
94
  }
95
95
  };
96
96