pdfjs-dist 2.1.266 → 2.5.207

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 (191) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8382 -18492
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +20417 -29816
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25688 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +58239 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +403 -0
  29. package/es5/web/pdf_viewer.js +7742 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +1475 -4897
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +750 -899
  36. package/lib/core/arithmetic_decoder.js +81 -97
  37. package/lib/core/bidi.js +54 -46
  38. package/lib/core/ccitt.js +88 -81
  39. package/lib/core/ccitt_stream.js +15 -14
  40. package/lib/core/cff_parser.js +235 -183
  41. package/lib/core/charsets.js +4 -4
  42. package/lib/core/chunked_stream.js +447 -542
  43. package/lib/core/cmap.js +222 -264
  44. package/lib/core/colorspace.js +699 -863
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +379 -437
  47. package/lib/core/document.js +573 -660
  48. package/lib/core/encodings.js +15 -15
  49. package/lib/core/evaluator.js +1103 -868
  50. package/lib/core/font_renderer.js +135 -178
  51. package/lib/core/fonts.js +570 -491
  52. package/lib/core/function.js +291 -288
  53. package/lib/core/glyphlist.js +4527 -4526
  54. package/lib/core/image.js +145 -149
  55. package/lib/core/image_utils.js +170 -0
  56. package/lib/core/jbig2.js +325 -316
  57. package/lib/core/jbig2_stream.js +18 -17
  58. package/lib/core/jpeg_stream.js +21 -26
  59. package/lib/core/jpg.js +284 -232
  60. package/lib/core/jpx.js +161 -143
  61. package/lib/core/jpx_stream.js +28 -28
  62. package/lib/core/metrics.js +2929 -2929
  63. package/lib/core/murmurhash3.js +90 -101
  64. package/lib/core/obj.js +1183 -1157
  65. package/lib/core/operator_list.js +99 -67
  66. package/lib/core/parser.js +972 -911
  67. package/lib/core/pattern.js +87 -70
  68. package/lib/core/pdf_manager.js +150 -315
  69. package/lib/core/primitives.js +83 -56
  70. package/lib/core/ps_parser.js +175 -214
  71. package/lib/core/standard_fonts.js +237 -236
  72. package/lib/core/stream.js +94 -74
  73. package/lib/core/type1_parser.js +87 -69
  74. package/lib/core/unicode.js +1654 -1654
  75. package/lib/core/worker.js +193 -390
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +741 -972
  78. package/lib/display/api.js +1500 -1791
  79. package/lib/display/api_compatibility.js +12 -17
  80. package/lib/display/canvas.js +165 -165
  81. package/lib/display/content_disposition.js +40 -59
  82. package/lib/display/display_utils.js +515 -0
  83. package/lib/display/fetch_stream.js +183 -298
  84. package/lib/display/font_loader.js +273 -413
  85. package/lib/display/metadata.js +86 -98
  86. package/lib/display/network.js +266 -359
  87. package/lib/display/network_utils.js +25 -18
  88. package/lib/display/node_stream.js +285 -458
  89. package/lib/display/pattern_helper.js +113 -65
  90. package/lib/display/svg.js +1166 -901
  91. package/lib/display/text_layer.js +156 -132
  92. package/lib/display/transport_stream.js +262 -278
  93. package/lib/display/webgl.js +70 -83
  94. package/lib/display/worker_options.js +3 -3
  95. package/lib/display/xml_parser.js +303 -392
  96. package/lib/examples/node/domstubs.js +40 -37
  97. package/lib/pdf.js +226 -59
  98. package/lib/pdf.worker.js +14 -6
  99. package/lib/shared/compatibility.js +3 -246
  100. package/lib/shared/is_node.js +7 -6
  101. package/lib/shared/message_handler.js +327 -332
  102. package/lib/shared/util.js +266 -416
  103. package/lib/test/unit/annotation_spec.js +1555 -701
  104. package/lib/test/unit/api_spec.js +802 -604
  105. package/lib/test/unit/bidi_spec.js +7 -7
  106. package/lib/test/unit/cff_parser_spec.js +84 -69
  107. package/lib/test/unit/clitests_helper.js +7 -9
  108. package/lib/test/unit/cmap_spec.js +74 -76
  109. package/lib/test/unit/colorspace_spec.js +166 -161
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +181 -181
  112. package/lib/test/unit/custom_spec.js +20 -22
  113. package/lib/test/unit/display_svg_spec.js +34 -39
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +16 -21
  116. package/lib/test/unit/encodings_spec.js +12 -34
  117. package/lib/test/unit/evaluator_spec.js +83 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +206 -204
  120. package/lib/test/unit/jasmine-boot.js +46 -30
  121. package/lib/test/unit/message_handler_spec.js +173 -159
  122. package/lib/test/unit/metadata_spec.js +69 -69
  123. package/lib/test/unit/murmurhash3_spec.js +12 -12
  124. package/lib/test/unit/network_spec.js +13 -61
  125. package/lib/test/unit/network_utils_spec.js +183 -119
  126. package/lib/test/unit/node_stream_spec.js +78 -92
  127. package/lib/test/unit/parser_spec.js +172 -114
  128. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  129. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  130. package/lib/test/unit/pdf_history_spec.js +32 -32
  131. package/lib/test/unit/primitives_spec.js +140 -125
  132. package/lib/test/unit/stream_spec.js +16 -14
  133. package/lib/test/unit/test_utils.js +131 -143
  134. package/lib/test/unit/testreporter.js +19 -19
  135. package/lib/test/unit/type1_parser_spec.js +42 -42
  136. package/lib/test/unit/ui_utils_spec.js +297 -459
  137. package/lib/test/unit/unicode_spec.js +38 -38
  138. package/lib/test/unit/util_spec.js +121 -305
  139. package/lib/web/annotation_layer_builder.js +66 -103
  140. package/lib/web/app.js +1328 -1214
  141. package/lib/web/app_options.js +105 -107
  142. package/lib/web/base_viewer.js +824 -838
  143. package/lib/web/chromecom.js +165 -252
  144. package/lib/web/debugger.js +149 -205
  145. package/lib/web/download_manager.js +39 -55
  146. package/lib/web/firefox_print_service.js +37 -27
  147. package/lib/web/firefoxcom.js +212 -363
  148. package/lib/web/genericcom.js +26 -108
  149. package/lib/web/genericl10n.js +24 -153
  150. package/lib/web/grab_to_pan.js +32 -30
  151. package/lib/web/interfaces.js +80 -254
  152. package/lib/web/overlay_manager.js +70 -246
  153. package/lib/web/password_prompt.js +38 -64
  154. package/lib/web/pdf_attachment_viewer.js +113 -131
  155. package/lib/web/pdf_cursor_tools.js +75 -102
  156. package/lib/web/pdf_document_properties.js +221 -306
  157. package/lib/web/pdf_find_bar.js +136 -170
  158. package/lib/web/pdf_find_controller.js +491 -548
  159. package/lib/web/pdf_find_utils.js +13 -13
  160. package/lib/web/pdf_history.js +397 -406
  161. package/lib/web/pdf_link_service.js +304 -348
  162. package/lib/web/pdf_outline_viewer.js +140 -175
  163. package/lib/web/pdf_page_view.js +452 -523
  164. package/lib/web/pdf_presentation_mode.js +308 -357
  165. package/lib/web/pdf_print_service.js +90 -104
  166. package/lib/web/pdf_rendering_queue.js +84 -108
  167. package/lib/web/pdf_sidebar.js +276 -306
  168. package/lib/web/pdf_sidebar_resizer.js +92 -119
  169. package/lib/web/pdf_single_page_viewer.js +77 -126
  170. package/lib/web/pdf_thumbnail_view.js +276 -297
  171. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  172. package/lib/web/pdf_viewer.component.js +20 -21
  173. package/lib/web/pdf_viewer.js +55 -115
  174. package/lib/web/preferences.js +82 -286
  175. package/lib/web/secondary_toolbar.js +164 -196
  176. package/lib/web/text_layer_builder.js +282 -339
  177. package/lib/web/toolbar.js +217 -210
  178. package/lib/web/ui_utils.js +267 -420
  179. package/lib/web/view_history.js +52 -226
  180. package/lib/web/viewer_compatibility.js +21 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +35 -25
  183. package/web/pdf_viewer.js +3489 -4855
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -494
  189. package/lib/shared/streams_polyfill.js +0 -43
  190. package/lib/shared/url_polyfill.js +0 -56
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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 2018 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 2018 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 2018 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,126 +21,128 @@
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')).toBeNull();
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
- expect(values[1]).toBeNull();
138
+ expect(values[1]).toBeUndefined();
137
139
  done();
