@snowcone-app/canvas 0.22.0 → 0.23.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 (30) hide show
  1. package/STYLING_CONTRACT.md +114 -85
  2. package/dist/{EditorCanvasImpl-BH_bKy-F.js → EditorCanvasImpl-Ckg7WO2j.js} +4 -4
  3. package/dist/{EditorCanvasImpl-BH_bKy-F.js.map → EditorCanvasImpl-Ckg7WO2j.js.map} +1 -1
  4. package/dist/{SnowconeCanvas-Cx7nXlBI.js → SnowconeCanvas-D1sLcIja.js} +2 -2
  5. package/dist/{SnowconeCanvas-Cx7nXlBI.js.map → SnowconeCanvas-D1sLcIja.js.map} +1 -1
  6. package/dist/api/embed.d.ts +2 -2
  7. package/dist/design/design-builder.d.ts +67 -12
  8. package/dist/design-builder-2VUjfmdt.js +422 -0
  9. package/dist/design-builder-2VUjfmdt.js.map +1 -0
  10. package/dist/editorErrors-B2mb1sVN.js.map +1 -1
  11. package/dist/{embed-8ecUMMH-.js → embed-DxsaqZJF.js} +4 -4
  12. package/dist/{embed-8ecUMMH-.js.map → embed-DxsaqZJF.js.map} +1 -1
  13. package/dist/embed.mjs +21 -20
  14. package/dist/errors/editorError.d.ts +10 -0
  15. package/dist/hooks/bindingGuards.d.ts +16 -0
  16. package/dist/hooks/useColorBinding.d.ts +2 -1
  17. package/dist/hooks/useFontBinding.d.ts +2 -1
  18. package/dist/hooks/useImageBinding.d.ts +2 -1
  19. package/dist/hooks/useTextBinding.d.ts +2 -1
  20. package/dist/index.mjs +3 -3
  21. package/dist/template-fields-CQ6n2P4V.js +548 -0
  22. package/dist/template-fields-CQ6n2P4V.js.map +1 -0
  23. package/dist/testing/failureFixtures.d.ts +2 -2
  24. package/dist/testing.mjs +1 -1
  25. package/example/package.json +1 -1
  26. package/package.json +1 -1
  27. package/dist/design-builder-CT4DHIPe.js +0 -367
  28. package/dist/design-builder-CT4DHIPe.js.map +0 -1
  29. package/dist/template-fields-C2pSfMBh.js +0 -494
  30. package/dist/template-fields-C2pSfMBh.js.map +0 -1
package/dist/embed.mjs CHANGED
@@ -1,45 +1,46 @@
1
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";
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 T, v } from "./embed-DxsaqZJF.js";
3
+ import { g as b, i as B, u as y } from "./editorErrors-B2mb1sVN.js";
4
+ import { D as R, d as D, a as k, i as F } from "./design-builder-2VUjfmdt.js";
5
+ import { D as L, T as w, r as M, u as h, a as A, b as _, c as z, d as G, e as K, f as N, w as Y } from "./template-fields-CQ6n2P4V.js";
6
+ import { s as q } from "./CanvasStateV1-DmZ1Qvvn.js";
7
7
  export {
8
8
  a as CanvasServicesProvider,
9
9
  R as DesignBuilder,
10
10
  L as DesignStateStore,
11
11
  m as Editor,
12
- B as EditorError,
12
+ b as EditorError,
13
13
  l as RealtimeCanvas,
14
14
  E as RealtimeEmbed,
15
15
  c as RealtimeMockup,
16
16
  p as SnowconeEditor,
17
- k as TEMPLATE_FIELDS_KEY,
17
+ w as TEMPLATE_FIELDS_KEY,
18
18
  g as collectEmbedIssues,
19
19
  r as createProxyGenerate,
20
20
  o as createProxyImageSearch,
21
21
  D as design,
22
22
  f as formatBuyPrice,
23
- C as isEditorError,
23
+ k as isColorToken,
24
+ B as isEditorError,
24
25
  F as isLayerToken,
25
26
  S as productToRenderConfig,
26
- w as readTemplateFields,
27
- j as serializeState,
27
+ M as readTemplateFields,
28
+ q as serializeState,
28
29
  t as useArtboards,
29
30
  i as useCanvasServices,
30
- M as useColorBinding,
31
- h as useCommands,
31
+ h as useColorBinding,
32
+ A as useCommands,
32
33
  y as useEditor,
33
- A as useElementByName,
34
+ _ as useElementByName,
34
35
  d as useExport,
35
- _ as useFontBinding,
36
- z as useImageBinding,
36
+ z as useFontBinding,
37
+ G as useImageBinding,
37
38
  n as useLayers,
38
39
  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 useRealtimeMockups,
41
+ K as useSelectedElement,
42
+ N as useTextBinding,
43
+ v as validateEmbed,
44
+ Y as withTemplateFields
44
45
  };
45
46
  //# sourceMappingURL=embed.mjs.map
@@ -39,6 +39,16 @@ export type EditorErrorCode =
39
39
  /** `select()` named an option key/choice that doesn't exist on the product
40
40
  * (Buy-owned selection, ADR-0085 §2 / P2). */
41
41
  | 'E_UNKNOWN_OPTION'
42
+ /** `design({ colors })`: two color roles share one (normalized) hex value.
43
+ * `useColorBinding` matches by VALUE, so colliding roles would capture each
44
+ * other's elements — rejected at mint time instead of failing subtly. */
45
+ | 'E_COLOR_ROLE_COLLISION'
46
+ /** `design({ colors })`: a role's value is not a `#RGB`/`#RRGGBB` hex
47
+ * (value-matched bindings normalize hex; other syntaxes can't bind). */
48
+ | 'E_COLOR_ROLE_INVALID'
49
+ /** `design.color(name)`: no color role with this name — lists the design's
50
+ * declared roles. */
51
+ | 'E_COLOR_ROLE_NOT_FOUND'
42
52
  /** `assertRenders`: the shop's asset-origin allowlist denied a design asset
43
53
  * (translated from the server's 403 — F4). */
44
54
  | 'E_ASSET_FORBIDDEN'
@@ -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
1
  import { e as u } from "./UnifiedFontService-CC3CSmH5.js";
2
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";
3
+ import { E as _, S as y, S as L, u as O, a as M } from "./SnowconeCanvas-D1sLcIja.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";
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-CQ6n2P4V.js";
6
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";
7
+ import { C as W, D as X, d as $, s as ee } from "./design-builder-2VUjfmdt.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() {