@snowcone-app/canvas 0.13.0 → 0.14.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.
- package/dist/advanced.mjs +323 -327
- package/dist/advanced.mjs.map +1 -1
- package/dist/components/VisualGuideOverlay.d.ts +1 -1
- package/dist/components/ui/index.d.ts +34 -34
- package/dist/embed.mjs +34 -34
- package/dist/embed.mjs.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/style.css +1 -1
- package/dist/{template-fields-IgDV7PRY.js → template-fields-Dw-KK9DX.js} +182 -182
- package/dist/template-fields-Dw-KK9DX.js.map +1 -0
- package/dist/validation-BahKiJWj.js +22973 -0
- package/dist/validation-BahKiJWj.js.map +1 -0
- package/dist/vendor/ui/index.d.ts +35 -0
- package/dist/vendor/ui/lib/utils.d.ts +2 -0
- package/dist/vendor/ui/primitives/Button.d.ts +14 -0
- package/dist/vendor/ui/primitives/accordion.d.ts +37 -0
- package/dist/vendor/ui/primitives/badge.d.ts +20 -0
- package/dist/vendor/ui/primitives/card.d.ts +12 -0
- package/dist/vendor/ui/primitives/checkbox.d.ts +8 -0
- package/dist/vendor/ui/primitives/collapsible.d.ts +10 -0
- package/dist/vendor/ui/primitives/drawer.d.ts +66 -0
- package/dist/vendor/ui/primitives/dropdown-menu.d.ts +27 -0
- package/dist/vendor/ui/primitives/fieldset.d.ts +35 -0
- package/dist/vendor/ui/primitives/input.d.ts +18 -0
- package/dist/vendor/ui/primitives/kbd.d.ts +37 -0
- package/dist/vendor/ui/primitives/label.d.ts +5 -0
- package/dist/vendor/ui/primitives/link.d.ts +52 -0
- package/dist/vendor/ui/primitives/popover.d.ts +26 -0
- package/dist/vendor/ui/primitives/radio-group.d.ts +15 -0
- package/dist/vendor/ui/primitives/select.d.ts +17 -0
- package/dist/vendor/ui/primitives/separator.d.ts +4 -0
- package/dist/vendor/ui/primitives/slider.d.ts +26 -0
- package/dist/vendor/ui/primitives/spinner.d.ts +12 -0
- package/dist/vendor/ui/primitives/surface.d.ts +52 -0
- package/dist/vendor/ui/primitives/switch.d.ts +4 -0
- package/dist/vendor/ui/primitives/tabs.d.ts +28 -0
- package/dist/vendor/ui/primitives/text-field.d.ts +36 -0
- package/dist/vendor/ui/primitives/textarea.d.ts +10 -0
- package/dist/vendor/ui/primitives/tooltip.d.ts +19 -0
- package/package.json +7 -5
- package/dist/template-fields-IgDV7PRY.js.map +0 -1
- package/dist/validation-BpmNOvuY.js +0 -21177
- package/dist/validation-BpmNOvuY.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as nt, y as K, z as Oe, I as Ht, T as Pt, C as Ye } from "./HybridHistoryManager-NL3zyEl4.js";
|
|
2
2
|
import { jsxs as Z, jsx as w, Fragment as de } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback as P, useMemo as ot, useRef as
|
|
3
|
+
import { useCallback as P, useMemo as ot, useRef as M, useEffect as C, Component as Xe, useState as _, forwardRef as ue, useImperativeHandle as Ve } from "react";
|
|
4
4
|
import { u as fe, T as _t, E as je, c as dt, b as At } from "./ThemeContext-Cl1JPVLZ.js";
|
|
5
|
-
import {
|
|
5
|
+
import { aq as te, ar as ee, ag as Ke, ah as re, ad as Ge, W as qe, J as Je, K as Qe, Q as Ze, O as _e, p as tr, z as er, ab as rr, Y as ne, F as nr, q as or, G as ar, r as sr, v as ir, u as cr, g as lr, a2 as dr, V as ur, a as fr, w as hr, as as mr } from "./validation-BahKiJWj.js";
|
|
6
6
|
import { C as Tt, E as gr } from "./ImportManager-eotl7r5d.js";
|
|
7
7
|
import { d as pr, o as ct, s as $, n as br, l as Y, u as oe, a as yr } from "./schemas-B4UXytQB.js";
|
|
8
8
|
const ae = nt("useCommands");
|
|
@@ -13,8 +13,8 @@ function xr() {
|
|
|
13
13
|
canUndo: o,
|
|
14
14
|
canRedo: n,
|
|
15
15
|
executeElementUpdate: a,
|
|
16
|
-
executeAddElement:
|
|
17
|
-
executeRemoveElement:
|
|
16
|
+
executeAddElement: s,
|
|
17
|
+
executeRemoveElement: i,
|
|
18
18
|
executeReorderElement: c,
|
|
19
19
|
executeCommandBatch: d,
|
|
20
20
|
executeCreateArtboard: x,
|
|
@@ -36,8 +36,8 @@ function xr() {
|
|
|
36
36
|
clearArtboardHistory: T,
|
|
37
37
|
// Command execution
|
|
38
38
|
executeElementUpdate: a,
|
|
39
|
-
executeAddElement:
|
|
40
|
-
executeRemoveElement:
|
|
39
|
+
executeAddElement: s,
|
|
40
|
+
executeRemoveElement: i,
|
|
41
41
|
executeReorderElement: c,
|
|
42
42
|
executeCreateArtboard: x,
|
|
43
43
|
executeDeleteArtboard: I,
|
|
@@ -71,9 +71,9 @@ const vr = () => {
|
|
|
71
71
|
)
|
|
72
72
|
] });
|
|
73
73
|
}, he = nt("KitLayout"), lt = "canvas", Dt = 320;
|
|
74
|
-
let
|
|
74
|
+
let se = !1;
|
|
75
75
|
function wr() {
|
|
76
|
-
|
|
76
|
+
se || (se = !0, Ke({
|
|
77
77
|
LayersPanel: qe,
|
|
78
78
|
EffectsPanel: Je,
|
|
79
79
|
ExportPanel: Qe,
|
|
@@ -112,10 +112,10 @@ function wt({ ids: e }) {
|
|
|
112
112
|
function Er({ kit: e, canvas: t }) {
|
|
113
113
|
var I, R, k, T;
|
|
114
114
|
wr();
|
|
115
|
-
const r = e.layout.slots, o = !!((I = r.topbar) != null && I.some((p) => p !== lt)), n = !!((R = r.left) != null && R.some((p) => p !== lt)), a = !!((k = r.right) != null && k.some((p) => p !== lt)),
|
|
116
|
-
() => !o && !n && !a && !
|
|
117
|
-
[o, n, a,
|
|
118
|
-
), c =
|
|
115
|
+
const r = e.layout.slots, o = !!((I = r.topbar) != null && I.some((p) => p !== lt)), n = !!((R = r.left) != null && R.some((p) => p !== lt)), a = !!((k = r.right) != null && k.some((p) => p !== lt)), s = !!((T = r.bottombar) != null && T.some((p) => p !== lt)), i = ot(
|
|
116
|
+
() => !o && !n && !a && !s,
|
|
117
|
+
[o, n, a, s]
|
|
118
|
+
), c = M(null), d = o || n || a || s, x = M(!1);
|
|
119
119
|
return C(() => {
|
|
120
120
|
var b;
|
|
121
121
|
if (typeof K > "u" || ((b = K.env) == null ? void 0 : b.NODE_ENV) !== "development" || !d) return;
|
|
@@ -131,11 +131,11 @@ function Er({ kit: e, canvas: t }) {
|
|
|
131
131
|
for (const v of E) N(v.contentRect.width);
|
|
132
132
|
});
|
|
133
133
|
return S.observe(p), () => S.disconnect();
|
|
134
|
-
}, [d, e.name]),
|
|
134
|
+
}, [d, e.name]), i ? /* @__PURE__ */ w(de, { children: t }) : /* @__PURE__ */ Z("div", { ref: c, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
|
|
135
135
|
o && /* @__PURE__ */ w(
|
|
136
136
|
"div",
|
|
137
137
|
{
|
|
138
|
-
className: "sc-kit-topbar toolbar",
|
|
138
|
+
className: "sc-kit-topbar sc-toolbar",
|
|
139
139
|
style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", flexShrink: 0 },
|
|
140
140
|
children: /* @__PURE__ */ w(wt, { ids: r.topbar })
|
|
141
141
|
}
|
|
@@ -145,10 +145,10 @@ function Er({ kit: e, canvas: t }) {
|
|
|
145
145
|
/* @__PURE__ */ w("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: t }),
|
|
146
146
|
a && /* @__PURE__ */ w("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ w(wt, { ids: r.right }) })
|
|
147
147
|
] }),
|
|
148
|
-
|
|
148
|
+
s && /* @__PURE__ */ w(
|
|
149
149
|
"div",
|
|
150
150
|
{
|
|
151
|
-
className: "sc-kit-bottombar toolbar",
|
|
151
|
+
className: "sc-kit-bottombar sc-toolbar",
|
|
152
152
|
style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 },
|
|
153
153
|
children: /* @__PURE__ */ w(wt, { ids: r.bottombar })
|
|
154
154
|
}
|
|
@@ -238,12 +238,12 @@ class kr extends Xe {
|
|
|
238
238
|
}
|
|
239
239
|
const Sr = nt("useAutoExport");
|
|
240
240
|
function Rr(e) {
|
|
241
|
-
const { config: t, historyManager: r, artboards: o, elements: n, onExport: a, onExportScheduled:
|
|
241
|
+
const { config: t, historyManager: r, artboards: o, elements: n, onExport: a, onExportScheduled: s, isCanvasReady: i = !1 } = e, c = M(null), d = M(!1), x = M({
|
|
242
242
|
totalExports: 0,
|
|
243
243
|
skippedExports: 0,
|
|
244
244
|
lastExportTime: null,
|
|
245
245
|
avgExportInterval: 0
|
|
246
|
-
}), [I, R] = _(x.current), k =
|
|
246
|
+
}), [I, R] = _(x.current), k = M(a);
|
|
247
247
|
k.current = a, C(() => {
|
|
248
248
|
const b = new or({
|
|
249
249
|
...ar,
|
|
@@ -259,17 +259,17 @@ function Rr(e) {
|
|
|
259
259
|
b.destroy();
|
|
260
260
|
};
|
|
261
261
|
}, []), C(() => {
|
|
262
|
-
|
|
263
|
-
}, [
|
|
262
|
+
i && d.current && c.current && (d.current = !1, c.current.forceExport());
|
|
263
|
+
}, [i]), C(() => {
|
|
264
264
|
c.current && t && c.current.updateConfig(t);
|
|
265
265
|
}, [t == null ? void 0 : t.enabled, t == null ? void 0 : t.debounceMs, t == null ? void 0 : t.maxWaitMs]), C(() => {
|
|
266
|
-
c.current &&
|
|
267
|
-
}, [
|
|
266
|
+
c.current && s && c.current.onExportScheduled(s);
|
|
267
|
+
}, [s]), C(() => {
|
|
268
268
|
if (!r || !c.current)
|
|
269
269
|
return;
|
|
270
270
|
const b = r.onCommandExecuted(() => {
|
|
271
271
|
if (c.current) {
|
|
272
|
-
if (!
|
|
272
|
+
if (!i) {
|
|
273
273
|
d.current = !0;
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
@@ -279,18 +279,18 @@ function Rr(e) {
|
|
|
279
279
|
return () => {
|
|
280
280
|
b();
|
|
281
281
|
};
|
|
282
|
-
}, [r,
|
|
282
|
+
}, [r, i]), C(() => {
|
|
283
283
|
if (c.current) {
|
|
284
|
-
if (!
|
|
284
|
+
if (!i) {
|
|
285
285
|
d.current = !0;
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
288
|
c.current.scheduleExport();
|
|
289
289
|
}
|
|
290
|
-
}, [n, o,
|
|
291
|
-
if (!c.current || !
|
|
290
|
+
}, [n, o, i]), C(() => Oe((E) => {
|
|
291
|
+
if (!c.current || !i) return;
|
|
292
292
|
n.some((W) => W.id === E) && c.current.scheduleExport();
|
|
293
|
-
}), [n,
|
|
293
|
+
}), [n, i]);
|
|
294
294
|
const T = P((b) => {
|
|
295
295
|
c.current && c.current.updateConfig(b);
|
|
296
296
|
}, []), p = P(async () => {
|
|
@@ -335,27 +335,27 @@ async function Ir(e) {
|
|
|
335
335
|
new Promise((r) => setTimeout(r, 250))
|
|
336
336
|
]), me.debug(`Awaited ${t.length} font(s)`);
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function Fr() {
|
|
339
339
|
return new Promise((e) => requestAnimationFrame(() => e()));
|
|
340
340
|
}
|
|
341
|
-
function
|
|
342
|
-
const { isCanvasReady: t, elements: r, hasInitialElements: o, initialElementsLoaded: n } = e, [a,
|
|
341
|
+
function Mr(e) {
|
|
342
|
+
const { isCanvasReady: t, elements: r, hasInitialElements: o, initialElementsLoaded: n } = e, [a, s] = _(!1), i = M(!1);
|
|
343
343
|
return C(() => {
|
|
344
|
-
if (a || !t || o && !n || o && r.length === 0 ||
|
|
345
|
-
|
|
344
|
+
if (a || !t || o && !n || o && r.length === 0 || i.current) return;
|
|
345
|
+
i.current = !0;
|
|
346
346
|
let c = !1;
|
|
347
347
|
return (async () => {
|
|
348
348
|
try {
|
|
349
349
|
const d = Cr(r);
|
|
350
|
-
if (d.length > 0 && (await Ir(d), c) || (await
|
|
351
|
-
|
|
350
|
+
if (d.length > 0 && (await Ir(d), c) || (await Fr(), c)) return;
|
|
351
|
+
s(!0);
|
|
352
352
|
} catch (d) {
|
|
353
|
-
me.error("Error during content readiness check:", d), c ||
|
|
353
|
+
me.error("Error during content readiness check:", d), c || s(!0);
|
|
354
354
|
} finally {
|
|
355
|
-
|
|
355
|
+
i.current = !1;
|
|
356
356
|
}
|
|
357
357
|
})(), () => {
|
|
358
|
-
c = !0,
|
|
358
|
+
c = !0, i.current = !1;
|
|
359
359
|
};
|
|
360
360
|
}, [t, r, o, n, a]), a;
|
|
361
361
|
}
|
|
@@ -386,9 +386,9 @@ function Dr(e) {
|
|
|
386
386
|
return e && Tr[e] || "c";
|
|
387
387
|
}
|
|
388
388
|
function Nr(e, t) {
|
|
389
|
-
const r = t.scaleMode || "cover", o = (r === "contain" ? t.marginTop : 0) || 0, n = (r === "contain" ? t.marginRight : 0) || 0, a = (r === "contain" ? t.marginBottom : 0) || 0,
|
|
389
|
+
const r = t.scaleMode || "cover", o = (r === "contain" ? t.marginTop : 0) || 0, n = (r === "contain" ? t.marginRight : 0) || 0, a = (r === "contain" ? t.marginBottom : 0) || 0, s = (r === "contain" ? t.marginLeft : 0) || 0, i = t.width - s - n, c = t.height - o - a, d = i / e.width, x = c / e.height, I = r === "contain" ? Math.min(d, x) : Math.max(d, x), R = t.scale || 1, k = I * R, T = e.width * k, p = e.height * k, N = t.align || "c";
|
|
390
390
|
let S = 0, b = 0;
|
|
391
|
-
const E = T -
|
|
391
|
+
const E = T - i, v = p - c;
|
|
392
392
|
switch (N) {
|
|
393
393
|
// Top row
|
|
394
394
|
case "tl":
|
|
@@ -423,7 +423,7 @@ function Nr(e, t) {
|
|
|
423
423
|
S = -E, b = -v;
|
|
424
424
|
break;
|
|
425
425
|
}
|
|
426
|
-
S +=
|
|
426
|
+
S += s, b += o;
|
|
427
427
|
const W = t.offsetX || 0, B = t.offsetY || 0, X = E, ut = v;
|
|
428
428
|
return S += W * X, b += B * ut, S = Math.round(S), b = Math.round(b), {
|
|
429
429
|
// Final scale to apply to artwork
|
|
@@ -482,11 +482,11 @@ function Pr(e, t) {
|
|
|
482
482
|
const o = new Image();
|
|
483
483
|
o.crossOrigin = "anonymous";
|
|
484
484
|
let n = null, a = !1;
|
|
485
|
-
const
|
|
485
|
+
const s = () => {
|
|
486
486
|
n && (clearTimeout(n), n = null);
|
|
487
|
-
},
|
|
487
|
+
}, i = () => {
|
|
488
488
|
if (a) return;
|
|
489
|
-
a = !0,
|
|
489
|
+
a = !0, s();
|
|
490
490
|
const d = o.naturalWidth || o.width, x = o.naturalHeight || o.height;
|
|
491
491
|
r({
|
|
492
492
|
success: !0,
|
|
@@ -496,12 +496,12 @@ function Pr(e, t) {
|
|
|
496
496
|
aspectRatio: x > 0 ? d / x : 1
|
|
497
497
|
});
|
|
498
498
|
}, c = (d) => {
|
|
499
|
-
a || (a = !0,
|
|
499
|
+
a || (a = !0, s(), r({
|
|
500
500
|
success: !1,
|
|
501
501
|
error: new Error(d)
|
|
502
502
|
}));
|
|
503
503
|
};
|
|
504
|
-
o.onload =
|
|
504
|
+
o.onload = i, o.onerror = () => {
|
|
505
505
|
c(`Failed to load image: ${e}`);
|
|
506
506
|
}, n = setTimeout(() => {
|
|
507
507
|
c(`Image load timed out after ${t}ms: ${e}`);
|
|
@@ -528,10 +528,10 @@ async function Wr(e, t, r = {}, o = {}) {
|
|
|
528
528
|
marginRight: t.marginRight,
|
|
529
529
|
marginBottom: t.marginBottom,
|
|
530
530
|
marginLeft: t.marginLeft
|
|
531
|
-
},
|
|
531
|
+
}, s = Nr(
|
|
532
532
|
{ width: n.width, height: n.height },
|
|
533
533
|
a
|
|
534
|
-
),
|
|
534
|
+
), i = t.artboard.x + s.x, c = t.artboard.y + s.y, d = i + s.width / 2, x = c + s.height / 2;
|
|
535
535
|
return {
|
|
536
536
|
success: !0,
|
|
537
537
|
element: new Ht({
|
|
@@ -544,8 +544,8 @@ async function Wr(e, t, r = {}, o = {}) {
|
|
|
544
544
|
// Don't recalculate dimensions on image load
|
|
545
545
|
transformData: {
|
|
546
546
|
type: "image",
|
|
547
|
-
width:
|
|
548
|
-
height:
|
|
547
|
+
width: s.width,
|
|
548
|
+
height: s.height,
|
|
549
549
|
cropX: ((R = r.transformData) == null ? void 0 : R.cropX) ?? 0,
|
|
550
550
|
cropY: ((k = r.transformData) == null ? void 0 : k.cropY) ?? 0,
|
|
551
551
|
cropWidth: ((T = r.transformData) == null ? void 0 : T.cropWidth) ?? 1,
|
|
@@ -557,9 +557,9 @@ async function Wr(e, t, r = {}, o = {}) {
|
|
|
557
557
|
}),
|
|
558
558
|
placement: {
|
|
559
559
|
artworkSize: { width: n.width, height: n.height },
|
|
560
|
-
finalSize: { width:
|
|
560
|
+
finalSize: { width: s.width, height: s.height },
|
|
561
561
|
position: { x: d, y: x },
|
|
562
|
-
scale:
|
|
562
|
+
scale: s.scale
|
|
563
563
|
}
|
|
564
564
|
};
|
|
565
565
|
}
|
|
@@ -573,7 +573,7 @@ function Nt(e, t, r, o) {
|
|
|
573
573
|
const n = e * r, a = t * r;
|
|
574
574
|
if (Math.max(n, a) <= o)
|
|
575
575
|
return r;
|
|
576
|
-
const
|
|
576
|
+
const i = Math.max(e, t), c = o / i;
|
|
577
577
|
return Math.min(c, r);
|
|
578
578
|
}
|
|
579
579
|
const ge = ue((e, t) => {
|
|
@@ -582,8 +582,8 @@ const ge = ue((e, t) => {
|
|
|
582
582
|
imageConfig: o,
|
|
583
583
|
layoutConfig: n,
|
|
584
584
|
kit: a,
|
|
585
|
-
artboards:
|
|
586
|
-
activeArtboard:
|
|
585
|
+
artboards: s,
|
|
586
|
+
activeArtboard: i,
|
|
587
587
|
onArtboardChange: c,
|
|
588
588
|
initialElements: d,
|
|
589
589
|
onChange: x,
|
|
@@ -601,15 +601,15 @@ const ge = ue((e, t) => {
|
|
|
601
601
|
style: B,
|
|
602
602
|
enableShortcuts: X,
|
|
603
603
|
overlay: ut
|
|
604
|
-
} = e, zt = R, at = e.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), tt = e.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", kt = e.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, G = e.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, z = e.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, ft = e.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", ht = e.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, L = e.initialImage ?? (o == null ? void 0 : o.src), Lt = e.initialImageAlignment ?? (o == null ? void 0 : o.alignment) ?? "center", Ot = e.initialImageScale ?? (o == null ? void 0 : o.scale) ?? 1, Yt = e.initialImageScaleMode ?? (o == null ? void 0 : o.scaleMode) ?? "cover", xe = e.width ?? (n == null ? void 0 : n.width) ?? 1200, ve = e.height ?? (n == null ? void 0 : n.height) ?? 1200, we = e.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, Ee = e.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, Ae = e.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), ke = e.maxHeight ?? (n == null ? void 0 : n.maxHeight), Se = e.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, Re = e.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Xt = e.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), Vt = e.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), Ce = e.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), jt = e.pieceGuides, Ie = e.pieceFocus,
|
|
604
|
+
} = e, zt = R, at = e.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), tt = e.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", kt = e.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, G = e.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, z = e.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, ft = e.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", ht = e.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, L = e.initialImage ?? (o == null ? void 0 : o.src), Lt = e.initialImageAlignment ?? (o == null ? void 0 : o.alignment) ?? "center", Ot = e.initialImageScale ?? (o == null ? void 0 : o.scale) ?? 1, Yt = e.initialImageScaleMode ?? (o == null ? void 0 : o.scaleMode) ?? "cover", xe = e.width ?? (n == null ? void 0 : n.width) ?? 1200, ve = e.height ?? (n == null ? void 0 : n.height) ?? 1200, we = e.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, Ee = e.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, Ae = e.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), ke = e.maxHeight ?? (n == null ? void 0 : n.maxHeight), Se = e.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, Re = e.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Xt = e.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), Vt = e.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), Ce = e.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), jt = e.pieceGuides, Ie = e.pieceFocus, Fe = X ?? !0, st = ot(() => sr(a ?? "pro-studio"), [a]);
|
|
605
605
|
C(() => {
|
|
606
606
|
var l;
|
|
607
|
-
if (typeof K < "u" && ((l = K.env) == null ? void 0 : l.NODE_ENV) === "development" &&
|
|
608
|
-
const u =
|
|
607
|
+
if (typeof K < "u" && ((l = K.env) == null ? void 0 : l.NODE_ENV) === "development" && st) {
|
|
608
|
+
const u = ir(st);
|
|
609
609
|
u.valid || J.warn("Kit validation warnings:", u.errors), u.warnings.length > 0 && J.warn("Kit validation warnings:", u.warnings);
|
|
610
610
|
}
|
|
611
|
-
}, [
|
|
612
|
-
const mt =
|
|
611
|
+
}, [st]);
|
|
612
|
+
const mt = M(E);
|
|
613
613
|
mt.current = E;
|
|
614
614
|
const U = P((l) => {
|
|
615
615
|
var u;
|
|
@@ -622,8 +622,8 @@ const ge = ue((e, t) => {
|
|
|
622
622
|
elements: q,
|
|
623
623
|
setElements: gt,
|
|
624
624
|
selectedId: Kt,
|
|
625
|
-
artboardManager:
|
|
626
|
-
refreshArtboards:
|
|
625
|
+
artboardManager: F,
|
|
626
|
+
refreshArtboards: Me,
|
|
627
627
|
historyManager: Te,
|
|
628
628
|
isCanvasReady: St,
|
|
629
629
|
setCanvasReady: pt
|
|
@@ -641,12 +641,12 @@ const ge = ue((e, t) => {
|
|
|
641
641
|
if (f) {
|
|
642
642
|
const h = u === "blob" ? await yt(g) : await bt(g), y = {};
|
|
643
643
|
for (const [D, O] of Object.entries(h)) {
|
|
644
|
-
const V = H.find((
|
|
644
|
+
const V = H.find((it) => it.id === D);
|
|
645
645
|
V && (y[V.name] = O);
|
|
646
646
|
}
|
|
647
647
|
return y;
|
|
648
648
|
} else {
|
|
649
|
-
const h =
|
|
649
|
+
const h = F.getActiveArtboard();
|
|
650
650
|
if (!h)
|
|
651
651
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
652
652
|
if (u === "blob") {
|
|
@@ -658,9 +658,9 @@ const ge = ue((e, t) => {
|
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
|
-
}), [et, bt, rt, yt, tt, G, z, ft, ht,
|
|
661
|
+
}), [et, bt, rt, yt, tt, G, z, ft, ht, F, H]), C(() => {
|
|
662
662
|
N && N(async () => {
|
|
663
|
-
const u =
|
|
663
|
+
const u = F.getActiveArtboard();
|
|
664
664
|
if (!u)
|
|
665
665
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
666
666
|
const A = Nt(
|
|
@@ -671,12 +671,12 @@ const ge = ue((e, t) => {
|
|
|
671
671
|
), f = tt === "blob" ? await rt(u.id, { scale: A }) : await et(u.id, { scale: A });
|
|
672
672
|
return { [u.name]: f };
|
|
673
673
|
});
|
|
674
|
-
}, [N, et, rt,
|
|
675
|
-
const [Gt, xt] = _("idle"), [qt, Rt] = _(null), Ct =
|
|
674
|
+
}, [N, et, rt, F, tt, G, z]);
|
|
675
|
+
const [Gt, xt] = _("idle"), [qt, Rt] = _(null), Ct = M(void 0), It = M(!1), Jt = M(!1), [Be, $e] = _(!1), He = M(0), Pe = M(0), Ft = M(!1);
|
|
676
676
|
C(() => {
|
|
677
677
|
if (It.current) return;
|
|
678
678
|
It.current = !0;
|
|
679
|
-
const l =
|
|
679
|
+
const l = s || [{ name: "Design", width: xe, height: ve }], u = F.getAllArtboards();
|
|
680
680
|
if (u.length > 0) {
|
|
681
681
|
const A = l[0], f = u[0], m = jt ? "transparent" : void 0, g = (h) => h.exportBackground ?? (!!h.backgroundColor && h.backgroundColor !== "transparent");
|
|
682
682
|
f.name = A.name, f.width = A.width, f.height = A.height, f.clipShape = A.clipShape, f.exportBackground = g(A), A.backgroundColor ? f.backgroundColor = A.backgroundColor : m && (f.backgroundColor = m);
|
|
@@ -687,20 +687,20 @@ const ge = ue((e, t) => {
|
|
|
687
687
|
exportBackground: g(l[h]),
|
|
688
688
|
clipShape: l[h].clipShape
|
|
689
689
|
});
|
|
690
|
-
!
|
|
690
|
+
!i && l.length > 1 && F.setActiveArtboard(f.id);
|
|
691
691
|
}
|
|
692
|
-
|
|
692
|
+
Me();
|
|
693
693
|
}, []), C(() => {
|
|
694
694
|
if (!(!d || d.length === 0) && !Jt.current && It.current) {
|
|
695
695
|
Jt.current = !0, $e(!0);
|
|
696
696
|
try {
|
|
697
|
-
const l = gr.createManyFromJSON(d), u =
|
|
697
|
+
const l = gr.createManyFromJSON(d), u = F.getAllArtboards();
|
|
698
698
|
if (u.length > 0) {
|
|
699
699
|
const f = new Map(u.map((m) => [m.name, m]));
|
|
700
700
|
l.forEach((m, g) => {
|
|
701
701
|
var D;
|
|
702
702
|
const h = (D = d[g]) == null ? void 0 : D.artboard, y = h && f.get(h) || u[0];
|
|
703
|
-
|
|
703
|
+
F.addElementToArtboard(m.id, y.id);
|
|
704
704
|
});
|
|
705
705
|
}
|
|
706
706
|
gt(l);
|
|
@@ -750,17 +750,17 @@ const ge = ue((e, t) => {
|
|
|
750
750
|
});
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
|
-
}, [d,
|
|
754
|
-
if (!
|
|
755
|
-
|
|
753
|
+
}, [d, F, gt, U]), C(() => {
|
|
754
|
+
if (!i) {
|
|
755
|
+
Ft.current = !0;
|
|
756
756
|
return;
|
|
757
757
|
}
|
|
758
|
-
const l = H.find((u) => u.name ===
|
|
758
|
+
const l = H.find((u) => u.name === i);
|
|
759
759
|
if (l) {
|
|
760
|
-
const u =
|
|
761
|
-
(u == null ? void 0 : u.name) !==
|
|
760
|
+
const u = F.getActiveArtboard();
|
|
761
|
+
(u == null ? void 0 : u.name) !== i && Ne(l.id), Ft.current = !0;
|
|
762
762
|
}
|
|
763
|
-
}, [
|
|
763
|
+
}, [i, H]), C(() => {
|
|
764
764
|
if (!L || Ct.current === L) return;
|
|
765
765
|
if (q.length > 0) {
|
|
766
766
|
Ct.current = L;
|
|
@@ -769,12 +769,12 @@ const ge = ue((e, t) => {
|
|
|
769
769
|
Ct.current = L, (async () => {
|
|
770
770
|
xt("loading"), Rt(null);
|
|
771
771
|
try {
|
|
772
|
-
const u =
|
|
772
|
+
const u = F.getAllArtboards();
|
|
773
773
|
if (u.length === 0)
|
|
774
774
|
throw new Error("No artboards available");
|
|
775
775
|
const A = [];
|
|
776
776
|
for (const f of u) {
|
|
777
|
-
const m =
|
|
777
|
+
const m = s == null ? void 0 : s.find((y) => y.name === f.name), g = (m == null ? void 0 : m.scaleMode) || Yt, h = await Wr(
|
|
778
778
|
L,
|
|
779
779
|
{
|
|
780
780
|
artboard: {
|
|
@@ -792,7 +792,7 @@ const ge = ue((e, t) => {
|
|
|
792
792
|
marginLeft: m == null ? void 0 : m.fitMarginLeft
|
|
793
793
|
}
|
|
794
794
|
);
|
|
795
|
-
h.success && h.element ? (
|
|
795
|
+
h.success && h.element ? (F.addElementToArtboard(h.element.id, f.id), A.push(h.element)) : J.error("Failed to load image for artboard:", f.name, h.error);
|
|
796
796
|
}
|
|
797
797
|
if (A.length > 0)
|
|
798
798
|
gt((f) => [...f, ...A]), xt("success"), S == null || S(L);
|
|
@@ -816,16 +816,16 @@ const ge = ue((e, t) => {
|
|
|
816
816
|
}
|
|
817
817
|
})();
|
|
818
818
|
}, [L, Lt, Ot, Yt]);
|
|
819
|
-
const vt =
|
|
819
|
+
const vt = M(I);
|
|
820
820
|
vt.current = I, C(() => {
|
|
821
821
|
var l;
|
|
822
822
|
(l = vt.current) == null || l.call(vt, Kt);
|
|
823
823
|
}, [Kt]);
|
|
824
|
-
const Qt =
|
|
824
|
+
const Qt = M(x);
|
|
825
825
|
Qt.current = x, C(() => {
|
|
826
826
|
const l = Qt.current;
|
|
827
827
|
if (!l) return;
|
|
828
|
-
const u =
|
|
828
|
+
const u = F.getActiveArtboard(), A = {
|
|
829
829
|
// Stamp each element with the NAME of the artboard it lives on (the
|
|
830
830
|
// manager is the membership source of truth). Without this the public
|
|
831
831
|
// state is flat and a multi-placement design cannot round-trip: restore
|
|
@@ -833,7 +833,7 @@ const ge = ue((e, t) => {
|
|
|
833
833
|
// states can't be derived from onChange. Pinned by
|
|
834
834
|
// SnowconeCanvas.artboard-membership.test.tsx.
|
|
835
835
|
elements: q.map((f) => {
|
|
836
|
-
const m = f.toJSON(), g =
|
|
836
|
+
const m = f.toJSON(), g = F.getArtboardForElement(f.id);
|
|
837
837
|
return g ? { ...m, artboard: g.name } : m;
|
|
838
838
|
}),
|
|
839
839
|
artboards: H.map((f) => ({
|
|
@@ -850,10 +850,10 @@ const ge = ue((e, t) => {
|
|
|
850
850
|
};
|
|
851
851
|
l(A);
|
|
852
852
|
}, [q, H]), C(() => {
|
|
853
|
-
if (!c || !
|
|
854
|
-
const l =
|
|
853
|
+
if (!c || !Ft.current) return;
|
|
854
|
+
const l = F.getActiveArtboard();
|
|
855
855
|
l && c(l.name);
|
|
856
|
-
}, [
|
|
856
|
+
}, [F.getActiveArtboardId()]);
|
|
857
857
|
const We = P(async () => {
|
|
858
858
|
if (!k && !p) return;
|
|
859
859
|
const l = ++Pe.current, u = Date.now();
|
|
@@ -863,7 +863,7 @@ const ge = ue((e, t) => {
|
|
|
863
863
|
const h = Nt(g.width, g.height, G, z);
|
|
864
864
|
A = Math.min(A, h);
|
|
865
865
|
}
|
|
866
|
-
const f =
|
|
866
|
+
const f = F.getActiveArtboard(), m = (f == null ? void 0 : f.id) ?? "unknown";
|
|
867
867
|
p == null || p({ status: "rendering", artboardId: m }), He.current = u;
|
|
868
868
|
try {
|
|
869
869
|
let g;
|
|
@@ -877,11 +877,11 @@ const ge = ue((e, t) => {
|
|
|
877
877
|
const y = await yt(h);
|
|
878
878
|
g = {};
|
|
879
879
|
for (const [D, O] of Object.entries(y)) {
|
|
880
|
-
const V = H.find((
|
|
880
|
+
const V = H.find((it) => it.id === D);
|
|
881
881
|
V && (g[V.name] = O);
|
|
882
882
|
}
|
|
883
883
|
} else {
|
|
884
|
-
const y =
|
|
884
|
+
const y = F.getActiveArtboard();
|
|
885
885
|
if (!y) return;
|
|
886
886
|
const D = await rt(y.id, h);
|
|
887
887
|
g = { [y.name]: D };
|
|
@@ -890,11 +890,11 @@ const ge = ue((e, t) => {
|
|
|
890
890
|
const y = await bt(h);
|
|
891
891
|
g = {};
|
|
892
892
|
for (const [D, O] of Object.entries(y)) {
|
|
893
|
-
const V = H.find((
|
|
893
|
+
const V = H.find((it) => it.id === D);
|
|
894
894
|
V && (g[V.name] = O);
|
|
895
895
|
}
|
|
896
896
|
} else {
|
|
897
|
-
const y =
|
|
897
|
+
const y = F.getActiveArtboard();
|
|
898
898
|
if (!y) return;
|
|
899
899
|
const D = await et(y.id, h);
|
|
900
900
|
g = { [y.name]: D };
|
|
@@ -918,7 +918,7 @@ const ge = ue((e, t) => {
|
|
|
918
918
|
recoverable: !0
|
|
919
919
|
});
|
|
920
920
|
}
|
|
921
|
-
}, [k, p, kt, tt, G, z, ft, ht, et, bt, rt, yt, H,
|
|
921
|
+
}, [k, p, kt, tt, G, z, ft, ht, et, bt, rt, yt, H, F, q, at, U]);
|
|
922
922
|
C(() => {
|
|
923
923
|
zt !== void 0 && zt > 0 && J.warn(
|
|
924
924
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
@@ -927,18 +927,18 @@ const ge = ue((e, t) => {
|
|
|
927
927
|
}, [q]);
|
|
928
928
|
const Ue = P(() => {
|
|
929
929
|
if (T == null || T(), p) {
|
|
930
|
-
const l =
|
|
930
|
+
const l = F.getActiveArtboard();
|
|
931
931
|
p({ status: "scheduled", artboardId: (l == null ? void 0 : l.id) ?? "unknown" });
|
|
932
932
|
}
|
|
933
|
-
}, [T, p,
|
|
933
|
+
}, [T, p, F]), ze = !!d && d.length > 0, Mt = Mr({
|
|
934
934
|
isCanvasReady: St,
|
|
935
935
|
elements: q,
|
|
936
936
|
hasInitialElements: ze,
|
|
937
937
|
initialElementsLoaded: Be
|
|
938
|
-
}), Zt =
|
|
938
|
+
}), Zt = M(!1);
|
|
939
939
|
C(() => {
|
|
940
|
-
|
|
941
|
-
}, [
|
|
940
|
+
Mt && !Zt.current && (Zt.current = !0, v == null || v());
|
|
941
|
+
}, [Mt, v]), Rr({
|
|
942
942
|
config: at ? {
|
|
943
943
|
enabled: at.enabled ?? !0,
|
|
944
944
|
debounceMs: at.debounceMs ?? 100,
|
|
@@ -952,7 +952,7 @@ const ge = ue((e, t) => {
|
|
|
952
952
|
elements: q,
|
|
953
953
|
onExport: We,
|
|
954
954
|
onExportScheduled: Ue,
|
|
955
|
-
isCanvasReady:
|
|
955
|
+
isCanvasReady: Mt
|
|
956
956
|
// Gate exports until content is fully ready (fonts loaded, elements deserialized)
|
|
957
957
|
}), C(() => {
|
|
958
958
|
if (H.length > 0 && !St) {
|
|
@@ -998,12 +998,12 @@ const ge = ue((e, t) => {
|
|
|
998
998
|
color: "var(--danger, #dc2626)",
|
|
999
999
|
padding: "1rem"
|
|
1000
1000
|
},
|
|
1001
|
-
children: /* @__PURE__ */ Z("div", { className: "text-center", children: [
|
|
1002
|
-
/* @__PURE__ */ w("div", { className: "font-medium", children: "Failed to load image" }),
|
|
1003
|
-
/* @__PURE__ */ w("div", { className: "text-sm mt-1 opacity-70", children: qt.message })
|
|
1001
|
+
children: /* @__PURE__ */ Z("div", { className: "sc:text-center", children: [
|
|
1002
|
+
/* @__PURE__ */ w("div", { className: "sc:font-medium", children: "Failed to load image" }),
|
|
1003
|
+
/* @__PURE__ */ w("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: qt.message })
|
|
1004
1004
|
] })
|
|
1005
1005
|
}
|
|
1006
|
-
) : /* @__PURE__ */ w(ur, { kit:
|
|
1006
|
+
) : /* @__PURE__ */ w(ur, { kit: st, children: /* @__PURE__ */ w("div", { className: `sc-root ${W || ""}`, style: { ...B, position: "relative" }, children: /* @__PURE__ */ Z(
|
|
1007
1007
|
kr,
|
|
1008
1008
|
{
|
|
1009
1009
|
onError: Le,
|
|
@@ -1056,13 +1056,13 @@ const ge = ue((e, t) => {
|
|
|
1056
1056
|
fixedMargin: Ae,
|
|
1057
1057
|
maxHeight: ke,
|
|
1058
1058
|
showRotationHandle: Se,
|
|
1059
|
-
enableShortcuts:
|
|
1059
|
+
enableShortcuts: Fe,
|
|
1060
1060
|
canvasCutouts: Ce,
|
|
1061
1061
|
pieceGuides: jt,
|
|
1062
1062
|
pieceFocus: Ie
|
|
1063
1063
|
}
|
|
1064
1064
|
);
|
|
1065
|
-
return /* @__PURE__ */ w(Er, { kit:
|
|
1065
|
+
return /* @__PURE__ */ w(Er, { kit: st, canvas: Xt || Vt ? /* @__PURE__ */ w("div", { className: Xt, style: Vt, children: l }) : l });
|
|
1066
1066
|
})(),
|
|
1067
1067
|
ut
|
|
1068
1068
|
]
|
|
@@ -1072,11 +1072,11 @@ const ge = ue((e, t) => {
|
|
|
1072
1072
|
ge.displayName = "SnowconeCanvasInner";
|
|
1073
1073
|
const zr = ue((e, t) => {
|
|
1074
1074
|
var c;
|
|
1075
|
-
const { inheritTheme: r, externalProvider: o, services: n } = e, a = e.viewPadding ?? ((c = e.layoutConfig) == null ? void 0 : c.viewPadding),
|
|
1076
|
-
return n ? /* @__PURE__ */ w(fr, { services: n, children:
|
|
1075
|
+
const { inheritTheme: r, externalProvider: o, services: n } = e, a = e.viewPadding ?? ((c = e.layoutConfig) == null ? void 0 : c.viewPadding), s = /* @__PURE__ */ w(ge, { ref: t, ...e }), i = o ? /* @__PURE__ */ w(_t, { defaultTheme: "light", passive: r, children: s }) : /* @__PURE__ */ w(_t, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ w(je, { viewPadding: a, children: s }) });
|
|
1076
|
+
return n ? /* @__PURE__ */ w(fr, { services: n, children: i }) : i;
|
|
1077
1077
|
});
|
|
1078
1078
|
zr.displayName = "SnowconeCanvas";
|
|
1079
|
-
const Lr = 3e3,
|
|
1079
|
+
const Lr = 3e3, ie = {
|
|
1080
1080
|
text: "useTextBinding",
|
|
1081
1081
|
image: "useImageBinding",
|
|
1082
1082
|
font: "useFontBinding"
|
|
@@ -1093,18 +1093,18 @@ function ce(e) {
|
|
|
1093
1093
|
return e instanceof Pt ? "text" : e instanceof Ht ? "image" : "other";
|
|
1094
1094
|
}
|
|
1095
1095
|
function Xr(e, t, r) {
|
|
1096
|
-
const o = `[${
|
|
1097
|
-
if (
|
|
1098
|
-
const d = [...new Set(
|
|
1096
|
+
const o = `[${ie[e]}]`, n = `the binding is dead (isConnected: false, ${Or[e]} is a no-op)`, a = Yr[e], s = r.getAllByName(t);
|
|
1097
|
+
if (s.length > 0) {
|
|
1098
|
+
const d = [...new Set(s.map(ce))], x = a === "text" ? "image" : "text", I = d.length === 1 && d[0] === x ? ` Bind it with ${ie[x]}("${t}") instead.` : "";
|
|
1099
1099
|
return `${o} the layer named "${t}" is ${d.join("/")}, not ${a} — ${n}.${I}`;
|
|
1100
1100
|
}
|
|
1101
|
-
const
|
|
1101
|
+
const i = r.getAll().filter((d) => d.name).map((d) => `"${d.name}" (${ce(d)})`), c = i.length ? `Named layers on this canvas: ${i.join(", ")}. Check the name for a typo.` : `No element on this canvas has a name — name one via design().${a}(…, { name: '${t}' }) or the element's \`name\` property.`;
|
|
1102
1102
|
return `${o} no ${a} layer named "${t}" exists — ${n}. ${c}`;
|
|
1103
1103
|
}
|
|
1104
1104
|
function Wt(e, t, r, o) {
|
|
1105
1105
|
C(() => {
|
|
1106
|
-
var
|
|
1107
|
-
if (o || typeof K > "u" || ((
|
|
1106
|
+
var s;
|
|
1107
|
+
if (o || typeof K > "u" || ((s = K.env) == null ? void 0 : s.NODE_ENV) === "production") return;
|
|
1108
1108
|
const n = `${e}:${t}`;
|
|
1109
1109
|
if (Bt.has(n)) return;
|
|
1110
1110
|
const a = setTimeout(() => {
|
|
@@ -1116,11 +1116,11 @@ function Wt(e, t, r, o) {
|
|
|
1116
1116
|
const Vr = () => {
|
|
1117
1117
|
}, jr = [];
|
|
1118
1118
|
function pn(e) {
|
|
1119
|
-
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((
|
|
1119
|
+
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((s) => s instanceof Pt), [t, e]), n = P(
|
|
1120
1120
|
(a) => {
|
|
1121
|
-
for (const
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1121
|
+
for (const s of o) {
|
|
1122
|
+
const i = s.clone();
|
|
1123
|
+
i.setText(a), r(s, i);
|
|
1124
1124
|
}
|
|
1125
1125
|
},
|
|
1126
1126
|
[o, r]
|
|
@@ -1138,48 +1138,48 @@ const Kr = () => {
|
|
|
1138
1138
|
function qr(e, t, r) {
|
|
1139
1139
|
const o = e / t;
|
|
1140
1140
|
if (r >= o) {
|
|
1141
|
-
const n = t, a = n * r,
|
|
1141
|
+
const n = t, a = n * r, s = e / a;
|
|
1142
1142
|
return {
|
|
1143
1143
|
width: a,
|
|
1144
1144
|
height: n,
|
|
1145
|
-
cropX: (1 -
|
|
1145
|
+
cropX: (1 - s) / 2,
|
|
1146
1146
|
cropY: 0,
|
|
1147
|
-
cropWidth:
|
|
1147
|
+
cropWidth: s,
|
|
1148
1148
|
cropHeight: 1
|
|
1149
1149
|
};
|
|
1150
1150
|
} else {
|
|
1151
|
-
const n = e, a = n / r,
|
|
1151
|
+
const n = e, a = n / r, s = t / a;
|
|
1152
1152
|
return {
|
|
1153
1153
|
width: n,
|
|
1154
1154
|
height: a,
|
|
1155
1155
|
cropX: 0,
|
|
1156
|
-
cropY: (1 -
|
|
1156
|
+
cropY: (1 - s) / 2,
|
|
1157
1157
|
cropWidth: 1,
|
|
1158
|
-
cropHeight:
|
|
1158
|
+
cropHeight: s
|
|
1159
1159
|
};
|
|
1160
1160
|
}
|
|
1161
1161
|
}
|
|
1162
1162
|
function bn(e, t) {
|
|
1163
|
-
const r = (t == null ? void 0 : t.fit) ?? "cover", { elementStore: o, setElements: n } = dt(), { executeElementUpdate: a } = At(),
|
|
1164
|
-
for (const R of
|
|
1165
|
-
if (!
|
|
1163
|
+
const r = (t == null ? void 0 : t.fit) ?? "cover", { elementStore: o, setElements: n } = dt(), { executeElementUpdate: a } = At(), s = ot(() => o.getAllByName(e).filter((k) => k instanceof Ht), [o, e]), i = M(/* @__PURE__ */ new Map());
|
|
1164
|
+
for (const R of s)
|
|
1165
|
+
if (!i.current.has(R.id)) {
|
|
1166
1166
|
const k = R.transformData;
|
|
1167
|
-
|
|
1167
|
+
i.current.set(R.id, {
|
|
1168
1168
|
width: k.width * k.cropWidth,
|
|
1169
1169
|
height: k.height * k.cropHeight
|
|
1170
1170
|
});
|
|
1171
1171
|
}
|
|
1172
|
-
const c =
|
|
1173
|
-
c.current =
|
|
1174
|
-
const d =
|
|
1172
|
+
const c = M(s);
|
|
1173
|
+
c.current = s;
|
|
1174
|
+
const d = M(a);
|
|
1175
1175
|
d.current = a;
|
|
1176
|
-
const x =
|
|
1176
|
+
const x = M(n);
|
|
1177
1177
|
x.current = n;
|
|
1178
1178
|
const I = P(
|
|
1179
1179
|
(R) => {
|
|
1180
1180
|
const k = c.current, T = d.current;
|
|
1181
1181
|
for (const p of k) {
|
|
1182
|
-
const N =
|
|
1182
|
+
const N = i.current.get(p.id);
|
|
1183
1183
|
if (!N) continue;
|
|
1184
1184
|
const { width: S, height: b } = N, E = p.clone();
|
|
1185
1185
|
E.imageLoaded = !1, E.imageElement = null, E.isCropping = !1, E.imageUrl = R, r === "cover" ? (E.preserveDimensions = !0, E.onLoadCallback = (v) => {
|
|
@@ -1194,11 +1194,11 @@ function bn(e, t) {
|
|
|
1194
1194
|
[r]
|
|
1195
1195
|
// Stable deps only — imageElements/executeElementUpdate/setElements accessed via refs
|
|
1196
1196
|
);
|
|
1197
|
-
return Wt("image", e, o,
|
|
1198
|
-
imageUrl:
|
|
1197
|
+
return Wt("image", e, o, s.length > 0), s.length === 0 ? { imageUrl: "", setImageUrl: Kr, element: null, elements: Gr, isConnected: !1 } : {
|
|
1198
|
+
imageUrl: s[0].imageUrl,
|
|
1199
1199
|
setImageUrl: I,
|
|
1200
|
-
element:
|
|
1201
|
-
elements:
|
|
1200
|
+
element: s[0],
|
|
1201
|
+
elements: s,
|
|
1202
1202
|
isConnected: !0
|
|
1203
1203
|
};
|
|
1204
1204
|
}
|
|
@@ -1216,15 +1216,15 @@ function pe(e, t) {
|
|
|
1216
1216
|
return j(r.color, t) || j((o = r.transformData) == null ? void 0 : o.fillColor, t) || j((n = r.transformData) == null ? void 0 : n.strokeColor, t) || ((a = r.stroke) == null ? void 0 : a.enabled) === !0 && j(r.stroke.color, t);
|
|
1217
1217
|
}
|
|
1218
1218
|
function Qr(e, t, r) {
|
|
1219
|
-
var
|
|
1219
|
+
var s, i, c;
|
|
1220
1220
|
if (!pe(e, t)) return null;
|
|
1221
1221
|
const o = e.clone(), n = e, a = o;
|
|
1222
|
-
return j(n.color, t) && (typeof a.setColor == "function" ? a.setColor(r) : a.color = r), j((
|
|
1222
|
+
return j(n.color, t) && (typeof a.setColor == "function" ? a.setColor(r) : a.color = r), j((s = n.transformData) == null ? void 0 : s.fillColor, t) && (a.transformData = { ...a.transformData, fillColor: r }), j((i = n.transformData) == null ? void 0 : i.strokeColor, t) && (a.transformData = { ...a.transformData, strokeColor: r }), ((c = n.stroke) == null ? void 0 : c.enabled) === !0 && j(n.stroke.color, t) && (a.stroke = { ...a.stroke, color: r }), o;
|
|
1223
1223
|
}
|
|
1224
1224
|
function yn(e) {
|
|
1225
|
-
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), [o, n] = _(() => Et(e)), [a,
|
|
1226
|
-
e !== a && (
|
|
1227
|
-
const
|
|
1225
|
+
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), [o, n] = _(() => Et(e)), [a, s] = _(e);
|
|
1226
|
+
e !== a && (s(e), n(Et(e)));
|
|
1227
|
+
const i = ot(
|
|
1228
1228
|
() => t.getAll().filter((d) => pe(d, o)),
|
|
1229
1229
|
[t, o]
|
|
1230
1230
|
), c = P(
|
|
@@ -1240,19 +1240,19 @@ function yn(e) {
|
|
|
1240
1240
|
},
|
|
1241
1241
|
[t, o, r]
|
|
1242
1242
|
);
|
|
1243
|
-
return
|
|
1243
|
+
return i.length === 0 ? { color: o, setColor: c, elements: Jr, isConnected: !1 } : { color: o, setColor: c, elements: i, isConnected: !0 };
|
|
1244
1244
|
}
|
|
1245
1245
|
const Zr = () => {
|
|
1246
1246
|
}, _r = [];
|
|
1247
1247
|
function xn(e) {
|
|
1248
|
-
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((
|
|
1248
|
+
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((s) => s instanceof Pt), [t, e]), n = P(
|
|
1249
1249
|
(a) => {
|
|
1250
1250
|
mr.loadGoogleFontByName(a);
|
|
1251
|
-
for (const
|
|
1252
|
-
if (
|
|
1253
|
-
Ye.clearCache(
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1251
|
+
for (const s of o) {
|
|
1252
|
+
if (s.fontFamily === a) continue;
|
|
1253
|
+
Ye.clearCache(s.fontFamily);
|
|
1254
|
+
const i = s.clone();
|
|
1255
|
+
i.fontFamily = a, r(s, i);
|
|
1256
1256
|
}
|
|
1257
1257
|
},
|
|
1258
1258
|
[o, r]
|
|
@@ -1287,8 +1287,8 @@ function en(e) {
|
|
|
1287
1287
|
var o;
|
|
1288
1288
|
const t = (o = e.artboards) != null && o.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], r = t.map(() => []);
|
|
1289
1289
|
for (const n of e.elements || []) {
|
|
1290
|
-
const a = n == null ? void 0 : n.artboard,
|
|
1291
|
-
r[
|
|
1290
|
+
const a = n == null ? void 0 : n.artboard, s = typeof a == "string" ? t.findIndex((i) => (i.name || "Front") === a) : -1;
|
|
1291
|
+
r[s >= 0 ? s : 0].push(rn(n));
|
|
1292
1292
|
}
|
|
1293
1293
|
return {
|
|
1294
1294
|
schemaVersion: tn,
|
|
@@ -1323,18 +1323,18 @@ function rn(e) {
|
|
|
1323
1323
|
}
|
|
1324
1324
|
function nn(e) {
|
|
1325
1325
|
var d;
|
|
1326
|
-
const t = e.transformData || {}, r = e.masks && e.masks.length > 0, o = t.width || 0, n = t.height || 0, a = r ? o : o * (t.cropWidth ?? 1),
|
|
1326
|
+
const t = e.transformData || {}, r = e.masks && e.masks.length > 0, o = t.width || 0, n = t.height || 0, a = r ? o : o * (t.cropWidth ?? 1), s = r ? n : n * (t.cropHeight ?? 1), i = {
|
|
1327
1327
|
id: e.id,
|
|
1328
1328
|
type: "image",
|
|
1329
1329
|
x: e.x || 0,
|
|
1330
1330
|
y: e.y || 0,
|
|
1331
1331
|
width: a,
|
|
1332
|
-
height:
|
|
1332
|
+
height: s,
|
|
1333
1333
|
rotation: e.rotation || 0,
|
|
1334
1334
|
imageUrl: e.imageUrl,
|
|
1335
1335
|
imageAspectRatio: e.imageAspectRatio
|
|
1336
1336
|
};
|
|
1337
|
-
return !r && (t.cropX !== 0 || t.cropY !== 0 || t.cropWidth !== 1 || t.cropHeight !== 1) && (
|
|
1337
|
+
return !r && (t.cropX !== 0 || t.cropY !== 0 || t.cropWidth !== 1 || t.cropHeight !== 1) && (i.cropX = t.cropX, i.cropY = t.cropY, i.cropWidth = t.cropWidth, i.cropHeight = t.cropHeight, i.needsCropPixelConversion = !0), t.flipHorizontal && (i.flipHorizontal = t.flipHorizontal), t.flipVertical && (i.flipVertical = t.flipVertical), t.borderRadius && (i.borderRadius = t.borderRadius), e.opacity !== void 0 && (i.opacity = e.opacity), e.distressEffect && (i.distressEffect = e.distressEffect), ((d = e.masks) == null ? void 0 : d.length) > 0 && (i.masks = e.masks), e.blendMode && (i.blendMode = e.blendMode), e.knockoutParts && (i.knockoutParts = e.knockoutParts), e.stroke && (i.stroke = e.stroke), be(i);
|
|
1338
1338
|
}
|
|
1339
1339
|
const le = "center";
|
|
1340
1340
|
function on(e) {
|
|
@@ -1344,19 +1344,19 @@ function an(e) {
|
|
|
1344
1344
|
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1345
1345
|
}
|
|
1346
1346
|
function $t(e, t, r, o, n, a) {
|
|
1347
|
-
const
|
|
1347
|
+
const s = on(e), i = an(e), c = s === "left" ? t / 2 + a : s === "right" ? o - t / 2 - a : o / 2, d = i === "top" ? r / 2 + a : i === "bottom" ? n - r / 2 - a : n / 2;
|
|
1348
1348
|
return { x: c, y: d };
|
|
1349
1349
|
}
|
|
1350
1350
|
function sn(e, t, r) {
|
|
1351
1351
|
const o = t / r;
|
|
1352
1352
|
if (e >= o) {
|
|
1353
|
-
const
|
|
1353
|
+
const s = r * e, i = t / s;
|
|
1354
1354
|
return {
|
|
1355
|
-
width:
|
|
1355
|
+
width: s,
|
|
1356
1356
|
height: r,
|
|
1357
|
-
cropX: (1 -
|
|
1357
|
+
cropX: (1 - i) / 2,
|
|
1358
1358
|
cropY: 0,
|
|
1359
|
-
cropWidth:
|
|
1359
|
+
cropWidth: i,
|
|
1360
1360
|
cropHeight: 1
|
|
1361
1361
|
};
|
|
1362
1362
|
}
|
|
@@ -1415,15 +1415,15 @@ class Ut {
|
|
|
1415
1415
|
const { width: o, height: n } = this.artboard;
|
|
1416
1416
|
let a;
|
|
1417
1417
|
if (r.aspectRatio && r.aspectRatio > 0) {
|
|
1418
|
-
const
|
|
1418
|
+
const i = sn(r.aspectRatio, o, n);
|
|
1419
1419
|
a = {
|
|
1420
1420
|
type: "image",
|
|
1421
|
-
width:
|
|
1422
|
-
height:
|
|
1423
|
-
cropX:
|
|
1424
|
-
cropY:
|
|
1425
|
-
cropWidth:
|
|
1426
|
-
cropHeight:
|
|
1421
|
+
width: i.width,
|
|
1422
|
+
height: i.height,
|
|
1423
|
+
cropX: i.cropX,
|
|
1424
|
+
cropY: i.cropY,
|
|
1425
|
+
cropWidth: i.cropWidth,
|
|
1426
|
+
cropHeight: i.cropHeight,
|
|
1427
1427
|
flipHorizontal: !1,
|
|
1428
1428
|
flipVertical: !1,
|
|
1429
1429
|
borderRadius: 0
|
|
@@ -1441,7 +1441,7 @@ class Ut {
|
|
|
1441
1441
|
flipVertical: !1,
|
|
1442
1442
|
borderRadius: 0
|
|
1443
1443
|
};
|
|
1444
|
-
const
|
|
1444
|
+
const s = {
|
|
1445
1445
|
id: this.nextId("bg"),
|
|
1446
1446
|
transformType: "image",
|
|
1447
1447
|
x: o / 2,
|
|
@@ -1453,14 +1453,14 @@ class Ut {
|
|
|
1453
1453
|
transformData: a,
|
|
1454
1454
|
name: r.name ?? "Background"
|
|
1455
1455
|
};
|
|
1456
|
-
return this.els.unshift(
|
|
1456
|
+
return this.els.unshift(s), this;
|
|
1457
1457
|
}
|
|
1458
1458
|
/** An anchored image element (not full-bleed). */
|
|
1459
1459
|
image(t, r = {}) {
|
|
1460
|
-
const { width: o, height: n } = this.artboard, a = r.width ?? Math.round(o / 3),
|
|
1460
|
+
const { width: o, height: n } = this.artboard, a = r.width ?? Math.round(o / 3), s = r.height ?? (r.aspectRatio ? Math.round(a / r.aspectRatio) : a), { x: i, y: c } = $t(r.anchor ?? le, a, s, o, n, r.padding ?? 0), d = {
|
|
1461
1461
|
id: this.nextId("img"),
|
|
1462
1462
|
transformType: "image",
|
|
1463
|
-
x:
|
|
1463
|
+
x: i,
|
|
1464
1464
|
y: c,
|
|
1465
1465
|
rotation: r.rotation ?? 0,
|
|
1466
1466
|
opacity: r.opacity ?? 1,
|
|
@@ -1469,7 +1469,7 @@ class Ut {
|
|
|
1469
1469
|
transformData: {
|
|
1470
1470
|
type: "image",
|
|
1471
1471
|
width: a,
|
|
1472
|
-
height:
|
|
1472
|
+
height: s,
|
|
1473
1473
|
cropX: 0,
|
|
1474
1474
|
cropY: 0,
|
|
1475
1475
|
cropWidth: 1,
|
|
@@ -1485,11 +1485,11 @@ class Ut {
|
|
|
1485
1485
|
/** An anchored text layer. Horizontal centring is exact (textAlign); vertical
|
|
1486
1486
|
* anchoring uses the font size as the line-height estimate. */
|
|
1487
1487
|
text(t, r = {}) {
|
|
1488
|
-
const { width: o, height: n } = this.artboard, a = r.fontSize ?? Math.round(this.artboard.height / 12), { x:
|
|
1488
|
+
const { width: o, height: n } = this.artboard, a = r.fontSize ?? Math.round(this.artboard.height / 12), { x: s, y: i } = $t(r.anchor ?? "top", 0, a, o, n, r.padding ?? Math.round(n / 20)), c = {
|
|
1489
1489
|
id: this.nextId("text"),
|
|
1490
1490
|
transformType: "custom",
|
|
1491
|
-
x:
|
|
1492
|
-
y:
|
|
1491
|
+
x: s,
|
|
1492
|
+
y: i,
|
|
1493
1493
|
rotation: r.rotation ?? 0,
|
|
1494
1494
|
text: t,
|
|
1495
1495
|
fontSize: a,
|
|
@@ -1505,11 +1505,11 @@ class Ut {
|
|
|
1505
1505
|
}
|
|
1506
1506
|
/** An anchored vector shape. */
|
|
1507
1507
|
shape(t, r = {}) {
|
|
1508
|
-
const { width: o, height: n } = this.artboard, a = r.size ?? Math.round(o / 6),
|
|
1508
|
+
const { width: o, height: n } = this.artboard, a = r.size ?? Math.round(o / 6), s = typeof a == "number" ? a : a.width, i = typeof a == "number" ? a : a.height, { x: c, y: d } = $t(r.anchor ?? le, s, i, o, n, r.padding ?? 0), x = {
|
|
1509
1509
|
type: "shape",
|
|
1510
1510
|
shapeType: t,
|
|
1511
|
-
width:
|
|
1512
|
-
height:
|
|
1511
|
+
width: s,
|
|
1512
|
+
height: i,
|
|
1513
1513
|
fillColor: r.fill ?? "#000000",
|
|
1514
1514
|
fillOpacity: r.opacity ?? 1,
|
|
1515
1515
|
...r.points !== void 0 ? { points: r.points } : {},
|
|
@@ -1613,7 +1613,7 @@ export {
|
|
|
1613
1613
|
ye as T,
|
|
1614
1614
|
yn as a,
|
|
1615
1615
|
xr as b,
|
|
1616
|
-
|
|
1616
|
+
Mr as c,
|
|
1617
1617
|
wn as d,
|
|
1618
1618
|
vn as e,
|
|
1619
1619
|
xn as f,
|
|
@@ -1624,4 +1624,4 @@ export {
|
|
|
1624
1624
|
Rr as u,
|
|
1625
1625
|
An as w
|
|
1626
1626
|
};
|
|
1627
|
-
//# sourceMappingURL=template-fields-
|
|
1627
|
+
//# sourceMappingURL=template-fields-Dw-KK9DX.js.map
|