@pixerate/editor 0.225.0 → 0.227.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 (64) hide show
  1. package/dist/animation-editor/index.cjs +66 -66
  2. package/dist/animation-editor/index.js +4 -4
  3. package/dist/{brushstrokeRender-C3UU6GVC.js → brushstrokeRender-MAHOXL7K.js} +2 -2
  4. package/dist/{brushstrokeRender-EAJNE6WP.cjs → brushstrokeRender-WDTKD54B.cjs} +5 -5
  5. package/dist/canvas/index.cjs +15 -15
  6. package/dist/canvas/index.js +2 -2
  7. package/dist/{chunk-WA4IS2EY.js → chunk-4MDWEX44.js} +1 -1
  8. package/dist/{chunk-7AAS3JO6.cjs → chunk-4PA6YS6W.cjs} +14 -14
  9. package/dist/{chunk-RDTCG5MS.js → chunk-56RFHF7O.js} +1 -1
  10. package/dist/{chunk-HKPLKISO.js → chunk-7DZ55AIE.js} +10 -5
  11. package/dist/{chunk-NTWR5TQB.cjs → chunk-ABQ2VGUB.cjs} +10 -5
  12. package/dist/{chunk-LCCMOWR7.cjs → chunk-ATKKG76G.cjs} +23 -23
  13. package/dist/{chunk-QAUIZPYI.cjs → chunk-BQE3Y6ZO.cjs} +2 -2
  14. package/dist/{chunk-MDNYYOBZ.cjs → chunk-C6CMQXMI.cjs} +7 -7
  15. package/dist/{chunk-G4E6RUPC.js → chunk-CDP2AKMA.js} +1 -1
  16. package/dist/{chunk-NDMXB4PR.js → chunk-CU6ANS5L.js} +1 -1
  17. package/dist/{chunk-ROVK6AXX.cjs → chunk-GNZI3KYK.cjs} +95 -23
  18. package/dist/{chunk-I7G3RSUJ.cjs → chunk-GXLZZVR5.cjs} +35 -35
  19. package/dist/{chunk-S6KKLFZO.js → chunk-KN3Y3FRY.js} +19 -4
  20. package/dist/{chunk-R35YOUP2.cjs → chunk-MXJP77K4.cjs} +104 -89
  21. package/dist/{chunk-F7YA3MMC.js → chunk-TQOL6CF7.js} +76 -4
  22. package/dist/{chunk-ZMHPQ6HP.cjs → chunk-V3L7U63N.cjs} +1 -1
  23. package/dist/{chunk-DJBYJOHM.js → chunk-XSVUNSDJ.js} +1 -1
  24. package/dist/{chunk-BGOCAUXH.js → chunk-YMREOA67.js} +1 -1
  25. package/dist/effects/index.cjs +44 -44
  26. package/dist/effects/index.js +2 -2
  27. package/dist/effects/tools.d.cts +6 -0
  28. package/dist/effects/tools.d.ts +6 -0
  29. package/dist/image-editor/controller.d.cts +12 -4
  30. package/dist/image-editor/controller.d.ts +12 -4
  31. package/dist/image-editor/index.cjs +944 -922
  32. package/dist/image-editor/index.js +49 -27
  33. package/dist/image-editor/layers/model.d.cts +6 -0
  34. package/dist/image-editor/layers/model.d.ts +6 -0
  35. package/dist/paint-editor/controller.d.cts +54 -3
  36. package/dist/paint-editor/controller.d.ts +54 -3
  37. package/dist/paint-editor/dab-stroke.d.cts +3 -0
  38. package/dist/paint-editor/dab-stroke.d.ts +3 -0
  39. package/dist/paint-editor/effect-paint.d.cts +47 -0
  40. package/dist/paint-editor/effect-paint.d.ts +47 -0
  41. package/dist/paint-editor/effect-tools.d.cts +4 -2
  42. package/dist/paint-editor/effect-tools.d.ts +4 -2
  43. package/dist/paint-editor/effects.d.cts +3 -0
  44. package/dist/paint-editor/effects.d.ts +3 -0
  45. package/dist/paint-editor/engine.d.cts +4 -0
  46. package/dist/paint-editor/engine.d.ts +4 -0
  47. package/dist/paint-editor/index.cjs +542 -315
  48. package/dist/paint-editor/index.d.cts +1 -0
  49. package/dist/paint-editor/index.d.ts +1 -0
  50. package/dist/paint-editor/index.js +252 -25
  51. package/dist/paint-editor/procedural.d.cts +4 -0
  52. package/dist/paint-editor/procedural.d.ts +4 -0
  53. package/dist/paint-editor/stroke.d.cts +9 -0
  54. package/dist/paint-editor/stroke.d.ts +9 -0
  55. package/dist/paint-editor/strokes.d.cts +6 -2
  56. package/dist/paint-editor/strokes.d.ts +6 -2
  57. package/dist/vector/index.cjs +968 -968
  58. package/dist/vector/index.js +5 -5
  59. package/dist/video-editor/index.cjs +309 -309
  60. package/dist/video-editor/index.js +3 -3
  61. package/package.json +1 -1
  62. package/skills/pixerate-canvas/SKILL.md +2 -1
  63. package/skills/pixerate-paint-editor/SKILL.md +42 -6
  64. package/skills/pixerate-paint-sketch-to-finish/SKILL.md +7 -0
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- var _chunkQAUIZPYIcjs = require('./chunk-QAUIZPYI.cjs');
21
+ var _chunkBQE3Y6ZOcjs = require('./chunk-BQE3Y6ZO.cjs');
22
22
 
