@pixerate/editor 0.114.0 → 0.116.0

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.
Files changed (122) hide show
  1. package/THIRD_PARTY_NOTICES.md +6 -0
  2. package/dist/animation-editor/index.cjs +54 -54
  3. package/dist/animation-editor/index.d.cts +2 -2
  4. package/dist/animation-editor/index.d.ts +2 -2
  5. package/dist/animation-editor/index.js +2 -2
  6. package/dist/{chunk-DFQEX3AM.cjs → chunk-2UT4GXYA.cjs} +133 -8
  7. package/dist/chunk-2UT4GXYA.cjs.map +1 -0
  8. package/dist/{chunk-VXR7XWMF.js → chunk-7LNZAWSJ.js} +437 -41
  9. package/dist/chunk-7LNZAWSJ.js.map +1 -0
  10. package/dist/{chunk-LKCYANMW.js → chunk-ARQ7PQ6Q.js} +129 -4
  11. package/dist/chunk-ARQ7PQ6Q.js.map +1 -0
  12. package/dist/chunk-COAMRKVI.cjs +159 -0
  13. package/dist/chunk-COAMRKVI.cjs.map +1 -0
  14. package/dist/{chunk-C6C5PDKU.js → chunk-D53KSJUV.js} +3 -322
  15. package/dist/chunk-D53KSJUV.js.map +1 -0
  16. package/dist/chunk-D53VQGEJ.js +3262 -0
  17. package/dist/chunk-D53VQGEJ.js.map +1 -0
  18. package/dist/chunk-EJVDBITD.cjs +501 -0
  19. package/dist/chunk-EJVDBITD.cjs.map +1 -0
  20. package/dist/{chunk-LPLCWZTM.cjs → chunk-FODKPD44.cjs} +555 -159
  21. package/dist/chunk-FODKPD44.cjs.map +1 -0
  22. package/dist/chunk-HOCPSFGA.cjs +3262 -0
  23. package/dist/chunk-HOCPSFGA.cjs.map +1 -0
  24. package/dist/chunk-IPFRWILU.js +1908 -0
  25. package/dist/chunk-IPFRWILU.js.map +1 -0
  26. package/dist/{chunk-FV5AXTSF.cjs → chunk-JSSBHMMU.cjs} +36 -188
  27. package/dist/chunk-JSSBHMMU.cjs.map +1 -0
  28. package/dist/chunk-LF4WOZXZ.js +159 -0
  29. package/dist/chunk-LF4WOZXZ.js.map +1 -0
  30. package/dist/{chunk-26PGXHY7.cjs → chunk-M7O4BJRH.cjs} +36 -36
  31. package/dist/{chunk-26PGXHY7.cjs.map → chunk-M7O4BJRH.cjs.map} +1 -1
  32. package/dist/chunk-N3467VD6.js +501 -0
  33. package/dist/chunk-N3467VD6.js.map +1 -0
  34. package/dist/{chunk-ST7E3NEE.cjs → chunk-PAOWHJ5O.cjs} +18 -337
  35. package/dist/chunk-PAOWHJ5O.cjs.map +1 -0
  36. package/dist/{chunk-EUVSQ25B.js → chunk-SEBYNBHW.js} +85 -46
  37. package/dist/chunk-SEBYNBHW.js.map +1 -0
  38. package/dist/chunk-SMJGE7HM.cjs +1908 -0
  39. package/dist/chunk-SMJGE7HM.cjs.map +1 -0
  40. package/dist/{chunk-MMVHBKMM.js → chunk-T2P5TIZ6.js} +2 -2
  41. package/dist/{chunk-FGW5OWJ4.js → chunk-VJUML33I.js} +4 -156
  42. package/dist/chunk-VJUML33I.js.map +1 -0
  43. package/dist/{chunk-5OVJHMZQ.cjs → chunk-ZYZGEILO.cjs} +332 -293
  44. package/dist/chunk-ZYZGEILO.cjs.map +1 -0
  45. package/dist/export/index.cjs +4 -2
  46. package/dist/export/index.cjs.map +1 -1
  47. package/dist/export/index.js +5 -3
  48. package/dist/{export-b6NjCZ5-.d.cts → export-BXxSGBCq.d.cts} +67 -5
  49. package/dist/{export-_1dUKwpF.d.ts → export-Dm44YUvS.d.ts} +67 -5
  50. package/dist/export-Dv0-ZVrV.d.cts +501 -0
  51. package/dist/export-Dv0-ZVrV.d.ts +501 -0
  52. package/dist/{retouch-Do6tBs2H.d.ts → flow-BMtHAmg4.d.ts} +561 -2
  53. package/dist/{retouch-Bxkuc0KH.d.cts → flow-COCB42TP.d.cts} +561 -2
  54. package/dist/image-editor/index.cjs +1227 -934
  55. package/dist/image-editor/index.cjs.map +1 -1
  56. package/dist/image-editor/index.d.cts +18 -10
  57. package/dist/image-editor/index.d.ts +18 -10
  58. package/dist/image-editor/index.js +324 -31
  59. package/dist/image-editor/index.js.map +1 -1
  60. package/dist/index.cjs +4 -2
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.js +5 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/kernel-wasm-WYCGNZR4.js +10 -0
  65. package/dist/kernel-wasm-WYCGNZR4.js.map +1 -0
  66. package/dist/kernel-wasm-YPVAEMVN.cjs +10 -0
  67. package/dist/kernel-wasm-YPVAEMVN.cjs.map +1 -0
  68. package/dist/paint/index.cjs +165 -3
  69. package/dist/paint/index.cjs.map +1 -1
  70. package/dist/paint/index.d.cts +225 -3
  71. package/dist/paint/index.d.ts +225 -3
  72. package/dist/paint/index.js +166 -4
  73. package/dist/paint-editor/index.cjs +4691 -845
  74. package/dist/paint-editor/index.cjs.map +1 -1
  75. package/dist/paint-editor/index.d.cts +1525 -277
  76. package/dist/paint-editor/index.d.ts +1525 -277
  77. package/dist/paint-editor/index.js +4561 -715
  78. package/dist/paint-editor/index.js.map +1 -1
  79. package/dist/raster/index.cjs +4 -3
  80. package/dist/raster/index.cjs.map +1 -1
  81. package/dist/raster/index.js +10 -9
  82. package/dist/{svg-BnRj0q8i.d.cts → svg-CVdFc80-.d.cts} +2 -2
  83. package/dist/{svg-CmmBFfGT.d.ts → svg-DlEuhwoX.d.ts} +2 -2
  84. package/dist/{types-1SUQKDAw.d.ts → types-CDLGhAZp.d.ts} +40 -2
  85. package/dist/{types-yINF17Ta.d.cts → types-Tfly4Aya.d.cts} +40 -2
  86. package/dist/vector/index.cjs +1897 -975
  87. package/dist/vector/index.cjs.map +1 -1
  88. package/dist/vector/index.d.cts +292 -32
  89. package/dist/vector/index.d.ts +292 -32
  90. package/dist/vector/index.js +928 -6
  91. package/dist/vector/index.js.map +1 -1
  92. package/dist/video-editor/index.cjs +502 -2165
  93. package/dist/video-editor/index.cjs.map +1 -1
  94. package/dist/video-editor/index.d.cts +3 -501
  95. package/dist/video-editor/index.d.ts +3 -501
  96. package/dist/video-editor/index.js +151 -1814
  97. package/dist/video-editor/index.js.map +1 -1
  98. package/package.json +4 -2
  99. package/skills/pixerate-image-editor/SKILL.md +1 -0
  100. package/skills/pixerate-image-editor/references/color-management.md +8 -3
  101. package/skills/pixerate-image-editor/references/photoshop-files.md +15 -9
  102. package/skills/pixerate-paint-editor/SKILL.md +136 -4
  103. package/skills/pixerate-vector/SKILL.md +22 -1
  104. package/dist/chunk-5OVJHMZQ.cjs.map +0 -1
  105. package/dist/chunk-C6C5PDKU.js.map +0 -1
  106. package/dist/chunk-DFQEX3AM.cjs.map +0 -1
  107. package/dist/chunk-EUVSQ25B.js.map +0 -1
  108. package/dist/chunk-FGW5OWJ4.js.map +0 -1
  109. package/dist/chunk-FV5AXTSF.cjs.map +0 -1
  110. package/dist/chunk-GX332W2C.js +0 -181
  111. package/dist/chunk-GX332W2C.js.map +0 -1
  112. package/dist/chunk-LKCYANMW.js.map +0 -1
  113. package/dist/chunk-LPLCWZTM.cjs.map +0 -1
  114. package/dist/chunk-MUUXNRU4.cjs +0 -181
  115. package/dist/chunk-MUUXNRU4.cjs.map +0 -1
  116. package/dist/chunk-ST7E3NEE.cjs.map +0 -1
  117. package/dist/chunk-TCKIXI46.cjs +0 -1136
  118. package/dist/chunk-TCKIXI46.cjs.map +0 -1
  119. package/dist/chunk-UBIXVXPR.js +0 -1136
  120. package/dist/chunk-UBIXVXPR.js.map +0 -1
  121. package/dist/chunk-VXR7XWMF.js.map +0 -1
  122. /package/dist/{chunk-MMVHBKMM.js.map → chunk-T2P5TIZ6.js.map} +0 -0
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
10
+ var _chunkEJVDBITDcjs = require('./chunk-EJVDBITD.cjs');
11
11
 
