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,41 +21,41 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _pdf_find_utils = require("../../web/pdf_find_utils");
24
+ var _pdf_find_utils = require("../../web/pdf_find_utils.js");
25
25
 
26
- describe('pdf_find_utils', function () {
27
- describe('getCharacterType', function () {
28
- it('gets expected character types', function () {
29
- var characters = {
30
- 'A': _pdf_find_utils.CharacterType.ALPHA_LETTER,
31
- 'a': _pdf_find_utils.CharacterType.ALPHA_LETTER,
32
- '0': _pdf_find_utils.CharacterType.ALPHA_LETTER,
33
- '5': _pdf_find_utils.CharacterType.ALPHA_LETTER,
34
- '\xC4': _pdf_find_utils.CharacterType.ALPHA_LETTER,
35
- '\xE4': _pdf_find_utils.CharacterType.ALPHA_LETTER,
36
- '_': _pdf_find_utils.CharacterType.ALPHA_LETTER,
37
- ' ': _pdf_find_utils.CharacterType.SPACE,
38
- '\t': _pdf_find_utils.CharacterType.SPACE,
39
- '\r': _pdf_find_utils.CharacterType.SPACE,
40
- '\n': _pdf_find_utils.CharacterType.SPACE,
41
- '\xA0': _pdf_find_utils.CharacterType.SPACE,
42
- '-': _pdf_find_utils.CharacterType.PUNCT,
43
- ',': _pdf_find_utils.CharacterType.PUNCT,
44
- '.': _pdf_find_utils.CharacterType.PUNCT,
45
- ';': _pdf_find_utils.CharacterType.PUNCT,
46
- ':': _pdf_find_utils.CharacterType.PUNCT,
26
+ describe("pdf_find_utils", function () {
27
+ describe("getCharacterType", function () {
28
+ it("gets expected character types", function () {
29
+ const characters = {
30
+ A: _pdf_find_utils.CharacterType.ALPHA_LETTER,
31
+ a: _pdf_find_utils.CharacterType.ALPHA_LETTER,
32
+ "0": _pdf_find_utils.CharacterType.ALPHA_LETTER,
33
+ "5": _pdf_find_utils.CharacterType.ALPHA_LETTER,
34
+ Ä: _pdf_find_utils.CharacterType.ALPHA_LETTER,
35
+ ä: _pdf_find_utils.CharacterType.ALPHA_LETTER,
36
+ _: _pdf_find_utils.CharacterType.ALPHA_LETTER,
37
+ " ": _pdf_find_utils.CharacterType.SPACE,
38
+ "\t": _pdf_find_utils.CharacterType.SPACE,
39
+ "\r": _pdf_find_utils.CharacterType.SPACE,
40
+ "\n": _pdf_find_utils.CharacterType.SPACE,
41
+ "\xA0": _pdf_find_utils.CharacterType.SPACE,
42
+ "-": _pdf_find_utils.CharacterType.PUNCT,
43
+ ",": _pdf_find_utils.CharacterType.PUNCT,
44
+ ".": _pdf_find_utils.CharacterType.PUNCT,
45
+ ";": _pdf_find_utils.CharacterType.PUNCT,
46
+ ":": _pdf_find_utils.CharacterType.PUNCT,
47
47
  "\u2122": _pdf_find_utils.CharacterType.ALPHA_LETTER,
48
- "\u0E25": _pdf_find_utils.CharacterType.THAI_LETTER,
49
- "\u4000": _pdf_find_utils.CharacterType.HAN_LETTER,
50
- "\uF950": _pdf_find_utils.CharacterType.HAN_LETTER,
51
- "\u30C0": _pdf_find_utils.CharacterType.KATAKANA_LETTER,
52
- "\u3050": _pdf_find_utils.CharacterType.HIRAGANA_LETTER,
53
- "\uFF80": _pdf_find_utils.CharacterType.HALFWIDTH_KATAKANA_LETTER
48
+ ล: _pdf_find_utils.CharacterType.THAI_LETTER,
49
+ 䀀: _pdf_find_utils.CharacterType.HAN_LETTER,
50
+ 縷: _pdf_find_utils.CharacterType.HAN_LETTER,
51
+ ダ: _pdf_find_utils.CharacterType.KATAKANA_LETTER,
52
+ ぐ: _pdf_find_utils.CharacterType.HIRAGANA_LETTER,
53
+ タ: _pdf_find_utils.CharacterType.HALFWIDTH_KATAKANA_LETTER
54
54
  };
55
55
 
56
- for (var character in characters) {
57
- var charCode = character.charCodeAt(0);
58
- var type = characters[character];
56
+ for (const character in characters) {
57
+ const charCode = character.charCodeAt(0);
58
+ const type = characters[character];
59
59
  expect((0, _pdf_find_utils.getCharacterType)(charCode)).toEqual(type);
60
60
  }
61
61
  });
@@ -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,73 +21,73 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _pdf_history = require("../../web/pdf_history");
24
+ var _pdf_history = require("../../web/pdf_history.js");
25
25
 
26
- describe('pdf_history', function () {
27
- describe('isDestHashesEqual', function () {
28
- it('should reject non-equal destination hashes', function () {
29
- expect((0, _pdf_history.isDestHashesEqual)(null, 'page.157')).toEqual(false);
30
- expect((0, _pdf_history.isDestHashesEqual)('title.0', 'page.157')).toEqual(false);
31
- expect((0, _pdf_history.isDestHashesEqual)('page=1&zoom=auto', 'page.157')).toEqual(false);
32
- expect((0, _pdf_history.isDestHashesEqual)('nameddest-page.157', 'page.157')).toEqual(false);
33
- expect((0, _pdf_history.isDestHashesEqual)('page.157', 'nameddest=page.157')).toEqual(false);
34
- var destArrayString = JSON.stringify([{
26
+ describe("pdf_history", function () {
27
+ describe("isDestHashesEqual", function () {
28
+ it("should reject non-equal destination hashes", function () {
29
+ expect((0, _pdf_history.isDestHashesEqual)(null, "page.157")).toEqual(false);
30
+ expect((0, _pdf_history.isDestHashesEqual)("title.0", "page.157")).toEqual(false);
31
+ expect((0, _pdf_history.isDestHashesEqual)("page=1&zoom=auto", "page.157")).toEqual(false);
32
+ expect((0, _pdf_history.isDestHashesEqual)("nameddest-page.157", "page.157")).toEqual(false);
33
+ expect((0, _pdf_history.isDestHashesEqual)("page.157", "nameddest=page.157")).toEqual(false);
34
+ const destArrayString = JSON.stringify([{
35
35
  num: 3757,
36
36
  gen: 0
37
37
  }, {
38
- name: 'XYZ'
38
+ name: "XYZ"
39
39
  }, 92.918, 748.972, null]);
40
- expect((0, _pdf_history.isDestHashesEqual)(destArrayString, 'page.157')).toEqual(false);
41
- expect((0, _pdf_history.isDestHashesEqual)('page.157', destArrayString)).toEqual(false);
40
+ expect((0, _pdf_history.isDestHashesEqual)(destArrayString, "page.157")).toEqual(false);
41
+ expect((0, _pdf_history.isDestHashesEqual)("page.157", destArrayString)).toEqual(false);
42
42
  });
43
- it('should accept equal destination hashes', function () {
44
- expect((0, _pdf_history.isDestHashesEqual)('page.157', 'page.157')).toEqual(true);
45
- expect((0, _pdf_history.isDestHashesEqual)('nameddest=page.157', 'page.157')).toEqual(true);
46
- expect((0, _pdf_history.isDestHashesEqual)('nameddest=page.157&zoom=100', 'page.157')).toEqual(true);
43
+ it("should accept equal destination hashes", function () {
44
+ expect((0, _pdf_history.isDestHashesEqual)("page.157", "page.157")).toEqual(true);
45
+ expect((0, _pdf_history.isDestHashesEqual)("nameddest=page.157", "page.157")).toEqual(true);
46
+ expect((0, _pdf_history.isDestHashesEqual)("nameddest=page.157&zoom=100", "page.157")).toEqual(true);
47
47
  });
48
48
  });
49
- describe('isDestArraysEqual', function () {
50
- var firstDest = [{
49
+ describe("isDestArraysEqual", function () {
50
+ const firstDest = [{
51
51
  num: 1,
52
52
  gen: 0
53
53
  }, {
54
- name: 'XYZ'
54
+ name: "XYZ"
55
55
  }, 0, 375, null];
56
- var secondDest = [{
56
+ const secondDest = [{
57
57
  num: 5,
58
58
  gen: 0
59
59
  }, {
60
- name: 'XYZ'
60
+ name: "XYZ"
61
61
  }, 0, 375, null];
62
- var thirdDest = [{
62
+ const thirdDest = [{
63
63
  num: 1,
64
64
  gen: 0
65
65
  }, {
66
- name: 'XYZ'
66
+ name: "XYZ"
67
67
  }, 750, 0, null];
68
- var fourthDest = [{
68
+ const fourthDest = [{
69
69
  num: 1,
70
70
  gen: 0
71
71
  }, {
72
- name: 'XYZ'
72
+ name: "XYZ"
73
73
  }, 0, 375, 1.0];
74
- var fifthDest = [{
74
+ const fifthDest = [{
75
75
  gen: 0,
76
76
  num: 1
77
77
  }, {
78
- name: 'XYZ'
78
+ name: "XYZ"
79
79
  }, 0, 375, null];
80
- it('should reject non-equal destination arrays', function () {
80
+ it("should reject non-equal destination arrays", function () {
81
81
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, undefined)).toEqual(false);
82
82
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, [1, 2, 3, 4, 5])).toEqual(false);
83
83
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, secondDest)).toEqual(false);
84
84
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, thirdDest)).toEqual(false);
85
85
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, fourthDest)).toEqual(false);
86
86
  });
87
- it('should accept equal destination arrays', function () {
87
+ it("should accept equal destination arrays", function () {
88
88
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, firstDest)).toEqual(true);
89
89
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, fifthDest)).toEqual(true);
90
- var firstDestCopy = firstDest.slice();
90
+ const firstDestCopy = firstDest.slice();
91
91
  expect(firstDest).not.toBe(firstDestCopy);
92
92
  expect((0, _pdf_history.isDestArraysEqual)(firstDest, firstDestCopy)).toEqual(true);
93
93
  });
@@ -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,146 +21,148 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _primitives = require("../../core/primitives");
24
+ var _primitives = require("../../core/primitives.js");
25
25
 
26
- var _test_utils = require("./test_utils");
26
+ var _test_utils = require("./test_utils.js");
27
27
 
28
- describe('primitives', function () {
29
- describe('Name', function () {
30
- it('should retain the given name', function () {
31
- var givenName = 'Font';
28
+ describe("primitives", function () {
29
+ describe("Name", function () {
30
+ it("should retain the given name", function () {
31
+ var givenName = "Font";
32
32
 
33
33
  var name = _primitives.Name.get(givenName);
34
34
 
35
35
  expect(name.name).toEqual(givenName);
36
36
  });
37
- it('should create only one object for a name and cache it', function () {
38
- var firstFont = _primitives.Name.get('Font');
37
+ it("should create only one object for a name and cache it", function () {
38
+ var firstFont = _primitives.Name.get("Font");
39
39
 
40
- var secondFont = _primitives.Name.get('Font');
40
+ var secondFont = _primitives.Name.get("Font");
41
41
 
42
- var firstSubtype = _primitives.Name.get('Subtype');
42
+ var firstSubtype = _primitives.Name.get("Subtype");
43
43
 
44
- var secondSubtype = _primitives.Name.get('Subtype');
44
+ var secondSubtype = _primitives.Name.get("Subtype");
45
45
 
46
46
  expect(firstFont).toBe(secondFont);
47
47
  expect(firstSubtype).toBe(secondSubtype);
48
48
  expect(firstFont).not.toBe(firstSubtype);
49
49
  });
50
50
  });
51
- describe('Cmd', function () {
52
- it('should retain the given cmd name', function () {
53
- var givenCmd = 'BT';
51
+ describe("Cmd", function () {
52
+ it("should retain the given cmd name", function () {
53
+ var givenCmd = "BT";
54
54
 
55
55
  var cmd = _primitives.Cmd.get(givenCmd);
56
56
 
57
57
  expect(cmd.cmd).toEqual(givenCmd);
58
58
  });
59
- it('should create only one object for a command and cache it', function () {
60
- var firstBT = _primitives.Cmd.get('BT');
59
+ it("should create only one object for a command and cache it", function () {
60
+ var firstBT = _primitives.Cmd.get("BT");
61
61
 
62
- var secondBT = _primitives.Cmd.get('BT');
62
+ var secondBT = _primitives.Cmd.get("BT");
63
63
 
64
- var firstET = _primitives.Cmd.get('ET');
64
+ var firstET = _primitives.Cmd.get("ET");
65
65
 
66
- var secondET = _primitives.Cmd.get('ET');
66
+ var secondET = _primitives.Cmd.get("ET");
67
67
 
68
68
  expect(firstBT).toBe(secondBT);
69
69
  expect(firstET).toBe(secondET);
70
70
  expect(firstBT).not.toBe(firstET);
71
71
  });
72
72
  });
73
- describe('Dict', function () {
74
- var checkInvalidHasValues = function checkInvalidHasValues(dict) {
73
+ describe("Dict", function () {
74
+ var checkInvalidHasValues = function (dict) {
75
75
  expect(dict.has()).toBeFalsy();
76
- expect(dict.has('Prev')).toBeFalsy();
76
+ expect(dict.has("Prev")).toBeFalsy();
77
77
  };
78
78
 
79
- var checkInvalidKeyValues = function checkInvalidKeyValues(dict) {
79
+ var checkInvalidKeyValues = function (dict) {
80
80
  expect(dict.get()).toBeUndefined();
81
- expect(dict.get('Prev')).toBeUndefined();
82
- expect(dict.get('Decode', 'D')).toBeUndefined();
83
- expect(dict.get('FontFile', 'FontFile2', 'FontFile3')).toBeUndefined();
81
+ expect(dict.get("Prev")).toBeUndefined();
82
+ expect(dict.get("Decode", "D")).toBeUndefined();
83
+ expect(dict.get("FontFile", "FontFile2", "FontFile3")).toBeUndefined();
84
84
  };
85
85
 
86
86
  var emptyDict, dictWithSizeKey, dictWithManyKeys;
87
87
  var storedSize = 42;
88
- var testFontFile = 'file1';
89
- var testFontFile2 = 'file2';
90
- var testFontFile3 = 'file3';
88
+ var testFontFile = "file1";
89
+ var testFontFile2 = "file2";
90
+ var testFontFile3 = "file3";
91
91
  beforeAll(function (done) {
92
92
  emptyDict = new _primitives.Dict();
93
93
  dictWithSizeKey = new _primitives.Dict();
94
- dictWithSizeKey.set('Size', storedSize);
94
+ dictWithSizeKey.set("Size", storedSize);
95
95
  dictWithManyKeys = new _primitives.Dict();
96
- dictWithManyKeys.set('FontFile', testFontFile);
97
- dictWithManyKeys.set('FontFile2', testFontFile2);
98
- dictWithManyKeys.set('FontFile3', testFontFile3);
96
+ dictWithManyKeys.set("FontFile", testFontFile);
97
+ dictWithManyKeys.set("FontFile2", testFontFile2);
98
+ dictWithManyKeys.set("FontFile3", testFontFile3);
99
99
  done();
100
100
  });
101
101
  afterAll(function () {
102
102
  emptyDict = dictWithSizeKey = dictWithManyKeys = null;
103
103
  });
104
- it('should return invalid values for unknown keys', function () {
104
+ it("should return invalid values for unknown keys", function () {
105
105
  checkInvalidHasValues(emptyDict);
106
106
  checkInvalidKeyValues(emptyDict);
107
107
  });
108
- it('should return correct value for stored Size key', function () {
109
- expect(dictWithSizeKey.has('Size')).toBeTruthy();
110
- expect(dictWithSizeKey.get('Size')).toEqual(storedSize);
111
- expect(dictWithSizeKey.get('Prev', 'Size')).toEqual(storedSize);
112
- expect(dictWithSizeKey.get('Prev', 'Root', 'Size')).toEqual(storedSize);
108
+ it("should return correct value for stored Size key", function () {
109
+ expect(dictWithSizeKey.has("Size")).toBeTruthy();
110
+ expect(dictWithSizeKey.get("Size")).toEqual(storedSize);
111
+ expect(dictWithSizeKey.get("Prev", "Size")).toEqual(storedSize);
112
+ expect(dictWithSizeKey.get("Prev", "Root", "Size")).toEqual(storedSize);
113
113
  });
114
- it('should return invalid values for unknown keys when Size key is stored', function () {
114
+ it("should return invalid values for unknown keys when Size key is stored", function () {
115
115
  checkInvalidHasValues(dictWithSizeKey);
116
116
  checkInvalidKeyValues(dictWithSizeKey);
117
117
  });
118
- it('should return correct value for stored Size key with undefined value', function () {
119
- var dict = new _primitives.Dict();
120
- dict.set('Size');
121
- expect(dict.has('Size')).toBeTruthy();
118
+ it("should not accept to set a key with an undefined value", function () {
119
+ const dict = new _primitives.Dict();
120
+ expect(function () {
121
+ dict.set("Size");
122
+ }).toThrow(new Error('Dict.set: The "value" cannot be undefined.'));
123
+ expect(dict.has("Size")).toBeFalsy();
122
124
  checkInvalidKeyValues(dict);
123
125
  });
124
- it('should return correct values for multiple stored keys', function () {
125
- expect(dictWithManyKeys.has('FontFile')).toBeTruthy();
126
- expect(dictWithManyKeys.has('FontFile2')).toBeTruthy();
127
- expect(dictWithManyKeys.has('FontFile3')).toBeTruthy();
128
- expect(dictWithManyKeys.get('FontFile3')).toEqual(testFontFile3);
129
- expect(dictWithManyKeys.get('FontFile2', 'FontFile3')).toEqual(testFontFile2);
130
- expect(dictWithManyKeys.get('FontFile', 'FontFile2', 'FontFile3')).toEqual(testFontFile);
126
+ it("should return correct values for multiple stored keys", function () {
127
+ expect(dictWithManyKeys.has("FontFile")).toBeTruthy();
128
+ expect(dictWithManyKeys.has("FontFile2")).toBeTruthy();
129
+ expect(dictWithManyKeys.has("FontFile3")).toBeTruthy();
130
+ expect(dictWithManyKeys.get("FontFile3")).toEqual(testFontFile3);
131
+ expect(dictWithManyKeys.get("FontFile2", "FontFile3")).toEqual(testFontFile2);
132
+ expect(dictWithManyKeys.get("FontFile", "FontFile2", "FontFile3")).toEqual(testFontFile);
131
133
  });
132
- it('should asynchronously fetch unknown keys', function (done) {
133
- var keyPromises = [dictWithManyKeys.getAsync('Size'), dictWithSizeKey.getAsync('FontFile', 'FontFile2', 'FontFile3')];
134
+ it("should asynchronously fetch unknown keys", function (done) {
135
+ var keyPromises = [dictWithManyKeys.getAsync("Size"), dictWithSizeKey.getAsync("FontFile", "FontFile2", "FontFile3")];
134
136
  Promise.all(keyPromises).then(function (values) {
135
137
  expect(values[0]).toBeUndefined();
136
138
  expect(values[1]).toBeUndefined();
137
139
  done();
138
- })["catch"](function (reason) {
140
+ }).catch(function (reason) {
139
141
  done.fail(reason);
140
142
  });
141
143
  });
142
- it('should asynchronously fetch correct values for multiple stored keys', function (done) {
143
- var keyPromises = [dictWithManyKeys.getAsync('FontFile3'), dictWithManyKeys.getAsync('FontFile2', 'FontFile3'), dictWithManyKeys.getAsync('FontFile', 'FontFile2', 'FontFile3')];
144
+ it("should asynchronously fetch correct values for multiple stored keys", function (done) {
145
+ var keyPromises = [dictWithManyKeys.getAsync("FontFile3"), dictWithManyKeys.getAsync("FontFile2", "FontFile3"), dictWithManyKeys.getAsync("FontFile", "FontFile2", "FontFile3")];
144
146
  Promise.all(keyPromises).then(function (values) {
145
147
  expect(values[0]).toEqual(testFontFile3);
146
148
  expect(values[1]).toEqual(testFontFile2);
147
149
  expect(values[2]).toEqual(testFontFile);
148
150
  done();
149
- })["catch"](function (reason) {
151
+ }).catch(function (reason) {
150
152
  done.fail(reason);
151
153
  });
152
154
  });
153
- it('should callback for each stored key', function () {
154
- var callbackSpy = jasmine.createSpy('spy on callback in dictionary');
155
+ it("should callback for each stored key", function () {
156
+ var callbackSpy = jasmine.createSpy("spy on callback in dictionary");
155
157
  dictWithManyKeys.forEach(callbackSpy);
156
158
  expect(callbackSpy).toHaveBeenCalled();
157
159
  var callbackSpyCalls = callbackSpy.calls;
158
- expect(callbackSpyCalls.argsFor(0)).toEqual(['FontFile', testFontFile]);
159
- expect(callbackSpyCalls.argsFor(1)).toEqual(['FontFile2', testFontFile2]);
160
- expect(callbackSpyCalls.argsFor(2)).toEqual(['FontFile3', testFontFile3]);
160
+ expect(callbackSpyCalls.argsFor(0)).toEqual(["FontFile", testFontFile]);
161
+ expect(callbackSpyCalls.argsFor(1)).toEqual(["FontFile2", testFontFile2]);
162
+ expect(callbackSpyCalls.argsFor(2)).toEqual(["FontFile3", testFontFile3]);
161
163
  expect(callbackSpyCalls.count()).toEqual(3);
162
164
  });
163
- it('should handle keys pointing to indirect objects, both sync and async', function (done) {
165
+ it("should handle keys pointing to indirect objects, both sync and async", function (done) {
164
166
  var fontRef = _primitives.Ref.get(1, 0);
165
167
 
166
168
  var xref = new _test_utils.XRefMock([{
@@ -168,17 +170,17 @@ describe('primitives', function () {
168
170
  data: testFontFile
169
171
  }]);
170
172
  var fontDict = new _primitives.Dict(xref);
171
- fontDict.set('FontFile', fontRef);
172
- expect(fontDict.getRaw('FontFile')).toEqual(fontRef);
173
- expect(fontDict.get('FontFile', 'FontFile2', 'FontFile3')).toEqual(testFontFile);
174
- fontDict.getAsync('FontFile', 'FontFile2', 'FontFile3').then(function (value) {
173
+ fontDict.set("FontFile", fontRef);
174
+ expect(fontDict.getRaw("FontFile")).toEqual(fontRef);
175
+ expect(fontDict.get("FontFile", "FontFile2", "FontFile3")).toEqual(testFontFile);
176
+ fontDict.getAsync("FontFile", "FontFile2", "FontFile3").then(function (value) {
175
177
  expect(value).toEqual(testFontFile);
176
178
  done();
177
- })["catch"](function (reason) {
179
+ }).catch(function (reason) {
178
180
  done.fail(reason);
179
181
  });
180
182
  });
181
- it('should handle arrays containing indirect objects', function () {
183
+ it("should handle arrays containing indirect objects", function () {
182
184
  var minCoordRef = _primitives.Ref.get(1, 0),
183
185
  maxCoordRef = _primitives.Ref.get(2, 0);
184
186
 
@@ -192,35 +194,35 @@ describe('primitives', function () {
192
194
  data: maxCoord
193
195
  }]);
194
196
  var xObjectDict = new _primitives.Dict(xref);
195
- xObjectDict.set('BBox', [minCoord, maxCoord, minCoordRef, maxCoordRef]);
196
- expect(xObjectDict.get('BBox')).toEqual([minCoord, maxCoord, minCoordRef, maxCoordRef]);
197
- expect(xObjectDict.getArray('BBox')).toEqual([minCoord, maxCoord, minCoord, maxCoord]);
197
+ xObjectDict.set("BBox", [minCoord, maxCoord, minCoordRef, maxCoordRef]);
198
+ expect(xObjectDict.get("BBox")).toEqual([minCoord, maxCoord, minCoordRef, maxCoordRef]);
199
+ expect(xObjectDict.getArray("BBox")).toEqual([minCoord, maxCoord, minCoord, maxCoord]);
198
200
  });
199
- it('should get all key names', function () {
200
- var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3'];
201
+ it("should get all key names", function () {
202
+ var expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
201
203
  var keys = dictWithManyKeys.getKeys();
202
204
  expect(keys.sort()).toEqual(expectedKeys);
203
205
  });
204
- it('should create only one object for Dict.empty', function () {
206
+ it("should create only one object for Dict.empty", function () {
205
207
  var firstDictEmpty = _primitives.Dict.empty;
206
208
  var secondDictEmpty = _primitives.Dict.empty;
207
209
  expect(firstDictEmpty).toBe(secondDictEmpty);
208
210
  expect(firstDictEmpty).not.toBe(emptyDict);
209
211
  });
210
- it('should correctly merge dictionaries', function () {
211
- var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3', 'Size'];
212
+ it("should correctly merge dictionaries", function () {
213
+ var expectedKeys = ["FontFile", "FontFile2", "FontFile3", "Size"];
212
214
  var fontFileDict = new _primitives.Dict();
213
- fontFileDict.set('FontFile', 'Type1 font file');
215
+ fontFileDict.set("FontFile", "Type1 font file");
214
216
 
215
217
  var mergedDict = _primitives.Dict.merge(null, [dictWithManyKeys, dictWithSizeKey, fontFileDict]);
216
218
 
217
219
  var mergedKeys = mergedDict.getKeys();
218
220
  expect(mergedKeys.sort()).toEqual(expectedKeys);
219
- expect(mergedDict.get('FontFile')).toEqual(testFontFile);
221
+ expect(mergedDict.get("FontFile")).toEqual(testFontFile);
220
222
  });
221
223
  });
222
- describe('Ref', function () {
223
- it('should retain the stored values', function () {
224
+ describe("Ref", function () {
225
+ it("should retain the stored values", function () {
224
226
  var storedNum = 4;
225
227
  var storedGen = 2;
226
228
 
@@ -230,15 +232,15 @@ describe('primitives', function () {
230
232
  expect(ref.gen).toEqual(storedGen);
231
233
  });
232
234
  });
233
- describe('RefSet', function () {
234
- it('should have a stored value', function () {
235
+ describe("RefSet", function () {
236
+ it("should have a stored value", function () {
235
237
  var ref = _primitives.Ref.get(4, 2);
236
238
 
237
239
  var refset = new _primitives.RefSet();
238
240
  refset.put(ref);
239
241
  expect(refset.has(ref)).toBeTruthy();
240
242
  });
241
- it('should not have an unknown value', function () {
243
+ it("should not have an unknown value", function () {
242
244
  var ref = _primitives.Ref.get(4, 2);
243
245
 
244
246
  var refset = new _primitives.RefSet();
@@ -250,77 +252,77 @@ describe('primitives', function () {
250
252
  expect(refset.has(anotherRef)).toBeFalsy();
251
253
  });
252
254
  });
253
- describe('isName', function () {
254
- it('handles non-names', function () {
255
+ describe("isName", function () {
256
+ it("handles non-names", function () {
255
257
  var nonName = {};
256
258
  expect((0, _primitives.isName)(nonName)).toEqual(false);
257
259
  });
258
- it('handles names', function () {
259
- var name = _primitives.Name.get('Font');
260
+ it("handles names", function () {
261
+ var name = _primitives.Name.get("Font");
260
262
 
261
263
  expect((0, _primitives.isName)(name)).toEqual(true);
262
264
  });
263
- it('handles names with name check', function () {
264
- var name = _primitives.Name.get('Font');
265
+ it("handles names with name check", function () {
266
+ var name = _primitives.Name.get("Font");
265
267
 
266
- expect((0, _primitives.isName)(name, 'Font')).toEqual(true);
267
- expect((0, _primitives.isName)(name, 'Subtype')).toEqual(false);
268
+ expect((0, _primitives.isName)(name, "Font")).toEqual(true);
269
+ expect((0, _primitives.isName)(name, "Subtype")).toEqual(false);
268
270
  });
269
271
  });
270
- describe('isCmd', function () {
271
- it('handles non-commands', function () {
272
+ describe("isCmd", function () {
273
+ it("handles non-commands", function () {
272
274
  var nonCmd = {};
273
275
  expect((0, _primitives.isCmd)(nonCmd)).toEqual(false);
274
276
  });
275
- it('handles commands', function () {
276
- var cmd = _primitives.Cmd.get('BT');
277
+ it("handles commands", function () {
278
+ var cmd = _primitives.Cmd.get("BT");
277
279
 
278
280
  expect((0, _primitives.isCmd)(cmd)).toEqual(true);
279
281
  });
280
- it('handles commands with cmd check', function () {
281
- var cmd = _primitives.Cmd.get('BT');
282
+ it("handles commands with cmd check", function () {
283
+ var cmd = _primitives.Cmd.get("BT");
282
284
 
283
- expect((0, _primitives.isCmd)(cmd, 'BT')).toEqual(true);
284
- expect((0, _primitives.isCmd)(cmd, 'ET')).toEqual(false);
285
+ expect((0, _primitives.isCmd)(cmd, "BT")).toEqual(true);
286
+ expect((0, _primitives.isCmd)(cmd, "ET")).toEqual(false);
285
287
  });
286
288
  });
287
- describe('isDict', function () {
288
- it('handles non-dictionaries', function () {
289
+ describe("isDict", function () {
290
+ it("handles non-dictionaries", function () {
289
291
  var nonDict = {};
290
292
  expect((0, _primitives.isDict)(nonDict)).toEqual(false);
291
293
  });
292
- it('handles empty dictionaries with type check', function () {
294
+ it("handles empty dictionaries with type check", function () {
293
295
  var dict = _primitives.Dict.empty;
294
296
  expect((0, _primitives.isDict)(dict)).toEqual(true);
295
- expect((0, _primitives.isDict)(dict, 'Page')).toEqual(false);
297
+ expect((0, _primitives.isDict)(dict, "Page")).toEqual(false);
296
298
  });
297
- it('handles dictionaries with type check', function () {
299
+ it("handles dictionaries with type check", function () {
298
300
  var dict = new _primitives.Dict();
299
- dict.set('Type', _primitives.Name.get('Page'));
300
- expect((0, _primitives.isDict)(dict, 'Page')).toEqual(true);
301
- expect((0, _primitives.isDict)(dict, 'Contents')).toEqual(false);
301
+ dict.set("Type", _primitives.Name.get("Page"));
302
+ expect((0, _primitives.isDict)(dict, "Page")).toEqual(true);
303
+ expect((0, _primitives.isDict)(dict, "Contents")).toEqual(false);
302
304
  });
303
305
  });
304
- describe('isRef', function () {
305
- it('handles non-refs', function () {
306
+ describe("isRef", function () {
307
+ it("handles non-refs", function () {
306
308
  var nonRef = {};
307
309
  expect((0, _primitives.isRef)(nonRef)).toEqual(false);
308
310
  });
309
- it('handles refs', function () {
311
+ it("handles refs", function () {
310
312
  var ref = _primitives.Ref.get(1, 0);
311
313
 
312
314
  expect((0, _primitives.isRef)(ref)).toEqual(true);
313
315
  });
314
316
  });
315
- describe('isRefsEqual', function () {
316
- it('should handle Refs pointing to the same object', function () {
317
+ describe("isRefsEqual", function () {
318
+ it("should handle Refs pointing to the same object", function () {
317
319
  var ref1 = _primitives.Ref.get(1, 0);
318
320
 
319
321
  var ref2 = _primitives.Ref.get(1, 0);
320
322
 
321
323
  expect((0, _primitives.isRefsEqual)(ref1, ref2)).toEqual(true);
322
324
  });
323
- it('should handle Refs pointing to different objects', function () {
325
+ it("should handle Refs pointing to different objects", function () {
324
326
  var ref1 = _primitives.Ref.get(1, 0);
325
327
 
326
328
  var ref2 = _primitives.Ref.get(2, 0);