23
23
 
24
24
 
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
37
37
  var toP = (v) => [v.x, v.y];
38
38
  var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
39
39
  var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
40
- function subpathToMorphContour(sp, m = _chunkQAUIZPYIcjs.IDENTITY_MATRIX) {
40
+ function subpathToMorphContour(sp, m = _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX) {
41
41
  const n = sp.anchors.length;
42
42
  if (!n) return null;
43
43
  const first = mapP(m, toP(sp.anchors[0]));
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
67
67
  const u2 = along(p2);
68
68
  return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
69
69
  }
70
- function morphContourToSubpath(c, m = _chunkQAUIZPYIcjs.IDENTITY_MATRIX, closed = c.closed) {
71
- const pts = _chunkQAUIZPYIcjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
70
+ function morphContourToSubpath(c, m = _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX, closed = c.closed) {
71
+ const pts = _chunkBQE3Y6ZOcjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
72
72
  const curves = curvesOf(c);
73
73
  const dropLast = closed && c.closed && curves > 0;
74
74
  const count = dropLast ? curves : curves + 1;
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkQAUIZPYIcjs.IDENTITY_MATRIX, closed
84
84
  anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
85
85
  }
86
86
  for (const a of anchors) {
87
- const type = _chunkQAUIZPYIcjs.inferAnchorType.call(void 0, a);
87
+ const type = _chunkBQE3Y6ZOcjs.inferAnchorType.call(void 0, a);
88
88
  if (type !== "corner") a.type = type;
89
89
  }
90
90
  const isClosed = closed && curves > 0;
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
267
267
  return best;
268
268
  }
269
269
  function placeIn(c, from, to) {
270
- const b = _chunkQAUIZPYIcjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
270
+ const b = _chunkBQE3Y6ZOcjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
271
271
  const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
272
272
  if (!from || !to) return p;
273
273
  const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
456
456
  }
457
457
  function resampleGradientStops(g, offsets) {
458
458
  return offsets.map((offset) => {
459
- const s = _chunkQAUIZPYIcjs.sampleVectorGradient.call(void 0, g, offset);
459
+ const s = _chunkBQE3Y6ZOcjs.sampleVectorGradient.call(void 0, g, offset);
460
460
  return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
461
461
  });
462
462
  }
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
467
467
  var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
468
468
  var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
469
469
  function lerpStops(a, b, t) {
470
- let stopsA = _chunkQAUIZPYIcjs.sortedVectorGradientStops.call(void 0, a);
471
- let stopsB = _chunkQAUIZPYIcjs.sortedVectorGradientStops.call(void 0, b);
470
+ let stopsA = _chunkBQE3Y6ZOcjs.sortedVectorGradientStops.call(void 0, a);
471
+ let stopsB = _chunkBQE3Y6ZOcjs.sortedVectorGradientStops.call(void 0, b);
472
472
  const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
473
473
  if (resampled) {
474
- const offs = [..._chunkQAUIZPYIcjs.expandVectorGradientStops.call(void 0, a), ..._chunkQAUIZPYIcjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
474
+ const offs = [..._chunkBQE3Y6ZOcjs.expandVectorGradientStops.call(void 0, a), ..._chunkBQE3Y6ZOcjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
475
475
  const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
476
476
  stopsA = resampleGradientStops(a, common);
477
477
  stopsB = resampleGradientStops(b, common);
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
498
498
  }
499
499
  if (near.spread && near.spread !== "pad") out.spread = near.spread;
500
500
  if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
501
- const ea = _chunkQAUIZPYIcjs.hasExplicitGradientGeometry.call(void 0, a);
502
- const eb = _chunkQAUIZPYIcjs.hasExplicitGradientGeometry.call(void 0, b);
501
+ const ea = _chunkBQE3Y6ZOcjs.hasExplicitGradientGeometry.call(void 0, a);
502
+ const eb = _chunkBQE3Y6ZOcjs.hasExplicitGradientGeometry.call(void 0, b);
503
503
  if (!ea && !eb) {
504
504
  if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
505
505
  const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
512
512
  }
513
513
  return out;
514
514
  }
515
- const pa = _chunkQAUIZPYIcjs.vectorGradientPoints.call(void 0, a);
516
- const pb = _chunkQAUIZPYIcjs.vectorGradientPoints.call(void 0, b);
515
+ const pa = _chunkBQE3Y6ZOcjs.vectorGradientPoints.call(void 0, a);
516
+ const pb = _chunkBQE3Y6ZOcjs.vectorGradientPoints.call(void 0, b);
517
517
  if (pa.units !== pb.units) {
518
- const src = _chunkQAUIZPYIcjs.explicitVectorGradient.call(void 0, near);
518
+ const src = _chunkBQE3Y6ZOcjs.explicitVectorGradient.call(void 0, near);
519
519
  return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
520
520
  }
521
521
  out.start = lerpPoint(pa.start, pb.start, t);
@@ -535,14 +535,14 @@ function solidLike(color, like) {
535
535
  function interpolateVectorPaint(a, b, t) {
536
536
  if (t <= 0) return a;
537
537
  if (t >= 1) return b;
538
- const pa = _chunkQAUIZPYIcjs.hasPaint.call(void 0, a);
539
- const pb = _chunkQAUIZPYIcjs.hasPaint.call(void 0, b);
538
+ const pa = _chunkBQE3Y6ZOcjs.hasPaint.call(void 0, a);
539
+ const pb = _chunkBQE3Y6ZOcjs.hasPaint.call(void 0, b);
540
540
  if (!pa && !pb) return t < 0.5 ? a : b;
541
541
  if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
542
542
  if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
543
543
  if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
544
- const ga = pa && _chunkQAUIZPYIcjs.isVectorGradient.call(void 0, a) ? a : null;
545
- const gb = pb && _chunkQAUIZPYIcjs.isVectorGradient.call(void 0, b) ? b : null;
544
+ const ga = pa && _chunkBQE3Y6ZOcjs.isVectorGradient.call(void 0, a) ? a : null;
545
+ const gb = pb && _chunkBQE3Y6ZOcjs.isVectorGradient.call(void 0, b) ? b : null;
546
546
  if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
547
547
  if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
548
548
  if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
553
553
  const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
554
554
  const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
555
555
  return ts.map((pos) => {
556
- const x = _chunkQAUIZPYIcjs.widthProfileAt.call(void 0, a, pos);
557
- const y = _chunkQAUIZPYIcjs.widthProfileAt.call(void 0, b, pos);
556
+ const x = _chunkBQE3Y6ZOcjs.widthProfileAt.call(void 0, a, pos);
557
+ const y = _chunkBQE3Y6ZOcjs.widthProfileAt.call(void 0, b, pos);
558
558
  return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
559
559
  });
560
560
  }
@@ -597,7 +597,7 @@ function reversedStyle(s) {
597
597
  out.endArrow = s.startArrow;
598
598
  out.startArrowScale = s.endArrowScale;
599
599
  out.endArrowScale = s.startArrowScale;
600
- if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkQAUIZPYIcjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
600
+ if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkBQE3Y6ZOcjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
601
601
  for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
602
602
  return out;
603
603
  }
@@ -623,19 +623,19 @@ function styleOf(n) {
623
623
  return out;
624
624
  }
625
625
  function contoursOf(node, m) {
626
- return _chunkQAUIZPYIcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
626
+ return _chunkBQE3Y6ZOcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
627
627
  }
628
- function preparePathMorph(a, b, options, ma = _chunkQAUIZPYIcjs.nodeMatrix.call(void 0, a), mb = _chunkQAUIZPYIcjs.nodeMatrix.call(void 0, b)) {
628
+ function preparePathMorph(a, b, options, ma = _chunkBQE3Y6ZOcjs.nodeMatrix.call(void 0, a), mb = _chunkBQE3Y6ZOcjs.nodeMatrix.call(void 0, b)) {
629
629
  const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
630
630
  const sim = procrustes(corr.a, corr.b);
631
631
  const styleA = styleOf(a);
632
632
  const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
633
- const rigid = !_chunkQAUIZPYIcjs.isIdentityMatrix.call(void 0, ma) || !_chunkQAUIZPYIcjs.isIdentityMatrix.call(void 0, mb);
633
+ const rigid = !_chunkBQE3Y6ZOcjs.isIdentityMatrix.call(void 0, ma) || !_chunkBQE3Y6ZOcjs.isIdentityMatrix.call(void 0, mb);
634
634
  const id = _nullishCoalesce(options.id, () => ( a.id));
635
635
  return (t) => {
636
636
  const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
637
- const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkQAUIZPYIcjs.IDENTITY_MATRIX;
638
- const back = rigid ? _chunkQAUIZPYIcjs.invertMatrix.call(void 0, m) : _chunkQAUIZPYIcjs.IDENTITY_MATRIX;
637
+ const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX;
638
+ const back = rigid ? _chunkBQE3Y6ZOcjs.invertMatrix.call(void 0, m) : _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX;
639
639
  const subpaths = contours.map((c, k) => {
640
640
  const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
641
641
  return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkQAUIZPYIcjs.nodeMatrix.call(
643
643
  const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
644
644
  const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
645
645
  if (opacity < 1) node.opacity = opacity;
646
- if (rigid && !_chunkQAUIZPYIcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
646
+ if (rigid && !_chunkBQE3Y6ZOcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
647
647
  return node;
648
648
  };
649
649
  }
650
- function flattenPaths(node, parent = _chunkQAUIZPYIcjs.IDENTITY_MATRIX) {
651
- const m = _chunkQAUIZPYIcjs.multiplyMatrices.call(void 0, _chunkQAUIZPYIcjs.nodeMatrix.call(void 0, node), parent);
650
+ function flattenPaths(node, parent = _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX) {
651
+ const m = _chunkBQE3Y6ZOcjs.multiplyMatrices.call(void 0, _chunkBQE3Y6ZOcjs.nodeMatrix.call(void 0, node), parent);
652
652
  if (node.type === "path") return [{ path: node, m, opacity: 1 }];
653
- if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkQAUIZPYIcjs.expandVectorAppearance.call(void 0, node), parent);
653
+ if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkBQE3Y6ZOcjs.expandVectorAppearance.call(void 0, node), parent);
654
654
  const o = _nullishCoalesce(node.opacity, () => ( 1));
655
655
  return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
656
656
  }
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
672
672
  }
673
673
  const pa = flattenPaths(a);
674
674
  const pb = flattenPaths(b);
675
- const ba = _chunkQAUIZPYIcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
676
- const bb = _chunkQAUIZPYIcjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
675
+ const ba = _chunkBQE3Y6ZOcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
676
+ const bb = _chunkBQE3Y6ZOcjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
677
677
  const id = _nullishCoalesce(options.id, () => ( a.id));
678
678
  const parts = [];
679
679
  const opacities = [];
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
685
685
  parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
686
686
  opacities.push([x.opacity, y.opacity]);
687
687
  } else if (x) {
688
- parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkQAUIZPYIcjs.IDENTITY_MATRIX));
688
+ parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX));
689
689
  opacities.push([x.opacity, x.opacity]);
690
690
  } else if (y) {
691
- parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkQAUIZPYIcjs.IDENTITY_MATRIX, y.m));
691
+ parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkBQE3Y6ZOcjs.IDENTITY_MATRIX, y.m));
692
692
  opacities.push([y.opacity, y.opacity]);