138
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);
@@ -150,36 +152,38 @@ describe('primitives', function () {
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) {
164
- var fontRef = new _primitives.Ref(1, 0);
165
+ it("should handle keys pointing to indirect objects, both sync and async", function (done) {
166
+ var fontRef = _primitives.Ref.get(1, 0);
167
+
165
168
  var xref = new _test_utils.XRefMock([{
166
169
  ref: fontRef,
167
170
  data: testFontFile
168
171
  }]);
169
172
  var fontDict = new _primitives.Dict(xref);
170
- fontDict.set('FontFile', fontRef);
171
- expect(fontDict.getRaw('FontFile')).toEqual(fontRef);
172
- expect(fontDict.get('FontFile', 'FontFile2', 'FontFile3')).toEqual(testFontFile);
173
- 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) {
174
177
  expect(value).toEqual(testFontFile);
175
178
  done();
176
179
  }).catch(function (reason) {
177
180
  done.fail(reason);
178
181
  });
179
182
  });
180
- it('should handle arrays containing indirect objects', function () {
181
- var minCoordRef = new _primitives.Ref(1, 0),
182
- maxCoordRef = new _primitives.Ref(2, 0);
183
+ it("should handle arrays containing indirect objects", function () {
184
+ var minCoordRef = _primitives.Ref.get(1, 0),
185
+ maxCoordRef = _primitives.Ref.get(2, 0);
186
+
183
187
  var minCoord = 0,
184
188
  maxCoord = 1;
185
189
  var xref = new _test_utils.XRefMock([{
@@ -190,128 +194,139 @@ describe('primitives', function () {
190
194
  data: maxCoord
191
195
  }]);
192
196
  var xObjectDict = new _primitives.Dict(xref);
193
- xObjectDict.set('BBox', [minCoord, maxCoord, minCoordRef, maxCoordRef]);
194
- expect(xObjectDict.get('BBox')).toEqual([minCoord, maxCoord, minCoordRef, maxCoordRef]);
195
- 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]);
196
200
  });
197
- it('should get all key names', function () {
198
- var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3'];
201
+ it("should get all key names", function () {
202
+ var expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
199
203
  var keys = dictWithManyKeys.getKeys();
200
204
  expect(keys.sort()).toEqual(expectedKeys);
201
205
  });
202
- it('should create only one object for Dict.empty', function () {
206
+ it("should create only one object for Dict.empty", function () {
203
207
  var firstDictEmpty = _primitives.Dict.empty;
204
208
  var secondDictEmpty = _primitives.Dict.empty;
205
209
  expect(firstDictEmpty).toBe(secondDictEmpty);
206
210
  expect(firstDictEmpty).not.toBe(emptyDict);
207
211
  });
208
- it('should correctly merge dictionaries', function () {
209
- var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3', 'Size'];
212
+ it("should correctly merge dictionaries", function () {
213
+ var expectedKeys = ["FontFile", "FontFile2", "FontFile3", "Size"];
210
214
  var fontFileDict = new _primitives.Dict();
211
- fontFileDict.set('FontFile', 'Type1 font file');
215
+ fontFileDict.set("FontFile", "Type1 font file");
212
216
 
213
217
  var mergedDict = _primitives.Dict.merge(null, [dictWithManyKeys, dictWithSizeKey, fontFileDict]);
214
218
 
215
219
  var mergedKeys = mergedDict.getKeys();
216
220
  expect(mergedKeys.sort()).toEqual(expectedKeys);
217
- expect(mergedDict.get('FontFile')).toEqual(testFontFile);
221
+ expect(mergedDict.get("FontFile")).toEqual(testFontFile);
218
222
  });
219
223
  });
220
- describe('Ref', function () {
221
- it('should retain the stored values', function () {
224
+ describe("Ref", function () {
225
+ it("should retain the stored values", function () {
222
226
  var storedNum = 4;
223
227
  var storedGen = 2;
224
- var ref = new _primitives.Ref(storedNum, storedGen);
228
+
229
+ var ref = _primitives.Ref.get(storedNum, storedGen);
230
+
225
231
  expect(ref.num).toEqual(storedNum);
226
232
  expect(ref.gen).toEqual(storedGen);
227
233
  });
228
234
  });
229
- describe('RefSet', function () {
230
- it('should have a stored value', function () {
231
- var ref = new _primitives.Ref(4, 2);
235
+ describe("RefSet", function () {
236
+ it("should have a stored value", function () {
237
+ var ref = _primitives.Ref.get(4, 2);
238
+
232
239
  var refset = new _primitives.RefSet();
233
240
  refset.put(ref);
234
241
  expect(refset.has(ref)).toBeTruthy();
235
242
  });
236
- it('should not have an unknown value', function () {
237
- var ref = new _primitives.Ref(4, 2);
243
+ it("should not have an unknown value", function () {
244
+ var ref = _primitives.Ref.get(4, 2);
245
+
238
246
  var refset = new _primitives.RefSet();
239
247
  expect(refset.has(ref)).toBeFalsy();
240
248
  refset.put(ref);
241
- var anotherRef = new _primitives.Ref(2, 4);
249
+
250
+ var anotherRef = _primitives.Ref.get(2, 4);
251
+
242
252
  expect(refset.has(anotherRef)).toBeFalsy();
243
253
  });
244
254
  });
245
- describe('isName', function () {
246
- it('handles non-names', function () {
255
+ describe("isName", function () {
256
+ it("handles non-names", function () {
247
257
  var nonName = {};
248
258
  expect((0, _primitives.isName)(nonName)).toEqual(false);
249
259
  });
250
- it('handles names', function () {
251
- var name = _primitives.Name.get('Font');
260
+ it("handles names", function () {
261
+ var name = _primitives.Name.get("Font");
252
262
 
253
263
  expect((0, _primitives.isName)(name)).toEqual(true);
254
264
  });
255
- it('handles names with name check', function () {
256
- var name = _primitives.Name.get('Font');
265
+ it("handles names with name check", function () {
266
+ var name = _primitives.Name.get("Font");
257
267
 
258
- expect((0, _primitives.isName)(name, 'Font')).toEqual(true);
259
- 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);
260
270
  });
261
271
  });
262
- describe('isCmd', function () {
263
- it('handles non-commands', function () {
272
+ describe("isCmd", function () {
273
+ it("handles non-commands", function () {
264
274
  var nonCmd = {};
265
275
  expect((0, _primitives.isCmd)(nonCmd)).toEqual(false);
266
276
  });
267
- it('handles commands', function () {
268
- var cmd = _primitives.Cmd.get('BT');
277
+ it("handles commands", function () {
278
+ var cmd = _primitives.Cmd.get("BT");
269
279
 
270
280
  expect((0, _primitives.isCmd)(cmd)).toEqual(true);
271
281
  });
272
- it('handles commands with cmd check', function () {
273
- var cmd = _primitives.Cmd.get('BT');
282
+ it("handles commands with cmd check", function () {
283
+ var cmd = _primitives.Cmd.get("BT");
274
284
 
275
- expect((0, _primitives.isCmd)(cmd, 'BT')).toEqual(true);
276
- 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);
277
287
  });
278
288
  });
279
- describe('isDict', function () {
280
- it('handles non-dictionaries', function () {
289
+ describe("isDict", function () {
290
+ it("handles non-dictionaries", function () {
281
291
  var nonDict = {};
282
292
  expect((0, _primitives.isDict)(nonDict)).toEqual(false);
283
293
  });
284
- it('handles empty dictionaries with type check', function () {
294
+ it("handles empty dictionaries with type check", function () {
285
295
  var dict = _primitives.Dict.empty;
286
296
  expect((0, _primitives.isDict)(dict)).toEqual(true);
287
- expect((0, _primitives.isDict)(dict, 'Page')).toEqual(false);
297
+ expect((0, _primitives.isDict)(dict, "Page")).toEqual(false);
288
298
  });
289
- it('handles dictionaries with type check', function () {
299
+ it("handles dictionaries with type check", function () {
290
300
  var dict = new _primitives.Dict();
291
- dict.set('Type', _primitives.Name.get('Page'));
292
- expect((0, _primitives.isDict)(dict, 'Page')).toEqual(true);
293
- 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);
294
304
  });
295
305
  });
296
- describe('isRef', function () {
297
- it('handles non-refs', function () {
306
+ describe("isRef", function () {
307
+ it("handles non-refs", function () {
298
308
  var nonRef = {};
299
309
  expect((0, _primitives.isRef)(nonRef)).toEqual(false);
300
310
  });
301
- it('handles refs', function () {
302
- var ref = new _primitives.Ref(1, 0);
311
+ it("handles refs", function () {
312
+ var ref = _primitives.Ref.get(1, 0);
313
+
303
314
  expect((0, _primitives.isRef)(ref)).toEqual(true);
304
315
  });
305
316
  });
306
- describe('isRefsEqual', function () {
307
- it('should handle different Refs pointing to the same object', function () {
308
- var ref1 = new _primitives.Ref(1, 0);
309
- var ref2 = new _primitives.Ref(1, 0);
317
+ describe("isRefsEqual", function () {
318
+ it("should handle Refs pointing to the same object", function () {
319
+ var ref1 = _primitives.Ref.get(1, 0);
320
+
321
+ var ref2 = _primitives.Ref.get(1, 0);
322
+
310
323
  expect((0, _primitives.isRefsEqual)(ref1, ref2)).toEqual(true);
311
324
  });
312
- it('should handle Refs pointing to different objects', function () {
313
- var ref1 = new _primitives.Ref(1, 0);
314
- var ref2 = new _primitives.Ref(2, 0);
325
+ it("should handle Refs pointing to different objects", function () {
326
+ var ref1 = _primitives.Ref.get(1, 0);
327
+
328
+ var ref2 = _primitives.Ref.get(2, 0);
329
+
315
330
  expect((0, _primitives.isRefsEqual)(ref1, ref2)).toEqual(false);
316
331
  });
317
332
  });