@snowcone-app/canvas 0.26.0 → 0.28.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 (70) hide show
  1. package/ERROR_CONTRACT.md +51 -0
  2. package/dist/{CanvasRenderer-6_HhR4-q.js → CanvasRenderer-B_3GISlW.js} +1124 -1068
  3. package/dist/CanvasRenderer-B_3GISlW.js.map +1 -0
  4. package/dist/{CanvasStateV1-DmZ1Qvvn.js → CanvasStateV1-kL09wsAn.js} +3 -3
  5. package/dist/{CanvasStateV1-DmZ1Qvvn.js.map → CanvasStateV1-kL09wsAn.js.map} +1 -1
  6. package/dist/ContextualToolbars-C69oYLdw.js +5771 -0
  7. package/dist/ContextualToolbars-C69oYLdw.js.map +1 -0
  8. package/dist/{EditorCanvasImpl-BLZV_el0.js → EditorCanvasImpl-CrI9C_xM.js} +8 -8
  9. package/dist/{EditorCanvasImpl-BLZV_el0.js.map → EditorCanvasImpl-CrI9C_xM.js.map} +1 -1
  10. package/dist/{ExportManager-DoU4VK6h.js → ExportManager-J2xK86uq.js} +12 -16
  11. package/dist/ExportManager-J2xK86uq.js.map +1 -0
  12. package/dist/{FontAnalyzer-CwIpgTGd.js → FontAnalyzer-PE6nysqE.js} +686 -657
  13. package/dist/FontAnalyzer-PE6nysqE.js.map +1 -0
  14. package/dist/{ImagePanel-sLSjaPWS.js → ImagePanel-CmQCxBGm.js} +6 -6
  15. package/dist/{ImagePanel-sLSjaPWS.js.map → ImagePanel-CmQCxBGm.js.map} +1 -1
  16. package/dist/{SnowconeCanvas-4ef4a61J.js → SnowconeCanvas-CQiFVR0X.js} +10 -10
  17. package/dist/{SnowconeCanvas-4ef4a61J.js.map → SnowconeCanvas-CQiFVR0X.js.map} +1 -1
  18. package/dist/{UnifiedFontService-Bx2MxFfy.js → UnifiedFontService-BJzoqfBF.js} +755 -713
  19. package/dist/UnifiedFontService-BJzoqfBF.js.map +1 -0
  20. package/dist/advanced.mjs +14 -14
  21. package/dist/api/embed.d.ts +4 -0
  22. package/dist/components/MultiSelectionToolbar.d.ts +18 -0
  23. package/dist/components/ui/toolbar-button.d.ts +2 -0
  24. package/dist/contexts/EditorContext.d.ts +34 -0
  25. package/dist/core/GestureConstraints.d.ts +92 -0
  26. package/dist/core/HybridHistoryManager.d.ts +7 -0
  27. package/dist/core/InteractionStateMachine.d.ts +16 -2
  28. package/dist/core/ResizeHandler.d.ts +4 -1
  29. package/dist/core/ResizePipeline.d.ts +3 -0
  30. package/dist/core/elementGuards.d.ts +19 -0
  31. package/dist/{custom-icons-DeYIrTK1.js → custom-icons-BWiUGqD6.js} +2 -2
  32. package/dist/{custom-icons-DeYIrTK1.js.map → custom-icons-BWiUGqD6.js.map} +1 -1
  33. package/dist/{design-builder-U7Su9MMC.js → design-builder-bquxIHct.js} +2 -2
  34. package/dist/{design-builder-U7Su9MMC.js.map → design-builder-bquxIHct.js.map} +1 -1
  35. package/dist/editorErrors-8uDRMhow.js +1219 -0
  36. package/dist/editorErrors-8uDRMhow.js.map +1 -0
  37. package/dist/{embed-DXGydZOT.js → embed-L3oRIgsj.js} +10 -10
  38. package/dist/{embed-DXGydZOT.js.map → embed-L3oRIgsj.js.map} +1 -1
  39. package/dist/embed.mjs +39 -33
  40. package/dist/errors/editorError.d.ts +19 -1
  41. package/dist/{guards-8rkFAMBs.js → guards-BlbhM5MX.js} +2 -2
  42. package/dist/{guards-8rkFAMBs.js.map → guards-BlbhM5MX.js.map} +1 -1
  43. package/dist/hooks/elementPatch.d.ts +96 -0
  44. package/dist/hooks/index.d.ts +2 -0
  45. package/dist/hooks/useAlignDistribute.d.ts +19 -0
  46. package/dist/hooks/useCommands.d.ts +20 -0
  47. package/dist/index.mjs +8 -8
  48. package/dist/internals.mjs +9 -9
  49. package/dist/template-fields-ai7vnW8g.js +716 -0
  50. package/dist/template-fields-ai7vnW8g.js.map +1 -0
  51. package/dist/testing.mjs +4 -4
  52. package/dist/{usePieceGuideBundle-CbJJg66S.js → usePieceGuideBundle-CMe5br2a.js} +2 -2
  53. package/dist/{usePieceGuideBundle-CbJJg66S.js.map → usePieceGuideBundle-CMe5br2a.js.map} +1 -1
  54. package/dist/utils/alignDistribute.d.ts +41 -0
  55. package/dist/{validation-DnAkXdUg.js → validation-B8kIYutI.js} +2592 -2562
  56. package/dist/validation-B8kIYutI.js.map +1 -0
  57. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  58. package/example/package.json +1 -1
  59. package/package.json +3 -3
  60. package/dist/CanvasRenderer-6_HhR4-q.js.map +0 -1
  61. package/dist/ContextualToolbars-DUhBKVxe.js +0 -5556
  62. package/dist/ContextualToolbars-DUhBKVxe.js.map +0 -1
  63. package/dist/ExportManager-DoU4VK6h.js.map +0 -1
  64. package/dist/FontAnalyzer-CwIpgTGd.js.map +0 -1
  65. package/dist/UnifiedFontService-Bx2MxFfy.js.map +0 -1
  66. package/dist/editorErrors-B2mb1sVN.js +0 -1208
  67. package/dist/editorErrors-B2mb1sVN.js.map +0 -1
  68. package/dist/template-fields-DJ157D3E.js +0 -548
  69. package/dist/template-fields-DJ157D3E.js.map +0 -1
  70. package/dist/validation-DnAkXdUg.js.map +0 -1
