@snowcone-app/canvas 0.8.1 → 0.11.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/CanvasStateV1-D3THl2Zc.js +456 -0
- package/dist/CanvasStateV1-D3THl2Zc.js.map +1 -0
- package/dist/HybridHistoryManager-DANuzx7G.js.map +1 -1
- package/dist/advanced.mjs +2 -2
- package/dist/api/embed.d.ts +4 -0
- package/dist/api/stable.d.ts +6 -2
- package/dist/components/embed/SnowconeCanvas.d.ts +8 -0
- package/dist/contexts/CanvasServicesContext.d.ts +9 -2
- package/dist/design/design-builder.d.ts +23 -1
- package/dist/design/template-fields.d.ts +59 -0
- package/dist/embed.mjs +67 -63
- package/dist/embed.mjs.map +1 -1
- package/dist/fonts/google-fonts.d.ts +1 -6
- package/dist/hooks/useArtboards.d.ts +1 -0
- package/dist/hooks/useColorBinding.d.ts +21 -0
- package/dist/index.mjs +45 -40
- package/dist/internals.mjs +1 -1
- package/dist/rendering/serialize-for-server.d.ts +1 -0
- package/dist/schemas-B4UXytQB.js +3250 -0
- package/dist/schemas-B4UXytQB.js.map +1 -0
- package/dist/services/imageSearch.d.ts +30 -0
- package/dist/style.css +1 -1
- package/dist/template-fields-C8Tj67ek.js +1585 -0
- package/dist/template-fields-C8Tj67ek.js.map +1 -0
- package/dist/utils/UnifiedFontService.d.ts +9 -30
- package/dist/{validation-CZ4CZV5B.js → validation-C857Ptxn.js} +5804 -6344
- package/dist/validation-C857Ptxn.js.map +1 -0
- package/package.json +3 -3
- package/dist/CanvasStateV1-D7mGz8FR.js +0 -3692
- package/dist/CanvasStateV1-D7mGz8FR.js.map +0 -1
- package/dist/components/MonotypeDemoPage.d.ts +0 -2
- package/dist/design-builder-CM5wSK5w.js +0 -1467
- package/dist/design-builder-CM5wSK5w.js.map +0 -1
- package/dist/utils/MonotypeCategoryMapping.d.ts +0 -36
- package/dist/utils/MonotypeService.d.ts +0 -148
- package/dist/validation-CZ4CZV5B.js.map +0 -1
package/dist/advanced.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as te, I as q, r as re, v as ne,
|
|
2
|
-
import {
|
|
1
|
+
import { D as te, I as q, r as re, v as ne, i as oe, e as ae } from "./validation-C857Ptxn.js";
|
|
2
|
+
import { j as it, k as lt, l as ct, B as dt, m as ut, n as mt, o as ft, p as ht, q as pt, s as gt, t as xt, w as bt, x as yt, y as vt, F as wt, z as St, G as Ct, H as Tt, J as Et, K as $t, L as kt, N as At, O as Ft, Q as Pt, R as Nt, S as Rt, T as Bt, U as Mt, V as Dt, W as zt, X as It, Y as Ot, Z as Lt, _ as Wt, $ as Kt, a0 as _t, a1 as Gt, a2 as Ut, a3 as jt, a4 as Jt, a5 as qt, a6 as Vt, a7 as Xt, a8 as Yt, a9 as Zt, aa as Ht, ab as Qt, ac as er, ad as tr, ae as rr, af as nr } from "./validation-C857Ptxn.js";
|
|
3
3
|
import { u as V } from "./ThemeContext-U-VDtIiS.js";
|
|
4
4
|
import { E as ar, P as sr, T as ir, p as lr, s as cr, b as dr, c as ur, d as mr, e as fr, f as hr, g as pr, a as gr } from "./ThemeContext-U-VDtIiS.js";
|
|
5
5
|
import { c as se, G as ie, F as le, g as ce, r as de, u as ue } from "./HybridHistoryManager-DANuzx7G.js";
|
package/dist/api/embed.d.ts
CHANGED
|
@@ -48,7 +48,11 @@ export { design, DesignBuilder } from '../design/design-builder.js';
|
|
|
48
48
|
export type { Anchor, ShapeKind, DesignArtboard } from '../design/design-builder.js';
|
|
49
49
|
export { useTextBinding } from '../hooks/useTextBinding.js';
|
|
50
50
|
export { useImageBinding } from '../hooks/useImageBinding.js';
|
|
51
|
+
export { useColorBinding } from '../hooks/useColorBinding.js';
|
|
52
|
+
export type { ColorBindingResult } from '../hooks/useColorBinding.js';
|
|
51
53
|
export { useElementByName } from '../hooks/useElementByName.js';
|
|
54
|
+
export { readTemplateFields, withTemplateFields, TEMPLATE_FIELDS_KEY, } from '../design/template-fields.js';
|
|
55
|
+
export type { TemplateField, TemplateTextField, TemplateImageField, TemplateColorField, } from '../design/template-fields.js';
|
|
52
56
|
export { CanvasServicesProvider, useCanvasServices } from '../contexts/CanvasServicesContext.js';
|
|
53
57
|
export type { CanvasServices, ResolvedCanvasServices } from '../contexts/CanvasServicesContext.js';
|
|
54
58
|
export { createProxyImageSearch, createProxyGenerate } from '../services/imageSearch.js';
|
package/dist/api/stable.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export { SnowconeCanvas, SnowconeCanvas as default } from '../components/embed/S
|
|
|
10
10
|
export type { SnowconeCanvasProps, SnowconeCanvasHandle, ArtboardConfig, CanvasState, ClipShape, AlignmentPoint, ExportStatusEvent, ExportConfig, ImageConfig, LayoutConfig, CanvasCutoutShape } from '../components/embed/SnowconeCanvas.js';
|
|
11
11
|
export { CanvasServicesProvider, useCanvasServices } from '../contexts/CanvasServicesContext.js';
|
|
12
12
|
export type { CanvasServices, ResolvedCanvasServices, VectorSearchProvider, VectorSearchResult, } from '../contexts/CanvasServicesContext.js';
|
|
13
|
-
export { createProxyImageSearch, createProxyGenerate } from '../services/imageSearch.js';
|
|
14
|
-
export type { ImageSearchProvider, ImageSearchResult, ImageSearchResponse, ImageSearchParams, GenerateProvider, GenerateParams, GenerateResponse, } from '../services/imageSearch.js';
|
|
13
|
+
export { createProxyImageSearch, createProxyGenerate, createProxyBgRemove } from '../services/imageSearch.js';
|
|
14
|
+
export type { ImageSearchProvider, ImageSearchResult, ImageSearchResponse, ImageSearchParams, GenerateProvider, GenerateParams, GenerateResponse, BgRemoveProvider, } from '../services/imageSearch.js';
|
|
15
15
|
export { useEditor } from '../contexts/EditorContext.js';
|
|
16
16
|
export type { EditorContextValue, EditorProviderProps } from '../contexts/EditorContext.js';
|
|
17
17
|
export { useArtboards } from '../hooks/useArtboards.js';
|
|
@@ -30,6 +30,8 @@ export { useTextBinding } from '../hooks/useTextBinding.js';
|
|
|
30
30
|
export type { TextBindingResult } from '../hooks/useTextBinding.js';
|
|
31
31
|
export { useImageBinding } from '../hooks/useImageBinding.js';
|
|
32
32
|
export type { ImageBindingResult, ImageBindingOptions, ImageFitMode } from '../hooks/useImageBinding.js';
|
|
33
|
+
export { useColorBinding } from '../hooks/useColorBinding.js';
|
|
34
|
+
export type { ColorBindingResult } from '../hooks/useColorBinding.js';
|
|
33
35
|
export { useElementByName } from '../hooks/useElementByName.js';
|
|
34
36
|
export { useContentReady } from '../hooks/useContentReady.js';
|
|
35
37
|
export type { UseContentReadyOptions } from '../hooks/useContentReady.js';
|
|
@@ -48,4 +50,6 @@ export { serializeStateForServer, CANVAS_STATE_SCHEMA_VERSION, } from '../render
|
|
|
48
50
|
export type { ServerRenderRequest } from '../rendering/serialize-for-server.js';
|
|
49
51
|
export { design, DesignBuilder } from '../design/design-builder.js';
|
|
50
52
|
export type { Anchor, ShapeKind, DesignArtboard, BackgroundOptions, ImageOptions, TextOptions, ShapeOptions, } from '../design/design-builder.js';
|
|
53
|
+
export { readTemplateFields, withTemplateFields, TEMPLATE_FIELDS_KEY, } from '../design/template-fields.js';
|
|
54
|
+
export type { TemplateField, TemplateTextField, TemplateImageField, TemplateColorField, } from '../design/template-fields.js';
|
|
51
55
|
export type { CanvasStateV1, SerializedArtboard, SerializedElement, DeserializeResult, ValidationResult, } from '../state/index.js';
|
|
@@ -33,6 +33,14 @@ export interface ArtboardConfig {
|
|
|
33
33
|
clipShape?: ClipShape;
|
|
34
34
|
/** Optional background color */
|
|
35
35
|
backgroundColor?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the background color is part of the design — painted in exports
|
|
38
|
+
* and server renders (realtime mockups), not just in the editor. Defaults to
|
|
39
|
+
* `true` when `backgroundColor` is explicitly set (and not 'transparent'),
|
|
40
|
+
* `false` otherwise: an author who sets a background expects the mockup to
|
|
41
|
+
* match the editor.
|
|
42
|
+
*/
|
|
43
|
+
exportBackground?: boolean;
|
|
36
44
|
/** Scale mode for initial image: "cover" fills area (may crop), "contain" fits inside (may have space). Default: "cover" */
|
|
37
45
|
scaleMode?: 'cover' | 'contain';
|
|
38
46
|
/** Top margin in pixels for contain mode (reduces available area) */
|
|
@@ -58,8 +58,15 @@ export interface CanvasServices {
|
|
|
58
58
|
/** Vector/icon search provider (dev playground only — no wire contract yet). */
|
|
59
59
|
vectors?: VectorSearchProvider;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* URL of your background-removal proxy route (`POST { imageUrl }` →
|
|
62
|
+
* `{ imageUrl }`; see `createProxyBgRemove` for the wire contract). Host this
|
|
63
|
+
* URL on your server; your bg-remove vendor key lives there.
|
|
64
|
+
*/
|
|
65
|
+
bgRemoveUrl?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Advanced override: full background-removal provider. Given an image URL
|
|
68
|
+
* (or data URL), resolve to the processed image URL/data URL. Wins over
|
|
69
|
+
* `bgRemoveUrl`.
|
|
63
70
|
*/
|
|
64
71
|
removeBackground?: (imageUrl: string) => Promise<string>;
|
|
65
72
|
}
|
|
@@ -11,7 +11,8 @@ export interface DesignArtboard {
|
|
|
11
11
|
name?: string;
|
|
12
12
|
width: number;
|
|
13
13
|
height: number;
|
|
14
|
-
/** Optional solid background fill behind all elements.
|
|
14
|
+
/** Optional solid background fill behind all elements. Rendered everywhere
|
|
15
|
+
* the design is — editor, exports, and server renders (realtime mockups). */
|
|
15
16
|
backgroundColor?: string;
|
|
16
17
|
}
|
|
17
18
|
/** A stable layer name. Set it so you can bind the layer in an interactive
|
|
@@ -77,6 +78,26 @@ export declare class DesignBuilder {
|
|
|
77
78
|
private readonly els;
|
|
78
79
|
private idCounter;
|
|
79
80
|
constructor(artboard: DesignArtboard);
|
|
81
|
+
/**
|
|
82
|
+
* Seed a builder from a previously saved canvas state — the editor shape
|
|
83
|
+
* `<SnowconeCanvas onChange>` emits (and `toJSON()` produces).
|
|
84
|
+
*
|
|
85
|
+
* This is how a saved editable template re-enters the turnkey embed path:
|
|
86
|
+
* load the template's state JSON, lift it back into a `DesignBuilder`, and
|
|
87
|
+
* hand it to `<RealtimeEmbed design={…}>`. The active artboard becomes the
|
|
88
|
+
* builder's artboard; elements tagged for other artboards are skipped
|
|
89
|
+
* (untagged elements are assumed to belong to the active one).
|
|
90
|
+
*/
|
|
91
|
+
static fromState(state: {
|
|
92
|
+
elements: AnyElementConfig[];
|
|
93
|
+
artboards: Array<{
|
|
94
|
+
name: string;
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
backgroundColor?: string;
|
|
98
|
+
}>;
|
|
99
|
+
activeArtboard: string;
|
|
100
|
+
}): DesignBuilder;
|
|
80
101
|
private nextId;
|
|
81
102
|
/** Full-bleed background image (fills the whole artboard). Cover-fit (no
|
|
82
103
|
* distortion) when `aspectRatio` is supplied. Inserted at the bottom of the
|
|
@@ -100,6 +121,7 @@ export declare class DesignBuilder {
|
|
|
100
121
|
width: number;
|
|
101
122
|
height: number;
|
|
102
123
|
backgroundColor?: string;
|
|
124
|
+
exportBackground?: boolean;
|
|
103
125
|
}>;
|
|
104
126
|
activeArtboard: string;
|
|
105
127
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ImageFitMode } from '../hooks/useImageBinding.js';
|
|
2
|
+
/** A buyer-editable text slot, bound to elements by their `name` property. */
|
|
3
|
+
export interface TemplateTextField {
|
|
4
|
+
type: 'text';
|
|
5
|
+
/** Element name (matches canvas layer `name` property). */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Label shown to the buyer (e.g. "Your name"). */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Placeholder text for the input. */
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
}
|
|
12
|
+
/** A buyer-swappable image slot, bound to elements by their `name` property. */
|
|
13
|
+
export interface TemplateImageField {
|
|
14
|
+
type: 'image';
|
|
15
|
+
/** Element name (matches canvas layer `name` property). */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Label shown to the buyer (e.g. "Upload your logo"). */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Placeholder text for the input. */
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
/** How the buyer's image fits the original element bounds. Default: "cover". */
|
|
22
|
+
fit?: ImageFitMode;
|
|
23
|
+
}
|
|
24
|
+
/** A buyer-editable color, matched by value across all elements that use it. */
|
|
25
|
+
export interface TemplateColorField {
|
|
26
|
+
type: 'color';
|
|
27
|
+
/** Original hex color to match (e.g. "#FF0000"). */
|
|
28
|
+
color: string;
|
|
29
|
+
/** Label shown to the buyer (e.g. "Accent color"). */
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
/** One buyer-editable aspect of a template. */
|
|
33
|
+
export type TemplateField = TemplateTextField | TemplateImageField | TemplateColorField;
|
|
34
|
+
/**
|
|
35
|
+
* The key template fields are stored under on the state document.
|
|
36
|
+
* Kept as `personalization` for compatibility with designs saved on snowcone.app.
|
|
37
|
+
*/
|
|
38
|
+
export declare const TEMPLATE_FIELDS_KEY = "personalization";
|
|
39
|
+
/**
|
|
40
|
+
* Read the template fields off a parsed state document.
|
|
41
|
+
*
|
|
42
|
+
* Accepts any JSON value — a `CanvasState` from `onChange`, a `CanvasStateV1`
|
|
43
|
+
* document, or a raw `JSON.parse` of a stored state file. Legacy fields with
|
|
44
|
+
* no `type` are normalized to text fields; malformed entries are dropped.
|
|
45
|
+
* Returns `[]` when the document carries no fields (a plain, non-template design).
|
|
46
|
+
*/
|
|
47
|
+
export declare function readTemplateFields(state: unknown): TemplateField[];
|
|
48
|
+
/**
|
|
49
|
+
* Attach template fields to a state document before persisting it.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* onChange={(state) => setDraft(state)}
|
|
53
|
+
* // …on save:
|
|
54
|
+
* save(JSON.stringify(withTemplateFields(draft, fields)));
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function withTemplateFields<T extends object>(state: T, fields: TemplateField[]): T & {
|
|
58
|
+
[TEMPLATE_FIELDS_KEY]: TemplateField[];
|
|
59
|
+
};
|
package/dist/embed.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { y as
|
|
1
|
+
import { a as K, e as z } from "./validation-C857Ptxn.js";
|
|
2
|
+
import { b as pe, d as ve, f as be } from "./validation-C857Ptxn.js";
|
|
3
|
+
import { y as T } from "./HybridHistoryManager-DANuzx7G.js";
|
|
4
4
|
import { jsx as b, Fragment as J } from "react/jsx-runtime";
|
|
5
|
-
import { createContext as W, useContext as H, useMemo as
|
|
6
|
-
import { assertVariantSelected as
|
|
7
|
-
import { S as
|
|
8
|
-
import { D as $e, d as ke,
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
const e = H(
|
|
5
|
+
import { createContext as W, useContext as H, useMemo as E, useRef as C, useState as q, useEffect as M } from "react";
|
|
6
|
+
import { assertVariantSelected as Y, RenderSession as Q } from "@snowcone-app/sdk";
|
|
7
|
+
import { S as X, s as Z } from "./template-fields-C8Tj67ek.js";
|
|
8
|
+
import { D as Ee, T as $e, d as Se, r as ke, a as Re, e as Te, f as we, g as xe, w as Ie } from "./template-fields-C8Tj67ek.js";
|
|
9
|
+
const V = W(void 0);
|
|
10
|
+
function B() {
|
|
11
|
+
const e = H(V);
|
|
12
12
|
if (!e)
|
|
13
13
|
throw new Error(
|
|
14
14
|
"useRealtimeMockups / <RealtimeCanvas> / <RealtimeMockup> must be rendered inside <RealtimeEmbed>. Wrap them: <RealtimeEmbed shop=… product=… design=… grantUrl=…>…</RealtimeEmbed>"
|
|
@@ -17,33 +17,33 @@ function N() {
|
|
|
17
17
|
}
|
|
18
18
|
const p = "[RealtimeEmbed]";
|
|
19
19
|
function ee(e) {
|
|
20
|
-
var a,
|
|
20
|
+
var a, i;
|
|
21
21
|
if ((a = e == null ? void 0 : e.requiredPlacements) != null && a.length)
|
|
22
22
|
return e.requiredPlacements.filter((t) => !t.autoFilledByVariant).map((t) => t.label);
|
|
23
23
|
const n = new Set(
|
|
24
|
-
(((
|
|
24
|
+
(((i = e == null ? void 0 : e.options) == null ? void 0 : i.combinations) ?? []).map((t) => t.variantId).filter((t) => typeof t == "string" && t !== "")
|
|
25
25
|
);
|
|
26
26
|
return !!(e != null && e.variantId) || n.size > 1 ? [] : (e == null ? void 0 : e.placements) ?? [];
|
|
27
27
|
}
|
|
28
28
|
function ne({ shop: e, product: n, design: s, hasGrant: a }) {
|
|
29
|
-
var v,
|
|
29
|
+
var v, o;
|
|
30
30
|
if (e || console.error(`${p} \`shop\` is required (your publishable shop id).`), a || console.error(
|
|
31
31
|
`${p} no grant source — pass \`grantUrl\` (a proxy to mintRealtimeGrant) or \`grant\`. Without it the session can never authorize and no mockup renders.`
|
|
32
32
|
), (v = n == null ? void 0 : n.mockupIds) != null && v.length || console.error(
|
|
33
33
|
`${p} product.mockupIds is empty — pass the catalog scene codes (product.mockups[].id) you want rendered, e.g. ["FV1qjO"].`
|
|
34
34
|
), n != null && n.options)
|
|
35
35
|
try {
|
|
36
|
-
|
|
36
|
+
Y(n);
|
|
37
37
|
} catch (r) {
|
|
38
38
|
console.error(`${p} ${r instanceof Error ? r.message : String(r)}`);
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const i = s.toJSON(), t = i.activeArtboard, d = ee(n);
|
|
41
41
|
d.length > 1 && console.error(
|
|
42
42
|
`${p} product ${n.productId} requires placements [${d.join(", ")}] but <RealtimeEmbed> renders a single placement ("${t}"). The render will time out waiting for the others. This product needs the eject path — see https://developers.snowcone.app/embed-mode#eject.`
|
|
43
|
-
), (
|
|
43
|
+
), (o = n == null ? void 0 : n.placements) != null && o.length && !n.placements.includes(t) && console.warn(
|
|
44
44
|
`${p} the design's placement "${t}" is not in product.placements [${n.placements.join(", ")}]. The canvas artboard name and renderState placement must equal a real product placement label, or the server renders a blank mockup. Fix the \`name\` passed to design({ name }).`
|
|
45
45
|
);
|
|
46
|
-
const c =
|
|
46
|
+
const c = i.elements.map((r) => r.name).filter((r) => !!r), h = c.filter((r, l) => c.indexOf(r) !== l);
|
|
47
47
|
h.length && console.warn(
|
|
48
48
|
`${p} duplicate layer name(s) [${[...new Set(h)].join(", ")}] — useTextBinding(name) / useImageBinding(name) bind to the FIRST match, so a duplicate name makes a control edit the wrong layer. Keep names unique.`
|
|
49
49
|
);
|
|
@@ -54,39 +54,39 @@ function te(e) {
|
|
|
54
54
|
const n = e.grant;
|
|
55
55
|
return typeof n == "function" ? { getToken: n } : { getToken: () => Promise.resolve(n) };
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const _ = 8e3;
|
|
58
58
|
function re(e) {
|
|
59
|
-
return `[RealtimeEmbed] No mockup after ${Math.round(
|
|
59
|
+
return `[RealtimeEmbed] No mockup after ${Math.round(_ / 1e3)}s. Common causes: a variant product missing \`variantId\` (pass \`product.options\` so the embed can flag it up front), a multi-placement product (the server waits for every required placement but <RealtimeEmbed> sends only "${e}" — pass \`product.requiredPlacements\` so this is flagged at mount; such products need the eject path), an unreachable or non-public asset URL in the design, or the placement "${e}" not existing on the product. The render may still arrive — this is a heads-up, not a failure.`;
|
|
60
60
|
}
|
|
61
61
|
function me(e) {
|
|
62
|
-
const { shop: n, product: s, design: a, throttleMs:
|
|
62
|
+
const { shop: n, product: s, design: a, throttleMs: i = 200, onMockups: t, onRenderError: d, wsUrl: c, services: h, children: v } = e, o = E(() => a.toJSON().activeArtboard, [a]), r = C(t), l = C(d);
|
|
63
63
|
r.current = t, l.current = d;
|
|
64
|
-
const [
|
|
64
|
+
const [N, D] = q([]), [$, y] = q(!0), [j, S] = q(null), w = !!("grantUrl" in e && e.grantUrl || "grant" in e && e.grant), x = te(e), L = "grantUrl" in x ? x.grantUrl : "getToken", I = `${s.productId}|${s.mockupIds.join(",")}|${s.variantId ?? ""}`, k = E(
|
|
65
65
|
() => {
|
|
66
66
|
try {
|
|
67
|
-
return { session: new
|
|
67
|
+
return { session: new Q({ shop: n, product: s, wsUrl: c, ...x }) };
|
|
68
68
|
} catch (m) {
|
|
69
69
|
return { error: m instanceof Error ? m.message : String(m) };
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
-
[n,
|
|
74
|
-
), g = "session" in
|
|
73
|
+
[n, I, o, c, L]
|
|
74
|
+
), g = "session" in k ? k.session : null, R = "error" in k ? k.error : null, P = C(null);
|
|
75
75
|
M(() => {
|
|
76
76
|
var m;
|
|
77
|
-
if (typeof
|
|
78
|
-
const u = `${n}|${
|
|
77
|
+
if (typeof T < "u" && ((m = T.env) == null ? void 0 : m.NODE_ENV) !== "production") {
|
|
78
|
+
const u = `${n}|${I}|${o}|${w}`;
|
|
79
79
|
if (P.current === u) return;
|
|
80
80
|
P.current = u, ne({ shop: n, product: s, design: a, hasGrant: w });
|
|
81
81
|
}
|
|
82
|
-
}, [n,
|
|
83
|
-
const
|
|
84
|
-
g && (S(null), y(!0), g.renderState(
|
|
82
|
+
}, [n, I, o, w]);
|
|
83
|
+
const U = E(() => (m, u = i) => {
|
|
84
|
+
g && (S(null), y(!0), g.renderState(o, m, u).catch((f) => {
|
|
85
85
|
var A;
|
|
86
|
-
const
|
|
87
|
-
S(
|
|
86
|
+
const O = f instanceof Error ? f.message : String(f);
|
|
87
|
+
S(O), y(!1), (A = l.current) == null || A.call(l, O);
|
|
88
88
|
}));
|
|
89
|
-
}, [g,
|
|
89
|
+
}, [g, o, i]);
|
|
90
90
|
M(() => {
|
|
91
91
|
var m;
|
|
92
92
|
if (R) {
|
|
@@ -96,55 +96,55 @@ function me(e) {
|
|
|
96
96
|
if (g)
|
|
97
97
|
return g.onMockups((u) => {
|
|
98
98
|
var f;
|
|
99
|
-
|
|
99
|
+
D(u), y(!1), (f = r.current) == null || f.call(r, u);
|
|
100
100
|
}), g.onError((u) => {
|
|
101
101
|
var f;
|
|
102
102
|
S(u), y(!1), (f = l.current) == null || f.call(l, u);
|
|
103
|
-
}),
|
|
103
|
+
}), U(a.toServerRequest()), () => g.close();
|
|
104
104
|
}, [g, R]), M(() => {
|
|
105
105
|
var u;
|
|
106
|
-
if (
|
|
107
|
-
const m = setTimeout(() => console.warn(re(
|
|
106
|
+
if (!$ || typeof T > "u" || ((u = T.env) == null ? void 0 : u.NODE_ENV) === "production") return;
|
|
107
|
+
const m = setTimeout(() => console.warn(re(o)), _);
|
|
108
108
|
return () => clearTimeout(m);
|
|
109
|
-
}, [
|
|
110
|
-
const
|
|
109
|
+
}, [$, o]);
|
|
110
|
+
const G = E(
|
|
111
111
|
() => ({
|
|
112
112
|
session: g,
|
|
113
113
|
design: a,
|
|
114
|
-
placement:
|
|
114
|
+
placement: o,
|
|
115
115
|
product: s,
|
|
116
|
-
mockups:
|
|
117
|
-
isRendering:
|
|
118
|
-
error:
|
|
119
|
-
throttleMs:
|
|
120
|
-
pushRender:
|
|
116
|
+
mockups: N,
|
|
117
|
+
isRendering: $,
|
|
118
|
+
error: j,
|
|
119
|
+
throttleMs: i,
|
|
120
|
+
pushRender: U
|
|
121
121
|
}),
|
|
122
|
-
[g, a,
|
|
123
|
-
),
|
|
124
|
-
return h ? /* @__PURE__ */ b(
|
|
122
|
+
[g, a, o, s, N, $, j, i, U]
|
|
123
|
+
), F = /* @__PURE__ */ b(V.Provider, { value: G, children: v });
|
|
124
|
+
return h ? /* @__PURE__ */ b(K, { services: h, children: F }) : F;
|
|
125
125
|
}
|
|
126
126
|
function ue({
|
|
127
127
|
children: e,
|
|
128
128
|
kit: n = "embed-only",
|
|
129
129
|
inheritTheme: s = !0,
|
|
130
130
|
maxHeight: a,
|
|
131
|
-
services:
|
|
131
|
+
services: i,
|
|
132
132
|
className: t,
|
|
133
133
|
style: d
|
|
134
134
|
}) {
|
|
135
|
-
const { design: c, placement: h, throttleMs: v, pushRender:
|
|
135
|
+
const { design: c, placement: h, throttleMs: v, pushRender: o } = B(), r = E(() => c.toJSON(), [c]);
|
|
136
136
|
return /* @__PURE__ */ b("div", { className: `app-modern${t ? ` ${t}` : ""}`, style: d, children: /* @__PURE__ */ b(
|
|
137
|
-
|
|
137
|
+
X,
|
|
138
138
|
{
|
|
139
139
|
kit: n,
|
|
140
140
|
inheritTheme: s,
|
|
141
|
-
services:
|
|
141
|
+
services: i,
|
|
142
142
|
artboards: r.artboards,
|
|
143
143
|
activeArtboard: h,
|
|
144
144
|
initialElements: r.elements,
|
|
145
145
|
layoutConfig: a ? { maxHeight: a } : void 0,
|
|
146
146
|
overlay: e,
|
|
147
|
-
onChange: (l) =>
|
|
147
|
+
onChange: (l) => o(Z(l), v)
|
|
148
148
|
}
|
|
149
149
|
) });
|
|
150
150
|
}
|
|
@@ -153,33 +153,37 @@ function de({
|
|
|
153
153
|
fallback: n = null,
|
|
154
154
|
alt: s = "Live product mockup",
|
|
155
155
|
className: a,
|
|
156
|
-
style:
|
|
156
|
+
style: i
|
|
157
157
|
}) {
|
|
158
|
-
const { mockups: t } =
|
|
158
|
+
const { mockups: t } = B(), d = e ? t.find((c) => c.mockupId === e && c.imageUrl) : t.find((c) => c.imageUrl);
|
|
159
159
|
return d != null && d.imageUrl ? (
|
|
160
160
|
// eslint-disable-next-line @next/next/no-img-element
|
|
161
|
-
/* @__PURE__ */ b("img", { src: d.imageUrl, alt: s, className: a, style:
|
|
161
|
+
/* @__PURE__ */ b("img", { src: d.imageUrl, alt: s, className: a, style: i })
|
|
162
162
|
) : /* @__PURE__ */ b(J, { children: n });
|
|
163
163
|
}
|
|
164
164
|
function ge() {
|
|
165
|
-
const { mockups: e, isRendering: n, error: s } =
|
|
165
|
+
const { mockups: e, isRendering: n, error: s } = B();
|
|
166
166
|
return { mockups: e, isRendering: n, error: s };
|
|
167
167
|
}
|
|
168
168
|
z();
|
|
169
169
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
K as CanvasServicesProvider,
|
|
171
|
+
Ee as DesignBuilder,
|
|
172
172
|
ue as RealtimeCanvas,
|
|
173
173
|
me as RealtimeEmbed,
|
|
174
174
|
de as RealtimeMockup,
|
|
175
|
+
$e as TEMPLATE_FIELDS_KEY,
|
|
175
176
|
pe as createProxyGenerate,
|
|
176
177
|
ve as createProxyImageSearch,
|
|
177
|
-
|
|
178
|
+
Se as design,
|
|
179
|
+
ke as readTemplateFields,
|
|
178
180
|
be as useCanvasServices,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
Re as useColorBinding,
|
|
182
|
+
Te as useElementByName,
|
|
183
|
+
we as useImageBinding,
|
|
181
184
|
ge as useRealtimeMockups,
|
|
182
|
-
|
|
183
|
-
ne as validateEmbed
|
|
185
|
+
xe as useTextBinding,
|
|
186
|
+
ne as validateEmbed,
|
|
187
|
+
Ie as withTemplateFields
|
|
184
188
|
};
|
|
185
189
|
//# sourceMappingURL=embed.mjs.map
|