@snowcone-app/canvas 0.1.10 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CanvasStateV1-BmE5V6me.cjs → CanvasStateV1-C4hC1MCe.cjs} +5 -5
- package/dist/{CanvasStateV1-BmE5V6me.cjs.map → CanvasStateV1-C4hC1MCe.cjs.map} +1 -1
- package/dist/{CanvasStateV1-CD3Q94F4.js → CanvasStateV1-CJU_xYW5.js} +3 -3
- package/dist/{CanvasStateV1-CD3Q94F4.js.map → CanvasStateV1-CJU_xYW5.js.map} +1 -1
- package/dist/{HybridHistoryManager-BV6XV0nD.js → HybridHistoryManager-jBBnVim8.js} +54 -54
- package/dist/{HybridHistoryManager-BV6XV0nD.js.map → HybridHistoryManager-jBBnVim8.js.map} +1 -1
- package/dist/{ElementFactory-Ckv6sSev.js → ImportManager-Oqu2yB54.js} +595 -378
- package/dist/ImportManager-Oqu2yB54.js.map +1 -0
- package/dist/{ElementFactory-DEjwp-Wg.cjs → ImportManager-W1eWhfyM.cjs} +5 -5
- package/dist/ImportManager-W1eWhfyM.cjs.map +1 -0
- package/dist/ThemeContext-BMNQKl1c.cjs +2 -0
- package/dist/{ThemeContext-4mJ_y0Me.cjs.map → ThemeContext-BMNQKl1c.cjs.map} +1 -1
- package/dist/ThemeContext-wj-wSO7J.js +1158 -0
- package/dist/{ThemeContext-H0Z-MqqR.js.map → ThemeContext-wj-wSO7J.js.map} +1 -1
- package/dist/advanced.js +5 -32
- package/dist/advanced.js.map +1 -1
- package/dist/advanced.mjs +588 -15069
- package/dist/advanced.mjs.map +1 -1
- package/dist/components/embed/KitLayout.d.ts +22 -0
- package/dist/components/embed/UndoRedoControls.d.ts +3 -0
- package/dist/compose-Dqh2f8tS.js +22222 -0
- package/dist/compose-Dqh2f8tS.js.map +1 -0
- package/dist/compose-HDJp4Z_d.cjs +60 -0
- package/dist/compose-HDJp4Z_d.cjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +600 -516
- package/dist/index.mjs.map +1 -1
- package/dist/internals.js +1 -1
- package/dist/internals.js.map +1 -1
- package/dist/internals.mjs +101 -102
- package/dist/internals.mjs.map +1 -1
- package/dist/style.css.d.ts +4 -0
- package/dist/testing.js +1 -1
- package/dist/testing.mjs +11 -11
- package/package.json +8 -4
- package/dist/ElementFactory-Ckv6sSev.js.map +0 -1
- package/dist/ElementFactory-DEjwp-Wg.cjs.map +0 -1
- package/dist/ImportManager-64OYjELO.js +0 -222
- package/dist/ImportManager-64OYjELO.js.map +0 -1
- package/dist/ImportManager-wSzrR-5a.cjs +0 -2
- package/dist/ImportManager-wSzrR-5a.cjs.map +0 -1
- package/dist/ThemeContext-4mJ_y0Me.cjs +0 -2
- package/dist/ThemeContext-H0Z-MqqR.js +0 -1077
- package/dist/compose-DHBRwi_A.cjs +0 -33
- package/dist/compose-DHBRwi_A.cjs.map +0 -1
- package/dist/compose-DIPiisIw.js +0 -7690
- package/dist/compose-DIPiisIw.js.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,148 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import {
|
|
6
|
-
import { u as
|
|
7
|
-
import { C as
|
|
8
|
-
import { d as
|
|
9
|
-
const
|
|
10
|
-
|
|
1
|
+
import { T as Be, i as Ue, r as yt, a as ze, g as wt, L as Et, E as At, b as St, I as kt, G as Rt, A as It, C as Ct, Z as Mt, M as $e, c as Tt, d as Dt, D as Ft, e as Pt, v as Nt, u as Ht, f as Lt, S as Wt, K as Bt, h as Ut, j as zt } from "./compose-Dqh2f8tS.js";
|
|
2
|
+
import { k as zr, l as $r, m as Or, n as Yr, P as Xr, o as Vr, p as Kr, q as jr } from "./compose-Dqh2f8tS.js";
|
|
3
|
+
import { c as q, p as me, s as $t, I as Ve, T as Ot } from "./HybridHistoryManager-jBBnVim8.js";
|
|
4
|
+
import { jsxs as j, jsx as v, Fragment as Ke } from "react/jsx-runtime";
|
|
5
|
+
import { useCallback as W, useMemo as he, Component as Yt, useRef as D, useState as re, useEffect as I, forwardRef as je, useImperativeHandle as Xt } from "react";
|
|
6
|
+
import { u as ge, T as Oe, E as Vt, a as ke, b as Ge, c as Kt } from "./ThemeContext-wj-wSO7J.js";
|
|
7
|
+
import { C as Ae, E as jt } from "./ImportManager-Oqu2yB54.js";
|
|
8
|
+
import { d as Zr, m as Qr, s as qr, v as Jr } from "./CanvasStateV1-CJU_xYW5.js";
|
|
9
|
+
const Ye = q("useCommands");
|
|
10
|
+
function Gt() {
|
|
11
|
+
const t = ge(), {
|
|
12
|
+
undo: e,
|
|
13
|
+
redo: r,
|
|
14
|
+
canUndo: a,
|
|
15
|
+
canRedo: n,
|
|
16
|
+
executeElementUpdate: c,
|
|
17
|
+
executeAddElement: o,
|
|
18
|
+
executeRemoveElement: i,
|
|
19
|
+
executeReorderElement: l,
|
|
20
|
+
executeCommandBatch: m,
|
|
21
|
+
executeCreateArtboard: A,
|
|
22
|
+
executeDeleteArtboard: M,
|
|
23
|
+
executeUpdateArtboard: w
|
|
24
|
+
} = t, S = W(() => {
|
|
25
|
+
Ye.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
|
|
26
|
+
}, []), T = W((E) => {
|
|
27
|
+
Ye.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
|
|
28
|
+
}, []);
|
|
29
|
+
return {
|
|
30
|
+
// Undo/Redo
|
|
31
|
+
undo: e,
|
|
32
|
+
redo: r,
|
|
33
|
+
canUndo: a,
|
|
34
|
+
canRedo: n,
|
|
35
|
+
// History management
|
|
36
|
+
clearHistory: S,
|
|
37
|
+
clearArtboardHistory: T,
|
|
38
|
+
// Command execution
|
|
39
|
+
executeElementUpdate: c,
|
|
40
|
+
executeAddElement: o,
|
|
41
|
+
executeRemoveElement: i,
|
|
42
|
+
executeReorderElement: l,
|
|
43
|
+
executeCreateArtboard: A,
|
|
44
|
+
executeDeleteArtboard: M,
|
|
45
|
+
executeUpdateArtboard: w,
|
|
46
|
+
// Batch execution
|
|
47
|
+
executeCommandBatch: m
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const Zt = () => {
|
|
51
|
+
const { undo: t, redo: e, canUndo: r, canRedo: a } = Gt();
|
|
52
|
+
return /* @__PURE__ */ j("div", { className: "sc-undo-redo", style: { display: "inline-flex", gap: 4 }, children: [
|
|
53
|
+
/* @__PURE__ */ v(
|
|
54
|
+
Be,
|
|
55
|
+
{
|
|
56
|
+
icon: Ue.undo,
|
|
57
|
+
onClick: t,
|
|
58
|
+
disabled: !r,
|
|
59
|
+
tooltip: "Undo",
|
|
60
|
+
"aria-label": "Undo"
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ v(
|
|
64
|
+
Be,
|
|
65
|
+
{
|
|
66
|
+
icon: Ue.redo,
|
|
67
|
+
onClick: e,
|
|
68
|
+
disabled: !a,
|
|
69
|
+
tooltip: "Redo",
|
|
70
|
+
"aria-label": "Redo"
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] });
|
|
74
|
+
}, Qt = q("KitLayout"), te = "canvas";
|
|
75
|
+
let Xe = !1;
|
|
76
|
+
function qt() {
|
|
77
|
+
Xe || (Xe = !0, yt({
|
|
78
|
+
LayersPanel: Et,
|
|
79
|
+
EffectsPanel: At,
|
|
80
|
+
ExportPanel: St,
|
|
81
|
+
ImagePanel: kt,
|
|
82
|
+
GlyphPanel: Rt,
|
|
83
|
+
ArtboardTabs: It,
|
|
84
|
+
ContextualToolbars: Ct,
|
|
85
|
+
ZoomControls: Mt,
|
|
86
|
+
MenuButton: $e,
|
|
87
|
+
CropPanel: Tt
|
|
88
|
+
}), ze("add-element-menu", {
|
|
89
|
+
component: $e,
|
|
90
|
+
label: "Add Element",
|
|
91
|
+
icon: "gravity-ui:plus",
|
|
92
|
+
position: "topbar"
|
|
93
|
+
}), ze("undo-redo-controls", {
|
|
94
|
+
component: Zt,
|
|
95
|
+
label: "Undo / Redo",
|
|
96
|
+
icon: "lucide:undo-2",
|
|
97
|
+
position: "topbar"
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
function fe({ ids: t }) {
|
|
101
|
+
return !t || t.length === 0 ? null : /* @__PURE__ */ v(Ke, { children: t.map((e) => {
|
|
102
|
+
var n;
|
|
103
|
+
if (e === te) return null;
|
|
104
|
+
const r = wt(e);
|
|
105
|
+
if (!r)
|
|
106
|
+
return typeof me < "u" && ((n = me.env) == null ? void 0 : n.NODE_ENV) === "development" && Qt.warn(
|
|
107
|
+
`Kit layout references unknown section "${e}" — skipping. Register it with registerSection("${e}", { ... }).`
|
|
108
|
+
), null;
|
|
109
|
+
const a = r.component;
|
|
110
|
+
return /* @__PURE__ */ v(a, {}, e);
|
|
111
|
+
}) });
|
|
112
|
+
}
|
|
113
|
+
function Jt({ kit: t, canvas: e }) {
|
|
114
|
+
var l, m, A, M;
|
|
115
|
+
qt();
|
|
116
|
+
const r = t.layout.slots, a = !!((l = r.topbar) != null && l.some((w) => w !== te)), n = !!((m = r.left) != null && m.some((w) => w !== te)), c = !!((A = r.right) != null && A.some((w) => w !== te)), o = !!((M = r.bottombar) != null && M.some((w) => w !== te));
|
|
117
|
+
return he(
|
|
118
|
+
() => !a && !n && !c && !o,
|
|
119
|
+
[a, n, c, o]
|
|
120
|
+
) ? /* @__PURE__ */ v(Ke, { children: e }) : /* @__PURE__ */ j("div", { className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
|
|
121
|
+
a && /* @__PURE__ */ v(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
className: "sc-kit-topbar toolbar",
|
|
125
|
+
style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", flexShrink: 0 },
|
|
126
|
+
children: /* @__PURE__ */ v(fe, { ids: r.topbar })
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ j("div", { className: "sc-kit-body", style: { display: "flex", flex: 1, minHeight: 0 }, children: [
|
|
130
|
+
n && /* @__PURE__ */ v("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(fe, { ids: r.left }) }),
|
|
131
|
+
/* @__PURE__ */ v("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: e }),
|
|
132
|
+
c && /* @__PURE__ */ v("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(fe, { ids: r.right }) })
|
|
133
|
+
] }),
|
|
134
|
+
o && /* @__PURE__ */ v(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: "sc-kit-bottombar toolbar",
|
|
138
|
+
style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 },
|
|
139
|
+
children: /* @__PURE__ */ v(fe, { ids: r.bottombar })
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
const _t = q("ErrorBoundary");
|
|
145
|
+
class er extends Yt {
|
|
11
146
|
constructor(e) {
|
|
12
147
|
super(e), this.resetError = () => {
|
|
13
148
|
this.setState({
|
|
@@ -26,7 +161,7 @@ class Tt extends St {
|
|
|
26
161
|
};
|
|
27
162
|
}
|
|
28
163
|
componentDidCatch(e, r) {
|
|
29
|
-
if (
|
|
164
|
+
if (_t.error("Caught error:", e, r), this.props.onError && this.props.onError(e, r), this.props.onCanvasError) {
|
|
30
165
|
const a = {
|
|
31
166
|
category: "unknown",
|
|
32
167
|
message: e.message,
|
|
@@ -37,7 +172,7 @@ class Tt extends St {
|
|
|
37
172
|
}
|
|
38
173
|
}
|
|
39
174
|
render() {
|
|
40
|
-
return this.state.hasError && this.state.error ? this.props.renderError ? this.props.renderError(this.state.error, this.resetError) : this.props.fallback ? typeof this.props.fallback == "function" ? this.props.fallback(this.state.error, this.resetError) : this.props.fallback : /* @__PURE__ */
|
|
175
|
+
return this.state.hasError && this.state.error ? this.props.renderError ? this.props.renderError(this.state.error, this.resetError) : this.props.fallback ? typeof this.props.fallback == "function" ? this.props.fallback(this.state.error, this.resetError) : this.props.fallback : /* @__PURE__ */ j(
|
|
41
176
|
"div",
|
|
42
177
|
{
|
|
43
178
|
style: {
|
|
@@ -49,8 +184,8 @@ class Tt extends St {
|
|
|
49
184
|
fontFamily: "system-ui, sans-serif"
|
|
50
185
|
},
|
|
51
186
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ v("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
|
|
188
|
+
/* @__PURE__ */ v(
|
|
54
189
|
"pre",
|
|
55
190
|
{
|
|
56
191
|
style: {
|
|
@@ -65,7 +200,7 @@ class Tt extends St {
|
|
|
65
200
|
children: this.state.error.message
|
|
66
201
|
}
|
|
67
202
|
),
|
|
68
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ v(
|
|
69
204
|
"button",
|
|
70
205
|
{
|
|
71
206
|
onClick: this.resetError,
|
|
@@ -87,80 +222,80 @@ class Tt extends St {
|
|
|
87
222
|
) : this.props.children;
|
|
88
223
|
}
|
|
89
224
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
92
|
-
const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l =
|
|
225
|
+
const tr = q("useAutoExport");
|
|
226
|
+
function rr(t) {
|
|
227
|
+
const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l = D(null), m = D(!1), A = D({
|
|
93
228
|
totalExports: 0,
|
|
94
229
|
skippedExports: 0,
|
|
95
230
|
lastExportTime: null,
|
|
96
231
|
avgExportInterval: 0
|
|
97
|
-
}), [
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
...
|
|
232
|
+
}), [M, w] = re(A.current), S = D(c);
|
|
233
|
+
S.current = c, I(() => {
|
|
234
|
+
const h = new Dt({
|
|
235
|
+
...Ft,
|
|
101
236
|
...e
|
|
102
237
|
});
|
|
103
|
-
return
|
|
238
|
+
return h.onExport(async () => {
|
|
104
239
|
try {
|
|
105
|
-
await
|
|
106
|
-
} catch (
|
|
107
|
-
|
|
240
|
+
await S.current(), A.current = h.getStats();
|
|
241
|
+
} catch (R) {
|
|
242
|
+
tr.error("[useAutoExport] Export failed:", R);
|
|
108
243
|
}
|
|
109
|
-
}), l.current =
|
|
110
|
-
|
|
244
|
+
}), l.current = h, () => {
|
|
245
|
+
h.destroy();
|
|
111
246
|
};
|
|
112
|
-
}, []),
|
|
113
|
-
i &&
|
|
114
|
-
}, [i]),
|
|
247
|
+
}, []), I(() => {
|
|
248
|
+
i && m.current && l.current && (m.current = !1, l.current.forceExport());
|
|
249
|
+
}, [i]), I(() => {
|
|
115
250
|
l.current && e && l.current.updateConfig(e);
|
|
116
|
-
}, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]),
|
|
251
|
+
}, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]), I(() => {
|
|
117
252
|
l.current && o && l.current.onExportScheduled(o);
|
|
118
|
-
}, [o]),
|
|
253
|
+
}, [o]), I(() => {
|
|
119
254
|
if (!r || !l.current)
|
|
120
255
|
return;
|
|
121
|
-
const
|
|
256
|
+
const h = r.onCommandExecuted(() => {
|
|
122
257
|
if (l.current) {
|
|
123
258
|
if (!i) {
|
|
124
|
-
|
|
259
|
+
m.current = !0;
|
|
125
260
|
return;
|
|
126
261
|
}
|
|
127
262
|
l.current.scheduleExport();
|
|
128
263
|
}
|
|
129
264
|
});
|
|
130
265
|
return () => {
|
|
131
|
-
|
|
266
|
+
h();
|
|
132
267
|
};
|
|
133
|
-
}, [r, i]),
|
|
268
|
+
}, [r, i]), I(() => {
|
|
134
269
|
if (l.current) {
|
|
135
270
|
if (!i) {
|
|
136
|
-
|
|
271
|
+
m.current = !0;
|
|
137
272
|
return;
|
|
138
273
|
}
|
|
139
274
|
l.current.scheduleExport();
|
|
140
275
|
}
|
|
141
|
-
}, [n, a, i]),
|
|
276
|
+
}, [n, a, i]), I(() => $t((R) => {
|
|
142
277
|
if (!l.current || !i) return;
|
|
143
|
-
n.some((
|
|
278
|
+
n.some((L) => L.id === R) && l.current.scheduleExport();
|
|
144
279
|
}), [n, i]);
|
|
145
|
-
const
|
|
146
|
-
l.current && l.current.updateConfig(
|
|
147
|
-
}, []),
|
|
148
|
-
l.current && (await l.current.forceExport(),
|
|
149
|
-
}, []),
|
|
150
|
-
l.current && (l.current.resetStats(),
|
|
151
|
-
}, []),
|
|
280
|
+
const T = W((h) => {
|
|
281
|
+
l.current && l.current.updateConfig(h);
|
|
282
|
+
}, []), E = W(async () => {
|
|
283
|
+
l.current && (await l.current.forceExport(), A.current = l.current.getStats(), w(A.current));
|
|
284
|
+
}, []), N = W(() => {
|
|
285
|
+
l.current && (l.current.resetStats(), A.current = l.current.getStats(), w(A.current));
|
|
286
|
+
}, []), k = W(() => {
|
|
152
287
|
l.current && l.current.resetChangeDetection();
|
|
153
288
|
}, []);
|
|
154
289
|
return {
|
|
155
|
-
stats:
|
|
156
|
-
updateConfig:
|
|
157
|
-
forceExport:
|
|
158
|
-
resetStats:
|
|
159
|
-
resetChangeDetection:
|
|
290
|
+
stats: M,
|
|
291
|
+
updateConfig: T,
|
|
292
|
+
forceExport: E,
|
|
293
|
+
resetStats: N,
|
|
294
|
+
resetChangeDetection: k
|
|
160
295
|
};
|
|
161
296
|
}
|
|
162
|
-
const
|
|
163
|
-
function
|
|
297
|
+
const Ze = q("useContentReady");
|
|
298
|
+
function nr(t) {
|
|
164
299
|
var r;
|
|
165
300
|
const e = /* @__PURE__ */ new Set();
|
|
166
301
|
for (const a of t)
|
|
@@ -174,7 +309,7 @@ function Pt(t) {
|
|
|
174
309
|
}
|
|
175
310
|
return Array.from(e);
|
|
176
311
|
}
|
|
177
|
-
async function
|
|
312
|
+
async function ar(t) {
|
|
178
313
|
if (t.length === 0 || typeof document > "u" || !document.fonts) return;
|
|
179
314
|
const e = [];
|
|
180
315
|
for (const r of t) {
|
|
@@ -184,24 +319,24 @@ async function Ht(t) {
|
|
|
184
319
|
await Promise.all(e), document.fonts.ready && await Promise.race([
|
|
185
320
|
document.fonts.ready,
|
|
186
321
|
new Promise((r) => setTimeout(r, 250))
|
|
187
|
-
]),
|
|
322
|
+
]), Ze.debug(`Awaited ${e.length} font(s)`);
|
|
188
323
|
}
|
|
189
|
-
function
|
|
324
|
+
function or() {
|
|
190
325
|
return new Promise((t) => requestAnimationFrame(() => t()));
|
|
191
326
|
}
|
|
192
|
-
function
|
|
193
|
-
const { isCanvasReady: e, elements: r, hasInitialElements: a, initialElementsLoaded: n } = t, [c, o] =
|
|
194
|
-
return
|
|
327
|
+
function sr(t) {
|
|
328
|
+
const { isCanvasReady: e, elements: r, hasInitialElements: a, initialElementsLoaded: n } = t, [c, o] = re(!1), i = D(!1);
|
|
329
|
+
return I(() => {
|
|
195
330
|
if (c || !e || a && !n || a && r.length === 0 || i.current) return;
|
|
196
331
|
i.current = !0;
|
|
197
332
|
let l = !1;
|
|
198
333
|
return (async () => {
|
|
199
334
|
try {
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
335
|
+
const m = nr(r);
|
|
336
|
+
if (m.length > 0 && (await ar(m), l) || (await or(), l)) return;
|
|
202
337
|
o(!0);
|
|
203
|
-
} catch (
|
|
204
|
-
|
|
338
|
+
} catch (m) {
|
|
339
|
+
Ze.error("Error during content readiness check:", m), l || o(!0);
|
|
205
340
|
} finally {
|
|
206
341
|
i.current = !1;
|
|
207
342
|
}
|
|
@@ -210,7 +345,7 @@ function Wt(t) {
|
|
|
210
345
|
};
|
|
211
346
|
}, [e, r, a, n, c]), c;
|
|
212
347
|
}
|
|
213
|
-
const
|
|
348
|
+
const ir = {
|
|
214
349
|
// Vertical alignments (map to top/center/bottom center)
|
|
215
350
|
"far-top": "t",
|
|
216
351
|
top: "t",
|
|
@@ -233,75 +368,75 @@ const Nt = {
|
|
|
233
368
|
b: "b",
|
|
234
369
|
br: "br"
|
|
235
370
|
};
|
|
236
|
-
function
|
|
237
|
-
return t &&
|
|
371
|
+
function cr(t) {
|
|
372
|
+
return t && ir[t] || "c";
|
|
238
373
|
}
|
|
239
|
-
function
|
|
240
|
-
const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c,
|
|
241
|
-
let
|
|
242
|
-
const
|
|
243
|
-
switch (
|
|
374
|
+
function lr(t, e) {
|
|
375
|
+
const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c, m = i / t.width, A = l / t.height, M = r === "contain" ? Math.min(m, A) : Math.max(m, A), w = e.scale || 1, S = M * w, T = t.width * S, E = t.height * S, N = e.align || "c";
|
|
376
|
+
let k = 0, h = 0;
|
|
377
|
+
const R = T - i, x = E - l;
|
|
378
|
+
switch (N) {
|
|
244
379
|
// Top row
|
|
245
380
|
case "tl":
|
|
246
|
-
|
|
381
|
+
k = 0, h = 0;
|
|
247
382
|
break;
|
|
248
383
|
case "t":
|
|
249
|
-
|
|
384
|
+
k = -R / 2, h = 0;
|
|
250
385
|
break;
|
|
251
386
|
case "tr":
|
|
252
|
-
|
|
387
|
+
k = -R, h = 0;
|
|
253
388
|
break;
|
|
254
389
|
// Middle row
|
|
255
390
|
case "l":
|
|
256
|
-
|
|
391
|
+
k = 0, h = -x / 2;
|
|
257
392
|
break;
|
|
258
393
|
case "c":
|
|
259
394
|
// Center (default)
|
|
260
395
|
default:
|
|
261
|
-
|
|
396
|
+
k = -R / 2, h = -x / 2;
|
|
262
397
|
break;
|
|
263
398
|
case "r":
|
|
264
|
-
|
|
399
|
+
k = -R, h = -x / 2;
|
|
265
400
|
break;
|
|
266
401
|
// Bottom row
|
|
267
402
|
case "bl":
|
|
268
|
-
|
|
403
|
+
k = 0, h = -x;
|
|
269
404
|
break;
|
|
270
405
|
case "b":
|
|
271
|
-
|
|
406
|
+
k = -R / 2, h = -x;
|
|
272
407
|
break;
|
|
273
408
|
case "br":
|
|
274
|
-
|
|
409
|
+
k = -R, h = -x;
|
|
275
410
|
break;
|
|
276
411
|
}
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
return
|
|
412
|
+
k += o, h += a;
|
|
413
|
+
const L = e.offsetX || 0, F = e.offsetY || 0, O = R, ne = x;
|
|
414
|
+
return k += L * O, h += F * ne, k = Math.round(k), h = Math.round(h), {
|
|
280
415
|
// Final scale to apply to artwork
|
|
281
|
-
scale:
|
|
416
|
+
scale: S,
|
|
282
417
|
// Final artwork dimensions after scaling
|
|
283
|
-
width: Math.round(
|
|
284
|
-
height: Math.round(
|
|
418
|
+
width: Math.round(T),
|
|
419
|
+
height: Math.round(E),
|
|
285
420
|
// Position to draw artwork (relative to artboard origin)
|
|
286
|
-
x:
|
|
287
|
-
y:
|
|
421
|
+
x: k,
|
|
422
|
+
y: h,
|
|
288
423
|
// Debug info
|
|
289
424
|
debug: {
|
|
290
|
-
coverScale:
|
|
291
|
-
userScale:
|
|
292
|
-
overflow: { x:
|
|
293
|
-
alignment:
|
|
294
|
-
appliedOffset: { x:
|
|
425
|
+
coverScale: M,
|
|
426
|
+
userScale: w,
|
|
427
|
+
overflow: { x: R, y: x },
|
|
428
|
+
alignment: N,
|
|
429
|
+
appliedOffset: { x: L * O, y: F * ne }
|
|
295
430
|
}
|
|
296
431
|
};
|
|
297
432
|
}
|
|
298
|
-
const
|
|
433
|
+
const dr = {
|
|
299
434
|
timeout: 3e4,
|
|
300
435
|
retries: 1,
|
|
301
436
|
retryDelay: 1e3,
|
|
302
437
|
validateUrl: !0
|
|
303
438
|
};
|
|
304
|
-
function
|
|
439
|
+
function ur(t) {
|
|
305
440
|
try {
|
|
306
441
|
const e = new URL(t);
|
|
307
442
|
return ["http:", "https:", "data:", "blob:"].includes(e.protocol);
|
|
@@ -309,9 +444,9 @@ function Yt(t) {
|
|
|
309
444
|
return !1;
|
|
310
445
|
}
|
|
311
446
|
}
|
|
312
|
-
async function
|
|
313
|
-
const r = { ...
|
|
314
|
-
if (r.validateUrl && !
|
|
447
|
+
async function fr(t, e = {}) {
|
|
448
|
+
const r = { ...dr, ...e };
|
|
449
|
+
if (r.validateUrl && !ur(t))
|
|
315
450
|
return {
|
|
316
451
|
success: !1,
|
|
317
452
|
error: new Error(`Invalid image URL: ${t}`)
|
|
@@ -319,16 +454,16 @@ async function $t(t, e = {}) {
|
|
|
319
454
|
let a;
|
|
320
455
|
for (let n = 0; n <= r.retries; n++)
|
|
321
456
|
try {
|
|
322
|
-
return await
|
|
457
|
+
return await mr(t, r.timeout);
|
|
323
458
|
} catch (c) {
|
|
324
|
-
a = c instanceof Error ? c : new Error(String(c)), n < r.retries && await
|
|
459
|
+
a = c instanceof Error ? c : new Error(String(c)), n < r.retries && await gr(r.retryDelay);
|
|
325
460
|
}
|
|
326
461
|
return {
|
|
327
462
|
success: !1,
|
|
328
463
|
error: a || new Error("Failed to load image after retries")
|
|
329
464
|
};
|
|
330
465
|
}
|
|
331
|
-
function
|
|
466
|
+
function mr(t, e) {
|
|
332
467
|
return new Promise((r) => {
|
|
333
468
|
const a = new Image();
|
|
334
469
|
a.crossOrigin = "anonymous";
|
|
@@ -338,18 +473,18 @@ function Ot(t, e) {
|
|
|
338
473
|
}, i = () => {
|
|
339
474
|
if (c) return;
|
|
340
475
|
c = !0, o();
|
|
341
|
-
const
|
|
476
|
+
const m = a.naturalWidth || a.width, A = a.naturalHeight || a.height;
|
|
342
477
|
r({
|
|
343
478
|
success: !0,
|
|
344
479
|
element: a,
|
|
345
|
-
width:
|
|
346
|
-
height:
|
|
347
|
-
aspectRatio:
|
|
480
|
+
width: m,
|
|
481
|
+
height: A,
|
|
482
|
+
aspectRatio: A > 0 ? m / A : 1
|
|
348
483
|
});
|
|
349
|
-
}, l = (
|
|
484
|
+
}, l = (m) => {
|
|
350
485
|
c || (c = !0, o(), r({
|
|
351
486
|
success: !1,
|
|
352
|
-
error: new Error(
|
|
487
|
+
error: new Error(m)
|
|
353
488
|
}));
|
|
354
489
|
};
|
|
355
490
|
a.onload = i, a.onerror = () => {
|
|
@@ -359,9 +494,9 @@ function Ot(t, e) {
|
|
|
359
494
|
}, e), a.src = t;
|
|
360
495
|
});
|
|
361
496
|
}
|
|
362
|
-
async function
|
|
363
|
-
var
|
|
364
|
-
const n = await
|
|
497
|
+
async function hr(t, e, r = {}, a = {}) {
|
|
498
|
+
var w, S, T, E, N, k, h;
|
|
499
|
+
const n = await fr(t, a);
|
|
365
500
|
if (!n.success || !n.width || !n.height)
|
|
366
501
|
return {
|
|
367
502
|
success: !1,
|
|
@@ -371,7 +506,7 @@ async function Xt(t, e, r = {}, a = {}) {
|
|
|
371
506
|
width: e.artboard.width,
|
|
372
507
|
height: e.artboard.height,
|
|
373
508
|
scale: e.scale,
|
|
374
|
-
align:
|
|
509
|
+
align: cr(e.alignment),
|
|
375
510
|
offsetX: e.offsetX,
|
|
376
511
|
offsetY: e.offsetY,
|
|
377
512
|
scaleMode: e.scaleMode,
|
|
@@ -379,16 +514,16 @@ async function Xt(t, e, r = {}, a = {}) {
|
|
|
379
514
|
marginRight: e.marginRight,
|
|
380
515
|
marginBottom: e.marginBottom,
|
|
381
516
|
marginLeft: e.marginLeft
|
|
382
|
-
}, o =
|
|
517
|
+
}, o = lr(
|
|
383
518
|
{ width: n.width, height: n.height },
|
|
384
519
|
c
|
|
385
|
-
), i = e.artboard.x + o.x, l = e.artboard.y + o.y,
|
|
520
|
+
), i = e.artboard.x + o.x, l = e.artboard.y + o.y, m = i + o.width / 2, A = l + o.height / 2;
|
|
386
521
|
return {
|
|
387
522
|
success: !0,
|
|
388
|
-
element: new
|
|
523
|
+
element: new Ve({
|
|
389
524
|
...r,
|
|
390
|
-
x:
|
|
391
|
-
y:
|
|
525
|
+
x: m,
|
|
526
|
+
y: A,
|
|
392
527
|
imageUrl: t,
|
|
393
528
|
imageAspectRatio: n.aspectRatio,
|
|
394
529
|
preserveDimensions: !0,
|
|
@@ -397,28 +532,28 @@ async function Xt(t, e, r = {}, a = {}) {
|
|
|
397
532
|
type: "image",
|
|
398
533
|
width: o.width,
|
|
399
534
|
height: o.height,
|
|
400
|
-
cropX: ((
|
|
401
|
-
cropY: ((
|
|
402
|
-
cropWidth: ((
|
|
403
|
-
cropHeight: ((
|
|
404
|
-
flipHorizontal: ((
|
|
405
|
-
flipVertical: ((
|
|
406
|
-
borderRadius: ((
|
|
535
|
+
cropX: ((w = r.transformData) == null ? void 0 : w.cropX) ?? 0,
|
|
536
|
+
cropY: ((S = r.transformData) == null ? void 0 : S.cropY) ?? 0,
|
|
537
|
+
cropWidth: ((T = r.transformData) == null ? void 0 : T.cropWidth) ?? 1,
|
|
538
|
+
cropHeight: ((E = r.transformData) == null ? void 0 : E.cropHeight) ?? 1,
|
|
539
|
+
flipHorizontal: ((N = r.transformData) == null ? void 0 : N.flipHorizontal) ?? !1,
|
|
540
|
+
flipVertical: ((k = r.transformData) == null ? void 0 : k.flipVertical) ?? !1,
|
|
541
|
+
borderRadius: ((h = r.transformData) == null ? void 0 : h.borderRadius) ?? 0
|
|
407
542
|
}
|
|
408
543
|
}),
|
|
409
544
|
placement: {
|
|
410
545
|
artworkSize: { width: n.width, height: n.height },
|
|
411
546
|
finalSize: { width: o.width, height: o.height },
|
|
412
|
-
position: { x:
|
|
547
|
+
position: { x: m, y: A },
|
|
413
548
|
scale: o.scale
|
|
414
549
|
}
|
|
415
550
|
};
|
|
416
551
|
}
|
|
417
|
-
function
|
|
552
|
+
function gr(t) {
|
|
418
553
|
return new Promise((e) => setTimeout(e, t));
|
|
419
554
|
}
|
|
420
|
-
const K =
|
|
421
|
-
function
|
|
555
|
+
const K = q("SnowconeCanvas");
|
|
556
|
+
function Se(t, e, r, a) {
|
|
422
557
|
if (a <= 0 || !isFinite(a))
|
|
423
558
|
return r;
|
|
424
559
|
const n = t * r, c = e * r;
|
|
@@ -427,7 +562,7 @@ function Ee(t, e, r, a) {
|
|
|
427
562
|
const i = Math.max(t, e), l = a / i;
|
|
428
563
|
return Math.min(l, r);
|
|
429
564
|
}
|
|
430
|
-
const
|
|
565
|
+
const Qe = je((t, e) => {
|
|
431
566
|
const {
|
|
432
567
|
exportConfig: r,
|
|
433
568
|
imageConfig: a,
|
|
@@ -436,152 +571,153 @@ const Je = je((t, e) => {
|
|
|
436
571
|
artboards: o,
|
|
437
572
|
activeArtboard: i,
|
|
438
573
|
onArtboardChange: l,
|
|
439
|
-
initialElements:
|
|
440
|
-
onChange:
|
|
441
|
-
onSelectionChange:
|
|
442
|
-
autoExportInterval:
|
|
443
|
-
onExport:
|
|
444
|
-
onExportScheduled:
|
|
445
|
-
onExportStatus:
|
|
446
|
-
onExportReady:
|
|
447
|
-
onImageLoad:
|
|
448
|
-
onImageError:
|
|
449
|
-
onError:
|
|
450
|
-
onReady:
|
|
451
|
-
className:
|
|
452
|
-
style:
|
|
453
|
-
enableShortcuts:
|
|
454
|
-
overlay:
|
|
455
|
-
} = t,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
574
|
+
initialElements: m,
|
|
575
|
+
onChange: A,
|
|
576
|
+
onSelectionChange: M,
|
|
577
|
+
autoExportInterval: w,
|
|
578
|
+
onExport: S,
|
|
579
|
+
onExportScheduled: T,
|
|
580
|
+
onExportStatus: E,
|
|
581
|
+
onExportReady: N,
|
|
582
|
+
onImageLoad: k,
|
|
583
|
+
onImageError: h,
|
|
584
|
+
onError: R,
|
|
585
|
+
onReady: x,
|
|
586
|
+
className: L,
|
|
587
|
+
style: F,
|
|
588
|
+
enableShortcuts: O,
|
|
589
|
+
overlay: ne
|
|
590
|
+
} = t, Re = w, J = t.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), G = t.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", pe = t.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, X = t.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, U = t.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, ae = t.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", oe = t.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, z = t.initialImage ?? (a == null ? void 0 : a.src), Ie = t.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", Ce = t.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, Me = t.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", qe = t.width ?? (n == null ? void 0 : n.width) ?? 1200, Je = t.height ?? (n == null ? void 0 : n.height) ?? 1200, _e = t.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, et = t.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, tt = t.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), rt = t.maxHeight ?? (n == null ? void 0 : n.maxHeight), nt = t.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, at = t.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Te = t.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), De = t.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), ot = t.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), Fe = t.pieceGuides, st = t.pieceFocus, it = O ?? !0, _ = he(() => Pt(c ?? "pro-studio"), [c]);
|
|
591
|
+
I(() => {
|
|
592
|
+
var s;
|
|
593
|
+
if (typeof me < "u" && ((s = me.env) == null ? void 0 : s.NODE_ENV) === "development" && _) {
|
|
594
|
+
const d = Nt(_);
|
|
595
|
+
d.valid || K.warn("Kit validation warnings:", d.errors), d.warnings.length > 0 && K.warn("Kit validation warnings:", d.warnings);
|
|
460
596
|
}
|
|
461
|
-
}, [
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
const B =
|
|
597
|
+
}, [_]);
|
|
598
|
+
const se = D(R);
|
|
599
|
+
se.current = R;
|
|
600
|
+
const B = W((s) => {
|
|
465
601
|
var d;
|
|
466
|
-
K.error(`[${s.category}] ${s.message}`, s.originalError), (d =
|
|
602
|
+
K.error(`[${s.category}] ${s.message}`, s.originalError), (d = se.current) == null || d.call(se, s);
|
|
467
603
|
}, []);
|
|
468
|
-
|
|
469
|
-
|
|
604
|
+
I(() => (Ae.onRenderError = B, () => {
|
|
605
|
+
Ae.onRenderError === B && (Ae.onRenderError = null);
|
|
470
606
|
}), [B]);
|
|
471
607
|
const {
|
|
472
608
|
elements: V,
|
|
473
|
-
setElements:
|
|
474
|
-
selectedId:
|
|
475
|
-
artboardManager:
|
|
476
|
-
refreshArtboards:
|
|
477
|
-
historyManager:
|
|
478
|
-
isCanvasReady:
|
|
479
|
-
setCanvasReady:
|
|
480
|
-
} =
|
|
481
|
-
|
|
609
|
+
setElements: ie,
|
|
610
|
+
selectedId: Pe,
|
|
611
|
+
artboardManager: C,
|
|
612
|
+
refreshArtboards: ct,
|
|
613
|
+
historyManager: lt,
|
|
614
|
+
isCanvasReady: be,
|
|
615
|
+
setCanvasReady: ce
|
|
616
|
+
} = ge(), { createArtboard: dt, selectArtboard: ut, artboards: H } = Ht(), { exportArtboard: Z, exportAllArtboards: le, exportArtboardAsBlob: Q, exportAllArtboardsAsBlobs: de } = Lt();
|
|
617
|
+
Xt(e, () => ({
|
|
482
618
|
exportArtboards: async (s = {}) => {
|
|
483
|
-
const d = s.format ||
|
|
484
|
-
let f =
|
|
619
|
+
const d = s.format || G, g = s.scale || X, p = s.all ?? !1;
|
|
620
|
+
let f = g;
|
|
485
621
|
if (U > 0 && isFinite(U))
|
|
486
|
-
for (const
|
|
487
|
-
const b =
|
|
622
|
+
for (const y of H) {
|
|
623
|
+
const b = Se(y.width, y.height, g, U);
|
|
488
624
|
f = Math.min(f, b);
|
|
489
625
|
}
|
|
490
|
-
const u = { scale: f, format:
|
|
491
|
-
if (
|
|
492
|
-
const
|
|
493
|
-
for (const [
|
|
494
|
-
const
|
|
495
|
-
|
|
626
|
+
const u = { scale: f, format: ae, quality: oe };
|
|
627
|
+
if (p) {
|
|
628
|
+
const y = d === "blob" ? await de(u) : await le(u), b = {};
|
|
629
|
+
for (const [P, $] of Object.entries(y)) {
|
|
630
|
+
const Y = H.find((ee) => ee.id === P);
|
|
631
|
+
Y && (b[Y.name] = $);
|
|
496
632
|
}
|
|
497
633
|
return b;
|
|
498
634
|
} else {
|
|
499
|
-
const
|
|
500
|
-
if (!
|
|
635
|
+
const y = C.getActiveArtboard();
|
|
636
|
+
if (!y)
|
|
501
637
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
502
638
|
if (d === "blob") {
|
|
503
|
-
const b = await Q(
|
|
504
|
-
return { [
|
|
639
|
+
const b = await Q(y.id, u);
|
|
640
|
+
return { [y.name]: b };
|
|
505
641
|
} else {
|
|
506
|
-
const b = await
|
|
507
|
-
return { [
|
|
642
|
+
const b = await Z(y.id, u);
|
|
643
|
+
return { [y.name]: b };
|
|
508
644
|
}
|
|
509
645
|
}
|
|
510
646
|
}
|
|
511
|
-
}), [
|
|
512
|
-
|
|
513
|
-
const d =
|
|
647
|
+
}), [Z, le, Q, de, G, X, U, ae, oe, C, H]), I(() => {
|
|
648
|
+
N && N(async () => {
|
|
649
|
+
const d = C.getActiveArtboard();
|
|
514
650
|
if (!d)
|
|
515
651
|
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
516
|
-
const
|
|
652
|
+
const g = Se(
|
|
517
653
|
d.width,
|
|
518
654
|
d.height,
|
|
519
655
|
X,
|
|
520
656
|
U
|
|
521
|
-
),
|
|
522
|
-
return { [d.name]:
|
|
657
|
+
), p = G === "blob" ? await Q(d.id, { scale: g }) : await Z(d.id, { scale: g });
|
|
658
|
+
return { [d.name]: p };
|
|
523
659
|
});
|
|
524
|
-
}, [
|
|
525
|
-
const [
|
|
526
|
-
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
const s = o || [{ name: "Design", width:
|
|
660
|
+
}, [N, Z, Q, C, G, X, U]);
|
|
661
|
+
const [Ne, ue] = re("idle"), [He, ve] = re(null), xe = D(void 0), ye = D(!1), Le = D(!1), [ft, mt] = re(!1), ht = D(0), gt = D(0), we = D(!1);
|
|
662
|
+
I(() => {
|
|
663
|
+
if (ye.current) return;
|
|
664
|
+
ye.current = !0;
|
|
665
|
+
const s = o || [{ name: "Design", width: qe, height: Je }], d = C.getAllArtboards();
|
|
530
666
|
if (d.length > 0) {
|
|
531
|
-
const
|
|
532
|
-
|
|
667
|
+
const g = s[0], p = d[0], f = Fe ? "transparent" : void 0;
|
|
668
|
+
p.name = g.name, p.width = g.width, p.height = g.height, p.clipShape = g.clipShape, g.backgroundColor ? p.backgroundColor = g.backgroundColor : f && (p.backgroundColor = f);
|
|
533
669
|
for (let u = 1; u < s.length; u++)
|
|
534
|
-
|
|
670
|
+
dt(s[u].width, s[u].height, {
|
|
535
671
|
name: s[u].name,
|
|
536
672
|
backgroundColor: s[u].backgroundColor ?? f,
|
|
537
673
|
clipShape: s[u].clipShape
|
|
538
674
|
});
|
|
539
675
|
}
|
|
540
|
-
|
|
541
|
-
}, []),
|
|
542
|
-
if (!(!
|
|
543
|
-
|
|
676
|
+
ct();
|
|
677
|
+
}, []), I(() => {
|
|
678
|
+
if (!(!m || m.length === 0) && !Le.current && ye.current) {
|
|
679
|
+
Le.current = !0, mt(!0);
|
|
544
680
|
try {
|
|
545
|
-
const s =
|
|
681
|
+
const s = jt.createManyFromJSON(m), d = C.getAllArtboards();
|
|
546
682
|
if (d.length > 0) {
|
|
547
|
-
const
|
|
683
|
+
const p = d[0];
|
|
548
684
|
for (const f of s)
|
|
549
|
-
|
|
685
|
+
C.addElementToArtboard(f.id, p.id);
|
|
550
686
|
}
|
|
551
|
-
|
|
552
|
-
const
|
|
553
|
-
for (const
|
|
554
|
-
const f =
|
|
555
|
-
typeof f == "string" && f.trim().length > 0 &&
|
|
687
|
+
ie(s);
|
|
688
|
+
const g = /* @__PURE__ */ new Set();
|
|
689
|
+
for (const p of s) {
|
|
690
|
+
const f = p.fontFamily;
|
|
691
|
+
typeof f == "string" && f.trim().length > 0 && g.add(f);
|
|
556
692
|
}
|
|
557
|
-
if (
|
|
558
|
-
const
|
|
559
|
-
const
|
|
560
|
-
let b = document.getElementById(
|
|
561
|
-
return b || (b = document.createElement("link"), b.id =
|
|
693
|
+
if (g.size > 0 && typeof document < "u") {
|
|
694
|
+
const p = document.fonts ?? null, f = Array.from(g).map((u) => {
|
|
695
|
+
const y = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
|
|
696
|
+
let b = document.getElementById(y);
|
|
697
|
+
return b || (b = document.createElement("link"), b.id = y, b.rel = "stylesheet", b.href = `https://fonts.googleapis.com/css2?family=${u.replace(
|
|
562
698
|
/\s+/g,
|
|
563
699
|
"+"
|
|
564
|
-
)}:wght@400;700&display=swap`, document.head.appendChild(b)), new Promise((
|
|
700
|
+
)}:wght@400;700&display=swap`, document.head.appendChild(b)), new Promise((P) => {
|
|
565
701
|
if (b.sheet) {
|
|
566
|
-
|
|
702
|
+
P(u);
|
|
567
703
|
return;
|
|
568
704
|
}
|
|
569
|
-
const
|
|
570
|
-
b.addEventListener("load",
|
|
705
|
+
const $ = () => P(u);
|
|
706
|
+
b.addEventListener("load", $, { once: !0 }), b.addEventListener("error", $, { once: !0 }), setTimeout($, 4e3);
|
|
571
707
|
});
|
|
572
708
|
});
|
|
573
709
|
Promise.all(f).then((u) => {
|
|
574
|
-
if (
|
|
710
|
+
if (p)
|
|
575
711
|
return Promise.all(
|
|
576
|
-
u.flatMap((
|
|
577
|
-
|
|
712
|
+
u.flatMap((y) => [
|
|
713
|
+
p.load(`400 16px "${y}"`).catch(() => {
|
|
578
714
|
}),
|
|
579
|
-
|
|
715
|
+
p.load(`700 16px "${y}"`).catch(() => {
|
|
580
716
|
})
|
|
581
717
|
])
|
|
582
718
|
);
|
|
583
719
|
}).then(() => {
|
|
584
|
-
|
|
720
|
+
ie((u) => u.slice());
|
|
585
721
|
});
|
|
586
722
|
}
|
|
587
723
|
} catch (s) {
|
|
@@ -595,41 +731,41 @@ const Je = je((t, e) => {
|
|
|
595
731
|
});
|
|
596
732
|
}
|
|
597
733
|
}
|
|
598
|
-
}, [
|
|
734
|
+
}, [m, C, ie, B]), I(() => {
|
|
599
735
|
if (!i) {
|
|
600
|
-
|
|
736
|
+
we.current = !0;
|
|
601
737
|
return;
|
|
602
738
|
}
|
|
603
|
-
const s =
|
|
739
|
+
const s = H.find((d) => d.name === i);
|
|
604
740
|
if (s) {
|
|
605
|
-
const d =
|
|
606
|
-
(d == null ? void 0 : d.name) !== i &&
|
|
741
|
+
const d = C.getActiveArtboard();
|
|
742
|
+
(d == null ? void 0 : d.name) !== i && ut(s.id), we.current = !0;
|
|
607
743
|
}
|
|
608
|
-
}, [i,
|
|
609
|
-
if (!z ||
|
|
744
|
+
}, [i, H]), I(() => {
|
|
745
|
+
if (!z || xe.current === z) return;
|
|
610
746
|
if (V.length > 0) {
|
|
611
|
-
|
|
747
|
+
xe.current = z;
|
|
612
748
|
return;
|
|
613
749
|
}
|
|
614
|
-
|
|
615
|
-
|
|
750
|
+
xe.current = z, (async () => {
|
|
751
|
+
ue("loading"), ve(null);
|
|
616
752
|
try {
|
|
617
|
-
const d =
|
|
753
|
+
const d = C.getAllArtboards();
|
|
618
754
|
if (d.length === 0)
|
|
619
755
|
throw new Error("No artboards available");
|
|
620
|
-
const
|
|
621
|
-
for (const
|
|
622
|
-
const f = o == null ? void 0 : o.find((b) => b.name ===
|
|
756
|
+
const g = [];
|
|
757
|
+
for (const p of d) {
|
|
758
|
+
const f = o == null ? void 0 : o.find((b) => b.name === p.name), u = (f == null ? void 0 : f.scaleMode) || Me, y = await hr(
|
|
623
759
|
z,
|
|
624
760
|
{
|
|
625
761
|
artboard: {
|
|
626
|
-
width:
|
|
627
|
-
height:
|
|
628
|
-
x:
|
|
629
|
-
y:
|
|
762
|
+
width: p.width,
|
|
763
|
+
height: p.height,
|
|
764
|
+
x: p.x,
|
|
765
|
+
y: p.y
|
|
630
766
|
},
|
|
631
|
-
alignment: (f == null ? void 0 : f.fitAlign) ||
|
|
632
|
-
scale:
|
|
767
|
+
alignment: (f == null ? void 0 : f.fitAlign) || Ie,
|
|
768
|
+
scale: Ce,
|
|
633
769
|
scaleMode: u,
|
|
634
770
|
marginTop: f == null ? void 0 : f.fitMarginTop,
|
|
635
771
|
marginRight: f == null ? void 0 : f.fitMarginRight,
|
|
@@ -637,135 +773,135 @@ const Je = je((t, e) => {
|
|
|
637
773
|
marginLeft: f == null ? void 0 : f.fitMarginLeft
|
|
638
774
|
}
|
|
639
775
|
);
|
|
640
|
-
|
|
776
|
+
y.success && y.element ? (C.addElementToArtboard(y.element.id, p.id), g.push(y.element)) : K.error("Failed to load image for artboard:", p.name, y.error);
|
|
641
777
|
}
|
|
642
|
-
if (
|
|
643
|
-
|
|
778
|
+
if (g.length > 0)
|
|
779
|
+
ie((p) => [...p, ...g]), ue("success"), k == null || k(z);
|
|
644
780
|
else {
|
|
645
|
-
const
|
|
646
|
-
|
|
781
|
+
const p = new Error("Failed to load image into any artboard");
|
|
782
|
+
ue("error"), ve(p), h == null || h(z, p), B({
|
|
647
783
|
category: "image",
|
|
648
|
-
message:
|
|
649
|
-
originalError:
|
|
784
|
+
message: p.message,
|
|
785
|
+
originalError: p,
|
|
650
786
|
recoverable: !0
|
|
651
787
|
});
|
|
652
788
|
}
|
|
653
789
|
} catch (d) {
|
|
654
|
-
const
|
|
655
|
-
|
|
790
|
+
const g = d instanceof Error ? d : new Error(String(d));
|
|
791
|
+
ue("error"), ve(g), h == null || h(z, g), B({
|
|
656
792
|
category: "image",
|
|
657
|
-
message:
|
|
658
|
-
originalError:
|
|
793
|
+
message: g.message,
|
|
794
|
+
originalError: g,
|
|
659
795
|
recoverable: !0
|
|
660
796
|
});
|
|
661
797
|
}
|
|
662
798
|
})();
|
|
663
|
-
}, [z,
|
|
664
|
-
|
|
665
|
-
}, [
|
|
666
|
-
if (!
|
|
667
|
-
const s =
|
|
668
|
-
elements: V.map((
|
|
669
|
-
artboards:
|
|
670
|
-
name:
|
|
671
|
-
width:
|
|
672
|
-
height:
|
|
673
|
-
clipShape:
|
|
674
|
-
backgroundColor:
|
|
799
|
+
}, [z, Ie, Ce, Me]), I(() => {
|
|
800
|
+
M == null || M(Pe);
|
|
801
|
+
}, [Pe, M]), I(() => {
|
|
802
|
+
if (!A) return;
|
|
803
|
+
const s = C.getActiveArtboard(), d = {
|
|
804
|
+
elements: V.map((g) => g.toJSON()),
|
|
805
|
+
artboards: H.map((g) => ({
|
|
806
|
+
name: g.name,
|
|
807
|
+
width: g.width,
|
|
808
|
+
height: g.height,
|
|
809
|
+
clipShape: g.clipShape,
|
|
810
|
+
backgroundColor: g.backgroundColor
|
|
675
811
|
})),
|
|
676
812
|
activeArtboard: (s == null ? void 0 : s.name) || "Design"
|
|
677
813
|
};
|
|
678
|
-
|
|
679
|
-
}, [V,
|
|
680
|
-
if (!l || !
|
|
681
|
-
const s =
|
|
814
|
+
A(d);
|
|
815
|
+
}, [V, H, A]), I(() => {
|
|
816
|
+
if (!l || !we.current) return;
|
|
817
|
+
const s = C.getActiveArtboard();
|
|
682
818
|
s && l(s.name);
|
|
683
|
-
}, [
|
|
684
|
-
const
|
|
685
|
-
if (!
|
|
686
|
-
const s = ++
|
|
687
|
-
let
|
|
819
|
+
}, [C.getActiveArtboardId()]);
|
|
820
|
+
const pt = W(async () => {
|
|
821
|
+
if (!S && !E) return;
|
|
822
|
+
const s = ++gt.current, d = Date.now();
|
|
823
|
+
let g = X;
|
|
688
824
|
if (U > 0 && isFinite(U))
|
|
689
|
-
for (const u of
|
|
690
|
-
const
|
|
691
|
-
|
|
825
|
+
for (const u of H) {
|
|
826
|
+
const y = Se(u.width, u.height, X, U);
|
|
827
|
+
g = Math.min(g, y);
|
|
692
828
|
}
|
|
693
|
-
const
|
|
694
|
-
|
|
829
|
+
const p = C.getActiveArtboard(), f = (p == null ? void 0 : p.id) ?? "unknown";
|
|
830
|
+
E == null || E({ status: "rendering", artboardId: f }), ht.current = d;
|
|
695
831
|
try {
|
|
696
832
|
let u;
|
|
697
|
-
const
|
|
698
|
-
format:
|
|
699
|
-
scale:
|
|
700
|
-
quality:
|
|
833
|
+
const y = {
|
|
834
|
+
format: ae,
|
|
835
|
+
scale: g,
|
|
836
|
+
quality: oe
|
|
701
837
|
};
|
|
702
|
-
if (
|
|
703
|
-
if (
|
|
704
|
-
const b = await
|
|
838
|
+
if (G === "blob")
|
|
839
|
+
if (pe) {
|
|
840
|
+
const b = await de(y);
|
|
705
841
|
u = {};
|
|
706
|
-
for (const [
|
|
707
|
-
const
|
|
708
|
-
|
|
842
|
+
for (const [P, $] of Object.entries(b)) {
|
|
843
|
+
const Y = H.find((ee) => ee.id === P);
|
|
844
|
+
Y && (u[Y.name] = $);
|
|
709
845
|
}
|
|
710
846
|
} else {
|
|
711
|
-
const b =
|
|
847
|
+
const b = C.getActiveArtboard();
|
|
712
848
|
if (!b) return;
|
|
713
|
-
const
|
|
714
|
-
u = { [b.name]:
|
|
849
|
+
const P = await Q(b.id, y);
|
|
850
|
+
u = { [b.name]: P };
|
|
715
851
|
}
|
|
716
|
-
else if (
|
|
717
|
-
const b = await
|
|
852
|
+
else if (pe) {
|
|
853
|
+
const b = await le(y);
|
|
718
854
|
u = {};
|
|
719
|
-
for (const [
|
|
720
|
-
const
|
|
721
|
-
|
|
855
|
+
for (const [P, $] of Object.entries(b)) {
|
|
856
|
+
const Y = H.find((ee) => ee.id === P);
|
|
857
|
+
Y && (u[Y.name] = $);
|
|
722
858
|
}
|
|
723
859
|
} else {
|
|
724
|
-
const b =
|
|
860
|
+
const b = C.getActiveArtboard();
|
|
725
861
|
if (!b) return;
|
|
726
|
-
const
|
|
727
|
-
u = { [b.name]:
|
|
862
|
+
const P = await Z(b.id, y);
|
|
863
|
+
u = { [b.name]: P };
|
|
728
864
|
}
|
|
729
|
-
|
|
865
|
+
S == null || S(u), E == null || E({ status: "complete", artboardId: f, result: u });
|
|
730
866
|
} catch (u) {
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
867
|
+
const y = u instanceof Error ? u.message : String(u);
|
|
868
|
+
if (y.includes("Canvas ref not available"))
|
|
733
869
|
return;
|
|
734
870
|
const b = Date.now() - d;
|
|
735
871
|
K.error("Export failed (export #" + s + "):", {
|
|
736
872
|
duration: `${b}ms`,
|
|
737
|
-
error:
|
|
873
|
+
error: y
|
|
738
874
|
});
|
|
739
|
-
const
|
|
740
|
-
|
|
875
|
+
const P = u instanceof Error ? u : new Error(y);
|
|
876
|
+
E == null || E({ status: "error", artboardId: f, error: P }), B({
|
|
741
877
|
category: "export",
|
|
742
|
-
message:
|
|
743
|
-
originalError:
|
|
878
|
+
message: P.message,
|
|
879
|
+
originalError: P,
|
|
744
880
|
artboardId: f,
|
|
745
881
|
recoverable: !0
|
|
746
882
|
});
|
|
747
883
|
}
|
|
748
|
-
}, [
|
|
749
|
-
|
|
750
|
-
|
|
884
|
+
}, [S, E, pe, G, X, U, ae, oe, Z, le, Q, de, H, C, V, J, B]);
|
|
885
|
+
I(() => {
|
|
886
|
+
Re !== void 0 && Re > 0 && K.warn(
|
|
751
887
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
752
888
|
);
|
|
753
|
-
}, []),
|
|
889
|
+
}, []), I(() => {
|
|
754
890
|
}, [V]);
|
|
755
|
-
const
|
|
756
|
-
if (
|
|
757
|
-
const s =
|
|
758
|
-
|
|
891
|
+
const bt = W(() => {
|
|
892
|
+
if (T == null || T(), E) {
|
|
893
|
+
const s = C.getActiveArtboard();
|
|
894
|
+
E({ status: "scheduled", artboardId: (s == null ? void 0 : s.id) ?? "unknown" });
|
|
759
895
|
}
|
|
760
|
-
}, [
|
|
761
|
-
isCanvasReady:
|
|
896
|
+
}, [T, E, C]), vt = !!m && m.length > 0, Ee = sr({
|
|
897
|
+
isCanvasReady: be,
|
|
762
898
|
elements: V,
|
|
763
|
-
hasInitialElements:
|
|
764
|
-
initialElementsLoaded:
|
|
765
|
-
}),
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}, [
|
|
899
|
+
hasInitialElements: vt,
|
|
900
|
+
initialElementsLoaded: ft
|
|
901
|
+
}), We = D(!1);
|
|
902
|
+
I(() => {
|
|
903
|
+
Ee && !We.current && (We.current = !0, x == null || x());
|
|
904
|
+
}, [Ee, x]), rr({
|
|
769
905
|
config: J ? {
|
|
770
906
|
enabled: J.enabled ?? !0,
|
|
771
907
|
debounceMs: J.debounceMs ?? 100,
|
|
@@ -774,24 +910,24 @@ const Je = je((t, e) => {
|
|
|
774
910
|
enabled: !1
|
|
775
911
|
// Only use smart export if autoExportConfig is provided
|
|
776
912
|
},
|
|
777
|
-
historyManager:
|
|
778
|
-
artboards:
|
|
913
|
+
historyManager: lt,
|
|
914
|
+
artboards: H,
|
|
779
915
|
elements: V,
|
|
780
|
-
onExport:
|
|
781
|
-
onExportScheduled:
|
|
782
|
-
isCanvasReady:
|
|
916
|
+
onExport: pt,
|
|
917
|
+
onExportScheduled: bt,
|
|
918
|
+
isCanvasReady: Ee
|
|
783
919
|
// Gate exports until content is fully ready (fonts loaded, elements deserialized)
|
|
784
|
-
}),
|
|
785
|
-
if (
|
|
920
|
+
}), I(() => {
|
|
921
|
+
if (H.length > 0 && !be) {
|
|
786
922
|
const s = requestAnimationFrame(() => {
|
|
787
|
-
|
|
923
|
+
ce(!0);
|
|
788
924
|
});
|
|
789
925
|
return () => cancelAnimationFrame(s);
|
|
790
926
|
}
|
|
791
|
-
}, [
|
|
792
|
-
|
|
793
|
-
}, [
|
|
794
|
-
const
|
|
927
|
+
}, [H.length, be, ce]), I(() => () => {
|
|
928
|
+
ce(!1);
|
|
929
|
+
}, [ce]);
|
|
930
|
+
const xt = W((s) => {
|
|
795
931
|
B({
|
|
796
932
|
category: "unknown",
|
|
797
933
|
message: s.message,
|
|
@@ -799,25 +935,25 @@ const Je = je((t, e) => {
|
|
|
799
935
|
recoverable: !1
|
|
800
936
|
});
|
|
801
937
|
}, [B]);
|
|
802
|
-
return
|
|
938
|
+
return Ne === "loading" ? /* @__PURE__ */ v(
|
|
803
939
|
"div",
|
|
804
940
|
{
|
|
805
|
-
className:
|
|
941
|
+
className: L,
|
|
806
942
|
style: {
|
|
807
|
-
...
|
|
943
|
+
...F,
|
|
808
944
|
display: "flex",
|
|
809
945
|
alignItems: "center",
|
|
810
946
|
justifyContent: "center",
|
|
811
947
|
backgroundColor: "var(--surface, #f5f5f5)"
|
|
812
948
|
},
|
|
813
|
-
children: /* @__PURE__ */
|
|
949
|
+
children: /* @__PURE__ */ v(Wt, { size: 48 })
|
|
814
950
|
}
|
|
815
|
-
) :
|
|
951
|
+
) : Ne === "error" && He ? /* @__PURE__ */ v(
|
|
816
952
|
"div",
|
|
817
953
|
{
|
|
818
|
-
className:
|
|
954
|
+
className: L,
|
|
819
955
|
style: {
|
|
820
|
-
...
|
|
956
|
+
...F,
|
|
821
957
|
display: "flex",
|
|
822
958
|
alignItems: "center",
|
|
823
959
|
justifyContent: "center",
|
|
@@ -825,16 +961,16 @@ const Je = je((t, e) => {
|
|
|
825
961
|
color: "var(--danger, #dc2626)",
|
|
826
962
|
padding: "1rem"
|
|
827
963
|
},
|
|
828
|
-
children: /* @__PURE__ */
|
|
829
|
-
/* @__PURE__ */
|
|
830
|
-
/* @__PURE__ */
|
|
964
|
+
children: /* @__PURE__ */ j("div", { className: "text-center", children: [
|
|
965
|
+
/* @__PURE__ */ v("div", { className: "font-medium", children: "Failed to load image" }),
|
|
966
|
+
/* @__PURE__ */ v("div", { className: "text-sm mt-1 opacity-70", children: He.message })
|
|
831
967
|
] })
|
|
832
968
|
}
|
|
833
|
-
) : /* @__PURE__ */
|
|
834
|
-
|
|
969
|
+
) : /* @__PURE__ */ v(Bt, { kit: _, children: /* @__PURE__ */ v("div", { className: `app-modern ${L || ""}`, style: { ...F, position: "relative" }, children: /* @__PURE__ */ j(
|
|
970
|
+
er,
|
|
835
971
|
{
|
|
836
|
-
onError:
|
|
837
|
-
fallback: (s, d) => /* @__PURE__ */
|
|
972
|
+
onError: xt,
|
|
973
|
+
fallback: (s, d) => /* @__PURE__ */ j(
|
|
838
974
|
"div",
|
|
839
975
|
{
|
|
840
976
|
style: {
|
|
@@ -850,9 +986,9 @@ const Je = je((t, e) => {
|
|
|
850
986
|
textAlign: "center"
|
|
851
987
|
},
|
|
852
988
|
children: [
|
|
853
|
-
/* @__PURE__ */
|
|
854
|
-
/* @__PURE__ */
|
|
855
|
-
/* @__PURE__ */
|
|
989
|
+
/* @__PURE__ */ v("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
|
|
990
|
+
/* @__PURE__ */ v("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: s.message }),
|
|
991
|
+
/* @__PURE__ */ v(
|
|
856
992
|
"button",
|
|
857
993
|
{
|
|
858
994
|
onClick: d,
|
|
@@ -873,100 +1009,48 @@ const Je = je((t, e) => {
|
|
|
873
1009
|
}
|
|
874
1010
|
),
|
|
875
1011
|
children: [
|
|
876
|
-
!
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
{
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
artboardBorderRadius: Me,
|
|
896
|
-
fixedMargin: Te,
|
|
897
|
-
maxHeight: De,
|
|
898
|
-
showRotationHandle: Fe,
|
|
899
|
-
enableShortcuts: Ne,
|
|
900
|
-
canvasCutouts: Le,
|
|
901
|
-
pieceGuides: me,
|
|
902
|
-
pieceFocus: We
|
|
903
|
-
}
|
|
904
|
-
)),
|
|
905
|
-
ee
|
|
1012
|
+
!at && /* @__PURE__ */ (() => {
|
|
1013
|
+
const s = /* @__PURE__ */ v(
|
|
1014
|
+
Ut,
|
|
1015
|
+
{
|
|
1016
|
+
style: { width: "100%" },
|
|
1017
|
+
fitPadding: _e,
|
|
1018
|
+
artboardBorderRadius: et,
|
|
1019
|
+
fixedMargin: tt,
|
|
1020
|
+
maxHeight: rt,
|
|
1021
|
+
showRotationHandle: nt,
|
|
1022
|
+
enableShortcuts: it,
|
|
1023
|
+
canvasCutouts: ot,
|
|
1024
|
+
pieceGuides: Fe,
|
|
1025
|
+
pieceFocus: st
|
|
1026
|
+
}
|
|
1027
|
+
);
|
|
1028
|
+
return /* @__PURE__ */ v(Jt, { kit: _, canvas: Te || De ? /* @__PURE__ */ v("div", { className: Te, style: De, children: s }) : s });
|
|
1029
|
+
})(),
|
|
1030
|
+
ne
|
|
906
1031
|
]
|
|
907
1032
|
}
|
|
908
1033
|
) }) });
|
|
909
1034
|
});
|
|
910
|
-
|
|
911
|
-
const
|
|
1035
|
+
Qe.displayName = "SnowconeCanvasInner";
|
|
1036
|
+
const pr = je((t, e) => {
|
|
912
1037
|
var o;
|
|
913
|
-
const { inheritTheme: r, externalProvider: a } = t, n = t.viewPadding ?? ((o = t.layoutConfig) == null ? void 0 : o.viewPadding), c = /* @__PURE__ */
|
|
914
|
-
return a ? /* @__PURE__ */
|
|
1038
|
+
const { inheritTheme: r, externalProvider: a } = t, n = t.viewPadding ?? ((o = t.layoutConfig) == null ? void 0 : o.viewPadding), c = /* @__PURE__ */ v(Qe, { ref: e, ...t });
|
|
1039
|
+
return a ? /* @__PURE__ */ v(Oe, { defaultTheme: "light", passive: r, children: c }) : /* @__PURE__ */ v(Oe, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ v(Vt, { viewPadding: n, children: c }) });
|
|
915
1040
|
});
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
const t = ue(), {
|
|
920
|
-
undo: e,
|
|
921
|
-
redo: r,
|
|
922
|
-
canUndo: a,
|
|
923
|
-
canRedo: n,
|
|
924
|
-
executeElementUpdate: c,
|
|
925
|
-
executeAddElement: o,
|
|
926
|
-
executeRemoveElement: i,
|
|
927
|
-
executeReorderElement: l,
|
|
928
|
-
executeCommandBatch: p,
|
|
929
|
-
executeCreateArtboard: S,
|
|
930
|
-
executeDeleteArtboard: P,
|
|
931
|
-
executeUpdateArtboard: I
|
|
932
|
-
} = t, E = N(() => {
|
|
933
|
-
Ve.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
|
|
934
|
-
}, []), M = N((w) => {
|
|
935
|
-
Ve.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
|
|
936
|
-
}, []);
|
|
937
|
-
return {
|
|
938
|
-
// Undo/Redo
|
|
939
|
-
undo: e,
|
|
940
|
-
redo: r,
|
|
941
|
-
canUndo: a,
|
|
942
|
-
canRedo: n,
|
|
943
|
-
// History management
|
|
944
|
-
clearHistory: E,
|
|
945
|
-
clearArtboardHistory: M,
|
|
946
|
-
// Command execution
|
|
947
|
-
executeElementUpdate: c,
|
|
948
|
-
executeAddElement: o,
|
|
949
|
-
executeRemoveElement: i,
|
|
950
|
-
executeReorderElement: l,
|
|
951
|
-
executeCreateArtboard: S,
|
|
952
|
-
executeDeleteArtboard: P,
|
|
953
|
-
executeUpdateArtboard: I,
|
|
954
|
-
// Batch execution
|
|
955
|
-
executeCommandBatch: p
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
function cr() {
|
|
959
|
-
const { selectedElement: t } = ue();
|
|
1041
|
+
pr.displayName = "SnowconeCanvas";
|
|
1042
|
+
function Dr() {
|
|
1043
|
+
const { selectedElement: t } = ge();
|
|
960
1044
|
return t ?? null;
|
|
961
1045
|
}
|
|
962
|
-
function
|
|
963
|
-
const { isCanvasReady: t } =
|
|
1046
|
+
function Fr() {
|
|
1047
|
+
const { isCanvasReady: t } = ge();
|
|
964
1048
|
return t;
|
|
965
1049
|
}
|
|
966
|
-
const
|
|
967
|
-
},
|
|
968
|
-
function
|
|
969
|
-
const { elementStore: e } =
|
|
1050
|
+
const br = () => {
|
|
1051
|
+
}, vr = [];
|
|
1052
|
+
function Pr(t) {
|
|
1053
|
+
const { elementStore: e } = ke(), { executeElementUpdate: r } = Ge(), a = he(() => e.getAllByName(t).filter((o) => o instanceof Ot), [e, t]), n = W(
|
|
970
1054
|
(c) => {
|
|
971
1055
|
for (const o of a) {
|
|
972
1056
|
const i = o.clone();
|
|
@@ -975,7 +1059,7 @@ function dr(t) {
|
|
|
975
1059
|
},
|
|
976
1060
|
[a, r]
|
|
977
1061
|
);
|
|
978
|
-
return a.length === 0 ? { text: "", setText:
|
|
1062
|
+
return a.length === 0 ? { text: "", setText: br, element: null, elements: vr, isConnected: !1 } : {
|
|
979
1063
|
text: a[0].getText(),
|
|
980
1064
|
setText: n,
|
|
981
1065
|
element: a[0],
|
|
@@ -983,9 +1067,9 @@ function dr(t) {
|
|
|
983
1067
|
isConnected: !0
|
|
984
1068
|
};
|
|
985
1069
|
}
|
|
986
|
-
const
|
|
987
|
-
},
|
|
988
|
-
function
|
|
1070
|
+
const xr = () => {
|
|
1071
|
+
}, yr = [];
|
|
1072
|
+
function wr(t, e, r) {
|
|
989
1073
|
const a = t / e;
|
|
990
1074
|
if (r >= a) {
|
|
991
1075
|
const n = e, c = n * r, o = t / c;
|
|
@@ -1009,63 +1093,63 @@ function Zt(t, e, r) {
|
|
|
1009
1093
|
};
|
|
1010
1094
|
}
|
|
1011
1095
|
}
|
|
1012
|
-
function
|
|
1013
|
-
const r = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: a, setElements: n } =
|
|
1014
|
-
for (const
|
|
1015
|
-
if (!i.current.has(
|
|
1016
|
-
const
|
|
1017
|
-
i.current.set(
|
|
1018
|
-
width:
|
|
1019
|
-
height:
|
|
1096
|
+
function Nr(t, e) {
|
|
1097
|
+
const r = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: a, setElements: n } = ke(), { executeElementUpdate: c } = Ge(), o = he(() => a.getAllByName(t).filter((S) => S instanceof Ve), [a, t]), i = D(/* @__PURE__ */ new Map());
|
|
1098
|
+
for (const w of o)
|
|
1099
|
+
if (!i.current.has(w.id)) {
|
|
1100
|
+
const S = w.transformData;
|
|
1101
|
+
i.current.set(w.id, {
|
|
1102
|
+
width: S.width * S.cropWidth,
|
|
1103
|
+
height: S.height * S.cropHeight
|
|
1020
1104
|
});
|
|
1021
1105
|
}
|
|
1022
|
-
const l =
|
|
1106
|
+
const l = D(o);
|
|
1023
1107
|
l.current = o;
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
const
|
|
1029
|
-
(
|
|
1030
|
-
const
|
|
1031
|
-
for (const
|
|
1032
|
-
const
|
|
1033
|
-
if (!
|
|
1034
|
-
const { width:
|
|
1035
|
-
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
}) : (
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
}),
|
|
1108
|
+
const m = D(c);
|
|
1109
|
+
m.current = c;
|
|
1110
|
+
const A = D(n);
|
|
1111
|
+
A.current = n;
|
|
1112
|
+
const M = W(
|
|
1113
|
+
(w) => {
|
|
1114
|
+
const S = l.current, T = m.current;
|
|
1115
|
+
for (const E of S) {
|
|
1116
|
+
const N = i.current.get(E.id);
|
|
1117
|
+
if (!N) continue;
|
|
1118
|
+
const { width: k, height: h } = N, R = E.clone();
|
|
1119
|
+
R.imageLoaded = !1, R.imageElement = null, R.isCropping = !1, R.imageUrl = w, r === "cover" ? (R.preserveDimensions = !0, R.onLoadCallback = (x) => {
|
|
1120
|
+
const L = x.imageAspectRatio || 1, F = wr(k, h, L);
|
|
1121
|
+
x.transformData.width = F.width, x.transformData.height = F.height, x.transformData.cropX = F.cropX, x.transformData.cropY = F.cropY, x.transformData.cropWidth = F.cropWidth, x.transformData.cropHeight = F.cropHeight, T(E, x);
|
|
1122
|
+
}) : (R.preserveDimensions = !1, R.onLoadCallback = (x) => {
|
|
1123
|
+
const L = x.transformData.width, F = x.transformData.height, O = Math.min(k / L, h / F, 1);
|
|
1124
|
+
O < 1 && (x.transformData.width = L * O, x.transformData.height = F * O), x.transformData.cropX = 0, x.transformData.cropY = 0, x.transformData.cropWidth = 1, x.transformData.cropHeight = 1, T(E, x);
|
|
1125
|
+
}), R.loadImage(w);
|
|
1042
1126
|
}
|
|
1043
1127
|
},
|
|
1044
1128
|
[r]
|
|
1045
1129
|
// Stable deps only — imageElements/executeElementUpdate/setElements accessed via refs
|
|
1046
1130
|
);
|
|
1047
|
-
return o.length === 0 ? { imageUrl: "", setImageUrl:
|
|
1131
|
+
return o.length === 0 ? { imageUrl: "", setImageUrl: xr, element: null, elements: yr, isConnected: !1 } : {
|
|
1048
1132
|
imageUrl: o[0].imageUrl,
|
|
1049
|
-
setImageUrl:
|
|
1133
|
+
setImageUrl: M,
|
|
1050
1134
|
element: o[0],
|
|
1051
1135
|
elements: o,
|
|
1052
1136
|
isConnected: !0
|
|
1053
1137
|
};
|
|
1054
1138
|
}
|
|
1055
|
-
function
|
|
1056
|
-
const { elementStore: e } =
|
|
1139
|
+
function Hr(t) {
|
|
1140
|
+
const { elementStore: e } = ke();
|
|
1057
1141
|
return t ? e.getByName(t) ?? null : null;
|
|
1058
1142
|
}
|
|
1059
|
-
function
|
|
1060
|
-
const { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i } =
|
|
1143
|
+
function Lr() {
|
|
1144
|
+
const { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i } = Kt();
|
|
1061
1145
|
return { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i };
|
|
1062
1146
|
}
|
|
1063
|
-
const
|
|
1064
|
-
function
|
|
1147
|
+
const Er = 1;
|
|
1148
|
+
function Wr(t) {
|
|
1065
1149
|
var a;
|
|
1066
|
-
const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(
|
|
1150
|
+
const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(Ar);
|
|
1067
1151
|
return {
|
|
1068
|
-
schemaVersion:
|
|
1152
|
+
schemaVersion: Er,
|
|
1069
1153
|
artboards: [{
|
|
1070
1154
|
id: "artboard-1",
|
|
1071
1155
|
name: e.name || "Front",
|
|
@@ -1081,15 +1165,15 @@ function hr(t) {
|
|
|
1081
1165
|
}]
|
|
1082
1166
|
};
|
|
1083
1167
|
}
|
|
1084
|
-
function
|
|
1168
|
+
function Ar(t) {
|
|
1085
1169
|
const e = t.type || t.transformType;
|
|
1086
|
-
return e === "image" ?
|
|
1170
|
+
return e === "image" ? Sr(t) : {
|
|
1087
1171
|
...t,
|
|
1088
1172
|
type: e
|
|
1089
1173
|
};
|
|
1090
1174
|
}
|
|
1091
|
-
function
|
|
1092
|
-
var
|
|
1175
|
+
function Sr(t) {
|
|
1176
|
+
var m;
|
|
1093
1177
|
const e = t.transformData || {}, r = t.masks && t.masks.length > 0, a = e.width || 0, n = e.height || 0, c = r ? a : a * (e.cropWidth ?? 1), o = r ? n : n * (e.cropHeight ?? 1), i = {
|
|
1094
1178
|
id: t.id,
|
|
1095
1179
|
type: "image",
|
|
@@ -1101,40 +1185,40 @@ function er(t) {
|
|
|
1101
1185
|
imageUrl: t.imageUrl,
|
|
1102
1186
|
imageAspectRatio: t.imageAspectRatio
|
|
1103
1187
|
};
|
|
1104
|
-
return !r && (e.cropX !== 0 || e.cropY !== 0 || e.cropWidth !== 1 || e.cropHeight !== 1) && (i.cropX = e.cropX, i.cropY = e.cropY, i.cropWidth = e.cropWidth, i.cropHeight = e.cropHeight, i.needsCropPixelConversion = !0), e.flipHorizontal && (i.flipHorizontal = e.flipHorizontal), e.flipVertical && (i.flipVertical = e.flipVertical), e.borderRadius && (i.borderRadius = e.borderRadius), t.opacity !== void 0 && (i.opacity = t.opacity), t.distressEffect && (i.distressEffect = t.distressEffect), ((
|
|
1188
|
+
return !r && (e.cropX !== 0 || e.cropY !== 0 || e.cropWidth !== 1 || e.cropHeight !== 1) && (i.cropX = e.cropX, i.cropY = e.cropY, i.cropWidth = e.cropWidth, i.cropHeight = e.cropHeight, i.needsCropPixelConversion = !0), e.flipHorizontal && (i.flipHorizontal = e.flipHorizontal), e.flipVertical && (i.flipVertical = e.flipVertical), e.borderRadius && (i.borderRadius = e.borderRadius), t.opacity !== void 0 && (i.opacity = t.opacity), t.distressEffect && (i.distressEffect = t.distressEffect), ((m = t.masks) == null ? void 0 : m.length) > 0 && (i.masks = t.masks), t.blendMode && (i.blendMode = t.blendMode), t.knockoutParts && (i.knockoutParts = t.knockoutParts), t.stroke && (i.stroke = t.stroke), i;
|
|
1105
1189
|
}
|
|
1106
|
-
|
|
1190
|
+
zt();
|
|
1107
1191
|
export {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1192
|
+
zr as ALL_CAPABILITIES,
|
|
1193
|
+
Er as CANVAS_STATE_SCHEMA_VERSION,
|
|
1194
|
+
$r as COMPACT_CUSTOMIZER,
|
|
1195
|
+
Or as EMBED_ONLY,
|
|
1196
|
+
er as ErrorBoundary,
|
|
1197
|
+
Yr as MINIMAL_CAPABILITIES,
|
|
1198
|
+
Xr as PRO_STUDIO,
|
|
1199
|
+
pr as SnowconeCanvas,
|
|
1200
|
+
Vr as createKit,
|
|
1201
|
+
pr as default,
|
|
1202
|
+
Zr as deserializeState,
|
|
1203
|
+
Kr as extendKit,
|
|
1204
|
+
Qr as migrateState,
|
|
1205
|
+
Pt as resolveKit,
|
|
1206
|
+
qr as serializeState,
|
|
1207
|
+
Wr as serializeStateForServer,
|
|
1208
|
+
Ht as useArtboards,
|
|
1209
|
+
rr as useAutoExport,
|
|
1210
|
+
Fr as useCanvasReady,
|
|
1211
|
+
Gt as useCommands,
|
|
1212
|
+
sr as useContentReady,
|
|
1213
|
+
ge as useEditor,
|
|
1214
|
+
Hr as useElementByName,
|
|
1215
|
+
Lt as useExport,
|
|
1216
|
+
Nr as useImageBinding,
|
|
1217
|
+
jr as useLayers,
|
|
1218
|
+
Dr as useSelectedElement,
|
|
1219
|
+
Pr as useTextBinding,
|
|
1220
|
+
Lr as useViewport,
|
|
1221
|
+
Nt as validateKit,
|
|
1222
|
+
Jr as validateState
|
|
1139
1223
|
};
|
|
1140
1224
|
//# sourceMappingURL=index.mjs.map
|