@snowcone-app/canvas 0.43.8 → 0.44.1
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/{CanvasRenderer-DIug_mjX.js → CanvasRenderer-B8BADU_r.js} +876 -830
- package/dist/CanvasRenderer-B8BADU_r.js.map +1 -0
- package/dist/{CanvasStateV1-BWd358xJ.js → CanvasStateV1-BlDWgOzV.js} +3 -3
- package/dist/{CanvasStateV1-BWd358xJ.js.map → CanvasStateV1-BlDWgOzV.js.map} +1 -1
- package/dist/ContextualToolbars-rCZo-KCm.js +6808 -0
- package/dist/ContextualToolbars-rCZo-KCm.js.map +1 -0
- package/dist/EditorCanvasImpl-VkjeyOGd.js +144 -0
- package/dist/EditorCanvasImpl-VkjeyOGd.js.map +1 -0
- package/dist/{ExportManager-BDH9jW4Q.js → ExportManager-xRsXgyNo.js} +2 -2
- package/dist/{ExportManager-BDH9jW4Q.js.map → ExportManager-xRsXgyNo.js.map} +1 -1
- package/dist/{FontAnalyzer-CyhywbAM.js → FontAnalyzer-Ds3Wdba7.js} +239 -236
- package/dist/FontAnalyzer-Ds3Wdba7.js.map +1 -0
- package/dist/{ImagePanel-CIGpLY3B.js → ImagePanel-DhOWKvIN.js} +6 -6
- package/dist/{ImagePanel-CIGpLY3B.js.map → ImagePanel-DhOWKvIN.js.map} +1 -1
- package/dist/{SnowconeCanvas-DE0A9UwD.js → SnowconeCanvas-COXpmwkS.js} +481 -466
- package/dist/SnowconeCanvas-COXpmwkS.js.map +1 -0
- package/dist/adjust-CDVzlVBY.js +145 -0
- package/dist/adjust-CDVzlVBY.js.map +1 -0
- package/dist/advanced.mjs +15 -15
- package/dist/api/stable.d.ts +2 -0
- package/dist/components/ImageToolbar.d.ts +3 -0
- package/dist/components/ShapeToolbar.d.ts +2 -0
- package/dist/components/TextToolbar.d.ts +2 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +8 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +24 -0
- package/dist/components/toolbars/index.d.ts +2 -2
- package/dist/core/ArtboardElement.d.ts +2 -0
- package/dist/core/CanvasRenderer.d.ts +3 -1
- package/dist/{custom-icons-sT5sNRcG.js → custom-icons-C4bzABm2.js} +2 -2
- package/dist/{custom-icons-sT5sNRcG.js.map → custom-icons-C4bzABm2.js.map} +1 -1
- package/dist/{design-builder-CwfefZJC.js → design-builder-DCHVrEFV.js} +315 -314
- package/dist/design-builder-DCHVrEFV.js.map +1 -0
- package/dist/{embed-rRSCS25g.js → embed-CamnTsuT.js} +10 -10
- package/dist/{embed-rRSCS25g.js.map → embed-CamnTsuT.js.map} +1 -1
- package/dist/embed.mjs +19 -19
- package/dist/engrave/EngraveSync.d.ts +5 -0
- package/dist/engrave/adjust.d.ts +36 -0
- package/dist/engrave/makeEngraved.d.ts +23 -0
- package/dist/engrave/types.d.ts +33 -0
- package/dist/{guards-Dvw7Qch0.js → guards-DwYEoqcn.js} +2 -2
- package/dist/{guards-Dvw7Qch0.js.map → guards-DwYEoqcn.js.map} +1 -1
- package/dist/index.mjs +57 -54
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +6 -6
- package/dist/rendering/EngraveViewRenderer.d.ts +15 -0
- package/dist/services/AutoExportManager.d.ts +13 -0
- package/dist/{template-fields-DF1ijCl9.js → template-fields-CK7Uvvc8.js} +5 -5
- package/dist/{template-fields-DF1ijCl9.js.map → template-fields-CK7Uvvc8.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/{useCommands-wwGeWCn6.js → useCommands-BrkGKdXr.js} +7 -7
- package/dist/{useCommands-wwGeWCn6.js.map → useCommands-BrkGKdXr.js.map} +1 -1
- package/dist/{usePieceGuideBundle-BWQINIJR.js → usePieceGuideBundle-BWdobHQE.js} +2 -2
- package/dist/{usePieceGuideBundle-BWQINIJR.js.map → usePieceGuideBundle-BWdobHQE.js.map} +1 -1
- package/dist/{validation-CXC34UhU.js → validation-jgr2OtXC.js} +2136 -2113
- package/dist/validation-jgr2OtXC.js.map +1 -0
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/CanvasRenderer-DIug_mjX.js.map +0 -1
- package/dist/ContextualToolbars-CspkC1T3.js +0 -6604
- package/dist/ContextualToolbars-CspkC1T3.js.map +0 -1
- package/dist/EditorCanvasImpl-Cn2fdo6a.js +0 -144
- package/dist/EditorCanvasImpl-Cn2fdo6a.js.map +0 -1
- package/dist/FontAnalyzer-CyhywbAM.js.map +0 -1
- package/dist/SnowconeCanvas-DE0A9UwD.js.map +0 -1
- package/dist/design-builder-CwfefZJC.js.map +0 -1
- package/dist/validation-CXC34UhU.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { p as ee, c as te, u as ze, t as ae, I as Ge, v as Ue, x as Ve, y as Xe } from "./FontAnalyzer-
|
|
2
|
-
import { jsx as
|
|
3
|
-
import Qe, { useMemo as Re, useRef as N, useEffect as
|
|
4
|
-
import { a as qe, b as _e, c as et, G as tt, d as rt, Z as nt, g as at, e as ot, D as st, r as it, v as ct, S as lt, K as dt, f as ut } from "./validation-
|
|
5
|
-
import { ImagePanel as ft } from "./ImagePanel-
|
|
6
|
-
import { C as mt, a as gt } from "./ContextualToolbars-
|
|
7
|
-
import { n as ht, o as pt, E as bt, C as vt, b as he, k as Et } from "./useCommands-
|
|
8
|
-
import { C as yt, D as xt } from "./template-fields-
|
|
9
|
-
import { E as wt, b as se, i as It, l as At, j as Ie } from "./design-builder-
|
|
1
|
+
import { p as ee, c as te, u as ze, t as ae, I as Ge, v as Ue, x as Ve, y as Xe } from "./FontAnalyzer-Ds3Wdba7.js";
|
|
2
|
+
import { jsx as y, Fragment as Je, jsxs as _ } from "react/jsx-runtime";
|
|
3
|
+
import Qe, { useMemo as Re, useRef as N, useEffect as F, Component as Ye, useState as oe, useCallback as V, useImperativeHandle as Ze, forwardRef as Ce } from "react";
|
|
4
|
+
import { a as qe, b as _e, c as et, G as tt, d as rt, Z as nt, g as at, e as ot, D as st, r as it, v as ct, S as lt, K as dt, f as ut } from "./validation-jgr2OtXC.js";
|
|
5
|
+
import { ImagePanel as ft } from "./ImagePanel-DhOWKvIN.js";
|
|
6
|
+
import { C as mt, a as gt } from "./ContextualToolbars-rCZo-KCm.js";
|
|
7
|
+
import { n as ht, o as pt, E as bt, C as vt, b as he, k as Et } from "./useCommands-BrkGKdXr.js";
|
|
8
|
+
import { C as yt, D as xt } from "./template-fields-CK7Uvvc8.js";
|
|
9
|
+
import { E as wt, b as se, i as It, l as At, j as Ie } from "./design-builder-DCHVrEFV.js";
|
|
10
10
|
import { T as Ae } from "./ThemeContext-Rjz25x9X.js";
|
|
11
11
|
import { c as St } from "./placement-tSiIVhrL.js";
|
|
12
|
-
import { a as kt, G as ce, E as Me, H as Ft } from "./ExportManager-
|
|
13
|
-
import { C as fe } from "./CanvasRenderer-
|
|
12
|
+
import { a as kt, G as ce, E as Me, H as Ft } from "./ExportManager-xRsXgyNo.js";
|
|
13
|
+
import { C as fe } from "./CanvasRenderer-B8BADU_r.js";
|
|
14
14
|
const pe = te("KitLayout"), ne = "canvas", me = 320;
|
|
15
15
|
let Se = !1;
|
|
16
16
|
function Rt() {
|
|
@@ -36,10 +36,10 @@ function Ct({ children: r }) {
|
|
|
36
36
|
...pt((a) => pe.error("[kit section]", a))
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ y(bt.Provider, { value: n.current, children: r });
|
|
40
40
|
}
|
|
41
41
|
function le({ ids: r }) {
|
|
42
|
-
return !r || r.length === 0 ? null : /* @__PURE__ */
|
|
42
|
+
return !r || r.length === 0 ? null : /* @__PURE__ */ y(Ct, { children: r.map((n) => {
|
|
43
43
|
var t;
|
|
44
44
|
if (n === ne) return null;
|
|
45
45
|
const e = at(n);
|
|
@@ -48,51 +48,51 @@ function le({ ids: r }) {
|
|
|
48
48
|
`Kit layout references unknown section "${n}" — skipping. Register it with registerSection("${n}", { ... }).`
|
|
49
49
|
), null;
|
|
50
50
|
const a = e.component;
|
|
51
|
-
return /* @__PURE__ */
|
|
51
|
+
return /* @__PURE__ */ y(a, {}, n);
|
|
52
52
|
}) });
|
|
53
53
|
}
|
|
54
54
|
function Mt({ kit: r, canvas: n }) {
|
|
55
|
-
var
|
|
55
|
+
var v, c, w, A;
|
|
56
56
|
Rt();
|
|
57
|
-
const e = r.layout.slots, a = !!((
|
|
58
|
-
() => !a && !t && !o && !
|
|
59
|
-
[a, t, o,
|
|
60
|
-
), s = N(null),
|
|
61
|
-
return
|
|
62
|
-
var
|
|
63
|
-
if (typeof ee > "u" || ((
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
const $ = (
|
|
67
|
-
|
|
68
|
-
`Kit "${r.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(
|
|
69
|
-
)) :
|
|
57
|
+
const e = r.layout.slots, a = !!((v = e.topbar) != null && v.some((S) => S !== ne)), t = !!((c = e.left) != null && c.some((S) => S !== ne)), o = !!((w = e.right) != null && w.some((S) => S !== ne)), i = !!((A = e.bottombar) != null && A.some((S) => S !== ne)), l = Re(
|
|
58
|
+
() => !a && !t && !o && !i,
|
|
59
|
+
[a, t, o, i]
|
|
60
|
+
), s = N(null), m = a || t || o || i, h = N(!1);
|
|
61
|
+
return F(() => {
|
|
62
|
+
var u;
|
|
63
|
+
if (typeof ee > "u" || ((u = ee.env) == null ? void 0 : u.NODE_ENV) !== "development" || !m) return;
|
|
64
|
+
const S = s.current;
|
|
65
|
+
if (!S || typeof ResizeObserver > "u") return;
|
|
66
|
+
const $ = (x) => {
|
|
67
|
+
x > 0 && x < me && !h.current ? (h.current = !0, pe.warn(
|
|
68
|
+
`Kit "${r.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(x)}px wide — below the ~${me}px needed to render it, so the toolbar / panels are suppressed and the editor looks like a bare canvas. Give the editor more container width, or pass kit="embed-only" if a chrome-less canvas is intended.`
|
|
69
|
+
)) : x >= me && (h.current = !1);
|
|
70
70
|
};
|
|
71
|
-
$(
|
|
72
|
-
const
|
|
73
|
-
for (const
|
|
71
|
+
$(S.getBoundingClientRect().width);
|
|
72
|
+
const T = new ResizeObserver((x) => {
|
|
73
|
+
for (const d of x) $(d.contentRect.width);
|
|
74
74
|
});
|
|
75
|
-
return
|
|
76
|
-
}, [
|
|
77
|
-
a && /* @__PURE__ */
|
|
75
|
+
return T.observe(S), () => T.disconnect();
|
|
76
|
+
}, [m, r.name]), l ? /* @__PURE__ */ y(Je, { children: n }) : /* @__PURE__ */ _("div", { ref: s, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
|
|
77
|
+
a && /* @__PURE__ */ y(
|
|
78
78
|
"div",
|
|
79
79
|
{
|
|
80
80
|
className: "sc-kit-topbar sc-toolbar",
|
|
81
81
|
style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", flexShrink: 0 },
|
|
82
|
-
children: /* @__PURE__ */
|
|
82
|
+
children: /* @__PURE__ */ y(le, { ids: e.topbar })
|
|
83
83
|
}
|
|
84
84
|
),
|
|
85
85
|
/* @__PURE__ */ _("div", { className: "sc-kit-body", style: { display: "flex", flex: 1, minHeight: 0 }, children: [
|
|
86
|
-
t && /* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
o && /* @__PURE__ */
|
|
86
|
+
t && /* @__PURE__ */ y("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ y(le, { ids: e.left }) }),
|
|
87
|
+
/* @__PURE__ */ y("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: n }),
|
|
88
|
+
o && /* @__PURE__ */ y("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ y(le, { ids: e.right }) })
|
|
89
89
|
] }),
|
|
90
|
-
|
|
90
|
+
i && /* @__PURE__ */ y(
|
|
91
91
|
"div",
|
|
92
92
|
{
|
|
93
93
|
className: "sc-kit-bottombar sc-toolbar",
|
|
94
94
|
style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 },
|
|
95
|
-
children: /* @__PURE__ */
|
|
95
|
+
children: /* @__PURE__ */ y(le, { ids: e.bottombar })
|
|
96
96
|
}
|
|
97
97
|
)
|
|
98
98
|
] });
|
|
@@ -140,8 +140,8 @@ class Nt extends Ye {
|
|
|
140
140
|
fontFamily: "system-ui, sans-serif"
|
|
141
141
|
},
|
|
142
142
|
children: [
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ y("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
|
|
144
|
+
/* @__PURE__ */ y(
|
|
145
145
|
"pre",
|
|
146
146
|
{
|
|
147
147
|
style: {
|
|
@@ -156,7 +156,7 @@ class Nt extends Ye {
|
|
|
156
156
|
children: this.state.error.message
|
|
157
157
|
}
|
|
158
158
|
),
|
|
159
|
-
/* @__PURE__ */
|
|
159
|
+
/* @__PURE__ */ y(
|
|
160
160
|
"button",
|
|
161
161
|
{
|
|
162
162
|
onClick: this.resetError,
|
|
@@ -185,83 +185,85 @@ function Lt({
|
|
|
185
185
|
viewPadding: a,
|
|
186
186
|
children: t
|
|
187
187
|
}) {
|
|
188
|
-
const o = n ? /* @__PURE__ */
|
|
189
|
-
return e ? /* @__PURE__ */
|
|
188
|
+
const o = n ? /* @__PURE__ */ y(Ae, { defaultTheme: "light", passive: r, children: t }) : /* @__PURE__ */ y(Ae, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ y(wt, { viewPadding: a, children: t }) });
|
|
189
|
+
return e ? /* @__PURE__ */ y(vt, { services: e, children: o }) : o;
|
|
190
190
|
}
|
|
191
191
|
const Pt = te("useAutoExport");
|
|
192
192
|
function $t(r) {
|
|
193
|
-
const { config: n, historyManager: e, artboards: a, elements: t, onExport: o, onExportScheduled:
|
|
193
|
+
const { config: n, historyManager: e, artboards: a, elements: t, onExport: o, onExportScheduled: i, isCanvasReady: l = !1 } = r, s = N(null), m = N(!1), h = N({
|
|
194
194
|
totalExports: 0,
|
|
195
195
|
skippedExports: 0,
|
|
196
196
|
lastExportTime: null,
|
|
197
|
-
avgExportInterval: 0
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
avgExportInterval: 0,
|
|
198
|
+
failedExports: 0,
|
|
199
|
+
lastExportError: null
|
|
200
|
+
}), [v, c] = oe(h.current), w = N(o);
|
|
201
|
+
w.current = o, F(() => {
|
|
202
|
+
const u = new ot({
|
|
201
203
|
...st,
|
|
202
204
|
...n
|
|
203
205
|
});
|
|
204
|
-
return
|
|
206
|
+
return u.onExport(async () => {
|
|
205
207
|
try {
|
|
206
|
-
await
|
|
207
|
-
} catch (
|
|
208
|
-
Pt.error("[useAutoExport] Export failed:",
|
|
208
|
+
await w.current(), h.current = u.getStats();
|
|
209
|
+
} catch (x) {
|
|
210
|
+
Pt.error("[useAutoExport] Export failed:", x);
|
|
209
211
|
}
|
|
210
|
-
}), s.current =
|
|
211
|
-
|
|
212
|
+
}), s.current = u, () => {
|
|
213
|
+
u.destroy();
|
|
212
214
|
};
|
|
213
|
-
}, []),
|
|
214
|
-
|
|
215
|
-
}, [
|
|
215
|
+
}, []), F(() => {
|
|
216
|
+
l && m.current && s.current && (m.current = !1, s.current.forceExport());
|
|
217
|
+
}, [l]), F(() => {
|
|
216
218
|
s.current && n && s.current.updateConfig(n);
|
|
217
|
-
}, [n == null ? void 0 : n.enabled, n == null ? void 0 : n.debounceMs, n == null ? void 0 : n.maxWaitMs]),
|
|
218
|
-
s.current &&
|
|
219
|
-
}, [
|
|
219
|
+
}, [n == null ? void 0 : n.enabled, n == null ? void 0 : n.debounceMs, n == null ? void 0 : n.maxWaitMs]), F(() => {
|
|
220
|
+
s.current && i && s.current.onExportScheduled(i);
|
|
221
|
+
}, [i]), F(() => {
|
|
220
222
|
if (!e || !s.current)
|
|
221
223
|
return;
|
|
222
|
-
const
|
|
224
|
+
const u = e.onCommandExecuted(() => {
|
|
223
225
|
if (s.current) {
|
|
224
|
-
if (!
|
|
225
|
-
|
|
226
|
+
if (!l) {
|
|
227
|
+
m.current = !0;
|
|
226
228
|
return;
|
|
227
229
|
}
|
|
228
230
|
s.current.scheduleExport();
|
|
229
231
|
}
|
|
230
232
|
});
|
|
231
233
|
return () => {
|
|
232
|
-
|
|
234
|
+
u();
|
|
233
235
|
};
|
|
234
|
-
}, [e,
|
|
236
|
+
}, [e, l]), F(() => {
|
|
235
237
|
if (s.current) {
|
|
236
|
-
if (!
|
|
237
|
-
|
|
238
|
+
if (!l) {
|
|
239
|
+
m.current = !0;
|
|
238
240
|
return;
|
|
239
241
|
}
|
|
240
242
|
s.current.scheduleExport();
|
|
241
243
|
}
|
|
242
|
-
}, [t, a,
|
|
243
|
-
if (!s.current || !
|
|
244
|
-
t.some((
|
|
245
|
-
}), [t,
|
|
246
|
-
const
|
|
247
|
-
s.current && s.current.updateConfig(
|
|
248
|
-
}, []),
|
|
249
|
-
s.current && (await s.current.forceExport(), h.current = s.current.getStats(),
|
|
244
|
+
}, [t, a, l]), F(() => ze((x) => {
|
|
245
|
+
if (!s.current || !l) return;
|
|
246
|
+
t.some((p) => p.id === x) && s.current.scheduleExport();
|
|
247
|
+
}), [t, l]);
|
|
248
|
+
const A = V((u) => {
|
|
249
|
+
s.current && s.current.updateConfig(u);
|
|
250
|
+
}, []), S = V(async () => {
|
|
251
|
+
s.current && (await s.current.forceExport(), h.current = s.current.getStats(), c(h.current));
|
|
250
252
|
}, []), $ = V(() => {
|
|
251
|
-
s.current && (s.current.resetStats(), h.current = s.current.getStats(),
|
|
252
|
-
}, []),
|
|
253
|
+
s.current && (s.current.resetStats(), h.current = s.current.getStats(), c(h.current));
|
|
254
|
+
}, []), T = V(() => {
|
|
253
255
|
s.current && s.current.resetChangeDetection();
|
|
254
256
|
}, []);
|
|
255
257
|
return {
|
|
256
|
-
stats:
|
|
257
|
-
updateConfig:
|
|
258
|
-
forceExport:
|
|
258
|
+
stats: v,
|
|
259
|
+
updateConfig: A,
|
|
260
|
+
forceExport: S,
|
|
259
261
|
resetStats: $,
|
|
260
|
-
resetChangeDetection:
|
|
262
|
+
resetChangeDetection: T
|
|
261
263
|
};
|
|
262
264
|
}
|
|
263
265
|
const Te = te("useContentReady");
|
|
264
|
-
function
|
|
266
|
+
function Ot(r) {
|
|
265
267
|
var e;
|
|
266
268
|
const n = /* @__PURE__ */ new Set();
|
|
267
269
|
for (const a of r)
|
|
@@ -275,7 +277,7 @@ function Dt(r) {
|
|
|
275
277
|
}
|
|
276
278
|
return Array.from(n);
|
|
277
279
|
}
|
|
278
|
-
async function
|
|
280
|
+
async function Dt(r) {
|
|
279
281
|
if (r.length === 0 || typeof document > "u" || !document.fonts) return;
|
|
280
282
|
const n = [];
|
|
281
283
|
for (const e of r) {
|
|
@@ -291,23 +293,23 @@ function Bt() {
|
|
|
291
293
|
return new Promise((r) => requestAnimationFrame(() => r()));
|
|
292
294
|
}
|
|
293
295
|
function Wt(r) {
|
|
294
|
-
const { isCanvasReady: n, elements: e, hasInitialElements: a, initialElementsLoaded: t } = r, [o,
|
|
295
|
-
return
|
|
296
|
-
if (o || !n || a && !t || a && e.length === 0 ||
|
|
297
|
-
|
|
296
|
+
const { isCanvasReady: n, elements: e, hasInitialElements: a, initialElementsLoaded: t } = r, [o, i] = oe(!1), l = N(!1);
|
|
297
|
+
return F(() => {
|
|
298
|
+
if (o || !n || a && !t || a && e.length === 0 || l.current) return;
|
|
299
|
+
l.current = !0;
|
|
298
300
|
let s = !1;
|
|
299
301
|
return (async () => {
|
|
300
302
|
try {
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
} catch (
|
|
305
|
-
Te.error("Error during content readiness check:",
|
|
303
|
+
const m = Ot(e);
|
|
304
|
+
if (m.length > 0 && (await Dt(m), s) || (await Bt(), s)) return;
|
|
305
|
+
i(!0);
|
|
306
|
+
} catch (m) {
|
|
307
|
+
Te.error("Error during content readiness check:", m), s || i(!0);
|
|
306
308
|
} finally {
|
|
307
|
-
|
|
309
|
+
l.current = !1;
|
|
308
310
|
}
|
|
309
311
|
})(), () => {
|
|
310
|
-
s = !0,
|
|
312
|
+
s = !0, l.current = !1;
|
|
311
313
|
};
|
|
312
314
|
}, [n, e, a, t, o]), o;
|
|
313
315
|
}
|
|
@@ -328,7 +330,7 @@ function Ht(r, n) {
|
|
|
328
330
|
}), r;
|
|
329
331
|
}
|
|
330
332
|
function Kt(r, n, e) {
|
|
331
|
-
const a = r.fontSize * n.height, t = (r.letterSpacing ?? 0) * n.height, o = e(r.text, a, r.fontFamily, t),
|
|
333
|
+
const a = r.fontSize * n.height, t = (r.letterSpacing ?? 0) * n.height, o = e(r.text, a, r.fontFamily, t), i = n.left + r.left * n.width, l = (r.width ?? 0) * n.width, s = r.align === "center" ? i + l / 2 : r.align === "right" ? i + l - o.advance / 2 : i + o.advance / 2, m = n.top + r.baseline * n.height;
|
|
332
334
|
return {
|
|
333
335
|
transformType: "custom",
|
|
334
336
|
name: r.name ?? r.text,
|
|
@@ -340,7 +342,7 @@ function Kt(r, n, e) {
|
|
|
340
342
|
...t !== 0 ? { letterSpacing: t } : {},
|
|
341
343
|
...r.stroke ? { stroke: { enabled: !0, color: r.stroke.color, width: r.stroke.width * n.height, lineJoin: "round", lineCap: "round" } } : {},
|
|
342
344
|
x: s,
|
|
343
|
-
y:
|
|
345
|
+
y: m - o.ascent + (o.ascent + o.descent) / 2,
|
|
344
346
|
rotation: 0,
|
|
345
347
|
// Room past the measured advance: the editor wraps a line at its box, and measures spaced letters a little
|
|
346
348
|
// wider when it wraps than when it measures (a spaced "BRIDE SQUAD" broke onto two lines at its exact width).
|
|
@@ -360,22 +362,22 @@ function Ne(r) {
|
|
|
360
362
|
async function zt(r, n, e) {
|
|
361
363
|
const a = Date.now();
|
|
362
364
|
for (; ; ) {
|
|
363
|
-
const t = Ne(n.filter((
|
|
365
|
+
const t = Ne(n.filter((i) => i.visible !== !1)).filter((i) => !i.imageElement || !i.imageLoaded);
|
|
364
366
|
if (t.length === 0) return;
|
|
365
|
-
const o = t.filter((
|
|
367
|
+
const o = t.filter((i) => i.imageLoadState === "error");
|
|
366
368
|
if (o.length > 0 || Date.now() - a > e) {
|
|
367
|
-
const
|
|
369
|
+
const i = (o.length > 0 ? o : t).map((l) => l.id);
|
|
368
370
|
throw new ae(
|
|
369
371
|
"E_PRINT_FILE_FAILED",
|
|
370
|
-
`the print file of "${r.name}" needs every picture on it, and ${
|
|
371
|
-
{ artboard: r.name, elements:
|
|
372
|
+
`the print file of "${r.name}" needs every picture on it, and ${i.join(", ")} ${o.length > 0 ? "failed to load" : `has not loaded after ${e} ms`}: remove or re-add that picture, then ask again.`,
|
|
373
|
+
{ artboard: r.name, elements: i, state: o.length > 0 ? "error" : "loading" }
|
|
372
374
|
);
|
|
373
375
|
}
|
|
374
|
-
await new Promise((
|
|
376
|
+
await new Promise((i) => setTimeout(i, 100));
|
|
375
377
|
}
|
|
376
378
|
}
|
|
377
379
|
async function Gt(r, n, e = {}, a = {}) {
|
|
378
|
-
var
|
|
380
|
+
var i, l;
|
|
379
381
|
const t = r.map((s) => s.name);
|
|
380
382
|
for (const s of Object.keys(e.regions ?? {}))
|
|
381
383
|
if (!t.includes(s))
|
|
@@ -385,13 +387,13 @@ async function Gt(r, n, e = {}, a = {}) {
|
|
|
385
387
|
});
|
|
386
388
|
const o = {};
|
|
387
389
|
for (const s of r) {
|
|
388
|
-
const
|
|
389
|
-
await zt(s,
|
|
390
|
-
const h = (
|
|
391
|
-
for (const { key:
|
|
392
|
-
if (
|
|
393
|
-
throw new ae("E_PRINT_FILE_FAILED", `two print files are keyed "${
|
|
394
|
-
o[
|
|
390
|
+
const m = n(s);
|
|
391
|
+
await zt(s, m, a.imageWaitMs ?? jt);
|
|
392
|
+
const h = (i = e.regions) == null ? void 0 : i[s.name], v = h ? h.map((c) => ({ key: c.id, region: c })) : [{ key: s.name }];
|
|
393
|
+
for (const { key: c, region: w } of v) {
|
|
394
|
+
if (c in o)
|
|
395
|
+
throw new ae("E_PRINT_FILE_FAILED", `two print files are keyed "${c}": region ids and artboard names must all differ.`, { key: c });
|
|
396
|
+
o[c] = await kt.exportPrintFile(s, m, { scale: ((l = e.scale) == null ? void 0 : l[c]) ?? 1, region: w });
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
399
|
return o;
|
|
@@ -403,7 +405,7 @@ function ge(r, n, e, a) {
|
|
|
403
405
|
const t = r * e, o = n * e;
|
|
404
406
|
if (Math.max(t, o) <= a)
|
|
405
407
|
return e;
|
|
406
|
-
const
|
|
408
|
+
const l = Math.max(r, n), s = a / l;
|
|
407
409
|
return Math.min(s, e);
|
|
408
410
|
}
|
|
409
411
|
function Ut(r) {
|
|
@@ -413,7 +415,7 @@ function Ut(r) {
|
|
|
413
415
|
var o;
|
|
414
416
|
Q.error(`[${t.category}] ${t.message}`, t.originalError), (o = n.current) == null || o.call(n, t);
|
|
415
417
|
}, []);
|
|
416
|
-
|
|
418
|
+
F(() => (fe.onRenderError = e, () => {
|
|
417
419
|
fe.onRenderError === e && (fe.onRenderError = null);
|
|
418
420
|
}), [e]);
|
|
419
421
|
const a = V((t) => {
|
|
@@ -433,151 +435,164 @@ function Vt(r) {
|
|
|
433
435
|
height: a,
|
|
434
436
|
pieceGuides: t,
|
|
435
437
|
controlledActiveArtboard: o,
|
|
436
|
-
onArtboardChange:
|
|
437
|
-
resetDocumentOnMount:
|
|
438
|
+
onArtboardChange: i,
|
|
439
|
+
resetDocumentOnMount: l
|
|
438
440
|
} = r, {
|
|
439
441
|
setElements: s,
|
|
440
|
-
setSelectedId:
|
|
442
|
+
setSelectedId: m,
|
|
441
443
|
setMultiSelection: h,
|
|
442
|
-
artboardManager:
|
|
443
|
-
refreshArtboards:
|
|
444
|
-
} = se(), { createArtboard:
|
|
445
|
-
|
|
444
|
+
artboardManager: v,
|
|
445
|
+
refreshArtboards: c
|
|
446
|
+
} = se(), { createArtboard: w, selectArtboard: A, artboards: S } = he(), $ = N(!1), T = N(!1);
|
|
447
|
+
F(() => {
|
|
446
448
|
if ($.current) return;
|
|
447
449
|
$.current = !0;
|
|
448
|
-
const
|
|
449
|
-
for (const
|
|
450
|
-
|
|
450
|
+
const d = n || [{ name: "Design", width: e, height: a }], p = t ? "transparent" : void 0, b = (E) => E.exportBackground ?? (!!E.backgroundColor && E.backgroundColor !== "transparent"), g = () => {
|
|
451
|
+
for (const E of v.getAllArtboards()) {
|
|
452
|
+
const f = d.find((I) => I.name === E.name);
|
|
453
|
+
E.imageFit = It(f), E.engrave = f != null && f.engrave ? { ...f.engrave } : void 0;
|
|
454
|
+
}
|
|
451
455
|
};
|
|
452
|
-
if (
|
|
453
|
-
|
|
454
|
-
for (const
|
|
455
|
-
|
|
456
|
-
name:
|
|
457
|
-
width:
|
|
458
|
-
height:
|
|
459
|
-
backgroundColor:
|
|
460
|
-
exportBackground:
|
|
461
|
-
clipShape:
|
|
462
|
-
role:
|
|
456
|
+
if (l) {
|
|
457
|
+
v.clear(), s([]), m(null), h([]);
|
|
458
|
+
for (const f of d)
|
|
459
|
+
v.createArtboard({
|
|
460
|
+
name: f.name,
|
|
461
|
+
width: f.width,
|
|
462
|
+
height: f.height,
|
|
463
|
+
backgroundColor: f.backgroundColor ?? p,
|
|
464
|
+
exportBackground: b(f),
|
|
465
|
+
clipShape: f.clipShape,
|
|
466
|
+
role: f.role
|
|
463
467
|
});
|
|
464
|
-
const
|
|
465
|
-
|
|
468
|
+
const E = v.getAllArtboards();
|
|
469
|
+
E.length > 0 && !o && v.setActiveArtboard(E[0].id), g(), c();
|
|
466
470
|
return;
|
|
467
471
|
}
|
|
468
|
-
const
|
|
469
|
-
if (
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
for (let
|
|
473
|
-
|
|
474
|
-
name:
|
|
475
|
-
backgroundColor:
|
|
476
|
-
exportBackground:
|
|
477
|
-
clipShape:
|
|
478
|
-
role:
|
|
472
|
+
const k = v.getAllArtboards();
|
|
473
|
+
if (k.length > 0) {
|
|
474
|
+
const E = d[0], f = k[0];
|
|
475
|
+
f.name = E.name, f.width = E.width, f.height = E.height, f.clipShape = E.clipShape, f.exportBackground = b(E), f.role = E.role, E.backgroundColor ? f.backgroundColor = E.backgroundColor : p && (f.backgroundColor = p);
|
|
476
|
+
for (let I = 1; I < d.length; I++)
|
|
477
|
+
w(d[I].width, d[I].height, {
|
|
478
|
+
name: d[I].name,
|
|
479
|
+
backgroundColor: d[I].backgroundColor ?? p,
|
|
480
|
+
exportBackground: b(d[I]),
|
|
481
|
+
clipShape: d[I].clipShape,
|
|
482
|
+
role: d[I].role
|
|
479
483
|
});
|
|
480
|
-
!o &&
|
|
484
|
+
!o && d.length > 1 && v.setActiveArtboard(f.id);
|
|
481
485
|
}
|
|
482
|
-
|
|
483
|
-
}, [])
|
|
486
|
+
g(), c();
|
|
487
|
+
}, []);
|
|
488
|
+
const u = JSON.stringify((n ?? []).map((d) => [d.name, d.engrave ?? null])), x = N(u);
|
|
489
|
+
F(() => {
|
|
490
|
+
if (x.current !== u) {
|
|
491
|
+
x.current = u;
|
|
492
|
+
for (const d of v.getAllArtboards()) {
|
|
493
|
+
const p = (n ?? []).find((b) => b.name === d.name);
|
|
494
|
+
d.engrave = p != null && p.engrave ? { ...p.engrave } : void 0;
|
|
495
|
+
}
|
|
496
|
+
c();
|
|
497
|
+
}
|
|
498
|
+
}, [u]), F(() => {
|
|
484
499
|
if (!o) {
|
|
485
|
-
|
|
500
|
+
T.current = !0;
|
|
486
501
|
return;
|
|
487
502
|
}
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
491
|
-
(
|
|
503
|
+
const d = S.find((p) => p.name === o);
|
|
504
|
+
if (d) {
|
|
505
|
+
const p = v.getActiveArtboard();
|
|
506
|
+
(p == null ? void 0 : p.name) !== o && A(d.id), T.current = !0;
|
|
492
507
|
}
|
|
493
|
-
}, [o,
|
|
494
|
-
if (!
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
}, [
|
|
508
|
+
}, [o, S]), F(() => {
|
|
509
|
+
if (!i || !T.current) return;
|
|
510
|
+
const d = v.getActiveArtboard();
|
|
511
|
+
d && i(d.name);
|
|
512
|
+
}, [v.getActiveArtboardId()]);
|
|
498
513
|
}
|
|
499
514
|
function Xt(r) {
|
|
500
|
-
const { initialElements: n, emitError: e, customFonts: a } = r, { setElements: t, artboardManager: o } = se(),
|
|
501
|
-
return
|
|
502
|
-
|
|
503
|
-
}), []),
|
|
504
|
-
if (!(!n || n.length === 0) && !
|
|
505
|
-
|
|
515
|
+
const { initialElements: n, emitError: e, customFonts: a } = r, { setElements: t, artboardManager: o } = se(), i = N(!1), [l, s] = oe(!1), m = N(!0);
|
|
516
|
+
return F(() => (m.current = !0, () => {
|
|
517
|
+
m.current = !1;
|
|
518
|
+
}), []), F(() => {
|
|
519
|
+
if (!(!n || n.length === 0) && !i.current) {
|
|
520
|
+
i.current = !0, s(!0);
|
|
506
521
|
try {
|
|
507
522
|
a && a.length > 0 && ce.register(a);
|
|
508
|
-
const h = Me.createManyFromJSON(n),
|
|
509
|
-
if (
|
|
510
|
-
const
|
|
511
|
-
h.forEach((
|
|
512
|
-
var
|
|
513
|
-
const $ = (
|
|
514
|
-
o.addElementToArtboard(
|
|
523
|
+
const h = Me.createManyFromJSON(n), v = o.getAllArtboards();
|
|
524
|
+
if (v.length > 0) {
|
|
525
|
+
const w = new Map(v.map((A) => [A.name, A]));
|
|
526
|
+
h.forEach((A, S) => {
|
|
527
|
+
var u;
|
|
528
|
+
const $ = (u = n[S]) == null ? void 0 : u.artboard, T = $ && w.get($) || v[0];
|
|
529
|
+
o.addElementToArtboard(A.id, T.id);
|
|
515
530
|
});
|
|
516
531
|
}
|
|
517
532
|
t(h);
|
|
518
|
-
const
|
|
519
|
-
for (const
|
|
520
|
-
const
|
|
521
|
-
typeof
|
|
533
|
+
const c = /* @__PURE__ */ new Set();
|
|
534
|
+
for (const w of h) {
|
|
535
|
+
const A = w.fontFamily;
|
|
536
|
+
typeof A == "string" && A.trim().length > 0 && c.add(A);
|
|
522
537
|
}
|
|
523
|
-
if (
|
|
524
|
-
const
|
|
525
|
-
(
|
|
526
|
-
),
|
|
527
|
-
ce.forFamilies(
|
|
538
|
+
if (c.size > 0 && typeof document < "u") {
|
|
539
|
+
const w = document.fonts ?? null, A = Array.from(c).filter(
|
|
540
|
+
(u) => ce.has(u)
|
|
541
|
+
), S = Ft(
|
|
542
|
+
ce.forFamilies(A),
|
|
528
543
|
{
|
|
529
|
-
onLoadError: (
|
|
530
|
-
|
|
544
|
+
onLoadError: (u) => {
|
|
545
|
+
m.current && e({
|
|
531
546
|
category: "import",
|
|
532
|
-
message:
|
|
533
|
-
originalError:
|
|
547
|
+
message: u.message,
|
|
548
|
+
originalError: u,
|
|
534
549
|
recoverable: !0
|
|
535
550
|
});
|
|
536
551
|
}
|
|
537
552
|
}
|
|
538
|
-
),
|
|
539
|
-
(
|
|
540
|
-
).map((
|
|
541
|
-
const
|
|
542
|
-
let
|
|
543
|
-
return
|
|
553
|
+
), T = Array.from(c).filter(
|
|
554
|
+
(u) => !ce.has(u)
|
|
555
|
+
).map((u) => {
|
|
556
|
+
const x = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
|
|
557
|
+
let d = document.getElementById(x);
|
|
558
|
+
return d || (d = document.createElement("link"), d.id = x, d.rel = "stylesheet", d.href = `https://fonts.googleapis.com/css2?family=${u.replace(
|
|
544
559
|
/\s+/g,
|
|
545
560
|
"+"
|
|
546
|
-
)}:wght@400;700&display=swap`, document.head.appendChild(
|
|
547
|
-
if (
|
|
548
|
-
|
|
561
|
+
)}:wght@400;700&display=swap`, document.head.appendChild(d)), new Promise((p) => {
|
|
562
|
+
if (d.sheet) {
|
|
563
|
+
p(u);
|
|
549
564
|
return;
|
|
550
565
|
}
|
|
551
|
-
const
|
|
552
|
-
|
|
566
|
+
const b = () => p(u);
|
|
567
|
+
d.addEventListener("load", b, { once: !0 }), d.addEventListener("error", b, { once: !0 }), setTimeout(b, 4e3);
|
|
553
568
|
});
|
|
554
569
|
});
|
|
555
|
-
Promise.all([Promise.all(
|
|
556
|
-
if (!(!
|
|
570
|
+
Promise.all([Promise.all(T), S]).then(([u]) => {
|
|
571
|
+
if (!(!m.current || !w))
|
|
557
572
|
return Promise.all(
|
|
558
|
-
|
|
559
|
-
|
|
573
|
+
u.flatMap((x) => [
|
|
574
|
+
w.load(`400 16px "${x}"`).catch(() => {
|
|
560
575
|
}),
|
|
561
|
-
|
|
576
|
+
w.load(`700 16px "${x}"`).catch(() => {
|
|
562
577
|
})
|
|
563
578
|
])
|
|
564
579
|
);
|
|
565
580
|
}).then(() => {
|
|
566
|
-
|
|
581
|
+
m.current && t((u) => u.slice());
|
|
567
582
|
});
|
|
568
583
|
}
|
|
569
584
|
} catch (h) {
|
|
570
585
|
Q.error("Failed to load initial elements:", h);
|
|
571
|
-
const
|
|
586
|
+
const v = h instanceof Error ? h : new Error(String(h));
|
|
572
587
|
e({
|
|
573
588
|
category: "import",
|
|
574
|
-
message: `Failed to load initial elements: ${
|
|
575
|
-
originalError:
|
|
589
|
+
message: `Failed to load initial elements: ${v.message}`,
|
|
590
|
+
originalError: v,
|
|
576
591
|
recoverable: !0
|
|
577
592
|
});
|
|
578
593
|
}
|
|
579
594
|
}
|
|
580
|
-
}, [n, o, t, e, a]), { initialElementsLoadedState:
|
|
595
|
+
}, [n, o, t, e, a]), { initialElementsLoadedState: l };
|
|
581
596
|
}
|
|
582
597
|
function Jt(r) {
|
|
583
598
|
const {
|
|
@@ -586,151 +601,151 @@ function Jt(r) {
|
|
|
586
601
|
initialImageAlignment: a,
|
|
587
602
|
initialImageScale: t,
|
|
588
603
|
initialImageScaleMode: o,
|
|
589
|
-
initialImageRole:
|
|
590
|
-
artboardConfigs:
|
|
604
|
+
initialImageRole: i,
|
|
605
|
+
artboardConfigs: l,
|
|
591
606
|
onImageLoad: s,
|
|
592
|
-
onImageError:
|
|
607
|
+
onImageError: m,
|
|
593
608
|
emitError: h
|
|
594
|
-
} = r, { elements:
|
|
595
|
-
return
|
|
596
|
-
if (!n ||
|
|
597
|
-
if (
|
|
598
|
-
|
|
609
|
+
} = r, { elements: v, setElements: c, artboardManager: w } = se(), [A, S] = oe("idle"), [$, T] = oe(null), u = N(void 0);
|
|
610
|
+
return F(() => {
|
|
611
|
+
if (!n || u.current === n) return;
|
|
612
|
+
if (v.length > 0) {
|
|
613
|
+
u.current = n;
|
|
599
614
|
return;
|
|
600
615
|
}
|
|
601
|
-
|
|
602
|
-
|
|
616
|
+
u.current = n, (async () => {
|
|
617
|
+
S("loading"), T(null);
|
|
603
618
|
try {
|
|
604
|
-
const
|
|
605
|
-
if (
|
|
619
|
+
const d = w.getAllArtboards();
|
|
620
|
+
if (d.length === 0)
|
|
606
621
|
throw new Error("No artboards available");
|
|
607
|
-
const
|
|
608
|
-
for (const
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
const
|
|
612
|
-
if (!
|
|
613
|
-
Q.error("Failed to load image for artboard:",
|
|
622
|
+
const p = [];
|
|
623
|
+
for (const b of d) {
|
|
624
|
+
const g = l == null ? void 0 : l.find((I) => I.name === b.name), k = (g == null ? void 0 : g.scaleMode) || o, E = (g == null ? void 0 : g.imageRegions) ?? [];
|
|
625
|
+
if (E.length > 0) {
|
|
626
|
+
const I = await At(n);
|
|
627
|
+
if (!I.success || !I.width || !I.height) {
|
|
628
|
+
Q.error("Failed to load image for artboard:", b.name, I.error);
|
|
614
629
|
continue;
|
|
615
630
|
}
|
|
616
|
-
for (const W of
|
|
617
|
-
const L = St(
|
|
631
|
+
for (const W of E) {
|
|
632
|
+
const L = St(I.width / I.height, W), H = await Ie(
|
|
618
633
|
n,
|
|
619
634
|
{
|
|
620
|
-
artboard: { width: L.width, height: L.height, x:
|
|
635
|
+
artboard: { width: L.width, height: L.height, x: b.x + L.centerX - L.width / 2, y: b.y + L.centerY - L.height / 2 },
|
|
621
636
|
alignment: "center",
|
|
622
637
|
scale: 1,
|
|
623
638
|
scaleMode: "cover"
|
|
624
639
|
},
|
|
625
640
|
{ transformData: { type: "image", width: L.width, height: L.height, cropX: L.cropX, cropY: L.cropY, cropWidth: L.cropWidth, cropHeight: L.cropHeight } }
|
|
626
641
|
);
|
|
627
|
-
H.success && H.element ? (
|
|
642
|
+
H.success && H.element ? (w.addElementToArtboard(H.element.id, b.id), p.push(H.element)) : Q.error("Failed to load image for a panel of artboard:", b.name, H.error);
|
|
628
643
|
}
|
|
629
644
|
continue;
|
|
630
645
|
}
|
|
631
|
-
const
|
|
646
|
+
const f = await Ie(
|
|
632
647
|
n,
|
|
633
648
|
{
|
|
634
649
|
artboard: {
|
|
635
|
-
width:
|
|
636
|
-
height:
|
|
637
|
-
x:
|
|
638
|
-
y:
|
|
650
|
+
width: b.width,
|
|
651
|
+
height: b.height,
|
|
652
|
+
x: b.x,
|
|
653
|
+
y: b.y
|
|
639
654
|
},
|
|
640
|
-
alignment: (
|
|
655
|
+
alignment: (g == null ? void 0 : g.fitAlign) || a,
|
|
641
656
|
scale: t,
|
|
642
|
-
scaleMode:
|
|
643
|
-
marginTop:
|
|
644
|
-
marginRight:
|
|
645
|
-
marginBottom:
|
|
646
|
-
marginLeft:
|
|
657
|
+
scaleMode: k,
|
|
658
|
+
marginTop: g == null ? void 0 : g.fitMarginTop,
|
|
659
|
+
marginRight: g == null ? void 0 : g.fitMarginRight,
|
|
660
|
+
marginBottom: g == null ? void 0 : g.fitMarginBottom,
|
|
661
|
+
marginLeft: g == null ? void 0 : g.fitMarginLeft
|
|
647
662
|
}
|
|
648
663
|
);
|
|
649
|
-
|
|
664
|
+
f.success && f.element ? (w.addElementToArtboard(f.element.id, b.id), p.push(f.element)) : Q.error("Failed to load image for artboard:", b.name, f.error);
|
|
650
665
|
}
|
|
651
|
-
if (e.length > 0 &&
|
|
652
|
-
const
|
|
653
|
-
for (const
|
|
666
|
+
if (e.length > 0 && p.length > 0) {
|
|
667
|
+
const b = await Zt(Array.from(new Set(e.map((k) => k.fontFamily))));
|
|
668
|
+
for (const k of b)
|
|
654
669
|
h({
|
|
655
670
|
category: "import",
|
|
656
|
-
message: `E_FONT_LOAD_FAILED: the font "${
|
|
671
|
+
message: `E_FONT_LOAD_FAILED: the font "${k}" for initialImageText could not be loaded; its words are drawn in a fallback font until it loads.`,
|
|
657
672
|
recoverable: !0
|
|
658
673
|
});
|
|
659
|
-
const
|
|
660
|
-
const W = Ue(
|
|
661
|
-
return { advance: Ve(
|
|
674
|
+
const g = (k, E, f, I) => {
|
|
675
|
+
const W = Ue(E, f);
|
|
676
|
+
return { advance: Ve(k, E, f, !1, !1, I), ascent: W.ascent, descent: W.descent };
|
|
662
677
|
};
|
|
663
|
-
for (const
|
|
664
|
-
const
|
|
665
|
-
if (!
|
|
666
|
-
const L = { left:
|
|
678
|
+
for (const k of p.slice()) {
|
|
679
|
+
const E = w.getArtboardForElement(k.id), f = k.transformData, I = (f == null ? void 0 : f.width) ?? 0, W = (f == null ? void 0 : f.height) ?? 0;
|
|
680
|
+
if (!E || !(I > 0) || !(W > 0)) continue;
|
|
681
|
+
const L = { left: k.x - I / 2, top: k.y - W / 2, width: I, height: W };
|
|
667
682
|
for (const H of e) {
|
|
668
|
-
const Y = Me.createFromJSON(Kt(H, L,
|
|
669
|
-
|
|
683
|
+
const Y = Me.createFromJSON(Kt(H, L, g));
|
|
684
|
+
w.addElementToArtboard(Y.id, E.id), p.push(Y);
|
|
670
685
|
}
|
|
671
686
|
}
|
|
672
687
|
}
|
|
673
|
-
if (
|
|
674
|
-
|
|
688
|
+
if (p.length > 0)
|
|
689
|
+
i === "placeholder" && w.markPlaceholders(p.map((b) => b.id)), c((b) => [...b, ...p]), S("success"), s == null || s(n);
|
|
675
690
|
else {
|
|
676
|
-
const
|
|
677
|
-
|
|
691
|
+
const b = new Error("Failed to load image into any artboard");
|
|
692
|
+
S("error"), T(b), m == null || m(n, b), h({
|
|
678
693
|
category: "image",
|
|
679
|
-
message:
|
|
680
|
-
originalError:
|
|
694
|
+
message: b.message,
|
|
695
|
+
originalError: b,
|
|
681
696
|
recoverable: !0
|
|
682
697
|
});
|
|
683
698
|
}
|
|
684
|
-
} catch (
|
|
685
|
-
const
|
|
686
|
-
|
|
699
|
+
} catch (d) {
|
|
700
|
+
const p = d instanceof Error ? d : new Error(String(d));
|
|
701
|
+
S("error"), T(p), m == null || m(n, p), h({
|
|
687
702
|
category: "image",
|
|
688
|
-
message:
|
|
689
|
-
originalError:
|
|
703
|
+
message: p.message,
|
|
704
|
+
originalError: p,
|
|
690
705
|
recoverable: !0
|
|
691
706
|
});
|
|
692
707
|
}
|
|
693
708
|
})();
|
|
694
|
-
}, [n, e, a, t, o,
|
|
709
|
+
}, [n, e, a, t, o, i]), { imageLoadingState: A, imageError: $ };
|
|
695
710
|
}
|
|
696
711
|
function Qt(r) {
|
|
697
|
-
const { onChange: n, onSelectionChange: e } = r, { elements: a, selectedId: t, artboardManager: o } = se(), { artboards:
|
|
698
|
-
|
|
699
|
-
var
|
|
700
|
-
(
|
|
712
|
+
const { onChange: n, onSelectionChange: e } = r, { elements: a, selectedId: t, artboardManager: o } = se(), { artboards: i } = he(), l = N(e);
|
|
713
|
+
l.current = e, F(() => {
|
|
714
|
+
var m;
|
|
715
|
+
(m = l.current) == null || m.call(l, t);
|
|
701
716
|
}, [t]);
|
|
702
717
|
const s = N(n);
|
|
703
|
-
s.current = n,
|
|
704
|
-
const
|
|
705
|
-
if (!
|
|
706
|
-
const h = o.getActiveArtboard(),
|
|
718
|
+
s.current = n, F(() => {
|
|
719
|
+
const m = s.current;
|
|
720
|
+
if (!m) return;
|
|
721
|
+
const h = o.getActiveArtboard(), v = {
|
|
707
722
|
// Stamp each element with the NAME of the artboard it lives on (the
|
|
708
723
|
// manager is the membership source of truth). Without this the public
|
|
709
724
|
// state is flat and a multi-placement design cannot round-trip: restore
|
|
710
725
|
// collapses everything onto the first artboard, and per-placement render
|
|
711
726
|
// states can't be derived from onChange. Pinned by
|
|
712
727
|
// SnowconeCanvas.artboard-membership.test.tsx.
|
|
713
|
-
elements: a.map((
|
|
714
|
-
const
|
|
715
|
-
return
|
|
728
|
+
elements: a.map((c) => {
|
|
729
|
+
const w = c.toJSON(), A = o.getArtboardForElement(c.id);
|
|
730
|
+
return A ? { ...w, artboard: A.name } : w;
|
|
716
731
|
}),
|
|
717
|
-
artboards:
|
|
718
|
-
name:
|
|
719
|
-
width:
|
|
720
|
-
height:
|
|
721
|
-
clipShape:
|
|
722
|
-
backgroundColor:
|
|
732
|
+
artboards: i.map((c) => ({
|
|
733
|
+
name: c.name,
|
|
734
|
+
width: c.width,
|
|
735
|
+
height: c.height,
|
|
736
|
+
clipShape: c.clipShape,
|
|
737
|
+
backgroundColor: c.backgroundColor,
|
|
723
738
|
// Carried so serializeStateForServer / saved states keep an
|
|
724
739
|
// explicitly-set background renderable (mockup matches editor).
|
|
725
|
-
exportBackground:
|
|
740
|
+
exportBackground: c.exportBackground,
|
|
726
741
|
// Pacing role for multi-page templates (ADR-0086) — emitted only when
|
|
727
742
|
// set so non-template states stay byte-identical.
|
|
728
|
-
...
|
|
743
|
+
...c.role ? { role: c.role } : {}
|
|
729
744
|
})),
|
|
730
745
|
activeArtboard: (h == null ? void 0 : h.name) || "Design"
|
|
731
746
|
};
|
|
732
|
-
|
|
733
|
-
}, [a,
|
|
747
|
+
m(v);
|
|
748
|
+
}, [a, i]);
|
|
734
749
|
}
|
|
735
750
|
function Yt(r, n) {
|
|
736
751
|
const {
|
|
@@ -738,163 +753,163 @@ function Yt(r, n) {
|
|
|
738
753
|
autoExportConfig: a,
|
|
739
754
|
autoExportFormat: t,
|
|
740
755
|
autoExportAll: o,
|
|
741
|
-
exportScale:
|
|
742
|
-
maxExportSize:
|
|
756
|
+
exportScale: i,
|
|
757
|
+
maxExportSize: l,
|
|
743
758
|
exportImageFormat: s,
|
|
744
|
-
exportImageQuality:
|
|
759
|
+
exportImageQuality: m,
|
|
745
760
|
onExport: h,
|
|
746
|
-
onExportScheduled:
|
|
747
|
-
onExportStatus:
|
|
748
|
-
onExportReady:
|
|
749
|
-
onReady:
|
|
750
|
-
hasInitialElements:
|
|
761
|
+
onExportScheduled: v,
|
|
762
|
+
onExportStatus: c,
|
|
763
|
+
onExportReady: w,
|
|
764
|
+
onReady: A,
|
|
765
|
+
hasInitialElements: S,
|
|
751
766
|
initialElementsLoaded: $,
|
|
752
|
-
emitError:
|
|
767
|
+
emitError: T
|
|
753
768
|
} = r, {
|
|
754
|
-
elements:
|
|
755
|
-
artboardManager:
|
|
756
|
-
historyManager:
|
|
757
|
-
isCanvasReady:
|
|
758
|
-
setCanvasReady:
|
|
759
|
-
} = se(), { artboards:
|
|
760
|
-
H.current =
|
|
761
|
-
exportArtboards: async (
|
|
762
|
-
const P =
|
|
769
|
+
elements: u,
|
|
770
|
+
artboardManager: x,
|
|
771
|
+
historyManager: d,
|
|
772
|
+
isCanvasReady: p,
|
|
773
|
+
setCanvasReady: b
|
|
774
|
+
} = se(), { artboards: g } = he(), { exportArtboard: k, exportAllArtboards: E, exportArtboardAsBlob: f, exportAllArtboardsAsBlobs: I } = Et(), W = N(0), L = N(0), H = N(u);
|
|
775
|
+
H.current = u, Ze(n, () => ({
|
|
776
|
+
exportArtboards: async (O = {}) => {
|
|
777
|
+
const P = O.format || t, B = O.scale || i, K = O.all ?? !1;
|
|
763
778
|
let j = B;
|
|
764
|
-
if (
|
|
765
|
-
for (const
|
|
766
|
-
const
|
|
767
|
-
j = Math.min(j,
|
|
779
|
+
if (l > 0 && isFinite(l))
|
|
780
|
+
for (const M of g) {
|
|
781
|
+
const C = ge(M.width, M.height, B, l);
|
|
782
|
+
j = Math.min(j, C);
|
|
768
783
|
}
|
|
769
|
-
const
|
|
784
|
+
const R = { scale: j, format: s, quality: m };
|
|
770
785
|
if (K) {
|
|
771
|
-
const
|
|
772
|
-
for (const [
|
|
773
|
-
const z =
|
|
774
|
-
z && (
|
|
786
|
+
const M = P === "blob" ? await I(R) : await E(R), C = {};
|
|
787
|
+
for (const [D, X] of Object.entries(M)) {
|
|
788
|
+
const z = g.find((J) => J.id === D);
|
|
789
|
+
z && (C[z.name] = X);
|
|
775
790
|
}
|
|
776
|
-
return
|
|
791
|
+
return C;
|
|
777
792
|
} else {
|
|
778
|
-
const
|
|
779
|
-
if (!
|
|
793
|
+
const M = x.getActiveArtboard();
|
|
794
|
+
if (!M)
|
|
780
795
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
781
796
|
if (P === "blob") {
|
|
782
|
-
const
|
|
783
|
-
return { [
|
|
797
|
+
const C = await f(M.id, R);
|
|
798
|
+
return { [M.name]: C };
|
|
784
799
|
} else {
|
|
785
|
-
const
|
|
786
|
-
return { [
|
|
800
|
+
const C = await k(M.id, R);
|
|
801
|
+
return { [M.name]: C };
|
|
787
802
|
}
|
|
788
803
|
}
|
|
789
804
|
},
|
|
790
805
|
// Print files: every artboard (or its regions), lossless PNG, full size, original picture pixels, one at a time.
|
|
791
806
|
// Never the auto-export's format / maxExportSize: those keep the live preview light, a print file is the product.
|
|
792
|
-
exportPrintFiles: (
|
|
793
|
-
|
|
807
|
+
exportPrintFiles: (O = {}) => Gt(
|
|
808
|
+
g,
|
|
794
809
|
(P) => {
|
|
795
|
-
const B = new Set(
|
|
810
|
+
const B = new Set(x.getElementsOnArtboard(P.id));
|
|
796
811
|
return H.current.filter((K) => B.has(K.id));
|
|
797
812
|
},
|
|
798
|
-
|
|
813
|
+
O
|
|
799
814
|
)
|
|
800
|
-
}), [
|
|
801
|
-
|
|
802
|
-
const P =
|
|
815
|
+
}), [k, E, f, I, t, i, l, s, m, x, g]), F(() => {
|
|
816
|
+
w && w(async () => {
|
|
817
|
+
const P = x.getActiveArtboard();
|
|
803
818
|
if (!P)
|
|
804
819
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
805
820
|
const B = ge(
|
|
806
821
|
P.width,
|
|
807
822
|
P.height,
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
), K = t === "blob" ? await
|
|
823
|
+
i,
|
|
824
|
+
l
|
|
825
|
+
), K = t === "blob" ? await f(P.id, { scale: B }) : await k(P.id, { scale: B });
|
|
811
826
|
return { [P.name]: K };
|
|
812
827
|
});
|
|
813
|
-
}, [
|
|
828
|
+
}, [w, k, f, x, t, i, l]);
|
|
814
829
|
const Y = V(async () => {
|
|
815
|
-
if (!h && !
|
|
816
|
-
const
|
|
817
|
-
let B =
|
|
818
|
-
if (
|
|
819
|
-
for (const
|
|
820
|
-
const
|
|
821
|
-
B = Math.min(B,
|
|
830
|
+
if (!h && !c) return;
|
|
831
|
+
const O = ++L.current, P = Date.now();
|
|
832
|
+
let B = i;
|
|
833
|
+
if (l > 0 && isFinite(l))
|
|
834
|
+
for (const R of g) {
|
|
835
|
+
const M = ge(R.width, R.height, i, l);
|
|
836
|
+
B = Math.min(B, M);
|
|
822
837
|
}
|
|
823
|
-
const K =
|
|
824
|
-
|
|
838
|
+
const K = x.getActiveArtboard(), j = (K == null ? void 0 : K.id) ?? "unknown";
|
|
839
|
+
c == null || c({ status: "rendering", artboardId: j }), W.current = P;
|
|
825
840
|
try {
|
|
826
|
-
let
|
|
827
|
-
const
|
|
841
|
+
let R;
|
|
842
|
+
const M = {
|
|
828
843
|
format: s,
|
|
829
844
|
scale: B,
|
|
830
|
-
quality:
|
|
845
|
+
quality: m
|
|
831
846
|
};
|
|
832
847
|
if (t === "blob")
|
|
833
848
|
if (o) {
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
for (const [
|
|
837
|
-
const z =
|
|
838
|
-
z && (
|
|
849
|
+
const C = await I(M);
|
|
850
|
+
R = {};
|
|
851
|
+
for (const [D, X] of Object.entries(C)) {
|
|
852
|
+
const z = g.find((J) => J.id === D);
|
|
853
|
+
z && (R[z.name] = X);
|
|
839
854
|
}
|
|
840
855
|
} else {
|
|
841
|
-
const
|
|
842
|
-
if (!
|
|
843
|
-
const
|
|
844
|
-
|
|
856
|
+
const C = x.getActiveArtboard();
|
|
857
|
+
if (!C) return;
|
|
858
|
+
const D = await f(C.id, M);
|
|
859
|
+
R = { [C.name]: D };
|
|
845
860
|
}
|
|
846
861
|
else if (o) {
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
for (const [
|
|
850
|
-
const z =
|
|
851
|
-
z && (
|
|
862
|
+
const C = await E(M);
|
|
863
|
+
R = {};
|
|
864
|
+
for (const [D, X] of Object.entries(C)) {
|
|
865
|
+
const z = g.find((J) => J.id === D);
|
|
866
|
+
z && (R[z.name] = X);
|
|
852
867
|
}
|
|
853
868
|
} else {
|
|
854
|
-
const
|
|
855
|
-
if (!
|
|
856
|
-
const
|
|
857
|
-
|
|
869
|
+
const C = x.getActiveArtboard();
|
|
870
|
+
if (!C) return;
|
|
871
|
+
const D = await k(C.id, M);
|
|
872
|
+
R = { [C.name]: D };
|
|
858
873
|
}
|
|
859
|
-
h == null || h(
|
|
860
|
-
} catch (
|
|
861
|
-
const
|
|
862
|
-
if (
|
|
874
|
+
h == null || h(R), c == null || c({ status: "complete", artboardId: j, result: R });
|
|
875
|
+
} catch (R) {
|
|
876
|
+
const M = R instanceof Error ? R.message : String(R);
|
|
877
|
+
if (M.includes("Canvas ref not available"))
|
|
863
878
|
return;
|
|
864
|
-
const
|
|
865
|
-
Q.error("Export failed (export #" +
|
|
866
|
-
duration: `${
|
|
867
|
-
error:
|
|
879
|
+
const C = Date.now() - P;
|
|
880
|
+
Q.error("Export failed (export #" + O + "):", {
|
|
881
|
+
duration: `${C}ms`,
|
|
882
|
+
error: M
|
|
868
883
|
});
|
|
869
|
-
const
|
|
870
|
-
|
|
884
|
+
const D = R instanceof Error ? R : new Error(M);
|
|
885
|
+
c == null || c({ status: "error", artboardId: j, error: D }), T({
|
|
871
886
|
category: "export",
|
|
872
|
-
message:
|
|
873
|
-
originalError:
|
|
887
|
+
message: D.message,
|
|
888
|
+
originalError: D,
|
|
874
889
|
artboardId: j,
|
|
875
890
|
recoverable: !0
|
|
876
891
|
});
|
|
877
892
|
}
|
|
878
|
-
}, [h,
|
|
879
|
-
|
|
893
|
+
}, [h, c, o, t, i, l, s, m, k, E, f, I, g, x, u, a, T]);
|
|
894
|
+
F(() => {
|
|
880
895
|
e !== void 0 && e > 0 && Q.warn(
|
|
881
896
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
882
897
|
);
|
|
883
898
|
}, []);
|
|
884
899
|
const de = V(() => {
|
|
885
|
-
if (
|
|
886
|
-
const
|
|
887
|
-
|
|
900
|
+
if (v == null || v(), c) {
|
|
901
|
+
const O = x.getActiveArtboard();
|
|
902
|
+
c({ status: "scheduled", artboardId: (O == null ? void 0 : O.id) ?? "unknown" });
|
|
888
903
|
}
|
|
889
|
-
}, [
|
|
890
|
-
isCanvasReady:
|
|
891
|
-
elements:
|
|
892
|
-
hasInitialElements:
|
|
904
|
+
}, [v, c, x]), re = Wt({
|
|
905
|
+
isCanvasReady: p,
|
|
906
|
+
elements: u,
|
|
907
|
+
hasInitialElements: S,
|
|
893
908
|
initialElementsLoaded: $
|
|
894
909
|
}), ie = N(!1);
|
|
895
|
-
|
|
896
|
-
re && !ie.current && (ie.current = !0,
|
|
897
|
-
}, [re,
|
|
910
|
+
F(() => {
|
|
911
|
+
re && !ie.current && (ie.current = !0, A == null || A());
|
|
912
|
+
}, [re, A]), $t({
|
|
898
913
|
config: a ? {
|
|
899
914
|
enabled: a.enabled ?? !0,
|
|
900
915
|
debounceMs: a.debounceMs ?? 100,
|
|
@@ -903,23 +918,23 @@ function Yt(r, n) {
|
|
|
903
918
|
enabled: !1
|
|
904
919
|
// Only use smart export if autoExportConfig is provided
|
|
905
920
|
},
|
|
906
|
-
historyManager:
|
|
907
|
-
artboards:
|
|
908
|
-
elements:
|
|
921
|
+
historyManager: d,
|
|
922
|
+
artboards: g,
|
|
923
|
+
elements: u,
|
|
909
924
|
onExport: Y,
|
|
910
925
|
onExportScheduled: de,
|
|
911
926
|
isCanvasReady: re
|
|
912
927
|
// Gate exports until content is fully ready (fonts loaded, elements deserialized)
|
|
913
|
-
}),
|
|
914
|
-
if (
|
|
915
|
-
const
|
|
916
|
-
|
|
928
|
+
}), F(() => {
|
|
929
|
+
if (g.length > 0 && !p) {
|
|
930
|
+
const O = requestAnimationFrame(() => {
|
|
931
|
+
b(!0);
|
|
917
932
|
});
|
|
918
|
-
return () => cancelAnimationFrame(
|
|
933
|
+
return () => cancelAnimationFrame(O);
|
|
919
934
|
}
|
|
920
|
-
}, [
|
|
921
|
-
|
|
922
|
-
}, [
|
|
935
|
+
}, [g.length, p, b]), F(() => () => {
|
|
936
|
+
b(!1);
|
|
937
|
+
}, [b]);
|
|
923
938
|
}
|
|
924
939
|
async function Zt(r) {
|
|
925
940
|
if (typeof document > "u" || r.length === 0) return [];
|
|
@@ -949,66 +964,66 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
|
|
|
949
964
|
imageConfig: a,
|
|
950
965
|
layoutConfig: t,
|
|
951
966
|
kit: o,
|
|
952
|
-
artboards:
|
|
953
|
-
activeArtboard:
|
|
967
|
+
artboards: i,
|
|
968
|
+
activeArtboard: l,
|
|
954
969
|
onArtboardChange: s,
|
|
955
|
-
initialElements:
|
|
970
|
+
initialElements: m,
|
|
956
971
|
customFonts: h,
|
|
957
|
-
onChange:
|
|
958
|
-
onSelectionChange:
|
|
959
|
-
autoExportInterval:
|
|
960
|
-
onExport:
|
|
961
|
-
onExportScheduled:
|
|
972
|
+
onChange: v,
|
|
973
|
+
onSelectionChange: c,
|
|
974
|
+
autoExportInterval: w,
|
|
975
|
+
onExport: A,
|
|
976
|
+
onExportScheduled: S,
|
|
962
977
|
onExportStatus: $,
|
|
963
|
-
onExportReady:
|
|
964
|
-
onImageLoad:
|
|
965
|
-
onImageError:
|
|
966
|
-
onImageLoadError:
|
|
967
|
-
onError:
|
|
968
|
-
onReady:
|
|
969
|
-
className:
|
|
970
|
-
style:
|
|
971
|
-
enableShortcuts:
|
|
972
|
-
overlay:
|
|
973
|
-
resetDocumentOnMount:
|
|
974
|
-
} = r, W =
|
|
975
|
-
|
|
978
|
+
onExportReady: T,
|
|
979
|
+
onImageLoad: u,
|
|
980
|
+
onImageError: x,
|
|
981
|
+
onImageLoadError: d,
|
|
982
|
+
onError: p,
|
|
983
|
+
onReady: b,
|
|
984
|
+
className: g,
|
|
985
|
+
style: k,
|
|
986
|
+
enableShortcuts: E,
|
|
987
|
+
overlay: f,
|
|
988
|
+
resetDocumentOnMount: I
|
|
989
|
+
} = r, W = w, L = r.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig), H = r.autoExportFormat ?? (e == null ? void 0 : e.format) ?? "dataUrl", Y = r.autoExportAll ?? (e == null ? void 0 : e.exportAll) ?? !1, de = r.exportScale ?? (e == null ? void 0 : e.scale) ?? 2, re = r.maxExportSize ?? (e == null ? void 0 : e.maxSize) ?? 4e3, ie = r.exportImageFormat ?? (e == null ? void 0 : e.imageFormat) ?? "png", O = r.exportImageQuality ?? (e == null ? void 0 : e.imageQuality) ?? 0.92, P = r.initialImage ?? (a == null ? void 0 : a.src), B = r.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", K = r.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, j = r.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", R = r.initialImageRole ?? (a == null ? void 0 : a.role) ?? "design", M = Qe.useMemo(() => Ht(r.initialImageText, P), [r.initialImageText, P]), C = r.width ?? (t == null ? void 0 : t.width) ?? 1200, D = r.height ?? (t == null ? void 0 : t.height) ?? 1200, X = r.viewPadding ?? (t == null ? void 0 : t.viewPadding) ?? 0.9, z = r.artboardBorderRadius ?? (t == null ? void 0 : t.artboardBorderRadius) ?? 0, J = r.fixedMargin ?? (t == null ? void 0 : t.fixedMargin), Pe = r.maxHeight ?? (t == null ? void 0 : t.maxHeight), $e = r.showRotationHandle ?? (t == null ? void 0 : t.showRotationHandle) ?? !0, Oe = r.hideCanvas ?? (t == null ? void 0 : t.hideCanvas) ?? !1, be = r.canvasWrapperClassName ?? (t == null ? void 0 : t.canvasWrapperClassName), ve = r.canvasWrapperStyle ?? (t == null ? void 0 : t.canvasWrapperStyle), De = r.canvasCutouts ?? (t == null ? void 0 : t.canvasCutouts), Ee = r.pieceGuides, Be = r.pieceFocus, We = E ?? !0, Z = Re(() => it(o ?? "pro-studio"), [o]);
|
|
990
|
+
F(() => {
|
|
976
991
|
var U;
|
|
977
992
|
if (typeof ee < "u" && ((U = ee.env) == null ? void 0 : U.NODE_ENV) === "development" && Z) {
|
|
978
993
|
const G = ct(Z);
|
|
979
994
|
G.valid || Fe.warn("Kit validation warnings:", G.errors), G.warnings.length > 0 && Fe.warn("Kit validation warnings:", G.warnings);
|
|
980
995
|
}
|
|
981
|
-
}, [Z]),
|
|
982
|
-
if (
|
|
983
|
-
return Xe(
|
|
984
|
-
}, [
|
|
985
|
-
const { emitError: ue, handleBoundaryError: He } = Ut(
|
|
996
|
+
}, [Z]), F(() => {
|
|
997
|
+
if (d)
|
|
998
|
+
return Xe(d);
|
|
999
|
+
}, [d]);
|
|
1000
|
+
const { emitError: ue, handleBoundaryError: He } = Ut(p);
|
|
986
1001
|
Vt({
|
|
987
|
-
artboardConfigs:
|
|
988
|
-
width:
|
|
989
|
-
height:
|
|
1002
|
+
artboardConfigs: i,
|
|
1003
|
+
width: C,
|
|
1004
|
+
height: D,
|
|
990
1005
|
pieceGuides: Ee,
|
|
991
|
-
controlledActiveArtboard:
|
|
1006
|
+
controlledActiveArtboard: l,
|
|
992
1007
|
onArtboardChange: s,
|
|
993
|
-
resetDocumentOnMount:
|
|
1008
|
+
resetDocumentOnMount: I
|
|
994
1009
|
});
|
|
995
1010
|
const { initialElementsLoadedState: Ke } = Xt({
|
|
996
|
-
initialElements:
|
|
1011
|
+
initialElements: m,
|
|
997
1012
|
customFonts: h,
|
|
998
1013
|
emitError: ue
|
|
999
1014
|
}), { imageLoadingState: ye, imageError: xe } = Jt({
|
|
1000
1015
|
initialImage: P,
|
|
1001
|
-
initialImageText:
|
|
1016
|
+
initialImageText: M,
|
|
1002
1017
|
initialImageAlignment: B,
|
|
1003
1018
|
initialImageScale: K,
|
|
1004
1019
|
initialImageScaleMode: j,
|
|
1005
|
-
initialImageRole:
|
|
1006
|
-
artboardConfigs:
|
|
1007
|
-
onImageLoad:
|
|
1008
|
-
onImageError:
|
|
1020
|
+
initialImageRole: R,
|
|
1021
|
+
artboardConfigs: i,
|
|
1022
|
+
onImageLoad: u,
|
|
1023
|
+
onImageError: x,
|
|
1009
1024
|
emitError: ue
|
|
1010
1025
|
});
|
|
1011
|
-
if (Qt({ onChange:
|
|
1026
|
+
if (Qt({ onChange: v, onSelectionChange: c }), Yt(
|
|
1012
1027
|
{
|
|
1013
1028
|
autoExportInterval: W,
|
|
1014
1029
|
autoExportConfig: L,
|
|
@@ -1017,39 +1032,39 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
|
|
|
1017
1032
|
exportScale: de,
|
|
1018
1033
|
maxExportSize: re,
|
|
1019
1034
|
exportImageFormat: ie,
|
|
1020
|
-
exportImageQuality:
|
|
1021
|
-
onExport:
|
|
1022
|
-
onExportScheduled:
|
|
1035
|
+
exportImageQuality: O,
|
|
1036
|
+
onExport: A,
|
|
1037
|
+
onExportScheduled: S,
|
|
1023
1038
|
onExportStatus: $,
|
|
1024
|
-
onExportReady:
|
|
1025
|
-
onReady:
|
|
1026
|
-
hasInitialElements: !!
|
|
1039
|
+
onExportReady: T,
|
|
1040
|
+
onReady: b,
|
|
1041
|
+
hasInitialElements: !!m && m.length > 0,
|
|
1027
1042
|
initialElementsLoaded: Ke,
|
|
1028
1043
|
emitError: ue
|
|
1029
1044
|
},
|
|
1030
1045
|
n
|
|
1031
1046
|
), ye === "loading")
|
|
1032
|
-
return /* @__PURE__ */
|
|
1047
|
+
return /* @__PURE__ */ y(
|
|
1033
1048
|
"div",
|
|
1034
1049
|
{
|
|
1035
|
-
className:
|
|
1050
|
+
className: g,
|
|
1036
1051
|
style: {
|
|
1037
|
-
...
|
|
1052
|
+
...k,
|
|
1038
1053
|
display: "flex",
|
|
1039
1054
|
alignItems: "center",
|
|
1040
1055
|
justifyContent: "center",
|
|
1041
1056
|
backgroundColor: "var(--surface, #f5f5f5)"
|
|
1042
1057
|
},
|
|
1043
|
-
children: /* @__PURE__ */
|
|
1058
|
+
children: /* @__PURE__ */ y(lt, { size: 48 })
|
|
1044
1059
|
}
|
|
1045
1060
|
);
|
|
1046
1061
|
if (ye === "error" && xe)
|
|
1047
|
-
return /* @__PURE__ */
|
|
1062
|
+
return /* @__PURE__ */ y(
|
|
1048
1063
|
"div",
|
|
1049
1064
|
{
|
|
1050
|
-
className:
|
|
1065
|
+
className: g,
|
|
1051
1066
|
style: {
|
|
1052
|
-
...
|
|
1067
|
+
...k,
|
|
1053
1068
|
display: "flex",
|
|
1054
1069
|
alignItems: "center",
|
|
1055
1070
|
justifyContent: "center",
|
|
@@ -1058,15 +1073,15 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
|
|
|
1058
1073
|
padding: "1rem"
|
|
1059
1074
|
},
|
|
1060
1075
|
children: /* @__PURE__ */ _("div", { className: "sc:text-center", children: [
|
|
1061
|
-
/* @__PURE__ */
|
|
1062
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ y("div", { className: "sc:font-medium", children: "Failed to load image" }),
|
|
1077
|
+
/* @__PURE__ */ y("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: xe.message })
|
|
1063
1078
|
] })
|
|
1064
1079
|
}
|
|
1065
1080
|
);
|
|
1066
1081
|
const je = Object.entries(((we = Z.layout) == null ? void 0 : we.slots) ?? {}).every(
|
|
1067
1082
|
([U, G]) => U === "canvas" || !G || G.length === 0
|
|
1068
1083
|
) ? { "--color-canvas-bg": "transparent" } : void 0;
|
|
1069
|
-
return /* @__PURE__ */
|
|
1084
|
+
return /* @__PURE__ */ y(dt, { kit: Z, children: /* @__PURE__ */ y("div", { className: `sc-root ${g || ""}`, style: { ...je, ...k, position: "relative" }, children: /* @__PURE__ */ _(
|
|
1070
1085
|
Nt,
|
|
1071
1086
|
{
|
|
1072
1087
|
onError: He,
|
|
@@ -1086,9 +1101,9 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
|
|
|
1086
1101
|
textAlign: "center"
|
|
1087
1102
|
},
|
|
1088
1103
|
children: [
|
|
1089
|
-
/* @__PURE__ */
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
/* @__PURE__ */
|
|
1104
|
+
/* @__PURE__ */ y("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
|
|
1105
|
+
/* @__PURE__ */ y("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: U.message }),
|
|
1106
|
+
/* @__PURE__ */ y(
|
|
1092
1107
|
"button",
|
|
1093
1108
|
{
|
|
1094
1109
|
onClick: G,
|
|
@@ -1109,8 +1124,8 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
|
|
|
1109
1124
|
}
|
|
1110
1125
|
),
|
|
1111
1126
|
children: [
|
|
1112
|
-
!
|
|
1113
|
-
const U = /* @__PURE__ */
|
|
1127
|
+
!Oe && /* @__PURE__ */ (() => {
|
|
1128
|
+
const U = /* @__PURE__ */ y(
|
|
1114
1129
|
ut,
|
|
1115
1130
|
{
|
|
1116
1131
|
style: { width: "100%" },
|
|
@@ -1120,30 +1135,30 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
|
|
|
1120
1135
|
maxHeight: Pe,
|
|
1121
1136
|
showRotationHandle: $e,
|
|
1122
1137
|
enableShortcuts: We,
|
|
1123
|
-
canvasCutouts:
|
|
1138
|
+
canvasCutouts: De,
|
|
1124
1139
|
pieceGuides: Ee,
|
|
1125
1140
|
pieceFocus: Be
|
|
1126
1141
|
}
|
|
1127
1142
|
);
|
|
1128
|
-
return /* @__PURE__ */
|
|
1143
|
+
return /* @__PURE__ */ y(Mt, { kit: Z, canvas: be || ve ? /* @__PURE__ */ y("div", { className: be, style: ve, children: U }) : U });
|
|
1129
1144
|
})(),
|
|
1130
|
-
|
|
1145
|
+
f
|
|
1131
1146
|
]
|
|
1132
1147
|
}
|
|
1133
1148
|
) }) });
|
|
1134
1149
|
});
|
|
1135
1150
|
Le.displayName = "SnowconeCanvasInner";
|
|
1136
1151
|
const qt = Ce((r, n) => {
|
|
1137
|
-
var
|
|
1138
|
-
const { inheritTheme: e, externalProvider: a, services: t } = r, o = r.viewPadding ?? ((
|
|
1139
|
-
return /* @__PURE__ */
|
|
1152
|
+
var i;
|
|
1153
|
+
const { inheritTheme: e, externalProvider: a, services: t } = r, o = r.viewPadding ?? ((i = r.layoutConfig) == null ? void 0 : i.viewPadding);
|
|
1154
|
+
return /* @__PURE__ */ y(
|
|
1140
1155
|
Lt,
|
|
1141
1156
|
{
|
|
1142
1157
|
inheritTheme: e,
|
|
1143
1158
|
externalProvider: a,
|
|
1144
1159
|
services: t,
|
|
1145
1160
|
viewPadding: o,
|
|
1146
|
-
children: /* @__PURE__ */
|
|
1161
|
+
children: /* @__PURE__ */ y(Le, { ref: n, ...r })
|
|
1147
1162
|
}
|
|
1148
1163
|
);
|
|
1149
1164
|
});
|
|
@@ -1154,4 +1169,4 @@ export {
|
|
|
1154
1169
|
Wt as a,
|
|
1155
1170
|
$t as u
|
|
1156
1171
|
};
|
|
1157
|
-
//# sourceMappingURL=SnowconeCanvas-
|
|
1172
|
+
//# sourceMappingURL=SnowconeCanvas-COXpmwkS.js.map
|