12
12
 
13
13
 
@@ -28,10 +28,6 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
28
28
 
29
29
  var _chunkTFOPHZ3Ucjs = require('./chunk-TFOPHZ3U.cjs');
30
30
 
31
-
32
-
33
- var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
34
-
35
31
  // src/raster/deep.ts
36
32
  var BIT_DEPTHS = [8, 16, 32];
37
33
  var isBitDepth = (v) => v === 8 || v === 16 || v === 32;
@@ -3832,10 +3828,10 @@ function assemble(src, tiles) {
3832
3828
  return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(src.channels, tiles, src.defaultValue);
3833
3829
  }
3834
3830
  function transformedBounds(source, h) {
3835
- if (!(source.width > 0 && source.height > 0) || !_chunkMUUXNRU4cjs.invertHomography.call(void 0, h)) return null;
3836
- const pts = _chunkMUUXNRU4cjs.boxQuad.call(void 0, source).map((p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p));
3831
+ if (!(source.width > 0 && source.height > 0) || !_chunkEJVDBITDcjs.invertHomography.call(void 0, h)) return null;
3832
+ const pts = _chunkEJVDBITDcjs.boxQuad.call(void 0, source).map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, h, p));
3837
3833
  if (pts.some((p) => !p)) return null;
3838
- return _chunkMUUXNRU4cjs.cornerBounds.call(void 0, pts);
3834
+ return _chunkEJVDBITDcjs.cornerBounds.call(void 0, pts);
3839
3835
  }
