@snowcone-app/canvas 0.17.0 → 0.17.2
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-C6i6vU6p.js → CanvasStateV1-BG2hEc3-.js} +3 -3
- package/dist/{CanvasStateV1-C6i6vU6p.js.map → CanvasStateV1-BG2hEc3-.js.map} +1 -1
- package/dist/EditorCanvasImpl-DgXvuWXX.js +70 -0
- package/dist/EditorCanvasImpl-DgXvuWXX.js.map +1 -0
- package/dist/EditorContext-CGkfmbgo.js +1178 -0
- package/dist/EditorContext-CGkfmbgo.js.map +1 -0
- package/dist/{ElementFactory-C05JJkRp.js → ElementFactory-CuHSAPfg.js} +1469 -710
- package/dist/ElementFactory-CuHSAPfg.js.map +1 -0
- package/dist/{HybridHistoryManager-Bht98XRv.js → FontAnalyzer-CLv7_msL.js} +2104 -2903
- package/dist/FontAnalyzer-CLv7_msL.js.map +1 -0
- package/dist/{ImportManager-kRYfIX-D.js → ImportManager-C_wBjWaV.js} +147 -147
- package/dist/{ImportManager-kRYfIX-D.js.map → ImportManager-C_wBjWaV.js.map} +1 -1
- package/dist/SnowconeCanvas-wdckG-6O.js +1179 -0
- package/dist/SnowconeCanvas-wdckG-6O.js.map +1 -0
- package/dist/{UnifiedFontService-BAtqqkU4.js → UnifiedFontService-Dsu5cwfT.js} +141 -141
- package/dist/UnifiedFontService-Dsu5cwfT.js.map +1 -0
- package/dist/advanced.mjs +10 -10
- package/dist/components/editor/RootInternals.d.ts +7 -0
- package/dist/components/editor/designStateStore.d.ts +1 -1
- package/dist/components/embed/EmbedRoot.d.ts +23 -0
- package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
- package/dist/components/embed/kernel.d.ts +114 -0
- package/dist/contexts/BoundLayerGuardContext.d.ts +36 -0
- package/dist/core/GroupElement.d.ts +0 -5
- package/dist/core/TextElement.d.ts +8 -3
- package/dist/core/paint-registry.d.ts +42 -0
- package/dist/core/rich-text-layout.d.ts +28 -0
- package/dist/{editorErrors-DbIEtCTt.js → editorErrors-BY4Pdg7a.js} +2 -2
- package/dist/{editorErrors-DbIEtCTt.js.map → editorErrors-BY4Pdg7a.js.map} +1 -1
- package/dist/{embed-Bdj4PKUA.js → embed-32ZVWfmj.js} +209 -200
- package/dist/embed-32ZVWfmj.js.map +1 -0
- package/dist/embed.mjs +21 -22
- package/dist/embed.mjs.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/internals.mjs +93 -93
- package/dist/rendering/element-painters.d.ts +16 -0
- package/dist/rendering/rich-text-renderer.d.ts +3 -28
- package/dist/{template-fields-GOM4MNfq.js → template-fields-Z9x13sjM.js} +32 -33
- package/dist/{template-fields-GOM4MNfq.js.map → template-fields-Z9x13sjM.js.map} +1 -1
- package/dist/testing.mjs +7 -7
- package/dist/transforms/ArchTransform.d.ts +0 -1
- package/dist/transforms/AscendTransform.d.ts +0 -1
- package/dist/transforms/CircleTransform.d.ts +0 -1
- package/dist/transforms/FlagTransform.d.ts +0 -1
- package/dist/transforms/LeanTransform.d.ts +0 -1
- package/dist/transforms/WaveTransform.d.ts +0 -1
- package/dist/{usePieceGuideBundle-CGERAQJl.js → usePieceGuideBundle-C1ipFnZd.js} +2 -2
- package/dist/{usePieceGuideBundle-CGERAQJl.js.map → usePieceGuideBundle-C1ipFnZd.js.map} +1 -1
- package/dist/{validation-DEd6EOCP.js → validation-C795COGQ.js} +4803 -4791
- package/dist/validation-C795COGQ.js.map +1 -0
- package/dist/vendor/ui/primitives/kbd.d.ts +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/package.json +7 -4
- package/dist/EditorCanvasImpl-DkgE5-C2.js +0 -68
- package/dist/EditorCanvasImpl-DkgE5-C2.js.map +0 -1
- package/dist/EditorContext-CyanYzo2.js +0 -1131
- package/dist/EditorContext-CyanYzo2.js.map +0 -1
- package/dist/ElementFactory-C05JJkRp.js.map +0 -1
- package/dist/HybridHistoryManager-Bht98XRv.js.map +0 -1
- package/dist/SnowconeCanvas-C3eZ9PP8.js +0 -1047
- package/dist/SnowconeCanvas-C3eZ9PP8.js.map +0 -1
- package/dist/UnifiedFontService-BAtqqkU4.js.map +0 -1
- package/dist/editorError-DMENTZ-3.js +0 -19
- package/dist/editorError-DMENTZ-3.js.map +0 -1
- package/dist/embed-Bdj4PKUA.js.map +0 -1
- package/dist/validation-DEd6EOCP.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePieceGuideBundle-
|
|
1
|
+
{"version":3,"file":"usePieceGuideBundle-C1ipFnZd.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,SAAO;AAAA,IACL,eAAeA,EAAI;AAAA,IACnB,gBAAgBA,EAAI;AAAA,IACpB,QAAQ;AAAA,MACN,QAAAC;AAAA,MACA,QAAQD,EAAI,eAAe,CAAA;AAA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