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