3840
3836
  function transformSurface(src, h, options = {}) {
3841
3837
  const interp = _nullishCoalesce(options.interpolation, () => ( "bicubic"));
@@ -3844,10 +3840,10 @@ function transformSurface(src, h, options = {}) {
3844
3840
  const empty = _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, ch, def);
3845
3841
  const given = options.source;
3846
3842
  const step = normalizeStep(options.step);
3847
- if (_chunkMUUXNRU4cjs.isIdentityHomography.call(void 0, h, 1e-12) && !given && !options.clip) return src;
3843
+ if (_chunkEJVDBITDcjs.isIdentityHomography.call(void 0, h, 1e-12) && !given && !options.clip) return src;
3848
3844
  const dx = h[2] / h[8];
3849
3845
  const dy = h[5] / h[8];
3850
- if (!given && !options.clip && _chunkMUUXNRU4cjs.isIdentityHomography.call(void 0, [h[0], h[1], 0, h[3], h[4], 0, h[6], h[7], h[8]], 1e-12) && Math.abs(dx - Math.round(dx)) < 1e-9 && Math.abs(dy - Math.round(dy)) < 1e-9) {
3846
+ if (!given && !options.clip && _chunkEJVDBITDcjs.isIdentityHomography.call(void 0, [h[0], h[1], 0, h[3], h[4], 0, h[6], h[7], h[8]], 1e-12) && Math.abs(dx - Math.round(dx)) < 1e-9 && Math.abs(dy - Math.round(dy)) < 1e-9) {
3851
3847
  return _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, src, Math.round(dx), Math.round(dy));
3852
3848
  }
3853
3849
  let srcRect = given ? intersect(given, given) : _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, src);
@@ -3855,8 +3851,8 @@ function transformSurface(src, h, options = {}) {
3855
3851
  let H = h;
3856
3852
  let S = src;
3857
3853
  if (interp === "bicubic") {
3858
- const inv0 = _chunkMUUXNRU4cjs.invertHomography.call(void 0, H);
3859
- const c = _chunkMUUXNRU4cjs.applyHomography.call(void 0, H, { x: srcRect.x + srcRect.width / 2, y: srcRect.y + srcRect.height / 2 });
3854
+ const inv0 = _chunkEJVDBITDcjs.invertHomography.call(void 0, H);
3855
+ const c = _chunkEJVDBITDcjs.applyHomography.call(void 0, H, { x: srcRect.x + srcRect.width / 2, y: srcRect.y + srcRect.height / 2 });
3860
3856
  if (inv0 && c) {
3861
3857
  const [su, sv] = inverseStretch(inv0, c.x, c.y);
3862
3858
  const kx = reduction(su);
@@ -3865,11 +3861,11 @@ function transformSurface(src, h, options = {}) {
3865
3861
  const red = boxReduce(src, srcRect, kx, ky);
3866
3862
  S = red.surface;
3867
3863
  srcRect = red.rect;
3868
- H = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [kx, 0, 0, 0, ky, 0, 0, 0, 1], H);
3864
+ H = _chunkEJVDBITDcjs.multiplyHomographies.call(void 0, [kx, 0, 0, 0, ky, 0, 0, 0, 1], H);
3869
3865
  }
3870
3866
  }
3871
3867
  }
3872
- const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, H);
3868
+ const inv = _chunkEJVDBITDcjs.invertHomography.call(void 0, H);
3873
3869
  if (!inv) return empty;
3874
3870
  const sr = srcRect;
