@snowcone-app/canvas 0.43.8 → 0.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CanvasRenderer-DIug_mjX.js → CanvasRenderer-B8BADU_r.js} +876 -830
- package/dist/CanvasRenderer-B8BADU_r.js.map +1 -0
- package/dist/{CanvasStateV1-BWd358xJ.js → CanvasStateV1-BlDWgOzV.js} +3 -3
- package/dist/{CanvasStateV1-BWd358xJ.js.map → CanvasStateV1-BlDWgOzV.js.map} +1 -1
- package/dist/ContextualToolbars-rCZo-KCm.js +6808 -0
- package/dist/ContextualToolbars-rCZo-KCm.js.map +1 -0
- package/dist/EditorCanvasImpl-VkjeyOGd.js +144 -0
- package/dist/EditorCanvasImpl-VkjeyOGd.js.map +1 -0
- package/dist/{ExportManager-BDH9jW4Q.js → ExportManager-xRsXgyNo.js} +2 -2
- package/dist/{ExportManager-BDH9jW4Q.js.map → ExportManager-xRsXgyNo.js.map} +1 -1
- package/dist/{FontAnalyzer-CyhywbAM.js → FontAnalyzer-Ds3Wdba7.js} +239 -236
- package/dist/FontAnalyzer-Ds3Wdba7.js.map +1 -0
- package/dist/{ImagePanel-CIGpLY3B.js → ImagePanel-DhOWKvIN.js} +6 -6
- package/dist/{ImagePanel-CIGpLY3B.js.map → ImagePanel-DhOWKvIN.js.map} +1 -1
- package/dist/{SnowconeCanvas-DE0A9UwD.js → SnowconeCanvas-COXpmwkS.js} +481 -466
- package/dist/SnowconeCanvas-COXpmwkS.js.map +1 -0
- package/dist/adjust-CDVzlVBY.js +145 -0
- package/dist/adjust-CDVzlVBY.js.map +1 -0
- package/dist/advanced.mjs +15 -15
- package/dist/api/stable.d.ts +2 -0
- package/dist/components/ImageToolbar.d.ts +3 -0
- package/dist/components/ShapeToolbar.d.ts +2 -0
- package/dist/components/TextToolbar.d.ts +2 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +8 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +24 -0
- package/dist/components/toolbars/index.d.ts +2 -2
- package/dist/core/ArtboardElement.d.ts +2 -0
- package/dist/core/CanvasRenderer.d.ts +3 -1
- package/dist/{custom-icons-sT5sNRcG.js → custom-icons-C4bzABm2.js} +2 -2
- package/dist/{custom-icons-sT5sNRcG.js.map → custom-icons-C4bzABm2.js.map} +1 -1
- package/dist/{design-builder-CwfefZJC.js → design-builder-DCHVrEFV.js} +315 -314
- package/dist/design-builder-DCHVrEFV.js.map +1 -0
- package/dist/{embed-rRSCS25g.js → embed-CamnTsuT.js} +10 -10
- package/dist/{embed-rRSCS25g.js.map → embed-CamnTsuT.js.map} +1 -1
- package/dist/embed.mjs +19 -19
- package/dist/engrave/EngraveSync.d.ts +5 -0
- package/dist/engrave/adjust.d.ts +36 -0
- package/dist/engrave/makeEngraved.d.ts +23 -0
- package/dist/engrave/types.d.ts +33 -0
- package/dist/{guards-Dvw7Qch0.js → guards-DwYEoqcn.js} +2 -2
- package/dist/{guards-Dvw7Qch0.js.map → guards-DwYEoqcn.js.map} +1 -1
- package/dist/index.mjs +57 -54
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +6 -6
- package/dist/rendering/EngraveViewRenderer.d.ts +15 -0
- package/dist/services/AutoExportManager.d.ts +13 -0
- package/dist/{template-fields-DF1ijCl9.js → template-fields-CK7Uvvc8.js} +5 -5
- package/dist/{template-fields-DF1ijCl9.js.map → template-fields-CK7Uvvc8.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +5 -0
- package/dist/{useCommands-wwGeWCn6.js → useCommands-BrkGKdXr.js} +7 -7
- package/dist/{useCommands-wwGeWCn6.js.map → useCommands-BrkGKdXr.js.map} +1 -1
- package/dist/{usePieceGuideBundle-BWQINIJR.js → usePieceGuideBundle-BWdobHQE.js} +2 -2
- package/dist/{usePieceGuideBundle-BWQINIJR.js.map → usePieceGuideBundle-BWdobHQE.js.map} +1 -1
- package/dist/{validation-CXC34UhU.js → validation-jgr2OtXC.js} +2136 -2113
- package/dist/validation-jgr2OtXC.js.map +1 -0
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/CanvasRenderer-DIug_mjX.js.map +0 -1
- package/dist/ContextualToolbars-CspkC1T3.js +0 -6604
- package/dist/ContextualToolbars-CspkC1T3.js.map +0 -1
- package/dist/EditorCanvasImpl-Cn2fdo6a.js +0 -144
- package/dist/EditorCanvasImpl-Cn2fdo6a.js.map +0 -1
- package/dist/FontAnalyzer-CyhywbAM.js.map +0 -1
- package/dist/SnowconeCanvas-DE0A9UwD.js.map +0 -1
- package/dist/design-builder-CwfefZJC.js.map +0 -1
- package/dist/validation-CXC34UhU.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useContext as G, useSyncExternalStore as
|
|
3
|
-
import { H as
|
|
4
|
-
import { g as
|
|
5
|
-
const
|
|
6
|
-
},
|
|
7
|
-
function
|
|
8
|
-
const e = G(
|
|
9
|
-
e ? e.subscribe :
|
|
10
|
-
e ? e.getVersion :
|
|
11
|
-
e ? e.getVersion :
|
|
1
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as G, useSyncExternalStore as Se, useCallback as h, createContext as Q, useRef as gt, useState as E, useEffect as $t, useMemo as q } from "react";
|
|
3
|
+
import { H as Re, t as ot, U as Ie, B as Te, G as qt, R as Ce, D as Fe, J as ve, K as Pe, M as Ne, c as Qt, z as Oe, N as ze, O as Ue, I as Vt, Q as He, e as ke, E as Yt, q as De, S as Le, V as Xt, X as Ve, Y as Gt, Z as _e, _ as $e, $ as Be, a0 as Me, a1 as We, i as Ye } from "./FontAnalyzer-Ds3Wdba7.js";
|
|
4
|
+
import { g as te, a as ee } from "./placement-tSiIVhrL.js";
|
|
5
|
+
const oe = Q(null), Xe = () => () => {
|
|
6
|
+
}, Kt = () => 0;
|
|
7
|
+
function Uo() {
|
|
8
|
+
const e = G(oe), t = Se(
|
|
9
|
+
e ? e.subscribe : Xe,
|
|
10
|
+
e ? e.getVersion : Kt,
|
|
11
|
+
e ? e.getVersion : Kt
|
|
12
12
|
);
|
|
13
13
|
return h(
|
|
14
14
|
(o) => !!(e && o && e.getBoundLayer(o)),
|
|
@@ -17,9 +17,9 @@ function zo() {
|
|
|
17
17
|
[e, t]
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
const wt =
|
|
21
|
-
function
|
|
22
|
-
const i = gt(new
|
|
20
|
+
const wt = Qt("useCommandHistory");
|
|
21
|
+
function Ge(e, t, o, n) {
|
|
22
|
+
const i = gt(new Re(o)), r = G(oe), a = h(
|
|
23
23
|
(l, p) => {
|
|
24
24
|
const w = l == null ? void 0 : l.name;
|
|
25
25
|
if (!r || !w) return;
|
|
@@ -50,12 +50,12 @@ function Xe(e, t, o, n) {
|
|
|
50
50
|
}, [o]), S = h(
|
|
51
51
|
(l, p) => {
|
|
52
52
|
l && l.name !== p.name && a(l, "rename");
|
|
53
|
-
const w = new
|
|
53
|
+
const w = new Ie(
|
|
54
54
|
p.id,
|
|
55
55
|
l || null,
|
|
56
56
|
p,
|
|
57
57
|
(C) => {
|
|
58
|
-
t((Y) => Y.map((
|
|
58
|
+
t((Y) => Y.map((z) => z.id === C.id ? C : z));
|
|
59
59
|
}
|
|
60
60
|
), A = o.getArtboardIdForElement(p.id);
|
|
61
61
|
if (A)
|
|
@@ -67,55 +67,55 @@ function Xe(e, t, o, n) {
|
|
|
67
67
|
d();
|
|
68
68
|
},
|
|
69
69
|
[t, o, d, a]
|
|
70
|
-
),
|
|
70
|
+
), N = h(
|
|
71
71
|
(l, p, w, A) => {
|
|
72
72
|
const C = p || o.getActiveArtboardId();
|
|
73
73
|
if (!C) {
|
|
74
74
|
wt.warn("No active artboard to add element to");
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
const Y = new
|
|
77
|
+
const Y = new Te(
|
|
78
78
|
l,
|
|
79
|
-
(
|
|
80
|
-
const
|
|
81
|
-
t((
|
|
79
|
+
(z) => {
|
|
80
|
+
const $ = z;
|
|
81
|
+
t((U) => {
|
|
82
82
|
if (A) {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const P = [...
|
|
86
|
-
return P.splice(
|
|
83
|
+
const L = U.findIndex((P) => P.id === A);
|
|
84
|
+
if (L !== -1) {
|
|
85
|
+
const P = [...U];
|
|
86
|
+
return P.splice(L, 0, $), P;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
if (w) {
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
const P = [...
|
|
93
|
-
return P.splice(
|
|
90
|
+
const L = U.findIndex((P) => P.id === w);
|
|
91
|
+
if (L !== -1) {
|
|
92
|
+
const P = [...U];
|
|
93
|
+
return P.splice(L + 1, 0, $), P;
|
|
94
94
|
}
|
|
95
|
-
for (let P = 0; P <
|
|
96
|
-
const K =
|
|
97
|
-
if (K instanceof
|
|
95
|
+
for (let P = 0; P < U.length; P++) {
|
|
96
|
+
const K = U[P];
|
|
97
|
+
if (K instanceof qt && K.children) {
|
|
98
98
|
const rt = K.children.findIndex((Z) => Z.id === w);
|
|
99
99
|
if (rt !== -1) {
|
|
100
100
|
const Z = K.clone();
|
|
101
|
-
Z.children.splice(rt + 1, 0,
|
|
102
|
-
const j = [...
|
|
101
|
+
Z.children.splice(rt + 1, 0, $);
|
|
102
|
+
const j = [...U];
|
|
103
103
|
return j[P] = Z, j;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
return [...
|
|
109
|
-
}), o.addElementToArtboard(
|
|
108
|
+
return [...U, $];
|
|
109
|
+
}), o.addElementToArtboard(z.id, C);
|
|
110
110
|
},
|
|
111
|
-
(
|
|
112
|
-
t((
|
|
111
|
+
(z) => {
|
|
112
|
+
t(($) => $.filter((U) => U.id !== z)), o.removeElementFromArtboard(z);
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
i.current.executeOnArtboard(C, Y), d();
|
|
116
116
|
},
|
|
117
117
|
[t, o, d]
|
|
118
|
-
),
|
|
118
|
+
), k = h(
|
|
119
119
|
(l) => {
|
|
120
120
|
a(l, "delete");
|
|
121
121
|
const p = o.getArtboardIdForElement(l.id);
|
|
@@ -123,7 +123,7 @@ function Xe(e, t, o, n) {
|
|
|
123
123
|
wt.warn("Element not found in any artboard");
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
const w = new
|
|
126
|
+
const w = new Ce(
|
|
127
127
|
l,
|
|
128
128
|
(A) => {
|
|
129
129
|
t((C) => [...C, A]), o.addElementToArtboard(A.id, p);
|
|
@@ -137,19 +137,19 @@ function Xe(e, t, o, n) {
|
|
|
137
137
|
[t, o, d, a]
|
|
138
138
|
), y = h(
|
|
139
139
|
(l) => {
|
|
140
|
-
const p = new
|
|
140
|
+
const p = new Fe(l, o);
|
|
141
141
|
i.current.executeGlobal(p), d(), n == null || n();
|
|
142
142
|
},
|
|
143
143
|
[o, d, n]
|
|
144
|
-
),
|
|
144
|
+
), D = h(
|
|
145
145
|
(l) => {
|
|
146
|
-
const p = new
|
|
146
|
+
const p = new ve(l, o);
|
|
147
147
|
i.current.executeGlobal(p), d(), n == null || n();
|
|
148
148
|
},
|
|
149
149
|
[o, d, n]
|
|
150
150
|
), f = h(
|
|
151
151
|
(l, p, w) => {
|
|
152
|
-
const A = new
|
|
152
|
+
const A = new Pe(l, p, w, o);
|
|
153
153
|
i.current.executeGlobal(A), d(), n == null || n();
|
|
154
154
|
},
|
|
155
155
|
[o, d, n]
|
|
@@ -190,22 +190,22 @@ function Xe(e, t, o, n) {
|
|
|
190
190
|
i.current.clearArtboardHistory(l), d();
|
|
191
191
|
},
|
|
192
192
|
[d]
|
|
193
|
-
),
|
|
193
|
+
), _ = gt(null);
|
|
194
194
|
$t(() => {
|
|
195
195
|
const l = o.getActiveArtboardId();
|
|
196
|
-
l !==
|
|
196
|
+
l !== _.current && (_.current = l, d());
|
|
197
197
|
});
|
|
198
198
|
const W = h(
|
|
199
199
|
(l, p, w) => {
|
|
200
|
-
const A = e.map((
|
|
200
|
+
const A = e.map((z) => z.id), C = o.getArtboardIdForElement(l);
|
|
201
201
|
if (!C) {
|
|
202
202
|
wt.warn("Element not found in any artboard");
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
|
-
const Y = new
|
|
206
|
-
t((
|
|
207
|
-
const
|
|
208
|
-
return
|
|
205
|
+
const Y = new Ne(l, p, w, A, (z) => {
|
|
206
|
+
t(($) => {
|
|
207
|
+
const U = new Map($.map((L) => [L.id, L]));
|
|
208
|
+
return z.map((L) => U.get(L)).filter(Boolean);
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
i.current.executeOnArtboard(C, Y), d();
|
|
@@ -215,14 +215,14 @@ function Xe(e, t, o, n) {
|
|
|
215
215
|
return {
|
|
216
216
|
// Element operations
|
|
217
217
|
executeElementUpdate: S,
|
|
218
|
-
executeAddElement:
|
|
219
|
-
executeRemoveElement:
|
|
218
|
+
executeAddElement: N,
|
|
219
|
+
executeRemoveElement: k,
|
|
220
220
|
executeReorderElement: W,
|
|
221
221
|
// Batch operations
|
|
222
222
|
executeCommandBatch: m,
|
|
223
223
|
// Artboard operations
|
|
224
224
|
executeCreateArtboard: y,
|
|
225
|
-
executeDeleteArtboard:
|
|
225
|
+
executeDeleteArtboard: D,
|
|
226
226
|
executeUpdateArtboard: f,
|
|
227
227
|
// Undo/redo (smart - considers last operation and active artboard)
|
|
228
228
|
undo: x,
|
|
@@ -244,7 +244,7 @@ function Xe(e, t, o, n) {
|
|
|
244
244
|
function dt(e) {
|
|
245
245
|
return e && "fontSize" in e && "color" in e && "fontFamily" in e;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function Ke(e, t) {
|
|
248
248
|
const [o, n] = E(32), [i, r] = E("#333333"), [a, s] = E("Arial"), [c, d] = E("center");
|
|
249
249
|
$t(() => {
|
|
250
250
|
if (e && dt(e)) {
|
|
@@ -255,13 +255,13 @@ function Ge(e, t) {
|
|
|
255
255
|
const S = h(
|
|
256
256
|
(f) => {
|
|
257
257
|
if (!e || !dt(e)) return;
|
|
258
|
-
const m = Math.max(
|
|
258
|
+
const m = Math.max(ze, Math.min(Ue, o + f));
|
|
259
259
|
n(m);
|
|
260
260
|
const x = e.clone();
|
|
261
261
|
x.transformType === "circle" && "setEffectiveFontSize" in x ? x.setEffectiveFontSize(m) : x.setFontSize(m), t(x);
|
|
262
262
|
},
|
|
263
263
|
[e, o, t]
|
|
264
|
-
),
|
|
264
|
+
), N = h(
|
|
265
265
|
(f) => {
|
|
266
266
|
if (!e || !dt(e)) return;
|
|
267
267
|
n(f);
|
|
@@ -269,7 +269,7 @@ function Ge(e, t) {
|
|
|
269
269
|
m.transformType === "circle" && "setEffectiveFontSize" in m ? m.setEffectiveFontSize(f) : m.setFontSize(f), t(m);
|
|
270
270
|
},
|
|
271
271
|
[e, t]
|
|
272
|
-
),
|
|
272
|
+
), k = h(
|
|
273
273
|
(f) => {
|
|
274
274
|
if (!e || !dt(e)) return;
|
|
275
275
|
r(f);
|
|
@@ -289,7 +289,7 @@ function Ge(e, t) {
|
|
|
289
289
|
x.fontFamily = f, t(x);
|
|
290
290
|
},
|
|
291
291
|
[e, t]
|
|
292
|
-
),
|
|
292
|
+
), D = h(
|
|
293
293
|
(f) => {
|
|
294
294
|
if (!e || !dt(e)) return;
|
|
295
295
|
d(f);
|
|
@@ -311,21 +311,21 @@ function Ge(e, t) {
|
|
|
311
311
|
setTextAlign: d,
|
|
312
312
|
// Update functions (update element + UI)
|
|
313
313
|
updateFontSize: S,
|
|
314
|
-
setFontSizeValue:
|
|
315
|
-
updateFontColor:
|
|
314
|
+
setFontSizeValue: N,
|
|
315
|
+
updateFontColor: k,
|
|
316
316
|
updateFontFamily: y,
|
|
317
|
-
updateTextAlign:
|
|
317
|
+
updateTextAlign: D
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
|
-
const
|
|
321
|
-
function
|
|
320
|
+
const ne = "data-preserve-selection";
|
|
321
|
+
function Ze(e) {
|
|
322
322
|
if (!(e instanceof Element))
|
|
323
323
|
return !1;
|
|
324
324
|
let t = e;
|
|
325
325
|
const o = [];
|
|
326
326
|
for (; t; ) {
|
|
327
327
|
const n = t.id ? `#${t.id}` : "", i = t.className ? `.${String(t.className).split(" ").slice(0, 2).join(".")}` : "";
|
|
328
|
-
if (o.push(`${t.tagName.toLowerCase()}${n}${i}`), t.hasAttribute(
|
|
328
|
+
if (o.push(`${t.tagName.toLowerCase()}${n}${i}`), t.hasAttribute(ne))
|
|
329
329
|
return !0;
|
|
330
330
|
const r = t.getAttribute("role");
|
|
331
331
|
if (r === "dialog" || r === "alertdialog" || r === "menu" || r === "listbox")
|
|
@@ -337,18 +337,18 @@ function Ke(e) {
|
|
|
337
337
|
}
|
|
338
338
|
return !1;
|
|
339
339
|
}
|
|
340
|
-
const
|
|
341
|
-
[
|
|
340
|
+
const Ho = {
|
|
341
|
+
[ne]: ""
|
|
342
342
|
};
|
|
343
|
-
function
|
|
344
|
-
const t =
|
|
343
|
+
function je(e) {
|
|
344
|
+
const t = re(e);
|
|
345
345
|
return t !== null && t < 0.5;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
348
|
-
const t =
|
|
347
|
+
function ko(e) {
|
|
348
|
+
const t = re(e);
|
|
349
349
|
return t !== null && t >= 0.5;
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function re(e) {
|
|
352
352
|
const t = e.trim();
|
|
353
353
|
if (t.startsWith("#")) {
|
|
354
354
|
const n = t.slice(1);
|
|
@@ -358,29 +358,29 @@ function ne(e) {
|
|
|
358
358
|
else if (n.length === 6)
|
|
359
359
|
i = parseInt(n.slice(0, 2), 16), r = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16);
|
|
360
360
|
else return null;
|
|
361
|
-
return Number.isNaN(i) || Number.isNaN(r) || Number.isNaN(a) ? null :
|
|
361
|
+
return Number.isNaN(i) || Number.isNaN(r) || Number.isNaN(a) ? null : Zt(i, r, a);
|
|
362
362
|
}
|
|
363
363
|
const o = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
364
|
-
return o ?
|
|
364
|
+
return o ? Zt(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function Zt(e, t, o) {
|
|
367
367
|
const n = (i) => {
|
|
368
368
|
const r = i / 255;
|
|
369
369
|
return r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
|
|
370
370
|
};
|
|
371
371
|
return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
|
|
372
372
|
}
|
|
373
|
-
const
|
|
374
|
-
function
|
|
375
|
-
return e &&
|
|
373
|
+
const Je = "#333333", qe = "#f4f4f5";
|
|
374
|
+
function Qe(e) {
|
|
375
|
+
return e && je(e) ? qe : Je;
|
|
376
376
|
}
|
|
377
|
-
const
|
|
377
|
+
const to = {
|
|
378
378
|
timeout: 3e4,
|
|
379
379
|
retries: 1,
|
|
380
380
|
retryDelay: 1e3,
|
|
381
381
|
validateUrl: !0
|
|
382
382
|
};
|
|
383
|
-
function
|
|
383
|
+
function eo(e) {
|
|
384
384
|
try {
|
|
385
385
|
const t = new URL(e);
|
|
386
386
|
return ["http:", "https:", "data:", "blob:"].includes(t.protocol);
|
|
@@ -388,9 +388,9 @@ function to(e) {
|
|
|
388
388
|
return !1;
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
async function
|
|
392
|
-
const o = { ...
|
|
393
|
-
if (o.validateUrl && !
|
|
391
|
+
async function ie(e, t = {}) {
|
|
392
|
+
const o = { ...to, ...t };
|
|
393
|
+
if (o.validateUrl && !eo(e))
|
|
394
394
|
return {
|
|
395
395
|
success: !1,
|
|
396
396
|
error: new Error(`Invalid image URL: ${e}`)
|
|
@@ -398,16 +398,16 @@ async function re(e, t = {}) {
|
|
|
398
398
|
let n;
|
|
399
399
|
for (let i = 0; i <= o.retries; i++)
|
|
400
400
|
try {
|
|
401
|
-
return await
|
|
401
|
+
return await oo(e, o.timeout);
|
|
402
402
|
} catch (r) {
|
|
403
|
-
n = r instanceof Error ? r : new Error(String(r)), i < o.retries && await
|
|
403
|
+
n = r instanceof Error ? r : new Error(String(r)), i < o.retries && await no(o.retryDelay);
|
|
404
404
|
}
|
|
405
405
|
return {
|
|
406
406
|
success: !1,
|
|
407
407
|
error: n || new Error("Failed to load image after retries")
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function oo(e, t) {
|
|
411
411
|
return new Promise((o) => {
|
|
412
412
|
const n = new Image();
|
|
413
413
|
n.crossOrigin = "anonymous";
|
|
@@ -438,9 +438,9 @@ function eo(e, t) {
|
|
|
438
438
|
}, t), n.src = e;
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
|
-
async function
|
|
442
|
-
var
|
|
443
|
-
const i = await
|
|
441
|
+
async function Do(e, t, o = {}, n = {}) {
|
|
442
|
+
var k, y, D, f, m, x, I;
|
|
443
|
+
const i = await ie(e, n);
|
|
444
444
|
if (!i.success || !i.width || !i.height)
|
|
445
445
|
return {
|
|
446
446
|
success: !1,
|
|
@@ -450,7 +450,7 @@ async function ko(e, t, o = {}, n = {}) {
|
|
|
450
450
|
width: t.artboard.width,
|
|
451
451
|
height: t.artboard.height,
|
|
452
452
|
scale: t.scale,
|
|
453
|
-
align:
|
|
453
|
+
align: te(t.alignment),
|
|
454
454
|
offsetX: t.offsetX,
|
|
455
455
|
offsetY: t.offsetY,
|
|
456
456
|
scaleMode: t.scaleMode,
|
|
@@ -458,7 +458,7 @@ async function ko(e, t, o = {}, n = {}) {
|
|
|
458
458
|
marginRight: t.marginRight,
|
|
459
459
|
marginBottom: t.marginBottom,
|
|
460
460
|
marginLeft: t.marginLeft
|
|
461
|
-
}, a =
|
|
461
|
+
}, a = ee(
|
|
462
462
|
{ width: i.width, height: i.height },
|
|
463
463
|
r
|
|
464
464
|
), s = t.artboard.x + a.x, c = t.artboard.y + a.y, d = s + a.width / 2, S = c + a.height / 2;
|
|
@@ -476,9 +476,9 @@ async function ko(e, t, o = {}, n = {}) {
|
|
|
476
476
|
type: "image",
|
|
477
477
|
width: a.width,
|
|
478
478
|
height: a.height,
|
|
479
|
-
cropX: ((
|
|
479
|
+
cropX: ((k = o.transformData) == null ? void 0 : k.cropX) ?? 0,
|
|
480
480
|
cropY: ((y = o.transformData) == null ? void 0 : y.cropY) ?? 0,
|
|
481
|
-
cropWidth: ((
|
|
481
|
+
cropWidth: ((D = o.transformData) == null ? void 0 : D.cropWidth) ?? 1,
|
|
482
482
|
cropHeight: ((f = o.transformData) == null ? void 0 : f.cropHeight) ?? 1,
|
|
483
483
|
flipHorizontal: ((m = o.transformData) == null ? void 0 : m.flipHorizontal) ?? !1,
|
|
484
484
|
flipVertical: ((x = o.transformData) == null ? void 0 : x.flipVertical) ?? !1,
|
|
@@ -493,10 +493,10 @@ async function ko(e, t, o = {}, n = {}) {
|
|
|
493
493
|
}
|
|
494
494
|
};
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function no(e) {
|
|
497
497
|
return new Promise((t) => setTimeout(t, e));
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function Lo(e) {
|
|
500
500
|
if (e != null && e.scaleMode)
|
|
501
501
|
return {
|
|
502
502
|
scaleMode: e.scaleMode,
|
|
@@ -507,21 +507,21 @@ function Do(e) {
|
|
|
507
507
|
align: e.fitAlign
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function se(e) {
|
|
511
511
|
var t;
|
|
512
512
|
return ((t = e == null ? void 0 : e.imageFit) == null ? void 0 : t.scaleMode) === "contain";
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
if (!
|
|
514
|
+
function ro(e, t) {
|
|
515
|
+
if (!se(e)) return null;
|
|
516
516
|
if (!(t.width > 0) || !(t.height > 0))
|
|
517
517
|
throw new Error(
|
|
518
518
|
`E_NEW_IMAGE_SIZE: a new picture of ${t.width}x${t.height} cannot be placed on a ${e.width}x${e.height} area; pass the picture's natural size (loadImageFromURL).`
|
|
519
519
|
);
|
|
520
|
-
const o = e.imageFit, n =
|
|
520
|
+
const o = e.imageFit, n = ee(t, {
|
|
521
521
|
width: e.width,
|
|
522
522
|
height: e.height,
|
|
523
523
|
scaleMode: "contain",
|
|
524
|
-
align:
|
|
524
|
+
align: te(o.align),
|
|
525
525
|
marginTop: o.marginTop,
|
|
526
526
|
marginRight: o.marginRight,
|
|
527
527
|
marginBottom: o.marginBottom,
|
|
@@ -534,23 +534,23 @@ function no(e, t) {
|
|
|
534
534
|
height: n.height
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
|
-
async function
|
|
538
|
-
if (!
|
|
539
|
-
const o = await
|
|
540
|
-
return !o.success || !o.width || !o.height ? null :
|
|
537
|
+
async function io(e, t) {
|
|
538
|
+
if (!se(e)) return null;
|
|
539
|
+
const o = await ie(t, { validateUrl: !1 });
|
|
540
|
+
return !o.success || !o.width || !o.height ? null : ro(e, { width: o.width, height: o.height });
|
|
541
541
|
}
|
|
542
|
-
const
|
|
542
|
+
const ae = Q(null), so = 0.1, ao = 4, jt = 0.25, co = ({
|
|
543
543
|
children: e,
|
|
544
544
|
artboardManager: t,
|
|
545
545
|
canvasRef: o,
|
|
546
546
|
viewPadding: n = 0.9
|
|
547
547
|
}) => {
|
|
548
|
-
const [i, r] = E(1), [a, s] = E({ x: 0, y: 0 }), [c, d] = E(!1), [S,
|
|
549
|
-
|
|
548
|
+
const [i, r] = E(1), [a, s] = E({ x: 0, y: 0 }), [c, d] = E(!1), [S, N] = E(1), k = h(() => {
|
|
549
|
+
N(1), s({ x: 0, y: 0 });
|
|
550
550
|
}, []), y = h(() => {
|
|
551
|
-
r((I) => Math.min(I +
|
|
552
|
-
}, []),
|
|
553
|
-
r((I) => Math.max(I -
|
|
551
|
+
r((I) => Math.min(I + jt, ao));
|
|
552
|
+
}, []), D = h(() => {
|
|
553
|
+
r((I) => Math.max(I - jt, so));
|
|
554
554
|
}, []), f = h(() => {
|
|
555
555
|
const I = t.getActiveArtboard();
|
|
556
556
|
if (!I || !o.current) return;
|
|
@@ -573,31 +573,31 @@ const se = Q(null), io = 0.1, so = 4, Zt = 0.25, ao = ({
|
|
|
573
573
|
panOffset: a,
|
|
574
574
|
isPanning: c,
|
|
575
575
|
zoomIn: y,
|
|
576
|
-
zoomOut:
|
|
576
|
+
zoomOut: D,
|
|
577
577
|
zoomToFit: f,
|
|
578
578
|
resetView: m,
|
|
579
579
|
setZoom: r,
|
|
580
580
|
setPanOffset: s,
|
|
581
581
|
setIsPanning: d,
|
|
582
582
|
userZoom: S,
|
|
583
|
-
setUserZoom:
|
|
584
|
-
resetUserView:
|
|
583
|
+
setUserZoom: N,
|
|
584
|
+
resetUserView: k
|
|
585
585
|
}),
|
|
586
|
-
[i, a, c, y,
|
|
586
|
+
[i, a, c, y, D, f, m, S, k]
|
|
587
587
|
);
|
|
588
|
-
return /* @__PURE__ */
|
|
588
|
+
return /* @__PURE__ */ V(ae.Provider, { value: x, children: e });
|
|
589
589
|
};
|
|
590
|
-
function
|
|
591
|
-
const e = G(
|
|
590
|
+
function lo() {
|
|
591
|
+
const e = G(ae);
|
|
592
592
|
if (!e)
|
|
593
593
|
throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
|
|
594
594
|
return e;
|
|
595
595
|
}
|
|
596
|
-
const
|
|
597
|
-
const [t, o] = E(null), [n, i] = E([]), [r, a] = E(null), [s, c] = E(null), [d, S] = E(!1),
|
|
598
|
-
o(
|
|
599
|
-
}, []),
|
|
600
|
-
a(
|
|
596
|
+
const ce = Q(null), uo = ({ children: e }) => {
|
|
597
|
+
const [t, o] = E(null), [n, i] = E([]), [r, a] = E(null), [s, c] = E(null), [d, S] = E(!1), N = h((D) => {
|
|
598
|
+
o(D);
|
|
599
|
+
}, []), k = h((D) => {
|
|
600
|
+
a(D);
|
|
601
601
|
}, []), y = q(
|
|
602
602
|
() => ({
|
|
603
603
|
selectedId: t,
|
|
@@ -609,8 +609,8 @@ const ae = Q(null), lo = ({ children: e }) => {
|
|
|
609
609
|
setMultiSelection: i,
|
|
610
610
|
setHoveredElementId: c,
|
|
611
611
|
setHideHandles: S,
|
|
612
|
-
handleSelectionChange:
|
|
613
|
-
handleActiveChildChange:
|
|
612
|
+
handleSelectionChange: N,
|
|
613
|
+
handleActiveChildChange: k
|
|
614
614
|
}),
|
|
615
615
|
[
|
|
616
616
|
t,
|
|
@@ -618,19 +618,19 @@ const ae = Q(null), lo = ({ children: e }) => {
|
|
|
618
618
|
r,
|
|
619
619
|
s,
|
|
620
620
|
d,
|
|
621
|
-
|
|
622
|
-
|
|
621
|
+
N,
|
|
622
|
+
k
|
|
623
623
|
]
|
|
624
624
|
);
|
|
625
|
-
return /* @__PURE__ */
|
|
625
|
+
return /* @__PURE__ */ V(ce.Provider, { value: y, children: e });
|
|
626
626
|
};
|
|
627
|
-
function
|
|
628
|
-
const e = G(
|
|
627
|
+
function ho() {
|
|
628
|
+
const e = G(ce);
|
|
629
629
|
if (!e)
|
|
630
630
|
throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
|
|
631
631
|
return e;
|
|
632
632
|
}
|
|
633
|
-
const
|
|
633
|
+
const de = Q(null), mo = ({ children: e, value: t }) => {
|
|
634
634
|
const o = q(
|
|
635
635
|
() => ({
|
|
636
636
|
undo: t.undo,
|
|
@@ -653,16 +653,16 @@ const ce = Q(null), ho = ({ children: e, value: t }) => {
|
|
|
653
653
|
t.canRedoActiveArtboard
|
|
654
654
|
]
|
|
655
655
|
);
|
|
656
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ V(de.Provider, { value: o, children: e });
|
|
657
657
|
};
|
|
658
|
-
function
|
|
659
|
-
const e = G(
|
|
658
|
+
function Vo() {
|
|
659
|
+
const e = G(de);
|
|
660
660
|
if (!e)
|
|
661
661
|
throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
|
|
662
662
|
return e;
|
|
663
663
|
}
|
|
664
|
-
const
|
|
665
|
-
const [t, o] = E(null), [n, i] = E(!1), [r, a] = E(0), [s, c] = E(!1), [d, S] = E(!1),
|
|
664
|
+
const le = Q(null), fo = ({ children: e }) => {
|
|
665
|
+
const [t, o] = E(null), [n, i] = E(!1), [r, a] = E(0), [s, c] = E(!1), [d, S] = E(!1), N = q(
|
|
666
666
|
() => ({
|
|
667
667
|
expandedPanelType: t,
|
|
668
668
|
setExpandedPanelType: o,
|
|
@@ -677,15 +677,15 @@ const de = Q(null), mo = ({ children: e }) => {
|
|
|
677
677
|
}),
|
|
678
678
|
[t, n, r, s, d]
|
|
679
679
|
);
|
|
680
|
-
return /* @__PURE__ */
|
|
680
|
+
return /* @__PURE__ */ V(le.Provider, { value: N, children: e });
|
|
681
681
|
};
|
|
682
|
-
function
|
|
683
|
-
const e = G(
|
|
682
|
+
function po() {
|
|
683
|
+
const e = G(le);
|
|
684
684
|
if (!e)
|
|
685
685
|
throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
|
|
686
686
|
return e;
|
|
687
687
|
}
|
|
688
|
-
const
|
|
688
|
+
const ue = Q(null), go = ({ children: e, value: t }) => {
|
|
689
689
|
const o = q(
|
|
690
690
|
() => ({
|
|
691
691
|
elements: t.elements,
|
|
@@ -740,15 +740,15 @@ const le = Q(null), po = ({ children: e, value: t }) => {
|
|
|
740
740
|
t.canvasEditorRef
|
|
741
741
|
]
|
|
742
742
|
);
|
|
743
|
-
return /* @__PURE__ */
|
|
743
|
+
return /* @__PURE__ */ V(ue.Provider, { value: o, children: e });
|
|
744
744
|
};
|
|
745
|
-
function
|
|
746
|
-
const e = G(
|
|
745
|
+
function _o() {
|
|
746
|
+
const e = G(ue);
|
|
747
747
|
if (!e)
|
|
748
748
|
throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
|
|
749
749
|
return e;
|
|
750
750
|
}
|
|
751
|
-
const
|
|
751
|
+
const he = Q(null), Ao = ({ children: e, value: t }) => {
|
|
752
752
|
const o = q(
|
|
753
753
|
() => ({
|
|
754
754
|
executeElementUpdate: t.executeElementUpdate,
|
|
@@ -789,26 +789,26 @@ const ue = Q(null), go = ({ children: e, value: t }) => {
|
|
|
789
789
|
t.historyManager
|
|
790
790
|
]
|
|
791
791
|
);
|
|
792
|
-
return /* @__PURE__ */
|
|
792
|
+
return /* @__PURE__ */ V(he.Provider, { value: o, children: e });
|
|
793
793
|
};
|
|
794
|
-
function
|
|
795
|
-
const e = G(
|
|
794
|
+
function $o() {
|
|
795
|
+
const e = G(he);
|
|
796
796
|
if (!e)
|
|
797
797
|
throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
|
|
798
798
|
return e;
|
|
799
799
|
}
|
|
800
|
-
const
|
|
801
|
-
const e = G(
|
|
800
|
+
const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
|
|
801
|
+
const e = G(fe);
|
|
802
802
|
if (!e)
|
|
803
803
|
throw new Error("useEditorHandles must be used within EditorProvider");
|
|
804
804
|
return e;
|
|
805
|
-
},
|
|
806
|
-
const i = gt(null), r = q(() => ({ get: () => i.current }), []), a =
|
|
805
|
+
}, xo = ({ children: e, artboardManager: t, canvasRef: o, canvasEditorRef: n }) => {
|
|
806
|
+
const i = gt(null), r = q(() => ({ get: () => i.current }), []), a = lo(), s = ho(), c = po(), [d, S] = E(
|
|
807
807
|
() => t.getAllArtboards()
|
|
808
|
-
), [
|
|
808
|
+
), [N, k] = E(0), [y, D] = E(
|
|
809
809
|
() => new Yt()
|
|
810
810
|
), f = q(() => y.toArray(), [y]), m = h((u) => {
|
|
811
|
-
|
|
811
|
+
D((g) => {
|
|
812
812
|
const b = g.toArray(), F = typeof u == "function" ? u(b) : u;
|
|
813
813
|
return F === b ? g : Yt.fromArray(F);
|
|
814
814
|
});
|
|
@@ -816,10 +816,10 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
816
816
|
(u) => y.get(u),
|
|
817
817
|
[y]
|
|
818
818
|
), [I, T] = E([]), R = s.selectedId ? y.get(s.selectedId) : void 0, M = h(() => {
|
|
819
|
-
S([...t.getAllArtboards()]),
|
|
819
|
+
S([...t.getAllArtboards()]), k((u) => u + 1);
|
|
820
820
|
}, [t]), {
|
|
821
821
|
historyManager: nt,
|
|
822
|
-
executeElementUpdate:
|
|
822
|
+
executeElementUpdate: _,
|
|
823
823
|
executeAddElement: W,
|
|
824
824
|
executeRemoveElement: l,
|
|
825
825
|
executeReorderElement: p,
|
|
@@ -827,15 +827,15 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
827
827
|
executeCreateArtboard: A,
|
|
828
828
|
executeDeleteArtboard: C,
|
|
829
829
|
executeUpdateArtboard: Y,
|
|
830
|
-
undo:
|
|
831
|
-
redo:
|
|
832
|
-
canUndo:
|
|
833
|
-
canRedo:
|
|
830
|
+
undo: z,
|
|
831
|
+
redo: $,
|
|
832
|
+
canUndo: U,
|
|
833
|
+
canRedo: L,
|
|
834
834
|
undoActiveArtboard: P,
|
|
835
835
|
redoActiveArtboard: K,
|
|
836
836
|
canUndoActiveArtboard: rt,
|
|
837
837
|
canRedoActiveArtboard: Z
|
|
838
|
-
} =
|
|
838
|
+
} = Ge(
|
|
839
839
|
f,
|
|
840
840
|
m,
|
|
841
841
|
t,
|
|
@@ -843,12 +843,12 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
843
843
|
), j = h(
|
|
844
844
|
(u) => {
|
|
845
845
|
const g = y.get(u.id);
|
|
846
|
-
|
|
846
|
+
_(g, u);
|
|
847
847
|
},
|
|
848
|
-
[y,
|
|
849
|
-
),
|
|
848
|
+
[y, _]
|
|
849
|
+
), xe = h(
|
|
850
850
|
(u) => {
|
|
851
|
-
if (!R || !(R instanceof
|
|
851
|
+
if (!R || !(R instanceof qt))
|
|
852
852
|
return;
|
|
853
853
|
const g = R.clone(), b = g.children.findIndex(
|
|
854
854
|
(F) => F.id === u.id
|
|
@@ -856,7 +856,7 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
856
856
|
b >= 0 && (g.children[b] = u, j(g));
|
|
857
857
|
},
|
|
858
858
|
[R, j]
|
|
859
|
-
),
|
|
859
|
+
), we = s.activeChildElement || R, be = s.activeChildElement ? xe : j, {
|
|
860
860
|
fontSize: Et,
|
|
861
861
|
fontColor: St,
|
|
862
862
|
fontFamily: Rt,
|
|
@@ -866,7 +866,7 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
866
866
|
updateFontColor: Ft,
|
|
867
867
|
updateFontFamily: vt,
|
|
868
868
|
updateTextAlign: Pt
|
|
869
|
-
} =
|
|
869
|
+
} = Ke(we, be), At = h(
|
|
870
870
|
async (u) => {
|
|
871
871
|
var Mt;
|
|
872
872
|
const g = u.type, b = u, F = t.getActiveArtboardId();
|
|
@@ -876,11 +876,11 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
876
876
|
`addElement({ type: "${g}" }) needs an active artboard and none exists. <Editor.Root> seeds one automatically; with a raw EditorProvider create one first (executeCreateArtboard) or select one (artboardManager.setActiveArtboard).`,
|
|
877
877
|
{ type: g, docSlug: "embed-mode" }
|
|
878
878
|
);
|
|
879
|
-
const v = `element-${Date.now()}`,
|
|
879
|
+
const v = `element-${Date.now()}`, O = t.getActiveArtboard(), ht = O ? O.x + O.width / 2 : window.innerWidth / 2, st = O ? O.y + O.height / 2 : window.innerHeight / 2, J = ((Mt = n.current) == null ? void 0 : Mt.getZoom()) || a.zoom || 1;
|
|
880
880
|
if (g === "image") {
|
|
881
|
-
const ft = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", et = 200 / J,
|
|
881
|
+
const ft = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", et = 200 / J, B = b == null ? void 0 : b.src, pt = B ? await io(O, B) : null;
|
|
882
882
|
if (pt) {
|
|
883
|
-
const
|
|
883
|
+
const H = new Vt({
|
|
884
884
|
id: v,
|
|
885
885
|
name: u.name,
|
|
886
886
|
x: pt.x,
|
|
@@ -889,7 +889,7 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
889
889
|
preserveDimensions: !0,
|
|
890
890
|
transformData: { type: "image", width: pt.width, height: pt.height }
|
|
891
891
|
});
|
|
892
|
-
return
|
|
892
|
+
return H.imageUrl = B, H.onLoadCallback = (xt) => _(H, xt), W(H, F), s.setSelectedId(H.id), H.loadImage(B), { id: H.id, name: u.name ?? "" };
|
|
893
893
|
}
|
|
894
894
|
const X = new Vt({
|
|
895
895
|
id: v,
|
|
@@ -898,7 +898,7 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
898
898
|
y: st,
|
|
899
899
|
// Defer loading `src` until after the element is in the store so a
|
|
900
900
|
// synchronously-cached image can't fire onLoadCallback too early.
|
|
901
|
-
imageUrl:
|
|
901
|
+
imageUrl: B ? "" : ft,
|
|
902
902
|
transformData: {
|
|
903
903
|
type: "image",
|
|
904
904
|
width: et,
|
|
@@ -912,10 +912,10 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
912
912
|
borderRadius: 0
|
|
913
913
|
}
|
|
914
914
|
});
|
|
915
|
-
return
|
|
916
|
-
const xt =
|
|
917
|
-
Dt < 1 && (
|
|
918
|
-
}), W(X, F), s.setSelectedId(X.id),
|
|
915
|
+
return B && (X.imageLoaded = !1, X.imageElement = null, X.isCropping = !1, X.imageUrl = B, X.preserveDimensions = !1, X.onLoadCallback = (H) => {
|
|
916
|
+
const xt = H.transformData.width, Wt = H.transformData.height, Dt = Math.min(et / xt, et / Wt, 1);
|
|
917
|
+
Dt < 1 && (H.transformData.width = xt * Dt, H.transformData.height = Wt * Dt), H.transformData.cropX = 0, H.transformData.cropY = 0, H.transformData.cropWidth = 1, H.transformData.cropHeight = 1, _(X, H);
|
|
918
|
+
}), W(X, F), s.setSelectedId(X.id), B && X.loadImage(B), { id: X.id, name: u.name ?? "" };
|
|
919
919
|
}
|
|
920
920
|
let tt;
|
|
921
921
|
const ct = {
|
|
@@ -924,14 +924,14 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
924
924
|
wave: "wave",
|
|
925
925
|
arch: "arch",
|
|
926
926
|
shape: "shape"
|
|
927
|
-
}[g] || "custom", Ht =
|
|
927
|
+
}[g] || "custom", Ht = De(ct);
|
|
928
928
|
if (!Ht || !Ht.Component)
|
|
929
929
|
throw new Error(`[EditorContext] no transform registered for element type "${g}"`);
|
|
930
|
-
const mt = t.getActiveArtboard(),
|
|
930
|
+
const mt = t.getActiveArtboard(), Ee = mt ? Math.min(mt.width, mt.height) * 0.1 : 80, kt = mt ? mt.width * 0.5 : 300;
|
|
931
931
|
if (g === "shape") {
|
|
932
932
|
const ft = (b == null ? void 0 : b.shapeType) ?? "rectangle";
|
|
933
|
-
let et = 200 / J,
|
|
934
|
-
ft === "ellipse" ? (et = 150 / J,
|
|
933
|
+
let et = 200 / J, B = 200 / J;
|
|
934
|
+
ft === "ellipse" ? (et = 150 / J, B = 250 / J) : ft === "line" && (et = 300 / J, B = 8 / J), tt = new Le({
|
|
935
935
|
id: v,
|
|
936
936
|
name: u.name,
|
|
937
937
|
x: ht,
|
|
@@ -940,8 +940,9 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
940
940
|
type: "shape",
|
|
941
941
|
shapeType: ft,
|
|
942
942
|
width: et,
|
|
943
|
-
height:
|
|
944
|
-
|
|
943
|
+
height: B,
|
|
944
|
+
// an engraved area has one ink: black, which the laser cuts
|
|
945
|
+
fillColor: O != null && O.engrave ? Xt : "#3b82f6",
|
|
945
946
|
fillOpacity: 1
|
|
946
947
|
}
|
|
947
948
|
});
|
|
@@ -952,18 +953,18 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
952
953
|
text: "New Text",
|
|
953
954
|
x: ht,
|
|
954
955
|
y: st,
|
|
955
|
-
fontSize:
|
|
956
|
+
fontSize: Ee,
|
|
956
957
|
fontFamily: "Poppins",
|
|
957
|
-
color:
|
|
958
|
+
color: O != null && O.engrave ? Xt : Qe(O == null ? void 0 : O.backgroundColor),
|
|
958
959
|
transformData: ct === "arch" ? {
|
|
959
960
|
type: "arch",
|
|
960
961
|
width: kt,
|
|
961
|
-
archHeight:
|
|
962
|
+
archHeight: Ve.archHeight
|
|
962
963
|
} : ct === "wave" ? {
|
|
963
964
|
type: "wave",
|
|
964
965
|
width: kt,
|
|
965
|
-
amplitude:
|
|
966
|
-
frequency:
|
|
966
|
+
amplitude: Gt.amplitude,
|
|
967
|
+
frequency: Gt.frequency
|
|
967
968
|
} : ct === "circle" ? {
|
|
968
969
|
type: "circle",
|
|
969
970
|
radius: kt / 2
|
|
@@ -975,13 +976,13 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
975
976
|
s.selectedId || void 0
|
|
976
977
|
), s.setSelectedId(v), { id: v, name: u.name ?? "" };
|
|
977
978
|
},
|
|
978
|
-
[t, W,
|
|
979
|
-
),
|
|
979
|
+
[t, W, _, s, a.zoom, n]
|
|
980
|
+
), Nt = h(
|
|
980
981
|
async (u, g) => {
|
|
981
982
|
await At({ ...g, type: u });
|
|
982
983
|
},
|
|
983
984
|
[At]
|
|
984
|
-
),
|
|
985
|
+
), Ot = h(() => {
|
|
985
986
|
const u = [];
|
|
986
987
|
if (s.multiSelection.length > 0) {
|
|
987
988
|
const g = f.filter(
|
|
@@ -997,15 +998,15 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
997
998
|
if (I.length === 0) return;
|
|
998
999
|
const u = [], g = 30, b = 30;
|
|
999
1000
|
I.forEach((F) => {
|
|
1000
|
-
const v = y.get(F.id),
|
|
1001
|
+
const v = y.get(F.id), O = v ? v.x : F.x, ht = v ? v.y : F.y, st = F.toJSON();
|
|
1001
1002
|
delete st.id;
|
|
1002
1003
|
const J = F.constructor, tt = new J(st);
|
|
1003
|
-
tt.x =
|
|
1004
|
+
tt.x = O + g, tt.y = ht + b;
|
|
1004
1005
|
let at = null;
|
|
1005
1006
|
if (v && (at = t.getArtboardIdForElement(
|
|
1006
1007
|
v.id
|
|
1007
1008
|
)), at || (at = t.getActiveArtboardId()), !at) {
|
|
1008
|
-
|
|
1009
|
+
yo.warn("[handlePasteElements] No artboard found for pasting");
|
|
1009
1010
|
return;
|
|
1010
1011
|
}
|
|
1011
1012
|
const ct = v ? v.id : void 0;
|
|
@@ -1022,7 +1023,7 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1022
1023
|
const u = R;
|
|
1023
1024
|
if (u.isCropping) {
|
|
1024
1025
|
const g = u.clone();
|
|
1025
|
-
g.exitCropMode(),
|
|
1026
|
+
g.exitCropMode(), _(u, g);
|
|
1026
1027
|
}
|
|
1027
1028
|
}
|
|
1028
1029
|
c.setExpandedPanelType(null);
|
|
@@ -1030,12 +1031,12 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1030
1031
|
c.expandedPanelType,
|
|
1031
1032
|
c.setExpandedPanelType,
|
|
1032
1033
|
R,
|
|
1033
|
-
|
|
1034
|
+
_
|
|
1034
1035
|
]);
|
|
1035
1036
|
$t(() => {
|
|
1036
1037
|
const u = (g) => {
|
|
1037
1038
|
const b = g.target;
|
|
1038
|
-
if (b.tagName === "CANVAS" ||
|
|
1039
|
+
if (b.tagName === "CANVAS" || Ze(b))
|
|
1039
1040
|
return;
|
|
1040
1041
|
const v = document.activeElement;
|
|
1041
1042
|
if (v != null && v.hasAttribute("data-preserve-selection")) {
|
|
@@ -1054,7 +1055,7 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1054
1055
|
(u, g, b) => {
|
|
1055
1056
|
t.clear(), u.forEach((F) => {
|
|
1056
1057
|
t.createArtboard(F.toJSON());
|
|
1057
|
-
}), b && t.setActiveArtboard(b), S([...t.getAllArtboards()]),
|
|
1058
|
+
}), b && t.setActiveArtboard(b), S([...t.getAllArtboards()]), k((F) => F + 1), m(g), s.setSelectedId(null);
|
|
1058
1059
|
},
|
|
1059
1060
|
[t, s, m]
|
|
1060
1061
|
), Bt = q(() => ({
|
|
@@ -1108,19 +1109,19 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1108
1109
|
// Element setters
|
|
1109
1110
|
setElements: m,
|
|
1110
1111
|
// Artboard version counter
|
|
1111
|
-
artboardVersion:
|
|
1112
|
+
artboardVersion: N,
|
|
1112
1113
|
// Handlers
|
|
1113
1114
|
refreshArtboards: M,
|
|
1114
1115
|
handleElementUpdate: j,
|
|
1115
1116
|
addElement: At,
|
|
1116
|
-
handleAddElement:
|
|
1117
|
+
handleAddElement: Nt,
|
|
1117
1118
|
handleLoadWorkspace: Ut,
|
|
1118
|
-
handleCopyElements:
|
|
1119
|
+
handleCopyElements: Ot,
|
|
1119
1120
|
handlePasteElements: zt,
|
|
1120
1121
|
hasClipboardContent: I.length > 0,
|
|
1121
1122
|
// Command history (undo/redo actions + execute functions)
|
|
1122
1123
|
historyManager: nt,
|
|
1123
|
-
executeElementUpdate:
|
|
1124
|
+
executeElementUpdate: _,
|
|
1124
1125
|
executeAddElement: W,
|
|
1125
1126
|
executeRemoveElement: l,
|
|
1126
1127
|
executeReorderElement: p,
|
|
@@ -1128,10 +1129,10 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1128
1129
|
executeCreateArtboard: A,
|
|
1129
1130
|
executeDeleteArtboard: C,
|
|
1130
1131
|
executeUpdateArtboard: Y,
|
|
1131
|
-
undo:
|
|
1132
|
-
redo:
|
|
1133
|
-
canUndo:
|
|
1134
|
-
canRedo:
|
|
1132
|
+
undo: z,
|
|
1133
|
+
redo: $,
|
|
1134
|
+
canUndo: U,
|
|
1135
|
+
canRedo: L,
|
|
1135
1136
|
undoActiveArtboard: P,
|
|
1136
1137
|
redoActiveArtboard: K,
|
|
1137
1138
|
canUndoActiveArtboard: rt,
|
|
@@ -1192,18 +1193,18 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1192
1193
|
o,
|
|
1193
1194
|
n,
|
|
1194
1195
|
m,
|
|
1195
|
-
|
|
1196
|
+
N,
|
|
1196
1197
|
M,
|
|
1197
1198
|
j,
|
|
1198
1199
|
At,
|
|
1199
|
-
Ot,
|
|
1200
|
-
Ut,
|
|
1201
1200
|
Nt,
|
|
1201
|
+
Ut,
|
|
1202
|
+
Ot,
|
|
1202
1203
|
zt,
|
|
1203
1204
|
I,
|
|
1204
1205
|
// Command history
|
|
1205
1206
|
nt,
|
|
1206
|
-
|
|
1207
|
+
_,
|
|
1207
1208
|
W,
|
|
1208
1209
|
l,
|
|
1209
1210
|
p,
|
|
@@ -1211,10 +1212,10 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1211
1212
|
A,
|
|
1212
1213
|
C,
|
|
1213
1214
|
Y,
|
|
1214
|
-
N,
|
|
1215
|
-
_,
|
|
1216
1215
|
z,
|
|
1217
|
-
|
|
1216
|
+
$,
|
|
1217
|
+
U,
|
|
1218
|
+
L,
|
|
1218
1219
|
P,
|
|
1219
1220
|
K,
|
|
1220
1221
|
rt,
|
|
@@ -1230,35 +1231,35 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1230
1231
|
vt,
|
|
1231
1232
|
Pt
|
|
1232
1233
|
]);
|
|
1233
|
-
return i.current = Bt, /* @__PURE__ */
|
|
1234
|
-
|
|
1234
|
+
return i.current = Bt, /* @__PURE__ */ V(fe.Provider, { value: r, children: /* @__PURE__ */ V(
|
|
1235
|
+
mo,
|
|
1235
1236
|
{
|
|
1236
1237
|
value: {
|
|
1237
|
-
undo:
|
|
1238
|
-
redo:
|
|
1239
|
-
canUndo:
|
|
1240
|
-
canRedo:
|
|
1238
|
+
undo: z,
|
|
1239
|
+
redo: $,
|
|
1240
|
+
canUndo: U,
|
|
1241
|
+
canRedo: L,
|
|
1241
1242
|
undoActiveArtboard: P,
|
|
1242
1243
|
redoActiveArtboard: K,
|
|
1243
1244
|
canUndoActiveArtboard: rt,
|
|
1244
1245
|
canRedoActiveArtboard: Z
|
|
1245
1246
|
},
|
|
1246
|
-
children: /* @__PURE__ */
|
|
1247
|
-
|
|
1247
|
+
children: /* @__PURE__ */ V(
|
|
1248
|
+
go,
|
|
1248
1249
|
{
|
|
1249
1250
|
value: {
|
|
1250
1251
|
elements: f,
|
|
1251
1252
|
elementStore: y,
|
|
1252
1253
|
artboards: d,
|
|
1253
1254
|
artboardManager: t,
|
|
1254
|
-
artboardVersion:
|
|
1255
|
+
artboardVersion: N,
|
|
1255
1256
|
setElements: m,
|
|
1256
1257
|
refreshArtboards: M,
|
|
1257
1258
|
getElementById: x,
|
|
1258
|
-
handleAddElement:
|
|
1259
|
+
handleAddElement: Nt,
|
|
1259
1260
|
handleElementUpdate: j,
|
|
1260
1261
|
handleLoadWorkspace: Ut,
|
|
1261
|
-
handleCopyElements:
|
|
1262
|
+
handleCopyElements: Ot,
|
|
1262
1263
|
handlePasteElements: zt,
|
|
1263
1264
|
fontSize: Et,
|
|
1264
1265
|
fontColor: St,
|
|
@@ -1272,11 +1273,11 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1272
1273
|
canvasRef: o,
|
|
1273
1274
|
canvasEditorRef: n
|
|
1274
1275
|
},
|
|
1275
|
-
children: /* @__PURE__ */
|
|
1276
|
-
|
|
1276
|
+
children: /* @__PURE__ */ V(
|
|
1277
|
+
Ao,
|
|
1277
1278
|
{
|
|
1278
1279
|
value: {
|
|
1279
|
-
executeElementUpdate:
|
|
1280
|
+
executeElementUpdate: _,
|
|
1280
1281
|
executeAddElement: W,
|
|
1281
1282
|
executeRemoveElement: l,
|
|
1282
1283
|
executeReorderElement: p,
|
|
@@ -1284,47 +1285,47 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1284
1285
|
executeCreateArtboard: A,
|
|
1285
1286
|
executeDeleteArtboard: C,
|
|
1286
1287
|
executeUpdateArtboard: Y,
|
|
1287
|
-
undo:
|
|
1288
|
-
redo:
|
|
1289
|
-
canUndo:
|
|
1290
|
-
canRedo:
|
|
1288
|
+
undo: z,
|
|
1289
|
+
redo: $,
|
|
1290
|
+
canUndo: U,
|
|
1291
|
+
canRedo: L,
|
|
1291
1292
|
undoActiveArtboard: P,
|
|
1292
1293
|
redoActiveArtboard: K,
|
|
1293
1294
|
canUndoActiveArtboard: rt,
|
|
1294
1295
|
canRedoActiveArtboard: Z,
|
|
1295
1296
|
historyManager: nt
|
|
1296
1297
|
},
|
|
1297
|
-
children: /* @__PURE__ */
|
|
1298
|
+
children: /* @__PURE__ */ V(me.Provider, { value: Bt, children: e })
|
|
1298
1299
|
}
|
|
1299
1300
|
)
|
|
1300
1301
|
}
|
|
1301
1302
|
)
|
|
1302
1303
|
}
|
|
1303
1304
|
) });
|
|
1304
|
-
},
|
|
1305
|
+
}, Mo = ({
|
|
1305
1306
|
children: e,
|
|
1306
1307
|
initialArtboardConfig: t = {},
|
|
1307
1308
|
viewPadding: o = 0.9
|
|
1308
1309
|
}) => {
|
|
1309
1310
|
const [n] = E(() => {
|
|
1310
|
-
const a = new
|
|
1311
|
+
const a = new ke(), s = {
|
|
1311
1312
|
name: t.name || "Artboard 1",
|
|
1312
1313
|
x: t.x ?? 0,
|
|
1313
1314
|
y: t.y ?? 0,
|
|
1314
1315
|
width: t.width ?? 1e3,
|
|
1315
1316
|
height: t.height ?? 1e3,
|
|
1316
|
-
backgroundColor: t.backgroundColor ||
|
|
1317
|
+
backgroundColor: t.backgroundColor || He
|
|
1317
1318
|
};
|
|
1318
1319
|
return a.createArtboard(s), a;
|
|
1319
1320
|
}), i = gt(null), r = gt(null);
|
|
1320
|
-
return /* @__PURE__ */
|
|
1321
|
-
|
|
1321
|
+
return /* @__PURE__ */ V(
|
|
1322
|
+
co,
|
|
1322
1323
|
{
|
|
1323
1324
|
artboardManager: n,
|
|
1324
1325
|
canvasRef: i,
|
|
1325
1326
|
viewPadding: o,
|
|
1326
|
-
children: /* @__PURE__ */
|
|
1327
|
-
|
|
1327
|
+
children: /* @__PURE__ */ V(uo, { children: /* @__PURE__ */ V(fo, { children: /* @__PURE__ */ V(
|
|
1328
|
+
xo,
|
|
1328
1329
|
{
|
|
1329
1330
|
artboardManager: n,
|
|
1330
1331
|
canvasRef: i,
|
|
@@ -1334,24 +1335,24 @@ const Ao = qt("EditorContext"), he = Q(null), me = Q(null), $o = () => {
|
|
|
1334
1335
|
) }) })
|
|
1335
1336
|
}
|
|
1336
1337
|
);
|
|
1337
|
-
},
|
|
1338
|
-
const e = G(
|
|
1338
|
+
}, Wo = () => {
|
|
1339
|
+
const e = G(me);
|
|
1339
1340
|
if (!e)
|
|
1340
1341
|
throw new Error("useEditor must be used within EditorProvider");
|
|
1341
1342
|
return e;
|
|
1342
1343
|
}, ut = [];
|
|
1343
|
-
function
|
|
1344
|
-
|
|
1344
|
+
function Yo(e) {
|
|
1345
|
+
$e() && ut.push(e);
|
|
1345
1346
|
}
|
|
1346
|
-
function
|
|
1347
|
+
function Xo() {
|
|
1347
1348
|
return [...ut];
|
|
1348
1349
|
}
|
|
1349
|
-
function
|
|
1350
|
+
function Go() {
|
|
1350
1351
|
ut.length = 0;
|
|
1351
1352
|
}
|
|
1352
|
-
function
|
|
1353
|
+
function Ko() {
|
|
1353
1354
|
if (ut.length === 0) return;
|
|
1354
|
-
const e = ut.map((t) =>
|
|
1355
|
+
const e = ut.map((t) => _e(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
|
|
1355
1356
|
- `);
|
|
1356
1357
|
throw ut.length = 0, new Error(
|
|
1357
1358
|
`expectNoEditorErrors: ${e.includes(`
|
|
@@ -1360,11 +1361,11 @@ function Go() {
|
|
|
1360
1361
|
A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
|
|
1361
1362
|
);
|
|
1362
1363
|
}
|
|
1363
|
-
const
|
|
1364
|
+
const wo = 1;
|
|
1364
1365
|
function it(e) {
|
|
1365
1366
|
return typeof e == "number" && Number.isFinite(e) ? Math.round(e * 100) / 100 : e;
|
|
1366
1367
|
}
|
|
1367
|
-
function
|
|
1368
|
+
function pe(e) {
|
|
1368
1369
|
return {
|
|
1369
1370
|
...e,
|
|
1370
1371
|
...e.x !== void 0 && { x: it(e.x) },
|
|
@@ -1374,15 +1375,15 @@ function fe(e) {
|
|
|
1374
1375
|
...e.rotation !== void 0 && { rotation: it(e.rotation) }
|
|
1375
1376
|
};
|
|
1376
1377
|
}
|
|
1377
|
-
function
|
|
1378
|
+
function bo(e) {
|
|
1378
1379
|
var n, i;
|
|
1379
1380
|
const t = (n = e.artboards) != null && n.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], o = t.map(() => []);
|
|
1380
1381
|
for (const r of e.elements || []) {
|
|
1381
1382
|
const a = r == null ? void 0 : r.artboard, s = typeof a == "string" ? t.findIndex((c) => (c.name || "Front") === a) : -1;
|
|
1382
|
-
(r == null ? void 0 : r.visible) !== !1 && o[s >= 0 ? s : 0].push(
|
|
1383
|
+
(r == null ? void 0 : r.visible) !== !1 && o[s >= 0 ? s : 0].push(ge(r));
|
|
1383
1384
|
}
|
|
1384
1385
|
return {
|
|
1385
|
-
schemaVersion:
|
|
1386
|
+
schemaVersion: wo,
|
|
1386
1387
|
artboards: t.map((r, a) => ({
|
|
1387
1388
|
id: `artboard-${a + 1}`,
|
|
1388
1389
|
name: r.name || "Front",
|
|
@@ -1406,19 +1407,19 @@ function wo(e) {
|
|
|
1406
1407
|
...(i = e.customFonts) != null && i.length ? { customFonts: e.customFonts } : {}
|
|
1407
1408
|
};
|
|
1408
1409
|
}
|
|
1409
|
-
function
|
|
1410
|
+
function ge(e) {
|
|
1410
1411
|
const t = e.type || e.transformType;
|
|
1411
1412
|
if (t === "image")
|
|
1412
|
-
return
|
|
1413
|
+
return Eo(e);
|
|
1413
1414
|
const { artboard: o, ...n } = e;
|
|
1414
|
-
return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((i) => i && i.visible !== !1).map(
|
|
1415
|
+
return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((i) => i && i.visible !== !1).map(ge)), pe({
|
|
1415
1416
|
...n,
|
|
1416
1417
|
type: t
|
|
1417
1418
|
});
|
|
1418
1419
|
}
|
|
1419
|
-
function
|
|
1420
|
+
function Eo(e) {
|
|
1420
1421
|
var d;
|
|
1421
|
-
const t = e.transformData || {}, o =
|
|
1422
|
+
const t = e.transformData || {}, o = Be(e), n = Me(t, o), i = t.width || 0, r = t.height || 0, a = i * n.cropWidth, s = r * n.cropHeight, c = {
|
|
1422
1423
|
id: e.id,
|
|
1423
1424
|
type: "image",
|
|
1424
1425
|
x: e.x || 0,
|
|
@@ -1429,44 +1430,44 @@ function bo(e) {
|
|
|
1429
1430
|
imageUrl: e.imageUrl,
|
|
1430
1431
|
imageAspectRatio: e.imageAspectRatio
|
|
1431
1432
|
};
|
|
1432
|
-
return
|
|
1433
|
+
return We(n) || (c.cropX = n.cropX, c.cropY = n.cropY, c.cropWidth = n.cropWidth, c.cropHeight = n.cropHeight, c.needsCropPixelConversion = !0), t.flipHorizontal && (c.flipHorizontal = t.flipHorizontal), t.flipVertical && (c.flipVertical = t.flipVertical), t.borderRadius && (c.borderRadius = t.borderRadius), e.shadow && (c.shadow = e.shadow), Ye(t.adjustments) || (c.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (c.opacity = e.opacity), e.distressEffect && (c.distressEffect = e.distressEffect), ((d = e.masks) == null ? void 0 : d.length) > 0 && (c.masks = e.masks), e.blendMode && (c.blendMode = e.blendMode), e.knockoutParts && (c.knockoutParts = e.knockoutParts), e.stroke && (c.stroke = e.stroke), pe(c);
|
|
1433
1434
|
}
|
|
1434
|
-
const
|
|
1435
|
-
function
|
|
1436
|
-
return typeof e == "object" && e !== null && e[
|
|
1435
|
+
const Jt = "center", Ae = Symbol.for("snowcone.canvas.layerToken");
|
|
1436
|
+
function Zo(e) {
|
|
1437
|
+
return typeof e == "object" && e !== null && e[Ae] === !0 && typeof e.name == "string" && (e.kind === "text" || e.kind === "image");
|
|
1437
1438
|
}
|
|
1438
|
-
function
|
|
1439
|
-
return Object.freeze({ kind: e, name: t, [
|
|
1439
|
+
function So(e, t) {
|
|
1440
|
+
return Object.freeze({ kind: e, name: t, [Ae]: !0 });
|
|
1440
1441
|
}
|
|
1441
|
-
const
|
|
1442
|
-
function
|
|
1443
|
-
return typeof e == "object" && e !== null && e[
|
|
1442
|
+
const ye = Symbol.for("snowcone.canvas.colorToken");
|
|
1443
|
+
function Ro(e) {
|
|
1444
|
+
return typeof e == "object" && e !== null && e[ye] === !0 && typeof e.name == "string" && typeof e.value == "string";
|
|
1444
1445
|
}
|
|
1445
|
-
function
|
|
1446
|
-
return Object.freeze({ name: e, value: t, [
|
|
1446
|
+
function Io(e, t) {
|
|
1447
|
+
return Object.freeze({ name: e, value: t, [ye]: !0 });
|
|
1447
1448
|
}
|
|
1448
|
-
function
|
|
1449
|
+
function To(e) {
|
|
1449
1450
|
let t = e.trim().toUpperCase();
|
|
1450
1451
|
return /^#[0-9A-F]{3}$/.test(t) && (t = "#" + t[1] + t[1] + t[2] + t[2] + t[3] + t[3]), /^#[0-9A-F]{6}$/.test(t) ? t : null;
|
|
1451
1452
|
}
|
|
1452
1453
|
function bt(e) {
|
|
1453
|
-
return
|
|
1454
|
+
return Ro(e) ? e.value : e;
|
|
1454
1455
|
}
|
|
1455
1456
|
function _t(e) {
|
|
1456
1457
|
const t = e.transformType;
|
|
1457
1458
|
return t === "image" ? "image" : t === "shape" || t === "group" || t === "path" ? null : "text";
|
|
1458
1459
|
}
|
|
1459
|
-
function
|
|
1460
|
+
function Co(e) {
|
|
1460
1461
|
return e === "top-left" || e === "left" || e === "bottom-left" ? "left" : e === "top-right" || e === "right" || e === "bottom-right" ? "right" : "center";
|
|
1461
1462
|
}
|
|
1462
|
-
function
|
|
1463
|
+
function Fo(e) {
|
|
1463
1464
|
return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
|
|
1464
1465
|
}
|
|
1465
1466
|
function Lt(e, t, o, n, i, r) {
|
|
1466
|
-
const a =
|
|
1467
|
+
const a = Co(e), s = Fo(e), c = a === "left" ? t / 2 + r : a === "right" ? n - t / 2 - r : n / 2, d = s === "top" ? o / 2 + r : s === "bottom" ? i - o / 2 - r : i / 2;
|
|
1467
1468
|
return { x: c, y: d };
|
|
1468
1469
|
}
|
|
1469
|
-
function
|
|
1470
|
+
function vo(e, t, o) {
|
|
1470
1471
|
const n = t / o;
|
|
1471
1472
|
if (e >= n) {
|
|
1472
1473
|
const a = o * e, s = t / a;
|
|
@@ -1494,7 +1495,7 @@ class lt {
|
|
|
1494
1495
|
if (this.els = [], this.colorRoles = /* @__PURE__ */ new Map(), this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
|
|
1495
1496
|
throw new Error("design(): artboard width and height must be positive numbers");
|
|
1496
1497
|
for (const [o, n] of Object.entries(t.colors ?? {})) {
|
|
1497
|
-
const i =
|
|
1498
|
+
const i = To(n);
|
|
1498
1499
|
if (i === null)
|
|
1499
1500
|
throw new ot(
|
|
1500
1501
|
"E_COLOR_ROLE_INVALID",
|
|
@@ -1616,7 +1617,7 @@ class lt {
|
|
|
1616
1617
|
const { width: n, height: i } = this.current;
|
|
1617
1618
|
let r;
|
|
1618
1619
|
if (o.aspectRatio && o.aspectRatio > 0) {
|
|
1619
|
-
const s =
|
|
1620
|
+
const s = vo(o.aspectRatio, n, i);
|
|
1620
1621
|
r = {
|
|
1621
1622
|
type: "image",
|
|
1622
1623
|
width: s.width,
|
|
@@ -1657,7 +1658,7 @@ class lt {
|
|
|
1657
1658
|
return this.els.unshift(a), this;
|
|
1658
1659
|
}
|
|
1659
1660
|
image(t, o = {}) {
|
|
1660
|
-
const { width: n, height: i } = this.current, r = o.width ?? Math.round(n / 3), a = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: s, y: c } = Lt(o.anchor ??
|
|
1661
|
+
const { width: n, height: i } = this.current, r = o.width ?? Math.round(n / 3), a = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: s, y: c } = Lt(o.anchor ?? Jt, r, a, n, i, o.padding ?? 0), d = {
|
|
1661
1662
|
id: this.nextId("img"),
|
|
1662
1663
|
transformType: "image",
|
|
1663
1664
|
x: s,
|
|
@@ -1731,7 +1732,7 @@ class lt {
|
|
|
1731
1732
|
`layer "${t}" is a ${o.transformType} element — only text and image layers are bindable. Bindable layers: ${JSON.stringify([...this.layerNamesOfKind("text"), ...this.layerNamesOfKind("image")])}.`,
|
|
1732
1733
|
{ layerName: t, actualType: o.transformType, docSlug: "embed-mode" }
|
|
1733
1734
|
);
|
|
1734
|
-
return
|
|
1735
|
+
return So(n, t);
|
|
1735
1736
|
}
|
|
1736
1737
|
/**
|
|
1737
1738
|
* Mint a {@link ColorToken} for a declared color role. Compile time: `name`
|
|
@@ -1754,7 +1755,7 @@ class lt {
|
|
|
1754
1755
|
`no color role "${t}" in this design. Declared roles: ${JSON.stringify([...this.colorRoles.keys()])}. Declare roles up front — design({ …, colors: { ${t}: '#FF2D8A' } }).`,
|
|
1755
1756
|
{ roleName: t, validNames: [...this.colorRoles.keys()], docSlug: "embed-mode" }
|
|
1756
1757
|
);
|
|
1757
|
-
return
|
|
1758
|
+
return Io(t, o);
|
|
1758
1759
|
}
|
|
1759
1760
|
/** Names of bindable layers of one kind, in stack order. @internal */
|
|
1760
1761
|
layerNamesOfKind(t) {
|
|
@@ -1762,7 +1763,7 @@ class lt {
|
|
|
1762
1763
|
}
|
|
1763
1764
|
/** An anchored vector shape. */
|
|
1764
1765
|
shape(t, o = {}) {
|
|
1765
|
-
const { width: n, height: i } = this.current, r = o.size ?? Math.round(n / 6), a = typeof r == "number" ? r : r.width, s = typeof r == "number" ? r : r.height, { x: c, y: d } = Lt(o.anchor ??
|
|
1766
|
+
const { width: n, height: i } = this.current, r = o.size ?? Math.round(n / 6), a = typeof r == "number" ? r : r.width, s = typeof r == "number" ? r : r.height, { x: c, y: d } = Lt(o.anchor ?? Jt, a, s, n, i, o.padding ?? 0), S = {
|
|
1766
1767
|
type: "shape",
|
|
1767
1768
|
shapeType: t,
|
|
1768
1769
|
width: a,
|
|
@@ -1771,7 +1772,7 @@ class lt {
|
|
|
1771
1772
|
fillOpacity: o.opacity ?? 1,
|
|
1772
1773
|
...o.points !== void 0 ? { points: o.points } : {},
|
|
1773
1774
|
...o.sides !== void 0 ? { sides: o.sides } : {}
|
|
1774
|
-
},
|
|
1775
|
+
}, N = {
|
|
1775
1776
|
id: this.nextId("shape"),
|
|
1776
1777
|
transformType: "shape",
|
|
1777
1778
|
x: c,
|
|
@@ -1780,7 +1781,7 @@ class lt {
|
|
|
1780
1781
|
transformData: S,
|
|
1781
1782
|
...o.name ? { name: o.name } : {}
|
|
1782
1783
|
};
|
|
1783
|
-
return this.els.push(
|
|
1784
|
+
return this.els.push(N), this;
|
|
1784
1785
|
}
|
|
1785
1786
|
/** The composed elements, in render order (background first). Editor shape. */
|
|
1786
1787
|
get elements() {
|
|
@@ -1814,47 +1815,47 @@ class lt {
|
|
|
1814
1815
|
/** Server-render payload for `RenderSession.renderState(placement, …)`.
|
|
1815
1816
|
* Equivalent to `serializeStateForServer(design.toJSON())`. */
|
|
1816
1817
|
toServerRequest() {
|
|
1817
|
-
return
|
|
1818
|
+
return bo(this.toJSON());
|
|
1818
1819
|
}
|
|
1819
1820
|
}
|
|
1820
|
-
function
|
|
1821
|
+
function jo(e) {
|
|
1821
1822
|
return new lt(e);
|
|
1822
1823
|
}
|
|
1823
|
-
function
|
|
1824
|
+
function Jo(e) {
|
|
1824
1825
|
return _t(e);
|
|
1825
1826
|
}
|
|
1826
1827
|
export {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1828
|
+
ko as A,
|
|
1829
|
+
oe as B,
|
|
1830
|
+
wo as C,
|
|
1830
1831
|
lt as D,
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1832
|
+
Mo as E,
|
|
1833
|
+
ne as P,
|
|
1834
|
+
$o as a,
|
|
1835
|
+
Wo as b,
|
|
1836
|
+
ho as c,
|
|
1837
|
+
se as d,
|
|
1838
|
+
lo as e,
|
|
1839
|
+
jo as f,
|
|
1840
|
+
Ko as g,
|
|
1841
|
+
Xo as h,
|
|
1842
|
+
Lo as i,
|
|
1843
|
+
Do as j,
|
|
1844
|
+
Jo as k,
|
|
1845
|
+
ie as l,
|
|
1846
|
+
Zo as m,
|
|
1847
|
+
Ro as n,
|
|
1848
|
+
Ho as o,
|
|
1849
|
+
io as p,
|
|
1850
|
+
Ze as q,
|
|
1851
|
+
Go as r,
|
|
1852
|
+
bo as s,
|
|
1853
|
+
Vo as t,
|
|
1854
|
+
_o as u,
|
|
1855
|
+
po as v,
|
|
1856
|
+
Yo as w,
|
|
1857
|
+
Uo as x,
|
|
1858
|
+
Bo as y,
|
|
1859
|
+
je as z
|
|
1859
1860
|
};
|
|
1860
|
-
//# sourceMappingURL=design-builder-
|
|
1861
|
+
//# sourceMappingURL=design-builder-DCHVrEFV.js.map
|