pdfjs-dist 2.0.943 → 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 (192) 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 +8286 -14230
  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 +25500 -26628
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25473 -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 +57878 -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 +407 -0
  29. package/es5/web/pdf_viewer.js +7757 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +2887 -4094
  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 +855 -778
  36. package/lib/core/arithmetic_decoder.js +325 -311
  37. package/lib/core/bidi.js +117 -50
  38. package/lib/core/ccitt.js +251 -89
  39. package/lib/core/ccitt_stream.js +26 -16
  40. package/lib/core/cff_parser.js +525 -197
  41. package/lib/core/charsets.js +6 -5
  42. package/lib/core/chunked_stream.js +541 -406
  43. package/lib/core/cmap.js +368 -253
  44. package/lib/core/colorspace.js +781 -800
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +609 -422
  47. package/lib/core/document.js +649 -481
  48. package/lib/core/encodings.js +33 -24
  49. package/lib/core/evaluator.js +1471 -736
  50. package/lib/core/font_renderer.js +289 -149
  51. package/lib/core/fonts.js +1067 -413
  52. package/lib/core/function.js +517 -287
  53. package/lib/core/glyphlist.js +4529 -4527
  54. package/lib/core/image.js +232 -114
  55. package/lib/core/image_utils.js +94 -0
  56. package/lib/core/jbig2.js +711 -342
  57. package/lib/core/jbig2_stream.js +31 -19
  58. package/lib/core/jpeg_stream.js +151 -26
  59. package/lib/core/jpg.js +433 -181
  60. package/lib/core/jpx.js +551 -143
  61. package/lib/core/jpx_stream.js +40 -28
  62. package/lib/core/metrics.js +2931 -2931
  63. package/lib/core/murmurhash3.js +104 -97
  64. package/lib/core/obj.js +1561 -1053
  65. package/lib/core/operator_list.js +192 -64
  66. package/lib/core/parser.js +1162 -864
  67. package/lib/core/pattern.js +224 -75
  68. package/lib/core/pdf_manager.js +154 -285
  69. package/lib/core/primitives.js +145 -69
  70. package/lib/core/ps_parser.js +212 -162
  71. package/lib/core/standard_fonts.js +245 -244
  72. package/lib/core/stream.js +353 -81
  73. package/lib/core/type1_parser.js +218 -68
  74. package/lib/core/unicode.js +1682 -1655
  75. package/lib/core/worker.js +233 -302
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +808 -862
  78. package/lib/display/api.js +1778 -1462
  79. package/lib/display/api_compatibility.js +14 -9
  80. package/lib/display/canvas.js +463 -140
  81. package/lib/display/content_disposition.js +86 -58
  82. package/lib/display/display_utils.js +524 -0
  83. package/lib/display/fetch_stream.js +202 -274
  84. package/lib/display/font_loader.js +311 -333
  85. package/lib/display/metadata.js +98 -88
  86. package/lib/display/network.js +343 -347
  87. package/lib/display/network_utils.js +46 -26
  88. package/lib/display/node_stream.js +326 -404
  89. package/lib/display/pattern_helper.js +168 -69
  90. package/lib/display/svg.js +1296 -885
  91. package/lib/display/text_layer.js +229 -103
  92. package/lib/display/transport_stream.js +290 -250
  93. package/lib/display/webgl.js +116 -83
  94. package/lib/display/worker_options.js +6 -5
  95. package/lib/display/xml_parser.js +358 -337
  96. package/lib/examples/node/domstubs.js +95 -39
  97. package/lib/pdf.js +49 -31
  98. package/lib/pdf.worker.js +7 -5
  99. package/lib/shared/compatibility.js +3 -145
  100. package/lib/shared/is_node.js +8 -7
  101. package/lib/shared/message_handler.js +367 -314
  102. package/lib/shared/util.js +421 -415
  103. package/lib/test/unit/annotation_spec.js +1570 -690
  104. package/lib/test/unit/api_spec.js +855 -493
  105. package/lib/test/unit/bidi_spec.js +12 -12
  106. package/lib/test/unit/cff_parser_spec.js +88 -61
  107. package/lib/test/unit/clitests_helper.js +9 -12
  108. package/lib/test/unit/cmap_spec.js +140 -88
  109. package/lib/test/unit/colorspace_spec.js +204 -152
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +194 -182
  112. package/lib/test/unit/custom_spec.js +50 -64
  113. package/lib/test/unit/display_svg_spec.js +53 -38
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +17 -22
  116. package/lib/test/unit/encodings_spec.js +15 -57
  117. package/lib/test/unit/evaluator_spec.js +90 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +219 -205
  120. package/lib/test/unit/jasmine-boot.js +68 -39
  121. package/lib/test/unit/message_handler_spec.js +187 -160
  122. package/lib/test/unit/metadata_spec.js +87 -34
  123. package/lib/test/unit/murmurhash3_spec.js +13 -13
  124. package/lib/test/unit/network_spec.js +26 -59
  125. package/lib/test/unit/network_utils_spec.js +187 -121
  126. package/lib/test/unit/node_stream_spec.js +98 -90
  127. package/lib/test/unit/parser_spec.js +173 -131
  128. package/lib/test/unit/pdf_find_controller_spec.js +148 -67
  129. package/lib/test/unit/pdf_find_utils_spec.js +35 -34
  130. package/lib/test/unit/pdf_history_spec.js +45 -33
  131. package/lib/test/unit/primitives_spec.js +161 -126
  132. package/lib/test/unit/stream_spec.js +22 -15
  133. package/lib/test/unit/test_utils.js +149 -98
  134. package/lib/test/unit/testreporter.js +36 -18
  135. package/lib/test/unit/type1_parser_spec.js +46 -44
  136. package/lib/test/unit/ui_utils_spec.js +388 -372
  137. package/lib/test/unit/unicode_spec.js +49 -46
  138. package/lib/test/unit/util_spec.js +144 -248
  139. package/lib/web/annotation_layer_builder.js +75 -95
  140. package/lib/web/app.js +1538 -1147
  141. package/lib/web/app_options.js +116 -104
  142. package/lib/web/base_viewer.js +950 -775
  143. package/lib/web/chromecom.js +217 -225
  144. package/lib/web/debugger.js +236 -148
  145. package/lib/web/download_manager.js +50 -50
  146. package/lib/web/firefox_print_service.js +51 -33
  147. package/lib/web/firefoxcom.js +225 -352
  148. package/lib/web/genericcom.js +30 -93
  149. package/lib/web/genericl10n.js +26 -143
  150. package/lib/web/grab_to_pan.js +57 -33
  151. package/lib/web/interfaces.js +105 -232
  152. package/lib/web/overlay_manager.js +73 -227
  153. package/lib/web/password_prompt.js +44 -62
  154. package/lib/web/pdf_attachment_viewer.js +118 -123
  155. package/lib/web/pdf_cursor_tools.js +89 -93
  156. package/lib/web/pdf_document_properties.js +242 -281
  157. package/lib/web/pdf_find_bar.js +157 -163
  158. package/lib/web/pdf_find_controller.js +598 -454
  159. package/lib/web/pdf_find_utils.js +32 -16
  160. package/lib/web/pdf_history.js +481 -355
  161. package/lib/web/pdf_link_service.js +355 -323
  162. package/lib/web/pdf_outline_viewer.js +167 -152
  163. package/lib/web/pdf_page_view.js +511 -457
  164. package/lib/web/pdf_presentation_mode.js +347 -335
  165. package/lib/web/pdf_print_service.js +133 -103
  166. package/lib/web/pdf_rendering_queue.js +98 -100
  167. package/lib/web/pdf_sidebar.js +323 -299
  168. package/lib/web/pdf_sidebar_resizer.js +107 -108
  169. package/lib/web/pdf_single_page_viewer.js +94 -146
  170. package/lib/web/pdf_thumbnail_view.js +319 -269
  171. package/lib/web/pdf_thumbnail_viewer.js +219 -199
  172. package/lib/web/pdf_viewer.component.js +111 -32
  173. package/lib/web/pdf_viewer.js +61 -101
  174. package/lib/web/preferences.js +87 -272
  175. package/lib/web/secondary_toolbar.js +207 -220
  176. package/lib/web/text_layer_builder.js +322 -322
  177. package/lib/web/toolbar.js +227 -180
  178. package/lib/web/ui_utils.js +476 -421
  179. package/lib/web/view_history.js +59 -208
  180. package/lib/web/viewer_compatibility.js +9 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +36 -22
  183. package/web/pdf_viewer.js +4407 -4516
  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 -441
  189. package/lib/shared/streams_polyfill.js +0 -39
  190. package/lib/shared/url_polyfill.js +0 -50
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
  192. package/lib/web/dom_events.js +0 -140