3875
3871
  const fwd = [
@@ -3877,12 +3873,12 @@ function transformSurface(src, h, options = {}) {
3877
3873
  { x: sr.x + sr.width + 1, y: sr.y - 1 },
3878
3874
  { x: sr.x + sr.width + 1, y: sr.y + sr.height + 1 },
3879
3875
  { x: sr.x - 1, y: sr.y + sr.height + 1 }
3880
- ].map((p) => _chunkMUUXNRU4cjs.homographyW.call(void 0, H, p));
3876
+ ].map((p) => _chunkEJVDBITDcjs.homographyW.call(void 0, H, p));
3881
3877
  const side = fwd.every((w) => w > 0) ? 1 : fwd.every((w) => w < 0) ? -1 : 0;
3882
3878
  const wLo = 1 / fwd.reduce((m, w) => Math.max(m, Math.abs(w)), 0);
3883
- const front = side === 0 ? _chunkMUUXNRU4cjs.homographyFrontSide.call(void 0, H, sr) : 0;
3884
- const corners = _chunkMUUXNRU4cjs.boxQuad.call(void 0, sr).map((p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, H, p));
3885
- const bounds = corners.every(Boolean) ? _chunkMUUXNRU4cjs.cornerBounds.call(void 0, corners) : null;
3879
+ const front = side === 0 ? _chunkEJVDBITDcjs.homographyFrontSide.call(void 0, H, sr) : 0;
3880
+ const corners = _chunkEJVDBITDcjs.boxQuad.call(void 0, sr).map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, H, p));
3881
+ const bounds = corners.every(Boolean) ? _chunkEJVDBITDcjs.cornerBounds.call(void 0, corners) : null;
3886
3882
  let dst;
3887
3883
  if (options.clip && bounds && side !== 0) dst = intersect(bounds, options.clip);
3888
3884
  else dst = _nullishCoalesce(options.clip, () => ( bounds));
@@ -3909,7 +3905,7 @@ function transformSurface(src, h, options = {}) {
3909
3905
  { x: t.x + t.width, y: t.y + t.height },
3910
3906
  { x: t.x, y: t.y + t.height }
3911
3907
  ];
3912
- const wc = tc.map((p) => _chunkMUUXNRU4cjs.homographyW.call(void 0, inv, p));
3908
+ const wc = tc.map((p) => _chunkEJVDBITDcjs.homographyW.call(void 0, inv, p));
3913
3909
  let poly = tc;
