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.
@@ -26,46 +26,30 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.ColorSpace = void 0;
28
28
 
29
- var _util = require("../shared/util");
29
+ var _util = require("../shared/util.js");
30
30
 
31
- var _primitives = require("./primitives");
31
+ var _primitives = require("./primitives.js");
32
32
 
33
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
34
-
35
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
36
-
37
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
38
-
39
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
-
41
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
42
-
43
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
44
-
45
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
46
-
47
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
48
-
49
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
+ var _core_utils = require("./core_utils.js");
50
34
 
51
35
  function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
52
- var COMPONENTS = 3;
36
+ const COMPONENTS = 3;
53
37
  alpha01 = alpha01 !== 1 ? 0 : alpha01;
54
- var xRatio = w1 / w2;
55
- var yRatio = h1 / h2;
56
- var newIndex = 0,
38
+ const xRatio = w1 / w2;
39
+ const yRatio = h1 / h2;
40
+ let newIndex = 0,
57
41
  oldIndex;
58
- var xScaled = new Uint16Array(w2);
59
- var w1Scanline = w1 * COMPONENTS;
42
+ const xScaled = new Uint16Array(w2);
43
+ const w1Scanline = w1 * COMPONENTS;
60
44
 
61
- for (var i = 0; i < w2; i++) {
45
+ for (let i = 0; i < w2; i++) {
62
46
  xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
63
47
  }
64
48
 
65
- for (var _i = 0; _i < h2; _i++) {
66
- var py = Math.floor(_i * yRatio) * w1Scanline;
49
+ for (let i = 0; i < h2; i++) {
50
+ const py = Math.floor(i * yRatio) * w1Scanline;
67
51
 
68
- for (var j = 0; j < w2; j++) {
52
+ for (let j = 0; j < w2; j++) {
69
53
  oldIndex = py + xScaled[j];
70
54
  dest[newIndex++] = src[oldIndex++];
71
55
  dest[newIndex++] = src[oldIndex++];
@@ -75,806 +59,700 @@ function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
75
59
  }
76
60
  }
77
61
 
78
- var ColorSpace =
79
- /*#__PURE__*/
80
- function () {
81
- function ColorSpace(name, numComps) {
82
- _classCallCheck(this, ColorSpace);
83
-
62
+ class ColorSpace {
63
+ constructor(name, numComps) {
84
64
  if (this.constructor === ColorSpace) {
85
- (0, _util.unreachable)('Cannot initialize ColorSpace.');
65
+ (0, _util.unreachable)("Cannot initialize ColorSpace.");
86
66
  }
87
67
 
88
68
  this.name = name;
89
69
  this.numComps = numComps;
90
70
  }
91
71
 
92
- _createClass(ColorSpace, [{
93
- key: "getRgb",
94
- value: function getRgb(src, srcOffset) {
95
- var rgb = new Uint8ClampedArray(3);
96
- this.getRgbItem(src, srcOffset, rgb, 0);
97
- return rgb;
98
- }
99
- }, {
100
- key: "getRgbItem",
101
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
102
- (0, _util.unreachable)('Should not call ColorSpace.getRgbItem');
72
+ getRgb(src, srcOffset) {
73
+ const rgb = new Uint8ClampedArray(3);
74
+ this.getRgbItem(src, srcOffset, rgb, 0);
75
+ return rgb;
76
+ }
77
+
78
+ getRgbItem(src, srcOffset, dest, destOffset) {
79
+ (0, _util.unreachable)("Should not call ColorSpace.getRgbItem");
80
+ }
81
+
82
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
83
+ (0, _util.unreachable)("Should not call ColorSpace.getRgbBuffer");
84
+ }
85
+
86
+ getOutputLength(inputLength, alpha01) {
87
+ (0, _util.unreachable)("Should not call ColorSpace.getOutputLength");
88
+ }
89
+
90
+ isPassthrough(bits) {
91
+ return false;
92
+ }
93
+
94
+ isDefaultDecode(decodeMap, bpc) {
95
+ return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
96
+ }
97
+
98
+ fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
99
+ const count = originalWidth * originalHeight;
100
+ let rgbBuf = null;
101
+ const numComponentColors = 1 << bpc;
102
+ const needsResizing = originalHeight !== height || originalWidth !== width;
103
+
104
+ if (this.isPassthrough(bpc)) {
105
+ rgbBuf = comps;
106
+ } else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
107
+ const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
108
+
109
+ for (let i = 0; i < numComponentColors; i++) {
110
+ allColors[i] = i;
111
+ }
112
+
113
+ const colorMap = new Uint8ClampedArray(numComponentColors * 3);
114
+ this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
115
+
116
+ if (!needsResizing) {
117
+ let destPos = 0;
118
+
119
+ for (let i = 0; i < count; ++i) {
120
+ const key = comps[i] * 3;
121
+ dest[destPos++] = colorMap[key];
122
+ dest[destPos++] = colorMap[key + 1];
123
+ dest[destPos++] = colorMap[key + 2];
124
+ destPos += alpha01;
125
+ }
126
+ } else {
127
+ rgbBuf = new Uint8Array(count * 3);
128
+ let rgbPos = 0;
129
+
130
+ for (let i = 0; i < count; ++i) {
131
+ const key = comps[i] * 3;
132
+ rgbBuf[rgbPos++] = colorMap[key];
133
+ rgbBuf[rgbPos++] = colorMap[key + 1];
134
+ rgbBuf[rgbPos++] = colorMap[key + 2];
135
+ }
136
+ }
137
+ } else {
138
+ if (!needsResizing) {
139
+ this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
140
+ } else {
141
+ rgbBuf = new Uint8ClampedArray(count * 3);
142
+ this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
143
+ }
103
144
  }
104
- }, {
105
- key: "getRgbBuffer",
106
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
107
- (0, _util.unreachable)('Should not call ColorSpace.getRgbBuffer');
145
+
146
+ if (rgbBuf) {
147
+ if (needsResizing) {
148
+ resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
149
+ } else {
150
+ let destPos = 0,
151
+ rgbPos = 0;
152
+
153
+ for (let i = 0, ii = width * actualHeight; i < ii; i++) {
154
+ dest[destPos++] = rgbBuf[rgbPos++];
155
+ dest[destPos++] = rgbBuf[rgbPos++];
156
+ dest[destPos++] = rgbBuf[rgbPos++];
157
+ destPos += alpha01;
158
+ }
159
+ }
108
160
  }
109
- }, {
110
- key: "getOutputLength",
111
- value: function getOutputLength(inputLength, alpha01) {
112
- (0, _util.unreachable)('Should not call ColorSpace.getOutputLength');
161
+ }
162
+
163
+ get usesZeroToOneRange() {
164
+ return (0, _util.shadow)(this, "usesZeroToOneRange", true);
165
+ }
166
+
167
+ static _cache(cacheKey, xref, localColorSpaceCache, parsedColorSpace) {
168
+ if (!localColorSpaceCache) {
169
+ throw new Error('ColorSpace._cache - expected "localColorSpaceCache" argument.');
113
170
  }
114
- }, {
115
- key: "isPassthrough",
116
- value: function isPassthrough(bits) {
117
- return false;
171
+
172
+ if (!parsedColorSpace) {
173
+ throw new Error('ColorSpace._cache - expected "parsedColorSpace" argument.');
118
174
  }
119
- }, {
120
- key: "isDefaultDecode",
121
- value: function isDefaultDecode(decodeMap, bpc) {
122
- return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
175
+
176
+ let csName, csRef;
177
+
178
+ if (cacheKey instanceof _primitives.Ref) {
179
+ csRef = cacheKey;
180
+ cacheKey = xref.fetch(cacheKey);
123
181
  }
124
- }, {
125
- key: "fillRgb",
126
- value: function fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
127
- var count = originalWidth * originalHeight;
128
- var rgbBuf = null;
129
- var numComponentColors = 1 << bpc;
130
- var needsResizing = originalHeight !== height || originalWidth !== width;
131
-
132
- if (this.isPassthrough(bpc)) {
133
- rgbBuf = comps;
134
- } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
135
- var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
136
-
137
- for (var i = 0; i < numComponentColors; i++) {
138
- allColors[i] = i;
139
- }
140
182
 
141
- var colorMap = new Uint8ClampedArray(numComponentColors * 3);
142
- this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
183
+ if (cacheKey instanceof _primitives.Name) {
184
+ csName = cacheKey.name;
185
+ }
143
186
 
144
- if (!needsResizing) {
145
- var destPos = 0;
187
+ if (csName || csRef) {
188
+ localColorSpaceCache.set(csName, csRef, parsedColorSpace);
189
+ }
190
+ }
146
191
 
147
- for (var _i2 = 0; _i2 < count; ++_i2) {
148
- var key = comps[_i2] * 3;
149
- dest[destPos++] = colorMap[key];
150
- dest[destPos++] = colorMap[key + 1];
151
- dest[destPos++] = colorMap[key + 2];
152
- destPos += alpha01;
153
- }
154
- } else {
155
- rgbBuf = new Uint8Array(count * 3);
156
- var rgbPos = 0;
192
+ static getCached(cacheKey, xref, localColorSpaceCache) {
193
+ if (!localColorSpaceCache) {
194
+ throw new Error('ColorSpace.getCached - expected "localColorSpaceCache" argument.');
195
+ }
157
196
 
158
- for (var _i3 = 0; _i3 < count; ++_i3) {
159
- var _key = comps[_i3] * 3;
197
+ if (cacheKey instanceof _primitives.Ref) {
198
+ const localColorSpace = localColorSpaceCache.getByRef(cacheKey);
160
199
 
161
- rgbBuf[rgbPos++] = colorMap[_key];
162
- rgbBuf[rgbPos++] = colorMap[_key + 1];
163
- rgbBuf[rgbPos++] = colorMap[_key + 2];
164
- }
165
- }
166
- } else {
167
- if (!needsResizing) {
168
- this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
169
- } else {
170
- rgbBuf = new Uint8ClampedArray(count * 3);
171
- this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
172
- }
200
+ if (localColorSpace) {
201
+ return localColorSpace;
173
202
  }
174
203
 
175
- if (rgbBuf) {
176
- if (needsResizing) {
177
- resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
178
- } else {
179
- var _destPos = 0,
180
- _rgbPos = 0;
181
-
182
- for (var _i4 = 0, ii = width * actualHeight; _i4 < ii; _i4++) {
183
- dest[_destPos++] = rgbBuf[_rgbPos++];
184
- dest[_destPos++] = rgbBuf[_rgbPos++];
185
- dest[_destPos++] = rgbBuf[_rgbPos++];
186
- _destPos += alpha01;
187
- }
204
+ try {
205
+ cacheKey = xref.fetch(cacheKey);
206
+ } catch (ex) {
207
+ if (ex instanceof _core_utils.MissingDataException) {
208
+ throw ex;
188
209
  }
189
210
  }
190
211
  }
191
- }, {
192
- key: "usesZeroToOneRange",
193
- get: function get() {
194
- return (0, _util.shadow)(this, 'usesZeroToOneRange', true);
195
- }
196
- }], [{
197
- key: "parse",
198
- value: function parse(cs, xref, res, pdfFunctionFactory) {
199
- var IR = this.parseToIR(cs, xref, res, pdfFunctionFactory);
200
- return this.fromIR(IR);
212
+
213
+ if (cacheKey instanceof _primitives.Name) {
214
+ const localColorSpace = localColorSpaceCache.getByName(cacheKey.name);
215
+
216
+ if (localColorSpace) {
217
+ return localColorSpace;
218
+ }
201
219
  }
202
- }, {
203
- key: "fromIR",
204
- value: function fromIR(IR) {
205
- var name = Array.isArray(IR) ? IR[0] : IR;
206
- var whitePoint, blackPoint, gamma;
207
-
208
- switch (name) {
209
- case 'DeviceGrayCS':
210
- return this.singletons.gray;
211
220
 
212
- case 'DeviceRgbCS':
213
- return this.singletons.rgb;
221
+ return null;
222
+ }
214
223
 
215
- case 'DeviceCmykCS':
216
- return this.singletons.cmyk;
224
+ static async parseAsync({
225
+ cs,
226
+ xref,
227
+ resources = null,
228
+ pdfFunctionFactory,
229
+ localColorSpaceCache
230
+ }) {
231
+ const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
217
232
 
218
- case 'CalGrayCS':
219
- whitePoint = IR[1];
220
- blackPoint = IR[2];
221
- gamma = IR[3];
222
- return new CalGrayCS(whitePoint, blackPoint, gamma);
233
+ this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
223
234
 
224
- case 'CalRGBCS':
225
- whitePoint = IR[1];
226
- blackPoint = IR[2];
227
- gamma = IR[3];
228
- var matrix = IR[4];
229
- return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
235
+ return parsedColorSpace;
236
+ }
230
237
 
231
- case 'PatternCS':
232
- var basePatternCS = IR[1];
238
+ static parse({
239
+ cs,
240
+ xref,
241
+ resources = null,
242
+ pdfFunctionFactory,
243
+ localColorSpaceCache
244
+ }) {
245
+ const cachedColorSpace = this.getCached(cs, xref, localColorSpaceCache);
246
+
247
+ if (cachedColorSpace) {
248
+ return cachedColorSpace;
249
+ }
233
250
 
234
- if (basePatternCS) {
235
- basePatternCS = this.fromIR(basePatternCS);
236
- }
251
+ const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
237
252
 
238
- return new PatternCS(basePatternCS);
253
+ this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
239
254
 
240
- case 'IndexedCS':
241
- var baseIndexedCS = IR[1];
242
- var hiVal = IR[2];
243
- var lookup = IR[3];
244
- return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);
255
+ return parsedColorSpace;
256
+ }
245
257
 
246
- case 'AlternateCS':
247
- var numComps = IR[1];
248
- var alt = IR[2];
249
- var tintFn = IR[3];
250
- return new AlternateCS(numComps, this.fromIR(alt), tintFn);
258
+ static _parse(cs, xref, resources = null, pdfFunctionFactory) {
259
+ cs = xref.fetchIfRef(cs);
251
260
 
252
- case 'LabCS':
253
- whitePoint = IR[1];
254
- blackPoint = IR[2];
255
- var range = IR[3];
256
- return new LabCS(whitePoint, blackPoint, range);
261
+ if ((0, _primitives.isName)(cs)) {
262
+ switch (cs.name) {
263
+ case "DeviceGray":
264
+ case "G":
265
+ return this.singletons.gray;
266
+
267
+ case "DeviceRGB":
268
+ case "RGB":
269
+ return this.singletons.rgb;
270
+
271
+ case "DeviceCMYK":
272
+ case "CMYK":
273
+ return this.singletons.cmyk;
274
+
275
+ case "Pattern":
276
+ return new PatternCS(null);
257
277
 
258
278
  default:
259
- throw new _util.FormatError("Unknown colorspace name: ".concat(name));
260
- }
261
- }
262
- }, {
263
- key: "parseToIR",
264
- value: function parseToIR(cs, xref) {
265
- var res = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
266
- var pdfFunctionFactory = arguments.length > 3 ? arguments[3] : undefined;
267
- cs = xref.fetchIfRef(cs);
268
-
269
- if ((0, _primitives.isName)(cs)) {
270
- switch (cs.name) {
271
- case 'DeviceGray':
272
- case 'G':
273
- return 'DeviceGrayCS';
274
-
275
- case 'DeviceRGB':
276
- case 'RGB':
277
- return 'DeviceRgbCS';
278
-
279
- case 'DeviceCMYK':
280
- case 'CMYK':
281
- return 'DeviceCmykCS';
282
-
283
- case 'Pattern':
284
- return ['PatternCS', null];
285
-
286
- default:
287
- if ((0, _primitives.isDict)(res)) {
288
- var colorSpaces = res.get('ColorSpace');
289
-
290
- if ((0, _primitives.isDict)(colorSpaces)) {
291
- var resCS = colorSpaces.get(cs.name);
292
-
293
- if (resCS) {
294
- if ((0, _primitives.isName)(resCS)) {
295
- return this.parseToIR(resCS, xref, res, pdfFunctionFactory);
296
- }
297
-
298
- cs = resCS;
299
- break;
279
+ if ((0, _primitives.isDict)(resources)) {
280
+ const colorSpaces = resources.get("ColorSpace");
281
+
282
+ if ((0, _primitives.isDict)(colorSpaces)) {
283
+ const resourcesCS = colorSpaces.get(cs.name);
284
+
285
+ if (resourcesCS) {
286
+ if ((0, _primitives.isName)(resourcesCS)) {
287
+ return this._parse(resourcesCS, xref, resources, pdfFunctionFactory);
300
288
  }
289
+
290
+ cs = resourcesCS;
291
+ break;
301
292
  }
302
293
  }
294
+ }
303
295
 
304
- throw new _util.FormatError("unrecognized colorspace ".concat(cs.name));
305
- }
296
+ throw new _util.FormatError(`Unrecognized ColorSpace: ${cs.name}`);
306
297
  }
298
+ }
307
299
 
308
- if (Array.isArray(cs)) {
309
- var mode = xref.fetchIfRef(cs[0]).name;
310
- var numComps, params, alt, whitePoint, blackPoint, gamma;
311
-
312
- switch (mode) {
313
- case 'DeviceGray':
314
- case 'G':
315
- return 'DeviceGrayCS';
316
-
317
- case 'DeviceRGB':
318
- case 'RGB':
319
- return 'DeviceRgbCS';
320
-
321
- case 'DeviceCMYK':
322
- case 'CMYK':
323
- return 'DeviceCmykCS';
324
-
325
- case 'CalGray':
326
- params = xref.fetchIfRef(cs[1]);
327
- whitePoint = params.getArray('WhitePoint');
328
- blackPoint = params.getArray('BlackPoint');
329
- gamma = params.get('Gamma');
330
- return ['CalGrayCS', whitePoint, blackPoint, gamma];
331
-
332
- case 'CalRGB':
333
- params = xref.fetchIfRef(cs[1]);
334
- whitePoint = params.getArray('WhitePoint');
335
- blackPoint = params.getArray('BlackPoint');
336
- gamma = params.getArray('Gamma');
337
- var matrix = params.getArray('Matrix');
338
- return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
339
-
340
- case 'ICCBased':
341
- var stream = xref.fetchIfRef(cs[1]);
342
- var dict = stream.dict;
343
- numComps = dict.get('N');
344
- alt = dict.get('Alternate');
345
-
346
- if (alt) {
347
- var altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);
348
- var altCS = this.fromIR(altIR, pdfFunctionFactory);
349
-
350
- if (altCS.numComps === numComps) {
351
- return altIR;
352
- }
300
+ if (Array.isArray(cs)) {
301
+ const mode = xref.fetchIfRef(cs[0]).name;
302
+ let params, numComps, baseCS, whitePoint, blackPoint, gamma;
353
303
 
354
- (0, _util.warn)('ICCBased color space: Ignoring incorrect /Alternate entry.');
355
- }
304
+ switch (mode) {
305
+ case "DeviceGray":
306
+ case "G":
307
+ return this.singletons.gray;
356
308
 
357
- if (numComps === 1) {
358
- return 'DeviceGrayCS';
359
- } else if (numComps === 3) {
360
- return 'DeviceRgbCS';
361
- } else if (numComps === 4) {
362
- return 'DeviceCmykCS';
363
- }
309
+ case "DeviceRGB":
310
+ case "RGB":
311
+ return this.singletons.rgb;
312
+
313
+ case "DeviceCMYK":
314
+ case "CMYK":
315
+ return this.singletons.cmyk;
364
316
 
365
- break;
317
+ case "CalGray":
318
+ params = xref.fetchIfRef(cs[1]);
319
+ whitePoint = params.getArray("WhitePoint");
320
+ blackPoint = params.getArray("BlackPoint");
321
+ gamma = params.get("Gamma");
322
+ return new CalGrayCS(whitePoint, blackPoint, gamma);
323
+
324
+ case "CalRGB":
325
+ params = xref.fetchIfRef(cs[1]);
326
+ whitePoint = params.getArray("WhitePoint");
327
+ blackPoint = params.getArray("BlackPoint");
328
+ gamma = params.getArray("Gamma");
329
+ const matrix = params.getArray("Matrix");
330
+ return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
331
+
332
+ case "ICCBased":
333
+ const stream = xref.fetchIfRef(cs[1]);
334
+ const dict = stream.dict;
335
+ numComps = dict.get("N");
336
+ const alt = dict.get("Alternate");
366
337
 
367
- case 'Pattern':
368
- var basePatternCS = cs[1] || null;
338
+ if (alt) {
339
+ const altCS = this._parse(alt, xref, resources, pdfFunctionFactory);
369
340
 
370
- if (basePatternCS) {
371
- basePatternCS = this.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);
341
+ if (altCS.numComps === numComps) {
342
+ return altCS;
372
343
  }
373
344
 
374
- return ['PatternCS', basePatternCS];
345
+ (0, _util.warn)("ICCBased color space: Ignoring incorrect /Alternate entry.");
346
+ }
375
347
 
376
- case 'Indexed':
377
- case 'I':
378
- var baseIndexedCS = this.parseToIR(cs[1], xref, res, pdfFunctionFactory);
379
- var hiVal = xref.fetchIfRef(cs[2]) + 1;
380
- var lookup = xref.fetchIfRef(cs[3]);
348
+ if (numComps === 1) {
349
+ return this.singletons.gray;
350
+ } else if (numComps === 3) {
351
+ return this.singletons.rgb;
352
+ } else if (numComps === 4) {
353
+ return this.singletons.cmyk;
354
+ }
381
355
 
382
- if ((0, _primitives.isStream)(lookup)) {
383
- lookup = lookup.getBytes();
384
- }
356
+ break;
385
357
 
386
- return ['IndexedCS', baseIndexedCS, hiVal, lookup];
387
-
388
- case 'Separation':
389
- case 'DeviceN':
390
- var name = xref.fetchIfRef(cs[1]);
391
- numComps = Array.isArray(name) ? name.length : 1;
392
- alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);
393
- var tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));
394
- return ['AlternateCS', numComps, alt, tintFn];
395
-
396
- case 'Lab':
397
- params = xref.fetchIfRef(cs[1]);
398
- whitePoint = params.getArray('WhitePoint');
399
- blackPoint = params.getArray('BlackPoint');
400
- var range = params.getArray('Range');
401
- return ['LabCS', whitePoint, blackPoint, range];
402
-
403
- default:
404
- throw new _util.FormatError("unimplemented color space object \"".concat(mode, "\""));
405
- }
406
- }
358
+ case "Pattern":
359
+ baseCS = cs[1] || null;
407
360
 
408
- throw new _util.FormatError("unrecognized color space object: \"".concat(cs, "\""));
409
- }
410
- }, {
411
- key: "isDefaultDecode",
412
- value: function isDefaultDecode(decode, numComps) {
413
- if (!Array.isArray(decode)) {
414
- return true;
415
- }
361
+ if (baseCS) {
362
+ baseCS = this._parse(baseCS, xref, resources, pdfFunctionFactory);
363
+ }
416
364
 
417
- if (numComps * 2 !== decode.length) {
418
- (0, _util.warn)('The decode map is not the correct length');
419
- return true;
420
- }
365
+ return new PatternCS(baseCS);
366
+
367
+ case "Indexed":
368
+ case "I":
369
+ baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
370
+ const hiVal = xref.fetchIfRef(cs[2]) + 1;
371
+ const lookup = xref.fetchIfRef(cs[3]);
372
+ return new IndexedCS(baseCS, hiVal, lookup);
373
+
374
+ case "Separation":
375
+ case "DeviceN":
376
+ const name = xref.fetchIfRef(cs[1]);
377
+ numComps = Array.isArray(name) ? name.length : 1;
378
+ baseCS = this._parse(cs[2], xref, resources, pdfFunctionFactory);
379
+ const tintFn = pdfFunctionFactory.create(cs[3]);
380
+ return new AlternateCS(numComps, baseCS, tintFn);
381
+
382
+ case "Lab":
383
+ params = xref.fetchIfRef(cs[1]);
384
+ whitePoint = params.getArray("WhitePoint");
385
+ blackPoint = params.getArray("BlackPoint");
386
+ const range = params.getArray("Range");
387
+ return new LabCS(whitePoint, blackPoint, range);
421
388
 
422
- for (var i = 0, ii = decode.length; i < ii; i += 2) {
423
- if (decode[i] !== 0 || decode[i + 1] !== 1) {
424
- return false;
425
- }
389
+ default:
390
+ throw new _util.FormatError(`Unimplemented ColorSpace object: ${mode}`);
426
391
  }
392
+ }
393
+
394
+ throw new _util.FormatError(`Unrecognized ColorSpace object: ${cs}`);
395
+ }
427
396
 
397
+ static isDefaultDecode(decode, numComps) {
398
+ if (!Array.isArray(decode)) {
428
399
  return true;
429
400
  }
430
- }, {
431
- key: "singletons",
432
- get: function get() {
433
- return (0, _util.shadow)(this, 'singletons', {
434
- get gray() {
435
- return (0, _util.shadow)(this, 'gray', new DeviceGrayCS());
436
- },
437
-
438
- get rgb() {
439
- return (0, _util.shadow)(this, 'rgb', new DeviceRgbCS());
440
- },
441
-
442
- get cmyk() {
443
- return (0, _util.shadow)(this, 'cmyk', new DeviceCmykCS());
444
- }
445
401
 
446
- });
402
+ if (numComps * 2 !== decode.length) {
403
+ (0, _util.warn)("The decode map is not the correct length");
404
+ return true;
447
405
  }
448
- }]);
449
406
 
450
- return ColorSpace;
451
- }();
407
+ for (let i = 0, ii = decode.length; i < ii; i += 2) {
408
+ if (decode[i] !== 0 || decode[i + 1] !== 1) {
409
+ return false;
410
+ }
411
+ }
452
412
 
453
- exports.ColorSpace = ColorSpace;
413
+ return true;
414
+ }
454
415
 
455
- var AlternateCS =
456
- /*#__PURE__*/
457
- function (_ColorSpace) {
458
- _inherits(AlternateCS, _ColorSpace);
416
+ static get singletons() {
417
+ return (0, _util.shadow)(this, "singletons", {
418
+ get gray() {
419
+ return (0, _util.shadow)(this, "gray", new DeviceGrayCS());
420
+ },
459
421
 
460
- function AlternateCS(numComps, base, tintFn) {
461
- var _this;
422
+ get rgb() {
423
+ return (0, _util.shadow)(this, "rgb", new DeviceRgbCS());
424
+ },
462
425
 
463
- _classCallCheck(this, AlternateCS);
426
+ get cmyk() {
427
+ return (0, _util.shadow)(this, "cmyk", new DeviceCmykCS());
428
+ }
464
429
 
465
- _this = _possibleConstructorReturn(this, _getPrototypeOf(AlternateCS).call(this, 'Alternate', numComps));
466
- _this.base = base;
467
- _this.tintFn = tintFn;
468
- _this.tmpBuf = new Float32Array(base.numComps);
469
- return _this;
430
+ });
470
431
  }
471
432
 
472
- _createClass(AlternateCS, [{
473
- key: "getRgbItem",
474
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
475
- var tmpBuf = this.tmpBuf;
476
- this.tintFn(src, srcOffset, tmpBuf, 0);
477
- this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
478
- }
479
- }, {
480
- key: "getRgbBuffer",
481
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
482
- var tintFn = this.tintFn;
483
- var base = this.base;
484
- var scale = 1 / ((1 << bits) - 1);
485
- var baseNumComps = base.numComps;
486
- var usesZeroToOneRange = base.usesZeroToOneRange;
487
- var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
488
- var pos = isPassthrough ? destOffset : 0;
489
- var baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
490
- var numComps = this.numComps;
491
- var scaled = new Float32Array(numComps);
492
- var tinted = new Float32Array(baseNumComps);
493
- var i, j;
494
-
495
- for (i = 0; i < count; i++) {
496
- for (j = 0; j < numComps; j++) {
497
- scaled[j] = src[srcOffset++] * scale;
498
- }
499
-
500
- tintFn(scaled, 0, tinted, 0);
433
+ }
501
434
 
502
- if (usesZeroToOneRange) {
503
- for (j = 0; j < baseNumComps; j++) {
504
- baseBuf[pos++] = tinted[j] * 255;
505
- }
506
- } else {
507
- base.getRgbItem(tinted, 0, baseBuf, pos);
508
- pos += baseNumComps;
509
- }
510
- }
435
+ exports.ColorSpace = ColorSpace;
511
436
 
512
- if (!isPassthrough) {
513
- base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
514
- }
515
- }
516
- }, {
517
- key: "getOutputLength",
518
- value: function getOutputLength(inputLength, alpha01) {
519
- return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
520
- }
521
- }]);
437
+ class AlternateCS extends ColorSpace {
438
+ constructor(numComps, base, tintFn) {
439
+ super("Alternate", numComps);
440
+ this.base = base;
441
+ this.tintFn = tintFn;
442
+ this.tmpBuf = new Float32Array(base.numComps);
443
+ }
522
444
 
523
- return AlternateCS;
524
- }(ColorSpace);
445
+ getRgbItem(src, srcOffset, dest, destOffset) {
446
+ const tmpBuf = this.tmpBuf;
447
+ this.tintFn(src, srcOffset, tmpBuf, 0);
448
+ this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
449
+ }
525
450
 
526
- var PatternCS =
527
- /*#__PURE__*/
528
- function (_ColorSpace2) {
529
- _inherits(PatternCS, _ColorSpace2);
451
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
452
+ const tintFn = this.tintFn;
453
+ const base = this.base;
454
+ const scale = 1 / ((1 << bits) - 1);
455
+ const baseNumComps = base.numComps;
456
+ const usesZeroToOneRange = base.usesZeroToOneRange;
457
+ const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
458
+ let pos = isPassthrough ? destOffset : 0;
459
+ const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
460
+ const numComps = this.numComps;
461
+ const scaled = new Float32Array(numComps);
462
+ const tinted = new Float32Array(baseNumComps);
463
+ let i, j;
464
+
465
+ for (i = 0; i < count; i++) {
466
+ for (j = 0; j < numComps; j++) {
467
+ scaled[j] = src[srcOffset++] * scale;
468
+ }
530
469
 
531
- function PatternCS(baseCS) {
532
- var _this2;
470
+ tintFn(scaled, 0, tinted, 0);
533
471
 
534
- _classCallCheck(this, PatternCS);
472
+ if (usesZeroToOneRange) {
473
+ for (j = 0; j < baseNumComps; j++) {
474
+ baseBuf[pos++] = tinted[j] * 255;
475
+ }
476
+ } else {
477
+ base.getRgbItem(tinted, 0, baseBuf, pos);
478
+ pos += baseNumComps;
479
+ }
480
+ }
535
481
 
536
- _this2 = _possibleConstructorReturn(this, _getPrototypeOf(PatternCS).call(this, 'Pattern', null));
537
- _this2.base = baseCS;
538
- return _this2;
482
+ if (!isPassthrough) {
483
+ base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
484
+ }
539
485
  }
540
486
 
541
- _createClass(PatternCS, [{
542
- key: "isDefaultDecode",
543
- value: function isDefaultDecode(decodeMap, bpc) {
544
- (0, _util.unreachable)('Should not call PatternCS.isDefaultDecode');
545
- }
546
- }]);
487
+ getOutputLength(inputLength, alpha01) {
488
+ return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
489
+ }
547
490
 
548
- return PatternCS;
549
- }(ColorSpace);
491
+ }
550
492
 
551
- var IndexedCS =
552
- /*#__PURE__*/
553
- function (_ColorSpace3) {
554
- _inherits(IndexedCS, _ColorSpace3);
493
+ class PatternCS extends ColorSpace {
494
+ constructor(baseCS) {
495
+ super("Pattern", null);
496
+ this.base = baseCS;
497
+ }
555
498
 
556
- function IndexedCS(base, highVal, lookup) {
557
- var _this3;
499
+ isDefaultDecode(decodeMap, bpc) {
500
+ (0, _util.unreachable)("Should not call PatternCS.isDefaultDecode");
501
+ }
558
502
 
559
- _classCallCheck(this, IndexedCS);
503
+ }
560
504
 
561
- _this3 = _possibleConstructorReturn(this, _getPrototypeOf(IndexedCS).call(this, 'Indexed', 1));
562
- _this3.base = base;
563
- _this3.highVal = highVal;
564
- var baseNumComps = base.numComps;
565
- var length = baseNumComps * highVal;
505
+ class IndexedCS extends ColorSpace {
506
+ constructor(base, highVal, lookup) {
507
+ super("Indexed", 1);
508
+ this.base = base;
509
+ this.highVal = highVal;
510
+ const length = base.numComps * highVal;
511
+ this.lookup = new Uint8Array(length);
566
512
 
567
513
  if ((0, _primitives.isStream)(lookup)) {
568
- _this3.lookup = new Uint8Array(length);
569
- var bytes = lookup.getBytes(length);
570
-
571
- _this3.lookup.set(bytes);
572
- } else if ((0, _util.isString)(lookup)) {
573
- _this3.lookup = new Uint8Array(length);
574
-
575
- for (var i = 0; i < length; ++i) {
576
- _this3.lookup[i] = lookup.charCodeAt(i);
514
+ const bytes = lookup.getBytes(length);
515
+ this.lookup.set(bytes);
516
+ } else if (typeof lookup === "string") {
517
+ for (let i = 0; i < length; ++i) {
518
+ this.lookup[i] = lookup.charCodeAt(i) & 0xff;
577
519
  }
578
- } else if (lookup instanceof Uint8Array) {
579
- _this3.lookup = lookup;
580
520
  } else {
581
- throw new _util.FormatError("Unrecognized lookup table: ".concat(lookup));
521
+ throw new _util.FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);
582
522
  }
523
+ }
583
524
 
584
- return _this3;
525
+ getRgbItem(src, srcOffset, dest, destOffset) {
526
+ const numComps = this.base.numComps;
527
+ const start = src[srcOffset] * numComps;
528
+ this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
585
529
  }
586
530
 
587
- _createClass(IndexedCS, [{
588
- key: "getRgbItem",
589
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
590
- var numComps = this.base.numComps;
591
- var start = src[srcOffset] * numComps;
592
- this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
593
- }
594
- }, {
595
- key: "getRgbBuffer",
596
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
597
- var base = this.base;
598
- var numComps = base.numComps;
599
- var outputDelta = base.getOutputLength(numComps, alpha01);
600
- var lookup = this.lookup;
601
-
602
- for (var i = 0; i < count; ++i) {
603
- var lookupPos = src[srcOffset++] * numComps;
604
- base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
605
- destOffset += outputDelta;
606
- }
607
- }
608
- }, {
609
- key: "getOutputLength",
610
- value: function getOutputLength(inputLength, alpha01) {
611
- return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
531
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
532
+ const base = this.base;
533
+ const numComps = base.numComps;
534
+ const outputDelta = base.getOutputLength(numComps, alpha01);
535
+ const lookup = this.lookup;
536
+
537
+ for (let i = 0; i < count; ++i) {
538
+ const lookupPos = src[srcOffset++] * numComps;
539
+ base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
540
+ destOffset += outputDelta;
612
541
  }
613
- }, {
614
- key: "isDefaultDecode",
615
- value: function isDefaultDecode(decodeMap, bpc) {
616
- if (!Array.isArray(decodeMap)) {
617
- return true;
618
- }
542
+ }
619
543
 
620
- if (decodeMap.length !== 2) {
621
- (0, _util.warn)('Decode map length is not correct');
622
- return true;
623
- }
544
+ getOutputLength(inputLength, alpha01) {
545
+ return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
546
+ }
624
547
 
625
- if (!Number.isInteger(bpc) || bpc < 1) {
626
- (0, _util.warn)('Bits per component is not correct');
627
- return true;
628
- }
548
+ isDefaultDecode(decodeMap, bpc) {
549
+ if (!Array.isArray(decodeMap)) {
550
+ return true;
551
+ }
629
552
 
630
- return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
553
+ if (decodeMap.length !== 2) {
554
+ (0, _util.warn)("Decode map length is not correct");
555
+ return true;
556
+ }
557
+
558
+ if (!Number.isInteger(bpc) || bpc < 1) {
559
+ (0, _util.warn)("Bits per component is not correct");
560
+ return true;
631
561
  }
632
- }]);
633
562
 
634
- return IndexedCS;
635
- }(ColorSpace);
563
+ return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
564
+ }
636
565
 
637
- var DeviceGrayCS =
638
- /*#__PURE__*/
639
- function (_ColorSpace4) {
640
- _inherits(DeviceGrayCS, _ColorSpace4);
566
+ }
641
567
 
642
- function DeviceGrayCS() {
643
- _classCallCheck(this, DeviceGrayCS);
568
+ class DeviceGrayCS extends ColorSpace {
569
+ constructor() {
570
+ super("DeviceGray", 1);
571
+ }
644
572
 
645
- return _possibleConstructorReturn(this, _getPrototypeOf(DeviceGrayCS).call(this, 'DeviceGray', 1));
573
+ getRgbItem(src, srcOffset, dest, destOffset) {
574
+ const c = src[srcOffset] * 255;
575
+ dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
646
576
  }
647
577
 
648
- _createClass(DeviceGrayCS, [{
649
- key: "getRgbItem",
650
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
651
- var c = src[srcOffset] * 255;
652
- dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
653
- }
654
- }, {
655
- key: "getRgbBuffer",
656
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
657
- var scale = 255 / ((1 << bits) - 1);
658
- var j = srcOffset,
659
- q = destOffset;
660
-
661
- for (var i = 0; i < count; ++i) {
662
- var c = scale * src[j++];
663
- dest[q++] = c;
664
- dest[q++] = c;
665
- dest[q++] = c;
666
- q += alpha01;
667
- }
668
- }
669
- }, {
670
- key: "getOutputLength",
671
- value: function getOutputLength(inputLength, alpha01) {
672
- return inputLength * (3 + alpha01);
578
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
579
+ const scale = 255 / ((1 << bits) - 1);
580
+ let j = srcOffset,
581
+ q = destOffset;
582
+
583
+ for (let i = 0; i < count; ++i) {
584
+ const c = scale * src[j++];
585
+ dest[q++] = c;
586
+ dest[q++] = c;
587
+ dest[q++] = c;
588
+ q += alpha01;
673
589
  }
674
- }]);
590
+ }
675
591
 
676
- return DeviceGrayCS;
677
- }(ColorSpace);
592
+ getOutputLength(inputLength, alpha01) {
593
+ return inputLength * (3 + alpha01);
594
+ }
678
595
 
679
- var DeviceRgbCS =
680
- /*#__PURE__*/
681
- function (_ColorSpace5) {
682
- _inherits(DeviceRgbCS, _ColorSpace5);
596
+ }
683
597
 
684
- function DeviceRgbCS() {
685
- _classCallCheck(this, DeviceRgbCS);
598
+ class DeviceRgbCS extends ColorSpace {
599
+ constructor() {
600
+ super("DeviceRGB", 3);
601
+ }
686
602
 
687
- return _possibleConstructorReturn(this, _getPrototypeOf(DeviceRgbCS).call(this, 'DeviceRGB', 3));
603
+ getRgbItem(src, srcOffset, dest, destOffset) {
604
+ dest[destOffset] = src[srcOffset] * 255;
605
+ dest[destOffset + 1] = src[srcOffset + 1] * 255;
606
+ dest[destOffset + 2] = src[srcOffset + 2] * 255;
688
607
  }
689
608
 
690
- _createClass(DeviceRgbCS, [{
691
- key: "getRgbItem",
692
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
693
- dest[destOffset] = src[srcOffset] * 255;
694
- dest[destOffset + 1] = src[srcOffset + 1] * 255;
695
- dest[destOffset + 2] = src[srcOffset + 2] * 255;
609
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
610
+ if (bits === 8 && alpha01 === 0) {
611
+ dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
612
+ return;
696
613
  }
697
- }, {
698
- key: "getRgbBuffer",
699
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
700
- if (bits === 8 && alpha01 === 0) {
701
- dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
702
- return;
703
- }
704
614
 
705
- var scale = 255 / ((1 << bits) - 1);
706
- var j = srcOffset,
707
- q = destOffset;
615
+ const scale = 255 / ((1 << bits) - 1);
616
+ let j = srcOffset,
617
+ q = destOffset;
708
618
 
709
- for (var i = 0; i < count; ++i) {
710
- dest[q++] = scale * src[j++];
711
- dest[q++] = scale * src[j++];
712
- dest[q++] = scale * src[j++];
713
- q += alpha01;
714
- }
715
- }
716
- }, {
717
- key: "getOutputLength",
718
- value: function getOutputLength(inputLength, alpha01) {
719
- return inputLength * (3 + alpha01) / 3 | 0;
619
+ for (let i = 0; i < count; ++i) {
620
+ dest[q++] = scale * src[j++];
621
+ dest[q++] = scale * src[j++];
622
+ dest[q++] = scale * src[j++];
623
+ q += alpha01;
720
624
  }
721
- }, {
722
- key: "isPassthrough",
723
- value: function isPassthrough(bits) {
724
- return bits === 8;
725
- }
726
- }]);
625
+ }
626
+
627
+ getOutputLength(inputLength, alpha01) {
628
+ return inputLength * (3 + alpha01) / 3 | 0;
629
+ }
727
630
 
728
- return DeviceRgbCS;
729
- }(ColorSpace);
631
+ isPassthrough(bits) {
632
+ return bits === 8;
633
+ }
634
+
635
+ }
730
636
 
731
- var DeviceCmykCS = function DeviceCmykCSClosure() {
637
+ const DeviceCmykCS = function DeviceCmykCSClosure() {
732
638
  function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
733
- var c = src[srcOffset] * srcScale;
734
- var m = src[srcOffset + 1] * srcScale;
735
- var y = src[srcOffset + 2] * srcScale;
736
- var k = src[srcOffset + 3] * srcScale;
639
+ const c = src[srcOffset] * srcScale;
640
+ const m = src[srcOffset + 1] * srcScale;
641
+ const y = src[srcOffset + 2] * srcScale;
642
+ const k = src[srcOffset + 3] * srcScale;
737
643
  dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
738
644
  dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
739
645
  dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
740
646
  }
741
647
 
742
- var DeviceCmykCS =
743
- /*#__PURE__*/
744
- function (_ColorSpace6) {
745
- _inherits(DeviceCmykCS, _ColorSpace6);
746
-
747
- function DeviceCmykCS() {
748
- _classCallCheck(this, DeviceCmykCS);
648
+ class DeviceCmykCS extends ColorSpace {
649
+ constructor() {
650
+ super("DeviceCMYK", 4);
651
+ }
749
652
 
750
- return _possibleConstructorReturn(this, _getPrototypeOf(DeviceCmykCS).call(this, 'DeviceCMYK', 4));
653
+ getRgbItem(src, srcOffset, dest, destOffset) {
654
+ convertToRgb(src, srcOffset, 1, dest, destOffset);
751
655
  }
752
656
 
753
- _createClass(DeviceCmykCS, [{
754
- key: "getRgbItem",
755
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
756
- convertToRgb(src, srcOffset, 1, dest, destOffset);
757
- }
758
- }, {
759
- key: "getRgbBuffer",
760
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
761
- var scale = 1 / ((1 << bits) - 1);
762
-
763
- for (var i = 0; i < count; i++) {
764
- convertToRgb(src, srcOffset, scale, dest, destOffset);
765
- srcOffset += 4;
766
- destOffset += 3 + alpha01;
767
- }
768
- }
769
- }, {
770
- key: "getOutputLength",
771
- value: function getOutputLength(inputLength, alpha01) {
772
- return inputLength / 4 * (3 + alpha01) | 0;
657
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
658
+ const scale = 1 / ((1 << bits) - 1);
659
+
660
+ for (let i = 0; i < count; i++) {
661
+ convertToRgb(src, srcOffset, scale, dest, destOffset);
662
+ srcOffset += 4;
663
+ destOffset += 3 + alpha01;
773
664
  }
774
- }]);
665
+ }
666
+
667
+ getOutputLength(inputLength, alpha01) {
668
+ return inputLength / 4 * (3 + alpha01) | 0;
669
+ }
775
670
 
776
- return DeviceCmykCS;
777
- }(ColorSpace);
671
+ }
778
672
 
779
673
  return DeviceCmykCS;
780
674
  }();
781
675
 
782
- var CalGrayCS = function CalGrayCSClosure() {
676
+ const CalGrayCS = function CalGrayCSClosure() {
783
677
  function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
784
- var A = src[srcOffset] * scale;
785
- var AG = Math.pow(A, cs.G);
786
- var L = cs.YW * AG;
787
- var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0);
678
+ const A = src[srcOffset] * scale;
679
+ const AG = A ** cs.G;
680
+ const L = cs.YW * AG;
681
+ const val = Math.max(295.8 * L ** 0.333333333333333333 - 40.8, 0);
788
682
  dest[destOffset] = val;
789
683
  dest[destOffset + 1] = val;
790
684
  dest[destOffset + 2] = val;
791
685
  }
792
686
 
793
- var CalGrayCS =
794
- /*#__PURE__*/
795
- function (_ColorSpace7) {
796
- _inherits(CalGrayCS, _ColorSpace7);
797
-
798
- function CalGrayCS(whitePoint, blackPoint, gamma) {
799
- var _this4;
800
-
801
- _classCallCheck(this, CalGrayCS);
802
-
803
- _this4 = _possibleConstructorReturn(this, _getPrototypeOf(CalGrayCS).call(this, 'CalGray', 1));
687
+ class CalGrayCS extends ColorSpace {
688
+ constructor(whitePoint, blackPoint, gamma) {
689
+ super("CalGray", 1);
804
690
 
805
691
  if (!whitePoint) {
806
- throw new _util.FormatError('WhitePoint missing - required for color space CalGray');
692
+ throw new _util.FormatError("WhitePoint missing - required for color space CalGray");
807
693
  }
808
694
 
809
695
  blackPoint = blackPoint || [0, 0, 0];
810
696
  gamma = gamma || 1;
811
- _this4.XW = whitePoint[0];
812
- _this4.YW = whitePoint[1];
813
- _this4.ZW = whitePoint[2];
814
- _this4.XB = blackPoint[0];
815
- _this4.YB = blackPoint[1];
816
- _this4.ZB = blackPoint[2];
817
- _this4.G = gamma;
818
-
819
- if (_this4.XW < 0 || _this4.ZW < 0 || _this4.YW !== 1) {
820
- throw new _util.FormatError("Invalid WhitePoint components for ".concat(_this4.name) + ', no fallback available');
697
+ this.XW = whitePoint[0];
698
+ this.YW = whitePoint[1];
699
+ this.ZW = whitePoint[2];
700
+ this.XB = blackPoint[0];
701
+ this.YB = blackPoint[1];
702
+ this.ZB = blackPoint[2];
703
+ this.G = gamma;
704
+
705
+ if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
706
+ throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
821
707
  }
822
708
 
823
- if (_this4.XB < 0 || _this4.YB < 0 || _this4.ZB < 0) {
824
- (0, _util.info)("Invalid BlackPoint for ".concat(_this4.name, ", falling back to default."));
825
- _this4.XB = _this4.YB = _this4.ZB = 0;
709
+ if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
710
+ (0, _util.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);
711
+ this.XB = this.YB = this.ZB = 0;
826
712
  }
827
713
 
828
- if (_this4.XB !== 0 || _this4.YB !== 0 || _this4.ZB !== 0) {
829
- (0, _util.warn)("".concat(_this4.name, ", BlackPoint: XB: ").concat(_this4.XB, ", YB: ").concat(_this4.YB, ", ") + "ZB: ".concat(_this4.ZB, ", only default values are supported."));
714
+ if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
715
+ (0, _util.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
830
716
  }
831
717
 
832
- if (_this4.G < 1) {
833
- (0, _util.info)("Invalid Gamma: ".concat(_this4.G, " for ").concat(_this4.name, ", ") + 'falling back to default.');
834
- _this4.G = 1;
718
+ if (this.G < 1) {
719
+ (0, _util.info)(`Invalid Gamma: ${this.G} for ${this.name}, ` + "falling back to default.");
720
+ this.G = 1;
835
721
  }
722
+ }
836
723
 
837
- return _this4;
724
+ getRgbItem(src, srcOffset, dest, destOffset) {
725
+ convertToRgb(this, src, srcOffset, dest, destOffset, 1);
838
726
  }
839
727
 
840
- _createClass(CalGrayCS, [{
841
- key: "getRgbItem",
842
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
843
- convertToRgb(this, src, srcOffset, dest, destOffset, 1);
844
- }
845
- }, {
846
- key: "getRgbBuffer",
847
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
848
- var scale = 1 / ((1 << bits) - 1);
849
-
850
- for (var i = 0; i < count; ++i) {
851
- convertToRgb(this, src, srcOffset, dest, destOffset, scale);
852
- srcOffset += 1;
853
- destOffset += 3 + alpha01;
854
- }
855
- }
856
- }, {
857
- key: "getOutputLength",
858
- value: function getOutputLength(inputLength, alpha01) {
859
- return inputLength * (3 + alpha01);
728
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
729
+ const scale = 1 / ((1 << bits) - 1);
730
+
731
+ for (let i = 0; i < count; ++i) {
732
+ convertToRgb(this, src, srcOffset, dest, destOffset, scale);
733
+ srcOffset += 1;
734
+ destOffset += 3 + alpha01;
860
735
  }
861
- }]);
736
+ }
737
+
738
+ getOutputLength(inputLength, alpha01) {
739
+ return inputLength * (3 + alpha01);
740
+ }
862
741
 
863
- return CalGrayCS;
864
- }(ColorSpace);
742
+ }
865
743
 
866
744
  return CalGrayCS;
867
745
  }();
868
746
 
869
- var CalRGBCS = function CalRGBCSClosure() {
870
- var BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
871
- var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
872
- var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
873
- var FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
874
- var tempNormalizeMatrix = new Float32Array(3);
875
- var tempConvertMatrix1 = new Float32Array(3);
876
- var tempConvertMatrix2 = new Float32Array(3);
877
- var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
747
+ const CalRGBCS = function CalRGBCSClosure() {
748
+ const BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
749
+ const BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
750
+ const SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
751
+ const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
752
+ const tempNormalizeMatrix = new Float32Array(3);
753
+ const tempConvertMatrix1 = new Float32Array(3);
754
+ const tempConvertMatrix2 = new Float32Array(3);
755
+ const DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
878
756
 
879
757
  function matrixProduct(a, b, result) {
880
758
  result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
@@ -889,9 +767,9 @@ var CalRGBCS = function CalRGBCSClosure() {
889
767
  }
890
768
 
891
769
  function convertToD65(sourceWhitePoint, LMS, result) {
892
- var D65X = 0.95047;
893
- var D65Y = 1;
894
- var D65Z = 1.08883;
770
+ const D65X = 0.95047;
771
+ const D65Y = 1;
772
+ const D65Z = 1.08883;
895
773
  result[0] = LMS[0] * D65X / sourceWhitePoint[0];
896
774
  result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
897
775
  result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
@@ -902,7 +780,11 @@ var CalRGBCS = function CalRGBCSClosure() {
902
780
  return adjustToRange(0, 1, 12.92 * color);
903
781
  }
904
782
 
905
- return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
783
+ if (color >= 0.99554525) {
784
+ return 1;
785
+ }
786
+
787
+ return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
906
788
  }
907
789
 
908
790
  function adjustToRange(min, max, value) {
@@ -915,7 +797,7 @@ var CalRGBCS = function CalRGBCSClosure() {
915
797
  }
916
798
 
917
799
  if (L > 8.0) {
918
- return Math.pow((L + 16) / 116, 3);
800
+ return ((L + 16) / 116) ** 3;
919
801
  }
920
802
 
921
803
  return L * DECODE_L_CONSTANT;
@@ -929,19 +811,19 @@ var CalRGBCS = function CalRGBCSClosure() {
929
811
  return;
930
812
  }
931
813
 
932
- var zeroDecodeL = decodeL(0);
933
- var X_DST = zeroDecodeL;
934
- var X_SRC = decodeL(sourceBlackPoint[0]);
935
- var Y_DST = zeroDecodeL;
936
- var Y_SRC = decodeL(sourceBlackPoint[1]);
937
- var Z_DST = zeroDecodeL;
938
- var Z_SRC = decodeL(sourceBlackPoint[2]);
939
- var X_Scale = (1 - X_DST) / (1 - X_SRC);
940
- var X_Offset = 1 - X_Scale;
941
- var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
942
- var Y_Offset = 1 - Y_Scale;
943
- var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
944
- var Z_Offset = 1 - Z_Scale;
814
+ const zeroDecodeL = decodeL(0);
815
+ const X_DST = zeroDecodeL;
816
+ const X_SRC = decodeL(sourceBlackPoint[0]);
817
+ const Y_DST = zeroDecodeL;
818
+ const Y_SRC = decodeL(sourceBlackPoint[1]);
819
+ const Z_DST = zeroDecodeL;
820
+ const Z_SRC = decodeL(sourceBlackPoint[2]);
821
+ const X_Scale = (1 - X_DST) / (1 - X_SRC);
822
+ const X_Offset = 1 - X_Scale;
823
+ const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
824
+ const Y_Offset = 1 - Y_Scale;
825
+ const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
826
+ const Z_Offset = 1 - Z_Scale;
945
827
  result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
946
828
  result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
947
829
  result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
@@ -955,137 +837,121 @@ var CalRGBCS = function CalRGBCSClosure() {
955
837
  return;
956
838
  }
957
839
 
958
- var LMS = result;
840
+ const LMS = result;
959
841
  matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
960
- var LMS_Flat = tempNormalizeMatrix;
842
+ const LMS_Flat = tempNormalizeMatrix;
961
843
  convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
962
844
  matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
963
845
  }
964
846
 
965
847
  function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
966
- var LMS = result;
848
+ const LMS = result;
967
849
  matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
968
- var LMS_D65 = tempNormalizeMatrix;
850
+ const LMS_D65 = tempNormalizeMatrix;
969
851
  convertToD65(sourceWhitePoint, LMS, LMS_D65);
970
852
  matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
971
853
  }
972
854
 
973
855
  function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
974
- var A = adjustToRange(0, 1, src[srcOffset] * scale);
975
- var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
976
- var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
977
- var AGR = Math.pow(A, cs.GR);
978
- var BGG = Math.pow(B, cs.GG);
979
- var CGB = Math.pow(C, cs.GB);
980
- var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
981
- var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
982
- var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
983
- var XYZ = tempConvertMatrix1;
856
+ const A = adjustToRange(0, 1, src[srcOffset] * scale);
857
+ const B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
858
+ const C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
859
+ const AGR = A === 1 ? 1 : A ** cs.GR;
860
+ const BGG = B === 1 ? 1 : B ** cs.GG;
861
+ const CGB = C === 1 ? 1 : C ** cs.GB;
862
+ const X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
863
+ const Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
864
+ const Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
865
+ const XYZ = tempConvertMatrix1;
984
866
  XYZ[0] = X;
985
867
  XYZ[1] = Y;
986
868
  XYZ[2] = Z;
987
- var XYZ_Flat = tempConvertMatrix2;
869
+ const XYZ_Flat = tempConvertMatrix2;
988
870
  normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
989
- var XYZ_Black = tempConvertMatrix1;
871
+ const XYZ_Black = tempConvertMatrix1;
990
872
  compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
991
- var XYZ_D65 = tempConvertMatrix2;
873
+ const XYZ_D65 = tempConvertMatrix2;
992
874
  normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
993
- var SRGB = tempConvertMatrix1;
875
+ const SRGB = tempConvertMatrix1;
994
876
  matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
995
877
  dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
996
878
  dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
997
879
  dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
998
880
  }
999
881
 
1000
- var CalRGBCS =
1001
- /*#__PURE__*/
1002
- function (_ColorSpace8) {
1003
- _inherits(CalRGBCS, _ColorSpace8);
1004
-
1005
- function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
1006
- var _this5;
1007
-
1008
- _classCallCheck(this, CalRGBCS);
1009
-
1010
- _this5 = _possibleConstructorReturn(this, _getPrototypeOf(CalRGBCS).call(this, 'CalRGB', 3));
882
+ class CalRGBCS extends ColorSpace {
883
+ constructor(whitePoint, blackPoint, gamma, matrix) {
884
+ super("CalRGB", 3);
1011
885
 
1012
886
  if (!whitePoint) {
1013
- throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');
887
+ throw new _util.FormatError("WhitePoint missing - required for color space CalRGB");
1014
888
  }
1015
889
 
1016
890
  blackPoint = blackPoint || new Float32Array(3);
1017
891
  gamma = gamma || new Float32Array([1, 1, 1]);
1018
892
  matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
1019
- var XW = whitePoint[0];
1020
- var YW = whitePoint[1];
1021
- var ZW = whitePoint[2];
1022
- _this5.whitePoint = whitePoint;
1023
- var XB = blackPoint[0];
1024
- var YB = blackPoint[1];
1025
- var ZB = blackPoint[2];
1026
- _this5.blackPoint = blackPoint;
1027
- _this5.GR = gamma[0];
1028
- _this5.GG = gamma[1];
1029
- _this5.GB = gamma[2];
1030
- _this5.MXA = matrix[0];
1031
- _this5.MYA = matrix[1];
1032
- _this5.MZA = matrix[2];
1033
- _this5.MXB = matrix[3];
1034
- _this5.MYB = matrix[4];
1035
- _this5.MZB = matrix[5];
1036
- _this5.MXC = matrix[6];
1037
- _this5.MYC = matrix[7];
1038
- _this5.MZC = matrix[8];
893
+ const XW = whitePoint[0];
894
+ const YW = whitePoint[1];
895
+ const ZW = whitePoint[2];
896
+ this.whitePoint = whitePoint;
897
+ const XB = blackPoint[0];
898
+ const YB = blackPoint[1];
899
+ const ZB = blackPoint[2];
900
+ this.blackPoint = blackPoint;
901
+ this.GR = gamma[0];
902
+ this.GG = gamma[1];
903
+ this.GB = gamma[2];
904
+ this.MXA = matrix[0];
905
+ this.MYA = matrix[1];
906
+ this.MZA = matrix[2];
907
+ this.MXB = matrix[3];
908
+ this.MYB = matrix[4];
909
+ this.MZB = matrix[5];
910
+ this.MXC = matrix[6];
911
+ this.MYC = matrix[7];
912
+ this.MZC = matrix[8];
1039
913
 
1040
914
  if (XW < 0 || ZW < 0 || YW !== 1) {
1041
- throw new _util.FormatError("Invalid WhitePoint components for ".concat(_this5.name) + ', no fallback available');
915
+ throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
1042
916
  }
1043
917
 
1044
918
  if (XB < 0 || YB < 0 || ZB < 0) {
1045
- (0, _util.info)("Invalid BlackPoint for ".concat(_this5.name, " [").concat(XB, ", ").concat(YB, ", ").concat(ZB, "], ") + 'falling back to default.');
1046
- _this5.blackPoint = new Float32Array(3);
919
+ (0, _util.info)(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + "falling back to default.");
920
+ this.blackPoint = new Float32Array(3);
1047
921
  }
1048
922
 
1049
- if (_this5.GR < 0 || _this5.GG < 0 || _this5.GB < 0) {
1050
- (0, _util.info)("Invalid Gamma [".concat(_this5.GR, ", ").concat(_this5.GG, ", ").concat(_this5.GB, "] for ") + "".concat(_this5.name, ", falling back to default."));
1051
- _this5.GR = _this5.GG = _this5.GB = 1;
923
+ if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
924
+ (0, _util.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
925
+ this.GR = this.GG = this.GB = 1;
1052
926
  }
927
+ }
1053
928
 
1054
- return _this5;
929
+ getRgbItem(src, srcOffset, dest, destOffset) {
930
+ convertToRgb(this, src, srcOffset, dest, destOffset, 1);
1055
931
  }
1056
932
 
1057
- _createClass(CalRGBCS, [{
1058
- key: "getRgbItem",
1059
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
1060
- convertToRgb(this, src, srcOffset, dest, destOffset, 1);
1061
- }
1062
- }, {
1063
- key: "getRgbBuffer",
1064
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
1065
- var scale = 1 / ((1 << bits) - 1);
1066
-
1067
- for (var i = 0; i < count; ++i) {
1068
- convertToRgb(this, src, srcOffset, dest, destOffset, scale);
1069
- srcOffset += 3;
1070
- destOffset += 3 + alpha01;
1071
- }
1072
- }
1073
- }, {
1074
- key: "getOutputLength",
1075
- value: function getOutputLength(inputLength, alpha01) {
1076
- return inputLength * (3 + alpha01) / 3 | 0;
933
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
934
+ const scale = 1 / ((1 << bits) - 1);
935
+
936
+ for (let i = 0; i < count; ++i) {
937
+ convertToRgb(this, src, srcOffset, dest, destOffset, scale);
938
+ srcOffset += 3;
939
+ destOffset += 3 + alpha01;
1077
940
  }
1078
- }]);
941
+ }
942
+
943
+ getOutputLength(inputLength, alpha01) {
944
+ return inputLength * (3 + alpha01) / 3 | 0;
945
+ }
1079
946
 
1080
- return CalRGBCS;
1081
- }(ColorSpace);
947
+ }
1082
948
 
1083
949
  return CalRGBCS;
1084
950
  }();
1085
951
 
1086
- var LabCS = function LabCSClosure() {
952
+ const LabCS = function LabCSClosure() {
1087
953
  function fn_g(x) {
1088
- var result;
954
+ let result;
1089
955
 
1090
956
  if (x >= 6 / 29) {
1091
957
  result = x * x * x;
@@ -1101,9 +967,9 @@ var LabCS = function LabCSClosure() {
1101
967
  }
1102
968
 
1103
969
  function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
1104
- var Ls = src[srcOffset];
1105
- var as = src[srcOffset + 1];
1106
- var bs = src[srcOffset + 2];
970
+ let Ls = src[srcOffset];
971
+ let as = src[srcOffset + 1];
972
+ let bs = src[srcOffset + 2];
1107
973
 
1108
974
  if (maxVal !== false) {
1109
975
  Ls = decode(Ls, maxVal, 0, 100);
@@ -1111,24 +977,34 @@ var LabCS = function LabCSClosure() {
1111
977
  bs = decode(bs, maxVal, cs.bmin, cs.bmax);
1112
978
  }
1113
979
 
1114
- as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
1115
- bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
1116
- var M = (Ls + 16) / 116;
1117
- var L = M + as / 500;
1118
- var N = M - bs / 200;
1119
- var X = cs.XW * fn_g(L);
1120
- var Y = cs.YW * fn_g(M);
1121
- var Z = cs.ZW * fn_g(N);
1122
- var r, g, b;
980
+ if (as > cs.amax) {
981
+ as = cs.amax;
982
+ } else if (as < cs.amin) {
983
+ as = cs.amin;
984
+ }
985
+
986
+ if (bs > cs.bmax) {
987
+ bs = cs.bmax;
988
+ } else if (bs < cs.bmin) {
989
+ bs = cs.bmin;
990
+ }
991
+
992
+ const M = (Ls + 16) / 116;
993
+ const L = M + as / 500;
994
+ const N = M - bs / 200;
995
+ const X = cs.XW * fn_g(L);
996
+ const Y = cs.YW * fn_g(M);
997
+ const Z = cs.ZW * fn_g(N);
998
+ let r, g, b;
1123
999
 
1124
1000
  if (cs.ZW < 1) {
1125
- r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
1126
- g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
1127
- b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
1001
+ r = X * 3.1339 + Y * -1.617 + Z * -0.4906;
1002
+ g = X * -0.9785 + Y * 1.916 + Z * 0.0333;
1003
+ b = X * 0.072 + Y * -0.229 + Z * 1.4057;
1128
1004
  } else {
1129
1005
  r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
1130
1006
  g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
1131
- b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
1007
+ b = X * 0.0557 + Y * -0.204 + Z * 1.057;
1132
1008
  }
1133
1009
 
1134
1010
  dest[destOffset] = Math.sqrt(r) * 255;
@@ -1136,90 +1012,72 @@ var LabCS = function LabCSClosure() {
1136
1012
  dest[destOffset + 2] = Math.sqrt(b) * 255;
1137
1013
  }
1138
1014
 
1139
- var LabCS =
1140
- /*#__PURE__*/
1141
- function (_ColorSpace9) {
1142
- _inherits(LabCS, _ColorSpace9);
1143
-
1144
- function LabCS(whitePoint, blackPoint, range) {
1145
- var _this6;
1146
-
1147
- _classCallCheck(this, LabCS);
1148
-
1149
- _this6 = _possibleConstructorReturn(this, _getPrototypeOf(LabCS).call(this, 'Lab', 3));
1015
+ class LabCS extends ColorSpace {
1016
+ constructor(whitePoint, blackPoint, range) {
1017
+ super("Lab", 3);
1150
1018
 
1151
1019
  if (!whitePoint) {
1152
- throw new _util.FormatError('WhitePoint missing - required for color space Lab');
1020
+ throw new _util.FormatError("WhitePoint missing - required for color space Lab");
1153
1021
  }
1154
1022
 
1155
1023
  blackPoint = blackPoint || [0, 0, 0];
1156
1024
  range = range || [-100, 100, -100, 100];
1157
- _this6.XW = whitePoint[0];
1158
- _this6.YW = whitePoint[1];
1159
- _this6.ZW = whitePoint[2];
1160
- _this6.amin = range[0];
1161
- _this6.amax = range[1];
1162
- _this6.bmin = range[2];
1163
- _this6.bmax = range[3];
1164
- _this6.XB = blackPoint[0];
1165
- _this6.YB = blackPoint[1];
1166
- _this6.ZB = blackPoint[2];
1167
-
1168
- if (_this6.XW < 0 || _this6.ZW < 0 || _this6.YW !== 1) {
1169
- throw new _util.FormatError('Invalid WhitePoint components, no fallback available');
1025
+ this.XW = whitePoint[0];
1026
+ this.YW = whitePoint[1];
1027
+ this.ZW = whitePoint[2];
1028
+ this.amin = range[0];
1029
+ this.amax = range[1];
1030
+ this.bmin = range[2];
1031
+ this.bmax = range[3];
1032
+ this.XB = blackPoint[0];
1033
+ this.YB = blackPoint[1];
1034
+ this.ZB = blackPoint[2];
1035
+
1036
+ if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
1037
+ throw new _util.FormatError("Invalid WhitePoint components, no fallback available");
1170
1038
  }
1171
1039
 
1172
- if (_this6.XB < 0 || _this6.YB < 0 || _this6.ZB < 0) {
1173
- (0, _util.info)('Invalid BlackPoint, falling back to default');
1174
- _this6.XB = _this6.YB = _this6.ZB = 0;
1040
+ if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
1041
+ (0, _util.info)("Invalid BlackPoint, falling back to default");
1042
+ this.XB = this.YB = this.ZB = 0;
1175
1043
  }
1176
1044
 
1177
- if (_this6.amin > _this6.amax || _this6.bmin > _this6.bmax) {
1178
- (0, _util.info)('Invalid Range, falling back to defaults');
1179
- _this6.amin = -100;
1180
- _this6.amax = 100;
1181
- _this6.bmin = -100;
1182
- _this6.bmax = 100;
1045
+ if (this.amin > this.amax || this.bmin > this.bmax) {
1046
+ (0, _util.info)("Invalid Range, falling back to defaults");
1047
+ this.amin = -100;
1048
+ this.amax = 100;
1049
+ this.bmin = -100;
1050
+ this.bmax = 100;
1183
1051
  }
1052
+ }
1184
1053
 
1185
- return _this6;
1054
+ getRgbItem(src, srcOffset, dest, destOffset) {
1055
+ convertToRgb(this, src, srcOffset, false, dest, destOffset);
1186
1056
  }
1187
1057
 
1188
- _createClass(LabCS, [{
1189
- key: "getRgbItem",
1190
- value: function getRgbItem(src, srcOffset, dest, destOffset) {
1191
- convertToRgb(this, src, srcOffset, false, dest, destOffset);
1192
- }
1193
- }, {
1194
- key: "getRgbBuffer",
1195
- value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
1196
- var maxVal = (1 << bits) - 1;
1197
-
1198
- for (var i = 0; i < count; i++) {
1199
- convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
1200
- srcOffset += 3;
1201
- destOffset += 3 + alpha01;
1202
- }
1203
- }
1204
- }, {
1205
- key: "getOutputLength",
1206
- value: function getOutputLength(inputLength, alpha01) {
1207
- return inputLength * (3 + alpha01) / 3 | 0;
1208
- }
1209
- }, {
1210
- key: "isDefaultDecode",
1211
- value: function isDefaultDecode(decodeMap, bpc) {
1212
- return true;
1213
- }
1214
- }, {
1215
- key: "usesZeroToOneRange",
1216
- get: function get() {
1217
- return (0, _util.shadow)(this, 'usesZeroToOneRange', false);
1058
+ getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
1059
+ const maxVal = (1 << bits) - 1;
1060
+
1061
+ for (let i = 0; i < count; i++) {
1062
+ convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
1063
+ srcOffset += 3;
1064
+ destOffset += 3 + alpha01;
1218
1065
  }
1219
- }]);
1066
+ }
1220
1067
 
1221
- return LabCS;
1222
- }(ColorSpace);
1068
+ getOutputLength(inputLength, alpha01) {
1069
+ return inputLength * (3 + alpha01) / 3 | 0;
1070
+ }
1071
+
1072
+ isDefaultDecode(decodeMap, bpc) {
1073
+ return true;
1074
+ }
1075
+
1076
+ get usesZeroToOneRange() {
1077
+ return (0, _util.shadow)(this, "usesZeroToOneRange", false);
1078
+ }
1079
+
1080
+ }
1223
1081
 
1224
1082
  return LabCS;
1225
1083
  }();