@snowcone-app/canvas 0.22.0 → 0.26.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.
Files changed (59) hide show
  1. package/ERROR_CONTRACT.md +600 -0
  2. package/README.md +2 -1
  3. package/STYLING_CONTRACT.md +173 -93
  4. package/dist/{ContextualToolbars-BDEt9ND0.js → ContextualToolbars-DUhBKVxe.js} +3 -3
  5. package/dist/{ContextualToolbars-BDEt9ND0.js.map → ContextualToolbars-DUhBKVxe.js.map} +1 -1
  6. package/dist/{EditorCanvasImpl-BH_bKy-F.js → EditorCanvasImpl-BLZV_el0.js} +6 -6
  7. package/dist/{EditorCanvasImpl-BH_bKy-F.js.map → EditorCanvasImpl-BLZV_el0.js.map} +1 -1
  8. package/dist/{ImagePanel-BwqFDKvW.js → ImagePanel-sLSjaPWS.js} +3 -3
  9. package/dist/{ImagePanel-BwqFDKvW.js.map → ImagePanel-sLSjaPWS.js.map} +1 -1
  10. package/dist/{SnowconeCanvas-Cx7nXlBI.js → SnowconeCanvas-4ef4a61J.js} +6 -6
  11. package/dist/{SnowconeCanvas-Cx7nXlBI.js.map → SnowconeCanvas-4ef4a61J.js.map} +1 -1
  12. package/dist/{UnifiedFontService-CC3CSmH5.js → UnifiedFontService-Bx2MxFfy.js} +867 -834
  13. package/dist/{UnifiedFontService-CC3CSmH5.js.map → UnifiedFontService-Bx2MxFfy.js.map} +1 -1
  14. package/dist/advanced.mjs +7 -7
  15. package/dist/api/embed.d.ts +4 -4
  16. package/dist/components/editor/EditorLoadingOverlay.d.ts +12 -0
  17. package/dist/components/editor/EditorPlacements.d.ts +14 -0
  18. package/dist/components/editor/EditorPreview.d.ts +32 -8
  19. package/dist/components/editor/EditorRoot.d.ts +12 -0
  20. package/dist/components/editor/PreviewPrismOverlay.d.ts +23 -0
  21. package/dist/components/editor/RootInternals.d.ts +31 -0
  22. package/dist/components/editor/editorAudit.d.ts +66 -0
  23. package/dist/components/editor/index.d.ts +14 -0
  24. package/dist/components/editor/usePlacements.d.ts +14 -0
  25. package/dist/components/embed-realtime/context.d.ts +11 -2
  26. package/dist/components/embed-realtime/validateEmbed.d.ts +20 -1
  27. package/dist/{custom-icons-BW6hqmkL.js → custom-icons-DeYIrTK1.js} +7 -7
  28. package/dist/{custom-icons-BW6hqmkL.js.map → custom-icons-DeYIrTK1.js.map} +1 -1
  29. package/dist/design/design-builder.d.ts +108 -15
  30. package/dist/design/product-config.d.ts +10 -0
  31. package/dist/design-builder-U7Su9MMC.js +470 -0
  32. package/dist/design-builder-U7Su9MMC.js.map +1 -0
  33. package/dist/editorErrors-B2mb1sVN.js.map +1 -1
  34. package/dist/embed-DXGydZOT.js +1586 -0
  35. package/dist/embed-DXGydZOT.js.map +1 -0
  36. package/dist/embed.mjs +34 -31
  37. package/dist/errors/editorError.d.ts +27 -1
  38. package/dist/hooks/bindingGuards.d.ts +16 -0
  39. package/dist/hooks/useColorBinding.d.ts +2 -1
  40. package/dist/hooks/useFontBinding.d.ts +2 -1
  41. package/dist/hooks/useImageBinding.d.ts +2 -1
  42. package/dist/hooks/useTextBinding.d.ts +2 -1
  43. package/dist/index.mjs +6 -6
  44. package/dist/style.css +1 -1
  45. package/dist/template-fields-DJ157D3E.js +548 -0
  46. package/dist/template-fields-DJ157D3E.js.map +1 -0
  47. package/dist/testing/failureFixtures.d.ts +2 -2
  48. package/dist/testing.mjs +1 -1
  49. package/dist/{validation-C9Fe9ahK.js → validation-DnAkXdUg.js} +7 -7
  50. package/dist/{validation-C9Fe9ahK.js.map → validation-DnAkXdUg.js.map} +1 -1
  51. package/example/package.json +1 -1
  52. package/llms.txt +3 -0
  53. package/package.json +6 -3
  54. package/dist/design-builder-CT4DHIPe.js +0 -367
  55. package/dist/design-builder-CT4DHIPe.js.map +0 -1
  56. package/dist/embed-8ecUMMH-.js +0 -1226
  57. package/dist/embed-8ecUMMH-.js.map +0 -1
  58. package/dist/template-fields-C2pSfMBh.js +0 -494
  59. package/dist/template-fields-C2pSfMBh.js.map +0 -1