3914
3910
  if (side !== 0) {
3915
3911
  const dd = wc.map((w) => side * w - wLo);
@@ -3931,7 +3927,7 @@ function transformSurface(src, h, options = {}) {
3931
3927
  let foot;
3932
3928
  if (straddles) foot = sr;
3933
3929
  else {
3934
- const fp = poly.map((p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, inv, p));
3930
+ const fp = poly.map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, inv, p));
3935
3931
  if (fp.some((p) => !p)) foot = sr;
3936
3932
  else {
3937
3933
  const xs = fp.map((p) => p.x);
@@ -4287,321 +4283,6 @@ function compositeSurfaceOver(base, top) {
4287
4283
  return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(ch, tiles, base.defaultValue);
4288
4284
  }
4289
4285
 
4290
- // src/raster/png.ts
4291
- var SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
4292
- var crcTable = null;
4293
- function crc32(bytes, start, end) {
4294
- if (!crcTable) {
4295
- crcTable = new Uint32Array(256);
4296
- for (let n = 0; n < 256; n++) {
4297
- let c2 = n;
4298
- for (let k = 0; k < 8; k++) c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
4299
- crcTable[n] = c2 >>> 0;
4300
- }
4301
- }
4302
- let c = 4294967295;
4303
- for (let i = start; i < end; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ c >>> 8;
4304
- return (c ^ 4294967295) >>> 0;
4305
- }
4306
- function paeth(a, b, c) {
4307
- const p = a + b - c;
4308
- const pa = Math.abs(p - a);
4309
- const pb = Math.abs(p - b);
4310
- const pc = Math.abs(p - c);
4311
- return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
4312
- }
4313
- function encodePng(width, height, data, channels = 4) {
4314
- const stride = width * channels;
4315
- const raw = new Uint8Array((stride + 1) * height);
4316
- const bpp = channels;
4317
- const cand = [new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride)];
4318
- for (let y = 0; y < height; y++) {
4319
- const row = y * stride;
4320
- const prevRow = (y - 1) * stride;
4321
- let best = 0;
4322
- let bestScore = Infinity;
4323
- for (let f = 0; f < 5; f++) {
4324
- const out2 = cand[f];
4325
- let score = 0;
4326
- for (let x = 0; x < stride; x++) {
4327
- const v = data[row + x];
4328
- const a = x >= bpp ? data[row + x - bpp] : 0;
4329
- const b = y > 0 ? data[prevRow + x] : 0;
4330
- const c = x >= bpp && y > 0 ? data[prevRow + x - bpp] : 0;
4331
- let r;
4332
- switch (f) {
4333
- case 0:
4334
- r = v;
4335
- break;
4336
- case 1:
4337
- r = v - a;
4338
- break;
4339
- case 2:
4340
- r = v - b;
4341
- break;
4342
- case 3:
4343
- r = v - (a + b >> 1);
4344
- break;
4345
- default:
4346
- r = v - paeth(a, b, c);
4347
- }
4348
- r &= 255;
4349
- out2[x] = r;
4350
- score += r < 128 ? r : 256 - r;
4351
- if (score >= bestScore) break;
4352
- }
4353
- if (score < bestScore) {
4354
- bestScore = score;
4355
- best = f;
4356
- }
4357
- }
4358
- const o = y * (stride + 1);
4359
- raw[o] = best;
4360
- raw.set(cand[best], o + 1);
4361
- }
4362
- const idat = _chunk643B2HKCcjs.deflate.call(void 0, raw);
4363
- const chunks = [];
4364
- const ihdr = new Uint8Array(13);
4365
- writeU32(ihdr, 0, width);
4366
- writeU32(ihdr, 4, height);
4367
- ihdr[8] = 8;
4368
- ihdr[9] = channels === 1 ? 0 : 6;
4369
- chunks.push(["IHDR", ihdr], ["IDAT", idat], ["IEND", new Uint8Array(0)]);
4370
- let size = 8;
4371
- for (const [, d] of chunks) size += 12 + d.length;
4372
- const out = new Uint8Array(size);
4373
- out.set(SIGNATURE, 0);
4374
- let p = 8;
4375
- for (const [type, d] of chunks) {
4376
- writeU32(out, p, d.length);
4377
- for (let i = 0; i < 4; i++) out[p + 4 + i] = type.charCodeAt(i);
4378
- out.set(d, p + 8);
4379
- writeU32(out, p + 8 + d.length, crc32(out, p + 4, p + 8 + d.length));
4380
- p += 12 + d.length;
4381
- }
4382
- return out;
4383
- }
4384
- function writeU32(b, o, v) {
4385
- b[o] = v >>> 24;
4386
- b[o + 1] = v >>> 16 & 255;
4387
- b[o + 2] = v >>> 8 & 255;
4388
- b[o + 3] = v & 255;
4389
- }
4390
- function readU32(b, o) {
4391
- return (b[o] << 24 | b[o + 1] << 16 | b[o + 2] << 8 | b[o + 3]) >>> 0;
4392
- }
4393
- function isPng(bytes) {
4394
- return bytes.length > 8 && SIGNATURE.every((v, i) => bytes[i] === v);
4395
- }
4396
- function decodePng(bytes, options = {}) {
4397
- if (!isPng(bytes)) throw new Error("Not a PNG image.");
4398
- let p = 8;
4399
- let width = 0;
4400
- let height = 0;
4401
- let depth = 0;
4402
- let type = 0;
4403
- let interlace = 0;
4404
- let palette = null;
4405
- let trns = null;
4406
- const idat = [];
4407
- while (p + 8 <= bytes.length) {
4408
- const len = readU32(bytes, p);
4409
- const t = String.fromCharCode(bytes[p + 4], bytes[p + 5], bytes[p + 6], bytes[p + 7]);
4410
- const body = bytes.subarray(p + 8, p + 8 + len);
4411
- if (p + 12 + len > bytes.length) throw new Error("Truncated PNG.");
4412
- if (t === "IHDR") {
4413
- width = readU32(body, 0);
4414
- height = readU32(body, 4);
4415
- depth = body[8];
4416
- type = body[9];
4417
- interlace = body[12];
4418
- } else if (t === "PLTE") palette = body;
4419
- else if (t === "tRNS") trns = body;
4420
- else if (t === "IDAT") idat.push(body);
4421
- else if (t === "IEND") break;
4422
- p += 12 + len;
4423
- }
4424
- if (!width || !height) throw new Error("PNG has no image header.");
4425
- if (interlace) throw new Error("Interlaced PNGs are not supported here; decode them with a canvas.");
4426
- const maxPixels = _nullishCoalesce(options.maxPixels, () => ( 1 << 28));
4427
- if (width * height > maxPixels) throw new Error(`PNG is too large (${width}\xD7${height}).`);
4428
- const samples = type === 0 ? 1 : type === 2 ? 3 : type === 3 ? 1 : type === 4 ? 2 : type === 6 ? 4 : 0;
4429
- if (!samples || ![1, 2, 4, 8, 16].includes(depth)) throw new Error(`Unsupported PNG format (type ${type}, depth ${depth}).`);
4430
- let total = 0;
4431
- for (const c of idat) total += c.length;
4432
- const z = new Uint8Array(total);
4433
- let o = 0;
4434
- for (const c of idat) {
4435
- z.set(c, o);
4436
- o += c.length;
4437
- }
4438
- const bitsPerPixel = samples * depth;
4439
- const stride = Math.ceil(width * bitsPerPixel / 8);
4440
- const raw = _chunk643B2HKCcjs.inflate.call(void 0, z, { maxOutput: (stride + 1) * height, sizeHint: (stride + 1) * height });
4441
- if (raw.length < (stride + 1) * height) throw new Error("PNG image data is truncated.");
4442
- const bpp = Math.max(1, bitsPerPixel >> 3);
4443
- const lines = new Uint8Array(stride * height);
4444
- for (let y = 0; y < height; y++) {
4445
- const f = raw[y * (stride + 1)];
4446
- const src = y * (stride + 1) + 1;
4447
- const dst = y * stride;
4448
- const up = dst - stride;
4449
- for (let x = 0; x < stride; x++) {
4450
- const v = raw[src + x];
4451
- const a = x >= bpp ? lines[dst + x - bpp] : 0;
4452
- const b = y > 0 ? lines[up + x] : 0;
4453
- const c = x >= bpp && y > 0 ? lines[up + x - bpp] : 0;
4454
- let r;
4455
- switch (f) {
4456
- case 0:
4457
- r = v;
4458
- break;
4459
- case 1:
4460
- r = v + a;
4461
- break;
4462
- case 2:
4463
- r = v + b;
4464
- break;
4465
- case 3:
4466
- r = v + (a + b >> 1);
4467
- break;
4468
- case 4:
4469
- r = v + paeth(a, b, c);
4470
- break;
4471
- default:
4472
- throw new Error(`Invalid PNG filter ${f}.`);
4473
- }
4474
- lines[dst + x] = r & 255;
4475
- }
4476
- }
4477
- const sample2 = (y, i) => {
4478
- const row = y * stride;
4479
- if (depth === 8) return lines[row + i];
4480
- if (depth === 16) return lines[row + i * 2];
4481
- const perByte = 8 / depth;
4482
- const byte = lines[row + Math.floor(i / perByte)];
4483
- const shift = 8 - depth * (i % perByte + 1);
4484
- const v = byte >> shift & (1 << depth) - 1;
4485
- return type === 3 ? v : Math.round(v * 255 / ((1 << depth) - 1));
4486
- };
4487
- const gray = options.keepGray && type === 0 && !trns;
4488
- const channels = gray ? 1 : 4;
4489
- const out = new Uint8ClampedArray(width * height * channels);
4490
- const trnsGray = trns && type === 0 ? depth === 16 ? trns[0] : sample16(trns, 0, depth) : -1;
4491
- const trnsRgb = trns && type === 2 ? [0, 1, 2].map((k) => depth === 16 ? trns[k * 2] : sample16(trns, k, depth)) : null;
4492
- for (let y = 0; y < height; y++) {
4493
- for (let x = 0; x < width; x++) {
4494
- const d = (y * width + x) * channels;
4495
- if (type === 0) {
4496
- const v = sample2(y, x);
4497
- if (gray) out[d] = v;
4498
- else {
4499
- out[d] = out[d + 1] = out[d + 2] = v;
4500
- out[d + 3] = v === trnsGray && trns ? 0 : 255;
4501
- }
4502
- } else if (type === 2) {
4503
- const r = sample2(y, x * 3);
4504
- const g = sample2(y, x * 3 + 1);
4505
- const b = sample2(y, x * 3 + 2);
4506
- out[d] = r;
4507
- out[d + 1] = g;
4508
- out[d + 2] = b;
4509
- out[d + 3] = trnsRgb && r === trnsRgb[0] && g === trnsRgb[1] && b === trnsRgb[2] ? 0 : 255;
4510
- } else if (type === 3) {
4511
- const i = sample2(y, x);
4512
- if (!palette || i * 3 + 2 >= palette.length) throw new Error("PNG palette index out of range.");
4513
- out[d] = palette[i * 3];
4514
- out[d + 1] = palette[i * 3 + 1];
4515
- out[d + 2] = palette[i * 3 + 2];
4516
- out[d + 3] = trns && i < trns.length ? trns[i] : 255;
4517
- } else if (type === 4) {
4518
- const v = sample2(y, x * 2);
4519
- out[d] = out[d + 1] = out[d + 2] = v;
4520
- out[d + 3] = sample2(y, x * 2 + 1);
4521
- } else {
4522
- out[d] = sample2(y, x * 4);
4523
- out[d + 1] = sample2(y, x * 4 + 1);
4524
- out[d + 2] = sample2(y, x * 4 + 2);
4525
- out[d + 3] = sample2(y, x * 4 + 3);
4526
- }
4527
- }
4528
- }
4529
- return { width, height, channels, data: out };
4530
- }
4531
- function sample16(trns, k, depth) {
4532
- const v = trns[k * 2] << 8 | trns[k * 2 + 1];
4533
- if (depth === 8) return v & 255;
4534
- return Math.round((v & (1 << depth) - 1) * 255 / ((1 << depth) - 1));
4535
- }
4536
- var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4537
- var B64_INV = null;
4538
- function bytesToBase64(bytes) {
4539
- const parts = [];
4540
- const CHUNK = 3 * 4096;
4541
- for (let start = 0; start < bytes.length; start += CHUNK) {
4542
- const end = Math.min(bytes.length, start + CHUNK);
4543
- let s = "";
4544
- let i = start;
4545
- for (; i + 2 < end; i += 3) {
4546
- const n = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
4547
- s += B64[n >> 18] + B64[n >> 12 & 63] + B64[n >> 6 & 63] + B64[n & 63];
4548
- }
4549
- if (i < end) {
4550
- const n = bytes[i] << 16 | (i + 1 < end ? bytes[i + 1] << 8 : 0);
4551
- s += B64[n >> 18] + B64[n >> 12 & 63] + (i + 1 < end ? B64[n >> 6 & 63] : "=") + "=";
4552
- }
4553
- parts.push(s);
4554
- }
4555
- return parts.join("");
4556
- }
4557
- function base64ToBytes(text) {
4558
- if (!B64_INV) {
4559
- B64_INV = new Int16Array(128).fill(-1);
4560
- for (let i = 0; i < 64; i++) B64_INV[B64.charCodeAt(i)] = i;
4561
- B64_INV["-".charCodeAt(0)] = 62;
4562
- B64_INV["_".charCodeAt(0)] = 63;
4563
- }
4564
- const inv = B64_INV;
4565
- const clean = text.replace(/[\s=]/g, "");
4566
- const out = new Uint8Array(Math.floor(clean.length * 3 / 4));
4567
- let bits = 0;
4568
- let acc = 0;
4569
- let o = 0;
4570
- for (let i = 0; i < clean.length; i++) {
4571
- const c = clean.charCodeAt(i);
4572
- const v = c < 128 ? inv[c] : -1;
4573
- if (v < 0) throw new Error("Invalid base64 data.");
4574
- acc = acc << 6 | v;
4575
- bits += 6;
4576
- if (bits >= 8) {
4577
- bits -= 8;
4578
- out[o++] = acc >> bits & 255;
4579
- }
4580
- }
4581
- return out.subarray(0, o);
4582
- }
4583
- function parseDataUrl(url) {
4584
- const m = /^data:([^;,]*)((?:;[^;,]*)*?),/i.exec(url);
4585
- if (!m) return null;
4586
- const body = url.slice(m[0].length);
4587
- const isBase64 = /;base64/i.test(m[2]);
4588
- if (isBase64) return { mime: m[1] || "text/plain", bytes: base64ToBytes(body) };
4589
- const text = decodeURIComponent(body);
4590
- const bytes = new Uint8Array(text.length);
4591
- for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i) & 255;
4592
- return { mime: m[1] || "text/plain", bytes };
4593
- }
4594
- function pngDataUrl(width, height, data, channels = 4) {
4595
- return `data:image/png;base64,${bytesToBase64(encodePng(width, height, data, channels))}`;
4596
- }
4597
-
4598
-
4599
-
4600
-
4601
-
4602
-
4603
-
4604
-
4605
4286
 
4606
4287
 
4607
4288
 
@@ -4687,5 +4368,5 @@ function pngDataUrl(width, height, data, channels = 4) {
4687
4368
 
4688
4369
 
4689
4370
 
4690
- exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.DEFAULT_GLOBAL_LIGHT = DEFAULT_GLOBAL_LIGHT; exports.LAYER_EFFECT_KINDS = LAYER_EFFECT_KINDS; exports.layerEffectLabel = layerEffectLabel; exports.isLayerEffectKind = isLayerEffectKind; exports.defaultEffectGradient = defaultEffectGradient; exports.newEffectId = newEffectId; exports.defaultLayerEffect = defaultLayerEffect; exports.hasActiveEffects = hasActiveEffects; exports.MAX_EFFECT_REACH = MAX_EFFECT_REACH; exports.effectReach = effectReach; exports.effectsMargin = effectsMargin; exports.effectsScale = effectsScale; exports.scaleLayerEffect = scaleLayerEffect; exports.parseEffectColor = parseEffectColor; exports.effectColorHex = effectColorHex; exports.LayerEffectError = LayerEffectError; exports.validateEffectGradient = validateEffectGradient; exports.layerEffectFields = layerEffectFields; exports.validateLayerEffect = validateLayerEffect; exports.mergeLayerEffect = mergeLayerEffect; exports.validateLayerEffects = validateLayerEffects; exports.normalizeLayerEffects = normalizeLayerEffects; exports.effectsFingerprint = effectsFingerprint; exports.DeepCompositor = DeepCompositor; exports.workingToSamples = workingToSamples; exports.DIRECT_GAUSSIAN_MAX_SIGMA = DIRECT_GAUSSIAN_MAX_SIGMA; exports.gaussianBlur = gaussianBlur; exports.flattenLayers = flattenLayers; exports.findLayer = findLayer; exports.mapLayer = mapLayer; exports.insertLayer = insertLayer; exports.isLayerLocked = isLayerLocked; exports.PatternTile = PatternTile; exports.PatternPlacement = PatternPlacement; exports.builtinPatternIds = builtinPatternIds; exports.builtinPattern = builtinPattern; exports.hashNoise = hashNoise; exports.CURVE_LUT_SIZE = CURVE_LUT_SIZE; exports.curveLut = curveLut; exports.STROKE_CHAMFER_MAX = STROKE_CHAMFER_MAX; exports.contourLut = contourLut; exports.activeEffectItems = activeEffectItems; exports.effectsAreLocal = effectsAreLocal; exports.buildEffectMaps = buildEffectMaps; exports.patchEffectMaps = patchEffectMaps; exports.gradientT = gradientT; exports.effectFillColors = effectFillColors; exports.compositeLayerEffects = compositeLayerEffects; exports.renderLayerEffects = renderLayerEffects; exports.blendTile = blendTile; exports.RasterCompositor = RasterCompositor; exports.changedTiles = changedTiles; exports.INTERPOLATIONS = INTERPOLATIONS; exports.isInterpolation = isInterpolation; exports.MAX_TRANSFORM_PIXELS = MAX_TRANSFORM_PIXELS; exports.TransformTooLargeError = TransformTooLargeError; exports.keysWeight = keysWeight; exports.reduceSurface = reduceSurface; exports.transformedBounds = transformedBounds; exports.transformSurface = transformSurface; exports.warpSurface = warpSurface; exports.compositeSurfaceOver = compositeSurfaceOver; exports.encodePng = encodePng; exports.isPng = isPng; exports.decodePng = decodePng; exports.bytesToBase64 = bytesToBase64; exports.base64ToBytes = base64ToBytes; exports.parseDataUrl = parseDataUrl; exports.pngDataUrl = pngDataUrl;
4691
- //# sourceMappingURL=chunk-ST7E3NEE.cjs.map
4371
+ exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.DEFAULT_GLOBAL_LIGHT = DEFAULT_GLOBAL_LIGHT; exports.LAYER_EFFECT_KINDS = LAYER_EFFECT_KINDS; exports.layerEffectLabel = layerEffectLabel; exports.isLayerEffectKind = isLayerEffectKind; exports.defaultEffectGradient = defaultEffectGradient; exports.newEffectId = newEffectId; exports.defaultLayerEffect = defaultLayerEffect; exports.hasActiveEffects = hasActiveEffects; exports.MAX_EFFECT_REACH = MAX_EFFECT_REACH; exports.effectReach = effectReach; exports.effectsMargin = effectsMargin; exports.effectsScale = effectsScale; exports.scaleLayerEffect = scaleLayerEffect; exports.parseEffectColor = parseEffectColor; exports.effectColorHex = effectColorHex; exports.LayerEffectError = LayerEffectError; exports.validateEffectGradient = validateEffectGradient; exports.layerEffectFields = layerEffectFields; exports.validateLayerEffect = validateLayerEffect; exports.mergeLayerEffect = mergeLayerEffect; exports.validateLayerEffects = validateLayerEffects; exports.normalizeLayerEffects = normalizeLayerEffects; exports.effectsFingerprint = effectsFingerprint; exports.DeepCompositor = DeepCompositor; exports.workingToSamples = workingToSamples; exports.DIRECT_GAUSSIAN_MAX_SIGMA = DIRECT_GAUSSIAN_MAX_SIGMA; exports.gaussianBlur = gaussianBlur; exports.flattenLayers = flattenLayers; exports.findLayer = findLayer; exports.mapLayer = mapLayer; exports.insertLayer = insertLayer; exports.isLayerLocked = isLayerLocked; exports.PatternTile = PatternTile; exports.PatternPlacement = PatternPlacement; exports.builtinPatternIds = builtinPatternIds; exports.builtinPattern = builtinPattern; exports.hashNoise = hashNoise; exports.CURVE_LUT_SIZE = CURVE_LUT_SIZE; exports.curveLut = curveLut; exports.STROKE_CHAMFER_MAX = STROKE_CHAMFER_MAX; exports.contourLut = contourLut; exports.activeEffectItems = activeEffectItems; exports.effectsAreLocal = effectsAreLocal; exports.buildEffectMaps = buildEffectMaps; exports.patchEffectMaps = patchEffectMaps; exports.gradientT = gradientT; exports.effectFillColors = effectFillColors; exports.compositeLayerEffects = compositeLayerEffects; exports.renderLayerEffects = renderLayerEffects; exports.blendTile = blendTile; exports.RasterCompositor = RasterCompositor; exports.changedTiles = changedTiles; exports.INTERPOLATIONS = INTERPOLATIONS; exports.isInterpolation = isInterpolation; exports.MAX_TRANSFORM_PIXELS = MAX_TRANSFORM_PIXELS; exports.TransformTooLargeError = TransformTooLargeError; exports.keysWeight = keysWeight; exports.reduceSurface = reduceSurface; exports.transformedBounds = transformedBounds; exports.transformSurface = transformSurface; exports.warpSurface = warpSurface; exports.compositeSurfaceOver = compositeSurfaceOver;
4372
+ //# sourceMappingURL=chunk-PAOWHJ5O.cjs.map