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