693
693
  }
694
694
  }
@@ -104,7 +104,7 @@ import {
104
104
  transformTextRect,
105
105
  translateMatrix,
106
106
  warpPresetMesh
107
- } from "./chunk-NDMXB4PR.js";
107
+ } from "./chunk-CU6ANS5L.js";
108
108
  import {
109
109
  bezierPathBounds,
110
110
  outlineStroke,
@@ -4894,13 +4894,14 @@ function applySmartFilters(placed, stack, canvas) {
4894
4894
  let out2;
4895
4895
  if (f.kind === "effect") {
4896
4896
  if (incomplete) continue;
4897
- const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => ({ ...x, id: void 0, blend: x === f ? void 0 : x.blend, opacity: x === f ? void 0 : x.opacity }))]);
4897
+ const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => x === f ? { ...x, id: void 0, blend: void 0, opacity: void 0, preserveTransparency: void 0 } : { ...x, id: void 0 })]);
4898
4898
  const r = canvas.effects?.resolve(f, acc, W, H, inputKey);
4899
4899
  if (!r?.result) {
4900
4900
  if (r?.pending) incomplete = true;
4901
4901
  continue;
4902
4902
  }
4903
4903
  out2 = new Uint8ClampedArray(r.result);
4904
+ if (f.preserveTransparency) keepAlphaOf(out2, acc);
4904
4905
  } else {
4905
4906
  out2 = new Uint8ClampedArray(acc);
4906
4907
  runLayerFilters(out2, W, H, [f]);
@@ -4925,6 +4926,18 @@ function applySmartFilters(placed, stack, canvas) {
4925
4926
  if (incomplete) incompleteSurfaces.add(out);
4926
4927
  return out;
4927
4928
  }
4929
+ function keepAlphaOf(result, input) {
4930
+ for (let i = 0; i < result.length; i += 4) {
4931
+ const ia = input[i + 3];
4932
+ const ta = result[i + 3] / 255;
4933
+ if (ta < 1) {
4934
+ const ba = ia / 255;
4935
+ const a = ta + ba * (1 - ta);
4936
+ for (let c = 0; c < 3; c++) result[i + c] = a > 0 ? (result[i + c] * ta + input[i + c] * ba * (1 - ta)) / a : 0;
4937
+ }
4938
+ result[i + 3] = ia;
4939
+ }
4940
+ }
4928
4941
  function lerpInto(dst, src, k, coverage) {
4929
4942
  for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
4930
4943
  const t = coverage ? k * coverage[p] : k;
@@ -5269,6 +5282,7 @@ function normalizeEffectSmartFilter(raw, id) {
5269
5282
  if (typeof raw.effect !== "string" || !raw.effect) fail4('An effect smart filter needs an "effect" id from search_effects.');
5270
5283
  const values = raw.values ?? {};
5271
5284
  if (typeof values !== "object" || values === null || Array.isArray(values)) fail4('"values" must be an object of control values.');
5285
+ if (raw.preserveTransparency !== void 0 && typeof raw.preserveTransparency !== "boolean") fail4('"preserveTransparency" must be true or false.');
5272
5286
  return {
5273
5287
  id,
5274
5288
  kind: "effect",
@@ -5276,7 +5290,8 @@ function normalizeEffectSmartFilter(raw, id) {
5276
5290
  effect: raw.effect,
5277
5291
  ...typeof raw.provider === "string" ? { provider: raw.provider } : {},
5278
5292
  ...typeof raw.name === "string" ? { name: raw.name } : {},
5279
- values: { ...values }
5293
+ values: { ...values },
5294
+ ...typeof raw.preserveTransparency === "boolean" ? { preserveTransparency: raw.preserveTransparency } : {}
5280
5295
  };
5281
5296
  }
5282
5297
  function withStack(layer, stack, canvas) {
@@ -6097,7 +6112,7 @@ function readSmartFilters(raw, ctx, what) {
6097
6112
  if (base) filters.push({ ...base, blend, opacity });
6098
6113
  } else if (f.kind === "effect") {
6099
6114
  const ref = readEffectRef(f);
6100
- if (ref) filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "effect", enabled: f.enabled !== false, ...ref, blend, opacity });
6115
+ if (ref) filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "effect", enabled: f.enabled !== false, ...ref, ...typeof f.preserveTransparency === "boolean" ? { preserveTransparency: f.preserveTransparency } : {}, blend, opacity });
6101
6116
  else ctx.problems.push(`${what}: an effect smart filter without an effect id was left out`);
6102
6117
  }
6103
6118
  }