@snowcone-app/canvas 0.33.1 → 0.35.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-1j-twIbs.js → CanvasRenderer-BHBCxI-B.js} +4 -4
- package/dist/{CanvasRenderer-1j-twIbs.js.map → CanvasRenderer-BHBCxI-B.js.map} +1 -1
- package/dist/{CanvasStateV1-BmC1JfPv.js → CanvasStateV1-BoG8ld4D.js} +3 -3
- package/dist/{CanvasStateV1-BmC1JfPv.js.map → CanvasStateV1-BoG8ld4D.js.map} +1 -1
- package/dist/{ContextualToolbars-BrllZJTn.js → ContextualToolbars-TCO7dzu6.js} +6 -6
- package/dist/{ContextualToolbars-BrllZJTn.js.map → ContextualToolbars-TCO7dzu6.js.map} +1 -1
- package/dist/{EditorCanvasImpl-BiNG1dIj.js → EditorCanvasImpl-Dl75xnjk.js} +7 -7
- package/dist/{EditorCanvasImpl-BiNG1dIj.js.map → EditorCanvasImpl-Dl75xnjk.js.map} +1 -1
- package/dist/{ExportManager-Ci81K6xA.js → ExportManager-D1PAlOiE.js} +2 -2
- package/dist/{ExportManager-Ci81K6xA.js.map → ExportManager-D1PAlOiE.js.map} +1 -1
- package/dist/{FontAnalyzer-BrKY6XYn.js → FontAnalyzer-CEYA_6fY.js} +476 -439
- package/dist/FontAnalyzer-CEYA_6fY.js.map +1 -0
- package/dist/ImagePanel-Duh1AMdF.js +984 -0
- package/dist/ImagePanel-Duh1AMdF.js.map +1 -0
- package/dist/{SnowconeCanvas-DjQFFTDh.js → SnowconeCanvas-h8cfofsO.js} +296 -292
- package/dist/{SnowconeCanvas-DjQFFTDh.js.map → SnowconeCanvas-h8cfofsO.js.map} +1 -1
- package/dist/advanced.mjs +14 -14
- package/dist/api/stable.d.ts +1 -0
- package/dist/components/ImageBrowserDrawer.d.ts +4 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +9 -0
- package/dist/contexts/CanvasServicesContext.d.ts +17 -1
- package/dist/core/ImageElement.d.ts +6 -0
- package/dist/core/ImageLoadEvents.d.ts +33 -0
- package/dist/{custom-icons-QEBlxVyq.js → custom-icons-DYIOjjXt.js} +2 -2
- package/dist/{custom-icons-QEBlxVyq.js.map → custom-icons-DYIOjjXt.js.map} +1 -1
- package/dist/{design-builder-D4izkvlb.js → design-builder-CqgTpp9B.js} +2 -2
- package/dist/{design-builder-D4izkvlb.js.map → design-builder-CqgTpp9B.js.map} +1 -1
- package/dist/{embed-C6kwN09N.js → embed-p_FskJ1G.js} +10 -10
- package/dist/{embed-C6kwN09N.js.map → embed-p_FskJ1G.js.map} +1 -1
- package/dist/embed.mjs +7 -7
- package/dist/{guards-BhaQgJrE.js → guards-DldCuuJq.js} +2 -2
- package/dist/{guards-BhaQgJrE.js.map → guards-DldCuuJq.js.map} +1 -1
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +6 -6
- package/dist/services/imageSearch.d.ts +24 -0
- package/dist/style.css +1 -1
- package/dist/{template-fields-xVQZRXvc.js → template-fields-jgE6czak.js} +5 -5
- package/dist/{template-fields-xVQZRXvc.js.map → template-fields-jgE6czak.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/{useCommands-DmewMc5w.js → useCommands-D16Tq-B-.js} +517 -499
- package/dist/{useCommands-DmewMc5w.js.map → useCommands-D16Tq-B-.js.map} +1 -1
- package/dist/{usePieceGuideBundle-CnSmYrmM.js → usePieceGuideBundle-BUQKb0Ja.js} +2 -2
- package/dist/{usePieceGuideBundle-CnSmYrmM.js.map → usePieceGuideBundle-BUQKb0Ja.js.map} +1 -1
- package/dist/{validation-CA6cMSOX.js → validation-8QF2gWih.js} +11 -11
- package/dist/{validation-CA6cMSOX.js.map → validation-8QF2gWih.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/FontAnalyzer-BrKY6XYn.js.map +0 -1
- package/dist/ImagePanel-Ckpc6QqR.js +0 -951
- package/dist/ImagePanel-Ckpc6QqR.js.map +0 -1
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { z as G, c as Q, aB as
|
|
2
|
-
import { jsx as y, Fragment as
|
|
3
|
-
import { useMemo as Se, useRef as F, useEffect as
|
|
4
|
-
import { l as
|
|
5
|
-
import { ImagePanel as
|
|
6
|
-
import { d as
|
|
7
|
-
import { E as
|
|
8
|
-
import { C as
|
|
9
|
-
import { E as
|
|
1
|
+
import { z as G, c as Q, aB as De, I as Be, aC as We } from "./FontAnalyzer-CEYA_6fY.js";
|
|
2
|
+
import { jsx as y, Fragment as $e, jsxs as V } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as Se, useRef as F, useEffect as k, Component as He, useState as Z, useCallback as O, useImperativeHandle as ze, forwardRef as Ae } from "react";
|
|
4
|
+
import { l as Oe, e as Ke, f as Ue, G as Xe, a as je, Z as Ye, i as Ve, b as Ge, D as Qe, r as qe, v as Je, S as Ze, g as _e, c as et } from "./validation-8QF2gWih.js";
|
|
5
|
+
import { ImagePanel as tt } from "./ImagePanel-Duh1AMdF.js";
|
|
6
|
+
import { d as rt, e as nt } from "./ContextualToolbars-TCO7dzu6.js";
|
|
7
|
+
import { E as at, p as ot, q as st, C as it, u as fe, g as ct } from "./useCommands-D16Tq-B-.js";
|
|
8
|
+
import { C as lt, D as dt } from "./template-fields-jgE6czak.js";
|
|
9
|
+
import { E as ut, u as ee } from "./design-builder-CqgTpp9B.js";
|
|
10
10
|
import { T as xe } from "./ThemeContext-Rjz25x9X.js";
|
|
11
|
-
import { c as re, K as
|
|
12
|
-
import { C as le } from "./CanvasRenderer-
|
|
11
|
+
import { c as re, K as ft, e as mt } from "./ExportManager-D1PAlOiE.js";
|
|
12
|
+
import { C as le } from "./CanvasRenderer-BHBCxI-B.js";
|
|
13
13
|
const me = Q("KitLayout"), J = "canvas", de = 320;
|
|
14
14
|
let ye = !1;
|
|
15
|
-
function
|
|
16
|
-
ye || (ye = !0,
|
|
17
|
-
EffectsPanel:
|
|
18
|
-
ExportPanel:
|
|
19
|
-
ImagePanel:
|
|
20
|
-
GlyphPanel:
|
|
21
|
-
ArtboardTabs:
|
|
22
|
-
ContextualToolbars:
|
|
23
|
-
ZoomControls:
|
|
24
|
-
CropPanel:
|
|
15
|
+
function gt() {
|
|
16
|
+
ye || (ye = !0, Oe({
|
|
17
|
+
EffectsPanel: Ke,
|
|
18
|
+
ExportPanel: Ue,
|
|
19
|
+
ImagePanel: tt,
|
|
20
|
+
GlyphPanel: Xe,
|
|
21
|
+
ArtboardTabs: je,
|
|
22
|
+
ContextualToolbars: rt,
|
|
23
|
+
ZoomControls: Ye,
|
|
24
|
+
CropPanel: nt
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ht({ children: n }) {
|
|
28
28
|
const e = F(null);
|
|
29
29
|
if (e.current === null) {
|
|
30
|
-
const t = new
|
|
30
|
+
const t = new at();
|
|
31
31
|
t.registerCanvas("legacy-kit-canvas"), e.current = {
|
|
32
|
-
store: new
|
|
33
|
-
commerce: new
|
|
32
|
+
store: new dt({ elements: [], artboards: [], activeArtboard: "" }),
|
|
33
|
+
commerce: new lt({ productId: "", mockupIds: [] }),
|
|
34
34
|
registry: t,
|
|
35
|
-
...
|
|
35
|
+
...ot((a) => me.error("[kit section]", a))
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
return /* @__PURE__ */ y(
|
|
38
|
+
return /* @__PURE__ */ y(st.Provider, { value: e.current, children: n });
|
|
39
39
|
}
|
|
40
40
|
function ne({ ids: n }) {
|
|
41
|
-
return !n || n.length === 0 ? null : /* @__PURE__ */ y(
|
|
41
|
+
return !n || n.length === 0 ? null : /* @__PURE__ */ y(ht, { children: n.map((e) => {
|
|
42
42
|
var r;
|
|
43
43
|
if (e === J) return null;
|
|
44
|
-
const t =
|
|
44
|
+
const t = Ve(e);
|
|
45
45
|
if (!t)
|
|
46
46
|
return typeof G < "u" && ((r = G.env) == null ? void 0 : r.NODE_ENV) === "development" && me.warn(
|
|
47
47
|
`Kit layout references unknown section "${e}" — skipping. Register it with registerSection("${e}", { ... }).`
|
|
@@ -50,29 +50,29 @@ function ne({ ids: n }) {
|
|
|
50
50
|
return /* @__PURE__ */ y(a, {}, e);
|
|
51
51
|
}) });
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function pt({ kit: n, canvas: e }) {
|
|
54
54
|
var p, u, b, E;
|
|
55
|
-
|
|
55
|
+
gt();
|
|
56
56
|
const t = n.layout.slots, a = !!((p = t.topbar) != null && p.some((w) => w !== J)), r = !!((u = t.left) != null && u.some((w) => w !== J)), s = !!((b = t.right) != null && b.some((w) => w !== J)), l = !!((E = t.bottombar) != null && E.some((w) => w !== J)), d = Se(
|
|
57
57
|
() => !a && !r && !s && !l,
|
|
58
58
|
[a, r, s, l]
|
|
59
|
-
), i = F(null), f = a || r || s || l,
|
|
60
|
-
return
|
|
59
|
+
), i = F(null), f = a || r || s || l, g = F(!1);
|
|
60
|
+
return k(() => {
|
|
61
61
|
var o;
|
|
62
62
|
if (typeof G > "u" || ((o = G.env) == null ? void 0 : o.NODE_ENV) !== "development" || !f) return;
|
|
63
63
|
const w = i.current;
|
|
64
64
|
if (!w || typeof ResizeObserver > "u") return;
|
|
65
65
|
const A = (c) => {
|
|
66
|
-
c > 0 && c < de && !
|
|
66
|
+
c > 0 && c < de && !g.current ? (g.current = !0, me.warn(
|
|
67
67
|
`Kit "${n.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(c)}px wide — below the ~${de}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.`
|
|
68
|
-
)) : c >= de && (
|
|
68
|
+
)) : c >= de && (g.current = !1);
|
|
69
69
|
};
|
|
70
70
|
A(w.getBoundingClientRect().width);
|
|
71
71
|
const v = new ResizeObserver((c) => {
|
|
72
|
-
for (const
|
|
72
|
+
for (const m of c) A(m.contentRect.width);
|
|
73
73
|
});
|
|
74
74
|
return v.observe(w), () => v.disconnect();
|
|
75
|
-
}, [f, n.name]), d ? /* @__PURE__ */ y(
|
|
75
|
+
}, [f, n.name]), d ? /* @__PURE__ */ y($e, { children: e }) : /* @__PURE__ */ V("div", { ref: i, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
|
|
76
76
|
a && /* @__PURE__ */ y(
|
|
77
77
|
"div",
|
|
78
78
|
{
|
|
@@ -96,8 +96,8 @@ function gt({ kit: n, canvas: e }) {
|
|
|
96
96
|
)
|
|
97
97
|
] });
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
class
|
|
99
|
+
const bt = Q("ErrorBoundary");
|
|
100
|
+
class vt extends He {
|
|
101
101
|
constructor(e) {
|
|
102
102
|
super(e), this.resetError = () => {
|
|
103
103
|
this.setState({
|
|
@@ -116,7 +116,7 @@ class pt extends We {
|
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
componentDidCatch(e, t) {
|
|
119
|
-
if (
|
|
119
|
+
if (bt.error("Caught error:", e, t), this.props.onError && this.props.onError(e, t), this.props.onCanvasError) {
|
|
120
120
|
const a = {
|
|
121
121
|
category: "unknown",
|
|
122
122
|
message: e.message,
|
|
@@ -177,45 +177,45 @@ class pt extends We {
|
|
|
177
177
|
) : this.props.children;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function Et({
|
|
181
181
|
inheritTheme: n,
|
|
182
182
|
externalProvider: e,
|
|
183
183
|
services: t,
|
|
184
184
|
viewPadding: a,
|
|
185
185
|
children: r
|
|
186
186
|
}) {
|
|
187
|
-
const s = e ? /* @__PURE__ */ y(xe, { defaultTheme: "light", passive: n, children: r }) : /* @__PURE__ */ y(xe, { defaultTheme: "light", passive: n, children: /* @__PURE__ */ y(
|
|
188
|
-
return t ? /* @__PURE__ */ y(
|
|
187
|
+
const s = e ? /* @__PURE__ */ y(xe, { defaultTheme: "light", passive: n, children: r }) : /* @__PURE__ */ y(xe, { defaultTheme: "light", passive: n, children: /* @__PURE__ */ y(ut, { viewPadding: a, children: r }) });
|
|
188
|
+
return t ? /* @__PURE__ */ y(it, { services: t, children: s }) : s;
|
|
189
189
|
}
|
|
190
|
-
const
|
|
191
|
-
function
|
|
192
|
-
const { config: e, historyManager: t, artboards: a, elements: r, onExport: s, onExportScheduled: l, isCanvasReady: d = !1 } = n, i = F(null), f = F(!1),
|
|
190
|
+
const xt = Q("useAutoExport");
|
|
191
|
+
function yt(n) {
|
|
192
|
+
const { config: e, historyManager: t, artboards: a, elements: r, onExport: s, onExportScheduled: l, isCanvasReady: d = !1 } = n, i = F(null), f = F(!1), g = F({
|
|
193
193
|
totalExports: 0,
|
|
194
194
|
skippedExports: 0,
|
|
195
195
|
lastExportTime: null,
|
|
196
196
|
avgExportInterval: 0
|
|
197
|
-
}), [p, u] = Z(
|
|
198
|
-
b.current = s,
|
|
199
|
-
const o = new
|
|
200
|
-
...
|
|
197
|
+
}), [p, u] = Z(g.current), b = F(s);
|
|
198
|
+
b.current = s, k(() => {
|
|
199
|
+
const o = new Ge({
|
|
200
|
+
...Qe,
|
|
201
201
|
...e
|
|
202
202
|
});
|
|
203
203
|
return o.onExport(async () => {
|
|
204
204
|
try {
|
|
205
|
-
await b.current(),
|
|
205
|
+
await b.current(), g.current = o.getStats();
|
|
206
206
|
} catch (c) {
|
|
207
|
-
|
|
207
|
+
xt.error("[useAutoExport] Export failed:", c);
|
|
208
208
|
}
|
|
209
209
|
}), i.current = o, () => {
|
|
210
210
|
o.destroy();
|
|
211
211
|
};
|
|
212
|
-
}, []),
|
|
212
|
+
}, []), k(() => {
|
|
213
213
|
d && f.current && i.current && (f.current = !1, i.current.forceExport());
|
|
214
|
-
}, [d]),
|
|
214
|
+
}, [d]), k(() => {
|
|
215
215
|
i.current && e && i.current.updateConfig(e);
|
|
216
|
-
}, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]),
|
|
216
|
+
}, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]), k(() => {
|
|
217
217
|
i.current && l && i.current.onExportScheduled(l);
|
|
218
|
-
}, [l]),
|
|
218
|
+
}, [l]), k(() => {
|
|
219
219
|
if (!t || !i.current)
|
|
220
220
|
return;
|
|
221
221
|
const o = t.onCommandExecuted(() => {
|
|
@@ -230,7 +230,7 @@ function Et(n) {
|
|
|
230
230
|
return () => {
|
|
231
231
|
o();
|
|
232
232
|
};
|
|
233
|
-
}, [t, d]),
|
|
233
|
+
}, [t, d]), k(() => {
|
|
234
234
|
if (i.current) {
|
|
235
235
|
if (!d) {
|
|
236
236
|
f.current = !0;
|
|
@@ -238,16 +238,16 @@ function Et(n) {
|
|
|
238
238
|
}
|
|
239
239
|
i.current.scheduleExport();
|
|
240
240
|
}
|
|
241
|
-
}, [r, a, d]),
|
|
241
|
+
}, [r, a, d]), k(() => De((c) => {
|
|
242
242
|
if (!i.current || !d) return;
|
|
243
243
|
r.some((x) => x.id === c) && i.current.scheduleExport();
|
|
244
244
|
}), [r, d]);
|
|
245
245
|
const E = O((o) => {
|
|
246
246
|
i.current && i.current.updateConfig(o);
|
|
247
247
|
}, []), w = O(async () => {
|
|
248
|
-
i.current && (await i.current.forceExport(),
|
|
248
|
+
i.current && (await i.current.forceExport(), g.current = i.current.getStats(), u(g.current));
|
|
249
249
|
}, []), A = O(() => {
|
|
250
|
-
i.current && (i.current.resetStats(),
|
|
250
|
+
i.current && (i.current.resetStats(), g.current = i.current.getStats(), u(g.current));
|
|
251
251
|
}, []), v = O(() => {
|
|
252
252
|
i.current && i.current.resetChangeDetection();
|
|
253
253
|
}, []);
|
|
@@ -259,8 +259,8 @@ function Et(n) {
|
|
|
259
259
|
resetChangeDetection: v
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
|
-
const
|
|
263
|
-
function
|
|
262
|
+
const Ie = Q("useContentReady");
|
|
263
|
+
function wt(n) {
|
|
264
264
|
var t;
|
|
265
265
|
const e = /* @__PURE__ */ new Set();
|
|
266
266
|
for (const a of n)
|
|
@@ -274,7 +274,7 @@ function xt(n) {
|
|
|
274
274
|
}
|
|
275
275
|
return Array.from(e);
|
|
276
276
|
}
|
|
277
|
-
async function
|
|
277
|
+
async function St(n) {
|
|
278
278
|
if (n.length === 0 || typeof document > "u" || !document.fonts) return;
|
|
279
279
|
const e = [];
|
|
280
280
|
for (const t of n) {
|
|
@@ -284,24 +284,24 @@ async function yt(n) {
|
|
|
284
284
|
await Promise.all(e), document.fonts.ready && await Promise.race([
|
|
285
285
|
document.fonts.ready,
|
|
286
286
|
new Promise((t) => setTimeout(t, 250))
|
|
287
|
-
]),
|
|
287
|
+
]), Ie.debug(`Awaited ${e.length} font(s)`);
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function At() {
|
|
290
290
|
return new Promise((n) => requestAnimationFrame(() => n()));
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function It(n) {
|
|
293
293
|
const { isCanvasReady: e, elements: t, hasInitialElements: a, initialElementsLoaded: r } = n, [s, l] = Z(!1), d = F(!1);
|
|
294
|
-
return
|
|
294
|
+
return k(() => {
|
|
295
295
|
if (s || !e || a && !r || a && t.length === 0 || d.current) return;
|
|
296
296
|
d.current = !0;
|
|
297
297
|
let i = !1;
|
|
298
298
|
return (async () => {
|
|
299
299
|
try {
|
|
300
|
-
const f =
|
|
301
|
-
if (f.length > 0 && (await
|
|
300
|
+
const f = wt(t);
|
|
301
|
+
if (f.length > 0 && (await St(f), i) || (await At(), i)) return;
|
|
302
302
|
l(!0);
|
|
303
303
|
} catch (f) {
|
|
304
|
-
|
|
304
|
+
Ie.error("Error during content readiness check:", f), i || l(!0);
|
|
305
305
|
} finally {
|
|
306
306
|
d.current = !1;
|
|
307
307
|
}
|
|
@@ -310,7 +310,7 @@ function St(n) {
|
|
|
310
310
|
};
|
|
311
311
|
}, [e, t, a, r, s]), s;
|
|
312
312
|
}
|
|
313
|
-
const
|
|
313
|
+
const kt = {
|
|
314
314
|
// Vertical alignments (map to top/center/bottom center)
|
|
315
315
|
"far-top": "t",
|
|
316
316
|
top: "t",
|
|
@@ -333,13 +333,13 @@ const At = {
|
|
|
333
333
|
b: "b",
|
|
334
334
|
br: "br"
|
|
335
335
|
};
|
|
336
|
-
function
|
|
337
|
-
return n &&
|
|
336
|
+
function Rt(n) {
|
|
337
|
+
return n && kt[n] || "c";
|
|
338
338
|
}
|
|
339
|
-
function
|
|
340
|
-
const t = e.scaleMode || "cover", a = (t === "contain" ? e.marginTop : 0) || 0, r = (t === "contain" ? e.marginRight : 0) || 0, s = (t === "contain" ? e.marginBottom : 0) || 0, l = (t === "contain" ? e.marginLeft : 0) || 0, d = e.width - l - r, i = e.height - a - s, f = d / n.width,
|
|
339
|
+
function Ct(n, e) {
|
|
340
|
+
const t = e.scaleMode || "cover", a = (t === "contain" ? e.marginTop : 0) || 0, r = (t === "contain" ? e.marginRight : 0) || 0, s = (t === "contain" ? e.marginBottom : 0) || 0, l = (t === "contain" ? e.marginLeft : 0) || 0, d = e.width - l - r, i = e.height - a - s, f = d / n.width, g = i / n.height, p = t === "contain" ? Math.min(f, g) : Math.max(f, g), u = e.scale || 1, b = p * u, E = n.width * b, w = n.height * b, A = e.align || "c";
|
|
341
341
|
let v = 0, o = 0;
|
|
342
|
-
const c = E - d,
|
|
342
|
+
const c = E - d, m = w - i;
|
|
343
343
|
switch (A) {
|
|
344
344
|
// Top row
|
|
345
345
|
case "tl":
|
|
@@ -353,30 +353,30 @@ function It(n, e) {
|
|
|
353
353
|
break;
|
|
354
354
|
// Middle row
|
|
355
355
|
case "l":
|
|
356
|
-
v = 0, o = -
|
|
356
|
+
v = 0, o = -m / 2;
|
|
357
357
|
break;
|
|
358
358
|
case "c":
|
|
359
359
|
// Center (default)
|
|
360
360
|
default:
|
|
361
|
-
v = -c / 2, o = -
|
|
361
|
+
v = -c / 2, o = -m / 2;
|
|
362
362
|
break;
|
|
363
363
|
case "r":
|
|
364
|
-
v = -c, o = -
|
|
364
|
+
v = -c, o = -m / 2;
|
|
365
365
|
break;
|
|
366
366
|
// Bottom row
|
|
367
367
|
case "bl":
|
|
368
|
-
v = 0, o = -
|
|
368
|
+
v = 0, o = -m;
|
|
369
369
|
break;
|
|
370
370
|
case "b":
|
|
371
|
-
v = -c / 2, o = -
|
|
371
|
+
v = -c / 2, o = -m;
|
|
372
372
|
break;
|
|
373
373
|
case "br":
|
|
374
|
-
v = -c, o = -
|
|
374
|
+
v = -c, o = -m;
|
|
375
375
|
break;
|
|
376
376
|
}
|
|
377
377
|
v += l, o += a;
|
|
378
|
-
const x = e.offsetX || 0, S = e.offsetY || 0, h = c,
|
|
379
|
-
return v += x * h, o += S *
|
|
378
|
+
const x = e.offsetX || 0, S = e.offsetY || 0, h = c, I = m;
|
|
379
|
+
return v += x * h, o += S * I, v = Math.round(v), o = Math.round(o), {
|
|
380
380
|
// Final scale to apply to artwork
|
|
381
381
|
scale: b,
|
|
382
382
|
// Final artwork dimensions after scaling
|
|
@@ -389,19 +389,19 @@ function It(n, e) {
|
|
|
389
389
|
debug: {
|
|
390
390
|
coverScale: p,
|
|
391
391
|
userScale: u,
|
|
392
|
-
overflow: { x: c, y:
|
|
392
|
+
overflow: { x: c, y: m },
|
|
393
393
|
alignment: A,
|
|
394
|
-
appliedOffset: { x: x * h, y: S *
|
|
394
|
+
appliedOffset: { x: x * h, y: S * I }
|
|
395
395
|
}
|
|
396
396
|
};
|
|
397
397
|
}
|
|
398
|
-
const
|
|
398
|
+
const Mt = {
|
|
399
399
|
timeout: 3e4,
|
|
400
400
|
retries: 1,
|
|
401
401
|
retryDelay: 1e3,
|
|
402
402
|
validateUrl: !0
|
|
403
403
|
};
|
|
404
|
-
function
|
|
404
|
+
function Ft(n) {
|
|
405
405
|
try {
|
|
406
406
|
const e = new URL(n);
|
|
407
407
|
return ["http:", "https:", "data:", "blob:"].includes(e.protocol);
|
|
@@ -409,9 +409,9 @@ function Ct(n) {
|
|
|
409
409
|
return !1;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
async function
|
|
413
|
-
const t = { ...
|
|
414
|
-
if (t.validateUrl && !
|
|
412
|
+
async function Nt(n, e = {}) {
|
|
413
|
+
const t = { ...Mt, ...e };
|
|
414
|
+
if (t.validateUrl && !Ft(n))
|
|
415
415
|
return {
|
|
416
416
|
success: !1,
|
|
417
417
|
error: new Error(`Invalid image URL: ${n}`)
|
|
@@ -419,16 +419,16 @@ async function Mt(n, e = {}) {
|
|
|
419
419
|
let a;
|
|
420
420
|
for (let r = 0; r <= t.retries; r++)
|
|
421
421
|
try {
|
|
422
|
-
return await
|
|
422
|
+
return await Lt(n, t.timeout);
|
|
423
423
|
} catch (s) {
|
|
424
|
-
a = s instanceof Error ? s : new Error(String(s)), r < t.retries && await
|
|
424
|
+
a = s instanceof Error ? s : new Error(String(s)), r < t.retries && await Tt(t.retryDelay);
|
|
425
425
|
}
|
|
426
426
|
return {
|
|
427
427
|
success: !1,
|
|
428
428
|
error: a || new Error("Failed to load image after retries")
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function Lt(n, e) {
|
|
432
432
|
return new Promise((t) => {
|
|
433
433
|
const a = new Image();
|
|
434
434
|
a.crossOrigin = "anonymous";
|
|
@@ -438,13 +438,13 @@ function Ft(n, e) {
|
|
|
438
438
|
}, d = () => {
|
|
439
439
|
if (s) return;
|
|
440
440
|
s = !0, l();
|
|
441
|
-
const f = a.naturalWidth || a.width,
|
|
441
|
+
const f = a.naturalWidth || a.width, g = a.naturalHeight || a.height;
|
|
442
442
|
t({
|
|
443
443
|
success: !0,
|
|
444
444
|
element: a,
|
|
445
445
|
width: f,
|
|
446
|
-
height:
|
|
447
|
-
aspectRatio:
|
|
446
|
+
height: g,
|
|
447
|
+
aspectRatio: g > 0 ? f / g : 1
|
|
448
448
|
});
|
|
449
449
|
}, i = (f) => {
|
|
450
450
|
s || (s = !0, l(), t({
|
|
@@ -459,9 +459,9 @@ function Ft(n, e) {
|
|
|
459
459
|
}, e), a.src = n;
|
|
460
460
|
});
|
|
461
461
|
}
|
|
462
|
-
async function
|
|
462
|
+
async function Pt(n, e, t = {}, a = {}) {
|
|
463
463
|
var u, b, E, w, A, v, o;
|
|
464
|
-
const r = await
|
|
464
|
+
const r = await Nt(n, a);
|
|
465
465
|
if (!r.success || !r.width || !r.height)
|
|
466
466
|
return {
|
|
467
467
|
success: !1,
|
|
@@ -471,7 +471,7 @@ async function Nt(n, e, t = {}, a = {}) {
|
|
|
471
471
|
width: e.artboard.width,
|
|
472
472
|
height: e.artboard.height,
|
|
473
473
|
scale: e.scale,
|
|
474
|
-
align:
|
|
474
|
+
align: Rt(e.alignment),
|
|
475
475
|
offsetX: e.offsetX,
|
|
476
476
|
offsetY: e.offsetY,
|
|
477
477
|
scaleMode: e.scaleMode,
|
|
@@ -479,16 +479,16 @@ async function Nt(n, e, t = {}, a = {}) {
|
|
|
479
479
|
marginRight: e.marginRight,
|
|
480
480
|
marginBottom: e.marginBottom,
|
|
481
481
|
marginLeft: e.marginLeft
|
|
482
|
-
}, l =
|
|
482
|
+
}, l = Ct(
|
|
483
483
|
{ width: r.width, height: r.height },
|
|
484
484
|
s
|
|
485
|
-
), d = e.artboard.x + l.x, i = e.artboard.y + l.y, f = d + l.width / 2,
|
|
485
|
+
), d = e.artboard.x + l.x, i = e.artboard.y + l.y, f = d + l.width / 2, g = i + l.height / 2;
|
|
486
486
|
return {
|
|
487
487
|
success: !0,
|
|
488
|
-
element: new
|
|
488
|
+
element: new Be({
|
|
489
489
|
...t,
|
|
490
490
|
x: f,
|
|
491
|
-
y:
|
|
491
|
+
y: g,
|
|
492
492
|
imageUrl: n,
|
|
493
493
|
imageAspectRatio: r.aspectRatio,
|
|
494
494
|
preserveDimensions: !0,
|
|
@@ -509,12 +509,12 @@ async function Nt(n, e, t = {}, a = {}) {
|
|
|
509
509
|
placement: {
|
|
510
510
|
artworkSize: { width: r.width, height: r.height },
|
|
511
511
|
finalSize: { width: l.width, height: l.height },
|
|
512
|
-
position: { x: f, y:
|
|
512
|
+
position: { x: f, y: g },
|
|
513
513
|
scale: l.scale
|
|
514
514
|
}
|
|
515
515
|
};
|
|
516
516
|
}
|
|
517
|
-
function
|
|
517
|
+
function Tt(n) {
|
|
518
518
|
return new Promise((e) => setTimeout(e, n));
|
|
519
519
|
}
|
|
520
520
|
const _ = Q("SnowconeCanvas");
|
|
@@ -527,14 +527,14 @@ function ue(n, e, t, a) {
|
|
|
527
527
|
const d = Math.max(n, e), i = a / d;
|
|
528
528
|
return Math.min(i, t);
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function Dt(n) {
|
|
531
531
|
const e = F(n);
|
|
532
532
|
e.current = n;
|
|
533
533
|
const t = O((r) => {
|
|
534
534
|
var s;
|
|
535
535
|
_.error(`[${r.category}] ${r.message}`, r.originalError), (s = e.current) == null || s.call(e, r);
|
|
536
536
|
}, []);
|
|
537
|
-
|
|
537
|
+
k(() => (le.onRenderError = t, () => {
|
|
538
538
|
le.onRenderError === t && (le.onRenderError = null);
|
|
539
539
|
}), [t]);
|
|
540
540
|
const a = O((r) => {
|
|
@@ -547,7 +547,7 @@ function Lt(n) {
|
|
|
547
547
|
}, [t]);
|
|
548
548
|
return { emitError: t, handleBoundaryError: a };
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function Bt(n) {
|
|
551
551
|
const {
|
|
552
552
|
artboardConfigs: e,
|
|
553
553
|
width: t,
|
|
@@ -559,23 +559,23 @@ function Tt(n) {
|
|
|
559
559
|
} = n, {
|
|
560
560
|
setElements: i,
|
|
561
561
|
setSelectedId: f,
|
|
562
|
-
setMultiSelection:
|
|
562
|
+
setMultiSelection: g,
|
|
563
563
|
artboardManager: p,
|
|
564
564
|
refreshArtboards: u
|
|
565
565
|
} = ee(), { createArtboard: b, selectArtboard: E, artboards: w } = fe(), A = F(!1), v = F(!1);
|
|
566
|
-
|
|
566
|
+
k(() => {
|
|
567
567
|
if (A.current) return;
|
|
568
568
|
A.current = !0;
|
|
569
|
-
const o = e || [{ name: "Design", width: t, height: a }], c = r ? "transparent" : void 0,
|
|
569
|
+
const o = e || [{ name: "Design", width: t, height: a }], c = r ? "transparent" : void 0, m = (S) => S.exportBackground ?? (!!S.backgroundColor && S.backgroundColor !== "transparent");
|
|
570
570
|
if (d) {
|
|
571
|
-
p.clear(), i([]), f(null),
|
|
571
|
+
p.clear(), i([]), f(null), g([]);
|
|
572
572
|
for (const h of o)
|
|
573
573
|
p.createArtboard({
|
|
574
574
|
name: h.name,
|
|
575
575
|
width: h.width,
|
|
576
576
|
height: h.height,
|
|
577
577
|
backgroundColor: h.backgroundColor ?? c,
|
|
578
|
-
exportBackground:
|
|
578
|
+
exportBackground: m(h),
|
|
579
579
|
clipShape: h.clipShape,
|
|
580
580
|
role: h.role
|
|
581
581
|
});
|
|
@@ -586,19 +586,19 @@ function Tt(n) {
|
|
|
586
586
|
const x = p.getAllArtboards();
|
|
587
587
|
if (x.length > 0) {
|
|
588
588
|
const S = o[0], h = x[0];
|
|
589
|
-
h.name = S.name, h.width = S.width, h.height = S.height, h.clipShape = S.clipShape, h.exportBackground =
|
|
590
|
-
for (let
|
|
591
|
-
b(o[
|
|
592
|
-
name: o[
|
|
593
|
-
backgroundColor: o[
|
|
594
|
-
exportBackground:
|
|
595
|
-
clipShape: o[
|
|
596
|
-
role: o[
|
|
589
|
+
h.name = S.name, h.width = S.width, h.height = S.height, h.clipShape = S.clipShape, h.exportBackground = m(S), h.role = S.role, S.backgroundColor ? h.backgroundColor = S.backgroundColor : c && (h.backgroundColor = c);
|
|
590
|
+
for (let I = 1; I < o.length; I++)
|
|
591
|
+
b(o[I].width, o[I].height, {
|
|
592
|
+
name: o[I].name,
|
|
593
|
+
backgroundColor: o[I].backgroundColor ?? c,
|
|
594
|
+
exportBackground: m(o[I]),
|
|
595
|
+
clipShape: o[I].clipShape,
|
|
596
|
+
role: o[I].role
|
|
597
597
|
});
|
|
598
598
|
!s && o.length > 1 && p.setActiveArtboard(h.id);
|
|
599
599
|
}
|
|
600
600
|
u();
|
|
601
|
-
}, []),
|
|
601
|
+
}, []), k(() => {
|
|
602
602
|
if (!s) {
|
|
603
603
|
v.current = !0;
|
|
604
604
|
return;
|
|
@@ -608,40 +608,40 @@ function Tt(n) {
|
|
|
608
608
|
const c = p.getActiveArtboard();
|
|
609
609
|
(c == null ? void 0 : c.name) !== s && E(o.id), v.current = !0;
|
|
610
610
|
}
|
|
611
|
-
}, [s, w]),
|
|
611
|
+
}, [s, w]), k(() => {
|
|
612
612
|
if (!l || !v.current) return;
|
|
613
613
|
const o = p.getActiveArtboard();
|
|
614
614
|
o && l(o.name);
|
|
615
615
|
}, [p.getActiveArtboardId()]);
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function Wt(n) {
|
|
618
618
|
const { initialElements: e, emitError: t, customFonts: a } = n, { setElements: r, artboardManager: s } = ee(), l = F(!1), [d, i] = Z(!1), f = F(!0);
|
|
619
|
-
return
|
|
619
|
+
return k(() => (f.current = !0, () => {
|
|
620
620
|
f.current = !1;
|
|
621
|
-
}), []),
|
|
621
|
+
}), []), k(() => {
|
|
622
622
|
if (!(!e || e.length === 0) && !l.current) {
|
|
623
623
|
l.current = !0, i(!0);
|
|
624
624
|
try {
|
|
625
625
|
a && a.length > 0 && re.register(a);
|
|
626
|
-
const
|
|
626
|
+
const g = ft.createManyFromJSON(e), p = s.getAllArtboards();
|
|
627
627
|
if (p.length > 0) {
|
|
628
628
|
const b = new Map(p.map((E) => [E.name, E]));
|
|
629
|
-
|
|
629
|
+
g.forEach((E, w) => {
|
|
630
630
|
var o;
|
|
631
631
|
const A = (o = e[w]) == null ? void 0 : o.artboard, v = A && b.get(A) || p[0];
|
|
632
632
|
s.addElementToArtboard(E.id, v.id);
|
|
633
633
|
});
|
|
634
634
|
}
|
|
635
|
-
r(
|
|
635
|
+
r(g);
|
|
636
636
|
const u = /* @__PURE__ */ new Set();
|
|
637
|
-
for (const b of
|
|
637
|
+
for (const b of g) {
|
|
638
638
|
const E = b.fontFamily;
|
|
639
639
|
typeof E == "string" && E.trim().length > 0 && u.add(E);
|
|
640
640
|
}
|
|
641
641
|
if (u.size > 0 && typeof document < "u") {
|
|
642
642
|
const b = document.fonts ?? null, E = Array.from(u).filter(
|
|
643
643
|
(o) => re.has(o)
|
|
644
|
-
), w =
|
|
644
|
+
), w = mt(
|
|
645
645
|
re.forFamilies(E),
|
|
646
646
|
{
|
|
647
647
|
onLoadError: (o) => {
|
|
@@ -657,17 +657,17 @@ function Dt(n) {
|
|
|
657
657
|
(o) => !re.has(o)
|
|
658
658
|
).map((o) => {
|
|
659
659
|
const c = `font-${o.replace(/\s+/g, "-").toLowerCase()}`;
|
|
660
|
-
let
|
|
661
|
-
return
|
|
660
|
+
let m = document.getElementById(c);
|
|
661
|
+
return m || (m = document.createElement("link"), m.id = c, m.rel = "stylesheet", m.href = `https://fonts.googleapis.com/css2?family=${o.replace(
|
|
662
662
|
/\s+/g,
|
|
663
663
|
"+"
|
|
664
|
-
)}:wght@400;700&display=swap`, document.head.appendChild(
|
|
665
|
-
if (
|
|
664
|
+
)}:wght@400;700&display=swap`, document.head.appendChild(m)), new Promise((x) => {
|
|
665
|
+
if (m.sheet) {
|
|
666
666
|
x(o);
|
|
667
667
|
return;
|
|
668
668
|
}
|
|
669
669
|
const S = () => x(o);
|
|
670
|
-
|
|
670
|
+
m.addEventListener("load", S, { once: !0 }), m.addEventListener("error", S, { once: !0 }), setTimeout(S, 4e3);
|
|
671
671
|
});
|
|
672
672
|
});
|
|
673
673
|
Promise.all([Promise.all(v), w]).then(([o]) => {
|
|
@@ -684,9 +684,9 @@ function Dt(n) {
|
|
|
684
684
|
f.current && r((o) => o.slice());
|
|
685
685
|
});
|
|
686
686
|
}
|
|
687
|
-
} catch (
|
|
688
|
-
_.error("Failed to load initial elements:",
|
|
689
|
-
const p =
|
|
687
|
+
} catch (g) {
|
|
688
|
+
_.error("Failed to load initial elements:", g);
|
|
689
|
+
const p = g instanceof Error ? g : new Error(String(g));
|
|
690
690
|
t({
|
|
691
691
|
category: "import",
|
|
692
692
|
message: `Failed to load initial elements: ${p.message}`,
|
|
@@ -697,7 +697,7 @@ function Dt(n) {
|
|
|
697
697
|
}
|
|
698
698
|
}, [e, s, r, t, a]), { initialElementsLoadedState: d };
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function $t(n) {
|
|
701
701
|
const {
|
|
702
702
|
initialImage: e,
|
|
703
703
|
initialImageAlignment: t,
|
|
@@ -707,8 +707,8 @@ function Bt(n) {
|
|
|
707
707
|
onImageLoad: l,
|
|
708
708
|
onImageError: d,
|
|
709
709
|
emitError: i
|
|
710
|
-
} = n, { elements: f, setElements:
|
|
711
|
-
return
|
|
710
|
+
} = n, { elements: f, setElements: g, artboardManager: p } = ee(), [u, b] = Z("idle"), [E, w] = Z(null), A = F(void 0);
|
|
711
|
+
return k(() => {
|
|
712
712
|
if (!e || A.current === e) return;
|
|
713
713
|
if (f.length > 0) {
|
|
714
714
|
A.current = e;
|
|
@@ -721,15 +721,15 @@ function Bt(n) {
|
|
|
721
721
|
if (o.length === 0)
|
|
722
722
|
throw new Error("No artboards available");
|
|
723
723
|
const c = [];
|
|
724
|
-
for (const
|
|
725
|
-
const x = s == null ? void 0 : s.find((
|
|
724
|
+
for (const m of o) {
|
|
725
|
+
const x = s == null ? void 0 : s.find((I) => I.name === m.name), S = (x == null ? void 0 : x.scaleMode) || r, h = await Pt(
|
|
726
726
|
e,
|
|
727
727
|
{
|
|
728
728
|
artboard: {
|
|
729
|
-
width:
|
|
730
|
-
height:
|
|
731
|
-
x:
|
|
732
|
-
y:
|
|
729
|
+
width: m.width,
|
|
730
|
+
height: m.height,
|
|
731
|
+
x: m.x,
|
|
732
|
+
y: m.y
|
|
733
733
|
},
|
|
734
734
|
alignment: (x == null ? void 0 : x.fitAlign) || t,
|
|
735
735
|
scale: a,
|
|
@@ -740,16 +740,16 @@ function Bt(n) {
|
|
|
740
740
|
marginLeft: x == null ? void 0 : x.fitMarginLeft
|
|
741
741
|
}
|
|
742
742
|
);
|
|
743
|
-
h.success && h.element ? (p.addElementToArtboard(h.element.id,
|
|
743
|
+
h.success && h.element ? (p.addElementToArtboard(h.element.id, m.id), c.push(h.element)) : _.error("Failed to load image for artboard:", m.name, h.error);
|
|
744
744
|
}
|
|
745
745
|
if (c.length > 0)
|
|
746
|
-
|
|
746
|
+
g((m) => [...m, ...c]), b("success"), l == null || l(e);
|
|
747
747
|
else {
|
|
748
|
-
const
|
|
749
|
-
b("error"), w(
|
|
748
|
+
const m = new Error("Failed to load image into any artboard");
|
|
749
|
+
b("error"), w(m), d == null || d(e, m), i({
|
|
750
750
|
category: "image",
|
|
751
|
-
message:
|
|
752
|
-
originalError:
|
|
751
|
+
message: m.message,
|
|
752
|
+
originalError: m,
|
|
753
753
|
recoverable: !0
|
|
754
754
|
});
|
|
755
755
|
}
|
|
@@ -765,17 +765,17 @@ function Bt(n) {
|
|
|
765
765
|
})();
|
|
766
766
|
}, [e, t, a, r]), { imageLoadingState: u, imageError: E };
|
|
767
767
|
}
|
|
768
|
-
function
|
|
768
|
+
function Ht(n) {
|
|
769
769
|
const { onChange: e, onSelectionChange: t } = n, { elements: a, selectedId: r, artboardManager: s } = ee(), { artboards: l } = fe(), d = F(t);
|
|
770
|
-
d.current = t,
|
|
770
|
+
d.current = t, k(() => {
|
|
771
771
|
var f;
|
|
772
772
|
(f = d.current) == null || f.call(d, r);
|
|
773
773
|
}, [r]);
|
|
774
774
|
const i = F(e);
|
|
775
|
-
i.current = e,
|
|
775
|
+
i.current = e, k(() => {
|
|
776
776
|
const f = i.current;
|
|
777
777
|
if (!f) return;
|
|
778
|
-
const
|
|
778
|
+
const g = s.getActiveArtboard(), p = {
|
|
779
779
|
// Stamp each element with the NAME of the artboard it lives on (the
|
|
780
780
|
// manager is the membership source of truth). Without this the public
|
|
781
781
|
// state is flat and a multi-placement design cannot round-trip: restore
|
|
@@ -799,12 +799,12 @@ function Wt(n) {
|
|
|
799
799
|
// set so non-template states stay byte-identical.
|
|
800
800
|
...u.role ? { role: u.role } : {}
|
|
801
801
|
})),
|
|
802
|
-
activeArtboard: (
|
|
802
|
+
activeArtboard: (g == null ? void 0 : g.name) || "Design"
|
|
803
803
|
};
|
|
804
804
|
f(p);
|
|
805
805
|
}, [a, l]);
|
|
806
806
|
}
|
|
807
|
-
function
|
|
807
|
+
function zt(n, e) {
|
|
808
808
|
const {
|
|
809
809
|
autoExportInterval: t,
|
|
810
810
|
autoExportConfig: a,
|
|
@@ -814,7 +814,7 @@ function $t(n, e) {
|
|
|
814
814
|
maxExportSize: d,
|
|
815
815
|
exportImageFormat: i,
|
|
816
816
|
exportImageQuality: f,
|
|
817
|
-
onExport:
|
|
817
|
+
onExport: g,
|
|
818
818
|
onExportScheduled: p,
|
|
819
819
|
onExportStatus: u,
|
|
820
820
|
onExportReady: b,
|
|
@@ -825,67 +825,67 @@ function $t(n, e) {
|
|
|
825
825
|
} = n, {
|
|
826
826
|
elements: o,
|
|
827
827
|
artboardManager: c,
|
|
828
|
-
historyManager:
|
|
828
|
+
historyManager: m,
|
|
829
829
|
isCanvasReady: x,
|
|
830
830
|
setCanvasReady: S
|
|
831
|
-
} = ee(), { artboards: h } = fe(), { exportArtboard:
|
|
832
|
-
|
|
833
|
-
exportArtboards: async (
|
|
834
|
-
const
|
|
831
|
+
} = ee(), { artboards: h } = fe(), { exportArtboard: I, exportAllArtboards: X, exportArtboardAsBlob: z, exportAllArtboardsAsBlobs: j } = ct(), ae = F(0), oe = F(0);
|
|
832
|
+
ze(e, () => ({
|
|
833
|
+
exportArtboards: async (L = {}) => {
|
|
834
|
+
const P = L.format || r, T = L.scale || l, $ = L.all ?? !1;
|
|
835
835
|
let D = T;
|
|
836
836
|
if (d > 0 && isFinite(d))
|
|
837
837
|
for (const M of h) {
|
|
838
|
-
const
|
|
839
|
-
D = Math.min(D,
|
|
838
|
+
const C = ue(M.width, M.height, T, d);
|
|
839
|
+
D = Math.min(D, C);
|
|
840
840
|
}
|
|
841
|
-
const
|
|
841
|
+
const R = { scale: D, format: i, quality: f };
|
|
842
842
|
if ($) {
|
|
843
|
-
const M =
|
|
843
|
+
const M = P === "blob" ? await j(R) : await X(R), C = {};
|
|
844
844
|
for (const [N, K] of Object.entries(M)) {
|
|
845
845
|
const B = h.find((U) => U.id === N);
|
|
846
|
-
B && (
|
|
846
|
+
B && (C[B.name] = K);
|
|
847
847
|
}
|
|
848
|
-
return
|
|
848
|
+
return C;
|
|
849
849
|
} else {
|
|
850
850
|
const M = c.getActiveArtboard();
|
|
851
851
|
if (!M)
|
|
852
852
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
853
|
-
if (
|
|
854
|
-
const
|
|
855
|
-
return { [M.name]:
|
|
853
|
+
if (P === "blob") {
|
|
854
|
+
const C = await z(M.id, R);
|
|
855
|
+
return { [M.name]: C };
|
|
856
856
|
} else {
|
|
857
|
-
const
|
|
858
|
-
return { [M.name]:
|
|
857
|
+
const C = await I(M.id, R);
|
|
858
|
+
return { [M.name]: C };
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
}), [
|
|
862
|
+
}), [I, X, z, j, r, l, d, i, f, c, h]), k(() => {
|
|
863
863
|
b && b(async () => {
|
|
864
|
-
const
|
|
865
|
-
if (!
|
|
864
|
+
const P = c.getActiveArtboard();
|
|
865
|
+
if (!P)
|
|
866
866
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
867
867
|
const T = ue(
|
|
868
|
-
|
|
869
|
-
|
|
868
|
+
P.width,
|
|
869
|
+
P.height,
|
|
870
870
|
l,
|
|
871
871
|
d
|
|
872
|
-
), $ = r === "blob" ? await z(
|
|
873
|
-
return { [
|
|
872
|
+
), $ = r === "blob" ? await z(P.id, { scale: T }) : await I(P.id, { scale: T });
|
|
873
|
+
return { [P.name]: $ };
|
|
874
874
|
});
|
|
875
|
-
}, [b,
|
|
875
|
+
}, [b, I, z, c, r, l, d]);
|
|
876
876
|
const se = O(async () => {
|
|
877
|
-
if (!
|
|
878
|
-
const
|
|
877
|
+
if (!g && !u) return;
|
|
878
|
+
const L = ++oe.current, P = Date.now();
|
|
879
879
|
let T = l;
|
|
880
880
|
if (d > 0 && isFinite(d))
|
|
881
|
-
for (const
|
|
882
|
-
const M = ue(
|
|
881
|
+
for (const R of h) {
|
|
882
|
+
const M = ue(R.width, R.height, l, d);
|
|
883
883
|
T = Math.min(T, M);
|
|
884
884
|
}
|
|
885
885
|
const $ = c.getActiveArtboard(), D = ($ == null ? void 0 : $.id) ?? "unknown";
|
|
886
|
-
u == null || u({ status: "rendering", artboardId: D }), ae.current =
|
|
886
|
+
u == null || u({ status: "rendering", artboardId: D }), ae.current = P;
|
|
887
887
|
try {
|
|
888
|
-
let
|
|
888
|
+
let R;
|
|
889
889
|
const M = {
|
|
890
890
|
format: i,
|
|
891
891
|
scale: T,
|
|
@@ -893,42 +893,42 @@ function $t(n, e) {
|
|
|
893
893
|
};
|
|
894
894
|
if (r === "blob")
|
|
895
895
|
if (s) {
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
for (const [N, K] of Object.entries(
|
|
896
|
+
const C = await j(M);
|
|
897
|
+
R = {};
|
|
898
|
+
for (const [N, K] of Object.entries(C)) {
|
|
899
899
|
const B = h.find((U) => U.id === N);
|
|
900
|
-
B && (
|
|
900
|
+
B && (R[B.name] = K);
|
|
901
901
|
}
|
|
902
902
|
} else {
|
|
903
|
-
const
|
|
904
|
-
if (!
|
|
905
|
-
const N = await z(
|
|
906
|
-
|
|
903
|
+
const C = c.getActiveArtboard();
|
|
904
|
+
if (!C) return;
|
|
905
|
+
const N = await z(C.id, M);
|
|
906
|
+
R = { [C.name]: N };
|
|
907
907
|
}
|
|
908
908
|
else if (s) {
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
for (const [N, K] of Object.entries(
|
|
909
|
+
const C = await X(M);
|
|
910
|
+
R = {};
|
|
911
|
+
for (const [N, K] of Object.entries(C)) {
|
|
912
912
|
const B = h.find((U) => U.id === N);
|
|
913
|
-
B && (
|
|
913
|
+
B && (R[B.name] = K);
|
|
914
914
|
}
|
|
915
915
|
} else {
|
|
916
|
-
const
|
|
917
|
-
if (!
|
|
918
|
-
const N = await C
|
|
919
|
-
|
|
916
|
+
const C = c.getActiveArtboard();
|
|
917
|
+
if (!C) return;
|
|
918
|
+
const N = await I(C.id, M);
|
|
919
|
+
R = { [C.name]: N };
|
|
920
920
|
}
|
|
921
|
-
|
|
922
|
-
} catch (
|
|
923
|
-
const M =
|
|
921
|
+
g == null || g(R), u == null || u({ status: "complete", artboardId: D, result: R });
|
|
922
|
+
} catch (R) {
|
|
923
|
+
const M = R instanceof Error ? R.message : String(R);
|
|
924
924
|
if (M.includes("Canvas ref not available"))
|
|
925
925
|
return;
|
|
926
|
-
const
|
|
927
|
-
_.error("Export failed (export #" +
|
|
928
|
-
duration: `${
|
|
926
|
+
const C = Date.now() - P;
|
|
927
|
+
_.error("Export failed (export #" + L + "):", {
|
|
928
|
+
duration: `${C}ms`,
|
|
929
929
|
error: M
|
|
930
930
|
});
|
|
931
|
-
const N =
|
|
931
|
+
const N = R instanceof Error ? R : new Error(M);
|
|
932
932
|
u == null || u({ status: "error", artboardId: D, error: N }), v({
|
|
933
933
|
category: "export",
|
|
934
934
|
message: N.message,
|
|
@@ -937,26 +937,26 @@ function $t(n, e) {
|
|
|
937
937
|
recoverable: !0
|
|
938
938
|
});
|
|
939
939
|
}
|
|
940
|
-
}, [
|
|
941
|
-
|
|
940
|
+
}, [g, u, s, r, l, d, i, f, I, X, z, j, h, c, o, a, v]);
|
|
941
|
+
k(() => {
|
|
942
942
|
t !== void 0 && t > 0 && _.warn(
|
|
943
943
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
944
944
|
);
|
|
945
945
|
}, []);
|
|
946
946
|
const ie = O(() => {
|
|
947
947
|
if (p == null || p(), u) {
|
|
948
|
-
const
|
|
949
|
-
u({ status: "scheduled", artboardId: (
|
|
948
|
+
const L = c.getActiveArtboard();
|
|
949
|
+
u({ status: "scheduled", artboardId: (L == null ? void 0 : L.id) ?? "unknown" });
|
|
950
950
|
}
|
|
951
|
-
}, [p, u, c]), q =
|
|
951
|
+
}, [p, u, c]), q = It({
|
|
952
952
|
isCanvasReady: x,
|
|
953
953
|
elements: o,
|
|
954
954
|
hasInitialElements: w,
|
|
955
955
|
initialElementsLoaded: A
|
|
956
956
|
}), te = F(!1);
|
|
957
|
-
|
|
957
|
+
k(() => {
|
|
958
958
|
q && !te.current && (te.current = !0, E == null || E());
|
|
959
|
-
}, [q, E]),
|
|
959
|
+
}, [q, E]), yt({
|
|
960
960
|
config: a ? {
|
|
961
961
|
enabled: a.enabled ?? !0,
|
|
962
962
|
debounceMs: a.debounceMs ?? 100,
|
|
@@ -965,25 +965,25 @@ function $t(n, e) {
|
|
|
965
965
|
enabled: !1
|
|
966
966
|
// Only use smart export if autoExportConfig is provided
|
|
967
967
|
},
|
|
968
|
-
historyManager:
|
|
968
|
+
historyManager: m,
|
|
969
969
|
artboards: h,
|
|
970
970
|
elements: o,
|
|
971
971
|
onExport: se,
|
|
972
972
|
onExportScheduled: ie,
|
|
973
973
|
isCanvasReady: q
|
|
974
974
|
// Gate exports until content is fully ready (fonts loaded, elements deserialized)
|
|
975
|
-
}),
|
|
975
|
+
}), k(() => {
|
|
976
976
|
if (h.length > 0 && !x) {
|
|
977
|
-
const
|
|
977
|
+
const L = requestAnimationFrame(() => {
|
|
978
978
|
S(!0);
|
|
979
979
|
});
|
|
980
|
-
return () => cancelAnimationFrame(
|
|
980
|
+
return () => cancelAnimationFrame(L);
|
|
981
981
|
}
|
|
982
|
-
}, [h.length, x, S]),
|
|
982
|
+
}, [h.length, x, S]), k(() => () => {
|
|
983
983
|
S(!1);
|
|
984
984
|
}, [S]);
|
|
985
985
|
}
|
|
986
|
-
const we = Q("SnowconeCanvas"),
|
|
986
|
+
const we = Q("SnowconeCanvas"), ke = Ae((n, e) => {
|
|
987
987
|
var Ee;
|
|
988
988
|
const {
|
|
989
989
|
exportConfig: t,
|
|
@@ -994,7 +994,7 @@ const we = Q("SnowconeCanvas"), Ie = Ae((n, e) => {
|
|
|
994
994
|
activeArtboard: d,
|
|
995
995
|
onArtboardChange: i,
|
|
996
996
|
initialElements: f,
|
|
997
|
-
customFonts:
|
|
997
|
+
customFonts: g,
|
|
998
998
|
onChange: p,
|
|
999
999
|
onSelectionChange: u,
|
|
1000
1000
|
autoExportInterval: b,
|
|
@@ -1004,60 +1004,64 @@ const we = Q("SnowconeCanvas"), Ie = Ae((n, e) => {
|
|
|
1004
1004
|
onExportReady: v,
|
|
1005
1005
|
onImageLoad: o,
|
|
1006
1006
|
onImageError: c,
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
R(() =>
|
|
1007
|
+
onImageLoadError: m,
|
|
1008
|
+
onError: x,
|
|
1009
|
+
onReady: S,
|
|
1010
|
+
className: h,
|
|
1011
|
+
style: I,
|
|
1012
|
+
enableShortcuts: X,
|
|
1013
|
+
overlay: z,
|
|
1014
|
+
resetDocumentOnMount: j
|
|
1015
|
+
} = n, ae = b, oe = n.autoExportConfig ?? (t == null ? void 0 : t.autoExportConfig), se = n.autoExportFormat ?? (t == null ? void 0 : t.format) ?? "dataUrl", ie = n.autoExportAll ?? (t == null ? void 0 : t.exportAll) ?? !1, q = n.exportScale ?? (t == null ? void 0 : t.scale) ?? 2, te = n.maxExportSize ?? (t == null ? void 0 : t.maxSize) ?? 4e3, L = n.exportImageFormat ?? (t == null ? void 0 : t.imageFormat) ?? "png", P = n.exportImageQuality ?? (t == null ? void 0 : t.imageQuality) ?? 0.92, T = n.initialImage ?? (a == null ? void 0 : a.src), $ = n.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", D = n.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, R = n.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", M = n.width ?? (r == null ? void 0 : r.width) ?? 1200, C = n.height ?? (r == null ? void 0 : r.height) ?? 1200, N = n.viewPadding ?? (r == null ? void 0 : r.viewPadding) ?? 0.9, K = n.artboardBorderRadius ?? (r == null ? void 0 : r.artboardBorderRadius) ?? 0, B = n.fixedMargin ?? (r == null ? void 0 : r.fixedMargin), U = n.maxHeight ?? (r == null ? void 0 : r.maxHeight), Re = n.showRotationHandle ?? (r == null ? void 0 : r.showRotationHandle) ?? !0, Ce = n.hideCanvas ?? (r == null ? void 0 : r.hideCanvas) ?? !1, ge = n.canvasWrapperClassName ?? (r == null ? void 0 : r.canvasWrapperClassName), he = n.canvasWrapperStyle ?? (r == null ? void 0 : r.canvasWrapperStyle), Me = n.canvasCutouts ?? (r == null ? void 0 : r.canvasCutouts), pe = n.pieceGuides, Fe = n.pieceFocus, Ne = X ?? !0, Y = Se(() => qe(s ?? "pro-studio"), [s]);
|
|
1016
|
+
k(() => {
|
|
1016
1017
|
var H;
|
|
1017
1018
|
if (typeof G < "u" && ((H = G.env) == null ? void 0 : H.NODE_ENV) === "development" && Y) {
|
|
1018
|
-
const W =
|
|
1019
|
+
const W = Je(Y);
|
|
1019
1020
|
W.valid || we.warn("Kit validation warnings:", W.errors), W.warnings.length > 0 && we.warn("Kit validation warnings:", W.warnings);
|
|
1020
1021
|
}
|
|
1021
|
-
}, [Y])
|
|
1022
|
-
|
|
1023
|
-
|
|
1022
|
+
}, [Y]), k(() => {
|
|
1023
|
+
if (m)
|
|
1024
|
+
return We(m);
|
|
1025
|
+
}, [m]);
|
|
1026
|
+
const { emitError: ce, handleBoundaryError: Le } = Dt(x);
|
|
1027
|
+
Bt({
|
|
1024
1028
|
artboardConfigs: l,
|
|
1025
|
-
width:
|
|
1026
|
-
height:
|
|
1029
|
+
width: M,
|
|
1030
|
+
height: C,
|
|
1027
1031
|
pieceGuides: pe,
|
|
1028
1032
|
controlledActiveArtboard: d,
|
|
1029
1033
|
onArtboardChange: i,
|
|
1030
|
-
resetDocumentOnMount:
|
|
1034
|
+
resetDocumentOnMount: j
|
|
1031
1035
|
});
|
|
1032
|
-
const { initialElementsLoadedState: Pe } =
|
|
1036
|
+
const { initialElementsLoadedState: Pe } = Wt({
|
|
1033
1037
|
initialElements: f,
|
|
1034
|
-
customFonts:
|
|
1038
|
+
customFonts: g,
|
|
1035
1039
|
emitError: ce
|
|
1036
|
-
}), { imageLoadingState: be, imageError: ve } =
|
|
1037
|
-
initialImage:
|
|
1038
|
-
initialImageAlignment:
|
|
1039
|
-
initialImageScale:
|
|
1040
|
-
initialImageScaleMode:
|
|
1040
|
+
}), { imageLoadingState: be, imageError: ve } = $t({
|
|
1041
|
+
initialImage: T,
|
|
1042
|
+
initialImageAlignment: $,
|
|
1043
|
+
initialImageScale: D,
|
|
1044
|
+
initialImageScaleMode: R,
|
|
1041
1045
|
artboardConfigs: l,
|
|
1042
1046
|
onImageLoad: o,
|
|
1043
1047
|
onImageError: c,
|
|
1044
1048
|
emitError: ce
|
|
1045
1049
|
});
|
|
1046
|
-
if (
|
|
1050
|
+
if (Ht({ onChange: p, onSelectionChange: u }), zt(
|
|
1047
1051
|
{
|
|
1048
|
-
autoExportInterval:
|
|
1049
|
-
autoExportConfig:
|
|
1050
|
-
autoExportFormat:
|
|
1051
|
-
autoExportAll:
|
|
1052
|
-
exportScale:
|
|
1053
|
-
maxExportSize:
|
|
1054
|
-
exportImageFormat:
|
|
1052
|
+
autoExportInterval: ae,
|
|
1053
|
+
autoExportConfig: oe,
|
|
1054
|
+
autoExportFormat: se,
|
|
1055
|
+
autoExportAll: ie,
|
|
1056
|
+
exportScale: q,
|
|
1057
|
+
maxExportSize: te,
|
|
1058
|
+
exportImageFormat: L,
|
|
1055
1059
|
exportImageQuality: P,
|
|
1056
1060
|
onExport: E,
|
|
1057
1061
|
onExportScheduled: w,
|
|
1058
1062
|
onExportStatus: A,
|
|
1059
1063
|
onExportReady: v,
|
|
1060
|
-
onReady:
|
|
1064
|
+
onReady: S,
|
|
1061
1065
|
hasInitialElements: !!f && f.length > 0,
|
|
1062
1066
|
initialElementsLoaded: Pe,
|
|
1063
1067
|
emitError: ce
|
|
@@ -1067,24 +1071,24 @@ const we = Q("SnowconeCanvas"), Ie = Ae((n, e) => {
|
|
|
1067
1071
|
return /* @__PURE__ */ y(
|
|
1068
1072
|
"div",
|
|
1069
1073
|
{
|
|
1070
|
-
className:
|
|
1074
|
+
className: h,
|
|
1071
1075
|
style: {
|
|
1072
|
-
...
|
|
1076
|
+
...I,
|
|
1073
1077
|
display: "flex",
|
|
1074
1078
|
alignItems: "center",
|
|
1075
1079
|
justifyContent: "center",
|
|
1076
1080
|
backgroundColor: "var(--surface, #f5f5f5)"
|
|
1077
1081
|
},
|
|
1078
|
-
children: /* @__PURE__ */ y(
|
|
1082
|
+
children: /* @__PURE__ */ y(Ze, { size: 48 })
|
|
1079
1083
|
}
|
|
1080
1084
|
);
|
|
1081
1085
|
if (be === "error" && ve)
|
|
1082
1086
|
return /* @__PURE__ */ y(
|
|
1083
1087
|
"div",
|
|
1084
1088
|
{
|
|
1085
|
-
className:
|
|
1089
|
+
className: h,
|
|
1086
1090
|
style: {
|
|
1087
|
-
...
|
|
1091
|
+
...I,
|
|
1088
1092
|
display: "flex",
|
|
1089
1093
|
alignItems: "center",
|
|
1090
1094
|
justifyContent: "center",
|
|
@@ -1098,13 +1102,13 @@ const we = Q("SnowconeCanvas"), Ie = Ae((n, e) => {
|
|
|
1098
1102
|
] })
|
|
1099
1103
|
}
|
|
1100
1104
|
);
|
|
1101
|
-
const
|
|
1105
|
+
const Te = Object.entries(((Ee = Y.layout) == null ? void 0 : Ee.slots) ?? {}).every(
|
|
1102
1106
|
([H, W]) => H === "canvas" || !W || W.length === 0
|
|
1103
1107
|
) ? { "--color-canvas-bg": "transparent" } : void 0;
|
|
1104
|
-
return /* @__PURE__ */ y(
|
|
1105
|
-
|
|
1108
|
+
return /* @__PURE__ */ y(_e, { kit: Y, children: /* @__PURE__ */ y("div", { className: `sc-root ${h || ""}`, style: { ...Te, ...I, position: "relative" }, children: /* @__PURE__ */ V(
|
|
1109
|
+
vt,
|
|
1106
1110
|
{
|
|
1107
|
-
onError:
|
|
1111
|
+
onError: Le,
|
|
1108
1112
|
fallback: (H, W) => /* @__PURE__ */ V(
|
|
1109
1113
|
"div",
|
|
1110
1114
|
{
|
|
@@ -1144,49 +1148,49 @@ const we = Q("SnowconeCanvas"), Ie = Ae((n, e) => {
|
|
|
1144
1148
|
}
|
|
1145
1149
|
),
|
|
1146
1150
|
children: [
|
|
1147
|
-
!
|
|
1151
|
+
!Ce && /* @__PURE__ */ (() => {
|
|
1148
1152
|
const H = /* @__PURE__ */ y(
|
|
1149
|
-
|
|
1153
|
+
et,
|
|
1150
1154
|
{
|
|
1151
1155
|
style: { width: "100%" },
|
|
1152
|
-
fitPadding:
|
|
1153
|
-
artboardBorderRadius:
|
|
1154
|
-
fixedMargin:
|
|
1155
|
-
maxHeight:
|
|
1156
|
-
showRotationHandle:
|
|
1157
|
-
enableShortcuts:
|
|
1158
|
-
canvasCutouts:
|
|
1156
|
+
fitPadding: N,
|
|
1157
|
+
artboardBorderRadius: K,
|
|
1158
|
+
fixedMargin: B,
|
|
1159
|
+
maxHeight: U,
|
|
1160
|
+
showRotationHandle: Re,
|
|
1161
|
+
enableShortcuts: Ne,
|
|
1162
|
+
canvasCutouts: Me,
|
|
1159
1163
|
pieceGuides: pe,
|
|
1160
|
-
pieceFocus:
|
|
1164
|
+
pieceFocus: Fe
|
|
1161
1165
|
}
|
|
1162
1166
|
);
|
|
1163
|
-
return /* @__PURE__ */ y(
|
|
1167
|
+
return /* @__PURE__ */ y(pt, { kit: Y, canvas: ge || he ? /* @__PURE__ */ y("div", { className: ge, style: he, children: H }) : H });
|
|
1164
1168
|
})(),
|
|
1165
|
-
|
|
1169
|
+
z
|
|
1166
1170
|
]
|
|
1167
1171
|
}
|
|
1168
1172
|
) }) });
|
|
1169
1173
|
});
|
|
1170
|
-
|
|
1171
|
-
const
|
|
1174
|
+
ke.displayName = "SnowconeCanvasInner";
|
|
1175
|
+
const Ot = Ae((n, e) => {
|
|
1172
1176
|
var l;
|
|
1173
1177
|
const { inheritTheme: t, externalProvider: a, services: r } = n, s = n.viewPadding ?? ((l = n.layoutConfig) == null ? void 0 : l.viewPadding);
|
|
1174
1178
|
return /* @__PURE__ */ y(
|
|
1175
|
-
|
|
1179
|
+
Et,
|
|
1176
1180
|
{
|
|
1177
1181
|
inheritTheme: t,
|
|
1178
1182
|
externalProvider: a,
|
|
1179
1183
|
services: r,
|
|
1180
1184
|
viewPadding: s,
|
|
1181
|
-
children: /* @__PURE__ */ y(
|
|
1185
|
+
children: /* @__PURE__ */ y(ke, { ref: e, ...n })
|
|
1182
1186
|
}
|
|
1183
1187
|
);
|
|
1184
1188
|
});
|
|
1185
|
-
|
|
1189
|
+
Ot.displayName = "SnowconeCanvas";
|
|
1186
1190
|
export {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
+
vt as E,
|
|
1192
|
+
Ot as S,
|
|
1193
|
+
It as a,
|
|
1194
|
+
yt as u
|
|
1191
1195
|
};
|
|
1192
|
-
//# sourceMappingURL=SnowconeCanvas-
|
|
1196
|
+
//# sourceMappingURL=SnowconeCanvas-h8cfofsO.js.map
|