package/dist/embed.mjs CHANGED
@@ -1,45 +1,48 @@
1
- import { C as a, a as r, b as o, u as t, d as i, f as d, g as n } from "./UnifiedFontService-CC3CSmH5.js";
2
- import { E as m, R as l, a as E, b as c, S as p, c as g, f, p as S, d as x, e as v, v as T } from "./embed-8ecUMMH-.js";
3
- import { g as B, i as C, u as y } from "./editorErrors-B2mb1sVN.js";
4
- import { D as R, d as D, i as F } from "./design-builder-CT4DHIPe.js";
5
- import { D as L, T as k, r as w, u as M, a as h, b as A, c as _, d as z, e as G, f as K, w as N } from "./template-fields-C2pSfMBh.js";
6
- import { s as j } from "./CanvasStateV1-DmZ1Qvvn.js";
1
+ import { C as a, a as r, b as o, u as t, d as i, f as d, g as n } from "./UnifiedFontService-Bx2MxFfy.js";
2
+ import { E as m, R as l, a as E, b as c, S as g, c as p, d as f, f as S, p as x, e as T, g as v, h as C, v as b } from "./embed-DXGydZOT.js";
3
+ import { g as P, i as y, u as R } from "./editorErrors-B2mb1sVN.js";
4
+ import { D as k, d as F, a as I, i as L } from "./design-builder-U7Su9MMC.js";
5
+ import { D as w, T as M, r as A, u as _, a as z, b as G, c as K, d as N, e as Y, f as j, w as q } from "./template-fields-DJ157D3E.js";
6
+ import { s as J } from "./CanvasStateV1-DmZ1Qvvn.js";
7
7
  export {
8
8
  a as CanvasServicesProvider,
9
- R as DesignBuilder,
10
- L as DesignStateStore,
9
+ k as DesignBuilder,
10
+ w as DesignStateStore,
11
11
  m as Editor,
12
- B as EditorError,
12
+ P as EditorError,
13
13
  l as RealtimeCanvas,
14
14
  E as RealtimeEmbed,
15
15
  c as RealtimeMockup,
16
- p as SnowconeEditor,
17
- k as TEMPLATE_FIELDS_KEY,
18
- g as collectEmbedIssues,
16
+ g as SnowconeEditor,
17
+ M as TEMPLATE_FIELDS_KEY,
18
+ p as auditEditor,
19
+ f as collectEmbedIssues,
19
20
  r as createProxyGenerate,
20
21
  o as createProxyImageSearch,
21
- D as design,
22
- f as formatBuyPrice,
23
- C as isEditorError,
24
- F as isLayerToken,
25
- S as productToRenderConfig,
26
- w as readTemplateFields,
27
- j as serializeState,
22
+ F as design,
23
+ S as formatBuyPrice,
24
+ I as isColorToken,
25
+ y as isEditorError,
26
+ L as isLayerToken,
27
+ x as productToRenderConfig,
28
+ A as readTemplateFields,
29
+ J as serializeState,
28
30
  t as useArtboards,
29
31
  i as useCanvasServices,
30
- M as useColorBinding,
31
- h as useCommands,
32
- y as useEditor,
33
- A as useElementByName,
32
+ _ as useColorBinding,
33
+ z as useCommands,
34
+ R as useEditor,
35
+ G as useElementByName,
34
36
  d as useExport,
35
- _ as useFontBinding,
36
- z as useImageBinding,
37
+ K as useFontBinding,
38
+ N as useImageBinding,
37
39
  n as useLayers,
38
- x as useProductSelection,
39
- v as useRealtimeMockups,
40
- G as useSelectedElement,
41
- K as useTextBinding,
42
- T as validateEmbed,
43
- N as withTemplateFields
40
+ T as usePlacements,
41
+ v as useProductSelection,
42
+ C as useRealtimeMockups,
43
+ Y as useSelectedElement,
44
+ j as useTextBinding,
45
+ b as validateEmbed,
46
+ q as withTemplateFields
44
47
  };