package/ERROR_CONTRACT.md CHANGED
@@ -42,11 +42,14 @@ the issue key in `error.data.issue`.
42
42
  | [`E_COLOR_ROLE_INVALID`](#e_color_role_invalid) | throw | `design({ colors })`: a role's value is not a `#RGB`/`#RRGGBB` hex (value-matched bindings normalize hex; other syntaxes can't bind). |
43
43
  | [`E_COLOR_ROLE_NOT_FOUND`](#e_color_role_not_found) | throw | `design.color(name)`: no color role with this name — lists the design's declared roles. |
44
44
  | [`E_PREVIEW_NO_LOADER`](#e_preview_no_loader) | throw | `Editor.Preview loadingOverlay` got `false`/an unknown value. A mockup preview ALWAYS has a render-in-flight treatment (a server render takes real time, and the loader paints OVER the still-visible previous mockup) — keep the default, pass a variant/custom element, or declare `"host-owned"` with your own indicator. Silence-then-pop-in is a composition mistake, not a preference. |
45
+ | [`E_INVALID_PATCH`](#e_invalid_patch) | throw | `updateElement(target, patch)`: a patch key doesn't apply to the target element's kind (e.g. `fontSize` on a shape), or a value is out of range (opacity outside 0..1, fontSize/width/height <= 0, non-finite number, wrong primitive type). The message names the element kind and lists the valid keys for it. Dev AND prod. |
46
+ | [`E_NO_ACTIVE_ARTBOARD`](#e_no_active_artboard) | throw | `addElement(spec)`: there is no active artboard to add the element to. Create or select an artboard first (`<Editor.Root>` seeds one automatically; with a raw `EditorProvider` use `executeCreateArtboard`). Replaces the old `handleAddElement` window.alert — agents read throws, not dialogs. |
45
47
  | [`E_ASSET_FORBIDDEN`](#e_asset_forbidden) | throw | `assertRenders`: the shop's asset-origin allowlist denied a design asset (translated from the server's 403 — F4). |
46
48
  | [`E_RENDER_FAILED`](#e_render_failed) | throw | `assertRenders`: the render failed or produced no usable image (F4). |
47
49
  | [`E_BINDING_INERT`](#e_binding_inert) | throw | `assertRenders`: the mutated render is byte-identical to the seed render — the binding under test is dead (the two-render contract, F4). |
48
50
  | [`E_NO_MUTABLE_BINDING`](#e_no_mutable_binding) | throw | `assertRenders`: the design has no named text layer to mutate and no `mutate` override was given (F4). |
49
51
  | [`E_AUDIT_NO_ROOT`](#e_audit_no_root) | throw | `auditEditor()` called with no `<Editor.Root>` mounted — the imperative audit reads the most-recent mounted Root's registry (#10). |
52
+ | [`E_DISTRIBUTE_MIN_THREE`](#e_distribute_min_three) | throw | `computeDistribute()` called with fewer than 3 movable elements — distributing needs something between the two ends. Gate the action on `useAlignDistribute().canDistribute` instead of calling below the threshold (the toolbar hides its distribute buttons for exactly this reason). |
50
53
  | [`missing-shop`](#missing-shop) | error → throws `E_EMBED_CONFIG` | No `shop` (the publishable shop id) was passed. |
51
54
  | [`missing-grant`](#missing-grant) | error → throws `E_EMBED_CONFIG` | No grant source (`grantUrl`/`grant`) — the session can never authorize, so no mockup ever renders. |
52
55
  | [`empty-mockup-ids`](#empty-mockup-ids) | error → throws `E_EMBED_CONFIG` | `product.mockupIds` is empty — nothing to render. |
@@ -118,6 +121,14 @@ the issue key in `error.data.issue`.
118
121
 
119
122
  `error.data`: `code`, `layerName`, `validNames`, `docSlug`
120
123
 
124
+ - `src/hooks/elementPatch.ts`
125
+
126
+ ```text
127
+ no element with ${isToken ? 'layer name' : 'id or layer name'} "${key}" in this document. Valid layer names: ${JSON.stringify(names)}; valid ids: ${JSON.stringify(all.map((el) => el.id))}.
128
+ ```
129
+
130
+ `error.data`: `code`, `layerName`, `validNames`, `validIds`, `docSlug`
131
+
121
132
  ### `E_LAYER_WRONG_KIND`
122
133
 
123
134
  **Fires when:** The layer exists but is not the kind the part binds (e.g. an image layer passed to `Editor.TextField`).
@@ -406,6 +417,34 @@ the issue key in `error.data.issue`.
406
417
 
407
418
  `error.data`: `code`, `docSlug`
408
419
 
420
+ ### `E_INVALID_PATCH`
421
+
422
+ **Fires when:** `updateElement(target, patch)`: a patch key doesn't apply to the target element's kind (e.g. `fontSize` on a shape), or a value is out of range (opacity outside 0..1, fontSize/width/height <= 0, non-finite number, wrong primitive type). The message names the element kind and lists the valid keys for it. Dev AND prod.
423
+
424
+ **Docs:** <https://developers.snowcone.app/embed-mode> (`error.data.docSlug`)
425
+
426
+ - `src/hooks/elementPatch.ts`
427
+
428
+ ```text
429
+ ${message}
430
+ ```
431
+
432
+ `error.data`: `code`, `...data`, `docSlug`
433
+
434
+ ### `E_NO_ACTIVE_ARTBOARD`
435
+
436
+ **Fires when:** `addElement(spec)`: there is no active artboard to add the element to. Create or select an artboard first (`<Editor.Root>` seeds one automatically; with a raw `EditorProvider` use `executeCreateArtboard`). Replaces the old `handleAddElement` window.alert — agents read throws, not dialogs.
437
+
438
+ **Docs:** <https://developers.snowcone.app/embed-mode> (`error.data.docSlug`)
439
+
440
+ - `src/contexts/EditorContext.tsx`
441
+
442
+ ```text
443
+ addElement({ type: "${elementType}" }) needs an active artboard and none exists. <Editor.Root> seeds one automatically; with a raw EditorProvider create one first (executeCreateArtboard) or select one (artboardManager.setActiveArtboard).
444
+ ```
445
+
446
+ `error.data`: `code`, `type`, `docSlug`
447
+
409
448
  ### `E_ASSET_FORBIDDEN`
410
449
 
411
450
  **Fires when:** `assertRenders`: the shop's asset-origin allowlist denied a design asset (translated from the server's 403 — F4).
@@ -498,6 +537,18 @@ the issue key in `error.data.issue`.
498
537
 
499
538
  `error.data`: `code`, `docSlug`
500
539
 
540
+ ### `E_DISTRIBUTE_MIN_THREE`
541
+
542
+ **Fires when:** `computeDistribute()` called with fewer than 3 movable elements — distributing needs something between the two ends. Gate the action on `useAlignDistribute().canDistribute` instead of calling below the threshold (the toolbar hides its distribute buttons for exactly this reason).
543
+
544
+ - `src/utils/alignDistribute.ts`
545
+
546
+ ```text
547
+ distribute ${mode} needs at least ${DISTRIBUTE_MIN_COUNT} movable elements, got ${items.length}. Gate the action on useAlignDistribute().canDistribute (or items.length >= DISTRIBUTE_MIN_COUNT) instead of calling computeDistribute below the threshold.
548
+ ```
549
+
550
+ `error.data`: `code`, `mode`, `count`, `min`
551
+
501
552
  ## Embed wiring issues (the `onIssue` channel)
502
553
 
503
554
  Mount-time wiring problems and runtime stalls are `EmbedIssue` objects