@snowcone-app/canvas 0.1.9 → 0.1.10

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 (38) hide show
  1. package/dist/{CanvasStateV1-D5GzvmnY.cjs → CanvasStateV1-BmE5V6me.cjs} +2 -2
  2. package/dist/{CanvasStateV1-D5GzvmnY.cjs.map → CanvasStateV1-BmE5V6me.cjs.map} +1 -1
  3. package/dist/{CanvasStateV1-ejb4d_LM.js → CanvasStateV1-CD3Q94F4.js} +2 -2
  4. package/dist/{CanvasStateV1-ejb4d_LM.js.map → CanvasStateV1-CD3Q94F4.js.map} +1 -1
  5. package/dist/{ElementFactory-uJTXU-nP.js → ElementFactory-Ckv6sSev.js} +698 -696
  6. package/dist/ElementFactory-Ckv6sSev.js.map +1 -0
  7. package/dist/{ElementFactory-B7UOaJSD.cjs → ElementFactory-DEjwp-Wg.cjs} +5 -5
  8. package/dist/ElementFactory-DEjwp-Wg.cjs.map +1 -0
  9. package/dist/{ImportManager-CxiaRg1N.js → ImportManager-64OYjELO.js} +2 -2
  10. package/dist/{ImportManager-CxiaRg1N.js.map → ImportManager-64OYjELO.js.map} +1 -1
  11. package/dist/{ImportManager-BYwuK6n4.cjs → ImportManager-wSzrR-5a.cjs} +2 -2
  12. package/dist/{ImportManager-BYwuK6n4.cjs.map → ImportManager-wSzrR-5a.cjs.map} +1 -1
  13. package/dist/advanced.js +14 -14
  14. package/dist/advanced.js.map +1 -1
  15. package/dist/advanced.mjs +1847 -1854
  16. package/dist/advanced.mjs.map +1 -1
  17. package/dist/{compose-Bo108juW.cjs → compose-DHBRwi_A.cjs} +5 -5
  18. package/dist/compose-DHBRwi_A.cjs.map +1 -0
  19. package/dist/{compose-DQ1FZS3O.js → compose-DIPiisIw.js} +355 -355
  20. package/dist/compose-DIPiisIw.js.map +1 -0
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +44 -45
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/internals.js +1 -1
  26. package/dist/internals.mjs +3 -3
  27. package/package.json +2 -2
  28. package/dist/ElementFactory-B7UOaJSD.cjs.map +0 -1
  29. package/dist/ElementFactory-uJTXU-nP.js.map +0 -1
  30. package/dist/components/stories/utils/MockEditorProvider.d.ts +0 -32
  31. package/dist/components/stories/utils/QACanvasCard.d.ts +0 -41
  32. package/dist/components/stories/utils/VisualQACard.d.ts +0 -24
  33. package/dist/components/stories/utils/element-factories.d.ts +0 -188
  34. package/dist/components/stories/utils/spec-to-elements.d.ts +0 -74
  35. package/dist/components/stories/utils/themeDecorator.d.ts +0 -45
  36. package/dist/components/stories/utils/unified-test-cases.d.ts +0 -27
  37. package/dist/compose-Bo108juW.cjs.map +0 -1
  38. package/dist/compose-DQ1FZS3O.js.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { A as ft, D as mt, r as ht, v as gt, u as pt, a as bt, S as vt, K as xt, C as Oe, e as wt } from "./compose-DQ1FZS3O.js";
2
- import { b as br, c as vr, E as xr, M as wr, P as Er, d as yr, f as Ar, g as Sr } from "./compose-DQ1FZS3O.js";
1
+ import { A as ft, D as mt, r as ht, v as gt, u as pt, a as bt, S as vt, K as xt, C as Oe, e as wt } from "./compose-DIPiisIw.js";
2
+ import { b as br, c as vr, E as xr, M as wr, P as Er, d as yr, f as Ar, g as Sr } from "./compose-DIPiisIw.js";
3
3
  import { c as _, s as Et, I as Ke, p as yt, T as At } from "./HybridHistoryManager-BV6XV0nD.js";
4
4
  import { jsxs as de, jsx as C } from "react/jsx-runtime";
5
5
  import { Component as St, useRef as T, useState as q, useEffect as R, useCallback as N, forwardRef as je, useMemo as ye, useImperativeHandle as Rt } from "react";