45
48
  //# sourceMappingURL=embed.mjs.map
@@ -36,9 +36,32 @@ export type EditorErrorCode =
36
36
  /** `productToRenderConfig`: the catalog product has no renderable image
37
37
  * placement / no mockup scenes, or the requested placement doesn't exist. */
38
38
  | 'E_PRODUCT_NOT_RENDERABLE'
39
+ /** `design().artboard()`: an artboard with this label already exists in the
40
+ * design (artboard names are placement labels — unique by contract). */
41
+ | 'E_DUPLICATE_ARTBOARD'
42
+ /** `usePlacements().select()`: the label names no artboard in the design
43
+ * (ADR-0088). Lists the valid placement labels. */
44
+ | 'E_UNKNOWN_PLACEMENT'
39
45
  /** `select()` named an option key/choice that doesn't exist on the product
40
46
  * (Buy-owned selection, ADR-0085 §2 / P2). */
41
47
  | 'E_UNKNOWN_OPTION'
48
+ /** `design({ colors })`: two color roles share one (normalized) hex value.
49
+ * `useColorBinding` matches by VALUE, so colliding roles would capture each
50
+ * other's elements — rejected at mint time instead of failing subtly. */
51
+ | 'E_COLOR_ROLE_COLLISION'
52
+ /** `design({ colors })`: a role's value is not a `#RGB`/`#RRGGBB` hex
53
+ * (value-matched bindings normalize hex; other syntaxes can't bind). */
54
+ | 'E_COLOR_ROLE_INVALID'
55
+ /** `design.color(name)`: no color role with this name — lists the design's
56
+ * declared roles. */
57
+ | 'E_COLOR_ROLE_NOT_FOUND'
58
+ /** `Editor.Preview loadingOverlay` got `false`/an unknown value. A mockup
59
+ * preview ALWAYS has a render-in-flight treatment (a server render takes
60
+ * real time, and the loader paints OVER the still-visible previous
61
+ * mockup) — keep the default, pass a variant/custom element, or declare
62
+ * `"host-owned"` with your own indicator. Silence-then-pop-in is a
63
+ * composition mistake, not a preference. */
64
+ | 'E_PREVIEW_NO_LOADER'
42
65
  /** `assertRenders`: the shop's asset-origin allowlist denied a design asset
43
66
  * (translated from the server's 403 — F4). */
44
67
  | 'E_ASSET_FORBIDDEN'
@@ -49,7 +72,10 @@ export type EditorErrorCode =
49
72
  | 'E_BINDING_INERT'
50
73
  /** `assertRenders`: the design has no named text layer to mutate and no
51
74
  * `mutate` override was given (F4). */
