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