pdfjs-dist 2.2.228 → 2.6.347

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 (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2019 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -21,26 +21,28 @@
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 _image_utils = require("../../core/image_utils.js");
31
31
 
32
- var _test_utils = require("./test_utils");
32
+ var _function = require("../../core/function.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
+ var _test_utils = require("./test_utils.js");
35
+
36
+ describe("colorspace", function () {
37
+ describe("ColorSpace.isDefaultDecode", function () {
38
+ it("should be true if decode is not an array", function () {
39
+ expect(_colorspace.ColorSpace.isDefaultDecode("string", 0)).toBeTruthy();
38
40
  });
39
- it('should be true if length of decode array is not correct', function () {
41
+ it("should be true if length of decode array is not correct", function () {
40
42
  expect(_colorspace.ColorSpace.isDefaultDecode([0], 1)).toBeTruthy();
41
43
  expect(_colorspace.ColorSpace.isDefaultDecode([0, 1, 0], 1)).toBeTruthy();
42
44
  });
43
- it('should be true if decode map matches the default decode map', function () {
45
+ it("should be true if decode map matches the default decode map", function () {
44
46
  expect(_colorspace.ColorSpace.isDefaultDecode([], 0)).toBeTruthy();
45
47
  expect(_colorspace.ColorSpace.isDefaultDecode([0, 0], 1)).toBeFalsy();
46
48
  expect(_colorspace.ColorSpace.isDefaultDecode([0, 1], 1)).toBeTruthy();
@@ -50,47 +52,183 @@ describe('colorspace', function () {
50
52
  expect(_colorspace.ColorSpace.isDefaultDecode([1, 0, 0, 1, 0, 1, 0, 1], 4)).toBeFalsy();
51
53
  });
52
54
  });
53
- describe('DeviceGrayCS', function () {
54
- it('should handle the case when cs is a Name object', function () {
55
- var cs = _primitives.Name.get('DeviceGray');
55
+ describe("ColorSpace caching", function () {
56
+ let localColorSpaceCache = null;
57
+ beforeAll(function (done) {
58
+ localColorSpaceCache = new _image_utils.LocalColorSpaceCache();
59
+ done();
60
+ });
61
+ afterAll(function (done) {
62
+ localColorSpaceCache = null;
63
+ done();
64
+ });
65
+ it("caching by Name", function () {
66
+ const xref = new _test_utils.XRefMock();
67
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
68
+ xref
69
+ });
70
+
71
+ const colorSpace1 = _colorspace.ColorSpace.parse({
72
+ cs: _primitives.Name.get("Pattern"),
73
+ xref,
74
+ resources: null,
75
+ pdfFunctionFactory,
76
+ localColorSpaceCache
77
+ });
78
+
79
+ expect(colorSpace1.name).toEqual("Pattern");
80
+
81
+ const colorSpace2 = _colorspace.ColorSpace.parse({
82
+ cs: _primitives.Name.get("Pattern"),
83
+ xref,
84
+ resources: null,
85
+ pdfFunctionFactory,
86
+ localColorSpaceCache
87
+ });
88
+
89
+ expect(colorSpace2.name).toEqual("Pattern");
90
+
91
+ const colorSpaceNonCached = _colorspace.ColorSpace.parse({
92
+ cs: _primitives.Name.get("Pattern"),
93
+ xref,
94
+ resources: null,
95
+ pdfFunctionFactory,
96
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
97
+ });
98
+
99
+ expect(colorSpaceNonCached.name).toEqual("Pattern");
100
+
101
+ const colorSpaceOther = _colorspace.ColorSpace.parse({
102
+ cs: _primitives.Name.get("RGB"),
103
+ xref,
104
+ resources: null,
105
+ pdfFunctionFactory,
106
+ localColorSpaceCache
107
+ });
108
+
109
+ expect(colorSpaceOther.name).toEqual("DeviceRGB");
110
+ expect(colorSpace1).toBe(colorSpace2);
111
+ expect(colorSpace1).not.toBe(colorSpaceNonCached);
112
+ expect(colorSpace1).not.toBe(colorSpaceOther);
113
+ });
114
+ it("caching by Ref", function () {
115
+ const paramsCalGray = new _primitives.Dict();
116
+ paramsCalGray.set("WhitePoint", [1, 1, 1]);
117
+ paramsCalGray.set("BlackPoint", [0, 0, 0]);
118
+ paramsCalGray.set("Gamma", 2.0);
119
+ const paramsCalRGB = new _primitives.Dict();
120
+ paramsCalRGB.set("WhitePoint", [1, 1, 1]);
121
+ paramsCalRGB.set("BlackPoint", [0, 0, 0]);
122
+ paramsCalRGB.set("Gamma", [1, 1, 1]);
123
+ paramsCalRGB.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
124
+ const xref = new _test_utils.XRefMock([{
125
+ ref: _primitives.Ref.get(50, 0),
126
+ data: [_primitives.Name.get("CalGray"), paramsCalGray]
127
+ }, {
128
+ ref: _primitives.Ref.get(100, 0),
129
+ data: [_primitives.Name.get("CalRGB"), paramsCalRGB]
130
+ }]);
131
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
132
+ xref
133
+ });
134
+
135
+ const colorSpace1 = _colorspace.ColorSpace.parse({
136
+ cs: _primitives.Ref.get(50, 0),
137
+ xref,
138
+ resources: null,
139
+ pdfFunctionFactory,
140
+ localColorSpaceCache
141
+ });
142
+
143
+ expect(colorSpace1.name).toEqual("CalGray");
144
+
145
+ const colorSpace2 = _colorspace.ColorSpace.parse({
146
+ cs: _primitives.Ref.get(50, 0),
147
+ xref,
148
+ resources: null,
149
+ pdfFunctionFactory,
150
+ localColorSpaceCache
151
+ });
152
+
153
+ expect(colorSpace2.name).toEqual("CalGray");
154
+
155
+ const colorSpaceNonCached = _colorspace.ColorSpace.parse({
156
+ cs: _primitives.Ref.get(50, 0),
157
+ xref,
158
+ resources: null,
159
+ pdfFunctionFactory,
160
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
161
+ });
162
+
163
+ expect(colorSpaceNonCached.name).toEqual("CalGray");
164
+
165
+ const colorSpaceOther = _colorspace.ColorSpace.parse({
166
+ cs: _primitives.Ref.get(100, 0),
167
+ xref,
168
+ resources: null,
169
+ pdfFunctionFactory,
170
+ localColorSpaceCache
171
+ });
172
+
173
+ expect(colorSpaceOther.name).toEqual("CalRGB");
174
+ expect(colorSpace1).toBe(colorSpace2);
175
+ expect(colorSpace1).not.toBe(colorSpaceNonCached);
176
+ expect(colorSpace1).not.toBe(colorSpaceOther);
177
+ });
178
+ });
179
+ describe("DeviceGrayCS", function () {
180
+ it("should handle the case when cs is a Name object", function () {
181
+ const cs = _primitives.Name.get("DeviceGray");
56
182
 
57
- var xref = new _test_utils.XRefMock([{
183
+ const xref = new _test_utils.XRefMock([{
58
184
  ref: _primitives.Ref.get(10, 0),
59
185
  data: new _primitives.Dict()
60
186
  }]);
61
- var res = new _primitives.Dict();
62
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
63
- xref: xref
187
+ const resources = new _primitives.Dict();
188
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
189
+ xref
64
190
  });
65
191
 
66
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
192
+ const colorSpace = _colorspace.ColorSpace.parse({
193
+ cs,
194
+ xref,
195
+ resources,
196
+ pdfFunctionFactory,
197
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
198
+ });
67
199
 
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]);
200
+ const testSrc = new Uint8Array([27, 125, 250, 131]);
201
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
202
+ 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
203
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
72
204
  expect(colorSpace.getRgb(new Float32Array([0.1]), 0)).toEqual(new Uint8ClampedArray([26, 26, 26]));
73
205
  expect(colorSpace.getOutputLength(2, 0)).toEqual(6);
74
206
  expect(colorSpace.isPassthrough(8)).toBeFalsy();
75
207
  expect(testDest).toEqual(expectedDest);
76
208
  });
77
- it('should handle the case when cs is an indirect object', function () {
78
- var cs = _primitives.Ref.get(10, 0);
209
+ it("should handle the case when cs is an indirect object", function () {
210
+ const cs = _primitives.Ref.get(10, 0);
79
211
 
80
- var xref = new _test_utils.XRefMock([{
212
+ const xref = new _test_utils.XRefMock([{
81
213
  ref: cs,
82
- data: _primitives.Name.get('DeviceGray')
214
+ data: _primitives.Name.get("DeviceGray")
83
215
  }]);
84
- var res = new _primitives.Dict();
85
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
86
- xref: xref
216
+ const resources = new _primitives.Dict();
217
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
218
+ xref
87
219
  });
88
220
 
89
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
221
+ const colorSpace = _colorspace.ColorSpace.parse({
222
+ cs,
223
+ xref,
224
+ resources,
225
+ pdfFunctionFactory,
226
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
227
+ });
90
228
 
91
- var testSrc = new Uint8Array([27, 125, 250, 131]);
92
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
93
- 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]);
229
+ const testSrc = new Uint8Array([27, 125, 250, 131]);
230
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
231
+ 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]);
94
232
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
95
233
  expect(colorSpace.getRgb(new Float32Array([0.2]), 0)).toEqual(new Uint8ClampedArray([51, 51, 51]));
96
234
  expect(colorSpace.getOutputLength(3, 1)).toEqual(12);
@@ -98,47 +236,59 @@ describe('colorspace', function () {
98
236
  expect(testDest).toEqual(expectedDest);
99
237
  });
100
238
  });
101
- describe('DeviceRgbCS', function () {
102
- it('should handle the case when cs is a Name object', function () {
103
- var cs = _primitives.Name.get('DeviceRGB');
239
+ describe("DeviceRgbCS", function () {
240
+ it("should handle the case when cs is a Name object", function () {
241
+ const cs = _primitives.Name.get("DeviceRGB");
104
242
 
105
- var xref = new _test_utils.XRefMock([{
243
+ const xref = new _test_utils.XRefMock([{
106
244
  ref: _primitives.Ref.get(10, 0),
107
245
  data: new _primitives.Dict()
108
246
  }]);
109
- var res = new _primitives.Dict();
110
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
111
- xref: xref
247
+ const resources = new _primitives.Dict();
248
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
249
+ xref
112
250
  });
113
251
 
114
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
252
+ const colorSpace = _colorspace.ColorSpace.parse({
253
+ cs,
254
+ xref,
255
+ resources,
256
+ pdfFunctionFactory,
257
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
258
+ });
115
259
 
116
- var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
117
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
118
- 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]);
260
+ const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
261
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
262
+ 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]);
119
263
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
120
264
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
121
265
  expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
122
266
  expect(colorSpace.isPassthrough(8)).toBeTruthy();
123
267
  expect(testDest).toEqual(expectedDest);
124
268
  });
125
- it('should handle the case when cs is an indirect object', function () {
126
- var cs = _primitives.Ref.get(10, 0);
269
+ it("should handle the case when cs is an indirect object", function () {
270
+ const cs = _primitives.Ref.get(10, 0);
127
271
 
128
- var xref = new _test_utils.XRefMock([{
272
+ const xref = new _test_utils.XRefMock([{
129
273
  ref: cs,
130
- data: _primitives.Name.get('DeviceRGB')
274
+ data: _primitives.Name.get("DeviceRGB")
131
275
  }]);
132
- var res = new _primitives.Dict();
133
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
134
- xref: xref
276
+ const resources = new _primitives.Dict();
277
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
278
+ xref
135
279
  });
136
280
 
137
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
281
+ const colorSpace = _colorspace.ColorSpace.parse({
282
+ cs,
283
+ xref,
284
+ resources,
285
+ pdfFunctionFactory,
286
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
287
+ });
138
288
 
139
- var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
140
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
141
- 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]);
289
+ const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
290
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
291
+ 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]);
142
292
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
143
293
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
144
294
  expect(colorSpace.getOutputLength(4, 1)).toEqual(5);
@@ -146,47 +296,59 @@ describe('colorspace', function () {
146
296
  expect(testDest).toEqual(expectedDest);
147
297
  });
148
298
  });
149
- describe('DeviceCmykCS', function () {
150
- it('should handle the case when cs is a Name object', function () {
151
- var cs = _primitives.Name.get('DeviceCMYK');
299
+ describe("DeviceCmykCS", function () {
300
+ it("should handle the case when cs is a Name object", function () {
301
+ const cs = _primitives.Name.get("DeviceCMYK");
152
302
 
153
- var xref = new _test_utils.XRefMock([{
303
+ const xref = new _test_utils.XRefMock([{
154
304
  ref: _primitives.Ref.get(10, 0),
155
305
  data: new _primitives.Dict()
156
306
  }]);
157
- var res = new _primitives.Dict();
158
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
159
- xref: xref
307
+ const resources = new _primitives.Dict();
308
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
309
+ xref
160
310
  });
161
311
 
162
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
312
+ const colorSpace = _colorspace.ColorSpace.parse({
313
+ cs,
314
+ xref,
315
+ resources,
316
+ pdfFunctionFactory,
317
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
318
+ });
163
319
 
164
- var testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
165
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
166
- 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]);
320
+ const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
321
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
322
+ 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]);
167
323
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
168
324
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
169
325
  expect(colorSpace.getOutputLength(4, 0)).toEqual(3);
170
326
  expect(colorSpace.isPassthrough(8)).toBeFalsy();
171
327
  expect(testDest).toEqual(expectedDest);
172
328
  });
173
- it('should handle the case when cs is an indirect object', function () {
174
- var cs = _primitives.Ref.get(10, 0);
329
+ it("should handle the case when cs is an indirect object", function () {
330
+ const cs = _primitives.Ref.get(10, 0);
175
331
 
176
- var xref = new _test_utils.XRefMock([{
332
+ const xref = new _test_utils.XRefMock([{
177
333
  ref: cs,
178
- data: _primitives.Name.get('DeviceCMYK')
334
+ data: _primitives.Name.get("DeviceCMYK")
179
335
  }]);
180
- var res = new _primitives.Dict();
181
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
182
- xref: xref
336
+ const resources = new _primitives.Dict();
337
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
338
+ xref
183
339
  });
184
340
 
185
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
341
+ const colorSpace = _colorspace.ColorSpace.parse({
342
+ cs,
343
+ xref,
344
+ resources,
345
+ pdfFunctionFactory,
346
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
347
+ });
186
348
 
187
- var testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
188
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
189
- 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]);
349
+ const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
350
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
351
+ 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]);
190
352
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
191
353
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
192
354
  expect(colorSpace.getOutputLength(4, 1)).toEqual(4);
@@ -194,27 +356,33 @@ describe('colorspace', function () {
194
356
  expect(testDest).toEqual(expectedDest);
195
357
  });
196
358
  });
197
- describe('CalGrayCS', function () {
198
- it('should handle the case when cs is an array', function () {
199
- var 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
- var cs = [_primitives.Name.get('CalGray'), params];
204
- var xref = new _test_utils.XRefMock([{
359
+ describe("CalGrayCS", function () {
360
+ it("should handle the case when cs is an array", function () {
361
+ const params = new _primitives.Dict();
362
+ params.set("WhitePoint", [1, 1, 1]);
363
+ params.set("BlackPoint", [0, 0, 0]);
364
+ params.set("Gamma", 2.0);
365
+ const cs = [_primitives.Name.get("CalGray"), params];
366
+ const xref = new _test_utils.XRefMock([{
205
367
  ref: _primitives.Ref.get(10, 0),
206
368
  data: new _primitives.Dict()
207
369
  }]);
208
- var res = new _primitives.Dict();
209
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
210
- xref: xref
370
+ const resources = new _primitives.Dict();
371
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
372
+ xref
211
373
  });
212
374
 
213
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
375
+ const colorSpace = _colorspace.ColorSpace.parse({
376
+ cs,
377
+ xref,
378
+ resources,
379
+ pdfFunctionFactory,
380
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
381
+ });
214
382
 
215
- var testSrc = new Uint8Array([27, 125, 250, 131]);
216
- var testDest = new Uint8ClampedArray(4 * 4 * 3);
217
- 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]);
383
+ const testSrc = new Uint8Array([27, 125, 250, 131]);
384
+ const testDest = new Uint8ClampedArray(4 * 4 * 3);
385
+ 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]);
218
386
  colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
219
387
  expect(colorSpace.getRgb(new Float32Array([1.0]), 0)).toEqual(new Uint8ClampedArray([255, 255, 255]));
220
388
  expect(colorSpace.getOutputLength(4, 0)).toEqual(12);
@@ -222,28 +390,34 @@ describe('colorspace', function () {
222
390
  expect(testDest).toEqual(expectedDest);
223
391
  });
224
392
  });
225
- describe('CalRGBCS', function () {
226
- it('should handle the case when cs is an array', function () {
227
- var 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
- var cs = [_primitives.Name.get('CalRGB'), params];
233
- var xref = new _test_utils.XRefMock([{
393
+ describe("CalRGBCS", function () {
394
+ it("should handle the case when cs is an array", function () {
395
+ const params = new _primitives.Dict();
396
+ params.set("WhitePoint", [1, 1, 1]);
397
+ params.set("BlackPoint", [0, 0, 0]);
398
+ params.set("Gamma", [1, 1, 1]);
399
+ params.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
400
+ const cs = [_primitives.Name.get("CalRGB"), params];
401
+ const xref = new _test_utils.XRefMock([{
234
402
  ref: _primitives.Ref.get(10, 0),
235
403
  data: new _primitives.Dict()
236
404
  }]);
237
- var res = new _primitives.Dict();
238
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
239
- xref: xref
405
+ const resources = new _primitives.Dict();
406
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
407
+ xref
240
408
  });
241
409
 
242
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
410
+ const colorSpace = _colorspace.ColorSpace.parse({
411
+ cs,
412
+ xref,
413
+ resources,
414
+ pdfFunctionFactory,
415
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
416
+ });
243
417
 
244
- var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
245
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
246
- 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]);
418
+ const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
419
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
420
+ 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]);
247
421
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
248
422
  expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([0, 147, 151]));
249
423
  expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
@@ -251,27 +425,33 @@ describe('colorspace', function () {
251
425
  expect(testDest).toEqual(expectedDest);
252
426
  });
253
427
  });
254
- describe('LabCS', function () {
255
- it('should handle the case when cs is an array', function () {
256
- var 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
- var cs = [_primitives.Name.get('Lab'), params];
261
- var xref = new _test_utils.XRefMock([{
428
+ describe("LabCS", function () {
429
+ it("should handle the case when cs is an array", function () {
430
+ const params = new _primitives.Dict();
431
+ params.set("WhitePoint", [1, 1, 1]);
432
+ params.set("BlackPoint", [0, 0, 0]);
433
+ params.set("Range", [-100, 100, -100, 100]);
434
+ const cs = [_primitives.Name.get("Lab"), params];
435
+ const xref = new _test_utils.XRefMock([{
262
436
  ref: _primitives.Ref.get(10, 0),
263
437
  data: new _primitives.Dict()
264
438
  }]);
265
- var res = new _primitives.Dict();
266
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
267
- xref: xref
439
+ const resources = new _primitives.Dict();
440
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
441
+ xref
268
442
  });
269
443
 
270
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
444
+ const colorSpace = _colorspace.ColorSpace.parse({
445
+ cs,
446
+ xref,
447
+ resources,
448
+ pdfFunctionFactory,
449
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
450
+ });
271
451
 
272
- var testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
273
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
274
- 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]);
452
+ const testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
453
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
454
+ 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]);
275
455
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
276
456
  expect(colorSpace.getRgb([55, 25, 35], 0)).toEqual(new Uint8ClampedArray([188, 100, 61]));
277
457
  expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
@@ -280,24 +460,30 @@ describe('colorspace', function () {
280
460
  expect(testDest).toEqual(expectedDest);
281
461
  });
282
462
  });
283
- describe('IndexedCS', function () {
284
- it('should handle the case when cs is an array', function () {
285
- var lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]);
286
- var cs = [_primitives.Name.get('Indexed'), _primitives.Name.get('DeviceRGB'), 2, lookup];
287
- var xref = new _test_utils.XRefMock([{
463
+ describe("IndexedCS", function () {
464
+ it("should handle the case when cs is an array", function () {
465
+ const lookup = new _stream.Stream(new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]));
466
+ const cs = [_primitives.Name.get("Indexed"), _primitives.Name.get("DeviceRGB"), 2, lookup];
467
+ const xref = new _test_utils.XRefMock([{
288
468
  ref: _primitives.Ref.get(10, 0),
289
469
  data: new _primitives.Dict()
290
470
  }]);
291
- var res = new _primitives.Dict();
292
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
293
- xref: xref
471
+ const resources = new _primitives.Dict();
472
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
473
+ xref
294
474
  });
295
475
 
296
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
476
+ const colorSpace = _colorspace.ColorSpace.parse({
477
+ cs,
478
+ xref,
479
+ resources,
480
+ pdfFunctionFactory,
481
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
482
+ });
297
483
 
298
- var testSrc = new Uint8Array([2, 2, 0, 1]);
299
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
300
- 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]);
484
+ const testSrc = new Uint8Array([2, 2, 0, 1]);
485
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
486
+ 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]);
301
487
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
302
488
  expect(colorSpace.getRgb([2], 0)).toEqual(new Uint8ClampedArray([255, 109, 70]));
303
489
  expect(colorSpace.isPassthrough(8)).toBeFalsy();
@@ -305,33 +491,39 @@ describe('colorspace', function () {
305
491
  expect(testDest).toEqual(expectedDest);
306
492
  });
307
493
  });
308
- describe('AlternateCS', function () {
309
- it('should handle the case when cs is an array', function () {
310
- var 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
- var fn = new _stream.StringStream('{ dup 0.84 mul ' + 'exch 0.00 exch ' + 'dup 0.44 mul ' + 'exch 0.21 mul }');
494
+ describe("AlternateCS", function () {
495
+ it("should handle the case when cs is an array", function () {
496
+ const fnDict = new _primitives.Dict();
497
+ fnDict.set("FunctionType", 4);
498
+ fnDict.set("Domain", [0.0, 1.0]);
499
+ fnDict.set("Range", [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
500
+ fnDict.set("Length", 58);
501
+ let fn = new _stream.StringStream("{ dup 0.84 mul " + "exch 0.00 exch " + "dup 0.44 mul " + "exch 0.21 mul }");
316
502
  fn = new _stream.Stream(fn.bytes, 0, 58, fnDict);
317
503
 
318
- var fnRef = _primitives.Ref.get(10, 0);
504
+ const fnRef = _primitives.Ref.get(10, 0);
319
505
 
320
- var cs = [_primitives.Name.get('Separation'), _primitives.Name.get('LogoGreen'), _primitives.Name.get('DeviceCMYK'), fnRef];
321
- var xref = new _test_utils.XRefMock([{
506
+ const cs = [_primitives.Name.get("Separation"), _primitives.Name.get("LogoGreen"), _primitives.Name.get("DeviceCMYK"), fnRef];
507
+ const xref = new _test_utils.XRefMock([{
322
508
  ref: fnRef,
323
509
  data: fn
324
510
  }]);
325
- var res = new _primitives.Dict();
326
- var pdfFunctionFactory = new _function.PDFFunctionFactory({
327
- xref: xref
511
+ const resources = new _primitives.Dict();
512
+ const pdfFunctionFactory = new _function.PDFFunctionFactory({
513
+ xref
328
514
  });
329
515
 
330
- var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
516
+ const colorSpace = _colorspace.ColorSpace.parse({
517
+ cs,
518
+ xref,
519
+ resources,
520
+ pdfFunctionFactory,
521
+ localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
522
+ });
331
523
 
332
- var testSrc = new Uint8Array([27, 25, 50, 31]);
333
- var testDest = new Uint8ClampedArray(3 * 3 * 3);
334
- 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]);
524
+ const testSrc = new Uint8Array([27, 25, 50, 31]);
525
+ const testDest = new Uint8ClampedArray(3 * 3 * 3);
526
+ 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]);
335
527
  colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
336
528
  expect(colorSpace.getRgb([0.1], 0)).toEqual(new Uint8ClampedArray([228, 243, 242]));
337
529
  expect(colorSpace.isPassthrough(8)).toBeFalsy();