52
- | 'E_NO_MUTABLE_BINDING';
75
+ | 'E_NO_MUTABLE_BINDING'
76
+ /** `auditEditor()` called with no `<Editor.Root>` mounted — the imperative
77
+ * audit reads the most-recent mounted Root's registry (#10). */
78
+ | 'E_AUDIT_NO_ROOT';
53
79
  export interface EditorErrorData {
54
80
  code: EditorErrorCode;
55
81
  /** Slug under https://developers.snowcone.app/ for the violated contract. */
@@ -0,0 +1,16 @@
1
+ import { LayerKind, LayerToken } from '../design/design-builder.js';
2
+ import { ElementStore } from '../core/ElementStore.js';
3
+ /**
4
+ * Under `<Editor.Root>`, declare that this binding hook needs a mounted
5
+ * `Editor.Canvas` — Root's registry validation throws `E_REQUIRES_CANVAS`
6
+ * (its existing single validation point) when none is in the composition.
7
+ * No-op outside a Root.
8
+ */
9
+ export declare function useBindingRequiresCanvas(hookName: string): void;
10
+ /**
11
+ * Accept a binding hook's `string | LayerToken` argument and return the bare
12
+ * layer name. With a token under `<Editor.Root>`, mount-validate it against
13
+ * the first non-empty element snapshot (see module doc). Bare strings keep
14
+ * the settle-aware dead-binding console.warn instead.
15
+ */
16
+ export declare function useValidatedBindingLayer(layerOrName: string | LayerToken, expectedKind: LayerKind, elementStore: ElementStore): string;
@@ -1,3 +1,4 @@
1
+ import { ColorToken } from '../design/design-builder.js';
1
2
  import { EditorElement } from '../contexts/EditorContext.js';
2
3
  /** Result returned by {@link useColorBinding}. */
3
4
  export interface ColorBindingResult {
@@ -18,4 +19,4 @@ export interface ColorBindingResult {
18
19
  * @param originalColor - The hex color to match (the template field's `color`).
19
20
  * @returns Applied color, setter, matching elements, and connection status.
20
21
  */
21
- export declare function useColorBinding(originalColor: string): ColorBindingResult;
22
+ export declare function useColorBinding(original: string | ColorToken): ColorBindingResult;
@@ -1,4 +1,5 @@
1
1
  import { EditorElement } from '../contexts/EditorContext.js';
2
+ import { LayerToken } from '../design/design-builder.js';
2
3
  /** Result returned by {@link useFontBinding}. */
3
4
  export interface FontBindingResult {
4
5
  /** Current font family (from first bound element). Empty string if disconnected. */
@@ -20,4 +21,4 @@ export interface FontBindingResult {
20
21
  * @param name - The element name to bind to.
21
22
  * @returns Font family, setter, element references, and connection status.
22
23
  */
23
- export declare function useFontBinding(name: string): FontBindingResult;
24
+ export declare function useFontBinding(layer: string | LayerToken<'text'>): FontBindingResult;
@@ -1,4 +1,5 @@
1
1
  import { EditorElement } from '../contexts/EditorContext.js';
2
+ import { LayerToken } from '../design/design-builder.js';
2
3
  /** How the image fits the element bounds. */
3
4
  export type ImageFitMode = 'cover' | 'contain';
4
5
  /** Options for {@link useImageBinding}. */
@@ -31,4 +32,4 @@ export interface ImageBindingResult {
31
32
  * @param options - Optional configuration (fit mode, etc.).
32
33
  * @returns Image URL value, setter, element references, and connection status.
33
34
  */
34
- export declare function useImageBinding(name: string, options?: ImageBindingOptions): ImageBindingResult;
35
+ export declare function useImageBinding(layer: string | LayerToken<'image'>, options?: ImageBindingOptions): ImageBindingResult;
@@ -1,4 +1,5 @@
1
1
  import { EditorElement } from '../contexts/EditorContext.js';
2
+ import { LayerToken } from '../design/design-builder.js';
2
3
  /** Result returned by {@link useTextBinding}. */
3
4
  export interface TextBindingResult {
4
5
  /** Current plain text content (from first bound element). Empty string if disconnected. */
@@ -23,4 +24,4 @@ export interface TextBindingResult {
23
24
  * @param name - The element name to bind to.
24
25
  * @returns Text value, setter, element references, and connection status.
25
26
  */
26
- export declare function useTextBinding(name: string): TextBindingResult;
27
+ export declare function useTextBinding(layer: string | LayerToken<'text'>): TextBindingResult;
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { e as u } from "./UnifiedFontService-CC3CSmH5.js";
2
- import { C as l, c as x, a as I, b as v, u as A, d as T, f as g, g as B } from "./UnifiedFontService-CC3CSmH5.js";
3
- import { E as _, S as y, S as L, u as O, a as M } from "./SnowconeCanvas-Cx7nXlBI.js";
1
+ import { e as u } from "./UnifiedFontService-Bx2MxFfy.js";
2
+ import { C as l, c as x, a as I, b as v, u as A, d as T, f as g, g as B } from "./UnifiedFontService-Bx2MxFfy.js";
3
+ import { E as _, S as y, S as L, u as O, a as M } from "./SnowconeCanvas-4ef4a61J.js";
4
4
  import { u as d, a as m } from "./editorErrors-B2mb1sVN.js";
5
- import { T as z, r as w, u as F, a as D, b as K, c as N, d as V, e as b, f as h, w as U } from "./template-fields-C2pSfMBh.js";
6
- import { A as Z, C as G, E as H, M as j, P as k, r as q, v as J } from "./validation-C9Fe9ahK.js";
7
- import { C as W, D as X, d as $, s as ee } from "./design-builder-CT4DHIPe.js";
5
+ import { T as z, r as w, u as F, a as D, b as K, c as N, d as V, e as b, f as h, w as U } from "./template-fields-DJ157D3E.js";
6
+ import { A as Z, C as G, E as H, M as j, P as k, r as q, v as J } from "./validation-DnAkXdUg.js";
7
+ import { C as W, D as X, d as $, s as ee } from "./design-builder-U7Su9MMC.js";
8
8
  import { c as se, e as te } from "./compose-DtQL_oit.js";
9
9
  import { d as oe, m as ie, s as ne, v as ue } from "./CanvasStateV1-DmZ1Qvvn.js";
10
10
  function C() {