pdfjs-dist 2.0.489 → 2.2.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (169) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +18515 -11402
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +48266 -37137
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/external/url/url-lib.js +627 -0
  10. package/image_decoders/pdf.image_decoders.js +11350 -0
  11. package/image_decoders/pdf.image_decoders.js.map +1 -0
  12. package/image_decoders/pdf.image_decoders.min.js +1 -0
  13. package/lib/core/annotation.js +587 -242
  14. package/lib/core/arithmetic_decoder.js +275 -245
  15. package/lib/core/bidi.js +65 -6
  16. package/lib/core/ccitt.js +173 -18
  17. package/lib/core/ccitt_stream.js +15 -6
  18. package/lib/core/cff_parser.js +433 -61
  19. package/lib/core/charsets.js +5 -4
  20. package/lib/core/chunked_stream.js +400 -152
  21. package/lib/core/cmap.js +326 -87
  22. package/lib/core/colorspace.js +874 -594
  23. package/lib/core/core_utils.js +147 -0
  24. package/lib/core/crypto.js +290 -45
  25. package/lib/core/document.js +560 -268
  26. package/lib/core/encodings.js +19 -10
  27. package/lib/core/evaluator.js +1005 -360
  28. package/lib/core/font_renderer.js +331 -97
  29. package/lib/core/fonts.js +812 -195
  30. package/lib/core/function.js +284 -71
  31. package/lib/core/glyphlist.js +4 -3
  32. package/lib/core/image.js +169 -62
  33. package/lib/core/image_utils.js +111 -0
  34. package/lib/core/jbig2.js +479 -66
  35. package/lib/core/jbig2_stream.js +19 -8
  36. package/lib/core/jpeg_stream.js +38 -13
  37. package/lib/core/jpg.js +253 -29
  38. package/lib/core/jpx.js +396 -6
  39. package/lib/core/jpx_stream.js +18 -6
  40. package/lib/core/metrics.js +15 -15
  41. package/lib/core/murmurhash3.js +56 -34
  42. package/lib/core/obj.js +1354 -488
  43. package/lib/core/operator_list.js +144 -31
  44. package/lib/core/parser.js +539 -191
  45. package/lib/core/pattern.js +148 -14
  46. package/lib/core/pdf_manager.js +323 -133
  47. package/lib/core/primitives.js +111 -24
  48. package/lib/core/ps_parser.js +134 -45
  49. package/lib/core/standard_fonts.js +17 -17
  50. package/lib/core/stream.js +313 -34
  51. package/lib/core/type1_parser.js +143 -13
  52. package/lib/core/unicode.js +32 -5
  53. package/lib/core/worker.js +217 -190
  54. package/lib/core/worker_stream.js +277 -0
  55. package/lib/display/annotation_layer.js +450 -133
  56. package/lib/display/api.js +1597 -784
  57. package/lib/display/api_compatibility.js +11 -13
  58. package/lib/display/canvas.js +360 -44
  59. package/lib/display/content_disposition.js +83 -32
  60. package/lib/display/display_utils.js +747 -0
  61. package/lib/display/fetch_stream.js +221 -90
  62. package/lib/display/font_loader.js +468 -236
  63. package/lib/display/metadata.js +38 -16
  64. package/lib/display/network.js +635 -428
  65. package/lib/display/network_utils.js +32 -19
  66. package/lib/display/node_stream.js +367 -175
  67. package/lib/display/pattern_helper.js +81 -31
  68. package/lib/display/svg.js +1235 -519
  69. package/lib/display/text_layer.js +153 -29
  70. package/lib/display/transport_stream.js +345 -94
  71. package/lib/display/webgl.js +64 -18
  72. package/lib/display/worker_options.js +5 -4
  73. package/lib/display/xml_parser.js +166 -53
  74. package/lib/examples/node/domstubs.js +60 -4
  75. package/lib/pdf.js +36 -14
  76. package/lib/pdf.worker.js +5 -3
  77. package/lib/shared/compatibility.js +158 -564
  78. package/lib/shared/global_scope.js +2 -2
  79. package/lib/shared/is_node.js +4 -4
  80. package/lib/shared/message_handler.js +521 -0
  81. package/lib/shared/streams_polyfill.js +21 -17
  82. package/lib/shared/url_polyfill.js +56 -0
  83. package/lib/shared/util.js +243 -710
  84. package/lib/test/unit/annotation_spec.js +870 -401
  85. package/lib/test/unit/api_spec.js +657 -345
  86. package/lib/test/unit/bidi_spec.js +7 -7
  87. package/lib/test/unit/cff_parser_spec.js +54 -11
  88. package/lib/test/unit/clitests_helper.js +10 -8
  89. package/lib/test/unit/cmap_spec.js +95 -41
  90. package/lib/test/unit/colorspace_spec.js +115 -63
  91. package/lib/test/unit/core_utils_spec.js +191 -0
  92. package/lib/test/unit/crypto_spec.js +17 -5
  93. package/lib/test/unit/custom_spec.js +43 -55
  94. package/lib/test/unit/display_svg_spec.js +34 -18
  95. package/lib/test/unit/display_utils_spec.js +273 -0
  96. package/lib/test/unit/document_spec.js +8 -13
  97. package/lib/test/unit/encodings_spec.js +25 -45
  98. package/lib/test/unit/evaluator_spec.js +38 -15
  99. package/lib/test/unit/fetch_stream_spec.js +109 -0
  100. package/lib/test/unit/function_spec.js +17 -5
  101. package/lib/test/unit/jasmine-boot.js +33 -20
  102. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  103. package/lib/test/unit/metadata_spec.js +71 -11
  104. package/lib/test/unit/murmurhash3_spec.js +3 -3
  105. package/lib/test/unit/network_spec.js +19 -54
  106. package/lib/test/unit/network_utils_spec.js +91 -14
  107. package/lib/test/unit/node_stream_spec.js +56 -32
  108. package/lib/test/unit/parser_spec.js +162 -71
  109. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  110. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  111. package/lib/test/unit/pdf_history_spec.js +21 -9
  112. package/lib/test/unit/primitives_spec.js +53 -20
  113. package/lib/test/unit/stream_spec.js +12 -4
  114. package/lib/test/unit/test_utils.js +273 -56
  115. package/lib/test/unit/testreporter.js +21 -3
  116. package/lib/test/unit/type1_parser_spec.js +8 -6
  117. package/lib/test/unit/ui_utils_spec.js +454 -16
  118. package/lib/test/unit/unicode_spec.js +18 -15
  119. package/lib/test/unit/util_spec.js +87 -128
  120. package/lib/web/annotation_layer_builder.js +39 -22
  121. package/lib/web/app.js +1290 -588
  122. package/lib/web/app_options.js +100 -62
  123. package/lib/web/base_viewer.js +511 -182
  124. package/lib/web/chromecom.js +261 -117
  125. package/lib/web/debugger.js +166 -22
  126. package/lib/web/download_manager.js +32 -13
  127. package/lib/web/firefox_print_service.js +20 -10
  128. package/lib/web/firefoxcom.js +315 -80
  129. package/lib/web/genericcom.js +89 -30
  130. package/lib/web/genericl10n.js +142 -30
  131. package/lib/web/grab_to_pan.js +28 -4
  132. package/lib/web/interfaces.js +170 -47
  133. package/lib/web/overlay_manager.js +235 -85
  134. package/lib/web/password_prompt.js +22 -14
  135. package/lib/web/pdf_attachment_viewer.js +38 -18
  136. package/lib/web/pdf_cursor_tools.js +39 -16
  137. package/lib/web/pdf_document_properties.js +255 -136
  138. package/lib/web/pdf_find_bar.js +84 -40
  139. package/lib/web/pdf_find_controller.js +495 -184
  140. package/lib/web/pdf_find_utils.js +111 -0
  141. package/lib/web/pdf_history.js +190 -53
  142. package/lib/web/pdf_link_service.js +138 -77
  143. package/lib/web/pdf_outline_viewer.js +122 -46
  144. package/lib/web/pdf_page_view.js +191 -67
  145. package/lib/web/pdf_presentation_mode.js +99 -34
  146. package/lib/web/pdf_print_service.js +61 -13
  147. package/lib/web/pdf_rendering_queue.js +28 -9
  148. package/lib/web/pdf_sidebar.js +141 -81
  149. package/lib/web/pdf_sidebar_resizer.js +42 -16
  150. package/lib/web/pdf_single_page_viewer.js +74 -66
  151. package/lib/web/pdf_thumbnail_view.js +104 -33
  152. package/lib/web/pdf_thumbnail_viewer.js +66 -26
  153. package/lib/web/pdf_viewer.component.js +112 -32
  154. package/lib/web/pdf_viewer.js +91 -52
  155. package/lib/web/preferences.js +284 -89
  156. package/lib/web/secondary_toolbar.js +165 -40
  157. package/lib/web/text_layer_builder.js +134 -59
  158. package/lib/web/toolbar.js +78 -43
  159. package/lib/web/ui_utils.js +462 -136
  160. package/lib/web/view_history.js +215 -67
  161. package/lib/web/viewer_compatibility.js +4 -13
  162. package/package.json +5 -4
  163. package/web/pdf_viewer.css +79 -11
  164. package/web/pdf_viewer.js +6107 -3748
  165. package/web/pdf_viewer.js.map +1 -1
  166. package/lib/display/dom_utils.js +0 -309
  167. package/lib/test/unit/dom_utils_spec.js +0 -89
  168. package/lib/test/unit/fonts_spec.js +0 -81
  169. package/lib/web/dom_events.js +0 -137
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2017 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,21 +19,21 @@
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 _bidi = require('../../core/bidi');
24
+ var _bidi = require("../../core/bidi");
25
25
 
