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,26 +21,26 @@
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 _stream = require("../../core/stream");
26
+ var _stream = require("../../core/stream.js");
27
27
 
28
- var _colorspace = require("../../core/colorspace");
28
+ var _colorspace = require("../../core/colorspace.js");
29
29
 
30
- var _function = require("../../core/function");
30
+ var _function = require("../../core/function.js");
31
31
 
32
- var _test_utils = require("./test_utils");
32
+ var _test_utils = require("./test_utils.js");
33
33
 
34
- describe('colorspace', function () {
35
- describe('ColorSpace', function () {
36
- it('should be true if decode is not an array', function () {
37
- expect(_colorspace.ColorSpace.isDefaultDecode('string', 0)).toBeTruthy();
34
+ describe("colorspace", function () {
35
+ describe("ColorSpace", function () {
36
+ it("should be true if decode is not an array", function () {
37
+ expect(_colorspace.ColorSpace.isDefaultDecode("string", 0)).toBeTruthy();
38
38
  });
39
- it('should be true if length of decode array is not correct', function () {
39
+ it("should be true if length of decode array is not correct", function () {
40
40
  expect(_colorspace.ColorSpace.isDefaultDecode([0], 1)).toBeTruthy();
41
41
  expect(_colorspace.ColorSpace.isDefaultDecode([0, 1, 0], 1)).toBeTruthy();
42
42
  });
43
- it('should be true if decode map matches the default decode map', function () {
43
+ it("should be true if decode map matches the default decode map", function () {
44
44
  expect(_colorspace.ColorSpace.isDefaultDecode([], 0)).toBeTruthy();
45
45
  expect(_colorspace.ColorSpace.isDefaultDecode([0, 0], 1)).toBeFalsy();
46
46
  expect(_colorspace.ColorSpace.isDefaultDecode([0, 1], 1)).toBeTruthy();
@@ -50,46 +50,47 @@ describe('colorspace', function () {
50
50
  expect(_colorspace.ColorSpace.isDefaultDecode([1, 0, 0, 1, 0, 1, 0, 1], 4)).toBeFalsy();
51
51
  });
52
52
  });
53
- describe('DeviceGrayCS', function () {
54
- it('should handle the case when cs is a Name object', function () {
55
- var cs = _primitives.Name.get('DeviceGray');
53
+ describe("DeviceGrayCS", function () {
54
+ it("should handle the case when cs is a Name object", function () {
55
+ const cs = _primitives.Name.get("DeviceGray");
56
56
 
57
- var xref = new _test_utils.XRefMock([{
58
- ref: new _primitives.Ref(10, 0),
57
+ const xref = new _test_utils.XRefMock([{
58
+ ref: _primitives.Ref.get(10, 0),
59
59
  data: new _primitives.Dict()
60
60
  }]);
61
- var res = new _primitives.Dict();
62
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
63
- xref: xref
61
+ const res = new _primitives.Dict();
62
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
63
+ xref
64
64
  });
65
65
 
66
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
66
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
67
67
 
68
- var testSrc = new Uint8Array([27, 125, 250, 131]);
69
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
70
- var expectedDest = new Uint8ClampedArray([27, 27, 27, 27, 27, 27, 125, 125, 125, 125, 125, 125, 27, 27, 27, 27, 27, 27, 125, 125, 125, 125, 125, 125, 250, 250, 250, 250, 250, 250, 131, 131, 131, 131, 131, 131, 250, 250, 250, 250, 250, 250, 131, 131, 131, 131, 131, 131]);
68
+ const testSrc = new Uint8Array([27, 125, 250, 131]);
69
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
70
+ const expectedDest = new Uint8ClampedArray([27, 27, 27, 27, 27, 27, 125, 125, 125, 125, 125, 125, 27, 27, 27, 27, 27, 27, 125, 125, 125, 125, 125, 125, 250, 250, 250, 250, 250, 250, 131, 131, 131, 131, 131, 131, 250, 250, 250, 250, 250, 250, 131, 131, 131, 131, 131, 131]);
71
71
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
72
72
  expect(colorSpace.getRgb(new Float32Array([0.1]), 0)).toEqual(new Uint8ClampedArray([26, 26, 26]));
73
73
  expect(colorSpace.getOutputLength(2, 0)).toEqual(6);
74
74
  expect(colorSpace.isPassthrough(8)).toBeFalsy();
75
75
  expect(testDest).toEqual(expectedDest);
76
76
  });
77
- it('should handle the case when cs is an indirect object', function () {
78
- var cs = new _primitives.Ref(10, 0);
79
- var xref = new _test_utils.XRefMock([{
77
+ it("should handle the case when cs is an indirect object", function () {
78
+ const cs = _primitives.Ref.get(10, 0);
79
+
80
+ const xref = new _test_utils.XRefMock([{
80
81
  ref: cs,
81
- data: _primitives.Name.get('DeviceGray')
82
+ data: _primitives.Name.get("DeviceGray")
82
83
  }]);
83
- var res = new _primitives.Dict();
84
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
85
- xref: xref
84
+ const res = new _primitives.Dict();
85
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
86
+ xref
86
87
  });
87
88
 
88
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
89
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
89
90
 
90
- var testSrc = new Uint8Array([27, 125, 250, 131]);
91
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
92
- var expectedDest = new Uint8ClampedArray([27, 27, 27, 27, 27, 27, 125, 125, 125, 27, 27, 27, 27, 27, 27, 125, 125, 125, 250, 250, 250, 250, 250, 250, 131, 131, 131]);
91
+ const testSrc = new Uint8Array([27, 125, 250, 131]);
92
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
93
+ const expectedDest = new Uint8ClampedArray([27, 27, 27, 27, 27, 27, 125, 125, 125, 27, 27, 27, 27, 27, 27, 125, 125, 125, 250, 250, 250, 250, 250, 250, 131, 131, 131]);
93
94
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
94
95
  expect(colorSpace.getRgb(new Float32Array([0.2]), 0)).toEqual(new Uint8ClampedArray([51, 51, 51]));
95
96
  expect(colorSpace.getOutputLength(3, 1)).toEqual(12);
@@ -97,46 +98,47 @@ describe('colorspace', function () {
97
98
  expect(testDest).toEqual(expectedDest);
98
99
  });
99
100
  });
100
- describe('DeviceRgbCS', function () {
101
- it('should handle the case when cs is a Name object', function () {
102
- var cs = _primitives.Name.get('DeviceRGB');
101
+ describe("DeviceRgbCS", function () {
102
+ it("should handle the case when cs is a Name object", function () {
103
+ const cs = _primitives.Name.get("DeviceRGB");
103
104
 
104
- var xref = new _test_utils.XRefMock([{
105
- ref: new _primitives.Ref(10, 0),
105
+ const xref = new _test_utils.XRefMock([{
106
+ ref: _primitives.Ref.get(10, 0),
106
107
  data: new _primitives.Dict()
107
108
  }]);
108
- var res = new _primitives.Dict();
109
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
110
- xref: xref
109
+ const res = new _primitives.Dict();
110
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
111
+ xref
111
112
  });
112
113
 
113
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
114
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
114
115
 
115
- var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
116
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
117
- var expectedDest = new Uint8ClampedArray([27, 125, 250, 27, 125, 250, 131, 139, 140, 131, 139, 140, 27, 125, 250, 27, 125, 250, 131, 139, 140, 131, 139, 140, 111, 25, 198, 111, 25, 198, 21, 147, 255, 21, 147, 255, 111, 25, 198, 111, 25, 198, 21, 147, 255, 21, 147, 255]);
116
+ const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
117
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
118
+ const expectedDest = new Uint8ClampedArray([27, 125, 250, 27, 125, 250, 131, 139, 140, 131, 139, 140, 27, 125, 250, 27, 125, 250, 131, 139, 140, 131, 139, 140, 111, 25, 198, 111, 25, 198, 21, 147, 255, 21, 147, 255, 111, 25, 198, 111, 25, 198, 21, 147, 255, 21, 147, 255]);
118
119
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
119
120
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
120
121
  expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
121
122
  expect(colorSpace.isPassthrough(8)).toBeTruthy();
122
123
  expect(testDest).toEqual(expectedDest);
123
124
  });
124
- it('should handle the case when cs is an indirect object', function () {
125
- var cs = new _primitives.Ref(10, 0);
126
- var xref = new _test_utils.XRefMock([{
125
+ it("should handle the case when cs is an indirect object", function () {
126
+ const cs = _primitives.Ref.get(10, 0);
127
+
128
+ const xref = new _test_utils.XRefMock([{
127
129
  ref: cs,
128
- data: _primitives.Name.get('DeviceRGB')
130
+ data: _primitives.Name.get("DeviceRGB")
129
131
  }]);
130
- var res = new _primitives.Dict();
131
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
132
- xref: xref
132
+ const res = new _primitives.Dict();
133
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
134
+ xref
133
135
  });
134
136
 
135
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
137
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
136
138
 
137
- var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
138
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
139
- var expectedDest = new Uint8ClampedArray([27, 125, 250, 27, 125, 250, 131, 139, 140, 27, 125, 250, 27, 125, 250, 131, 139, 140, 111, 25, 198, 111, 25, 198, 21, 147, 255]);
139
+ const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
140
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
141
+ const expectedDest = new Uint8ClampedArray([27, 125, 250, 27, 125, 250, 131, 139, 140, 27, 125, 250, 27, 125, 250, 131, 139, 140, 111, 25, 198, 111, 25, 198, 21, 147, 255]);
140
142
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
141
143
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
142
144
  expect(colorSpace.getOutputLength(4, 1)).toEqual(5);
@@ -144,46 +146,47 @@ describe('colorspace', function () {
144
146
  expect(testDest).toEqual(expectedDest);
145
147
  });
146
148
  });
147
- describe('DeviceCmykCS', function () {
148
- it('should handle the case when cs is a Name object', function () {
149
- var cs = _primitives.Name.get('DeviceCMYK');
149
+ describe("DeviceCmykCS", function () {
150
+ it("should handle the case when cs is a Name object", function () {
151
+ const cs = _primitives.Name.get("DeviceCMYK");
150
152
 
151
- var xref = new _test_utils.XRefMock([{
152
- ref: new _primitives.Ref(10, 0),
153
+ const xref = new _test_utils.XRefMock([{
154
+ ref: _primitives.Ref.get(10, 0),
153
155
  data: new _primitives.Dict()
154
156
  }]);
155
- var res = new _primitives.Dict();
156
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
157
- xref: xref
157
+ const res = new _primitives.Dict();
158
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
159
+ xref
158
160
  });
159
161
 
160
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
162
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
161
163
 
162
- var testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
163
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
164
- var expectedDest = new Uint8ClampedArray([135, 81, 18, 135, 81, 18, 114, 102, 97, 114, 102, 97, 135, 81, 18, 135, 81, 18, 114, 102, 97, 114, 102, 97, 112, 144, 75, 112, 144, 75, 188, 98, 27, 188, 98, 27, 112, 144, 75, 112, 144, 75, 188, 98, 27, 188, 98, 27]);
164
+ const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
165
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
166
+ const expectedDest = new Uint8ClampedArray([135, 81, 18, 135, 81, 18, 114, 102, 97, 114, 102, 97, 135, 81, 18, 135, 81, 18, 114, 102, 97, 114, 102, 97, 112, 144, 75, 112, 144, 75, 188, 98, 27, 188, 98, 27, 112, 144, 75, 112, 144, 75, 188, 98, 27, 188, 98, 27]);
165
167
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
166
168
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
167
169
  expect(colorSpace.getOutputLength(4, 0)).toEqual(3);
168
170
  expect(colorSpace.isPassthrough(8)).toBeFalsy();
169
171
  expect(testDest).toEqual(expectedDest);
170
172
  });
171
- it('should handle the case when cs is an indirect object', function () {
172
- var cs = new _primitives.Ref(10, 0);
173
- var xref = new _test_utils.XRefMock([{
173
+ it("should handle the case when cs is an indirect object", function () {
174
+ const cs = _primitives.Ref.get(10, 0);
175
+
176
+ const xref = new _test_utils.XRefMock([{
174
177
  ref: cs,
175
- data: _primitives.Name.get('DeviceCMYK')
178
+ data: _primitives.Name.get("DeviceCMYK")
176
179
  }]);
177
- var res = new _primitives.Dict();
178
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
179
- xref: xref
180
+ const res = new _primitives.Dict();
181
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
182
+ xref
180
183
  });
181
184
 
182
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
185
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
183
186
 
184
- var testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
185
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
186
- var expectedDest = new Uint8ClampedArray([135, 81, 18, 135, 81, 18, 114, 102, 97, 135, 81, 18, 135, 81, 18, 114, 102, 97, 112, 144, 75, 112, 144, 75, 188, 98, 27]);
187
+ const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
188
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
189
+ const expectedDest = new Uint8ClampedArray([135, 81, 18, 135, 81, 18, 114, 102, 97, 135, 81, 18, 135, 81, 18, 114, 102, 97, 112, 144, 75, 112, 144, 75, 188, 98, 27]);
187
190
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
188
191
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
189
192
  expect(colorSpace.getOutputLength(4, 1)).toEqual(4);
@@ -191,27 +194,27 @@ describe('colorspace', function () {
191
194
  expect(testDest).toEqual(expectedDest);
192
195
  });
193
196
  });
194
- describe('CalGrayCS', function () {
195
- it('should handle the case when cs is an array', function () {
196
- var params = new _primitives.Dict();
197
- params.set('WhitePoint', [1, 1, 1]);
198
- params.set('BlackPoint', [0, 0, 0]);
199
- params.set('Gamma', 2.0);
200
- var cs = [_primitives.Name.get('CalGray'), params];
201
- var xref = new _test_utils.XRefMock([{
202
- ref: new _primitives.Ref(10, 0),
197
+ describe("CalGrayCS", function () {
198
+ it("should handle the case when cs is an array", function () {
199
+ const params = new _primitives.Dict();
200
+ params.set("WhitePoint", [1, 1, 1]);
201
+ params.set("BlackPoint", [0, 0, 0]);
202
+ params.set("Gamma", 2.0);
203
+ const cs = [_primitives.Name.get("CalGray"), params];
204
+ const xref = new _test_utils.XRefMock([{
205
+ ref: _primitives.Ref.get(10, 0),
203
206
  data: new _primitives.Dict()
204
207
  }]);
205
- var res = new _primitives.Dict();
206
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
207
- xref: xref
208
+ const res = new _primitives.Dict();
209
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
210
+ xref
208
211
  });
209
212
 
210
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
213
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
211
214
 
212
- var testSrc = new Uint8Array([27, 125, 250, 131]);
213
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
214
- var expectedDest = new Uint8ClampedArray([25, 25, 25, 25, 25, 25, 143, 143, 143, 143, 143, 143, 25, 25, 25, 25, 25, 25, 143, 143, 143, 143, 143, 143, 251, 251, 251, 251, 251, 251, 149, 149, 149, 149, 149, 149, 251, 251, 251, 251, 251, 251, 149, 149, 149, 149, 149, 149]);
215
+ const testSrc = new Uint8Array([27, 125, 250, 131]);
216
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
217
+ const expectedDest = new Uint8ClampedArray([25, 25, 25, 25, 25, 25, 143, 143, 143, 143, 143, 143, 25, 25, 25, 25, 25, 25, 143, 143, 143, 143, 143, 143, 251, 251, 251, 251, 251, 251, 149, 149, 149, 149, 149, 149, 251, 251, 251, 251, 251, 251, 149, 149, 149, 149, 149, 149]);
215
218
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
216
219
  expect(colorSpace.getRgb(new Float32Array([1.0]), 0)).toEqual(new Uint8ClampedArray([255, 255, 255]));
217
220
  expect(colorSpace.getOutputLength(4, 0)).toEqual(12);
@@ -219,28 +222,28 @@ describe('colorspace', function () {
219
222
  expect(testDest).toEqual(expectedDest);
220
223
  });
221
224
  });
222
- describe('CalRGBCS', function () {
223
- it('should handle the case when cs is an array', function () {
224
- var params = new _primitives.Dict();
225
- params.set('WhitePoint', [1, 1, 1]);
226
- params.set('BlackPoint', [0, 0, 0]);
227
- params.set('Gamma', [1, 1, 1]);
228
- params.set('Matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
229
- var cs = [_primitives.Name.get('CalRGB'), params];
230
- var xref = new _test_utils.XRefMock([{
231
- ref: new _primitives.Ref(10, 0),
225
+ describe("CalRGBCS", function () {
226
+ it("should handle the case when cs is an array", function () {
227
+ const params = new _primitives.Dict();
228
+ params.set("WhitePoint", [1, 1, 1]);
229
+ params.set("BlackPoint", [0, 0, 0]);
230
+ params.set("Gamma", [1, 1, 1]);
231
+ params.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
232
+ const cs = [_primitives.Name.get("CalRGB"), params];
233
+ const xref = new _test_utils.XRefMock([{
234
+ ref: _primitives.Ref.get(10, 0),
232
235
  data: new _primitives.Dict()
233
236
  }]);
234
- var res = new _primitives.Dict();
235
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
236
- xref: xref
237
+ const res = new _primitives.Dict();
238
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
239
+ xref
237
240
  });
238
241
 
239
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
242
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
240
243
 
241
- var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
242
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
243
- var expectedDest = new Uint8ClampedArray([0, 238, 255, 0, 238, 255, 185, 196, 195, 0, 238, 255, 0, 238, 255, 185, 196, 195, 235, 0, 243, 235, 0, 243, 0, 255, 255]);
244
+ const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
245
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
246
+ const expectedDest = new Uint8ClampedArray([0, 238, 255, 0, 238, 255, 185, 196, 195, 0, 238, 255, 0, 238, 255, 185, 196, 195, 235, 0, 243, 235, 0, 243, 0, 255, 255]);
244
247
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
245
248
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([0, 147, 151]));
246
249
  expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
@@ -248,27 +251,27 @@ describe('colorspace', function () {
248
251
  expect(testDest).toEqual(expectedDest);
249
252
  });
250
253
  });
251
- describe('LabCS', function () {
252
- it('should handle the case when cs is an array', function () {
253
- var params = new _primitives.Dict();
254
- params.set('WhitePoint', [1, 1, 1]);
255
- params.set('BlackPoint', [0, 0, 0]);
256
- params.set('Range', [-100, 100, -100, 100]);
257
- var cs = [_primitives.Name.get('Lab'), params];
258
- var xref = new _test_utils.XRefMock([{
259
- ref: new _primitives.Ref(10, 0),
254
+ describe("LabCS", function () {
255
+ it("should handle the case when cs is an array", function () {
256
+ const params = new _primitives.Dict();
257
+ params.set("WhitePoint", [1, 1, 1]);
258
+ params.set("BlackPoint", [0, 0, 0]);
259
+ params.set("Range", [-100, 100, -100, 100]);
260
+ const cs = [_primitives.Name.get("Lab"), params];
261
+ const xref = new _test_utils.XRefMock([{
262
+ ref: _primitives.Ref.get(10, 0),
260
263
  data: new _primitives.Dict()
261
264
  }]);
262
- var res = new _primitives.Dict();
263
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
264
- xref: xref
265
+ const res = new _primitives.Dict();
266
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
267
+ xref
265
268
  });
266
269
 
267
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
270
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
268
271
 
269
- var testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
270
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
271
- var expectedDest = new Uint8ClampedArray([0, 49, 101, 0, 49, 101, 0, 53, 117, 0, 49, 101, 0, 49, 101, 0, 53, 117, 0, 41, 40, 0, 41, 40, 0, 43, 90]);
272
+ const testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
273
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
274
+ const expectedDest = new Uint8ClampedArray([0, 49, 101, 0, 49, 101, 0, 53, 117, 0, 49, 101, 0, 49, 101, 0, 53, 117, 0, 41, 40, 0, 41, 40, 0, 43, 90]);
272
275
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
273
276
  expect(colorSpace.getRgb([55, 25, 35], 0)).toEqual(new Uint8ClampedArray([188, 100, 61]));
274
277
  expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
@@ -277,24 +280,24 @@ describe('colorspace', function () {
277
280
  expect(testDest).toEqual(expectedDest);
278
281
  });
279
282
  });
280
- describe('IndexedCS', function () {
281
- it('should handle the case when cs is an array', function () {
282
- var lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]);
283
- var cs = [_primitives.Name.get('Indexed'), _primitives.Name.get('DeviceRGB'), 2, lookup];
284
- var xref = new _test_utils.XRefMock([{
285
- ref: new _primitives.Ref(10, 0),
283
+ describe("IndexedCS", function () {
284
+ it("should handle the case when cs is an array", function () {
285
+ const lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]);
286
+ const cs = [_primitives.Name.get("Indexed"), _primitives.Name.get("DeviceRGB"), 2, lookup];
287
+ const xref = new _test_utils.XRefMock([{
288
+ ref: _primitives.Ref.get(10, 0),
286
289
  data: new _primitives.Dict()
287
290
  }]);
288
- var res = new _primitives.Dict();
289
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
290
- xref: xref
291
+ const res = new _primitives.Dict();
292
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
293
+ xref
291
294
  });
292
295
 
293
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
296
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
294
297
 
295
- var testSrc = new Uint8Array([2, 2, 0, 1]);
296
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
297
- var expectedDest = new Uint8ClampedArray([255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 23, 155, 35, 23, 155, 35, 147, 69, 93]);
298
+ const testSrc = new Uint8Array([2, 2, 0, 1]);
299
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
300
+ const expectedDest = new Uint8ClampedArray([255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 23, 155, 35, 23, 155, 35, 147, 69, 93]);
298
301
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
299
302
  expect(colorSpace.getRgb([2], 0)).toEqual(new Uint8ClampedArray([255, 109, 70]));
300
303
  expect(colorSpace.isPassthrough(8)).toBeFalsy();
@@ -302,31 +305,33 @@ describe('colorspace', function () {
302
305
  expect(testDest).toEqual(expectedDest);
303
306
  });
304
307
  });
305
- describe('AlternateCS', function () {
306
- it('should handle the case when cs is an array', function () {
307
- var fnDict = new _primitives.Dict();
308
- fnDict.set('FunctionType', 4);
309
- fnDict.set('Domain', [0.0, 1.0]);
310
- fnDict.set('Range', [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
311
- fnDict.set('Length', 58);
312
- var fn = new _stream.StringStream('{ dup 0.84 mul ' + 'exch 0.00 exch ' + 'dup 0.44 mul ' + 'exch 0.21 mul }');
308
+ describe("AlternateCS", function () {
309
+ it("should handle the case when cs is an array", function () {
310
+ const fnDict = new _primitives.Dict();
311
+ fnDict.set("FunctionType", 4);
312
+ fnDict.set("Domain", [0.0, 1.0]);
313
+ fnDict.set("Range", [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
314
+ fnDict.set("Length", 58);
315
+ let fn = new _stream.StringStream("{ dup 0.84 mul " + "exch 0.00 exch " + "dup 0.44 mul " + "exch 0.21 mul }");
313
316
  fn = new _stream.Stream(fn.bytes, 0, 58, fnDict);
314
- var fnRef = new _primitives.Ref(10, 0);
315
- var cs = [_primitives.Name.get('Separation'), _primitives.Name.get('LogoGreen'), _primitives.Name.get('DeviceCMYK'), fnRef];
316
- var xref = new _test_utils.XRefMock([{
317
+
318
+ const fnRef = _primitives.Ref.get(10, 0);
319
+
320
+ const cs = [_primitives.Name.get("Separation"), _primitives.Name.get("LogoGreen"), _primitives.Name.get("DeviceCMYK"), fnRef];
321
+ const xref = new _test_utils.XRefMock([{
317
322
  ref: fnRef,
318
323
  data: fn
319
324
  }]);
320
- var res = new _primitives.Dict();
321
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
322
- xref: xref
325
+ const res = new _primitives.Dict();
326
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
327
+ xref
323
328
  });
324
329
 
325
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
330
+ const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
326
331
 
327
- var testSrc = new Uint8Array([27, 25, 50, 31]);
328
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
329
- var expectedDest = new Uint8ClampedArray([226, 242, 241, 226, 242, 241, 229, 244, 242, 226, 242, 241, 226, 242, 241, 229, 244, 242, 203, 232, 229, 203, 232, 229, 222, 241, 238]);
332
+ const testSrc = new Uint8Array([27, 25, 50, 31]);
333
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
334
+ const expectedDest = new Uint8ClampedArray([226, 242, 241, 226, 242, 241, 229, 244, 242, 226, 242, 241, 226, 242, 241, 229, 244, 242, 203, 232, 229, 203, 232, 229, 222, 241, 238]);
330
335
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
331
336
  expect(colorSpace.getRgb([0.1], 0)).toEqual(new Uint8ClampedArray([228, 243, 242]));
332
337
  expect(colorSpace.isPassthrough(8)).toBeFalsy();