6
6
  import { u as ue, T as Xe, E as It, a as Ae, b as Ge, c as kt } from "./ThemeContext-H0Z-MqqR.js";
7
- import { C as we, E as Ct } from "./ElementFactory-uJTXU-nP.js";
8
- import { d as Ir, m as kr, s as Cr, v as Mr } from "./CanvasStateV1-ejb4d_LM.js";
7
+ import { C as we, E as Ct } from "./ElementFactory-Ckv6sSev.js";
8
+ import { d as Ir, m as kr, s as Cr, v as Mr } from "./CanvasStateV1-CD3Q94F4.js";
9
9
  const Mt = _("ErrorBoundary");
10
10
  class Tt extends St {
11
11
  constructor(e) {
@@ -89,12 +89,12 @@ class Tt extends St {
89
89
  }
90
90
  const Dt = _("useAutoExport");
91
91
  function Ft(t) {
92
- const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l = T(null), p = T(!1), A = T({
92
+ const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l = T(null), p = T(!1), S = T({
93
93
  totalExports: 0,
94
94
  skippedExports: 0,
95
95
  lastExportTime: null,
96
96
  avgExportInterval: 0
97
- }), [P, I] = q(A.current), E = T(c);
97
+ }), [P, I] = q(S.current), E = T(c);
98
98
  E.current = c, R(() => {
99
99
  const m = new ft({
100
100
  ...mt,
@@ -102,9 +102,9 @@ function Ft(t) {
102
102
  });
103
103
  return m.onExport(async () => {
104
104
  try {
105
- await E.current(), A.current = m.getStats();
106
- } catch (S) {
107
- Dt.error("[useAutoExport] Export failed:", S);
105
+ await E.current(), S.current = m.getStats();
106
+ } catch (A) {
107
+ Dt.error("[useAutoExport] Export failed:", A);
108
108
  }
109
109
  }), l.current = m, () => {
110
110
  m.destroy();
@@ -138,16 +138,16 @@ function Ft(t) {
138
138
  }
139
139
  l.current.scheduleExport();
140
140
  }
141
- }, [n, a, i]), R(() => Et((S) => {
141
+ }, [n, a, i]), R(() => Et((A) => {
142
142
  if (!l.current || !i) return;
143
- n.some((W) => W.id === S) && l.current.scheduleExport();
143
+ n.some((W) => W.id === A) && l.current.scheduleExport();
144
144
  }), [n, i]);
145
145
  const M = N((m) => {
146
146
  l.current && l.current.updateConfig(m);
147
147
  }, []), w = N(async () => {
148
- l.current && (await l.current.forceExport(), A.current = l.current.getStats(), I(A.current));
148
+ l.current && (await l.current.forceExport(), S.current = l.current.getStats(), I(S.current));
149
149
  }, []), H = N(() => {
150
- l.current && (l.current.resetStats(), A.current = l.current.getStats(), I(A.current));
150
+ l.current && (l.current.resetStats(), S.current = l.current.getStats(), I(S.current));
151
151
  }, []), y = N(() => {
152
152
  l.current && l.current.resetChangeDetection();
153
153
  }, []);
@@ -237,19 +237,19 @@ function Bt(t) {
237
237
  return t && Nt[t] || "c";
238
238
  }
239
239
  function Ut(t, e) {
240
- const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c, p = i / t.width, A = l / t.height, P = r === "contain" ? Math.min(p, A) : Math.max(p, A), I = e.scale || 1, E = P * I, M = t.width * E, w = t.height * E, H = e.align || "c";
240
+ const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c, p = i / t.width, S = l / t.height, P = r === "contain" ? Math.min(p, S) : Math.max(p, S), I = e.scale || 1, E = P * I, M = t.width * E, w = t.height * E, H = e.align || "c";
241
241
  let y = 0, m = 0;
242
- const S = M - i, v = w - l;
242
+ const A = M - i, v = w - l;
243
243
  switch (H) {
244
244
  // Top row
245
245
  case "tl":
246
246
  y = 0, m = 0;
247
247
  break;
248
248
  case "t":
249
- y = -S / 2, m = 0;
249
+ y = -A / 2, m = 0;
250
250
  break;
251
251
  case "tr":
252
- y = -S, m = 0;
252
+ y = -A, m = 0;
253
253
  break;
254
254
  // Middle row
255
255
  case "l":
@@ -258,24 +258,24 @@ function Ut(t, e) {
258
258
  case "c":
259
259
  // Center (default)
260
260
  default:
261
- y = -S / 2, m = -v / 2;
261
+ y = -A / 2, m = -v / 2;
262
262
  break;
263
263
  case "r":
264
- y = -S, m = -v / 2;
264
+ y = -A, m = -v / 2;
265
265
  break;
266
266
  // Bottom row
267
267
  case "bl":
268
268
  y = 0, m = -v;
269
269
  break;
270
270
  case "b":
271
- y = -S / 2, m = -v;
271
+ y = -A / 2, m = -v;
272
272
  break;
273
273
  case "br":
274
- y = -S, m = -v;
274
+ y = -A, m = -v;
275
275
  break;
276
276
  }
277
277
  y += o, m += a;
278
- const W = e.offsetX || 0, D = e.offsetY || 0, $ = S, ee = v;
278
+ const W = e.offsetX || 0, D = e.offsetY || 0, $ = A, ee = v;
279
279
  return y += W * $, m += D * ee, y = Math.round(y), m = Math.round(m), {
280
280
  // Final scale to apply to artwork
281
281
  scale: E,
@@ -289,7 +289,7 @@ function Ut(t, e) {
289
289
  debug: {
290
290
  coverScale: P,
291
291
  userScale: I,
292
- overflow: { x: S, y: v },
292
+ overflow: { x: A, y: v },
293
293
  alignment: H,
294
294
  appliedOffset: { x: W * $, y: D * ee }
295
295
  }
@@ -338,13 +338,13 @@ function Ot(t, e) {
338
338
  }, i = () => {
339
339
  if (c) return;
340
340
  c = !0, o();
341
- const p = a.naturalWidth || a.width, A = a.naturalHeight || a.height;
341
+ const p = a.naturalWidth || a.width, S = a.naturalHeight || a.height;
342
342
  r({
343
343
  success: !0,
344
344
  element: a,
345
345
  width: p,
346
- height: A,
347
- aspectRatio: A > 0 ? p / A : 1
346
+ height: S,
347
+ aspectRatio: S > 0 ? p / S : 1
348
348
  });
349
349
  }, l = (p) => {
350
350
  c || (c = !0, o(), r({
@@ -382,13 +382,13 @@ async function Xt(t, e, r = {}, a = {}) {
382
382
  }, o = Ut(
383
383
  { width: n.width, height: n.height },
384
384
  c
385
- ), i = e.artboard.x + o.x, l = e.artboard.y + o.y, p = i + o.width / 2, A = l + o.height / 2;
385
+ ), i = e.artboard.x + o.x, l = e.artboard.y + o.y, p = i + o.width / 2, S = l + o.height / 2;
386
386
  return {
387
387
  success: !0,
388
388
  element: new Ke({
389
389
  ...r,
390
390
  x: p,
391
- y: A,
391
+ y: S,
392
392
  imageUrl: t,
393
393
  imageAspectRatio: n.aspectRatio,
394
394
  preserveDimensions: !0,
@@ -409,7 +409,7 @@ async function Xt(t, e, r = {}, a = {}) {
409
409
  placement: {
410
410
  artworkSize: { width: n.width, height: n.height },
411
411
  finalSize: { width: o.width, height: o.height },
412
- position: { x: p, y: A },
412
+ position: { x: p, y: S },
413
413
  scale: o.scale
414
414
  }
415
415
  };
@@ -437,7 +437,7 @@ const Je = je((t, e) => {
437
437
  activeArtboard: i,
438
438
  onArtboardChange: l,
439
439
  initialElements: p,
440
- onChange: A,
440
+ onChange: S,
441
441
  onSelectionChange: P,
442
442
  autoExportInterval: I,
443
443
  onExport: E,
@@ -446,7 +446,7 @@ const Je = je((t, e) => {
446
446
  onExportReady: H,
447
447
  onImageLoad: y,
448
448
  onImageError: m,
449
- onError: S,
449
+ onError: A,
450
450
  onReady: v,
451
451
  className: W,
452
452
  style: D,
@@ -459,8 +459,8 @@ const Je = je((t, e) => {
459
459
  s.valid || K.warn("Kit validation warnings:", s.errors), s.warnings.length > 0 && K.warn("Kit validation warnings:", s.warnings);
460
460
  }
461
461
  }, [ne]);
462
- const ae = T(S);
463
- ae.current = S;
462
+ const ae = T(A);
463
+ ae.current = A;
464
464
  const B = N((s) => {
465
465
  var d;
466
466
  K.error(`[${s.category}] ${s.message}`, s.originalError), (d = ae.current) == null || d.call(ae, s);
@@ -663,7 +663,7 @@ const Je = je((t, e) => {
663
663
  }, [z, Re, Ie, ke]), R(() => {
664
664
  P == null || P(Be);
665
665
  }, [Be, P]), R(() => {
666
- if (!A) return;
666
+ if (!S) return;
667
667
  const s = k.getActiveArtboard(), d = {
668
668
  elements: V.map((h) => h.toJSON()),
669
669
  artboards: L.map((h) => ({
@@ -675,8 +675,8 @@ const Je = je((t, e) => {
675
675
  })),
676
676
  activeArtboard: (s == null ? void 0 : s.name) || "Design"
677
677
  };
678
- A(d);
679
- }, [V, L, A]), R(() => {
678
+ S(d);
679
+ }, [V, L, S]), R(() => {
680
680
  if (!l || !ve.current) return;
681
681
  const s = k.getActiveArtboard();
682
682
  s && l(s.name);
@@ -926,7 +926,7 @@ function ir() {
926
926
  executeRemoveElement: i,
927
927
  executeReorderElement: l,
928
928
  executeCommandBatch: p,
929
- executeCreateArtboard: A,
929
+ executeCreateArtboard: S,
930
930
  executeDeleteArtboard: P,
931
931
  executeUpdateArtboard: I
932
932
  } = t, E = N(() => {
@@ -948,7 +948,7 @@ function ir() {
948
948
  executeAddElement: o,
949
949
  executeRemoveElement: i,
950
950
  executeReorderElement: l,
951
- executeCreateArtboard: A,
951
+ executeCreateArtboard: S,
952
952
  executeDeleteArtboard: P,
953
953
  executeUpdateArtboard: I,
954
954
  // Batch execution
@@ -1023,23 +1023,22 @@ function ur(t, e) {
1023
1023
  l.current = o;
1024
1024
  const p = T(c);
1025
1025
  p.current = c;
1026
- const A = T(n);
1027
- A.current = n;
1026
+ const S = T(n);
1027
+ S.current = n;
1028
1028
  const P = N(
1029
1029
  (I) => {
1030
1030
  const E = l.current, M = p.current;
1031
- A.current;
1032
1031
  for (const w of E) {
1033
1032
  const H = i.current.get(w.id);
1034
1033
  if (!H) continue;
1035
- const { width: y, height: m } = H, S = w.clone();
1036
- S.imageLoaded = !1, S.imageElement = null, S.isCropping = !1, S.imageUrl = I, r === "cover" ? (S.preserveDimensions = !0, S.onLoadCallback = (v) => {
1034
+ const { width: y, height: m } = H, A = w.clone();
1035
+ A.imageLoaded = !1, A.imageElement = null, A.isCropping = !1, A.imageUrl = I, r === "cover" ? (A.preserveDimensions = !0, A.onLoadCallback = (v) => {
1037
1036
  const W = v.imageAspectRatio || 1, D = Zt(y, m, W);
1038
1037
  v.transformData.width = D.width, v.transformData.height = D.height, v.transformData.cropX = D.cropX, v.transformData.cropY = D.cropY, v.transformData.cropWidth = D.cropWidth, v.transformData.cropHeight = D.cropHeight, M(w, v);
1039
- }) : (S.preserveDimensions = !1, S.onLoadCallback = (v) => {
1038
+ }) : (A.preserveDimensions = !1, A.onLoadCallback = (v) => {
1040
1039
  const W = v.transformData.width, D = v.transformData.height, $ = Math.min(y / W, m / D, 1);
1041
1040
  $ < 1 && (v.transformData.width = W * $, v.transformData.height = D * $), v.transformData.cropX = 0, v.transformData.cropY = 0, v.transformData.cropWidth = 1, v.transformData.cropHeight = 1, M(w, v);
1042
- }), S.loadImage(I);
1041
+ }), A.loadImage(I);
1043
1042
  }
1044
1043
  },
1045
1044
  [r]