26
26
  describe('bidi', function () {
27
27
  it('should mark text as RTL if more than 30% of text is RTL', function () {
28
- var test = '\u0645\u0635\u0631 Egypt';
29
- var result = 'Egypt \u0631\u0635\u0645';
28
+ var test = "\u0645\u0635\u0631 Egypt";
29
+ var result = "Egypt \u0631\u0635\u0645";
30
30
  var bidiText = (0, _bidi.bidi)(test, -1, false);
31
31
  expect(bidiText.str).toEqual(result);
32
32
  expect(bidiText.dir).toEqual('rtl');
33
33
  });
34
34
  it('should mark text as LTR if less than 30% of text is RTL', function () {
35
- var test = 'Egypt is known as \u0645\u0635\u0631 in Arabic.';
36
- var result = 'Egypt is known as \u0631\u0635\u0645 in Arabic.';
35
+ var test = "Egypt is known as \u0645\u0635\u0631 in Arabic.";
36
+ var result = "Egypt is known as \u0631\u0635\u0645 in Arabic.";
37
37
  var bidiText = (0, _bidi.bidi)(test, -1, false);
38
38
  expect(bidiText.str).toEqual(result);
39
39
  expect(bidiText.dir).toEqual('ltr');
@@ -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 2017 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,22 +19,25 @@
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 _cff_parser = require('../../core/cff_parser');
24
+ var _cff_parser = require("../../core/cff_parser");
25
25
 
26
- var _fonts = require('../../core/fonts');
26
+ var _fonts = require("../../core/fonts");
27
27
 
28
- var _stream = require('../../core/stream');
28
+ var _stream = require("../../core/stream");
29
29
 
30
30
  describe('CFFParser', function () {
31
31
  function createWithNullProto(obj) {
32
32
  var result = Object.create(null);
33
+
33
34
  for (var i in obj) {
34
35
  result[i] = obj[i];
35
36
  }
37
+
36
38
  return result;
37
39
  }
40
+
38
41
  var privateDictStub = {
39
42
  getByName: function getByName(name) {
40
43
  return 0;
@@ -44,10 +47,12 @@ describe('CFFParser', function () {
44
47
  beforeAll(function (done) {
45
48
  var exampleFont = '0100040100010101134142434445462b' + '54696d65732d526f6d616e000101011f' + 'f81b00f81c02f81d03f819041c6f000d' + 'fb3cfb6efa7cfa1605e911b8f1120003' + '01010813183030312e30303754696d65' + '7320526f6d616e54696d657300000002' + '010102030e0e7d99f92a99fb7695f773' + '8b06f79a93fc7c8c077d99f85695f75e' + '9908fb6e8cf87393f7108b09a70adf0b' + 'f78e14';
46
49
  var fontArr = [];
50
+
47
51
  for (var i = 0, ii = exampleFont.length; i < ii; i += 2) {
48
- var hex = exampleFont.substr(i, 2);
52
+ var hex = exampleFont.substring(i, i + 2);
49
53
  fontArr.push(parseInt(hex, 16));
50
54
  }
55
+
51
56
  fontData = new _stream.Stream(fontArr);
52
57
  done();
53
58
  });
@@ -103,9 +108,11 @@ describe('CFFParser', function () {
103
108
  parser.bytes = bytes;
104
109
  var topDict = cff.topDict;
105
110
  topDict.setByName('Private', [bytes.length, 0]);
111
+
106
112
  var parsePrivateDict = function parsePrivateDict() {
107
113
  parser.parsePrivateDict(topDict);
108
114
  };
115
+
109
116
  expect(parsePrivateDict).not.toThrow();
110
117
  var privateDict = topDict.privateDict;
111
118
  expect(privateDict.getByName('BlueValues')).toBeNull();
@@ -198,7 +205,9 @@ describe('CFFParser', function () {
198
205
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x08]);
199
206
  parser.bytes = bytes;
200
207
  var encoding = parser.parseEncoding(2, {}, new _cff_parser.CFFStrings(), null);
201
- expect(encoding.encoding).toEqual(createWithNullProto({ 0x8: 1 }));
208
+ expect(encoding.encoding).toEqual(createWithNullProto({
209
+ 0x8: 1
210
+ }));
202
211
  });
203
212
  it('parses encoding format 1', function () {
204
213
  var bytes = new Uint8Array([0x00, 0x00, 0x01, 0x01, 0x07, 0x01]);
@@ -214,22 +223,21 @@ describe('CFFParser', function () {
214
223
  parser.bytes = bytes.slice();
215
224
  var fdSelect = parser.parseFDSelect(0, 2);
216
225
  expect(fdSelect.fdSelect).toEqual([0, 1]);
217
- expect(fdSelect.raw).toEqual(bytes);
226
+ expect(fdSelect.format).toEqual(0);
218
227
  });
219
228
  it('parses fdselect format 3', function () {
220
229
  var bytes = new Uint8Array([0x03, 0x00, 0x02, 0x00, 0x00, 0x09, 0x00, 0x02, 0x0a, 0x00, 0x04]);
221
230
  parser.bytes = bytes.slice();
222
231
  var fdSelect = parser.parseFDSelect(0, 4);
223
232
  expect(fdSelect.fdSelect).toEqual([9, 9, 0xa, 0xa]);
224
- expect(fdSelect.raw).toEqual(bytes);
233
+ expect(fdSelect.format).toEqual(3);
225
234
  });
226
235
  it('parses invalid fdselect format 3 (bug 1146106)', function () {
227
236
  var bytes = new Uint8Array([0x03, 0x00, 0x02, 0x00, 0x01, 0x09, 0x00, 0x02, 0x0a, 0x00, 0x04]);
228
237
  parser.bytes = bytes.slice();
229
238
  var fdSelect = parser.parseFDSelect(0, 4);
230
239
  expect(fdSelect.fdSelect).toEqual([9, 9, 0xa, 0xa]);
231
- bytes[3] = bytes[4] = 0x00;
232
- expect(fdSelect.raw).toEqual(bytes);
240
+ expect(fdSelect.format).toEqual(3);
233
241
  });
234
242
  });
235
243
  describe('CFFCompiler', function () {
@@ -241,6 +249,7 @@ describe('CFFCompiler', function () {
241
249
  }
242
250
  }, {}, _fonts.SEAC_ANALYSIS_ENABLED);
243
251
  }
252
+
244
253
  it('encodes integers', function () {
245
254
  var c = new _cff_parser.CFFCompiler();
246
255
  expect(c.encodeInteger(0)).toEqual([0x8b]);
@@ -266,13 +275,47 @@ describe('CFFCompiler', function () {
266
275
  var names = parser.parseNameIndex(nameIndex.obj);
267
276
  expect(names).toEqual(['_a']);
268
277
  var longName = '';
278
+
269
279
  for (var i = 0; i < 129; i++) {
270
280
  longName += '_';
271
281
  }
282
+
272
283
  nameIndexCompiled = c.compileNameIndex([longName]);
273
284
  parser = testParser(nameIndexCompiled);
274
285
  nameIndex = parser.parseIndex(0);
275
286
  names = parser.parseNameIndex(nameIndex.obj);
276
287
  expect(names[0].length).toEqual(127);
277
288
  });
289
+ it('compiles fdselect format 0', function () {
290
+ var fdSelect = new _cff_parser.CFFFDSelect(0, [3, 2, 1]);
291
+ var c = new _cff_parser.CFFCompiler();
292
+ var out = c.compileFDSelect(fdSelect);
293
+ expect(out).toEqual([0, 3, 2, 1]);
294
+ });
295
+ it('compiles fdselect format 3', function () {
296
+ var fdSelect = new _cff_parser.CFFFDSelect(3, [0, 0, 1, 1]);
297
+ var c = new _cff_parser.CFFCompiler();
298
+ var out = c.compileFDSelect(fdSelect);
299
+ expect(out).toEqual([3, 0, 2, 0, 0, 0, 0, 2, 1, 0, 4]);
300
+ });
301
+ it('compiles fdselect format 3, single range', function () {
302
+ var fdSelect = new _cff_parser.CFFFDSelect(3, [0, 0]);
303
+ var c = new _cff_parser.CFFCompiler();
304
+ var out = c.compileFDSelect(fdSelect);
305
+ expect(out).toEqual([3, 0, 1, 0, 0, 0, 0, 2]);
306
+ });
307
+ it('compiles charset of CID font', function () {
308
+ var charset = new _cff_parser.CFFCharset();
309
+ var c = new _cff_parser.CFFCompiler();
310
+ var numGlyphs = 7;
311
+ var out = c.compileCharset(charset, numGlyphs, new _cff_parser.CFFStrings(), true);
312
+ expect(out).toEqual([2, 0, 0, 0, numGlyphs - 1]);
313
+ });
314
+ it('compiles charset of non CID font', function () {
315
+ var charset = new _cff_parser.CFFCharset(false, 0, ['space', 'exclam']);
316
+ var c = new _cff_parser.CFFCompiler();
317
+ var numGlyphs = 3;
318
+ var out = c.compileCharset(charset, numGlyphs, new _cff_parser.CFFStrings(), false);
319
+ expect(out).toEqual([0, 0, 1, 0, 2]);
320
+ });
278
321
  });
@@ -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 2017 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,21 +19,23 @@
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 _is_node = require('../../shared/is_node');
24
+ var _util = require("../../shared/util");
25
25
 
26
- var _is_node2 = _interopRequireDefault(_is_node);
26
+ var _is_node = _interopRequireDefault(require("../../shared/is_node"));
27
27
 
28
- var _node_stream = require('../../display/node_stream');
28
+ var _node_stream = require("../../display/node_stream");
29
29
 
30
- var _api = require('../../display/api');
30
+ var _api = require("../../display/api");
31
31
 
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
33
 
34
- if (!(0, _is_node2.default)()) {
34
+ if (!(0, _is_node["default"])()) {
35
35
  throw new Error('The `gulp unittestcli` command can only be used in ' + 'Node.js environments.');
36
36
  }
37
+
38
+ (0, _util.setVerbosityLevel)(_util.VerbosityLevel.ERRORS);
37
39
  (0, _api.setPDFNetworkStreamFactory)(function (params) {
38
40
  return new _node_stream.PDFNodeStream(params);
39
41
  });
@@ -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 2017 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,23 +19,21 @@
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 _cmap = require('../../core/cmap');
24
+ var _cmap = require("../../core/cmap");
25
25
 
26
- var _dom_utils = require('../../display/dom_utils');
26
+ var _display_utils = require("../../display/display_utils");
27
27
 
28
- var _is_node = require('../../shared/is_node');
28
+ var _is_node = _interopRequireDefault(require("../../shared/is_node"));
29
29
 
30
- var _is_node2 = _interopRequireDefault(_is_node);
30
+ var _primitives = require("../../core/primitives");
31
31
 
32
- var _primitives = require('../../core/primitives');
32
+ var _test_utils = require("./test_utils");
33
33
 
34
- var _test_utils = require('./test_utils');
34
+ var _stream = require("../../core/stream");
35
35
 
36
- var _stream = require('../../core/stream');
37
-
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
37
 
40
38
  var cMapUrl = {
41
39
  dom: '../../external/bcmaps/',
@@ -46,20 +44,25 @@ describe('cmap', function () {
46
44
  var fetchBuiltInCMap;
47
45
  beforeAll(function (done) {
48
46
  var CMapReaderFactory;
49
- if ((0, _is_node2.default)()) {
47
+
48
+ if ((0, _is_node["default"])()) {
50
49
  CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
51
50
  baseUrl: cMapUrl.node,
52
51
  isCompressed: cMapPacked
53
52
  });
54
53
  } else {
55
- CMapReaderFactory = new _dom_utils.DOMCMapReaderFactory({
54
+ CMapReaderFactory = new _display_utils.DOMCMapReaderFactory({
56
55
  baseUrl: cMapUrl.dom,
57
56
  isCompressed: cMapPacked
58
57
  });
59
58
  }
59
+
60
60
  fetchBuiltInCMap = function fetchBuiltInCMap(name) {
61
- return CMapReaderFactory.fetch({ name: name });
61
+ return CMapReaderFactory.fetch({
62
+ name: name
63
+ });
62
64
  };
65
+
63
66
  done();
64
67
  });
65
68
  afterAll(function () {
@@ -68,74 +71,98 @@ describe('cmap', function () {
68
71
  it('parses beginbfchar', function (done) {
69
72
  var str = '2 beginbfchar\n' + '<03> <00>\n' + '<04> <01>\n' + 'endbfchar\n';
70
73
  var stream = new _stream.StringStream(str);
71
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
74
+
75
+ var cmapPromise = _cmap.CMapFactory.create({
76
+ encoding: stream
77
+ });
78
+
72
79
  cmapPromise.then(function (cmap) {
73
80
  expect(cmap.lookup(0x03)).toEqual(String.fromCharCode(0x00));
74
81
  expect(cmap.lookup(0x04)).toEqual(String.fromCharCode(0x01));
75
82
  expect(cmap.lookup(0x05)).toBeUndefined();
76
83
  done();
77
- }).catch(function (reason) {
84
+ })["catch"](function (reason) {
78
85
  done.fail(reason);
79
86
  });
80
87
  });
81
88
  it('parses beginbfrange with range', function (done) {
82
89
  var str = '1 beginbfrange\n' + '<06> <0B> 0\n' + 'endbfrange\n';
83
90
  var stream = new _stream.StringStream(str);
84
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
91
+
92
+ var cmapPromise = _cmap.CMapFactory.create({
93
+ encoding: stream
94
+ });
95
+
85
96
  cmapPromise.then(function (cmap) {
86
97
  expect(cmap.lookup(0x05)).toBeUndefined();
87
98
  expect(cmap.lookup(0x06)).toEqual(String.fromCharCode(0x00));
88
99
  expect(cmap.lookup(0x0B)).toEqual(String.fromCharCode(0x05));
89
100
  expect(cmap.lookup(0x0C)).toBeUndefined();
90
101
  done();
91
- }).catch(function (reason) {
102
+ })["catch"](function (reason) {
92
103
  done.fail(reason);
93
104
  });
94
105
  });
95
106
  it('parses beginbfrange with array', function (done) {
96
107
  var str = '1 beginbfrange\n' + '<0D> <12> [ 0 1 2 3 4 5 ]\n' + 'endbfrange\n';
97
108
  var stream = new _stream.StringStream(str);
98
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
109
+
110
+ var cmapPromise = _cmap.CMapFactory.create({
111
+ encoding: stream
112
+ });
113
+
99
114
  cmapPromise.then(function (cmap) {
100
115
  expect(cmap.lookup(0x0C)).toBeUndefined();
101
116
  expect(cmap.lookup(0x0D)).toEqual(0x00);
102
117
  expect(cmap.lookup(0x12)).toEqual(0x05);
103
118
  expect(cmap.lookup(0x13)).toBeUndefined();
104
119
  done();
105
- }).catch(function (reason) {
120
+ })["catch"](function (reason) {
106
121
  done.fail(reason);
107
122
  });
108
123
  });
109
124
  it('parses begincidchar', function (done) {
110
125
  var str = '1 begincidchar\n' + '<14> 0\n' + 'endcidchar\n';
111
126
  var stream = new _stream.StringStream(str);
112
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
127
+
128
+ var cmapPromise = _cmap.CMapFactory.create({
129
+ encoding: stream
130
+ });
131
+
113
132
  cmapPromise.then(function (cmap) {
114
133
  expect(cmap.lookup(0x14)).toEqual(0x00);
115
134
  expect(cmap.lookup(0x15)).toBeUndefined();
116
135
  done();
117
- }).catch(function (reason) {
136
+ })["catch"](function (reason) {
118
137
  done.fail(reason);
119
138
  });
120
139
  });
121
140
  it('parses begincidrange', function (done) {
122
141
  var str = '1 begincidrange\n' + '<0016> <001B> 0\n' + 'endcidrange\n';
123
142
  var stream = new _stream.StringStream(str);
124
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
143
+
144
+ var cmapPromise = _cmap.CMapFactory.create({
145
+ encoding: stream
146
+ });
147
+
125
148
  cmapPromise.then(function (cmap) {
126
149
  expect(cmap.lookup(0x15)).toBeUndefined();
127
150
  expect(cmap.lookup(0x16)).toEqual(0x00);
128
151
  expect(cmap.lookup(0x1B)).toEqual(0x05);
129
152
  expect(cmap.lookup(0x1C)).toBeUndefined();
130
153
  done();
131
- }).catch(function (reason) {
154
+ })["catch"](function (reason) {
132
155
  done.fail(reason);
133
156
  });
134
157
  });
135
158
  it('decodes codespace ranges', function (done) {
136
159
  var str = '1 begincodespacerange\n' + '<01> <02>\n' + '<00000003> <00000004>\n' + 'endcodespacerange\n';
137
160
  var stream = new _stream.StringStream(str);
138
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
161
+
162
+ var cmapPromise = _cmap.CMapFactory.create({
163
+ encoding: stream
164
+ });
165
+
139
166
  cmapPromise.then(function (cmap) {
140
167
  var c = {};
141
168
  cmap.readCharCode(String.fromCharCode(1), 0, c);
@@ -145,32 +172,38 @@ describe('cmap', function () {
145
172
  expect(c.charcode).toEqual(3);
146
173
  expect(c.length).toEqual(4);
147
174
  done();
148
- }).catch(function (reason) {
175
+ })["catch"](function (reason) {
149
176
  done.fail(reason);
150
177
  });
151
178
  });
152
179
  it('decodes 4 byte codespace ranges', function (done) {
153
180
  var str = '1 begincodespacerange\n' + '<8EA1A1A1> <8EA1FEFE>\n' + 'endcodespacerange\n';
154
181
  var stream = new _stream.StringStream(str);
155
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
182
+
183
+ var cmapPromise = _cmap.CMapFactory.create({
184
+ encoding: stream
185
+ });
186
+
156
187
  cmapPromise.then(function (cmap) {
157
188
  var c = {};
158
189
  cmap.readCharCode(String.fromCharCode(0x8E, 0xA1, 0xA1, 0xA1), 0, c);
159
190
  expect(c.charcode).toEqual(0x8EA1A1A1);
160
191
  expect(c.length).toEqual(4);
161
192
  done();
162
- }).catch(function (reason) {
193
+ })["catch"](function (reason) {
163
194
  done.fail(reason);
164
195
  });
165
196
  });
166
197
  it('read usecmap', function (done) {
167
198
  var str = '/Adobe-Japan1-1 usecmap\n';
168
199
  var stream = new _stream.StringStream(str);
200
+
169
201
  var cmapPromise = _cmap.CMapFactory.create({
170
202
  encoding: stream,
171
203
  fetchBuiltInCMap: fetchBuiltInCMap,
172
204
  useCMap: null
173
205
  });
206
+
174
207
  cmapPromise.then(function (cmap) {
175
208
  expect(cmap instanceof _cmap.CMap).toEqual(true);
176
209
  expect(cmap.useCMap).not.toBeNull();
@@ -178,29 +211,37 @@ describe('cmap', function () {
178
211
  expect(cmap.length).toEqual(0x20A7);
179
212
  expect(cmap.isIdentityCMap).toEqual(false);
180
213
  done();
181
- }).catch(function (reason) {
214
+ })["catch"](function (reason) {
182
215
  done.fail(reason);
183
216
  });
184
217
  });
185
218
  it('parses cmapname', function (done) {
186
219
  var str = '/CMapName /Identity-H def\n';
187
220
  var stream = new _stream.StringStream(str);
188
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
221
+
222
+ var cmapPromise = _cmap.CMapFactory.create({
223
+ encoding: stream
224
+ });
225
+
189
226
  cmapPromise.then(function (cmap) {
190
227
  expect(cmap.name).toEqual('Identity-H');
191
228
  done();
192
- }).catch(function (reason) {
229
+ })["catch"](function (reason) {
193
230
  done.fail(reason);
194
231
  });
195
232
  });
196
233
  it('parses wmode', function (done) {
197
234
  var str = '/WMode 1 def\n';
198
235
  var stream = new _stream.StringStream(str);
199
- var cmapPromise = _cmap.CMapFactory.create({ encoding: stream });
236
+
237
+ var cmapPromise = _cmap.CMapFactory.create({
238
+ encoding: stream
239
+ });
240
+
200
241
  cmapPromise.then(function (cmap) {
201
242
  expect(cmap.vertical).toEqual(true);
202
243
  done();
203
- }).catch(function (reason) {
244
+ })["catch"](function (reason) {
204
245
  done.fail(reason);
205
246
  });
206
247
  });
@@ -210,6 +251,7 @@ describe('cmap', function () {
210
251
  fetchBuiltInCMap: fetchBuiltInCMap,
211
252
  useCMap: null
212
253
  });
254
+
213
255
  cmapPromise.then(function (cmap) {
214
256
  expect(cmap instanceof _cmap.CMap).toEqual(true);
215
257
  expect(cmap.useCMap).toBeNull();
@@ -217,7 +259,7 @@ describe('cmap', function () {
217
259
  expect(cmap.length).toEqual(0x20A7);
218
260
  expect(cmap.isIdentityCMap).toEqual(false);
219
261
  done();
220
- }).catch(function (reason) {
262
+ })["catch"](function (reason) {
221
263
  done.fail(reason);
222
264
  });
223
265
  });
@@ -227,6 +269,7 @@ describe('cmap', function () {
227
269
  fetchBuiltInCMap: fetchBuiltInCMap,
228
270
  useCMap: null
229
271
  });
272
+
230
273
  cmapPromise.then(function (cmap) {
231
274
  expect(cmap instanceof _cmap.IdentityCMap).toEqual(true);
232
275
  expect(cmap.vertical).toEqual(false);
@@ -235,7 +278,7 @@ describe('cmap', function () {
235
278
  return cmap.isIdentityCMap;
236
279
  }).toThrow(new Error('should not access .isIdentityCMap'));
237
280
  done();
238
- }).catch(function (reason) {
281
+ })["catch"](function (reason) {
239
282
  done.fail(reason);
240
283
  });
241
284
  });
@@ -245,6 +288,7 @@ describe('cmap', function () {
245
288
  fetchBuiltInCMap: fetchBuiltInCMap,
246
289
  useCMap: null
247
290
  });
291
+
248
292
  cmapPromise.then(function () {
249
293
  done.fail('No CMap should be loaded');
250
294
  }, function (reason) {
@@ -255,14 +299,18 @@ describe('cmap', function () {
255
299
  });
256
300
  it('attempts to load a built-in CMap without the necessary API parameters', function (done) {
257
301
  function tmpFetchBuiltInCMap(name) {
258
- var CMapReaderFactory = (0, _is_node2.default)() ? new _test_utils.NodeCMapReaderFactory({}) : new _dom_utils.DOMCMapReaderFactory({});
259
- return CMapReaderFactory.fetch({ name: name });
302
+ var CMapReaderFactory = (0, _is_node["default"])() ? new _test_utils.NodeCMapReaderFactory({}) : new _display_utils.DOMCMapReaderFactory({});
303
+ return CMapReaderFactory.fetch({
304
+ name: name
305
+ });
260
306
  }
307
+
261
308
  var cmapPromise = _cmap.CMapFactory.create({
262
309
  encoding: _primitives.Name.get('Adobe-Japan1-1'),
263
310
  fetchBuiltInCMap: tmpFetchBuiltInCMap,
264
311
  useCMap: null
265
312
  });
313
+
266
314
  cmapPromise.then(function () {
267
315
  done.fail('No CMap should be loaded');
268
316
  }, function (reason) {
@@ -273,25 +321,31 @@ describe('cmap', function () {
273
321
  });
274
322
  it('attempts to load a built-in CMap with inconsistent API parameters', function (done) {
275
323
  function tmpFetchBuiltInCMap(name) {
276
- var CMapReaderFactory = void 0;
277
- if ((0, _is_node2.default)()) {
324
+ var CMapReaderFactory;
325
+
326
+ if ((0, _is_node["default"])()) {
278
327
  CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
279
328
  baseUrl: cMapUrl.node,
280
329
  isCompressed: false
281
330
  });
282
331
  } else {
283
- CMapReaderFactory = new _dom_utils.DOMCMapReaderFactory({
332
+ CMapReaderFactory = new _display_utils.DOMCMapReaderFactory({
284
333
  baseUrl: cMapUrl.dom,
285
334
  isCompressed: false
286
335
  });
287
336
  }
288
- return CMapReaderFactory.fetch({ name: name });
337
+
338
+ return CMapReaderFactory.fetch({
339
+ name: name
340
+ });
289
341
  }
342
+
290
343
  var cmapPromise = _cmap.CMapFactory.create({
291
344
  encoding: _primitives.Name.get('Adobe-Japan1-1'),
292
345
  fetchBuiltInCMap: tmpFetchBuiltInCMap,
293
346
  useCMap: null
294
347
  });
348
+
295
349
  cmapPromise.then(function () {
296
350
  done.fail('No CMap should be loaded');
297
351
  }, function (reason) {