@snowcone-app/canvas 0.13.1 → 0.15.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/CanvasStateV1-BQD8fCBU.js +3699 -0
- package/dist/CanvasStateV1-BQD8fCBU.js.map +1 -0
- package/dist/advanced.mjs +323 -327
- package/dist/advanced.mjs.map +1 -1
- package/dist/api/embed.d.ts +14 -0
- package/dist/components/VisualGuideOverlay.d.ts +1 -1
- package/dist/components/embed-realtime/RealtimeCanvas.d.ts +24 -1
- package/dist/components/ui/index.d.ts +34 -34
- package/dist/embed.mjs +171 -156
- package/dist/embed.mjs.map +1 -1
- package/dist/index.mjs +47 -51
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/{template-fields-IgDV7PRY.js → template-fields-coO73lV3.js} +245 -240
- package/dist/template-fields-coO73lV3.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/CanvasStateV1-CKsfggNP.js +0 -456
- package/dist/CanvasStateV1-CKsfggNP.js.map +0 -1
- package/dist/schemas-B4UXytQB.js +0 -3250
- package/dist/schemas-B4UXytQB.js.map +0 -1
- 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,29 +1,29 @@
|
|
|
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
|
-
import { jsxs as Z, jsx as w, Fragment as
|
|
3
|
-
import { useCallback as P, useMemo as ot, useRef as
|
|
4
|
-
import { u as
|
|
5
|
-
import {
|
|
2
|
+
import { jsxs as Z, jsx as w, Fragment as ue } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback as P, useMemo as ot, useRef as M, useEffect as C, Component as Xe, useState as _, forwardRef as fe, useImperativeHandle as Ve } from "react";
|
|
4
|
+
import { u as Wt, T as te, E as je, c as dt, b as At } from "./ThemeContext-Cl1JPVLZ.js";
|
|
5
|
+
import { aq as ee, ar as re, ag as Ke, ah as ne, 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 oe, 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
|
-
import {
|
|
8
|
-
const
|
|
7
|
+
import { a as pr, o as ct, b as $, n as br, l as Y, u as ae, c as yr } from "./CanvasStateV1-BQD8fCBU.js";
|
|
8
|
+
const se = nt("useCommands");
|
|
9
9
|
function xr() {
|
|
10
|
-
const e =
|
|
10
|
+
const e = Wt(), {
|
|
11
11
|
undo: t,
|
|
12
12
|
redo: r,
|
|
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,
|
|
21
21
|
executeDeleteArtboard: I,
|
|
22
22
|
executeUpdateArtboard: R
|
|
23
23
|
} = e, k = P(() => {
|
|
24
|
-
|
|
24
|
+
se.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
|
|
25
25
|
}, []), T = P((p) => {
|
|
26
|
-
|
|
26
|
+
se.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
|
|
27
27
|
}, []);
|
|
28
28
|
return {
|
|
29
29
|
// Undo/Redo
|
|
@@ -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,
|
|
@@ -50,9 +50,9 @@ const vr = () => {
|
|
|
50
50
|
const { undo: e, redo: t, canUndo: r, canRedo: o } = xr();
|
|
51
51
|
return /* @__PURE__ */ Z("div", { className: "sc-undo-redo", style: { display: "inline-flex", gap: 4 }, children: [
|
|
52
52
|
/* @__PURE__ */ w(
|
|
53
|
-
|
|
53
|
+
ee,
|
|
54
54
|
{
|
|
55
|
-
icon:
|
|
55
|
+
icon: re.undo,
|
|
56
56
|
onClick: e,
|
|
57
57
|
disabled: !r,
|
|
58
58
|
tooltip: "Undo",
|
|
@@ -60,9 +60,9 @@ const vr = () => {
|
|
|
60
60
|
}
|
|
61
61
|
),
|
|
62
62
|
/* @__PURE__ */ w(
|
|
63
|
-
|
|
63
|
+
ee,
|
|
64
64
|
{
|
|
65
|
-
icon:
|
|
65
|
+
icon: re.redo,
|
|
66
66
|
onClick: t,
|
|
67
67
|
disabled: !o,
|
|
68
68
|
tooltip: "Redo",
|
|
@@ -82,14 +82,14 @@ function wr() {
|
|
|
82
82
|
ArtboardTabs: tr,
|
|
83
83
|
ContextualToolbars: er,
|
|
84
84
|
ZoomControls: rr,
|
|
85
|
-
MenuButton:
|
|
85
|
+
MenuButton: oe,
|
|
86
86
|
CropPanel: nr
|
|
87
|
-
}),
|
|
88
|
-
component:
|
|
87
|
+
}), ne("add-element-menu", {
|
|
88
|
+
component: oe,
|
|
89
89
|
label: "Add Element",
|
|
90
90
|
icon: "gravity-ui:plus",
|
|
91
91
|
position: "topbar"
|
|
92
|
-
}),
|
|
92
|
+
}), ne("undo-redo-controls", {
|
|
93
93
|
component: vr,
|
|
94
94
|
label: "Undo / Redo",
|
|
95
95
|
icon: "lucide:undo-2",
|
|
@@ -97,7 +97,7 @@ function wr() {
|
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
99
99
|
function wt({ ids: e }) {
|
|
100
|
-
return !e || e.length === 0 ? null : /* @__PURE__ */ w(
|
|
100
|
+
return !e || e.length === 0 ? null : /* @__PURE__ */ w(ue, { children: e.map((t) => {
|
|
101
101
|
var n;
|
|
102
102
|
if (t === lt) return null;
|
|
103
103
|
const r = Ge(t);
|
|
@@ -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(ue, { 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,17 +573,17 @@ 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
|
-
const ge =
|
|
579
|
+
const ge = fe((e, t) => {
|
|
580
580
|
const {
|
|
581
581
|
exportConfig: r,
|
|
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,
|
|
604
|
+
} = e, Lt = 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), Ot = e.initialImageAlignment ?? (o == null ? void 0 : o.alignment) ?? "center", Yt = e.initialImageScale ?? (o == null ? void 0 : o.scale) ?? 1, Xt = 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, Vt = e.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), jt = e.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), Ce = e.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), Kt = 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;
|
|
@@ -621,13 +621,13 @@ const ge = ue((e, t) => {
|
|
|
621
621
|
const {
|
|
622
622
|
elements: q,
|
|
623
623
|
setElements: gt,
|
|
624
|
-
selectedId:
|
|
625
|
-
artboardManager:
|
|
626
|
-
refreshArtboards:
|
|
624
|
+
selectedId: Gt,
|
|
625
|
+
artboardManager: F,
|
|
626
|
+
refreshArtboards: Me,
|
|
627
627
|
historyManager: Te,
|
|
628
628
|
isCanvasReady: St,
|
|
629
629
|
setCanvasReady: pt
|
|
630
|
-
} =
|
|
630
|
+
} = Wt(), { createArtboard: De, selectArtboard: Ne, artboards: H } = cr(), { exportArtboard: et, exportAllArtboards: bt, exportArtboardAsBlob: rt, exportAllArtboardsAsBlobs: yt } = lr();
|
|
631
631
|
Ve(t, () => ({
|
|
632
632
|
exportArtboards: async (l = {}) => {
|
|
633
633
|
const u = l.format || tt, A = l.scale || G, f = l.all ?? !1;
|
|
@@ -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,14 +671,14 @@ 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 [
|
|
674
|
+
}, [N, et, rt, F, tt, G, z]);
|
|
675
|
+
const [qt, xt] = _("idle"), [Jt, Rt] = _(null), Ct = M(void 0), It = M(!1), Qt = 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
|
-
const A = l[0], f = u[0], m =
|
|
681
|
+
const A = l[0], f = u[0], m = Kt ? "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);
|
|
683
683
|
for (let h = 1; h < l.length; h++)
|
|
684
684
|
De(l[h].width, l[h].height, {
|
|
@@ -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
|
-
if (!(!d || d.length === 0) && !
|
|
695
|
-
|
|
694
|
+
if (!(!d || d.length === 0) && !Qt.current && It.current) {
|
|
695
|
+
Qt.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) || Xt, h = await Wr(
|
|
778
778
|
L,
|
|
779
779
|
{
|
|
780
780
|
artboard: {
|
|
@@ -783,8 +783,8 @@ const ge = ue((e, t) => {
|
|
|
783
783
|
x: f.x,
|
|
784
784
|
y: f.y
|
|
785
785
|
},
|
|
786
|
-
alignment: (m == null ? void 0 : m.fitAlign) ||
|
|
787
|
-
scale:
|
|
786
|
+
alignment: (m == null ? void 0 : m.fitAlign) || Ot,
|
|
787
|
+
scale: Yt,
|
|
788
788
|
scaleMode: g,
|
|
789
789
|
marginTop: m == null ? void 0 : m.fitMarginTop,
|
|
790
790
|
marginRight: m == null ? void 0 : m.fitMarginRight,
|
|
@@ -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);
|
|
@@ -815,17 +815,17 @@ const ge = ue((e, t) => {
|
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
817
|
})();
|
|
818
|
-
}, [L,
|
|
819
|
-
const vt =
|
|
818
|
+
}, [L, Ot, Yt, Xt]);
|
|
819
|
+
const vt = M(I);
|
|
820
820
|
vt.current = I, C(() => {
|
|
821
821
|
var l;
|
|
822
|
-
(l = vt.current) == null || l.call(vt,
|
|
823
|
-
}, [
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
const l =
|
|
822
|
+
(l = vt.current) == null || l.call(vt, Gt);
|
|
823
|
+
}, [Gt]);
|
|
824
|
+
const Zt = M(x);
|
|
825
|
+
Zt.current = x, C(() => {
|
|
826
|
+
const l = Zt.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,27 +918,27 @@ 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
|
+
Lt !== void 0 && Lt > 0 && J.warn(
|
|
924
924
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
925
925
|
);
|
|
926
926
|
}, []), C(() => {
|
|
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
|
-
}),
|
|
938
|
+
}), _t = M(!1);
|
|
939
939
|
C(() => {
|
|
940
|
-
|
|
941
|
-
}, [
|
|
940
|
+
Mt && !_t.current && (_t.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) {
|
|
@@ -972,7 +972,7 @@ const ge = ue((e, t) => {
|
|
|
972
972
|
recoverable: !1
|
|
973
973
|
});
|
|
974
974
|
}, [U]);
|
|
975
|
-
return
|
|
975
|
+
return qt === "loading" ? /* @__PURE__ */ w(
|
|
976
976
|
"div",
|
|
977
977
|
{
|
|
978
978
|
className: W,
|
|
@@ -985,7 +985,7 @@ const ge = ue((e, t) => {
|
|
|
985
985
|
},
|
|
986
986
|
children: /* @__PURE__ */ w(dr, { size: 48 })
|
|
987
987
|
}
|
|
988
|
-
) :
|
|
988
|
+
) : qt === "error" && Jt ? /* @__PURE__ */ w(
|
|
989
989
|
"div",
|
|
990
990
|
{
|
|
991
991
|
className: W,
|
|
@@ -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:
|
|
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: Jt.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
|
-
pieceGuides:
|
|
1061
|
+
pieceGuides: Kt,
|
|
1062
1062
|
pieceFocus: Ie
|
|
1063
1063
|
}
|
|
1064
1064
|
);
|
|
1065
|
-
return /* @__PURE__ */ w(Er, { kit:
|
|
1065
|
+
return /* @__PURE__ */ w(Er, { kit: st, canvas: Vt || jt ? /* @__PURE__ */ w("div", { className: Vt, style: jt, children: l }) : l });
|
|
1066
1066
|
})(),
|
|
1067
1067
|
ut
|
|
1068
1068
|
]
|
|
@@ -1070,13 +1070,17 @@ const ge = ue((e, t) => {
|
|
|
1070
1070
|
) }) });
|
|
1071
1071
|
});
|
|
1072
1072
|
ge.displayName = "SnowconeCanvasInner";
|
|
1073
|
-
const zr =
|
|
1073
|
+
const zr = fe((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(te, { defaultTheme: "light", passive: r, children: s }) : /* @__PURE__ */ w(te, { 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
|
-
|
|
1079
|
+
function pn() {
|
|
1080
|
+
const { selectedElement: e } = Wt();
|
|
1081
|
+
return e ?? null;
|
|
1082
|
+
}
|
|
1083
|
+
const Lr = 3e3, ce = {
|
|
1080
1084
|
text: "useTextBinding",
|
|
1081
1085
|
image: "useImageBinding",
|
|
1082
1086
|
font: "useFontBinding"
|
|
@@ -1089,22 +1093,22 @@ const Lr = 3e3, se = {
|
|
|
1089
1093
|
image: "image",
|
|
1090
1094
|
font: "text"
|
|
1091
1095
|
}, Bt = /* @__PURE__ */ new Set();
|
|
1092
|
-
function
|
|
1096
|
+
function le(e) {
|
|
1093
1097
|
return e instanceof Pt ? "text" : e instanceof Ht ? "image" : "other";
|
|
1094
1098
|
}
|
|
1095
1099
|
function Xr(e, t, r) {
|
|
1096
|
-
const o = `[${
|
|
1097
|
-
if (
|
|
1098
|
-
const d = [...new Set(
|
|
1100
|
+
const o = `[${ce[e]}]`, n = `the binding is dead (isConnected: false, ${Or[e]} is a no-op)`, a = Yr[e], s = r.getAllByName(t);
|
|
1101
|
+
if (s.length > 0) {
|
|
1102
|
+
const d = [...new Set(s.map(le))], x = a === "text" ? "image" : "text", I = d.length === 1 && d[0] === x ? ` Bind it with ${ce[x]}("${t}") instead.` : "";
|
|
1099
1103
|
return `${o} the layer named "${t}" is ${d.join("/")}, not ${a} — ${n}.${I}`;
|
|
1100
1104
|
}
|
|
1101
|
-
const
|
|
1105
|
+
const i = r.getAll().filter((d) => d.name).map((d) => `"${d.name}" (${le(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
1106
|
return `${o} no ${a} layer named "${t}" exists — ${n}. ${c}`;
|
|
1103
1107
|
}
|
|
1104
|
-
function
|
|
1108
|
+
function Ut(e, t, r, o) {
|
|
1105
1109
|
C(() => {
|
|
1106
|
-
var
|
|
1107
|
-
if (o || typeof K > "u" || ((
|
|
1110
|
+
var s;
|
|
1111
|
+
if (o || typeof K > "u" || ((s = K.env) == null ? void 0 : s.NODE_ENV) === "production") return;
|
|
1108
1112
|
const n = `${e}:${t}`;
|
|
1109
1113
|
if (Bt.has(n)) return;
|
|
1110
1114
|
const a = setTimeout(() => {
|
|
@@ -1115,17 +1119,17 @@ function Wt(e, t, r, o) {
|
|
|
1115
1119
|
}
|
|
1116
1120
|
const Vr = () => {
|
|
1117
1121
|
}, jr = [];
|
|
1118
|
-
function
|
|
1119
|
-
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((
|
|
1122
|
+
function bn(e) {
|
|
1123
|
+
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((s) => s instanceof Pt), [t, e]), n = P(
|
|
1120
1124
|
(a) => {
|
|
1121
|
-
for (const
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1125
|
+
for (const s of o) {
|
|
1126
|
+
const i = s.clone();
|
|
1127
|
+
i.setText(a), r(s, i);
|
|
1124
1128
|
}
|
|
1125
1129
|
},
|
|
1126
1130
|
[o, r]
|
|
1127
1131
|
);
|
|
1128
|
-
return
|
|
1132
|
+
return Ut("text", e, t, o.length > 0), o.length === 0 ? { text: "", setText: Vr, element: null, elements: jr, isConnected: !1 } : {
|
|
1129
1133
|
text: o[0].getText(),
|
|
1130
1134
|
setText: n,
|
|
1131
1135
|
element: o[0],
|
|
@@ -1138,48 +1142,48 @@ const Kr = () => {
|
|
|
1138
1142
|
function qr(e, t, r) {
|
|
1139
1143
|
const o = e / t;
|
|
1140
1144
|
if (r >= o) {
|
|
1141
|
-
const n = t, a = n * r,
|
|
1145
|
+
const n = t, a = n * r, s = e / a;
|
|
1142
1146
|
return {
|
|
1143
1147
|
width: a,
|
|
1144
1148
|
height: n,
|
|
1145
|
-
cropX: (1 -
|
|
1149
|
+
cropX: (1 - s) / 2,
|
|
1146
1150
|
cropY: 0,
|
|
1147
|
-
cropWidth:
|
|
1151
|
+
cropWidth: s,
|
|
1148
1152
|
cropHeight: 1
|
|
1149
1153
|
};
|
|
1150
1154
|
} else {
|
|
1151
|
-
const n = e, a = n / r,
|
|
1155
|
+
const n = e, a = n / r, s = t / a;
|
|
1152
1156
|
return {
|
|
1153
1157
|
width: n,
|
|
1154
1158
|
height: a,
|
|
1155
1159
|
cropX: 0,
|
|
1156
|
-
cropY: (1 -
|
|
1160
|
+
cropY: (1 - s) / 2,
|
|
1157
1161
|
cropWidth: 1,
|
|
1158
|
-
cropHeight:
|
|
1162
|
+
cropHeight: s
|
|
1159
1163
|
};
|
|
1160
1164
|
}
|
|
1161
1165
|
}
|
|
1162
|
-
function
|
|
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 (!
|
|
1166
|
+
function yn(e, t) {
|
|
1167
|
+
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());
|
|
1168
|
+
for (const R of s)
|
|
1169
|
+
if (!i.current.has(R.id)) {
|
|
1166
1170
|
const k = R.transformData;
|
|
1167
|
-
|
|
1171
|
+
i.current.set(R.id, {
|
|
1168
1172
|
width: k.width * k.cropWidth,
|
|
1169
1173
|
height: k.height * k.cropHeight
|
|
1170
1174
|
});
|
|
1171
1175
|
}
|
|
1172
|
-
const c =
|
|
1173
|
-
c.current =
|
|
1174
|
-
const d =
|
|
1176
|
+
const c = M(s);
|
|
1177
|
+
c.current = s;
|
|
1178
|
+
const d = M(a);
|
|
1175
1179
|
d.current = a;
|
|
1176
|
-
const x =
|
|
1180
|
+
const x = M(n);
|
|
1177
1181
|
x.current = n;
|
|
1178
1182
|
const I = P(
|
|
1179
1183
|
(R) => {
|
|
1180
1184
|
const k = c.current, T = d.current;
|
|
1181
1185
|
for (const p of k) {
|
|
1182
|
-
const N =
|
|
1186
|
+
const N = i.current.get(p.id);
|
|
1183
1187
|
if (!N) continue;
|
|
1184
1188
|
const { width: S, height: b } = N, E = p.clone();
|
|
1185
1189
|
E.imageLoaded = !1, E.imageElement = null, E.isCropping = !1, E.imageUrl = R, r === "cover" ? (E.preserveDimensions = !0, E.onLoadCallback = (v) => {
|
|
@@ -1194,11 +1198,11 @@ function bn(e, t) {
|
|
|
1194
1198
|
[r]
|
|
1195
1199
|
// Stable deps only — imageElements/executeElementUpdate/setElements accessed via refs
|
|
1196
1200
|
);
|
|
1197
|
-
return
|
|
1198
|
-
imageUrl:
|
|
1201
|
+
return Ut("image", e, o, s.length > 0), s.length === 0 ? { imageUrl: "", setImageUrl: Kr, element: null, elements: Gr, isConnected: !1 } : {
|
|
1202
|
+
imageUrl: s[0].imageUrl,
|
|
1199
1203
|
setImageUrl: I,
|
|
1200
|
-
element:
|
|
1201
|
-
elements:
|
|
1204
|
+
element: s[0],
|
|
1205
|
+
elements: s,
|
|
1202
1206
|
isConnected: !0
|
|
1203
1207
|
};
|
|
1204
1208
|
}
|
|
@@ -1216,15 +1220,15 @@ function pe(e, t) {
|
|
|
1216
1220
|
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
1221
|
}
|
|
1218
1222
|
function Qr(e, t, r) {
|
|
1219
|
-
var
|
|
1223
|
+
var s, i, c;
|
|
1220
1224
|
if (!pe(e, t)) return null;
|
|
1221
1225
|
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((
|
|
1226
|
+
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
1227
|
}
|
|
1224
|
-
function
|
|
1225
|
-
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), [o, n] = _(() => Et(e)), [a,
|
|
1226
|
-
e !== a && (
|
|
1227
|
-
const
|
|
1228
|
+
function xn(e) {
|
|
1229
|
+
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), [o, n] = _(() => Et(e)), [a, s] = _(e);
|
|
1230
|
+
e !== a && (s(e), n(Et(e)));
|
|
1231
|
+
const i = ot(
|
|
1228
1232
|
() => t.getAll().filter((d) => pe(d, o)),
|
|
1229
1233
|
[t, o]
|
|
1230
1234
|
), c = P(
|
|
@@ -1240,24 +1244,24 @@ function yn(e) {
|
|
|
1240
1244
|
},
|
|
1241
1245
|
[t, o, r]
|
|
1242
1246
|
);
|
|
1243
|
-
return
|
|
1247
|
+
return i.length === 0 ? { color: o, setColor: c, elements: Jr, isConnected: !1 } : { color: o, setColor: c, elements: i, isConnected: !0 };
|
|
1244
1248
|
}
|
|
1245
1249
|
const Zr = () => {
|
|
1246
1250
|
}, _r = [];
|
|
1247
|
-
function
|
|
1248
|
-
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((
|
|
1251
|
+
function vn(e) {
|
|
1252
|
+
const { elementStore: t } = dt(), { executeElementUpdate: r } = At(), o = ot(() => t.getAllByName(e).filter((s) => s instanceof Pt), [t, e]), n = P(
|
|
1249
1253
|
(a) => {
|
|
1250
1254
|
mr.loadGoogleFontByName(a);
|
|
1251
|
-
for (const
|
|
1252
|
-
if (
|
|
1253
|
-
Ye.clearCache(
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1255
|
+
for (const s of o) {
|
|
1256
|
+
if (s.fontFamily === a) continue;
|
|
1257
|
+
Ye.clearCache(s.fontFamily);
|
|
1258
|
+
const i = s.clone();
|
|
1259
|
+
i.fontFamily = a, r(s, i);
|
|
1256
1260
|
}
|
|
1257
1261
|
},
|
|
1258
1262
|
[o, r]
|
|
1259
1263
|
);
|
|
1260
|
-
return
|
|
1264
|
+
return Ut("font", e, t, o.length > 0), o.length === 0 ? { fontFamily: "", setFontFamily: Zr, element: null, elements: _r, isConnected: !1 } : {
|
|
1261
1265
|
fontFamily: o[0].fontFamily,
|
|
1262
1266
|
setFontFamily: n,
|
|
1263
1267
|
element: o[0],
|
|
@@ -1265,7 +1269,7 @@ function xn(e) {
|
|
|
1265
1269
|
isConnected: !0
|
|
1266
1270
|
};
|
|
1267
1271
|
}
|
|
1268
|
-
function
|
|
1272
|
+
function wn(e) {
|
|
1269
1273
|
const { elementStore: t } = dt();
|
|
1270
1274
|
return e ? t.getByName(e) ?? null : null;
|
|
1271
1275
|
}
|
|
@@ -1287,8 +1291,8 @@ function en(e) {
|
|
|
1287
1291
|
var o;
|
|
1288
1292
|
const t = (o = e.artboards) != null && o.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], r = t.map(() => []);
|
|
1289
1293
|
for (const n of e.elements || []) {
|
|
1290
|
-
const a = n == null ? void 0 : n.artboard,
|
|
1291
|
-
r[
|
|
1294
|
+
const a = n == null ? void 0 : n.artboard, s = typeof a == "string" ? t.findIndex((i) => (i.name || "Front") === a) : -1;
|
|
1295
|
+
r[s >= 0 ? s : 0].push(rn(n));
|
|
1292
1296
|
}
|
|
1293
1297
|
return {
|
|
1294
1298
|
schemaVersion: tn,
|
|
@@ -1323,20 +1327,20 @@ function rn(e) {
|
|
|
1323
1327
|
}
|
|
1324
1328
|
function nn(e) {
|
|
1325
1329
|
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),
|
|
1330
|
+
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
1331
|
id: e.id,
|
|
1328
1332
|
type: "image",
|
|
1329
1333
|
x: e.x || 0,
|
|
1330
1334
|
y: e.y || 0,
|
|
1331
1335
|
width: a,
|
|
1332
|
-
height:
|
|
1336
|
+
height: s,
|
|
1333
1337
|
rotation: e.rotation || 0,
|
|
1334
1338
|
imageUrl: e.imageUrl,
|
|
1335
1339
|
imageAspectRatio: e.imageAspectRatio
|
|
1336
1340
|
};
|
|
1337
|
-
return !r && (t.cropX !== 0 || t.cropY !== 0 || t.cropWidth !== 1 || t.cropHeight !== 1) && (
|
|
1341
|
+
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
1342
|
}
|
|
1339
|
-
const
|
|
1343
|
+
const de = "center";
|
|
1340
1344
|
function on(e) {
|
|
1341
1345
|
return e === "top-left" || e === "left" || e === "bottom-left" ? "left" : e === "top-right" || e === "right" || e === "bottom-right" ? "right" : "center";
|
|
1342
1346
|
}
|
|
@@ -1344,19 +1348,19 @@ function an(e) {
|
|
|
1344
1348
|
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1345
1349
|
}
|
|
1346
1350
|
function $t(e, t, r, o, n, a) {
|
|
1347
|
-
const
|
|
1351
|
+
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
1352
|
return { x: c, y: d };
|
|
1349
1353
|
}
|
|
1350
1354
|
function sn(e, t, r) {
|
|
1351
1355
|
const o = t / r;
|
|
1352
1356
|
if (e >= o) {
|
|
1353
|
-
const
|
|
1357
|
+
const s = r * e, i = t / s;
|
|
1354
1358
|
return {
|
|
1355
|
-
width:
|
|
1359
|
+
width: s,
|
|
1356
1360
|
height: r,
|
|
1357
|
-
cropX: (1 -
|
|
1361
|
+
cropX: (1 - i) / 2,
|
|
1358
1362
|
cropY: 0,
|
|
1359
|
-
cropWidth:
|
|
1363
|
+
cropWidth: i,
|
|
1360
1364
|
cropHeight: 1
|
|
1361
1365
|
};
|
|
1362
1366
|
}
|
|
@@ -1370,7 +1374,7 @@ function sn(e, t, r) {
|
|
|
1370
1374
|
cropHeight: a
|
|
1371
1375
|
};
|
|
1372
1376
|
}
|
|
1373
|
-
class
|
|
1377
|
+
class zt {
|
|
1374
1378
|
constructor(t) {
|
|
1375
1379
|
if (this.els = [], this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
|
|
1376
1380
|
throw new Error("design(): artboard width and height must be positive numbers");
|
|
@@ -1395,7 +1399,7 @@ class Ut {
|
|
|
1395
1399
|
const r = t.artboards.find((n) => n.name === t.activeArtboard) ?? t.artboards[0];
|
|
1396
1400
|
if (!r)
|
|
1397
1401
|
throw new Error("DesignBuilder.fromState(): state has no artboards");
|
|
1398
|
-
const o = new
|
|
1402
|
+
const o = new zt({
|
|
1399
1403
|
name: r.name,
|
|
1400
1404
|
width: r.width,
|
|
1401
1405
|
height: r.height,
|
|
@@ -1415,15 +1419,15 @@ class Ut {
|
|
|
1415
1419
|
const { width: o, height: n } = this.artboard;
|
|
1416
1420
|
let a;
|
|
1417
1421
|
if (r.aspectRatio && r.aspectRatio > 0) {
|
|
1418
|
-
const
|
|
1422
|
+
const i = sn(r.aspectRatio, o, n);
|
|
1419
1423
|
a = {
|
|
1420
1424
|
type: "image",
|
|
1421
|
-
width:
|
|
1422
|
-
height:
|
|
1423
|
-
cropX:
|
|
1424
|
-
cropY:
|
|
1425
|
-
cropWidth:
|
|
1426
|
-
cropHeight:
|
|
1425
|
+
width: i.width,
|
|
1426
|
+
height: i.height,
|
|
1427
|
+
cropX: i.cropX,
|
|
1428
|
+
cropY: i.cropY,
|
|
1429
|
+
cropWidth: i.cropWidth,
|
|
1430
|
+
cropHeight: i.cropHeight,
|
|
1427
1431
|
flipHorizontal: !1,
|
|
1428
1432
|
flipVertical: !1,
|
|
1429
1433
|
borderRadius: 0
|
|
@@ -1441,7 +1445,7 @@ class Ut {
|
|
|
1441
1445
|
flipVertical: !1,
|
|
1442
1446
|
borderRadius: 0
|
|
1443
1447
|
};
|
|
1444
|
-
const
|
|
1448
|
+
const s = {
|
|
1445
1449
|
id: this.nextId("bg"),
|
|
1446
1450
|
transformType: "image",
|
|
1447
1451
|
x: o / 2,
|
|
@@ -1453,14 +1457,14 @@ class Ut {
|
|
|
1453
1457
|
transformData: a,
|
|
1454
1458
|
name: r.name ?? "Background"
|
|
1455
1459
|
};
|
|
1456
|
-
return this.els.unshift(
|
|
1460
|
+
return this.els.unshift(s), this;
|
|
1457
1461
|
}
|
|
1458
1462
|
/** An anchored image element (not full-bleed). */
|
|
1459
1463
|
image(t, r = {}) {
|
|
1460
|
-
const { width: o, height: n } = this.artboard, a = r.width ?? Math.round(o / 3),
|
|
1464
|
+
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 ?? de, a, s, o, n, r.padding ?? 0), d = {
|
|
1461
1465
|
id: this.nextId("img"),
|
|
1462
1466
|
transformType: "image",
|
|
1463
|
-
x:
|
|
1467
|
+
x: i,
|
|
1464
1468
|
y: c,
|
|
1465
1469
|
rotation: r.rotation ?? 0,
|
|
1466
1470
|
opacity: r.opacity ?? 1,
|
|
@@ -1469,7 +1473,7 @@ class Ut {
|
|
|
1469
1473
|
transformData: {
|
|
1470
1474
|
type: "image",
|
|
1471
1475
|
width: a,
|
|
1472
|
-
height:
|
|
1476
|
+
height: s,
|
|
1473
1477
|
cropX: 0,
|
|
1474
1478
|
cropY: 0,
|
|
1475
1479
|
cropWidth: 1,
|
|
@@ -1485,11 +1489,11 @@ class Ut {
|
|
|
1485
1489
|
/** An anchored text layer. Horizontal centring is exact (textAlign); vertical
|
|
1486
1490
|
* anchoring uses the font size as the line-height estimate. */
|
|
1487
1491
|
text(t, r = {}) {
|
|
1488
|
-
const { width: o, height: n } = this.artboard, a = r.fontSize ?? Math.round(this.artboard.height / 12), { x:
|
|
1492
|
+
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
1493
|
id: this.nextId("text"),
|
|
1490
1494
|
transformType: "custom",
|
|
1491
|
-
x:
|
|
1492
|
-
y:
|
|
1495
|
+
x: s,
|
|
1496
|
+
y: i,
|
|
1493
1497
|
rotation: r.rotation ?? 0,
|
|
1494
1498
|
text: t,
|
|
1495
1499
|
fontSize: a,
|
|
@@ -1505,11 +1509,11 @@ class Ut {
|
|
|
1505
1509
|
}
|
|
1506
1510
|
/** An anchored vector shape. */
|
|
1507
1511
|
shape(t, r = {}) {
|
|
1508
|
-
const { width: o, height: n } = this.artboard, a = r.size ?? Math.round(o / 6),
|
|
1512
|
+
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 ?? de, s, i, o, n, r.padding ?? 0), x = {
|
|
1509
1513
|
type: "shape",
|
|
1510
1514
|
shapeType: t,
|
|
1511
|
-
width:
|
|
1512
|
-
height:
|
|
1515
|
+
width: s,
|
|
1516
|
+
height: i,
|
|
1513
1517
|
fillColor: r.fill ?? "#000000",
|
|
1514
1518
|
fillOpacity: r.opacity ?? 1,
|
|
1515
1519
|
...r.points !== void 0 ? { points: r.points } : {},
|
|
@@ -1555,8 +1559,8 @@ class Ut {
|
|
|
1555
1559
|
return en(this.toJSON());
|
|
1556
1560
|
}
|
|
1557
1561
|
}
|
|
1558
|
-
function
|
|
1559
|
-
return new
|
|
1562
|
+
function En(e) {
|
|
1563
|
+
return new zt(e);
|
|
1560
1564
|
}
|
|
1561
1565
|
const ye = "personalization", cn = pr("type", [
|
|
1562
1566
|
ct({
|
|
@@ -1572,7 +1576,7 @@ const ye = "personalization", cn = pr("type", [
|
|
|
1572
1576
|
name: $().min(1),
|
|
1573
1577
|
label: $(),
|
|
1574
1578
|
placeholder: $().optional(),
|
|
1575
|
-
fit:
|
|
1579
|
+
fit: ae([Y("cover"), Y("contain")]).optional(),
|
|
1576
1580
|
group: $().optional()
|
|
1577
1581
|
}),
|
|
1578
1582
|
ct({
|
|
@@ -1585,12 +1589,12 @@ const ye = "personalization", cn = pr("type", [
|
|
|
1585
1589
|
type: Y("select"),
|
|
1586
1590
|
name: $().min(1),
|
|
1587
1591
|
label: $(),
|
|
1588
|
-
property:
|
|
1592
|
+
property: ae([Y("text"), Y("imageUrl"), Y("fontFamily")]),
|
|
1589
1593
|
options: yr(ct({ label: $(), value: $() })).min(1),
|
|
1590
1594
|
group: $().optional()
|
|
1591
1595
|
})
|
|
1592
1596
|
]);
|
|
1593
|
-
function
|
|
1597
|
+
function An(e) {
|
|
1594
1598
|
if (!e || typeof e != "object") return [];
|
|
1595
1599
|
const t = e[ye];
|
|
1596
1600
|
if (!Array.isArray(t)) return [];
|
|
@@ -1602,26 +1606,27 @@ function En(e) {
|
|
|
1602
1606
|
}
|
|
1603
1607
|
return r;
|
|
1604
1608
|
}
|
|
1605
|
-
function
|
|
1609
|
+
function kn(e, t) {
|
|
1606
1610
|
return { ...e, [ye]: t };
|
|
1607
1611
|
}
|
|
1608
1612
|
export {
|
|
1609
1613
|
tn as C,
|
|
1610
|
-
|
|
1614
|
+
zt as D,
|
|
1611
1615
|
kr as E,
|
|
1612
1616
|
zr as S,
|
|
1613
1617
|
ye as T,
|
|
1614
|
-
|
|
1618
|
+
xn as a,
|
|
1615
1619
|
xr as b,
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1620
|
+
Mr as c,
|
|
1621
|
+
En as d,
|
|
1622
|
+
wn as e,
|
|
1623
|
+
vn as f,
|
|
1624
|
+
yn as g,
|
|
1621
1625
|
pn as h,
|
|
1622
|
-
|
|
1626
|
+
bn as i,
|
|
1627
|
+
An as r,
|
|
1623
1628
|
en as s,
|
|
1624
1629
|
Rr as u,
|
|
1625
|
-
|
|
1630
|
+
kn as w
|
|
1626
1631
|
};
|
|
1627
|
-
//# sourceMappingURL=template-fields-
|
|
1632
|
+
//# sourceMappingURL=template-fields-coO73lV3.js.map
|