@snowcone-app/canvas 0.19.1 → 0.20.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/{CanvasRenderer-DUc-MOeR.js → CanvasRenderer-CwiYq8qg.js} +3 -3
- package/dist/{CanvasRenderer-DUc-MOeR.js.map → CanvasRenderer-CwiYq8qg.js.map} +1 -1
- package/dist/{CanvasStateV1-Bq48qhv5.js → CanvasStateV1-BFabcAKC.js} +35 -30
- package/dist/{CanvasStateV1-Bq48qhv5.js.map → CanvasStateV1-BFabcAKC.js.map} +1 -1
- package/dist/{ContextualToolbars-CkLjHNPn.js → ContextualToolbars--vTtorNg.js} +5 -5
- package/dist/{ContextualToolbars-CkLjHNPn.js.map → ContextualToolbars--vTtorNg.js.map} +1 -1
- package/dist/{EditorCanvasImpl-_3xCnLkx.js → EditorCanvasImpl-UBKdG0c0.js} +18 -17
- package/dist/{EditorCanvasImpl-_3xCnLkx.js.map → EditorCanvasImpl-UBKdG0c0.js.map} +1 -1
- package/dist/{ImportManager-D--7JnvW.js → ExportManager-DK7CdI-G.js} +24758 -24758
- package/dist/ExportManager-DK7CdI-G.js.map +1 -0
- package/dist/{FontAnalyzer-DIlqmyuf.js → FontAnalyzer-BpsTYowD.js} +5 -2
- package/dist/FontAnalyzer-BpsTYowD.js.map +1 -0
- package/dist/SnowconeCanvas-B01o5LmS.js +1172 -0
- package/dist/SnowconeCanvas-B01o5LmS.js.map +1 -0
- package/dist/{MenuButton-CeoEAtzP.js → UnifiedFontService-B1PGVu8O.js} +3704 -3429
- package/dist/UnifiedFontService-B1PGVu8O.js.map +1 -0
- package/dist/advanced.mjs +13 -13
- package/dist/api/embed.d.ts +3 -1
- package/dist/api/stable.d.ts +2 -2
- package/dist/components/embed/SnowconeCanvas.d.ts +10 -2
- package/dist/core/ArtboardElement.d.ts +2 -1
- package/dist/default-editor/SnowconeEditor.d.ts +39 -0
- package/dist/design/design-builder.d.ts +44 -19
- package/dist/design/template-fields.d.ts +32 -0
- package/dist/design-builder-DMKx9UXD.js +368 -0
- package/dist/design-builder-DMKx9UXD.js.map +1 -0
- package/dist/{EditorContext-5QpqAhjh.js → editorErrors-CK1RISFa.js} +382 -358
- package/dist/editorErrors-CK1RISFa.js.map +1 -0
- package/dist/embed-uALcVSYN.js +1117 -0
- package/dist/embed-uALcVSYN.js.map +1 -0
- package/dist/embed.mjs +33 -31
- package/dist/hooks/useArtboards.d.ts +2 -1
- package/dist/index.mjs +8 -8
- package/dist/internals.mjs +5 -5
- package/dist/kits/sections.d.ts +11 -7
- package/dist/rendering/serialize-for-server.d.ts +3 -0
- package/dist/state/CanvasStateV1.d.ts +12 -0
- package/dist/template-fields-B9RagVpT.js +476 -0
- package/dist/template-fields-B9RagVpT.js.map +1 -0
- package/dist/testing.mjs +8 -8
- package/dist/types/index.d.ts +10 -0
- package/dist/{usePieceGuideBundle-DVOISsB1.js → usePieceGuideBundle-Ctnu5k2D.js} +2 -2
- package/dist/{usePieceGuideBundle-DVOISsB1.js.map → usePieceGuideBundle-Ctnu5k2D.js.map} +1 -1
- package/dist/{validation-0IscSfRb.js → validation-3YEMnKLB.js} +467 -463
- package/dist/validation-3YEMnKLB.js.map +1 -0
- package/package.json +6 -5
- package/dist/EditorContext-5QpqAhjh.js.map +0 -1
- package/dist/FontAnalyzer-DIlqmyuf.js.map +0 -1
- package/dist/ImportManager-D--7JnvW.js.map +0 -1
- package/dist/MenuButton-CeoEAtzP.js.map +0 -1
- package/dist/SnowconeCanvas-3PA17na3.js +0 -1166
- package/dist/SnowconeCanvas-3PA17na3.js.map +0 -1
- package/dist/design-builder-v4935TeS.js +0 -343
- package/dist/design-builder-v4935TeS.js.map +0 -1
- package/dist/editorErrors-DXNfVXtD.js +0 -29
- package/dist/editorErrors-DXNfVXtD.js.map +0 -1
- package/dist/embed-D2QOpJXG.js +0 -1090
- package/dist/embed-D2QOpJXG.js.map +0 -1
- package/dist/template-fields-Dr3fMItw.js +0 -329
- package/dist/template-fields-Dr3fMItw.js.map +0 -1
- package/dist/validation-0IscSfRb.js.map +0 -1
package/dist/testing.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as A, g as m } from "./editorErrors-CK1RISFa.js";
|
|
2
|
+
import { l as ie, m as oe, n as ae } from "./editorErrors-CK1RISFa.js";
|
|
2
3
|
import { fetchMockupImage as S, isSnowconeSdkError as b, RenderSession as _, mintRealtimeGrant as R } from "@snowcone-app/sdk";
|
|
3
|
-
import { s as I, d as
|
|
4
|
-
import { E as y, g as m } from "./EditorContext-5QpqAhjh.js";
|
|
4
|
+
import { s as I, d as y } from "./design-builder-DMKx9UXD.js";
|
|
5
5
|
import { jsx as u } from "react/jsx-runtime";
|
|
6
6
|
import { useState as D } from "react";
|
|
7
7
|
import { T as p } from "./ThemeContext-Rjz25x9X.js";
|
|
8
|
-
import { E as T, A as k, g as F, I as x } from "./FontAnalyzer-
|
|
8
|
+
import { E as T, A as k, g as F, I as x } from "./FontAnalyzer-BpsTYowD.js";
|
|
9
9
|
const G = ({
|
|
10
10
|
children: t,
|
|
11
11
|
initialElements: n = [],
|
|
@@ -32,7 +32,7 @@ const G = ({
|
|
|
32
32
|
}), a;
|
|
33
33
|
});
|
|
34
34
|
return /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(
|
|
35
|
-
|
|
35
|
+
A,
|
|
36
36
|
{
|
|
37
37
|
initialArtboardConfig: o,
|
|
38
38
|
children: t
|
|
@@ -44,7 +44,7 @@ const G = ({
|
|
|
44
44
|
initialSelection: e = null,
|
|
45
45
|
initialMultiSelection: r = [],
|
|
46
46
|
initialArtboardConfig: i = {}
|
|
47
|
-
}) => /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(
|
|
47
|
+
}) => /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(A, { initialArtboardConfig: i, children: t }) });
|
|
48
48
|
function W(t = "custom", n = {}) {
|
|
49
49
|
const e = F(t);
|
|
50
50
|
if (!e || !e.Component)
|
|
@@ -223,10 +223,10 @@ async function X(t, n, e) {
|
|
|
223
223
|
}
|
|
224
224
|
const v = "https://assets.test-403.invalid/denied.png";
|
|
225
225
|
function Z() {
|
|
226
|
-
return
|
|
226
|
+
return y({ name: "Front", width: 1e3, height: 1e3 }).background(v, { aspectRatio: 1, name: "art" }).text("ALLOWLIST DENIAL FIXTURE", { anchor: "top", name: "headline" });
|
|
227
227
|
}
|
|
228
228
|
function ee() {
|
|
229
|
-
return
|
|
229
|
+
return y({ name: "Front", width: 1e3, height: 1e3 }).text("YOUR NAME", { anchor: "center", name: "name" });
|
|
230
230
|
}
|
|
231
231
|
function te(t = "failing-grant fixture: grant endpoint unavailable") {
|
|
232
232
|
return () => Promise.reject(new Error(t));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -568,6 +568,15 @@ export type ClipShape = 'rectangle' | 'circle' | {
|
|
|
568
568
|
baseHeight?: number;
|
|
569
569
|
}>;
|
|
570
570
|
};
|
|
571
|
+
/**
|
|
572
|
+
* Pacing role of an artboard in a multi-page template (ADR-0086 albums).
|
|
573
|
+
*
|
|
574
|
+
* Client/template metadata: auto-fill uses it to know which spreads clone as
|
|
575
|
+
* the page count grows (`repeating`) and which stay fixed (`cover` /
|
|
576
|
+
* `front-matter` / `back-matter`). It never reaches the server render wire —
|
|
577
|
+
* `serializeStateForServer` strips it like the element `artboard` membership tag.
|
|
578
|
+
*/
|
|
579
|
+
export type ArtboardRole = 'cover' | 'front-matter' | 'repeating' | 'back-matter';
|
|
571
580
|
export interface ArtboardConfig {
|
|
572
581
|
id?: string;
|
|
573
582
|
name?: string;
|
|
@@ -581,6 +590,7 @@ export interface ArtboardConfig {
|
|
|
581
590
|
exportBackground?: boolean;
|
|
582
591
|
elementIds?: string[];
|
|
583
592
|
transformType?: 'artboard';
|
|
593
|
+
role?: ArtboardRole;
|
|
584
594
|
clipShape?: ClipShape;
|
|
585
595
|
previewBackgroundColor?: string;
|
|
586
596
|
distressTexture?: ArtboardDistressTexture;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { y as r } from "./FontAnalyzer-
|
|
1
|
+
import { y as r } from "./FontAnalyzer-BpsTYowD.js";
|
|
2
2
|
import { useState as a, useEffect as d } from "react";
|
|
3
3
|
const u = "https://api.snowcone.app";
|
|
4
4
|
function h(e) {
|
|
@@ -58,4 +58,4 @@ export {
|
|
|
58
58
|
l as p,
|
|
59
59
|
p as u
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=usePieceGuideBundle-
|
|
61
|
+
//# sourceMappingURL=usePieceGuideBundle-Ctnu5k2D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePieceGuideBundle-
|
|
1
|
+
{"version":3,"file":"usePieceGuideBundle-Ctnu5k2D.js","sources":["../src/components/embed-realtime/usePieceGuideBundle.ts"],"sourcesContent":["'use client';\n\n/**\n * usePieceGuideBundle — fetch a product's printable-area guides for the embed.\n *\n * Some products hide part of the print file under hardware (a phone case's\n * camera module, a notebook's spine). snowcone.app's own editor draws the\n * printable-area / dead-zone overlay from the product's piece guides;\n * `<RealtimeEmbed>` uses this hook so embedders get the same overlay with\n * zero config — without it, a buyer can edit artwork the mockup will never\n * show, with no signal anywhere (#566).\n *\n * The endpoint is a public read (geometry only — piece rects, safe areas,\n * authored guides; same exposure class as the public catalog). Errors degrade\n * silently to \"no guides\": the editor keeps working, the overlay just doesn't\n * appear — same posture as snowcone.app's own loader.\n *\n * @module\n */\n\nimport { useEffect, useState } from 'react';\nimport type { PieceGuidesConfig } from '../embed/SnowconeCanvas.js';\nimport type {\n PieceGuide,\n PieceGuideRendererPiece,\n PieceGuideRendererStyle,\n} from '../../rendering/PieceGuideRenderer.js';\n\n/** Backend base hosting `GET /printables/by-gvid/:gvid/piece-guides`. */\nexport const PIECE_GUIDES_API_BASE = 'https://api.snowcone.app';\n\n/** Wire shape of the piece-guides endpoint (the consumer-safe subset). */\ninterface RawPieceGuidesResponse {\n artboardWidth: number;\n artboardHeight: number;\n /** Inches→px conversion factor for `safeAreaInsetInches`. */\n templateDpi: number;\n pieces: Array<{\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n safeAreaInsetInches?: number;\n }>;\n pieceGuides?: Record<string, PieceGuide>;\n pieceGuidesStyle?: PieceGuideRendererStyle;\n}\n\n/** A fetched bundle: the overlay config plus the artboard frame it was authored in. */\nexport interface PieceGuideBundle {\n /** The print-file frame the piece coords live in. */\n artboardWidth: number;\n artboardHeight: number;\n config: PieceGuidesConfig;\n}\n\n/** Convert the wire response into a renderer-ready bundle (inches → px, etc.). */\nexport function transformPieceGuides(raw: RawPieceGuidesResponse): PieceGuideBundle {\n const pieces: PieceGuideRendererPiece[] = raw.pieces.map((p) => ({\n id: p.id,\n x: p.x,\n y: p.y,\n width: p.width,\n height: p.height,\n rotation: typeof p.rotation === 'number' ? p.rotation : undefined,\n safeAreaInsetPx:\n typeof p.safeAreaInsetInches === 'number' && p.safeAreaInsetInches > 0\n ? p.safeAreaInsetInches * raw.templateDpi\n : undefined,\n }));\n return {\n artboardWidth: raw.artboardWidth,\n artboardHeight: raw.artboardHeight,\n config: {\n pieces,\n guides: raw.pieceGuides ?? {},\n style: raw.pieceGuidesStyle,\n },\n };\n}\n\n/**\n * Gate the bundle on the design's artboard matching the print-file frame the\n * guides were authored in — the same gate snowcone.app's editor applies. A\n * design authored at other dims would render the overlay misaligned, so it's\n * skipped (with a dev hint, since the fix — author at the placement's dims —\n * is on the embedder's side).\n */\nexport function pieceGuidesForArtboard(\n bundle: PieceGuideBundle,\n artboard: { width: number; height: number } | undefined,\n): PieceGuidesConfig | undefined {\n if (!artboard) return undefined;\n if (artboard.width !== bundle.artboardWidth || artboard.height !== bundle.artboardHeight) {\n if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {\n console.warn(\n `[RealtimeEmbed] This product has printable-area guides (authored at ` +\n `${bundle.artboardWidth}×${bundle.artboardHeight}), but the design's artboard is ` +\n `${artboard.width}×${artboard.height} — the dead-zone overlay is skipped because the ` +\n `coordinates wouldn't line up. Author the design at the placement's dimensions to get it.`,\n );\n }\n return undefined;\n }\n return bundle.config;\n}\n\n/**\n * Fetch the piece-guide bundle for a variant (gvid). Returns null while\n * loading, when `gvid` is undefined, and on any error (silent degrade).\n */\nexport function usePieceGuideBundle(\n gvid: string | undefined,\n apiBase: string = PIECE_GUIDES_API_BASE,\n): PieceGuideBundle | null {\n const [bundle, setBundle] = useState<PieceGuideBundle | null>(null);\n\n useEffect(() => {\n if (!gvid) {\n setBundle(null);\n return;\n }\n let cancelled = false;\n fetch(`${apiBase}/printables/by-gvid/${encodeURIComponent(gvid)}/piece-guides`)\n .then(async (res) => {\n if (!res.ok) throw new Error(`status ${res.status}`);\n return (await res.json()) as RawPieceGuidesResponse;\n })\n .then((raw) => {\n if (!cancelled) setBundle(transformPieceGuides(raw));\n })\n .catch(() => {\n // No guides is a degraded state, not a failure — the editor keeps\n // working, the overlay just doesn't appear.\n if (!cancelled) setBundle(null);\n });\n return () => {\n cancelled = true;\n };\n }, [gvid, apiBase]);\n\n return bundle;\n}\n"],"names":["PIECE_GUIDES_API_BASE","transformPieceGuides","raw","pieces","p","pieceGuidesForArtboard","bundle","artboard","process","usePieceGuideBundle","gvid","apiBase","setBundle","useState","useEffect","cancelled","res"],"mappings":";;AA6BO,MAAMA,IAAwB;AA8B9B,SAASC,EAAqBC,GAA+C;AAClF,QAAMC,IAAoCD,EAAI,OAAO,IAAI,CAACE,OAAO;AAAA,IAC/D,IAAIA,EAAE;AAAA,IACN,GAAGA,EAAE;AAAA,IACL,GAAGA,EAAE;AAAA,IACL,OAAOA,EAAE;AAAA,IACT,QAAQA,EAAE;AAAA,IACV,UAAU,OAAOA,EAAE,YAAa,WAAWA,EAAE,WAAW;AAAA,IACxD,iBACE,OAAOA,EAAE,uBAAwB,YAAYA,EAAE,sBAAsB,IACjEA,EAAE,sBAAsBF,EAAI,cAC5B;AAAA,EAAA,EACN;AACF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