@snowcone-app/canvas 0.40.35 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{EditorCanvasImpl-CI_mLBGt.js → EditorCanvasImpl-CSDnCIpN.js} +3 -3
- package/dist/{EditorCanvasImpl-CI_mLBGt.js.map → EditorCanvasImpl-CSDnCIpN.js.map} +1 -1
- package/dist/{SnowconeCanvas-0w0-l9tm.js → SnowconeCanvas-BZk7PRpk.js} +230 -228
- package/dist/SnowconeCanvas-BZk7PRpk.js.map +1 -0
- package/dist/{embed-VKMR6QO1.js → embed-GXevsHX5.js} +2 -2
- package/dist/{embed-VKMR6QO1.js.map → embed-GXevsHX5.js.map} +1 -1
- package/dist/embed.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/utils/initialImageText.d.ts +10 -0
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/SnowconeCanvas-0w0-l9tm.js.map +0 -1
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import { jsx as E, Fragment as
|
|
3
|
-
import
|
|
4
|
-
import { a as
|
|
5
|
-
import { ImagePanel as
|
|
6
|
-
import { C as
|
|
7
|
-
import { n as
|
|
8
|
-
import { C as
|
|
9
|
-
import { E as
|
|
1
|
+
import { p as _, c as ee, u as Ke, I as Ue, t as ye, v as Xe, x as je, y as Ge } from "./FontAnalyzer-Bj2KrX80.js";
|
|
2
|
+
import { jsx as E, Fragment as Ve, jsxs as q } from "react/jsx-runtime";
|
|
3
|
+
import Ye, { useMemo as Re, useRef as N, useEffect as A, Component as Je, useState as ae, useCallback as j, useImperativeHandle as Qe, forwardRef as Fe } from "react";
|
|
4
|
+
import { a as Ze, b as qe, c as _e, G as et, d as tt, Z as rt, g as at, e as ot, D as nt, r as st, v as it, S as ct, K as lt, f as dt } from "./validation-D4zxugNJ.js";
|
|
5
|
+
import { ImagePanel as ut } from "./ImagePanel-0ZwDDaCy.js";
|
|
6
|
+
import { C as mt, a as ft } from "./ContextualToolbars-wmbHxn5a.js";
|
|
7
|
+
import { n as ht, o as gt, E as pt, C as bt, b as fe, k as vt } from "./useCommands-Cm3mDB-l.js";
|
|
8
|
+
import { C as Et, D as wt } from "./template-fields-tobyHoMe.js";
|
|
9
|
+
import { E as yt, b as oe } from "./design-builder-DUEwCUmA.js";
|
|
10
10
|
import { T as xe } from "./ThemeContext-Rjz25x9X.js";
|
|
11
|
-
import { g as
|
|
12
|
-
import { G as se, E as
|
|
11
|
+
import { g as xt, c as St, a as At } from "./placement-D31o3YYC.js";
|
|
12
|
+
import { G as se, E as Ce, H as It } from "./ExportManager-CHlByUYV.js";
|
|
13
13
|
import { C as de } from "./CanvasRenderer-JcBrIZ6I.js";
|
|
14
|
-
const he =
|
|
14
|
+
const he = ee("KitLayout"), re = "canvas", ue = 320;
|
|
15
15
|
let Se = !1;
|
|
16
|
-
function
|
|
17
|
-
Se || (Se = !0,
|
|
18
|
-
EffectsPanel:
|
|
19
|
-
ExportPanel:
|
|
20
|
-
ImagePanel:
|
|
21
|
-
GlyphPanel:
|
|
22
|
-
ArtboardTabs:
|
|
23
|
-
ContextualToolbars:
|
|
24
|
-
ZoomControls:
|
|
25
|
-
CropPanel:
|
|
16
|
+
function kt() {
|
|
17
|
+
Se || (Se = !0, Ze({
|
|
18
|
+
EffectsPanel: qe,
|
|
19
|
+
ExportPanel: _e,
|
|
20
|
+
ImagePanel: ut,
|
|
21
|
+
GlyphPanel: et,
|
|
22
|
+
ArtboardTabs: tt,
|
|
23
|
+
ContextualToolbars: mt,
|
|
24
|
+
ZoomControls: rt,
|
|
25
|
+
CropPanel: ft
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Rt({ children: a }) {
|
|
29
29
|
const r = N(null);
|
|
30
30
|
if (r.current === null) {
|
|
31
|
-
const e = new
|
|
31
|
+
const e = new ht();
|
|
32
32
|
e.registerCanvas("legacy-kit-canvas"), r.current = {
|
|
33
|
-
store: new
|
|
34
|
-
commerce: new
|
|
33
|
+
store: new wt({ elements: [], artboards: [], activeArtboard: "" }),
|
|
34
|
+
commerce: new Et({ productId: "", mockupIds: [] }),
|
|
35
35
|
registry: e,
|
|
36
|
-
...
|
|
36
|
+
...gt((o) => he.error("[kit section]", o))
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
return /* @__PURE__ */ E(
|
|
39
|
+
return /* @__PURE__ */ E(pt.Provider, { value: r.current, children: a });
|
|
40
40
|
}
|
|
41
41
|
function ie({ ids: a }) {
|
|
42
|
-
return !a || a.length === 0 ? null : /* @__PURE__ */ E(
|
|
42
|
+
return !a || a.length === 0 ? null : /* @__PURE__ */ E(Rt, { children: a.map((r) => {
|
|
43
43
|
var t;
|
|
44
44
|
if (r === re) return null;
|
|
45
|
-
const e =
|
|
45
|
+
const e = at(r);
|
|
46
46
|
if (!e)
|
|
47
|
-
return typeof
|
|
47
|
+
return typeof _ < "u" && ((t = _.env) == null ? void 0 : t.NODE_ENV) === "development" && he.warn(
|
|
48
48
|
`Kit layout references unknown section "${r}" — skipping. Register it with registerSection("${r}", { ... }).`
|
|
49
49
|
), null;
|
|
50
|
-
const
|
|
51
|
-
return /* @__PURE__ */ E(
|
|
50
|
+
const o = e.component;
|
|
51
|
+
return /* @__PURE__ */ E(o, {}, r);
|
|
52
52
|
}) });
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function Ft({ kit: a, canvas: r }) {
|
|
55
55
|
var w, l, y, p;
|
|
56
|
-
|
|
57
|
-
const e = a.layout.slots,
|
|
58
|
-
() => !
|
|
59
|
-
[
|
|
60
|
-
), s = N(null), m =
|
|
56
|
+
kt();
|
|
57
|
+
const e = a.layout.slots, o = !!((w = e.topbar) != null && w.some((x) => x !== re)), t = !!((l = e.left) != null && l.some((x) => x !== re)), n = !!((y = e.right) != null && y.some((x) => x !== re)), c = !!((p = e.bottombar) != null && p.some((x) => x !== re)), d = Re(
|
|
58
|
+
() => !o && !t && !n && !c,
|
|
59
|
+
[o, t, n, c]
|
|
60
|
+
), s = N(null), m = o || t || n || c, g = N(!1);
|
|
61
61
|
return A(() => {
|
|
62
62
|
var i;
|
|
63
|
-
if (typeof
|
|
63
|
+
if (typeof _ > "u" || ((i = _.env) == null ? void 0 : i.NODE_ENV) !== "development" || !m) return;
|
|
64
64
|
const x = s.current;
|
|
65
65
|
if (!x || typeof ResizeObserver > "u") return;
|
|
66
66
|
const T = (f) => {
|
|
@@ -73,8 +73,8 @@ function Rt({ kit: a, canvas: r }) {
|
|
|
73
73
|
for (const b of f) T(b.contentRect.width);
|
|
74
74
|
});
|
|
75
75
|
return I.observe(x), () => I.disconnect();
|
|
76
|
-
}, [m, a.name]), d ? /* @__PURE__ */ E(
|
|
77
|
-
|
|
76
|
+
}, [m, a.name]), d ? /* @__PURE__ */ E(Ve, { children: r }) : /* @__PURE__ */ q("div", { ref: s, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
|
|
77
|
+
o && /* @__PURE__ */ E(
|
|
78
78
|
"div",
|
|
79
79
|
{
|
|
80
80
|
className: "sc-kit-topbar sc-toolbar",
|
|
@@ -82,10 +82,10 @@ function Rt({ kit: a, canvas: r }) {
|
|
|
82
82
|
children: /* @__PURE__ */ E(ie, { ids: e.topbar })
|
|
83
83
|
}
|
|
84
84
|
),
|
|
85
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ q("div", { className: "sc-kit-body", style: { display: "flex", flex: 1, minHeight: 0 }, children: [
|
|
86
86
|
t && /* @__PURE__ */ E("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ E(ie, { ids: e.left }) }),
|
|
87
87
|
/* @__PURE__ */ E("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: r }),
|
|
88
|
-
|
|
88
|
+
n && /* @__PURE__ */ E("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ E(ie, { ids: e.right }) })
|
|
89
89
|
] }),
|
|
90
90
|
c && /* @__PURE__ */ E(
|
|
91
91
|
"div",
|
|
@@ -97,8 +97,8 @@ function Rt({ kit: a, canvas: r }) {
|
|
|
97
97
|
)
|
|
98
98
|
] });
|
|
99
99
|
}
|
|
100
|
-
const
|
|
101
|
-
class
|
|
100
|
+
const Ct = ee("ErrorBoundary");
|
|
101
|
+
class Tt extends Je {
|
|
102
102
|
constructor(r) {
|
|
103
103
|
super(r), this.resetError = () => {
|
|
104
104
|
this.setState({
|
|
@@ -117,18 +117,18 @@ class Ct extends Ye {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
componentDidCatch(r, e) {
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
120
|
+
if (Ct.error("Caught error:", r, e), this.props.onError && this.props.onError(r, e), this.props.onCanvasError) {
|
|
121
|
+
const o = {
|
|
122
122
|
category: "unknown",
|
|
123
123
|
message: r.message,
|
|
124
124
|
originalError: r,
|
|
125
125
|
recoverable: !1
|
|
126
126
|
};
|
|
127
|
-
this.props.onCanvasError(
|
|
127
|
+
this.props.onCanvasError(o);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
render() {
|
|
131
|
-
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__ */
|
|
131
|
+
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__ */ q(
|
|
132
132
|
"div",
|
|
133
133
|
{
|
|
134
134
|
style: {
|
|
@@ -178,26 +178,26 @@ class Ct extends Ye {
|
|
|
178
178
|
) : this.props.children;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Mt({
|
|
182
182
|
inheritTheme: a,
|
|
183
183
|
externalProvider: r,
|
|
184
184
|
services: e,
|
|
185
|
-
viewPadding:
|
|
185
|
+
viewPadding: o,
|
|
186
186
|
children: t
|
|
187
187
|
}) {
|
|
188
|
-
const
|
|
189
|
-
return e ? /* @__PURE__ */ E(
|
|
188
|
+
const n = r ? /* @__PURE__ */ E(xe, { defaultTheme: "light", passive: a, children: t }) : /* @__PURE__ */ E(xe, { defaultTheme: "light", passive: a, children: /* @__PURE__ */ E(yt, { viewPadding: o, children: t }) });
|
|
189
|
+
return e ? /* @__PURE__ */ E(bt, { services: e, children: n }) : n;
|
|
190
190
|
}
|
|
191
|
-
const
|
|
192
|
-
function
|
|
193
|
-
const { config: r, historyManager: e, artboards:
|
|
191
|
+
const Nt = ee("useAutoExport");
|
|
192
|
+
function Lt(a) {
|
|
193
|
+
const { config: r, historyManager: e, artboards: o, elements: t, onExport: n, onExportScheduled: c, isCanvasReady: d = !1 } = a, s = N(null), m = N(!1), g = N({
|
|
194
194
|
totalExports: 0,
|
|
195
195
|
skippedExports: 0,
|
|
196
196
|
lastExportTime: null,
|
|
197
197
|
avgExportInterval: 0
|
|
198
|
-
}), [w, l] = ae(g.current), y = N(
|
|
199
|
-
y.current =
|
|
200
|
-
const i = new
|
|
198
|
+
}), [w, l] = ae(g.current), y = N(n);
|
|
199
|
+
y.current = n, A(() => {
|
|
200
|
+
const i = new ot({
|
|
201
201
|
...nt,
|
|
202
202
|
...r
|
|
203
203
|
});
|
|
@@ -205,7 +205,7 @@ function Nt(a) {
|
|
|
205
205
|
try {
|
|
206
206
|
await y.current(), g.current = i.getStats();
|
|
207
207
|
} catch (f) {
|
|
208
|
-
|
|
208
|
+
Nt.error("[useAutoExport] Export failed:", f);
|
|
209
209
|
}
|
|
210
210
|
}), s.current = i, () => {
|
|
211
211
|
i.destroy();
|
|
@@ -239,7 +239,7 @@ function Nt(a) {
|
|
|
239
239
|
}
|
|
240
240
|
s.current.scheduleExport();
|
|
241
241
|
}
|
|
242
|
-
}, [t,
|
|
242
|
+
}, [t, o, d]), A(() => Ke((f) => {
|
|
243
243
|
if (!s.current || !d) return;
|
|
244
244
|
t.some((v) => v.id === f) && s.current.scheduleExport();
|
|
245
245
|
}), [t, d]);
|
|
@@ -260,64 +260,64 @@ function Nt(a) {
|
|
|
260
260
|
resetChangeDetection: I
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
|
-
const
|
|
264
|
-
function
|
|
263
|
+
const Te = ee("useContentReady");
|
|
264
|
+
function Pt(a) {
|
|
265
265
|
var e;
|
|
266
266
|
const r = /* @__PURE__ */ new Set();
|
|
267
|
-
for (const
|
|
268
|
-
if ("fontFamily" in
|
|
267
|
+
for (const o of a)
|
|
268
|
+
if ("fontFamily" in o && typeof o.fontFamily == "string" && o.fontFamily && r.add(o.fontFamily), "getRichText" in o && typeof o.getRichText == "function")
|
|
269
269
|
try {
|
|
270
|
-
const t =
|
|
270
|
+
const t = o.getRichText();
|
|
271
271
|
if (t != null && t.spans)
|
|
272
|
-
for (const
|
|
273
|
-
(e =
|
|
272
|
+
for (const n of t.spans)
|
|
273
|
+
(e = n.style) != null && e.fontFamily && r.add(n.style.fontFamily);
|
|
274
274
|
} catch {
|
|
275
275
|
}
|
|
276
276
|
return Array.from(r);
|
|
277
277
|
}
|
|
278
|
-
async function
|
|
278
|
+
async function Dt(a) {
|
|
279
279
|
if (a.length === 0 || typeof document > "u" || !document.fonts) return;
|
|
280
280
|
const r = [];
|
|
281
281
|
for (const e of a) {
|
|
282
|
-
const
|
|
283
|
-
r.push(document.fonts.load(
|
|
282
|
+
const o = `16px "${e}"`;
|
|
283
|
+
r.push(document.fonts.load(o));
|
|
284
284
|
}
|
|
285
285
|
await Promise.all(r), document.fonts.ready && await Promise.race([
|
|
286
286
|
document.fonts.ready,
|
|
287
287
|
new Promise((e) => setTimeout(e, 250))
|
|
288
|
-
]),
|
|
288
|
+
]), Te.debug(`Awaited ${r.length} font(s)`);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function $t() {
|
|
291
291
|
return new Promise((a) => requestAnimationFrame(() => a()));
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
const { isCanvasReady: r, elements: e, hasInitialElements:
|
|
293
|
+
function Bt(a) {
|
|
294
|
+
const { isCanvasReady: r, elements: e, hasInitialElements: o, initialElementsLoaded: t } = a, [n, c] = ae(!1), d = N(!1);
|
|
295
295
|
return A(() => {
|
|
296
|
-
if (
|
|
296
|
+
if (n || !r || o && !t || o && e.length === 0 || d.current) return;
|
|
297
297
|
d.current = !0;
|
|
298
298
|
let s = !1;
|
|
299
299
|
return (async () => {
|
|
300
300
|
try {
|
|
301
|
-
const m =
|
|
302
|
-
if (m.length > 0 && (await
|
|
301
|
+
const m = Pt(e);
|
|
302
|
+
if (m.length > 0 && (await Dt(m), s) || (await $t(), s)) return;
|
|
303
303
|
c(!0);
|
|
304
304
|
} catch (m) {
|
|
305
|
-
|
|
305
|
+
Te.error("Error during content readiness check:", m), s || c(!0);
|
|
306
306
|
} finally {
|
|
307
307
|
d.current = !1;
|
|
308
308
|
}
|
|
309
309
|
})(), () => {
|
|
310
310
|
s = !0, d.current = !1;
|
|
311
311
|
};
|
|
312
|
-
}, [r, e,
|
|
312
|
+
}, [r, e, o, t, n]), n;
|
|
313
313
|
}
|
|
314
|
-
const
|
|
314
|
+
const Wt = {
|
|
315
315
|
timeout: 3e4,
|
|
316
316
|
retries: 1,
|
|
317
317
|
retryDelay: 1e3,
|
|
318
318
|
validateUrl: !0
|
|
319
319
|
};
|
|
320
|
-
function
|
|
320
|
+
function Ht(a) {
|
|
321
321
|
try {
|
|
322
322
|
const r = new URL(a);
|
|
323
323
|
return ["http:", "https:", "data:", "blob:"].includes(r.protocol);
|
|
@@ -325,69 +325,69 @@ function Wt(a) {
|
|
|
325
325
|
return !1;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
async function
|
|
329
|
-
const e = { ...
|
|
330
|
-
if (e.validateUrl && !
|
|
328
|
+
async function Me(a, r = {}) {
|
|
329
|
+
const e = { ...Wt, ...r };
|
|
330
|
+
if (e.validateUrl && !Ht(a))
|
|
331
331
|
return {
|
|
332
332
|
success: !1,
|
|
333
333
|
error: new Error(`Invalid image URL: ${a}`)
|
|
334
334
|
};
|
|
335
|
-
let
|
|
335
|
+
let o;
|
|
336
336
|
for (let t = 0; t <= e.retries; t++)
|
|
337
337
|
try {
|
|
338
|
-
return await
|
|
339
|
-
} catch (
|
|
340
|
-
|
|
338
|
+
return await Ot(a, e.timeout);
|
|
339
|
+
} catch (n) {
|
|
340
|
+
o = n instanceof Error ? n : new Error(String(n)), t < e.retries && await zt(e.retryDelay);
|
|
341
341
|
}
|
|
342
342
|
return {
|
|
343
343
|
success: !1,
|
|
344
|
-
error:
|
|
344
|
+
error: o || new Error("Failed to load image after retries")
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function Ot(a, r) {
|
|
348
348
|
return new Promise((e) => {
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
let t = null,
|
|
349
|
+
const o = new Image();
|
|
350
|
+
o.crossOrigin = "anonymous";
|
|
351
|
+
let t = null, n = !1;
|
|
352
352
|
const c = () => {
|
|
353
353
|
t && (clearTimeout(t), t = null);
|
|
354
354
|
}, d = () => {
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
const m =
|
|
355
|
+
if (n) return;
|
|
356
|
+
n = !0, c();
|
|
357
|
+
const m = o.naturalWidth || o.width, g = o.naturalHeight || o.height;
|
|
358
358
|
e({
|
|
359
359
|
success: !0,
|
|
360
|
-
element:
|
|
360
|
+
element: o,
|
|
361
361
|
width: m,
|
|
362
362
|
height: g,
|
|
363
363
|
aspectRatio: g > 0 ? m / g : 1
|
|
364
364
|
});
|
|
365
365
|
}, s = (m) => {
|
|
366
|
-
|
|
366
|
+
n || (n = !0, c(), e({
|
|
367
367
|
success: !1,
|
|
368
368
|
error: new Error(m)
|
|
369
369
|
}));
|
|
370
370
|
};
|
|
371
|
-
|
|
371
|
+
o.onload = d, o.onerror = () => {
|
|
372
372
|
s(`Failed to load image: ${a}`);
|
|
373
373
|
}, t = setTimeout(() => {
|
|
374
374
|
s(`Image load timed out after ${r}ms: ${a}`);
|
|
375
|
-
}, r),
|
|
375
|
+
}, r), o.src = a;
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
|
-
async function Ae(a, r, e = {},
|
|
378
|
+
async function Ae(a, r, e = {}, o = {}) {
|
|
379
379
|
var l, y, p, x, T, I, i;
|
|
380
|
-
const t = await
|
|
380
|
+
const t = await Me(a, o);
|
|
381
381
|
if (!t.success || !t.width || !t.height)
|
|
382
382
|
return {
|
|
383
383
|
success: !1,
|
|
384
384
|
error: t.error || new Error("Failed to get image dimensions")
|
|
385
385
|
};
|
|
386
|
-
const
|
|
386
|
+
const n = {
|
|
387
387
|
width: r.artboard.width,
|
|
388
388
|
height: r.artboard.height,
|
|
389
389
|
scale: r.scale,
|
|
390
|
-
align:
|
|
390
|
+
align: xt(r.alignment),
|
|
391
391
|
offsetX: r.offsetX,
|
|
392
392
|
offsetY: r.offsetY,
|
|
393
393
|
scaleMode: r.scaleMode,
|
|
@@ -395,13 +395,13 @@ async function Ae(a, r, e = {}, n = {}) {
|
|
|
395
395
|
marginRight: r.marginRight,
|
|
396
396
|
marginBottom: r.marginBottom,
|
|
397
397
|
marginLeft: r.marginLeft
|
|
398
|
-
}, c =
|
|
398
|
+
}, c = St(
|
|
399
399
|
{ width: t.width, height: t.height },
|
|
400
|
-
|
|
400
|
+
n
|
|
401
401
|
), d = r.artboard.x + c.x, s = r.artboard.y + c.y, m = d + c.width / 2, g = s + c.height / 2;
|
|
402
402
|
return {
|
|
403
403
|
success: !0,
|
|
404
|
-
element: new
|
|
404
|
+
element: new Ue({
|
|
405
405
|
...e,
|
|
406
406
|
x: m,
|
|
407
407
|
y: g,
|
|
@@ -430,10 +430,10 @@ async function Ae(a, r, e = {}, n = {}) {
|
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function zt(a) {
|
|
434
434
|
return new Promise((r) => setTimeout(r, a));
|
|
435
435
|
}
|
|
436
|
-
const
|
|
436
|
+
const Ie = /^#[0-9a-fA-F]{6}$/, Z = (a, r, e) => typeof a == "number" && Number.isFinite(a) && a >= r && a <= e;
|
|
437
437
|
function Kt(a, r) {
|
|
438
438
|
if (!a || a.length === 0) return [];
|
|
439
439
|
if (!r)
|
|
@@ -442,52 +442,54 @@ function Kt(a, r) {
|
|
|
442
442
|
"initialImageText places words on the first picture, and no initialImage was given. Pass the picture as initialImage (the words go where they belong on it), or pass the whole design as initialElements and leave initialImageText out.",
|
|
443
443
|
{ docSlug: "initial-image-text" }
|
|
444
444
|
);
|
|
445
|
-
return a.forEach((e,
|
|
445
|
+
return a.forEach((e, o) => {
|
|
446
|
+
var n;
|
|
446
447
|
const t = [];
|
|
447
|
-
if ((typeof (e == null ? void 0 : e.text) != "string" || e.text.trim() === "") && t.push("text is a non-empty string"), (typeof (e == null ? void 0 : e.fontFamily) != "string" || e.fontFamily.trim() === "") && t.push("fontFamily is a Google Fonts family"), (typeof (e == null ? void 0 : e.color) != "string" || !
|
|
448
|
-
throw new ye("E_INITIAL_TEXT_INVALID", `initialImageText[${
|
|
448
|
+
if ((typeof (e == null ? void 0 : e.text) != "string" || e.text.trim() === "") && t.push("text is a non-empty string"), (typeof (e == null ? void 0 : e.fontFamily) != "string" || e.fontFamily.trim() === "") && t.push("fontFamily is a Google Fonts family"), (typeof (e == null ? void 0 : e.color) != "string" || !Ie.test(e.color)) && t.push('color is "#rrggbb"'), Z(e == null ? void 0 : e.fontSize, 1e-3, 2) || t.push("fontSize is a share of the picture's height, above 0"), (e == null ? void 0 : e.letterSpacing) !== void 0 && !Z(e.letterSpacing, -1, 1) && t.push("letterSpacing is a share of the picture's height"), Z(e == null ? void 0 : e.left, -1, 2) || t.push("left is a share of the picture's width"), (e == null ? void 0 : e.width) !== void 0 && !Z(e.width, 0, 3) && t.push("width is a share of the picture's width"), (e == null ? void 0 : e.align) !== void 0 && e.align !== "left" && e.align !== "center" && e.align !== "right" && t.push('align is "left" | "center" | "right"'), ((e == null ? void 0 : e.align) === "center" || (e == null ? void 0 : e.align) === "right") && (e == null ? void 0 : e.width) === void 0 && t.push(`align "${e.align}" needs the line's width`), Z(e == null ? void 0 : e.baseline, -1, 2) || t.push("baseline is a share of the picture's height"), (e == null ? void 0 : e.stroke) !== void 0 && (typeof ((n = e.stroke) == null ? void 0 : n.color) != "string" || !Ie.test(e.stroke.color) || !Z(e.stroke.width, 1e-4, 1)) && t.push(`stroke is { color: "#rrggbb", width: a share of the picture's height, above 0 }`), t.length > 0)
|
|
449
|
+
throw new ye("E_INITIAL_TEXT_INVALID", `initialImageText[${o}]: ${t.join("; ")}.`, { docSlug: "initial-image-text", index: o });
|
|
449
450
|
}), a;
|
|
450
451
|
}
|
|
451
452
|
function Ut(a, r, e) {
|
|
452
|
-
const
|
|
453
|
+
const o = a.fontSize * r.height, t = (a.letterSpacing ?? 0) * r.height, n = e(a.text, o, a.fontFamily, t), c = r.left + a.left * r.width, d = (a.width ?? 0) * r.width, s = a.align === "center" ? c + d / 2 : a.align === "right" ? c + d - n.advance / 2 : c + n.advance / 2, m = r.top + a.baseline * r.height;
|
|
453
454
|
return {
|
|
454
455
|
transformType: "custom",
|
|
455
456
|
name: a.name ?? a.text,
|
|
456
457
|
text: a.text,
|
|
457
458
|
fontFamily: a.fontFamily,
|
|
458
|
-
fontSize:
|
|
459
|
+
fontSize: o,
|
|
459
460
|
color: a.color,
|
|
460
461
|
textAlign: "center",
|
|
461
462
|
...t !== 0 ? { letterSpacing: t } : {},
|
|
463
|
+
...a.stroke ? { stroke: { enabled: !0, color: a.stroke.color, width: a.stroke.width * r.height, lineJoin: "round", lineCap: "round" } } : {},
|
|
462
464
|
x: s,
|
|
463
|
-
y: m -
|
|
465
|
+
y: m - n.ascent + (n.ascent + n.descent) / 2,
|
|
464
466
|
rotation: 0,
|
|
465
467
|
// Room past the measured advance: the editor wraps a line at its box, and measures spaced letters a little
|
|
466
468
|
// wider when it wraps than when it measures (a spaced "BRIDE SQUAD" broke onto two lines at its exact width).
|
|
467
|
-
transformData: { type: "custom", controlPoints: [], width: Math.ceil(
|
|
469
|
+
transformData: { type: "custom", controlPoints: [], width: Math.ceil(n.advance + 2 * Math.abs(t) + 0.5 * o) }
|
|
468
470
|
};
|
|
469
471
|
}
|
|
470
|
-
const Y =
|
|
471
|
-
function me(a, r, e,
|
|
472
|
-
if (
|
|
472
|
+
const Y = ee("SnowconeCanvas");
|
|
473
|
+
function me(a, r, e, o) {
|
|
474
|
+
if (o <= 0 || !isFinite(o))
|
|
473
475
|
return e;
|
|
474
|
-
const t = a * e,
|
|
475
|
-
if (Math.max(t,
|
|
476
|
+
const t = a * e, n = r * e;
|
|
477
|
+
if (Math.max(t, n) <= o)
|
|
476
478
|
return e;
|
|
477
|
-
const d = Math.max(a, r), s =
|
|
479
|
+
const d = Math.max(a, r), s = o / d;
|
|
478
480
|
return Math.min(s, e);
|
|
479
481
|
}
|
|
480
482
|
function Xt(a) {
|
|
481
483
|
const r = N(a);
|
|
482
484
|
r.current = a;
|
|
483
485
|
const e = j((t) => {
|
|
484
|
-
var
|
|
485
|
-
Y.error(`[${t.category}] ${t.message}`, t.originalError), (
|
|
486
|
+
var n;
|
|
487
|
+
Y.error(`[${t.category}] ${t.message}`, t.originalError), (n = r.current) == null || n.call(r, t);
|
|
486
488
|
}, []);
|
|
487
489
|
A(() => (de.onRenderError = e, () => {
|
|
488
490
|
de.onRenderError === e && (de.onRenderError = null);
|
|
489
491
|
}), [e]);
|
|
490
|
-
const
|
|
492
|
+
const o = j((t) => {
|
|
491
493
|
e({
|
|
492
494
|
category: "unknown",
|
|
493
495
|
message: t.message,
|
|
@@ -495,15 +497,15 @@ function Xt(a) {
|
|
|
495
497
|
recoverable: !1
|
|
496
498
|
});
|
|
497
499
|
}, [e]);
|
|
498
|
-
return { emitError: e, handleBoundaryError:
|
|
500
|
+
return { emitError: e, handleBoundaryError: o };
|
|
499
501
|
}
|
|
500
502
|
function jt(a) {
|
|
501
503
|
const {
|
|
502
504
|
artboardConfigs: r,
|
|
503
505
|
width: e,
|
|
504
|
-
height:
|
|
506
|
+
height: o,
|
|
505
507
|
pieceGuides: t,
|
|
506
|
-
controlledActiveArtboard:
|
|
508
|
+
controlledActiveArtboard: n,
|
|
507
509
|
onArtboardChange: c,
|
|
508
510
|
resetDocumentOnMount: d
|
|
509
511
|
} = a, {
|
|
@@ -512,11 +514,11 @@ function jt(a) {
|
|
|
512
514
|
setMultiSelection: g,
|
|
513
515
|
artboardManager: w,
|
|
514
516
|
refreshArtboards: l
|
|
515
|
-
} =
|
|
517
|
+
} = oe(), { createArtboard: y, selectArtboard: p, artboards: x } = fe(), T = N(!1), I = N(!1);
|
|
516
518
|
A(() => {
|
|
517
519
|
if (T.current) return;
|
|
518
520
|
T.current = !0;
|
|
519
|
-
const i = r || [{ name: "Design", width: e, height:
|
|
521
|
+
const i = r || [{ name: "Design", width: e, height: o }], f = t ? "transparent" : void 0, b = (u) => u.exportBackground ?? (!!u.backgroundColor && u.backgroundColor !== "transparent");
|
|
520
522
|
if (d) {
|
|
521
523
|
w.clear(), s([]), m(null), g([]);
|
|
522
524
|
for (const h of i)
|
|
@@ -530,7 +532,7 @@ function jt(a) {
|
|
|
530
532
|
role: h.role
|
|
531
533
|
});
|
|
532
534
|
const u = w.getAllArtboards();
|
|
533
|
-
u.length > 0 && !
|
|
535
|
+
u.length > 0 && !n && w.setActiveArtboard(u[0].id), l();
|
|
534
536
|
return;
|
|
535
537
|
}
|
|
536
538
|
const v = w.getAllArtboards();
|
|
@@ -545,41 +547,41 @@ function jt(a) {
|
|
|
545
547
|
clipShape: i[S].clipShape,
|
|
546
548
|
role: i[S].role
|
|
547
549
|
});
|
|
548
|
-
!
|
|
550
|
+
!n && i.length > 1 && w.setActiveArtboard(h.id);
|
|
549
551
|
}
|
|
550
552
|
l();
|
|
551
553
|
}, []), A(() => {
|
|
552
|
-
if (!
|
|
554
|
+
if (!n) {
|
|
553
555
|
I.current = !0;
|
|
554
556
|
return;
|
|
555
557
|
}
|
|
556
|
-
const i = x.find((f) => f.name ===
|
|
558
|
+
const i = x.find((f) => f.name === n);
|
|
557
559
|
if (i) {
|
|
558
560
|
const f = w.getActiveArtboard();
|
|
559
|
-
(f == null ? void 0 : f.name) !==
|
|
561
|
+
(f == null ? void 0 : f.name) !== n && p(i.id), I.current = !0;
|
|
560
562
|
}
|
|
561
|
-
}, [
|
|
563
|
+
}, [n, x]), A(() => {
|
|
562
564
|
if (!c || !I.current) return;
|
|
563
565
|
const i = w.getActiveArtboard();
|
|
564
566
|
i && c(i.name);
|
|
565
567
|
}, [w.getActiveArtboardId()]);
|
|
566
568
|
}
|
|
567
569
|
function Gt(a) {
|
|
568
|
-
const { initialElements: r, emitError: e, customFonts:
|
|
570
|
+
const { initialElements: r, emitError: e, customFonts: o } = a, { setElements: t, artboardManager: n } = oe(), c = N(!1), [d, s] = ae(!1), m = N(!0);
|
|
569
571
|
return A(() => (m.current = !0, () => {
|
|
570
572
|
m.current = !1;
|
|
571
573
|
}), []), A(() => {
|
|
572
574
|
if (!(!r || r.length === 0) && !c.current) {
|
|
573
575
|
c.current = !0, s(!0);
|
|
574
576
|
try {
|
|
575
|
-
|
|
576
|
-
const g =
|
|
577
|
+
o && o.length > 0 && se.register(o);
|
|
578
|
+
const g = Ce.createManyFromJSON(r), w = n.getAllArtboards();
|
|
577
579
|
if (w.length > 0) {
|
|
578
580
|
const y = new Map(w.map((p) => [p.name, p]));
|
|
579
581
|
g.forEach((p, x) => {
|
|
580
582
|
var i;
|
|
581
583
|
const T = (i = r[x]) == null ? void 0 : i.artboard, I = T && y.get(T) || w[0];
|
|
582
|
-
|
|
584
|
+
n.addElementToArtboard(p.id, I.id);
|
|
583
585
|
});
|
|
584
586
|
}
|
|
585
587
|
t(g);
|
|
@@ -591,7 +593,7 @@ function Gt(a) {
|
|
|
591
593
|
if (l.size > 0 && typeof document < "u") {
|
|
592
594
|
const y = document.fonts ?? null, p = Array.from(l).filter(
|
|
593
595
|
(i) => se.has(i)
|
|
594
|
-
), x =
|
|
596
|
+
), x = It(
|
|
595
597
|
se.forFamilies(p),
|
|
596
598
|
{
|
|
597
599
|
onLoadError: (i) => {
|
|
@@ -645,20 +647,20 @@ function Gt(a) {
|
|
|
645
647
|
});
|
|
646
648
|
}
|
|
647
649
|
}
|
|
648
|
-
}, [r,
|
|
650
|
+
}, [r, n, t, e, o]), { initialElementsLoadedState: d };
|
|
649
651
|
}
|
|
650
652
|
function Vt(a) {
|
|
651
653
|
const {
|
|
652
654
|
initialImage: r,
|
|
653
655
|
initialImageText: e,
|
|
654
|
-
initialImageAlignment:
|
|
656
|
+
initialImageAlignment: o,
|
|
655
657
|
initialImageScale: t,
|
|
656
|
-
initialImageScaleMode:
|
|
658
|
+
initialImageScaleMode: n,
|
|
657
659
|
artboardConfigs: c,
|
|
658
660
|
onImageLoad: d,
|
|
659
661
|
onImageError: s,
|
|
660
662
|
emitError: m
|
|
661
|
-
} = a, { elements: g, setElements: w, artboardManager: l } =
|
|
663
|
+
} = a, { elements: g, setElements: w, artboardManager: l } = oe(), [y, p] = ae("idle"), [x, T] = ae(null), I = N(void 0);
|
|
662
664
|
return A(() => {
|
|
663
665
|
if (!r || I.current === r) return;
|
|
664
666
|
if (g.length > 0) {
|
|
@@ -673,15 +675,15 @@ function Vt(a) {
|
|
|
673
675
|
throw new Error("No artboards available");
|
|
674
676
|
const b = [];
|
|
675
677
|
for (const v of f) {
|
|
676
|
-
const u = c == null ? void 0 : c.find((F) => F.name === v.name), h = (u == null ? void 0 : u.scaleMode) ||
|
|
678
|
+
const u = c == null ? void 0 : c.find((F) => F.name === v.name), h = (u == null ? void 0 : u.scaleMode) || n, S = (u == null ? void 0 : u.imageRegions) ?? [];
|
|
677
679
|
if (S.length > 0) {
|
|
678
|
-
const F = await
|
|
680
|
+
const F = await Me(r);
|
|
679
681
|
if (!F.success || !F.width || !F.height) {
|
|
680
682
|
Y.error("Failed to load image for artboard:", v.name, F.error);
|
|
681
683
|
continue;
|
|
682
684
|
}
|
|
683
685
|
for (const P of S) {
|
|
684
|
-
const L =
|
|
686
|
+
const L = At(F.width / F.height, P), H = await Ae(
|
|
685
687
|
r,
|
|
686
688
|
{
|
|
687
689
|
artboard: { width: L.width, height: L.height, x: v.x + L.centerX - L.width / 2, y: v.y + L.centerY - L.height / 2 },
|
|
@@ -704,7 +706,7 @@ function Vt(a) {
|
|
|
704
706
|
x: v.x,
|
|
705
707
|
y: v.y
|
|
706
708
|
},
|
|
707
|
-
alignment: (u == null ? void 0 : u.fitAlign) ||
|
|
709
|
+
alignment: (u == null ? void 0 : u.fitAlign) || o,
|
|
708
710
|
scale: t,
|
|
709
711
|
scaleMode: h,
|
|
710
712
|
marginTop: u == null ? void 0 : u.fitMarginTop,
|
|
@@ -716,7 +718,7 @@ function Vt(a) {
|
|
|
716
718
|
M.success && M.element ? (l.addElementToArtboard(M.element.id, v.id), b.push(M.element)) : Y.error("Failed to load image for artboard:", v.name, M.error);
|
|
717
719
|
}
|
|
718
720
|
if (e.length > 0 && b.length > 0) {
|
|
719
|
-
const v = await
|
|
721
|
+
const v = await Qt(Array.from(new Set(e.map((h) => h.fontFamily))));
|
|
720
722
|
for (const h of v)
|
|
721
723
|
m({
|
|
722
724
|
category: "import",
|
|
@@ -724,16 +726,16 @@ function Vt(a) {
|
|
|
724
726
|
recoverable: !0
|
|
725
727
|
});
|
|
726
728
|
const u = (h, S, M, F) => {
|
|
727
|
-
const P =
|
|
728
|
-
return { advance:
|
|
729
|
+
const P = Xe(S, M);
|
|
730
|
+
return { advance: je(h, S, M, !1, !1, F), ascent: P.ascent, descent: P.descent };
|
|
729
731
|
};
|
|
730
732
|
for (const h of b.slice()) {
|
|
731
733
|
const S = l.getArtboardForElement(h.id), M = h.transformData, F = (M == null ? void 0 : M.width) ?? 0, P = (M == null ? void 0 : M.height) ?? 0;
|
|
732
734
|
if (!S || !(F > 0) || !(P > 0)) continue;
|
|
733
735
|
const L = { left: h.x - F / 2, top: h.y - P / 2, width: F, height: P };
|
|
734
736
|
for (const H of e) {
|
|
735
|
-
const
|
|
736
|
-
l.addElementToArtboard(
|
|
737
|
+
const J = Ce.createFromJSON(Ut(H, L, u));
|
|
738
|
+
l.addElementToArtboard(J.id, S.id), b.push(J);
|
|
737
739
|
}
|
|
738
740
|
}
|
|
739
741
|
}
|
|
@@ -758,10 +760,10 @@ function Vt(a) {
|
|
|
758
760
|
});
|
|
759
761
|
}
|
|
760
762
|
})();
|
|
761
|
-
}, [r, e,
|
|
763
|
+
}, [r, e, o, t, n]), { imageLoadingState: y, imageError: x };
|
|
762
764
|
}
|
|
763
765
|
function Yt(a) {
|
|
764
|
-
const { onChange: r, onSelectionChange: e } = a, { elements:
|
|
766
|
+
const { onChange: r, onSelectionChange: e } = a, { elements: o, selectedId: t, artboardManager: n } = oe(), { artboards: c } = fe(), d = N(e);
|
|
765
767
|
d.current = e, A(() => {
|
|
766
768
|
var m;
|
|
767
769
|
(m = d.current) == null || m.call(d, t);
|
|
@@ -770,15 +772,15 @@ function Yt(a) {
|
|
|
770
772
|
s.current = r, A(() => {
|
|
771
773
|
const m = s.current;
|
|
772
774
|
if (!m) return;
|
|
773
|
-
const g =
|
|
775
|
+
const g = n.getActiveArtboard(), w = {
|
|
774
776
|
// Stamp each element with the NAME of the artboard it lives on (the
|
|
775
777
|
// manager is the membership source of truth). Without this the public
|
|
776
778
|
// state is flat and a multi-placement design cannot round-trip: restore
|
|
777
779
|
// collapses everything onto the first artboard, and per-placement render
|
|
778
780
|
// states can't be derived from onChange. Pinned by
|
|
779
781
|
// SnowconeCanvas.artboard-membership.test.tsx.
|
|
780
|
-
elements:
|
|
781
|
-
const y = l.toJSON(), p =
|
|
782
|
+
elements: o.map((l) => {
|
|
783
|
+
const y = l.toJSON(), p = n.getArtboardForElement(l.id);
|
|
782
784
|
return p ? { ...y, artboard: p.name } : y;
|
|
783
785
|
}),
|
|
784
786
|
artboards: c.map((l) => ({
|
|
@@ -797,14 +799,14 @@ function Yt(a) {
|
|
|
797
799
|
activeArtboard: (g == null ? void 0 : g.name) || "Design"
|
|
798
800
|
};
|
|
799
801
|
m(w);
|
|
800
|
-
}, [
|
|
802
|
+
}, [o, c]);
|
|
801
803
|
}
|
|
802
|
-
function
|
|
804
|
+
function Jt(a, r) {
|
|
803
805
|
const {
|
|
804
806
|
autoExportInterval: e,
|
|
805
|
-
autoExportConfig:
|
|
807
|
+
autoExportConfig: o,
|
|
806
808
|
autoExportFormat: t,
|
|
807
|
-
autoExportAll:
|
|
809
|
+
autoExportAll: n,
|
|
808
810
|
exportScale: c,
|
|
809
811
|
maxExportSize: d,
|
|
810
812
|
exportImageFormat: s,
|
|
@@ -823,7 +825,7 @@ function Qt(a, r) {
|
|
|
823
825
|
historyManager: b,
|
|
824
826
|
isCanvasReady: v,
|
|
825
827
|
setCanvasReady: u
|
|
826
|
-
} =
|
|
828
|
+
} = oe(), { artboards: h } = fe(), { exportArtboard: S, exportAllArtboards: M, exportArtboardAsBlob: F, exportAllArtboardsAsBlobs: P } = vt(), L = N(0), H = N(0);
|
|
827
829
|
Qe(r, () => ({
|
|
828
830
|
exportArtboards: async ($ = {}) => {
|
|
829
831
|
const B = $.format || t, W = $.scale || c, U = $.all ?? !1;
|
|
@@ -868,7 +870,7 @@ function Qt(a, r) {
|
|
|
868
870
|
return { [B.name]: U };
|
|
869
871
|
});
|
|
870
872
|
}, [y, S, F, f, t, c, d]);
|
|
871
|
-
const
|
|
873
|
+
const J = j(async () => {
|
|
872
874
|
if (!g && !l) return;
|
|
873
875
|
const $ = ++H.current, B = Date.now();
|
|
874
876
|
let W = c;
|
|
@@ -887,7 +889,7 @@ function Qt(a, r) {
|
|
|
887
889
|
quality: m
|
|
888
890
|
};
|
|
889
891
|
if (t === "blob")
|
|
890
|
-
if (
|
|
892
|
+
if (n) {
|
|
891
893
|
const R = await P(C);
|
|
892
894
|
k = {};
|
|
893
895
|
for (const [D, G] of Object.entries(R)) {
|
|
@@ -900,7 +902,7 @@ function Qt(a, r) {
|
|
|
900
902
|
const D = await F(R.id, C);
|
|
901
903
|
k = { [R.name]: D };
|
|
902
904
|
}
|
|
903
|
-
else if (
|
|
905
|
+
else if (n) {
|
|
904
906
|
const R = await M(C);
|
|
905
907
|
k = {};
|
|
906
908
|
for (const [D, G] of Object.entries(R)) {
|
|
@@ -932,7 +934,7 @@ function Qt(a, r) {
|
|
|
932
934
|
recoverable: !0
|
|
933
935
|
});
|
|
934
936
|
}
|
|
935
|
-
}, [g, l,
|
|
937
|
+
}, [g, l, n, t, c, d, s, m, S, M, F, P, h, f, i, o, I]);
|
|
936
938
|
A(() => {
|
|
937
939
|
e !== void 0 && e > 0 && Y.warn(
|
|
938
940
|
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
@@ -943,19 +945,19 @@ function Qt(a, r) {
|
|
|
943
945
|
const $ = f.getActiveArtboard();
|
|
944
946
|
l({ status: "scheduled", artboardId: ($ == null ? void 0 : $.id) ?? "unknown" });
|
|
945
947
|
}
|
|
946
|
-
}, [w, l, f]),
|
|
948
|
+
}, [w, l, f]), te = Bt({
|
|
947
949
|
isCanvasReady: v,
|
|
948
950
|
elements: i,
|
|
949
951
|
hasInitialElements: x,
|
|
950
952
|
initialElementsLoaded: T
|
|
951
|
-
}),
|
|
953
|
+
}), ne = N(!1);
|
|
952
954
|
A(() => {
|
|
953
|
-
|
|
954
|
-
}, [
|
|
955
|
-
config:
|
|
956
|
-
enabled:
|
|
957
|
-
debounceMs:
|
|
958
|
-
maxWaitMs:
|
|
955
|
+
te && !ne.current && (ne.current = !0, p == null || p());
|
|
956
|
+
}, [te, p]), Lt({
|
|
957
|
+
config: o ? {
|
|
958
|
+
enabled: o.enabled ?? !0,
|
|
959
|
+
debounceMs: o.debounceMs ?? 100,
|
|
960
|
+
maxWaitMs: o.maxWaitMs ?? 1e3
|
|
959
961
|
} : {
|
|
960
962
|
enabled: !1
|
|
961
963
|
// Only use smart export if autoExportConfig is provided
|
|
@@ -963,9 +965,9 @@ function Qt(a, r) {
|
|
|
963
965
|
historyManager: b,
|
|
964
966
|
artboards: h,
|
|
965
967
|
elements: i,
|
|
966
|
-
onExport:
|
|
968
|
+
onExport: J,
|
|
967
969
|
onExportScheduled: ce,
|
|
968
|
-
isCanvasReady:
|
|
970
|
+
isCanvasReady: te
|
|
969
971
|
// Gate exports until content is fully ready (fonts loaded, elements deserialized)
|
|
970
972
|
}), A(() => {
|
|
971
973
|
if (h.length > 0 && !v) {
|
|
@@ -978,16 +980,16 @@ function Qt(a, r) {
|
|
|
978
980
|
u(!1);
|
|
979
981
|
}, [u]);
|
|
980
982
|
}
|
|
981
|
-
async function
|
|
983
|
+
async function Qt(a) {
|
|
982
984
|
if (typeof document > "u" || a.length === 0) return [];
|
|
983
985
|
const r = document.fonts ?? null;
|
|
984
986
|
return await Promise.all(
|
|
985
987
|
a.map((e) => {
|
|
986
|
-
const
|
|
987
|
-
let t = document.getElementById(
|
|
988
|
-
return t || (t = document.createElement("link"), t.id =
|
|
989
|
-
if (t.sheet) return
|
|
990
|
-
t.addEventListener("load", () =>
|
|
988
|
+
const o = `font-${e.replace(/\s+/g, "-").toLowerCase()}`;
|
|
989
|
+
let t = document.getElementById(o);
|
|
990
|
+
return t || (t = document.createElement("link"), t.id = o, t.rel = "stylesheet", t.href = `https://fonts.googleapis.com/css2?family=${e.replace(/\s+/g, "+")}:wght@400;700&display=swap`, document.head.appendChild(t)), new Promise((n) => {
|
|
991
|
+
if (t.sheet) return n();
|
|
992
|
+
t.addEventListener("load", () => n(), { once: !0 }), t.addEventListener("error", () => n(), { once: !0 }), setTimeout(n, 4e3);
|
|
991
993
|
});
|
|
992
994
|
})
|
|
993
995
|
), r ? (await Promise.all(a.map((e) => r.load(`400 16px "${e}"`).catch(() => {
|
|
@@ -999,13 +1001,13 @@ async function Jt(a) {
|
|
|
999
1001
|
}
|
|
1000
1002
|
})) : [];
|
|
1001
1003
|
}
|
|
1002
|
-
const
|
|
1004
|
+
const ke = ee("SnowconeCanvas"), Ne = Fe((a, r) => {
|
|
1003
1005
|
var we;
|
|
1004
1006
|
const {
|
|
1005
1007
|
exportConfig: e,
|
|
1006
|
-
imageConfig:
|
|
1008
|
+
imageConfig: o,
|
|
1007
1009
|
layoutConfig: t,
|
|
1008
|
-
kit:
|
|
1010
|
+
kit: n,
|
|
1009
1011
|
artboards: c,
|
|
1010
1012
|
activeArtboard: d,
|
|
1011
1013
|
onArtboardChange: s,
|
|
@@ -1028,18 +1030,18 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1028
1030
|
enableShortcuts: M,
|
|
1029
1031
|
overlay: F,
|
|
1030
1032
|
resetDocumentOnMount: P
|
|
1031
|
-
} = a, L = y, H = a.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig),
|
|
1033
|
+
} = a, L = y, H = a.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig), J = a.autoExportFormat ?? (e == null ? void 0 : e.format) ?? "dataUrl", ce = a.autoExportAll ?? (e == null ? void 0 : e.exportAll) ?? !1, te = a.exportScale ?? (e == null ? void 0 : e.scale) ?? 2, ne = a.maxExportSize ?? (e == null ? void 0 : e.maxSize) ?? 4e3, $ = a.exportImageFormat ?? (e == null ? void 0 : e.imageFormat) ?? "png", B = a.exportImageQuality ?? (e == null ? void 0 : e.imageQuality) ?? 0.92, W = a.initialImage ?? (o == null ? void 0 : o.src), U = a.initialImageAlignment ?? (o == null ? void 0 : o.alignment) ?? "center", O = a.initialImageScale ?? (o == null ? void 0 : o.scale) ?? 1, k = a.initialImageScaleMode ?? (o == null ? void 0 : o.scaleMode) ?? "cover", C = Ye.useMemo(() => Kt(a.initialImageText, W), [a.initialImageText, W]), R = a.width ?? (t == null ? void 0 : t.width) ?? 1200, D = a.height ?? (t == null ? void 0 : t.height) ?? 1200, G = a.viewPadding ?? (t == null ? void 0 : t.viewPadding) ?? 0.9, z = a.artboardBorderRadius ?? (t == null ? void 0 : t.artboardBorderRadius) ?? 0, V = a.fixedMargin ?? (t == null ? void 0 : t.fixedMargin), Le = a.maxHeight ?? (t == null ? void 0 : t.maxHeight), Pe = a.showRotationHandle ?? (t == null ? void 0 : t.showRotationHandle) ?? !0, De = a.hideCanvas ?? (t == null ? void 0 : t.hideCanvas) ?? !1, ge = a.canvasWrapperClassName ?? (t == null ? void 0 : t.canvasWrapperClassName), pe = a.canvasWrapperStyle ?? (t == null ? void 0 : t.canvasWrapperStyle), $e = a.canvasCutouts ?? (t == null ? void 0 : t.canvasCutouts), be = a.pieceGuides, Be = a.pieceFocus, We = M ?? !0, Q = Re(() => st(n ?? "pro-studio"), [n]);
|
|
1032
1034
|
A(() => {
|
|
1033
1035
|
var X;
|
|
1034
|
-
if (typeof
|
|
1035
|
-
const K =
|
|
1036
|
-
K.valid ||
|
|
1036
|
+
if (typeof _ < "u" && ((X = _.env) == null ? void 0 : X.NODE_ENV) === "development" && Q) {
|
|
1037
|
+
const K = it(Q);
|
|
1038
|
+
K.valid || ke.warn("Kit validation warnings:", K.errors), K.warnings.length > 0 && ke.warn("Kit validation warnings:", K.warnings);
|
|
1037
1039
|
}
|
|
1038
|
-
}, [
|
|
1040
|
+
}, [Q]), A(() => {
|
|
1039
1041
|
if (b)
|
|
1040
|
-
return
|
|
1042
|
+
return Ge(b);
|
|
1041
1043
|
}, [b]);
|
|
1042
|
-
const { emitError: le, handleBoundaryError:
|
|
1044
|
+
const { emitError: le, handleBoundaryError: He } = Xt(v);
|
|
1043
1045
|
jt({
|
|
1044
1046
|
artboardConfigs: c,
|
|
1045
1047
|
width: R,
|
|
@@ -1049,7 +1051,7 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1049
1051
|
onArtboardChange: s,
|
|
1050
1052
|
resetDocumentOnMount: P
|
|
1051
1053
|
});
|
|
1052
|
-
const { initialElementsLoadedState:
|
|
1054
|
+
const { initialElementsLoadedState: Oe } = Gt({
|
|
1053
1055
|
initialElements: m,
|
|
1054
1056
|
customFonts: g,
|
|
1055
1057
|
emitError: le
|
|
@@ -1064,14 +1066,14 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1064
1066
|
onImageError: f,
|
|
1065
1067
|
emitError: le
|
|
1066
1068
|
});
|
|
1067
|
-
if (Yt({ onChange: w, onSelectionChange: l }),
|
|
1069
|
+
if (Yt({ onChange: w, onSelectionChange: l }), Jt(
|
|
1068
1070
|
{
|
|
1069
1071
|
autoExportInterval: L,
|
|
1070
1072
|
autoExportConfig: H,
|
|
1071
|
-
autoExportFormat:
|
|
1073
|
+
autoExportFormat: J,
|
|
1072
1074
|
autoExportAll: ce,
|
|
1073
|
-
exportScale:
|
|
1074
|
-
maxExportSize:
|
|
1075
|
+
exportScale: te,
|
|
1076
|
+
maxExportSize: ne,
|
|
1075
1077
|
exportImageFormat: $,
|
|
1076
1078
|
exportImageQuality: B,
|
|
1077
1079
|
onExport: p,
|
|
@@ -1080,7 +1082,7 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1080
1082
|
onExportReady: I,
|
|
1081
1083
|
onReady: u,
|
|
1082
1084
|
hasInitialElements: !!m && m.length > 0,
|
|
1083
|
-
initialElementsLoaded:
|
|
1085
|
+
initialElementsLoaded: Oe,
|
|
1084
1086
|
emitError: le
|
|
1085
1087
|
},
|
|
1086
1088
|
r
|
|
@@ -1096,7 +1098,7 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1096
1098
|
justifyContent: "center",
|
|
1097
1099
|
backgroundColor: "var(--surface, #f5f5f5)"
|
|
1098
1100
|
},
|
|
1099
|
-
children: /* @__PURE__ */ E(
|
|
1101
|
+
children: /* @__PURE__ */ E(ct, { size: 48 })
|
|
1100
1102
|
}
|
|
1101
1103
|
);
|
|
1102
1104
|
if (ve === "error" && Ee)
|
|
@@ -1113,20 +1115,20 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1113
1115
|
color: "var(--danger, #dc2626)",
|
|
1114
1116
|
padding: "1rem"
|
|
1115
1117
|
},
|
|
1116
|
-
children: /* @__PURE__ */
|
|
1118
|
+
children: /* @__PURE__ */ q("div", { className: "sc:text-center", children: [
|
|
1117
1119
|
/* @__PURE__ */ E("div", { className: "sc:font-medium", children: "Failed to load image" }),
|
|
1118
1120
|
/* @__PURE__ */ E("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: Ee.message })
|
|
1119
1121
|
] })
|
|
1120
1122
|
}
|
|
1121
1123
|
);
|
|
1122
|
-
const
|
|
1124
|
+
const ze = Object.entries(((we = Q.layout) == null ? void 0 : we.slots) ?? {}).every(
|
|
1123
1125
|
([X, K]) => X === "canvas" || !K || K.length === 0
|
|
1124
1126
|
) ? { "--color-canvas-bg": "transparent" } : void 0;
|
|
1125
|
-
return /* @__PURE__ */ E(
|
|
1126
|
-
|
|
1127
|
+
return /* @__PURE__ */ E(lt, { kit: Q, children: /* @__PURE__ */ E("div", { className: `sc-root ${h || ""}`, style: { ...ze, ...S, position: "relative" }, children: /* @__PURE__ */ q(
|
|
1128
|
+
Tt,
|
|
1127
1129
|
{
|
|
1128
|
-
onError:
|
|
1129
|
-
fallback: (X, K) => /* @__PURE__ */
|
|
1130
|
+
onError: He,
|
|
1131
|
+
fallback: (X, K) => /* @__PURE__ */ q(
|
|
1130
1132
|
"div",
|
|
1131
1133
|
{
|
|
1132
1134
|
style: {
|
|
@@ -1165,49 +1167,49 @@ const Ie = _("SnowconeCanvas"), Me = Re((a, r) => {
|
|
|
1165
1167
|
}
|
|
1166
1168
|
),
|
|
1167
1169
|
children: [
|
|
1168
|
-
!
|
|
1170
|
+
!De && /* @__PURE__ */ (() => {
|
|
1169
1171
|
const X = /* @__PURE__ */ E(
|
|
1170
|
-
|
|
1172
|
+
dt,
|
|
1171
1173
|
{
|
|
1172
1174
|
style: { width: "100%" },
|
|
1173
1175
|
fitPadding: G,
|
|
1174
1176
|
artboardBorderRadius: z,
|
|
1175
1177
|
fixedMargin: V,
|
|
1176
|
-
maxHeight:
|
|
1177
|
-
showRotationHandle:
|
|
1178
|
-
enableShortcuts:
|
|
1179
|
-
canvasCutouts:
|
|
1178
|
+
maxHeight: Le,
|
|
1179
|
+
showRotationHandle: Pe,
|
|
1180
|
+
enableShortcuts: We,
|
|
1181
|
+
canvasCutouts: $e,
|
|
1180
1182
|
pieceGuides: be,
|
|
1181
|
-
pieceFocus:
|
|
1183
|
+
pieceFocus: Be
|
|
1182
1184
|
}
|
|
1183
1185
|
);
|
|
1184
|
-
return /* @__PURE__ */ E(
|
|
1186
|
+
return /* @__PURE__ */ E(Ft, { kit: Q, canvas: ge || pe ? /* @__PURE__ */ E("div", { className: ge, style: pe, children: X }) : X });
|
|
1185
1187
|
})(),
|
|
1186
1188
|
F
|
|
1187
1189
|
]
|
|
1188
1190
|
}
|
|
1189
1191
|
) }) });
|
|
1190
1192
|
});
|
|
1191
|
-
|
|
1192
|
-
const Zt =
|
|
1193
|
+
Ne.displayName = "SnowconeCanvasInner";
|
|
1194
|
+
const Zt = Fe((a, r) => {
|
|
1193
1195
|
var c;
|
|
1194
|
-
const { inheritTheme: e, externalProvider:
|
|
1196
|
+
const { inheritTheme: e, externalProvider: o, services: t } = a, n = a.viewPadding ?? ((c = a.layoutConfig) == null ? void 0 : c.viewPadding);
|
|
1195
1197
|
return /* @__PURE__ */ E(
|
|
1196
|
-
|
|
1198
|
+
Mt,
|
|
1197
1199
|
{
|
|
1198
1200
|
inheritTheme: e,
|
|
1199
|
-
externalProvider:
|
|
1201
|
+
externalProvider: o,
|
|
1200
1202
|
services: t,
|
|
1201
|
-
viewPadding:
|
|
1202
|
-
children: /* @__PURE__ */ E(
|
|
1203
|
+
viewPadding: n,
|
|
1204
|
+
children: /* @__PURE__ */ E(Ne, { ref: r, ...a })
|
|
1203
1205
|
}
|
|
1204
1206
|
);
|
|
1205
1207
|
});
|
|
1206
1208
|
Zt.displayName = "SnowconeCanvas";
|
|
1207
1209
|
export {
|
|
1208
|
-
|
|
1210
|
+
Tt as E,
|
|
1209
1211
|
Zt as S,
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
+
Bt as a,
|
|
1213
|
+
Lt as u
|
|
1212
1214
|
};
|
|
1213
|
-
//# sourceMappingURL=SnowconeCanvas-
|
|
1215
|
+
//# sourceMappingURL=SnowconeCanvas-BZk7PRpk.js.map
|