@snowcone-app/canvas 0.1.3 → 0.1.5
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.
- package/README.md +101 -326
- package/dist/api/stable.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -89
- package/dist/index.mjs.map +1 -1
- package/dist/rendering/serialize-for-server.d.ts +13 -0
- package/package.json +9 -4
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
|
|
2
|
-
import { b as
|
|
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";
|
|
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
|
-
import { Component as St, useRef as T, useState as q, useEffect as R, useCallback as
|
|
6
|
-
import { u as ue, T as
|
|
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
|
+
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
7
|
import { C as we, E as Ct } from "./ElementFactory-uJTXU-nP.js";
|
|
8
|
-
import { d as
|
|
8
|
+
import { d as Ir, m as kr, s as Cr, v as Mr } from "./CanvasStateV1-ejb4d_LM.js";
|
|
9
9
|
const Mt = _("ErrorBoundary");
|
|
10
10
|
class Tt extends St {
|
|
11
11
|
constructor(e) {
|
|
@@ -142,13 +142,13 @@ function Ft(t) {
|
|
|
142
142
|
if (!l.current || !i) return;
|
|
143
143
|
n.some((W) => W.id === S) && l.current.scheduleExport();
|
|
144
144
|
}), [n, i]);
|
|
145
|
-
const M =
|
|
145
|
+
const M = N((m) => {
|
|
146
146
|
l.current && l.current.updateConfig(m);
|
|
147
|
-
}, []), w =
|
|
147
|
+
}, []), w = N(async () => {
|
|
148
148
|
l.current && (await l.current.forceExport(), A.current = l.current.getStats(), I(A.current));
|
|
149
|
-
}, []), H =
|
|
149
|
+
}, []), H = N(() => {
|
|
150
150
|
l.current && (l.current.resetStats(), A.current = l.current.getStats(), I(A.current));
|
|
151
|
-
}, []), y =
|
|
151
|
+
}, []), y = N(() => {
|
|
152
152
|
l.current && l.current.resetChangeDetection();
|
|
153
153
|
}, []);
|
|
154
154
|
return {
|
|
@@ -210,7 +210,7 @@ function Wt(t) {
|
|
|
210
210
|
};
|
|
211
211
|
}, [e, r, a, n, c]), c;
|
|
212
212
|
}
|
|
213
|
-
const
|
|
213
|
+
const Nt = {
|
|
214
214
|
// Vertical alignments (map to top/center/bottom center)
|
|
215
215
|
"far-top": "t",
|
|
216
216
|
top: "t",
|
|
@@ -233,8 +233,8 @@ const Bt = {
|
|
|
233
233
|
b: "b",
|
|
234
234
|
br: "br"
|
|
235
235
|
};
|
|
236
|
-
function
|
|
237
|
-
return t &&
|
|
236
|
+
function Bt(t) {
|
|
237
|
+
return t && Nt[t] || "c";
|
|
238
238
|
}
|
|
239
239
|
function Ut(t, e) {
|
|
240
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";
|
|
@@ -319,7 +319,7 @@ async function $t(t, e = {}) {
|
|
|
319
319
|
let a;
|
|
320
320
|
for (let n = 0; n <= r.retries; n++)
|
|
321
321
|
try {
|
|
322
|
-
return await
|
|
322
|
+
return await Ot(t, r.timeout);
|
|
323
323
|
} catch (c) {
|
|
324
324
|
a = c instanceof Error ? c : new Error(String(c)), n < r.retries && await Vt(r.retryDelay);
|
|
325
325
|
}
|
|
@@ -328,7 +328,7 @@ async function $t(t, e = {}) {
|
|
|
328
328
|
error: a || new Error("Failed to load image after retries")
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Ot(t, e) {
|
|
332
332
|
return new Promise((r) => {
|
|
333
333
|
const a = new Image();
|
|
334
334
|
a.crossOrigin = "anonymous";
|
|
@@ -359,7 +359,7 @@ function Xt(t, e) {
|
|
|
359
359
|
}, e), a.src = t;
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
|
-
async function
|
|
362
|
+
async function Xt(t, e, r = {}, a = {}) {
|
|
363
363
|
var I, E, M, w, H, y, m;
|
|
364
364
|
const n = await $t(t, a);
|
|
365
365
|
if (!n.success || !n.width || !n.height)
|
|
@@ -371,7 +371,7 @@ async function Ot(t, e, r = {}, a = {}) {
|
|
|
371
371
|
width: e.artboard.width,
|
|
372
372
|
height: e.artboard.height,
|
|
373
373
|
scale: e.scale,
|
|
374
|
-
align:
|
|
374
|
+
align: Bt(e.alignment),
|
|
375
375
|
offsetX: e.offsetX,
|
|
376
376
|
offsetY: e.offsetY,
|
|
377
377
|
scaleMode: e.scaleMode,
|
|
@@ -452,7 +452,7 @@ const Je = je((t, e) => {
|
|
|
452
452
|
style: D,
|
|
453
453
|
enableShortcuts: $,
|
|
454
454
|
overlay: ee
|
|
455
|
-
} = t, Se = I, J = t.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), j = t.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", fe = t.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1,
|
|
455
|
+
} = t, Se = I, J = t.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), j = t.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", fe = t.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, X = t.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, U = t.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, te = t.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", re = t.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, z = t.initialImage ?? (a == null ? void 0 : a.src), Re = t.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", Ie = t.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, ke = t.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", Ze = t.width ?? (n == null ? void 0 : n.width) ?? 1200, qe = t.height ?? (n == null ? void 0 : n.height) ?? 1200, Ce = t.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, Me = t.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, Te = t.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), De = t.maxHeight ?? (n == null ? void 0 : n.maxHeight), Fe = t.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, _e = t.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Pe = t.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), He = t.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), Le = t.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), me = t.pieceGuides, We = t.pieceFocus, Ne = $ ?? !0, ne = ye(() => ht(c ?? "pro-studio"), [c]);
|
|
456
456
|
R(() => {
|
|
457
457
|
if (yt.env.NODE_ENV === "development" && ne) {
|
|
458
458
|
const s = gt(ne);
|
|
@@ -461,17 +461,17 @@ const Je = je((t, e) => {
|
|
|
461
461
|
}, [ne]);
|
|
462
462
|
const ae = T(S);
|
|
463
463
|
ae.current = S;
|
|
464
|
-
const
|
|
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);
|
|
467
467
|
}, []);
|
|
468
|
-
R(() => (we.onRenderError =
|
|
469
|
-
we.onRenderError ===
|
|
470
|
-
}), [
|
|
468
|
+
R(() => (we.onRenderError = B, () => {
|
|
469
|
+
we.onRenderError === B && (we.onRenderError = null);
|
|
470
|
+
}), [B]);
|
|
471
471
|
const {
|
|
472
472
|
elements: V,
|
|
473
473
|
setElements: oe,
|
|
474
|
-
selectedId:
|
|
474
|
+
selectedId: Be,
|
|
475
475
|
artboardManager: k,
|
|
476
476
|
refreshArtboards: et,
|
|
477
477
|
historyManager: tt,
|
|
@@ -480,7 +480,7 @@ const Je = je((t, e) => {
|
|
|
480
480
|
} = ue(), { createArtboard: rt, selectArtboard: nt, artboards: L } = pt(), { exportArtboard: G, exportAllArtboards: ie, exportArtboardAsBlob: Q, exportAllArtboardsAsBlobs: ce } = bt();
|
|
481
481
|
Rt(e, () => ({
|
|
482
482
|
exportArtboards: async (s = {}) => {
|
|
483
|
-
const d = s.format || j, h = s.scale ||
|
|
483
|
+
const d = s.format || j, h = s.scale || X, g = s.all ?? !1;
|
|
484
484
|
let f = h;
|
|
485
485
|
if (U > 0 && isFinite(U))
|
|
486
486
|
for (const x of L) {
|
|
@@ -491,8 +491,8 @@ const Je = je((t, e) => {
|
|
|
491
491
|
if (g) {
|
|
492
492
|
const x = d === "blob" ? await ce(u) : await ie(u), b = {};
|
|
493
493
|
for (const [F, Y] of Object.entries(x)) {
|
|
494
|
-
const
|
|
495
|
-
|
|
494
|
+
const O = L.find((Z) => Z.id === F);
|
|
495
|
+
O && (b[O.name] = Y);
|
|
496
496
|
}
|
|
497
497
|
return b;
|
|
498
498
|
} else {
|
|
@@ -508,7 +508,7 @@ const Je = je((t, e) => {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
}), [G, ie, Q, ce, j,
|
|
511
|
+
}), [G, ie, Q, ce, j, X, U, te, re, k, L]), R(() => {
|
|
512
512
|
H && H(async () => {
|
|
513
513
|
const d = k.getActiveArtboard();
|
|
514
514
|
if (!d)
|
|
@@ -516,12 +516,12 @@ const Je = je((t, e) => {
|
|
|
516
516
|
const h = Ee(
|
|
517
517
|
d.width,
|
|
518
518
|
d.height,
|
|
519
|
-
|
|
519
|
+
X,
|
|
520
520
|
U
|
|
521
521
|
), g = j === "blob" ? await Q(d.id, { scale: h }) : await G(d.id, { scale: h });
|
|
522
522
|
return { [d.name]: g };
|
|
523
523
|
});
|
|
524
|
-
}, [H, G, Q, k, j,
|
|
524
|
+
}, [H, G, Q, k, j, X, U]);
|
|
525
525
|
const [Ue, le] = q("idle"), [ze, ge] = q(null), pe = T(void 0), be = T(!1), Ye = T(!1), [at, ot] = q(!1), st = T(0), it = T(0), ve = T(!1);
|
|
526
526
|
R(() => {
|
|
527
527
|
if (be.current) return;
|
|
@@ -587,7 +587,7 @@ const Je = je((t, e) => {
|
|
|
587
587
|
} catch (s) {
|
|
588
588
|
K.error("Failed to load initial elements:", s);
|
|
589
589
|
const d = s instanceof Error ? s : new Error(String(s));
|
|
590
|
-
|
|
590
|
+
B({
|
|
591
591
|
category: "import",
|
|
592
592
|
message: `Failed to load initial elements: ${d.message}`,
|
|
593
593
|
originalError: d,
|
|
@@ -595,7 +595,7 @@ const Je = je((t, e) => {
|
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
|
-
}, [p, k, oe,
|
|
598
|
+
}, [p, k, oe, B]), R(() => {
|
|
599
599
|
if (!i) {
|
|
600
600
|
ve.current = !0;
|
|
601
601
|
return;
|
|
@@ -619,7 +619,7 @@ const Je = je((t, e) => {
|
|
|
619
619
|
throw new Error("No artboards available");
|
|
620
620
|
const h = [];
|
|
621
621
|
for (const g of d) {
|
|
622
|
-
const f = o == null ? void 0 : o.find((b) => b.name === g.name), u = (f == null ? void 0 : f.scaleMode) || ke, x = await
|
|
622
|
+
const f = o == null ? void 0 : o.find((b) => b.name === g.name), u = (f == null ? void 0 : f.scaleMode) || ke, x = await Xt(
|
|
623
623
|
z,
|
|
624
624
|
{
|
|
625
625
|
artboard: {
|
|
@@ -643,7 +643,7 @@ const Je = je((t, e) => {
|
|
|
643
643
|
oe((g) => [...g, ...h]), le("success"), y == null || y(z);
|
|
644
644
|
else {
|
|
645
645
|
const g = new Error("Failed to load image into any artboard");
|
|
646
|
-
le("error"), ge(g), m == null || m(z, g),
|
|
646
|
+
le("error"), ge(g), m == null || m(z, g), B({
|
|
647
647
|
category: "image",
|
|
648
648
|
message: g.message,
|
|
649
649
|
originalError: g,
|
|
@@ -652,7 +652,7 @@ const Je = je((t, e) => {
|
|
|
652
652
|
}
|
|
653
653
|
} catch (d) {
|
|
654
654
|
const h = d instanceof Error ? d : new Error(String(d));
|
|
655
|
-
le("error"), ge(h), m == null || m(z, h),
|
|
655
|
+
le("error"), ge(h), m == null || m(z, h), B({
|
|
656
656
|
category: "image",
|
|
657
657
|
message: h.message,
|
|
658
658
|
originalError: h,
|
|
@@ -661,8 +661,8 @@ const Je = je((t, e) => {
|
|
|
661
661
|
}
|
|
662
662
|
})();
|
|
663
663
|
}, [z, Re, Ie, ke]), R(() => {
|
|
664
|
-
P == null || P(
|
|
665
|
-
}, [
|
|
664
|
+
P == null || P(Be);
|
|
665
|
+
}, [Be, P]), R(() => {
|
|
666
666
|
if (!A) return;
|
|
667
667
|
const s = k.getActiveArtboard(), d = {
|
|
668
668
|
elements: V.map((h) => h.toJSON()),
|
|
@@ -681,13 +681,13 @@ const Je = je((t, e) => {
|
|
|
681
681
|
const s = k.getActiveArtboard();
|
|
682
682
|
s && l(s.name);
|
|
683
683
|
}, [k.getActiveArtboardId()]);
|
|
684
|
-
const ct =
|
|
684
|
+
const ct = N(async () => {
|
|
685
685
|
if (!E && !w) return;
|
|
686
686
|
const s = ++it.current, d = Date.now();
|
|
687
|
-
let h =
|
|
687
|
+
let h = X;
|
|
688
688
|
if (U > 0 && isFinite(U))
|
|
689
689
|
for (const u of L) {
|
|
690
|
-
const x = Ee(u.width, u.height,
|
|
690
|
+
const x = Ee(u.width, u.height, X, U);
|
|
691
691
|
h = Math.min(h, x);
|
|
692
692
|
}
|
|
693
693
|
const g = k.getActiveArtboard(), f = (g == null ? void 0 : g.id) ?? "unknown";
|
|
@@ -704,8 +704,8 @@ const Je = je((t, e) => {
|
|
|
704
704
|
const b = await ce(x);
|
|
705
705
|
u = {};
|
|
706
706
|
for (const [F, Y] of Object.entries(b)) {
|
|
707
|
-
const
|
|
708
|
-
|
|
707
|
+
const O = L.find((Z) => Z.id === F);
|
|
708
|
+
O && (u[O.name] = Y);
|
|
709
709
|
}
|
|
710
710
|
} else {
|
|
711
711
|
const b = k.getActiveArtboard();
|
|
@@ -717,8 +717,8 @@ const Je = je((t, e) => {
|
|
|
717
717
|
const b = await ie(x);
|
|
718
718
|
u = {};
|
|
719
719
|
for (const [F, Y] of Object.entries(b)) {
|
|
720
|
-
const
|
|
721
|
-
|
|
720
|
+
const O = L.find((Z) => Z.id === F);
|
|
721
|
+
O && (u[O.name] = Y);
|
|
722
722
|
}
|
|
723
723
|
} else {
|
|
724
724
|
const b = k.getActiveArtboard();
|
|
@@ -737,7 +737,7 @@ const Je = je((t, e) => {
|
|
|
737
737
|
error: x
|
|
738
738
|
});
|
|
739
739
|
const F = u instanceof Error ? u : new Error(x);
|
|
740
|
-
w == null || w({ status: "error", artboardId: f, error: F }),
|
|
740
|
+
w == null || w({ status: "error", artboardId: f, error: F }), B({
|
|
741
741
|
category: "export",
|
|
742
742
|
message: F.message,
|
|
743
743
|
originalError: F,
|
|
@@ -745,14 +745,14 @@ const Je = je((t, e) => {
|
|
|
745
745
|
recoverable: !0
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
|
-
}, [E, w, fe, j,
|
|
748
|
+
}, [E, w, fe, j, X, U, te, re, G, ie, Q, ce, L, k, V, J, B]);
|
|
749
749
|
R(() => {
|
|
750
750
|
Se !== void 0 && Se > 0 && K.warn(
|
|
751
751
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
752
752
|
);
|
|
753
753
|
}, []), R(() => {
|
|
754
754
|
}, [V]);
|
|
755
|
-
const lt =
|
|
755
|
+
const lt = N(() => {
|
|
756
756
|
if (M == null || M(), w) {
|
|
757
757
|
const s = k.getActiveArtboard();
|
|
758
758
|
w({ status: "scheduled", artboardId: (s == null ? void 0 : s.id) ?? "unknown" });
|
|
@@ -791,14 +791,14 @@ const Je = je((t, e) => {
|
|
|
791
791
|
}, [L.length, he, se]), R(() => () => {
|
|
792
792
|
se(!1);
|
|
793
793
|
}, [se]);
|
|
794
|
-
const ut =
|
|
795
|
-
|
|
794
|
+
const ut = N((s) => {
|
|
795
|
+
B({
|
|
796
796
|
category: "unknown",
|
|
797
797
|
message: s.message,
|
|
798
798
|
originalError: s,
|
|
799
799
|
recoverable: !1
|
|
800
800
|
});
|
|
801
|
-
}, [
|
|
801
|
+
}, [B]);
|
|
802
802
|
return Ue === "loading" ? /* @__PURE__ */ C(
|
|
803
803
|
"div",
|
|
804
804
|
{
|
|
@@ -874,7 +874,7 @@ const Je = je((t, e) => {
|
|
|
874
874
|
),
|
|
875
875
|
children: [
|
|
876
876
|
!_e && (Pe || He ? /* @__PURE__ */ C("div", { className: Pe, style: He, children: /* @__PURE__ */ C(
|
|
877
|
-
|
|
877
|
+
Oe,
|
|
878
878
|
{
|
|
879
879
|
style: { width: "100%" },
|
|
880
880
|
fitPadding: Ce,
|
|
@@ -882,13 +882,13 @@ const Je = je((t, e) => {
|
|
|
882
882
|
fixedMargin: Te,
|
|
883
883
|
maxHeight: De,
|
|
884
884
|
showRotationHandle: Fe,
|
|
885
|
-
enableShortcuts:
|
|
885
|
+
enableShortcuts: Ne,
|
|
886
886
|
canvasCutouts: Le,
|
|
887
887
|
pieceGuides: me,
|
|
888
888
|
pieceFocus: We
|
|
889
889
|
}
|
|
890
890
|
) }) : /* @__PURE__ */ C(
|
|
891
|
-
|
|
891
|
+
Oe,
|
|
892
892
|
{
|
|
893
893
|
style: { width: "100%" },
|
|
894
894
|
fitPadding: Ce,
|
|
@@ -896,7 +896,7 @@ const Je = je((t, e) => {
|
|
|
896
896
|
fixedMargin: Te,
|
|
897
897
|
maxHeight: De,
|
|
898
898
|
showRotationHandle: Fe,
|
|
899
|
-
enableShortcuts:
|
|
899
|
+
enableShortcuts: Ne,
|
|
900
900
|
canvasCutouts: Le,
|
|
901
901
|
pieceGuides: me,
|
|
902
902
|
pieceFocus: We
|
|
@@ -911,11 +911,11 @@ Je.displayName = "SnowconeCanvasInner";
|
|
|
911
911
|
const Kt = je((t, e) => {
|
|
912
912
|
var o;
|
|
913
913
|
const { inheritTheme: r, externalProvider: a } = t, n = t.viewPadding ?? ((o = t.layoutConfig) == null ? void 0 : o.viewPadding), c = /* @__PURE__ */ C(Je, { ref: e, ...t });
|
|
914
|
-
return a ? /* @__PURE__ */ C(
|
|
914
|
+
return a ? /* @__PURE__ */ C(Xe, { defaultTheme: "light", passive: r, children: c }) : /* @__PURE__ */ C(Xe, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ C(It, { viewPadding: n, children: c }) });
|
|
915
915
|
});
|
|
916
916
|
Kt.displayName = "SnowconeCanvas";
|
|
917
917
|
const Ve = _("useCommands");
|
|
918
|
-
function
|
|
918
|
+
function ir() {
|
|
919
919
|
const t = ue(), {
|
|
920
920
|
undo: e,
|
|
921
921
|
redo: r,
|
|
@@ -929,9 +929,9 @@ function sr() {
|
|
|
929
929
|
executeCreateArtboard: A,
|
|
930
930
|
executeDeleteArtboard: P,
|
|
931
931
|
executeUpdateArtboard: I
|
|
932
|
-
} = t, E =
|
|
932
|
+
} = t, E = N(() => {
|
|
933
933
|
Ve.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
|
|
934
|
-
}, []), M =
|
|
934
|
+
}, []), M = N((w) => {
|
|
935
935
|
Ve.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
|
|
936
936
|
}, []);
|
|
937
937
|
return {
|
|
@@ -955,18 +955,18 @@ function sr() {
|
|
|
955
955
|
executeCommandBatch: p
|
|
956
956
|
};
|
|
957
957
|
}
|
|
958
|
-
function
|
|
958
|
+
function cr() {
|
|
959
959
|
const { selectedElement: t } = ue();
|
|
960
960
|
return t ?? null;
|
|
961
961
|
}
|
|
962
|
-
function
|
|
962
|
+
function lr() {
|
|
963
963
|
const { isCanvasReady: t } = ue();
|
|
964
964
|
return t;
|
|
965
965
|
}
|
|
966
966
|
const jt = () => {
|
|
967
967
|
}, Gt = [];
|
|
968
|
-
function
|
|
969
|
-
const { elementStore: e } = Ae(), { executeElementUpdate: r } = Ge(), a = ye(() => e.getAllByName(t).filter((o) => o instanceof At), [e, t]), n =
|
|
968
|
+
function dr(t) {
|
|
969
|
+
const { elementStore: e } = Ae(), { executeElementUpdate: r } = Ge(), a = ye(() => e.getAllByName(t).filter((o) => o instanceof At), [e, t]), n = N(
|
|
970
970
|
(c) => {
|
|
971
971
|
for (const o of a) {
|
|
972
972
|
const i = o.clone();
|
|
@@ -1009,7 +1009,7 @@ function Zt(t, e, r) {
|
|
|
1009
1009
|
};
|
|
1010
1010
|
}
|
|
1011
1011
|
}
|
|
1012
|
-
function
|
|
1012
|
+
function ur(t, e) {
|
|
1013
1013
|
const r = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: a, setElements: n } = Ae(), { executeElementUpdate: c } = Ge(), o = ye(() => a.getAllByName(t).filter((E) => E instanceof Ke), [a, t]), i = T(/* @__PURE__ */ new Map());
|
|
1014
1014
|
for (const I of o)
|
|
1015
1015
|
if (!i.current.has(I.id)) {
|
|
@@ -1025,7 +1025,7 @@ function dr(t, e) {
|
|
|
1025
1025
|
p.current = c;
|
|
1026
1026
|
const A = T(n);
|
|
1027
1027
|
A.current = n;
|
|
1028
|
-
const P =
|
|
1028
|
+
const P = N(
|
|
1029
1029
|
(I) => {
|
|
1030
1030
|
const E = l.current, M = p.current;
|
|
1031
1031
|
A.current;
|
|
@@ -1053,18 +1053,20 @@ function dr(t, e) {
|
|
|
1053
1053
|
isConnected: !0
|
|
1054
1054
|
};
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1056
|
+
function fr(t) {
|
|
1057
1057
|
const { elementStore: e } = Ae();
|
|
1058
1058
|
return t ? e.getByName(t) ?? null : null;
|
|
1059
1059
|
}
|
|
1060
|
-
function
|
|
1060
|
+
function mr() {
|
|
1061
1061
|
const { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i } = kt();
|
|
1062
1062
|
return { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i };
|
|
1063
1063
|
}
|
|
1064
|
-
|
|
1064
|
+
const qt = 1;
|
|
1065
|
+
function hr(t) {
|
|
1065
1066
|
var a;
|
|
1066
|
-
const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(
|
|
1067
|
+
const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(_t);
|
|
1067
1068
|
return {
|
|
1069
|
+
schemaVersion: qt,
|
|
1068
1070
|
artboards: [{
|
|
1069
1071
|
id: "artboard-1",
|
|
1070
1072
|
name: e.name || "Front",
|
|
@@ -1080,14 +1082,14 @@ function mr(t) {
|
|
|
1080
1082
|
}]
|
|
1081
1083
|
};
|
|
1082
1084
|
}
|
|
1083
|
-
function
|
|
1085
|
+
function _t(t) {
|
|
1084
1086
|
const e = t.type || t.transformType;
|
|
1085
|
-
return e === "image" ?
|
|
1087
|
+
return e === "image" ? er(t) : {
|
|
1086
1088
|
...t,
|
|
1087
1089
|
type: e
|
|
1088
1090
|
};
|
|
1089
1091
|
}
|
|
1090
|
-
function
|
|
1092
|
+
function er(t) {
|
|
1091
1093
|
var p;
|
|
1092
1094
|
const e = t.transformData || {}, r = t.masks && t.masks.length > 0, a = e.width || 0, n = e.height || 0, c = r ? a : a * (e.cropWidth ?? 1), o = r ? n : n * (e.cropHeight ?? 1), i = {
|
|
1093
1095
|
id: t.id,
|
|
@@ -1104,35 +1106,36 @@ function _t(t) {
|
|
|
1104
1106
|
}
|
|
1105
1107
|
wt();
|
|
1106
1108
|
export {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
vr as
|
|
1109
|
+
br as ALL_CAPABILITIES,
|
|
1110
|
+
qt as CANVAS_STATE_SCHEMA_VERSION,
|
|
1111
|
+
vr as COMPACT_CUSTOMIZER,
|
|
1112
|
+
xr as EMBED_ONLY,
|
|
1110
1113
|
Tt as ErrorBoundary,
|
|
1111
|
-
|
|
1112
|
-
|
|
1114
|
+
wr as MINIMAL_CAPABILITIES,
|
|
1115
|
+
Er as PRO_STUDIO,
|
|
1113
1116
|
Kt as SnowconeCanvas,
|
|
1114
|
-
|
|
1117
|
+
yr as createKit,
|
|
1115
1118
|
Kt as default,
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
+
Ir as deserializeState,
|
|
1120
|
+
Ar as extendKit,
|
|
1121
|
+
kr as migrateState,
|
|
1119
1122
|
ht as resolveKit,
|
|
1120
|
-
|
|
1121
|
-
|
|
1123
|
+
Cr as serializeState,
|
|
1124
|
+
hr as serializeStateForServer,
|
|
1122
1125
|
pt as useArtboards,
|
|
1123
1126
|
Ft as useAutoExport,
|
|
1124
|
-
|
|
1125
|
-
|
|
1127
|
+
lr as useCanvasReady,
|
|
1128
|
+
ir as useCommands,
|
|
1126
1129
|
Wt as useContentReady,
|
|
1127
1130
|
ue as useEditor,
|
|
1128
|
-
|
|
1131
|
+
fr as useElementByName,
|
|
1129
1132
|
bt as useExport,
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1133
|
+
ur as useImageBinding,
|
|
1134
|
+
Sr as useLayers,
|
|
1135
|
+
cr as useSelectedElement,
|
|
1136
|
+
dr as useTextBinding,
|
|
1137
|
+
mr as useViewport,
|
|
1135
1138
|
gt as validateKit,
|
|
1136
|
-
|
|
1139
|
+
Mr as validateState
|
|
1137
1140
|
};
|
|
1138
1141
|
//# sourceMappingURL=index.mjs.map
|