@@ -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.
@@ -19,114 +19,130 @@
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 _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
+
28
+ describe("primitives", function () {
29
+ describe("Name", function () {
30
+ it("should retain the given name", function () {
31
+ var givenName = "Font";
27
32
 
28
- describe('primitives', function () {
29
- describe('Name', function () {
30
- it('should retain the given name', function () {
31
- var givenName = 'Font';
32
33
  var name = _primitives.Name.get(givenName);
34
+
33
35
  expect(name.name).toEqual(givenName);
34
36
  });
35
- it('should create only one object for a name and cache it', function () {
36
- var firstFont = _primitives.Name.get('Font');
37
- var secondFont = _primitives.Name.get('Font');
38
- var firstSubtype = _primitives.Name.get('Subtype');
39
- var secondSubtype = _primitives.Name.get('Subtype');
37
+ it("should create only one object for a name and cache it", function () {
38
+ var firstFont = _primitives.Name.get("Font");
39
+
40
+ var secondFont = _primitives.Name.get("Font");
41
+
42
+ var firstSubtype = _primitives.Name.get("Subtype");
43
+
44
+ var secondSubtype = _primitives.Name.get("Subtype");
45
+
40
46
  expect(firstFont).toBe(secondFont);
41
47
  expect(firstSubtype).toBe(secondSubtype);
42
48
  expect(firstFont).not.toBe(firstSubtype);
43
49
  });
44
50
  });
45
- describe('Cmd', function () {
46
- it('should retain the given cmd name', function () {
47
- var givenCmd = 'BT';
51
+ describe("Cmd", function () {
52
+ it("should retain the given cmd name", function () {
53
+ var givenCmd = "BT";
54
+
48
55
  var cmd = _primitives.Cmd.get(givenCmd);
56
+
49
57
  expect(cmd.cmd).toEqual(givenCmd);
50
58
  });
51
- it('should create only one object for a command and cache it', function () {
52
- var firstBT = _primitives.Cmd.get('BT');
53
- var secondBT = _primitives.Cmd.get('BT');
54
- var firstET = _primitives.Cmd.get('ET');
55
- var secondET = _primitives.Cmd.get('ET');
59
+ it("should create only one object for a command and cache it", function () {
60
+ var firstBT = _primitives.Cmd.get("BT");
61
+
62
+ var secondBT = _primitives.Cmd.get("BT");
63
+
64
+ var firstET = _primitives.Cmd.get("ET");
65
+
66
+ var secondET = _primitives.Cmd.get("ET");
67
+
56
68
  expect(firstBT).toBe(secondBT);
57
69
  expect(firstET).toBe(secondET);
58
70
  expect(firstBT).not.toBe(firstET);
59
71
  });
60
72
  });
61
- describe('Dict', function () {
62
- var checkInvalidHasValues = function checkInvalidHasValues(dict) {
73
+ describe("Dict", function () {
74
+ var checkInvalidHasValues = function (dict) {
63
75
  expect(dict.has()).toBeFalsy();
64
- expect(dict.has('Prev')).toBeFalsy();
76
+ expect(dict.has("Prev")).toBeFalsy();
65
77
  };
66
- var checkInvalidKeyValues = function checkInvalidKeyValues(dict) {
78
+
79
+ var checkInvalidKeyValues = function (dict) {
67
80
  expect(dict.get()).toBeUndefined();
68
- expect(dict.get('Prev')).toBeUndefined();
69
- expect(dict.get('Decode', 'D')).toBeUndefined();
70
- 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();
71
84
  };
85
+
72
86
  var emptyDict, dictWithSizeKey, dictWithManyKeys;
73
87
  var storedSize = 42;
74
- var testFontFile = 'file1';
75
- var testFontFile2 = 'file2';
76
- var testFontFile3 = 'file3';
88
+ var testFontFile = "file1";
89
+ var testFontFile2 = "file2";
90
+ var testFontFile3 = "file3";
77
91
  beforeAll(function (done) {
78
92
  emptyDict = new _primitives.Dict();
79
93
  dictWithSizeKey = new _primitives.Dict();
80
- dictWithSizeKey.set('Size', storedSize);
94
+ dictWithSizeKey.set("Size", storedSize);
81
95
  dictWithManyKeys = new _primitives.Dict();
82
- dictWithManyKeys.set('FontFile', testFontFile);
83
- dictWithManyKeys.set('FontFile2', testFontFile2);
84
- dictWithManyKeys.set('FontFile3', testFontFile3);
96
+ dictWithManyKeys.set("FontFile", testFontFile);
97
+ dictWithManyKeys.set("FontFile2", testFontFile2);
98
+ dictWithManyKeys.set("FontFile3", testFontFile3);
85
99
  done();
86
100
  });
87
101
  afterAll(function () {
88
102
  emptyDict = dictWithSizeKey = dictWithManyKeys = null;
89
103
  });
90
- it('should return invalid values for unknown keys', function () {
104
+ it("should return invalid values for unknown keys", function () {
91
105
  checkInvalidHasValues(emptyDict);
92
106
  checkInvalidKeyValues(emptyDict);
93
107
  });
94
- it('should return correct value for stored Size key', function () {
95
- expect(dictWithSizeKey.has('Size')).toBeTruthy();
96
- expect(dictWithSizeKey.get('Size')).toEqual(storedSize);
97
- expect(dictWithSizeKey.get('Prev', 'Size')).toEqual(storedSize);
98
- 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);
99
113
  });
100
- 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 () {
101
115
  checkInvalidHasValues(dictWithSizeKey);
102
116
  checkInvalidKeyValues(dictWithSizeKey);
103
117
  });
104
- it('should return correct value for stored Size key with undefined value', function () {
105
- var dict = new _primitives.Dict();
106
- dict.set('Size');
107
- 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();
108
124
  checkInvalidKeyValues(dict);
109
125
  });
110
- it('should return correct values for multiple stored keys', function () {
111
- expect(dictWithManyKeys.has('FontFile')).toBeTruthy();
112
- expect(dictWithManyKeys.has('FontFile2')).toBeTruthy();
113
- expect(dictWithManyKeys.has('FontFile3')).toBeTruthy();
114
- expect(dictWithManyKeys.get('FontFile3')).toEqual(testFontFile3);
115
- expect(dictWithManyKeys.get('FontFile2', 'FontFile3')).toEqual(testFontFile2);
116
- 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);
117
133
  });
118
- it('should asynchronously fetch unknown keys', function (done) {
119
- 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")];
120
136
  Promise.all(keyPromises).then(function (values) {
121
137
  expect(values[0]).toBeUndefined();
122
- expect(values[1]).toBeNull();
138
+ expect(values[1]).toBeUndefined();
123
139
  done();
124
140
  }).catch(function (reason) {
125
141
  done.fail(reason);
126
142
  });
127
143
  });
128
- it('should asynchronously fetch correct values for multiple stored keys', function (done) {
129
- 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")];
130
146
  Promise.all(keyPromises).then(function (values) {
131
147
  expect(values[0]).toEqual(testFontFile3);
132
148
  expect(values[1]).toEqual(testFontFile2);
@@ -136,36 +152,38 @@ describe('primitives', function () {
136
152
  done.fail(reason);
137
153
  });
138
154
  });
139
- it('should callback for each stored key', function () {
140
- 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");
141
157
  dictWithManyKeys.forEach(callbackSpy);
142
158
  expect(callbackSpy).toHaveBeenCalled();
143
159
  var callbackSpyCalls = callbackSpy.calls;
144
- expect(callbackSpyCalls.argsFor(0)).toEqual(['FontFile', testFontFile]);
145
- expect(callbackSpyCalls.argsFor(1)).toEqual(['FontFile2', testFontFile2]);
146
- 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]);
147
163
  expect(callbackSpyCalls.count()).toEqual(3);
148
164
  });
149
- it('should handle keys pointing to indirect objects, both sync and async', function (done) {
150
- 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
+
151
168
  var xref = new _test_utils.XRefMock([{
152
169
  ref: fontRef,
153
170
  data: testFontFile
154
171
  }]);
155
172
  var fontDict = new _primitives.Dict(xref);
156
- fontDict.set('FontFile', fontRef);
157
- expect(fontDict.getRaw('FontFile')).toEqual(fontRef);
158
- expect(fontDict.get('FontFile', 'FontFile2', 'FontFile3')).toEqual(testFontFile);
159
- 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) {
160
177
  expect(value).toEqual(testFontFile);
161
178
  done();
162
179
  }).catch(function (reason) {
163
180
  done.fail(reason);
164
181
  });
165
182
  });
166
- it('should handle arrays containing indirect objects', function () {
167
- var minCoordRef = new _primitives.Ref(1, 0),
168
- 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
+
169
187
  var minCoord = 0,
170
188
  maxCoord = 1;
171
189
  var xref = new _test_utils.XRefMock([{
@@ -176,122 +194,139 @@ describe('primitives', function () {
176
194
  data: maxCoord
177
195
  }]);
178
196
  var xObjectDict = new _primitives.Dict(xref);
179
- xObjectDict.set('BBox', [minCoord, maxCoord, minCoordRef, maxCoordRef]);
180
- expect(xObjectDict.get('BBox')).toEqual([minCoord, maxCoord, minCoordRef, maxCoordRef]);
181
- 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]);
182
200
  });
183
- it('should get all key names', function () {
184
- var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3'];
201
+ it("should get all key names", function () {
202
+ var expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
185
203
  var keys = dictWithManyKeys.getKeys();
186
204
  expect(keys.sort()).toEqual(expectedKeys);
187
205
  });
188
- it('should create only one object for Dict.empty', function () {
206
+ it("should create only one object for Dict.empty", function () {
189
207
  var firstDictEmpty = _primitives.Dict.empty;
190
208
  var secondDictEmpty = _primitives.Dict.empty;
191
209
  expect(firstDictEmpty).toBe(secondDictEmpty);
192
210
  expect(firstDictEmpty).not.toBe(emptyDict);
193
211
  });
194
- it('should correctly merge dictionaries', function () {
195
- var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3', 'Size'];
212
+ it("should correctly merge dictionaries", function () {
213
+ var expectedKeys = ["FontFile", "FontFile2", "FontFile3", "Size"];
196
214
  var fontFileDict = new _primitives.Dict();
197
- fontFileDict.set('FontFile', 'Type1 font file');
215
+ fontFileDict.set("FontFile", "Type1 font file");
216
+
198
217
  var mergedDict = _primitives.Dict.merge(null, [dictWithManyKeys, dictWithSizeKey, fontFileDict]);
218
+
199
219
  var mergedKeys = mergedDict.getKeys();
200
220
  expect(mergedKeys.sort()).toEqual(expectedKeys);
201
- expect(mergedDict.get('FontFile')).toEqual(testFontFile);
221
+ expect(mergedDict.get("FontFile")).toEqual(testFontFile);
202
222
  });
203
223
  });
204
- describe('Ref', function () {
205
- it('should retain the stored values', function () {
224
+ describe("Ref", function () {
225
+ it("should retain the stored values", function () {
206
226
  var storedNum = 4;
207
227
  var storedGen = 2;
208
- var ref = new _primitives.Ref(storedNum, storedGen);
228
+
229
+ var ref = _primitives.Ref.get(storedNum, storedGen);
230
+
209
231
  expect(ref.num).toEqual(storedNum);
210
232
  expect(ref.gen).toEqual(storedGen);
211
233
  });
212
234
  });
213
- describe('RefSet', function () {
214
- it('should have a stored value', function () {
215
- 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
+
216
239
  var refset = new _primitives.RefSet();
217
240
  refset.put(ref);
218
241
  expect(refset.has(ref)).toBeTruthy();
219
242
  });
220
- it('should not have an unknown value', function () {
221
- 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
+
222
246
  var refset = new _primitives.RefSet();
223
247
  expect(refset.has(ref)).toBeFalsy();
224
248
  refset.put(ref);
225
- var anotherRef = new _primitives.Ref(2, 4);
249
+
250
+ var anotherRef = _primitives.Ref.get(2, 4);
251
+
226
252
  expect(refset.has(anotherRef)).toBeFalsy();
227
253
  });
228
254
  });
229
- describe('isName', function () {
230
- it('handles non-names', function () {
255
+ describe("isName", function () {
256
+ it("handles non-names", function () {
231
257
  var nonName = {};
232
258
  expect((0, _primitives.isName)(nonName)).toEqual(false);
233
259
  });
234
- it('handles names', function () {
235
- var name = _primitives.Name.get('Font');
260
+ it("handles names", function () {
261
+ var name = _primitives.Name.get("Font");
262
+
236
263
  expect((0, _primitives.isName)(name)).toEqual(true);
237
264
  });
238
- it('handles names with name check', function () {
239
- var name = _primitives.Name.get('Font');
240
- expect((0, _primitives.isName)(name, 'Font')).toEqual(true);
241
- expect((0, _primitives.isName)(name, 'Subtype')).toEqual(false);
265
+ it("handles names with name check", function () {
266
+ var name = _primitives.Name.get("Font");
267
+
268
+ expect((0, _primitives.isName)(name, "Font")).toEqual(true);
269
+ expect((0, _primitives.isName)(name, "Subtype")).toEqual(false);
242
270
  });
243
271
  });
244
- describe('isCmd', function () {
245
- it('handles non-commands', function () {
272
+ describe("isCmd", function () {
273
+ it("handles non-commands", function () {
246
274
  var nonCmd = {};
247
275
  expect((0, _primitives.isCmd)(nonCmd)).toEqual(false);
248
276
  });
249
- it('handles commands', function () {
250
- var cmd = _primitives.Cmd.get('BT');
277
+ it("handles commands", function () {
278
+ var cmd = _primitives.Cmd.get("BT");
279
+
251
280
  expect((0, _primitives.isCmd)(cmd)).toEqual(true);
252
281
  });
253
- it('handles commands with cmd check', function () {
254
- var cmd = _primitives.Cmd.get('BT');
255
- expect((0, _primitives.isCmd)(cmd, 'BT')).toEqual(true);
256
- expect((0, _primitives.isCmd)(cmd, 'ET')).toEqual(false);
282
+ it("handles commands with cmd check", function () {
283
+ var cmd = _primitives.Cmd.get("BT");
284
+
285
+ expect((0, _primitives.isCmd)(cmd, "BT")).toEqual(true);
286
+ expect((0, _primitives.isCmd)(cmd, "ET")).toEqual(false);
257
287
  });
258
288
  });
259
- describe('isDict', function () {
260
- it('handles non-dictionaries', function () {
289
+ describe("isDict", function () {
290
+ it("handles non-dictionaries", function () {
261
291
  var nonDict = {};
262
292
  expect((0, _primitives.isDict)(nonDict)).toEqual(false);
263
293
  });
264
- it('handles empty dictionaries with type check', function () {
294
+ it("handles empty dictionaries with type check", function () {
265
295
  var dict = _primitives.Dict.empty;
266
296
  expect((0, _primitives.isDict)(dict)).toEqual(true);
267
- expect((0, _primitives.isDict)(dict, 'Page')).toEqual(false);
297
+ expect((0, _primitives.isDict)(dict, "Page")).toEqual(false);
268
298
  });
269
- it('handles dictionaries with type check', function () {
299
+ it("handles dictionaries with type check", function () {
270
300
  var dict = new _primitives.Dict();
271
- dict.set('Type', _primitives.Name.get('Page'));
272
- expect((0, _primitives.isDict)(dict, 'Page')).toEqual(true);
273
- 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);
274
304
  });
275
305
  });
276
- describe('isRef', function () {
277
- it('handles non-refs', function () {
306
+ describe("isRef", function () {
307
+ it("handles non-refs", function () {
278
308
  var nonRef = {};
279
309
  expect((0, _primitives.isRef)(nonRef)).toEqual(false);
280
310
  });
281
- it('handles refs', function () {
282
- var ref = new _primitives.Ref(1, 0);
311
+ it("handles refs", function () {
312
+ var ref = _primitives.Ref.get(1, 0);
313
+
283
314
  expect((0, _primitives.isRef)(ref)).toEqual(true);
284
315
  });
285
316
  });
286
- describe('isRefsEqual', function () {
287
- it('should handle different Refs pointing to the same object', function () {
288
- var ref1 = new _primitives.Ref(1, 0);
289
- 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
+
290
323
  expect((0, _primitives.isRefsEqual)(ref1, ref2)).toEqual(true);
291
324
  });
292
- it('should handle Refs pointing to different objects', function () {
293
- var ref1 = new _primitives.Ref(1, 0);
294
- 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
+
295
330
  expect((0, _primitives.isRefsEqual)(ref1, ref2)).toEqual(false);
296
331
  });
297
332
  });
@@ -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.
@@ -19,52 +19,59 @@
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 _stream = require('../../core/stream');
24
+ var _stream = require("../../core/stream.js");
25
25
 
26
- var _primitives = require('../../core/primitives');
26
+ var _primitives = require("../../core/primitives.js");
27
27
 
28
- describe('stream', function () {
28
+ describe("stream", function () {
29
29
  beforeEach(function () {
30
30
  jasmine.addMatchers({
31
- toMatchTypedArray: function toMatchTypedArray(util, customEqualityTesters) {
31
+ toMatchTypedArray(util, customEqualityTesters) {
32
32
  return {
33
- compare: function compare(actual, expected) {
33
+ compare(actual, expected) {
34
34
  var result = {};
35
+
35
36
  if (actual.length !== expected.length) {
36
37
  result.pass = false;
37
- result.message = 'Array length: ' + actual.length + ', expected: ' + expected.length;
38
+ result.message = "Array length: " + actual.length + ", expected: " + expected.length;
38
39
  return result;
39
40
  }
41
+
40
42
  result.pass = true;
43
+
41
44
  for (var i = 0, ii = expected.length; i < ii; i++) {
42
45
  var a = actual[i],
43
46
  b = expected[i];
47
+
44
48
  if (a !== b) {
45
49
  result.pass = false;
46
50
  break;
47
51
  }
48
52
  }
53
+
49
54
  return result;
50
55
  }
56
+
51
57
  };
52
58
  }
59
+
53
60
  });
54
61
  });
55
- describe('PredictorStream', function () {
56
- it('should decode simple predictor data', function () {
62
+ describe("PredictorStream", function () {
63
+ it("should decode simple predictor data", function () {
57
64
  var dict = new _primitives.Dict();
58
- dict.set('Predictor', 12);
59
- dict.set('Colors', 1);
60
- dict.set('BitsPerComponent', 8);
61
- dict.set('Columns', 2);
65
+ dict.set("Predictor", 12);
66
+ dict.set("Colors", 1);
67
+ dict.set("BitsPerComponent", 8);
68
+ dict.set("Columns", 2);
62
69
  var input = new _stream.Stream(new Uint8Array([2, 100, 3, 2, 1, 255, 2, 1, 255]), 0, 9, dict);
63
70
  var predictor = new _stream.PredictorStream(input, 9, dict);
64
71
  var result = predictor.getBytes(6);
65
72
  expect(result).toMatchTypedArray(new Uint8Array([100, 3, 101, 2, 102, 1]));
66
73
  predictor.reset();
67
- var clampedResult = predictor.getBytes(6, true);
74
+ const clampedResult = predictor.getBytes(6, true);
68
75
  expect(clampedResult).toEqual(new Uint8ClampedArray([100, 3, 101, 2, 102, 1]));
69
76
  });
70
77
  });