@snowcone-app/canvas 0.29.0 → 0.30.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/ERROR_CONTRACT.md +13 -0
- package/dist/{CanvasRenderer-_lFoIoz5.js → CanvasRenderer-BEf0hXeF.js} +4 -4
- package/dist/{CanvasRenderer-_lFoIoz5.js.map → CanvasRenderer-BEf0hXeF.js.map} +1 -1
- package/dist/{CanvasStateV1-BMxr6xb8.js → CanvasStateV1-BDSyYo4A.js} +868 -843
- package/dist/{CanvasStateV1-BMxr6xb8.js.map → CanvasStateV1-BDSyYo4A.js.map} +1 -1
- package/dist/ContextualToolbars-C3D_6sep.js +5960 -0
- package/dist/ContextualToolbars-C3D_6sep.js.map +1 -0
- package/dist/{EditorCanvasImpl-BNz8TPFs.js → EditorCanvasImpl-DXeBz2CX.js} +8 -8
- package/dist/{EditorCanvasImpl-BNz8TPFs.js.map → EditorCanvasImpl-DXeBz2CX.js.map} +1 -1
- package/dist/{ExportManager-B8Td7uR5.js → ExportManager-DUdis6se.js} +794 -536
- package/dist/ExportManager-DUdis6se.js.map +1 -0
- package/dist/{FontAnalyzer-D4Sg-P6_.js → FontAnalyzer-DKG5JK0x.js} +823 -808
- package/dist/FontAnalyzer-DKG5JK0x.js.map +1 -0
- package/dist/{ImagePanel-CN2Bu3hf.js → ImagePanel-CBgGqmVV.js} +53 -53
- package/dist/{ImagePanel-CN2Bu3hf.js.map → ImagePanel-CBgGqmVV.js.map} +1 -1
- package/dist/SnowconeCanvas-BWPBngvI.js +1192 -0
- package/dist/SnowconeCanvas-BWPBngvI.js.map +1 -0
- package/dist/{UnifiedFontService-CgYnYTj7.js → UnifiedFontService-Co9tQ59z.js} +869 -826
- package/dist/UnifiedFontService-Co9tQ59z.js.map +1 -0
- package/dist/advanced.mjs +14 -14
- package/dist/api/embed.d.ts +2 -0
- package/dist/api/stable.d.ts +2 -0
- package/dist/components/CanvasContextMenu.d.ts +15 -0
- package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +27 -0
- package/dist/components/CanvasEditor.d.ts +8 -0
- package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
- package/dist/components/embed/kernel.d.ts +8 -0
- package/dist/components/ui/icons.d.ts +2 -0
- package/dist/contexts/CanvasServicesContext.d.ts +17 -0
- package/dist/contexts/EditorContext.d.ts +7 -0
- package/dist/{custom-icons-B5TRC1Ed.js → custom-icons-BIaRovwG.js} +2 -2
- package/dist/{custom-icons-B5TRC1Ed.js.map → custom-icons-BIaRovwG.js.map} +1 -1
- package/dist/{design-builder-COj0zkxu.js → design-builder-JYLO_Hyi.js} +2 -2
- package/dist/{design-builder-COj0zkxu.js.map → design-builder-JYLO_Hyi.js.map} +1 -1
- package/dist/{editorErrors-CCvoKj_P.js → editorErrors-WzaNxU1Y.js} +181 -194
- package/dist/editorErrors-WzaNxU1Y.js.map +1 -0
- package/dist/{embed-BTRtoktw.js → embed-Csez1hui.js} +113 -112
- package/dist/{embed-BTRtoktw.js.map → embed-Csez1hui.js.map} +1 -1
- package/dist/embed.mjs +51 -45
- package/dist/embed.mjs.map +1 -1
- package/dist/errors/editorError.d.ts +8 -0
- package/dist/{guards-uQtEQJbs.js → guards-BSoX73yg.js} +2 -2
- package/dist/{guards-uQtEQJbs.js.map → guards-BSoX73yg.js.map} +1 -1
- package/dist/hooks/useKeyboardShortcuts.d.ts +15 -2
- package/dist/hooks/useLayers.d.ts +2 -0
- package/dist/index.mjs +42 -37
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +47 -47
- package/dist/state/CanvasStateV1.d.ts +31 -3
- package/dist/state/index.d.ts +2 -2
- package/dist/{template-fields-BLRp84Ny.js → template-fields-DYPW7bVU.js} +40 -40
- package/dist/{template-fields-BLRp84Ny.js.map → template-fields-DYPW7bVU.js.map} +1 -1
- package/dist/testing.mjs +13 -13
- package/dist/{usePieceGuideBundle-CTQszfKA.js → usePieceGuideBundle-CRLY2iQa.js} +2 -2
- package/dist/{usePieceGuideBundle-CTQszfKA.js.map → usePieceGuideBundle-CRLY2iQa.js.map} +1 -1
- package/dist/utils/custom-fonts.d.ts +99 -0
- package/dist/validation-BGEl9rrE.js +8686 -0
- package/dist/validation-BGEl9rrE.js.map +1 -0
- package/dist/workers/export-protocol.d.ts +13 -0
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/ContextualToolbars-0jWvnQgp.js +0 -5833
- package/dist/ContextualToolbars-0jWvnQgp.js.map +0 -1
- package/dist/ExportManager-B8Td7uR5.js.map +0 -1
- package/dist/FontAnalyzer-D4Sg-P6_.js.map +0 -1
- package/dist/SnowconeCanvas-CR_LdRFP.js +0 -1173
- package/dist/SnowconeCanvas-CR_LdRFP.js.map +0 -1
- package/dist/UnifiedFontService-CgYnYTj7.js.map +0 -1
- package/dist/editorErrors-CCvoKj_P.js.map +0 -1
- package/dist/validation-eCebhplp.js +0 -8402
- package/dist/validation-eCebhplp.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { E as Le, o as Ve, p as Be, C as Fe, q as H, r as J, t as Ue, v as Me, w as je, x as qe, y as ze, g as Ke, e as We } from "./UnifiedFontService-
|
|
2
|
-
import { y as L } from "./FontAnalyzer-
|
|
1
|
+
import { E as Le, o as Ve, p as Be, C as Fe, q as H, r as J, t as Ue, v as Me, w as je, x as qe, y as ze, g as Ke, e as We } from "./UnifiedFontService-Co9tQ59z.js";
|
|
2
|
+
import { E as T, y as be, z as L } from "./FontAnalyzer-DKG5JK0x.js";
|
|
3
3
|
import { jsx as l, jsxs as N, Fragment as Ge } from "react/jsx-runtime";
|
|
4
|
-
import { useContext as He, createContext as Je, useRef as x, useState as C, useMemo as O, useCallback as F, useLayoutEffect as Q, useEffect as $, useSyncExternalStore as z, Component as Qe, forwardRef as
|
|
4
|
+
import { useContext as He, createContext as Je, useRef as x, useState as C, useMemo as O, useCallback as F, useLayoutEffect as Q, useEffect as $, useSyncExternalStore as z, Component as Qe, forwardRef as we, useId as de, memo as Ye, isValidElement as Ee } from "react";
|
|
5
5
|
import { assertVariantSelected as Xe, RenderSession as Ze, createCartDetail as et } from "@snowcone-app/sdk";
|
|
6
|
-
import {
|
|
7
|
-
import { u as ot, p as it } from "./usePieceGuideBundle-
|
|
8
|
-
import { s as le, i as st } from "./design-builder-
|
|
9
|
-
import { D as at, C as dt, g as lt, e as ct } from "./template-fields-
|
|
10
|
-
import "./
|
|
6
|
+
import { B as tt, E as nt, r as rt } from "./editorErrors-WzaNxU1Y.js";
|
|
7
|
+
import { u as ot, p as it } from "./usePieceGuideBundle-CRLY2iQa.js";
|
|
8
|
+
import { s as le, i as st } from "./design-builder-JYLO_Hyi.js";
|
|
9
|
+
import { D as at, C as dt, g as lt, e as ct } from "./template-fields-DYPW7bVU.js";
|
|
10
|
+
import "./ExportManager-DUdis6se.js";
|
|
11
|
+
import "./CanvasStateV1-BDSyYo4A.js";
|
|
11
12
|
const xe = Je(void 0);
|
|
12
13
|
function K() {
|
|
13
14
|
const t = He(xe);
|
|
@@ -64,14 +65,14 @@ function Re({ shop: t, product: e, design: n, hasGrant: r }) {
|
|
|
64
65
|
issue: "placement-mismatch",
|
|
65
66
|
message: `the design's artboard(s) [${a.join(", ")}] are not in product.placements [${e.placements.join(", ")}]. Every artboard name must equal a real product placement label (renderState targets placements by that name), or the server renders a blank mockup. Fix the \`name\` passed to design({ name }) / design().artboard(name, …).`
|
|
66
67
|
});
|
|
67
|
-
const
|
|
68
|
+
const f = s.elements.map((o) => o.name).filter((o) => !!o), m = f.filter((o, g) => f.indexOf(o) !== g);
|
|
68
69
|
return m.length && i.push({
|
|
69
70
|
severity: "warn",
|
|
70
71
|
issue: "duplicate-layer-names",
|
|
71
72
|
message: `duplicate layer name(s) [${[...new Set(m)].join(", ")}] — useTextBinding(name) / useImageBinding(name) bind to the FIRST match, so a duplicate name makes a control edit the wrong layer. Keep names unique.`
|
|
72
73
|
}), i;
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
+
function pt(t) {
|
|
75
76
|
for (const e of Re(t))
|
|
76
77
|
(e.severity === "error" && e.issue !== "placement-mismatch" ? console.error : console.warn)(`${ut} ${e.message}`);
|
|
77
78
|
}
|
|
@@ -110,15 +111,15 @@ function Se({ registry: t, store: e, product: n }) {
|
|
|
110
111
|
fix: "Mount <Editor.Buy onAddToCart={…}/> under the same <Editor.Root> (it assembles the payload and gates on completeness), or ignore if this composition is deliberately non-commerce."
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
|
-
const
|
|
114
|
+
const f = [];
|
|
114
115
|
for (const o of s)
|
|
115
116
|
e.layerKindOf(o.name) === void 0 ? r.push({
|
|
116
117
|
code: "A_LAYER_UNMATCHED",
|
|
117
118
|
severity: "error",
|
|
118
119
|
message: `<Editor.TextField layer={design.layer("${o.name}")}> matches zero elements in the current design state — the layer was removed or renamed after the field mounted, so the binding is dead and writes will fail. Bindable layers now: ${JSON.stringify(e.bindableLayerNames())}.`,
|
|
119
120
|
fix: `Restore a text layer named "${o.name}" to the design, or bind the field to an existing layer: layer={design.layer(<one of ${JSON.stringify(e.bindableLayerNames())}>)}.`
|
|
120
|
-
}) :
|
|
121
|
-
const m =
|
|
121
|
+
}) : f.push(o);
|
|
122
|
+
const m = f.filter((o) => !o.optional);
|
|
122
123
|
if (m.length > 0 && m.every((o) => e.textOf(o.name) === e.seedTextOf(o.name))) {
|
|
123
124
|
const o = m.map((g) => g.name);
|
|
124
125
|
r.push({
|
|
@@ -140,13 +141,13 @@ function Se({ registry: t, store: e, product: n }) {
|
|
|
140
141
|
return { findings: r, parts: b };
|
|
141
142
|
}
|
|
142
143
|
const G = [];
|
|
143
|
-
function
|
|
144
|
+
function ft(t) {
|
|
144
145
|
return G.push(t), () => {
|
|
145
146
|
const e = G.indexOf(t);
|
|
146
147
|
e !== -1 && G.splice(e, 1);
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function on() {
|
|
150
151
|
const t = G[G.length - 1];
|
|
151
152
|
if (!t)
|
|
152
153
|
throw new T(
|
|
@@ -167,7 +168,7 @@ function gt(t) {
|
|
|
167
168
|
return typeof e == "function" ? { getToken: e } : { getToken: () => Promise.resolve(e) };
|
|
168
169
|
}
|
|
169
170
|
function Ce({ error: t, onRetry: e }) {
|
|
170
|
-
const n =
|
|
171
|
+
const n = be(t) ? t.code : "EDITOR_ERROR";
|
|
171
172
|
return /* @__PURE__ */ N(
|
|
172
173
|
"div",
|
|
173
174
|
{
|
|
@@ -230,7 +231,7 @@ class yt extends Qe {
|
|
|
230
231
|
}
|
|
231
232
|
function vt({ reportedError: t, onRetry: e, children: n }) {
|
|
232
233
|
if (t) {
|
|
233
|
-
const r =
|
|
234
|
+
const r = be(t) && t.code === "E_CHUNK_LOAD_FAILED";
|
|
234
235
|
return /* @__PURE__ */ l(Ce, { error: t, onRetry: r ? e : void 0 });
|
|
235
236
|
}
|
|
236
237
|
return /* @__PURE__ */ l(yt, { reportedError: null, onRetry: e, children: n });
|
|
@@ -246,11 +247,11 @@ function bt(t) {
|
|
|
246
247
|
onIssue: c,
|
|
247
248
|
wsUrl: u,
|
|
248
249
|
services: a,
|
|
249
|
-
children:
|
|
250
|
+
children: f,
|
|
250
251
|
internals: m,
|
|
251
252
|
recordAudit: y,
|
|
252
253
|
__validation: b = "throw"
|
|
253
|
-
} = t, o = O(() => r.toJSON().activeArtboard, [r]), g = O(() => r.toJSON().artboards.map((h) => h.name), [r]), [w,
|
|
254
|
+
} = t, o = O(() => r.toJSON().activeArtboard, [r]), g = O(() => r.toJSON().artboards.map((h) => h.name), [r]), [w, p] = C(null), S = w && w.design === r ? w.label : o, v = O(
|
|
254
255
|
() => (h) => {
|
|
255
256
|
if (!g.includes(h))
|
|
256
257
|
throw new T(
|
|
@@ -258,7 +259,7 @@ function bt(t) {
|
|
|
258
259
|
`no placement "${h}" in this design — its artboards are ${JSON.stringify(g)}. Add it to the seed with design(…).artboard('${h}', { width, height }) (ADR-0088).`,
|
|
259
260
|
{ placement: h, validNames: g, docSlug: "embed-mode" }
|
|
260
261
|
);
|
|
261
|
-
|
|
262
|
+
p({ design: r, label: h });
|
|
262
263
|
},
|
|
263
264
|
[r, g]
|
|
264
265
|
), V = O(() => {
|
|
@@ -295,20 +296,20 @@ function bt(t) {
|
|
|
295
296
|
for (const B of h)
|
|
296
297
|
typeof L < "u" && ((I = L.env) == null ? void 0 : I.NODE_ENV) !== "production" && console.warn(`[Editor.Root] ${B.message}`);
|
|
297
298
|
return h;
|
|
298
|
-
}, [q, b]),
|
|
299
|
+
}, [q, b]), pe = x(null);
|
|
299
300
|
$(() => {
|
|
300
301
|
var h;
|
|
301
|
-
if (oe.length !== 0 &&
|
|
302
|
-
|
|
302
|
+
if (oe.length !== 0 && pe.current !== q) {
|
|
303
|
+
pe.current = q;
|
|
303
304
|
for (const E of oe) (h = j.current) == null || h.call(j, E);
|
|
304
305
|
}
|
|
305
306
|
}, [oe, q]);
|
|
306
|
-
const
|
|
307
|
+
const fe = x(null);
|
|
307
308
|
$(() => {
|
|
308
309
|
var h;
|
|
309
310
|
if (b === "warn" && typeof L < "u" && ((h = L.env) == null ? void 0 : h.NODE_ENV) !== "production") {
|
|
310
|
-
if (
|
|
311
|
-
|
|
311
|
+
if (fe.current === q) return;
|
|
312
|
+
fe.current = q, pt({ shop: e, product: n, design: r, hasGrant: ne });
|
|
312
313
|
}
|
|
313
314
|
}, [q, b]);
|
|
314
315
|
const Z = O(
|
|
@@ -409,7 +410,7 @@ function bt(t) {
|
|
|
409
410
|
nt,
|
|
410
411
|
{
|
|
411
412
|
...V ? { initialArtboardConfig: V } : {},
|
|
412
|
-
children:
|
|
413
|
+
children: f
|
|
413
414
|
}
|
|
414
415
|
) }) }) });
|
|
415
416
|
return a ? /* @__PURE__ */ l(Fe, { services: a, children: he }) : he;
|
|
@@ -431,8 +432,8 @@ function Ie(t) {
|
|
|
431
432
|
}),
|
|
432
433
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
433
434
|
[s.current.internals, d.current.commerce]
|
|
434
|
-
),
|
|
435
|
-
|
|
435
|
+
), f = x(n);
|
|
436
|
+
f.current = n;
|
|
436
437
|
const m = x(r);
|
|
437
438
|
m.current = r;
|
|
438
439
|
const y = x(null), b = F((w) => {
|
|
@@ -441,17 +442,17 @@ function Ie(t) {
|
|
|
441
442
|
() => Se({
|
|
442
443
|
registry: s.current.internals.registry,
|
|
443
444
|
store: s.current.internals.store,
|
|
444
|
-
product:
|
|
445
|
+
product: f.current
|
|
445
446
|
}),
|
|
446
447
|
[]
|
|
447
448
|
);
|
|
448
|
-
Q(() =>
|
|
449
|
+
Q(() => ft({ compute: o }), [o]);
|
|
449
450
|
const g = x(!1);
|
|
450
451
|
return $(() => {
|
|
451
452
|
let w = !1;
|
|
452
453
|
return queueMicrotask(() => {
|
|
453
|
-
var
|
|
454
|
-
w || g.current || (g.current = !0, (
|
|
454
|
+
var p;
|
|
455
|
+
w || g.current || (g.current = !0, (p = m.current) == null || p.call(m, y.current ?? o()));
|
|
455
456
|
}), () => {
|
|
456
457
|
w = !0;
|
|
457
458
|
};
|
|
@@ -460,21 +461,21 @@ function Ie(t) {
|
|
|
460
461
|
// wrapper, which had no DOM at all, stays layout-identical).
|
|
461
462
|
/* @__PURE__ */ l("div", { className: "sc-root", style: { display: "contents" }, "data-sc-part": "root", children: /* @__PURE__ */ l(vt, { reportedError: c, onRetry: () => u(null), children: /* @__PURE__ */ l(bt, { ...t, internals: a, recordAudit: b }) }) });
|
|
462
463
|
}
|
|
463
|
-
let wt = () => import("./EditorCanvasImpl-
|
|
464
|
+
let wt = () => import("./EditorCanvasImpl-DXeBz2CX.js").then((t) => t.EditorCanvasImpl);
|
|
464
465
|
function Oe() {
|
|
465
466
|
return wt();
|
|
466
467
|
}
|
|
467
|
-
const Et =
|
|
468
|
+
const Et = we(function({ children: e, maxHeight: n, floatingToolbar: r = !0, className: i, style: s }, d) {
|
|
468
469
|
const c = H("Editor.Canvas");
|
|
469
470
|
J("Editor.Canvas", { floatingToolbar: r });
|
|
470
471
|
const u = de();
|
|
471
472
|
Q(() => c.registry.registerCanvas(u), [c.registry, u]);
|
|
472
|
-
const [a,
|
|
473
|
+
const [a, f] = C(null);
|
|
473
474
|
return $(() => {
|
|
474
475
|
let m = !1;
|
|
475
476
|
return Oe().then(
|
|
476
477
|
(y) => {
|
|
477
|
-
m ||
|
|
478
|
+
m || f(() => y);
|
|
478
479
|
},
|
|
479
480
|
(y) => {
|
|
480
481
|
m || c.reportRuntimeError(
|
|
@@ -600,12 +601,12 @@ const Ne = Ye(function({
|
|
|
600
601
|
}, []);
|
|
601
602
|
const [d, c] = C(!1);
|
|
602
603
|
$(() => {
|
|
603
|
-
const
|
|
604
|
-
return () => cancelAnimationFrame(
|
|
604
|
+
const f = requestAnimationFrame(() => c(!0));
|
|
605
|
+
return () => cancelAnimationFrame(f);
|
|
605
606
|
}, []);
|
|
606
607
|
const u = F(
|
|
607
|
-
(
|
|
608
|
-
|
|
608
|
+
(f) => {
|
|
609
|
+
f.propertyName === "background-color" && (e || n == null || n());
|
|
609
610
|
},
|
|
610
611
|
[e, n]
|
|
611
612
|
);
|
|
@@ -618,18 +619,18 @@ const Ne = Ye(function({
|
|
|
618
619
|
onTransitionEnd: u,
|
|
619
620
|
"aria-hidden": "true",
|
|
620
621
|
children: [
|
|
621
|
-
Array.from({ length: 6 }, (
|
|
622
|
-
i.map((
|
|
622
|
+
Array.from({ length: 6 }, (f, m) => /* @__PURE__ */ l("div", { className: "sc-prism-band" }, `b-${m}`)),
|
|
623
|
+
i.map((f, m) => /* @__PURE__ */ l(
|
|
623
624
|
"div",
|
|
624
625
|
{
|
|
625
626
|
className: "sc-prism-particle",
|
|
626
627
|
style: {
|
|
627
|
-
left: `${
|
|
628
|
-
top: `${
|
|
629
|
-
animationDelay: `${
|
|
630
|
-
animationDuration: `${
|
|
631
|
-
width: `${
|
|
632
|
-
height: `${
|
|
628
|
+
left: `${f.left}%`,
|
|
629
|
+
top: `${f.top}%`,
|
|
630
|
+
animationDelay: `${f.delay}s`,
|
|
631
|
+
animationDuration: `${f.duration}s`,
|
|
632
|
+
width: `${f.size}px`,
|
|
633
|
+
height: `${f.size}px`
|
|
633
634
|
}
|
|
634
635
|
},
|
|
635
636
|
`p-${m}`
|
|
@@ -663,7 +664,7 @@ function Tt(t, e) {
|
|
|
663
664
|
}
|
|
664
665
|
function $t(t) {
|
|
665
666
|
if (t === void 0 || t === !0 || t === "dark") return "dark";
|
|
666
|
-
if (t === "light" || t === "host-owned" ||
|
|
667
|
+
if (t === "light" || t === "host-owned" || Ee(t)) return t;
|
|
667
668
|
throw new T(
|
|
668
669
|
"E_PREVIEW_NO_LOADER",
|
|
669
670
|
`Editor.Preview: invalid loadingOverlay value ${JSON.stringify(t)}. A mockup preview always has a render-in-flight treatment (the loader paints over the still-visible previous mockup). Omit the prop for the default rainbow overlay, pass "dark" | "light", pass a custom ReactElement, or declare "host-owned" if the host renders its own indicator off data-sc-preview-state / <Editor.LoadingOverlay>.`,
|
|
@@ -680,18 +681,18 @@ function $e({
|
|
|
680
681
|
}) {
|
|
681
682
|
const { mockups: d, error: c, isRendering: u } = K();
|
|
682
683
|
J("Editor.Preview", { ...t !== void 0 ? { mockupId: t } : {} });
|
|
683
|
-
const a = $t(r),
|
|
684
|
+
const a = $t(r), f = a === "dark" || a === "light" ? a : null, m = Ee(a) ? a : null, y = a !== "host-owned", { showOverlay: b, overlayVisible: o, handleExited: g } = Te(
|
|
684
685
|
y && u
|
|
685
|
-
), w = x(/* @__PURE__ */ new Set()),
|
|
686
|
+
), w = x(/* @__PURE__ */ new Set()), p = t ? d.find((v) => v.mockupId === t && v.imageUrl) : d.find((v) => v.imageUrl), S = (v) => {
|
|
686
687
|
var P;
|
|
687
|
-
if (!
|
|
688
|
+
if (!p || typeof L > "u" || ((P = L.env) == null ? void 0 : P.NODE_ENV) === "production" || typeof window > "u" || w.current.has(p.mockupId)) return;
|
|
688
689
|
const V = v.currentTarget, R = V.getBoundingClientRect().width;
|
|
689
690
|
if (R <= 0) return;
|
|
690
691
|
const _ = Math.round(R * (window.devicePixelRatio || 1)), D = Tt(V.naturalWidth, _);
|
|
691
|
-
D && (w.current.add(
|
|
692
|
+
D && (w.current.add(p.mockupId), console.warn(D));
|
|
692
693
|
};
|
|
693
694
|
if (y) {
|
|
694
|
-
const v =
|
|
695
|
+
const v = p != null && p.imageUrl ? u ? "rendering" : "ready" : c ? "error" : "rendering";
|
|
695
696
|
return /* @__PURE__ */ N(
|
|
696
697
|
"div",
|
|
697
698
|
{
|
|
@@ -701,9 +702,9 @@ function $e({
|
|
|
701
702
|
className: `sc-preview-frame${i ? ` ${i}` : ""}`,
|
|
702
703
|
style: s,
|
|
703
704
|
children: [
|
|
704
|
-
|
|
705
|
+
p != null && p.imageUrl ? (
|
|
705
706
|
// eslint-disable-next-line @next/next/no-img-element
|
|
706
|
-
/* @__PURE__ */ l("img", { "data-sc-part": "preview-image", src:
|
|
707
|
+
/* @__PURE__ */ l("img", { "data-sc-part": "preview-image", src: p.imageUrl, alt: n, onLoad: S })
|
|
707
708
|
) : c ? /* @__PURE__ */ l("div", { "data-sc-part": "preview-error", role: "alert", "data-sc-error": c, children: e ?? `Render failed: ${c}` }) : e,
|
|
708
709
|
m ? (
|
|
709
710
|
// Custom indicator: same show-delay + linger window; no exit fade
|
|
@@ -718,11 +719,11 @@ function $e({
|
|
|
718
719
|
children: m
|
|
719
720
|
}
|
|
720
721
|
) : null
|
|
721
|
-
) : b &&
|
|
722
|
+
) : b && f ? /* @__PURE__ */ l(
|
|
722
723
|
Ne,
|
|
723
724
|
{
|
|
724
725
|
visible: o,
|
|
725
|
-
variant:
|
|
726
|
+
variant: f,
|
|
726
727
|
onExited: g
|
|
727
728
|
}
|
|
728
729
|
) : null
|
|
@@ -730,14 +731,14 @@ function $e({
|
|
|
730
731
|
}
|
|
731
732
|
);
|
|
732
733
|
}
|
|
733
|
-
return
|
|
734
|
+
return p != null && p.imageUrl ? (
|
|
734
735
|
// eslint-disable-next-line @next/next/no-img-element
|
|
735
736
|
/* @__PURE__ */ l(
|
|
736
737
|
"img",
|
|
737
738
|
{
|
|
738
739
|
"data-sc-part": "preview",
|
|
739
740
|
"data-sc-preview-state": u ? "rendering" : "ready",
|
|
740
|
-
src:
|
|
741
|
+
src: p.imageUrl,
|
|
741
742
|
alt: n,
|
|
742
743
|
className: i,
|
|
743
744
|
style: s,
|
|
@@ -760,7 +761,7 @@ function $e({
|
|
|
760
761
|
function _t(t) {
|
|
761
762
|
const { layer: e, optional: n = !1, placeholder: r, className: i, style: s } = t, d = H("Editor.TextField");
|
|
762
763
|
J("Editor.TextField");
|
|
763
|
-
const { pushRender: c, throttleMs: u, stateStore: a } = K(),
|
|
764
|
+
const { pushRender: c, throttleMs: u, stateStore: a } = K(), f = de(), m = x(null);
|
|
764
765
|
if (!st(e))
|
|
765
766
|
throw new T(
|
|
766
767
|
"E_LAYER_TOKEN_REQUIRED",
|
|
@@ -783,7 +784,7 @@ function _t(t) {
|
|
|
783
784
|
);
|
|
784
785
|
m.current = e.name;
|
|
785
786
|
}
|
|
786
|
-
Q(() => d.registry.registerTextField(
|
|
787
|
+
Q(() => d.registry.registerTextField(f, { name: e.name, optional: n }), [d.registry, f, e.name, n]);
|
|
787
788
|
const y = z(
|
|
788
789
|
a.subscribe,
|
|
789
790
|
() => a.textOf(e.name) ?? "",
|
|
@@ -861,9 +862,9 @@ function Pt(t) {
|
|
|
861
862
|
"<Editor.Buy> has no product context — pass `product` (with `productId`) on <Editor.Root product={…}>. Buy assembles its cart payload from the Root product and the live design state.",
|
|
862
863
|
{ docSlug: "embed-mode" }
|
|
863
864
|
);
|
|
864
|
-
const
|
|
865
|
+
const f = x(!1);
|
|
865
866
|
Q(() => {
|
|
866
|
-
|
|
867
|
+
f.current || (f.current = !0, typeof n == "number" && a.setQuantity(n));
|
|
867
868
|
}, [a]);
|
|
868
869
|
const m = z(u.subscribe, u.getState, u.getState), y = z(a.subscribe, a.getVersion, a.getVersion), b = z(
|
|
869
870
|
d.registry.subscribe,
|
|
@@ -881,7 +882,7 @@ function Pt(t) {
|
|
|
881
882
|
}),
|
|
882
883
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
883
884
|
[a, o, m, y, b]
|
|
884
|
-
), w = g.length === 0, [
|
|
885
|
+
), w = g.length === 0, [p, S] = C(!1), v = x(!1), V = F(() => {
|
|
885
886
|
if (v.current || !w) return;
|
|
886
887
|
v.current = !0, S(!0);
|
|
887
888
|
const R = u.getState(), _ = a.resolvedVariantId(), D = {
|
|
@@ -908,10 +909,10 @@ function Pt(t) {
|
|
|
908
909
|
{
|
|
909
910
|
type: "button",
|
|
910
911
|
"data-sc-part": "buy",
|
|
911
|
-
"data-sc-buy-state":
|
|
912
|
+
"data-sc-buy-state": p ? "busy" : w ? "ready" : "incomplete",
|
|
912
913
|
"data-sc-buy-missing": g.join(",") || void 0,
|
|
913
|
-
disabled: !w ||
|
|
914
|
-
"aria-busy":
|
|
914
|
+
disabled: !w || p,
|
|
915
|
+
"aria-busy": p || void 0,
|
|
915
916
|
onClick: V,
|
|
916
917
|
className: i,
|
|
917
918
|
style: s,
|
|
@@ -935,7 +936,7 @@ function Lt({
|
|
|
935
936
|
return $(() => {
|
|
936
937
|
if (!s) return;
|
|
937
938
|
let u = !1;
|
|
938
|
-
return import("./ContextualToolbars-
|
|
939
|
+
return import("./ContextualToolbars-C3D_6sep.js").then((a) => a.s).then(
|
|
939
940
|
(a) => {
|
|
940
941
|
u || c(() => a.ContextualToolbars);
|
|
941
942
|
},
|
|
@@ -1027,23 +1028,23 @@ const M = {
|
|
|
1027
1028
|
* Fills its positioned parent; rides the session (canvas-free). */
|
|
1028
1029
|
LoadingOverlay: Vt
|
|
1029
1030
|
};
|
|
1030
|
-
function
|
|
1031
|
+
function sn(t) {
|
|
1031
1032
|
return /* @__PURE__ */ l(Ie, { ...t, __validation: "warn" });
|
|
1032
1033
|
}
|
|
1033
|
-
const
|
|
1034
|
+
const an = we(
|
|
1034
1035
|
function(e, n) {
|
|
1035
1036
|
const { children: r, className: i, style: s, maxHeight: d, ...c } = e, [u, a] = C(null);
|
|
1036
1037
|
return $(() => {
|
|
1037
|
-
let
|
|
1038
|
+
let f = !1;
|
|
1038
1039
|
return Oe().then(
|
|
1039
1040
|
(m) => {
|
|
1040
|
-
|
|
1041
|
+
f || a(() => m);
|
|
1041
1042
|
},
|
|
1042
1043
|
(m) => {
|
|
1043
1044
|
console.error("[RealtimeCanvas] failed to load the rendering chunk:", m);
|
|
1044
1045
|
}
|
|
1045
1046
|
), () => {
|
|
1046
|
-
|
|
1047
|
+
f = !0;
|
|
1047
1048
|
};
|
|
1048
1049
|
}, []), u ? /* @__PURE__ */ l(u, { ref: n, selfScope: !0, maxHeight: d, className: i, style: s, ...c, children: r }) : /* @__PURE__ */ l(
|
|
1049
1050
|
"div",
|
|
@@ -1055,19 +1056,19 @@ const sn = be(
|
|
|
1055
1056
|
);
|
|
1056
1057
|
}
|
|
1057
1058
|
);
|
|
1058
|
-
function
|
|
1059
|
+
function dn(t) {
|
|
1059
1060
|
return /* @__PURE__ */ l($e, { ...t });
|
|
1060
1061
|
}
|
|
1061
|
-
function
|
|
1062
|
+
function ln() {
|
|
1062
1063
|
const { mockups: t, isRendering: e, error: n } = K();
|
|
1063
1064
|
return { mockups: t, isRendering: e, error: n };
|
|
1064
1065
|
}
|
|
1065
1066
|
function Ft(t) {
|
|
1066
1067
|
return t.type !== "color" && typeof t.width == "number" && t.width > 0 && typeof t.height == "number" && t.height > 0;
|
|
1067
1068
|
}
|
|
1068
|
-
function
|
|
1069
|
+
function cn(t, e = {}) {
|
|
1069
1070
|
var y, b, o, g, w;
|
|
1070
|
-
const n = (t.placements ?? []).filter(Ft), r = n.map((
|
|
1071
|
+
const n = (t.placements ?? []).filter(Ft), r = n.map((p) => p.label), i = e.placement ? n.find((p) => p.label === e.placement) : n[0];
|
|
1071
1072
|
if (!i)
|
|
1072
1073
|
throw e.placement ? new T(
|
|
1073
1074
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
@@ -1079,17 +1080,17 @@ function ln(t, e = {}) {
|
|
|
1079
1080
|
{ productId: t.id, docSlug: "embed-mode" }
|
|
1080
1081
|
);
|
|
1081
1082
|
const s = ((y = t.options) == null ? void 0 : y.attributes) ?? {}, c = Object.values(s).some(
|
|
1082
|
-
(
|
|
1083
|
+
(p) => {
|
|
1083
1084
|
var S;
|
|
1084
|
-
return (S =
|
|
1085
|
+
return (S = p == null ? void 0 : p.choices) == null ? void 0 : S.some((v) => v == null ? void 0 : v.hex);
|
|
1085
1086
|
}
|
|
1086
1087
|
) ? (g = (o = (b = t.options) == null ? void 0 : b.combinations) == null ? void 0 : o.find(
|
|
1087
|
-
(
|
|
1088
|
-
)) == null ? void 0 : g.variantId : void 0, u = t.mockups ?? [], a = c ? u.filter((
|
|
1088
|
+
(p) => typeof p.variantId == "string" && p.variantId !== ""
|
|
1089
|
+
)) == null ? void 0 : g.variantId : void 0, u = t.mockups ?? [], a = c ? u.filter((p) => {
|
|
1089
1090
|
var S;
|
|
1090
|
-
return (S =
|
|
1091
|
-
}) : u,
|
|
1092
|
-
if (
|
|
1091
|
+
return (S = p.gvids) == null ? void 0 : S.includes(c);
|
|
1092
|
+
}) : u, f = (a.length > 0 ? a : u).map((p) => p.id);
|
|
1093
|
+
if (f.length === 0)
|
|
1093
1094
|
throw new T(
|
|
1094
1095
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1095
1096
|
`product ${t.id} has no mockup scenes — nothing to render a preview into.`,
|
|
@@ -1098,10 +1099,10 @@ function ln(t, e = {}) {
|
|
|
1098
1099
|
return {
|
|
1099
1100
|
product: {
|
|
1100
1101
|
productId: t.id,
|
|
1101
|
-
mockupIds:
|
|
1102
|
+
mockupIds: f,
|
|
1102
1103
|
...typeof c == "string" ? { variantId: c } : {},
|
|
1103
1104
|
options: t.options,
|
|
1104
|
-
placements: (w = t.placements) == null ? void 0 : w.map((
|
|
1105
|
+
placements: (w = t.placements) == null ? void 0 : w.map((p) => p.label),
|
|
1105
1106
|
mockups: u,
|
|
1106
1107
|
requiredPlacements: t.requiredPlacements,
|
|
1107
1108
|
...t.defaultGvid ? { defaultGvid: t.defaultGvid } : {},
|
|
@@ -1114,13 +1115,13 @@ function ln(t, e = {}) {
|
|
|
1114
1115
|
aspectRatio: i.width / i.height
|
|
1115
1116
|
},
|
|
1116
1117
|
placementLabels: r,
|
|
1117
|
-
placements: n.map((
|
|
1118
|
-
label:
|
|
1119
|
-
width:
|
|
1120
|
-
height:
|
|
1121
|
-
aspectRatio:
|
|
1118
|
+
placements: n.map((p) => ({
|
|
1119
|
+
label: p.label,
|
|
1120
|
+
width: p.width,
|
|
1121
|
+
height: p.height,
|
|
1122
|
+
aspectRatio: p.width / p.height
|
|
1122
1123
|
})),
|
|
1123
|
-
primaryMockupId:
|
|
1124
|
+
primaryMockupId: f[0],
|
|
1124
1125
|
variantId: c
|
|
1125
1126
|
};
|
|
1126
1127
|
}
|
|
@@ -1239,15 +1240,15 @@ function qt({
|
|
|
1239
1240
|
}
|
|
1240
1241
|
}
|
|
1241
1242
|
),
|
|
1242
|
-
n > 1 ? Array.from({ length: n }, (a,
|
|
1243
|
+
n > 1 ? Array.from({ length: n }, (a, f) => /* @__PURE__ */ l(
|
|
1243
1244
|
ae,
|
|
1244
1245
|
{
|
|
1245
|
-
label: `View ${
|
|
1246
|
+
label: `View ${f + 1}${f === r ? " ✓" : ""}`,
|
|
1246
1247
|
onSelect: () => {
|
|
1247
|
-
u(), i(
|
|
1248
|
+
u(), i(f);
|
|
1248
1249
|
}
|
|
1249
1250
|
},
|
|
1250
|
-
|
|
1251
|
+
f
|
|
1251
1252
|
)) : null,
|
|
1252
1253
|
/* @__PURE__ */ l(
|
|
1253
1254
|
ae,
|
|
@@ -1364,7 +1365,7 @@ function Wt({
|
|
|
1364
1365
|
className: s,
|
|
1365
1366
|
style: d
|
|
1366
1367
|
}) {
|
|
1367
|
-
const [c, u] = C(!1), [a,
|
|
1368
|
+
const [c, u] = C(!1), [a, f] = C(0), [m, y] = C(!1), b = x(null), o = ct(), g = n[Math.min(a, n.length - 1)], w = F(async () => {
|
|
1368
1369
|
var D;
|
|
1369
1370
|
const v = await ((D = b.current) == null ? void 0 : D.exportArtboards({ format: "dataUrl" }));
|
|
1370
1371
|
if (!v) return;
|
|
@@ -1372,7 +1373,7 @@ function Wt({
|
|
|
1372
1373
|
if (typeof R != "string") return;
|
|
1373
1374
|
const _ = document.createElement("a");
|
|
1374
1375
|
_.href = R, _.download = `${V ?? "design"}.png`, _.click();
|
|
1375
|
-
}, []),
|
|
1376
|
+
}, []), p = {
|
|
1376
1377
|
display: "flex",
|
|
1377
1378
|
flexDirection: "column",
|
|
1378
1379
|
overflow: "hidden",
|
|
@@ -1414,7 +1415,7 @@ function Wt({
|
|
|
1414
1415
|
"data-sc-part": "snowcone-editor",
|
|
1415
1416
|
"data-sc-fullscreen": c ? "true" : void 0,
|
|
1416
1417
|
className: s,
|
|
1417
|
-
style:
|
|
1418
|
+
style: p,
|
|
1418
1419
|
children: [
|
|
1419
1420
|
/* @__PURE__ */ N(
|
|
1420
1421
|
"div",
|
|
@@ -1437,7 +1438,7 @@ function Wt({
|
|
|
1437
1438
|
onToggleFullscreen: () => u((v) => !v),
|
|
1438
1439
|
viewCount: n.length,
|
|
1439
1440
|
viewIndex: a,
|
|
1440
|
-
onSelectView:
|
|
1441
|
+
onSelectView: f,
|
|
1441
1442
|
onExport: () => void w()
|
|
1442
1443
|
}
|
|
1443
1444
|
),
|
|
@@ -1543,7 +1544,7 @@ function Wt({
|
|
|
1543
1544
|
}
|
|
1544
1545
|
);
|
|
1545
1546
|
}
|
|
1546
|
-
function
|
|
1547
|
+
function un(t) {
|
|
1547
1548
|
const {
|
|
1548
1549
|
onAddToCart: e,
|
|
1549
1550
|
defaultQuantity: n,
|
|
@@ -1569,18 +1570,18 @@ function cn(t) {
|
|
|
1569
1570
|
We();
|
|
1570
1571
|
export {
|
|
1571
1572
|
M as E,
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1573
|
+
an as R,
|
|
1574
|
+
un as S,
|
|
1575
|
+
sn as a,
|
|
1576
|
+
dn as b,
|
|
1577
|
+
on as c,
|
|
1577
1578
|
Re as d,
|
|
1578
1579
|
xt as e,
|
|
1579
1580
|
Ut as f,
|
|
1580
1581
|
Bt as g,
|
|
1581
|
-
|
|
1582
|
-
|
|
1582
|
+
ln as h,
|
|
1583
|
+
cn as p,
|
|
1583
1584
|
K as u,
|
|
1584
|
-
|
|
1585
|
+
pt as v
|
|
1585
1586
|
};
|
|
1586
|
-
//# sourceMappingURL=embed-
|
|
1587
|
+
//# sourceMappingURL=embed-Csez1hui.js.map
|