@pixel-point/toolcraft 0.0.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.
Files changed (257) hide show
  1. package/LICENSE.md +98 -0
  2. package/README.md +41 -0
  3. package/bin/create-toolcraft-app.mjs +8 -0
  4. package/bin/toolcraft.mjs +8 -0
  5. package/package.json +24 -0
  6. package/scripts/prepare-pack.mjs +29 -0
  7. package/src/cli.mjs +392 -0
  8. package/src/cli.test.mjs +284 -0
  9. package/src/copy-recursive.mjs +86 -0
  10. package/src/generate.mjs +212 -0
  11. package/src/generate.test.mjs +322 -0
  12. package/src/import-map.mjs +14 -0
  13. package/src/package-json.mjs +80 -0
  14. package/src/package-json.test.mjs +67 -0
  15. package/src/rewrite-imports.mjs +85 -0
  16. package/src/rewrite-imports.test.mjs +58 -0
  17. package/templates/runtime/contracts/component-contracts.test.ts +1165 -0
  18. package/templates/runtime/contracts/component-contracts.ts +1340 -0
  19. package/templates/runtime/contracts/decision-contracts.test.ts +206 -0
  20. package/templates/runtime/contracts/decision-contracts.ts +283 -0
  21. package/templates/runtime/contracts/index.test.ts +14 -0
  22. package/templates/runtime/contracts/index.ts +3 -0
  23. package/templates/runtime/contracts/types.ts +56 -0
  24. package/templates/runtime/export/export.test.ts +203 -0
  25. package/templates/runtime/export/export.ts +132 -0
  26. package/templates/runtime/export/index.ts +1 -0
  27. package/templates/runtime/index.ts +14 -0
  28. package/templates/runtime/react/canvas-shell.test.tsx +424 -0
  29. package/templates/runtime/react/canvas-shell.tsx +408 -0
  30. package/templates/runtime/react/control-renderers.ts +31 -0
  31. package/templates/runtime/react/controls-panel.test.tsx +3736 -0
  32. package/templates/runtime/react/controls-panel.tsx +2327 -0
  33. package/templates/runtime/react/curve-geometry.test.ts +70 -0
  34. package/templates/runtime/react/index.ts +15 -0
  35. package/templates/runtime/react/layer-tree.ts +96 -0
  36. package/templates/runtime/react/layers-panel.test.tsx +487 -0
  37. package/templates/runtime/react/layers-panel.tsx +1348 -0
  38. package/templates/runtime/react/media-file.ts +82 -0
  39. package/templates/runtime/react/panel-host-config.ts +80 -0
  40. package/templates/runtime/react/panel-host-geometry.test.ts +66 -0
  41. package/templates/runtime/react/panel-host-geometry.ts +109 -0
  42. package/templates/runtime/react/panel-host-types.ts +74 -0
  43. package/templates/runtime/react/panel-host.test.tsx +102 -0
  44. package/templates/runtime/react/panel-host.tsx +353 -0
  45. package/templates/runtime/react/runtime-public-api.test.tsx +132 -0
  46. package/templates/runtime/react/settings-transfer.test.ts +150 -0
  47. package/templates/runtime/react/settings-transfer.ts +279 -0
  48. package/templates/runtime/react/storage-key-migration.ts +48 -0
  49. package/templates/runtime/react/theme-runtime.tsx +177 -0
  50. package/templates/runtime/react/timeline-panel.test.tsx +668 -0
  51. package/templates/runtime/react/timeline-panel.tsx +2953 -0
  52. package/templates/runtime/react/toolbar-panel.test.tsx +212 -0
  53. package/templates/runtime/react/toolbar-panel.tsx +205 -0
  54. package/templates/runtime/react/toolcraft-app.integration.test.tsx +350 -0
  55. package/templates/runtime/react/toolcraft-app.test.tsx +339 -0
  56. package/templates/runtime/react/toolcraft-app.tsx +81 -0
  57. package/templates/runtime/react/toolcraft-root.test.tsx +347 -0
  58. package/templates/runtime/react/toolcraft-root.tsx +203 -0
  59. package/templates/runtime/react/use-toolcraft.ts +41 -0
  60. package/templates/runtime/schema/define-toolcraft.test.ts +1524 -0
  61. package/templates/runtime/schema/define-toolcraft.ts +1442 -0
  62. package/templates/runtime/schema/keyframe-capability.test.ts +90 -0
  63. package/templates/runtime/schema/keyframe-capability.ts +51 -0
  64. package/templates/runtime/schema/runtime-targets.ts +40 -0
  65. package/templates/runtime/schema/types.ts +370 -0
  66. package/templates/runtime/state/canvas-zoom.ts +8 -0
  67. package/templates/runtime/state/create-template-state.test.ts +242 -0
  68. package/templates/runtime/state/create-template-state.ts +95 -0
  69. package/templates/runtime/state/keyframe-evaluation.test.ts +141 -0
  70. package/templates/runtime/state/keyframe-evaluation.ts +203 -0
  71. package/templates/runtime/state/persistence.test.ts +217 -0
  72. package/templates/runtime/state/persistence.ts +511 -0
  73. package/templates/runtime/state/reducer.test.ts +937 -0
  74. package/templates/runtime/state/reducer.ts +1212 -0
  75. package/templates/runtime/state/timeline-readiness.ts +43 -0
  76. package/templates/runtime/state/types.ts +242 -0
  77. package/templates/runtime/styles.css +125 -0
  78. package/templates/runtime/testing/performance.test.ts +1058 -0
  79. package/templates/runtime/testing/performance.ts +1078 -0
  80. package/templates/starter/AGENTS.md +186 -0
  81. package/templates/starter/LICENSE.md +98 -0
  82. package/templates/starter/NOTICE.md +8 -0
  83. package/templates/starter/docs/toolcraft/README.md +41 -0
  84. package/templates/starter/docs/toolcraft/acceptance-testing.md +205 -0
  85. package/templates/starter/docs/toolcraft/agent-worklog.md +81 -0
  86. package/templates/starter/docs/toolcraft/assembly-workflow.md +206 -0
  87. package/templates/starter/docs/toolcraft/component-rules.md +299 -0
  88. package/templates/starter/docs/toolcraft/custom-controls.md +71 -0
  89. package/templates/starter/docs/toolcraft/decision-contract.md +71 -0
  90. package/templates/starter/docs/toolcraft/performance.md +112 -0
  91. package/templates/starter/docs/toolcraft/renderer-technique.md +48 -0
  92. package/templates/starter/docs/toolcraft/schema-reference.md +265 -0
  93. package/templates/starter/docs/toolcraft/workflow.md +87 -0
  94. package/templates/starter/e2e/app-browser-acceptance.spec.ts +785 -0
  95. package/templates/starter/e2e/app-controls.spec.ts +41 -0
  96. package/templates/starter/e2e/app-performance.spec.ts +326 -0
  97. package/templates/starter/e2e/canvas-handle-helpers.ts +244 -0
  98. package/templates/starter/e2e/performance-helpers.ts +612 -0
  99. package/templates/starter/e2e/product-observable-helpers.ts +170 -0
  100. package/templates/starter/index.html +12 -0
  101. package/templates/starter/package.json +52 -0
  102. package/templates/starter/playwright.config.ts +43 -0
  103. package/templates/starter/scripts/check-ai-skills.mjs +95 -0
  104. package/templates/starter/scripts/check-toolcraft-docs.mjs +159 -0
  105. package/templates/starter/scripts/check-toolcraft-integrity.mjs +232 -0
  106. package/templates/starter/scripts/run-vite-on-free-port.mjs +48 -0
  107. package/templates/starter/scripts/toolcraft-port.mjs +54 -0
  108. package/templates/starter/scripts/toolcraft-port.test.mjs +73 -0
  109. package/templates/starter/src/app/starter-acceptance.test.ts +5959 -0
  110. package/templates/starter/src/app/starter-acceptance.ts +2646 -0
  111. package/templates/starter/src/app/starter-performance.test.ts +1390 -0
  112. package/templates/starter/src/app/starter-performance.ts +12 -0
  113. package/templates/starter/src/app/starter-schema.test.ts +70 -0
  114. package/templates/starter/src/app/starter-schema.ts +15 -0
  115. package/templates/starter/src/main.tsx +18 -0
  116. package/templates/starter/src/router.tsx +16 -0
  117. package/templates/starter/src/routes/index.tsx +7 -0
  118. package/templates/starter/src/routes/root.tsx +19 -0
  119. package/templates/starter/src/styles.css +120 -0
  120. package/templates/starter/tsconfig.json +11 -0
  121. package/templates/starter/vite.config.ts +13 -0
  122. package/templates/ui/components/composites/accordion.tsx +73 -0
  123. package/templates/ui/components/composites/alert-dialog.tsx +190 -0
  124. package/templates/ui/components/composites/alert.tsx +74 -0
  125. package/templates/ui/components/composites/aspect-ratio.tsx +22 -0
  126. package/templates/ui/components/composites/avatar.tsx +98 -0
  127. package/templates/ui/components/composites/badge.tsx +69 -0
  128. package/templates/ui/components/composites/breadcrumb.tsx +106 -0
  129. package/templates/ui/components/composites/card.tsx +91 -0
  130. package/templates/ui/components/composites/combobox.tsx +486 -0
  131. package/templates/ui/components/composites/command.tsx +296 -0
  132. package/templates/ui/components/composites/context-menu.tsx +247 -0
  133. package/templates/ui/components/composites/dialog.tsx +282 -0
  134. package/templates/ui/components/composites/dropdown-menu.tsx +299 -0
  135. package/templates/ui/components/composites/empty.tsx +110 -0
  136. package/templates/ui/components/composites/hover-card.tsx +44 -0
  137. package/templates/ui/components/composites/index.ts +30 -0
  138. package/templates/ui/components/composites/menubar.tsx +214 -0
  139. package/templates/ui/components/composites/navigation-menu.tsx +167 -0
  140. package/templates/ui/components/composites/pagination.tsx +131 -0
  141. package/templates/ui/components/composites/progress.tsx +72 -0
  142. package/templates/ui/components/composites/radio-group.tsx +84 -0
  143. package/templates/ui/components/composites/resizable.tsx +42 -0
  144. package/templates/ui/components/composites/sheet.tsx +153 -0
  145. package/templates/ui/components/composites/sidebar-structural.tsx +310 -0
  146. package/templates/ui/components/composites/sidebar.tsx +431 -0
  147. package/templates/ui/components/composites/sonner.tsx +35 -0
  148. package/templates/ui/components/composites/spinner.tsx +43 -0
  149. package/templates/ui/components/composites/table.tsx +108 -0
  150. package/templates/ui/components/composites/tabs.tsx +83 -0
  151. package/templates/ui/components/control-layout/index.tsx +437 -0
  152. package/templates/ui/components/controls/actions/actions-control.tsx +139 -0
  153. package/templates/ui/components/controls/actions/index.ts +9 -0
  154. package/templates/ui/components/controls/anchor-grid/anchor-grid-control.tsx +107 -0
  155. package/templates/ui/components/controls/anchor-grid/index.ts +4 -0
  156. package/templates/ui/components/controls/boolean/boolean-controls.tsx +79 -0
  157. package/templates/ui/components/controls/boolean/index.ts +4 -0
  158. package/templates/ui/components/controls/channel-mixer/channel-mixer-control.tsx +95 -0
  159. package/templates/ui/components/controls/channel-mixer/index.ts +4 -0
  160. package/templates/ui/components/controls/channel-tabs/channel-tabs.tsx +42 -0
  161. package/templates/ui/components/controls/channel-tabs/index.ts +6 -0
  162. package/templates/ui/components/controls/code-textarea/code-textarea-control.tsx +90 -0
  163. package/templates/ui/components/controls/code-textarea/index.ts +4 -0
  164. package/templates/ui/components/controls/color/color-control.tsx +571 -0
  165. package/templates/ui/components/controls/color/color-picker-popover.tsx +104 -0
  166. package/templates/ui/components/controls/color/index.ts +41 -0
  167. package/templates/ui/components/controls/color/palette-control-data.ts +436 -0
  168. package/templates/ui/components/controls/color/palette-control.tsx +535 -0
  169. package/templates/ui/components/controls/color/style-guide-color-picker-channel-utils.ts +162 -0
  170. package/templates/ui/components/controls/color/style-guide-color-picker-interactions.ts +190 -0
  171. package/templates/ui/components/controls/color/style-guide-color-picker-logic.ts +485 -0
  172. package/templates/ui/components/controls/color/style-guide-color-picker-parts.tsx +710 -0
  173. package/templates/ui/components/controls/color/style-guide-color-picker.tsx +503 -0
  174. package/templates/ui/components/controls/control-types.ts +43 -0
  175. package/templates/ui/components/controls/curves/curve-geometry.ts +355 -0
  176. package/templates/ui/components/controls/curves/curve-graph.tsx +390 -0
  177. package/templates/ui/components/controls/curves/curves-control.tsx +445 -0
  178. package/templates/ui/components/controls/curves/index.ts +6 -0
  179. package/templates/ui/components/controls/file-drop/file-drop-control.tsx +191 -0
  180. package/templates/ui/components/controls/file-drop/index.ts +5 -0
  181. package/templates/ui/components/controls/font-picker/font-catalog.json +15360 -0
  182. package/templates/ui/components/controls/font-picker/font-catalog.ts +116 -0
  183. package/templates/ui/components/controls/font-picker/font-picker-control.tsx +1202 -0
  184. package/templates/ui/components/controls/font-picker/font-preview-loader.ts +336 -0
  185. package/templates/ui/components/controls/font-picker/index.ts +24 -0
  186. package/templates/ui/components/controls/font-picker/use-hover-intent.ts +46 -0
  187. package/templates/ui/components/controls/gradient/gradient-control-utils.ts +190 -0
  188. package/templates/ui/components/controls/gradient/gradient-control.tsx +612 -0
  189. package/templates/ui/components/controls/gradient/gradient-stop-list.tsx +400 -0
  190. package/templates/ui/components/controls/gradient/gradient-toolbar.tsx +152 -0
  191. package/templates/ui/components/controls/gradient/index.ts +4 -0
  192. package/templates/ui/components/controls/image-picker/image-picker-control.tsx +139 -0
  193. package/templates/ui/components/controls/image-picker/index.ts +7 -0
  194. package/templates/ui/components/controls/index.ts +192 -0
  195. package/templates/ui/components/controls/range-input/index.ts +4 -0
  196. package/templates/ui/components/controls/range-input/range-input-control.tsx +173 -0
  197. package/templates/ui/components/controls/range-slider/index.ts +4 -0
  198. package/templates/ui/components/controls/range-slider/range-slider-control.tsx +122 -0
  199. package/templates/ui/components/controls/range-slider/range-slider-value.ts +61 -0
  200. package/templates/ui/components/controls/segmented/index.ts +8 -0
  201. package/templates/ui/components/controls/segmented/segmented-control.tsx +94 -0
  202. package/templates/ui/components/controls/select/index.ts +4 -0
  203. package/templates/ui/components/controls/select/select-control.tsx +223 -0
  204. package/templates/ui/components/controls/slider/index.ts +4 -0
  205. package/templates/ui/components/controls/slider/slider-control.tsx +150 -0
  206. package/templates/ui/components/controls/slider/slider-value.ts +56 -0
  207. package/templates/ui/components/controls/text-input/index.ts +4 -0
  208. package/templates/ui/components/controls/text-input/text-input-control.tsx +158 -0
  209. package/templates/ui/components/controls/use-measured-element-width.ts +42 -0
  210. package/templates/ui/components/controls/vector/index.ts +8 -0
  211. package/templates/ui/components/controls/vector/vector-control.tsx +401 -0
  212. package/templates/ui/components/panel/index.ts +19 -0
  213. package/templates/ui/components/panel/panel-actions.tsx +165 -0
  214. package/templates/ui/components/panel/panel-header.tsx +61 -0
  215. package/templates/ui/components/panel/panel-icon-button.tsx +96 -0
  216. package/templates/ui/components/panel/panel-section.tsx +168 -0
  217. package/templates/ui/components/panel/panel-surface.tsx +206 -0
  218. package/templates/ui/components/panel/panel.tsx +210 -0
  219. package/templates/ui/components/primitives/animated-loader.tsx +61 -0
  220. package/templates/ui/components/primitives/button-group.tsx +134 -0
  221. package/templates/ui/components/primitives/button.tsx +429 -0
  222. package/templates/ui/components/primitives/checkbox.tsx +62 -0
  223. package/templates/ui/components/primitives/editable-slider-value-label.tsx +337 -0
  224. package/templates/ui/components/primitives/field.tsx +225 -0
  225. package/templates/ui/components/primitives/index.ts +82 -0
  226. package/templates/ui/components/primitives/input-group.tsx +298 -0
  227. package/templates/ui/components/primitives/input.tsx +61 -0
  228. package/templates/ui/components/primitives/internal/button-loading.tsx +178 -0
  229. package/templates/ui/components/primitives/label.tsx +16 -0
  230. package/templates/ui/components/primitives/popover.tsx +126 -0
  231. package/templates/ui/components/primitives/portal-layer-context.tsx +33 -0
  232. package/templates/ui/components/primitives/primitive-arrow-icon.tsx +38 -0
  233. package/templates/ui/components/primitives/scroll-fade-logic.ts +441 -0
  234. package/templates/ui/components/primitives/scroll-fade-render.tsx +75 -0
  235. package/templates/ui/components/primitives/scroll-fade-types.ts +41 -0
  236. package/templates/ui/components/primitives/scroll-fade.tsx +72 -0
  237. package/templates/ui/components/primitives/select.tsx +408 -0
  238. package/templates/ui/components/primitives/selection-state.ts +31 -0
  239. package/templates/ui/components/primitives/separator.tsx +21 -0
  240. package/templates/ui/components/primitives/slider/index.ts +4 -0
  241. package/templates/ui/components/primitives/slider/slider-interaction.tsx +96 -0
  242. package/templates/ui/components/primitives/slider/slider-parts.tsx +303 -0
  243. package/templates/ui/components/primitives/slider/slider-reset.ts +152 -0
  244. package/templates/ui/components/primitives/slider/slider-value.ts +114 -0
  245. package/templates/ui/components/primitives/slider/slider.tsx +511 -0
  246. package/templates/ui/components/primitives/switch.tsx +35 -0
  247. package/templates/ui/components/primitives/textarea.tsx +49 -0
  248. package/templates/ui/components/primitives/toggle-group.tsx +114 -0
  249. package/templates/ui/components/primitives/toggle.tsx +46 -0
  250. package/templates/ui/components/primitives/tooltip.tsx +100 -0
  251. package/templates/ui/hooks/use-mobile.ts +21 -0
  252. package/templates/ui/index.ts +31 -0
  253. package/templates/ui/lib/control-outline.ts +3 -0
  254. package/templates/ui/lib/input-control-style.ts +131 -0
  255. package/templates/ui/lib/style-guide-color-utils.ts +111 -0
  256. package/templates/ui/lib/utils.ts +6 -0
  257. package/templates/ui/styles.css +291 -0
@@ -0,0 +1,1340 @@
1
+ import type {
2
+ ToolcraftComponentContract,
3
+ ToolcraftControlDecisionCatalog,
4
+ ToolcraftLabelPolicy,
5
+ ToolcraftPanelPlacement,
6
+ ToolcraftPanelSnapEdge,
7
+ ToolcraftSectionLayout,
8
+ } from "./types";
9
+
10
+ export type * from "./types";
11
+
12
+ export const TOOLCRAFT_COMPONENT_CONTRACTS = {
13
+ slider: {
14
+ ...control("slider", "Slider", "grouped", "required"),
15
+ decisionCatalog: decisionCatalog({
16
+ strictness: "best-fit",
17
+ ownsValueModel: [
18
+ "single numeric value",
19
+ "bounded continuous range",
20
+ "bounded stepped range",
21
+ "small semantic integer range",
22
+ ],
23
+ useWhen: [
24
+ "Use Slider for one numeric value inside fixed min and max bounds.",
25
+ "Use Slider when dragging through approximate values is useful and every intermediate value is valid.",
26
+ "Use variant discrete only for small semantic integer domains where markers help choose positions.",
27
+ ],
28
+ doNotReplaceWith: [
29
+ "Do not use Slider for finite named options; use Select or Segmented.",
30
+ "Do not use two Slider controls for a lower/upper range; use RangeSlider or RangeInput.",
31
+ "Do not use Slider as a detached opacity field for a color entity; use ColorOpacity.",
32
+ ],
33
+ acceptableAlternatives: [
34
+ "Use Select for small named option sets.",
35
+ "Use RangeSlider or RangeInput for from/to ranges.",
36
+ ],
37
+ layoutConstraints: [
38
+ "Schema sliders stay stacked at full width.",
39
+ "Only FontPicker may pair its internal letter-spacing and line-height sliders.",
40
+ ],
41
+ requiredAcceptance: [
42
+ "Prove changing the slider changes product output or the intended runtime side effect.",
43
+ "For discrete sliders, prove the discrete variant renders markers and dragging remains smooth.",
44
+ ],
45
+ }),
46
+ aiUsageRules: [
47
+ "Slider step means numeric snapping only; it does not make the slider visually discrete by itself.",
48
+ "Classify every stepped slider as stepped continuous or visual discrete before writing the schema.",
49
+ 'Small semantic integer domains such as rows, cols, gaps, jitter, counts, levels, bands, passes, points, tiles, and segments must use variant: "discrete".',
50
+ 'Finite animation step domains such as flip depth, character count, glyph steps, and frame steps must use variant: "discrete" when the marker count stays within the Toolcraft visual budget.',
51
+ "Large or precision stepped ranges such as speed, FPS, rate, duration, density, size, and intensity stay visually continuous even when they declare step.",
52
+ "Schema sliders render stacked at full width; do not put sliders in two-column inline layout groups.",
53
+ "The fontPicker component is the only built-in exception with two internal footer sliders for letter spacing and line height.",
54
+ "For a small named option set, prefer Select or Segmented instead of forcing a discrete Slider.",
55
+ 'Specs, plans, and app-schema tests must assert explicit discrete sliders render as variant: "discrete" with markers derived from min, max, and step.',
56
+ 'Browser verification can inspect [data-slot="slider"][data-variant="discrete"] plus slider markers to prove the Toolcraft component variant rendered.',
57
+ "Visual discrete sliders must still drag smoothly; browser performance tests should use expectToolcraftDiscreteSliderDragSmoothness for real pointer drag.",
58
+ "Use schema disabled: true for unavailable sliders; do not recreate a disabled-looking slider with custom markup.",
59
+ "Use disabledWhen for sliders that are only meaningful in some mode values, such as Fill level and Islands being disabled when Fill mode is Full.",
60
+ "Do not leave a mode-dependent slider active while making the renderer ignore it; the UI must expose the unavailable state.",
61
+ ],
62
+ },
63
+ rangeSlider: {
64
+ ...control("rangeSlider", "RangeSlider", "grouped", "required"),
65
+ decisionCatalog: decisionCatalog({
66
+ strictness: "exact-owner",
67
+ ownsValueModel: [
68
+ "numeric lower and upper bounds",
69
+ "from/to numeric range",
70
+ "two-thumb bounded interval",
71
+ ],
72
+ useWhen: [
73
+ "Use RangeSlider when users edit lower and upper bounds on the same numeric scale.",
74
+ "Use RangeSlider when the relationship between the two values matters visually.",
75
+ ],
76
+ doNotReplaceWith: [
77
+ "Do not replace RangeSlider with two independent Slider controls.",
78
+ "Do not place RangeSlider beside another slider in an inline row.",
79
+ ],
80
+ acceptableAlternatives: [
81
+ "Use RangeInput when manual exact text entry matters more than dragging handles.",
82
+ ],
83
+ layoutConstraints: [
84
+ "RangeSlider is always full-width and stacked.",
85
+ "Default lower and upper values must be different.",
86
+ ],
87
+ requiredAcceptance: [
88
+ "Prove rangeSlider.lower and rangeSlider.upper both affect product output.",
89
+ ],
90
+ }),
91
+ aiUsageRules: [
92
+ "Range slider step means numeric snapping only; it does not make the range slider visually discrete by itself.",
93
+ "Classify every stepped range slider as stepped continuous or visual discrete before writing the schema.",
94
+ 'Small semantic integer domains such as rows, cols, gaps, jitter, counts, levels, bands, passes, points, tiles, and segments must use variant: "discrete".',
95
+ 'Finite animation step domains such as flip depth, character count, glyph steps, and frame steps must use variant: "discrete" when the marker count stays within the Toolcraft visual budget.',
96
+ "Large or precision stepped ranges such as speed, FPS, rate, duration, density, size, and intensity stay visually continuous even when they declare step.",
97
+ "RangeSlider is always a full-width two-thumb control; never place it in an inline two-column layout group with another slider or range slider.",
98
+ "RangeSlider defaultValue must start with different lower and upper values so the two-thumb control does not collapse into a single-value slider.",
99
+ "Manual range value editing accepts common separators such as slash, hyphen, spaces, and dashes; do not create custom parsers for RangeSlider labels.",
100
+ 'Specs, plans, and app-schema tests must assert explicit discrete range sliders render as variant: "discrete" with markers derived from min, max, and step.',
101
+ "Visual discrete sliders must still drag smoothly; browser performance tests should use expectToolcraftDiscreteSliderDragSmoothness for real pointer drag.",
102
+ "Use schema disabled: true for unavailable range sliders; do not recreate a disabled-looking range slider with custom markup.",
103
+ "Use disabledWhen for range sliders that are only meaningful in some mode values; keep the value so it returns when the mode becomes relevant again.",
104
+ "Do not leave a mode-dependent range slider active while making the renderer ignore it; the UI must expose the unavailable state.",
105
+ "Acceptance must prove both rangeSlider.lower and rangeSlider.upper change the product output; testing one handle is not enough.",
106
+ ],
107
+ },
108
+ select: {
109
+ ...control("select", "Select", "grouped", "required"),
110
+ decisionCatalog: decisionCatalog({
111
+ strictness: "best-fit",
112
+ ownsValueModel: [
113
+ "finite single selection",
114
+ "long option labels",
115
+ "many options",
116
+ "segmented fallback",
117
+ ],
118
+ useWhen: [
119
+ "Use Select for finite choices with long labels, many options, or values that would not fit in Segmented.",
120
+ "Use Select when a compact dropdown is more readable than a row of cells.",
121
+ ],
122
+ doNotReplaceWith: [
123
+ "Do not use Select to recreate FontPicker, Gradient, ImagePicker, FileDrop, Curves, Vector, or Palette value models.",
124
+ ],
125
+ acceptableAlternatives: [
126
+ "Use Segmented for two to four short closely related options that fit without clipping.",
127
+ ],
128
+ layoutConstraints: [
129
+ "Prefer compact two-column inline layout for related short Select pairs that tune one workflow or entity.",
130
+ "Use vertical one-select-per-row layout only as a fallback when a label, selected value, or option text would clip, truncate, or lose internal padding in the compact row.",
131
+ "If a compact Select pair falls back to vertical layout, record the fit reason in the spec or worklog.",
132
+ ],
133
+ requiredAcceptance: [
134
+ "Prove every visible option or representative option set changes product output or interpreted product state.",
135
+ ],
136
+ }),
137
+ },
138
+ segmented: {
139
+ ...control("segmented", "Segmented", "grouped", "required"),
140
+ decisionCatalog: decisionCatalog({
141
+ strictness: "best-fit",
142
+ ownsValueModel: [
143
+ "compact finite mode choice",
144
+ "two to four short related options",
145
+ "single-row mode toggle",
146
+ ],
147
+ useWhen: [
148
+ "Use Segmented for compact mode choices where every cell keeps internal padding.",
149
+ "Use Segmented when the options are short, closely related, and easier to compare side by side.",
150
+ ],
151
+ doNotReplaceWith: [
152
+ "Do not use Segmented for long labels, many options, or values that clip.",
153
+ "Do not use Segmented for actions; use buttons or panelActions.",
154
+ ],
155
+ acceptableAlternatives: [
156
+ "Use Select when options are long, numerous, or break segmented cell padding.",
157
+ ],
158
+ layoutConstraints: [
159
+ "Keep text segmented controls to at most four options and compact labels.",
160
+ "Fallback to Select when cells collide, clip, or lose padding.",
161
+ ],
162
+ requiredAcceptance: [
163
+ "Prove every visible segment changes the relevant product mode or output.",
164
+ "Browser verification must treat clipped or paddingless cells as broken.",
165
+ ],
166
+ }),
167
+ aiUsageRules: [
168
+ "Use Segmented only for compact mode choices where every cell keeps its internal padding.",
169
+ "If a segmented control is too wide, first shorten option labels; if the compact labels still exceed the width budget, use Select because it has the same selection mechanics without broken cells.",
170
+ "Generated schemas should keep text segmented controls to at most four options, no option label longer than nine characters, and no more than twenty-four total option-label characters.",
171
+ "Browser verification must treat collided, clipped, or paddingless segmented cells as a broken component and switch to shorter labels or Select.",
172
+ ],
173
+ },
174
+ switch: {
175
+ ...control("switch", "Switch", "grouped", "required"),
176
+ decisionCatalog: decisionCatalog({
177
+ strictness: "best-fit",
178
+ ownsValueModel: [
179
+ "immediate binary setting",
180
+ "on/off product behavior",
181
+ "enabled/disabled runtime option",
182
+ ],
183
+ useWhen: [
184
+ "Use Switch for a binary setting that applies immediately.",
185
+ "Use Switch for options such as Glow, Loop, CRT, Background, or Guides.",
186
+ ],
187
+ doNotReplaceWith: [
188
+ "Do not use Switch for more than two options.",
189
+ "Do not use Switch for destructive actions or commands that need confirmation.",
190
+ ],
191
+ acceptableAlternatives: [
192
+ "Use Checkbox when the option is an explicit inclusion flag.",
193
+ "Use Select or Segmented for more than two options.",
194
+ ],
195
+ layoutConstraints: [
196
+ "Two adjacent Switch controls for the same product entity must share one inline row when both labels fit; the runtime auto-pairs safe adjacent switches by target entity when no explicit layout group is needed.",
197
+ ],
198
+ requiredAcceptance: [
199
+ "Prove toggling the switch changes the product output or runtime behavior.",
200
+ ],
201
+ }),
202
+ aiUsageRules: [
203
+ 'Switch labels name the setting context only; do not prefix labels with "Enable" or "Disable" because the switch already communicates on/off behavior.',
204
+ 'Use labels such as "CRT", "Background", "Glow", or "Loop" instead of "Enable CRT" or "Disable background".',
205
+ "Two adjacent Switch controls for the same product entity must share one inline row when every visible label fits without truncation. Keep paired labels to short one- or two-word names; the runtime auto-pairs safe adjacent switches by target entity, and generated schemas should stack switches only when any label would truncate.",
206
+ "When the nearest section title already names the switch context, do not duplicate that title as the visible switch label. Use label false for a visual-only toggle and keep the meaning in target/description.",
207
+ "A Switch may share an inline row with one related parameter control when the visible switch label is short enough to fit. Hide the switch label when the section title provides the visible context, such as Include background plus Background color inside Background.",
208
+ ],
209
+ },
210
+ checkbox: {
211
+ ...control("checkbox", "Checkbox", "grouped", "required"),
212
+ decisionCatalog: decisionCatalog({
213
+ strictness: "best-fit",
214
+ ownsValueModel: [
215
+ "explicit optional flag",
216
+ "included/excluded choice",
217
+ "binary checklist state",
218
+ ],
219
+ useWhen: [
220
+ "Use Checkbox when the product meaning is an explicit optional flag or inclusion choice.",
221
+ ],
222
+ doNotReplaceWith: [
223
+ "Do not use Checkbox for immediate setting toggles that read more naturally as Switch.",
224
+ "Do not use Checkbox for commands.",
225
+ ],
226
+ acceptableAlternatives: [
227
+ "Use Switch for immediate on/off settings.",
228
+ "Use Select or Segmented for more than two options.",
229
+ ],
230
+ layoutConstraints: [
231
+ "Two adjacent Checkbox controls for the same product entity must share one inline row when both labels fit; the runtime auto-pairs safe adjacent checkboxes by target entity when no explicit layout group is needed.",
232
+ ],
233
+ requiredAcceptance: [
234
+ "Prove checking and unchecking changes product output or runtime behavior.",
235
+ ],
236
+ }),
237
+ aiUsageRules: [
238
+ 'Checkbox labels name the setting context only; do not prefix labels with "Enable" or "Disable" because the checkbox already communicates enabled/selected state.',
239
+ 'Use labels such as "Transparent background", "Guides", or "Loop" instead of "Enable transparent background".',
240
+ "When the nearest section title already names the checkbox context, do not duplicate that title as the visible checkbox label. Use label false for a visual-only checkbox and keep the meaning in target/description.",
241
+ "Two adjacent Checkbox controls for the same product entity must share one inline row when every visible label fits without truncation. Keep paired labels to short one- or two-word names; the runtime auto-pairs safe adjacent checkboxes by target entity, and generated schemas should stack checkboxes only when any label would truncate.",
242
+ "A Checkbox may share an inline row with one related parameter control when the visible checkbox label is short enough to fit. Hide the checkbox label when the section title provides the visible context.",
243
+ ],
244
+ },
245
+ colorOpacity: {
246
+ ...control("colorOpacity", "ColorOpacity", "standalone", "component-owned"),
247
+ decisionCatalog: decisionCatalog({
248
+ strictness: "exact-owner",
249
+ ownsValueModel: [
250
+ "color plus opacity for one entity",
251
+ "hex color and percent opacity",
252
+ ],
253
+ useWhen: [
254
+ "Use ColorOpacity when one product entity owns both a color and opacity.",
255
+ ],
256
+ doNotReplaceWith: [
257
+ "Do not split ColorOpacity into separate Color and opacity Slider/Input controls.",
258
+ ],
259
+ acceptableAlternatives: [
260
+ "Use Color only when opacity is not editable.",
261
+ "Use Gradient when the entity is a color transition or gradient fill.",
262
+ ],
263
+ layoutConstraints: [
264
+ "ColorOpacity stays stacked and does not share inline color rows.",
265
+ ],
266
+ requiredAcceptance: [
267
+ "Prove colorOpacity.hex and colorOpacity.opacity both affect product output.",
268
+ ],
269
+ }),
270
+ aiUsageRules: [
271
+ "Use ColorOpacity when one product entity needs both a color and an opacity value, such as text color, shadow color, glow color, overlay color, or stroke color.",
272
+ "Do not split ColorOpacity into a separate Color plus Slider/Input for opacity; use type: \"colorOpacity\" so the color popover and percent input stay visually connected.",
273
+ "ColorOpacity is the only color control variant that may expose opacity in the color picker popover; plain Color popovers hide opacity controls.",
274
+ "Use one object value with hex and opacity. Renderers and exports must consume both parts.",
275
+ "Do not place ColorOpacity in inline two-column layout groups. If either color control has opacity, keep the controls stacked.",
276
+ "Only plain Color controls without opacity may render in two-column color rows.",
277
+ "Acceptance must prove colorOpacity.hex and colorOpacity.opacity both affect the product output; testing only the swatch or only runtime state is not enough.",
278
+ ],
279
+ },
280
+ text: {
281
+ ...control("text", "TextInput", "grouped", "required"),
282
+ decisionCatalog: decisionCatalog({
283
+ strictness: "best-fit",
284
+ ownsValueModel: [
285
+ "short single-line text",
286
+ "single-line content",
287
+ "single-line setting value",
288
+ ],
289
+ useWhen: [
290
+ "Use TextInput for short names, titles, tokens, compact prompts, and small setting strings.",
291
+ "Use commitMode content for real product content and commitMode setting for configuration-like values.",
292
+ ],
293
+ doNotReplaceWith: [
294
+ "Do not use TextInput for long multiline content; use CodeTextarea.",
295
+ ],
296
+ acceptableAlternatives: [
297
+ "Use CodeTextarea for multiline or long structured content.",
298
+ "Use Select for finite choices.",
299
+ ],
300
+ layoutConstraints: [
301
+ "Short numeric/text pairs can share inline rows when they tune one product meaning.",
302
+ ],
303
+ requiredAcceptance: [
304
+ "Prove text edits change product content or the intended setting at the correct commit timing.",
305
+ ],
306
+ }),
307
+ aiUsageRules: [
308
+ 'TextInput commitMode defaults to "content": text content, prompts, names, tokens, titles, and instructions apply while typing.',
309
+ 'Use commitMode: "setting" for text inputs that edit settings such as font size, numeric-like style values, dimensions, ids, or configuration fields; setting text commits on blur or Enter.',
310
+ "Canvas width and Canvas height are runtime editable-size fields and always commit on blur or Enter like editor size fields.",
311
+ ],
312
+ },
313
+ rangeInput: {
314
+ ...control("rangeInput", "RangeInput", "grouped", "required"),
315
+ decisionCatalog: decisionCatalog({
316
+ strictness: "exact-owner",
317
+ ownsValueModel: [
318
+ "manual lower and upper values",
319
+ "from/to text range",
320
+ "compact paired range input",
321
+ ],
322
+ useWhen: [
323
+ "Use RangeInput when users need to type or inspect a lower and upper bound more than drag them.",
324
+ ],
325
+ doNotReplaceWith: [
326
+ "Do not replace RangeInput with two unrelated TextInput controls for one range.",
327
+ ],
328
+ acceptableAlternatives: [
329
+ "Use RangeSlider when dragging the range relationship is the primary interaction.",
330
+ ],
331
+ layoutConstraints: [
332
+ "Keep the two range fields together as one compound control.",
333
+ ],
334
+ requiredAcceptance: [
335
+ "Prove rangeInput.start and rangeInput.end both affect product output.",
336
+ ],
337
+ }),
338
+ aiUsageRules: [
339
+ "RangeInput is a compound control; acceptance must prove rangeInput.start and rangeInput.end both affect the product output.",
340
+ "Do not accept a range input test that edits only the first field or only checks runtime state.",
341
+ ],
342
+ },
343
+ actions: {
344
+ ...control("actions", "Actions", "grouped", "required"),
345
+ decisionCatalog: decisionCatalog({
346
+ strictness: "best-fit",
347
+ ownsValueModel: [
348
+ "local section action",
349
+ "small contextual command",
350
+ "non-sticky workflow command",
351
+ "entity-scoped command group",
352
+ ],
353
+ useWhen: [
354
+ "Use Actions for local commands inside a control section that affect the nearby entity.",
355
+ "Use Actions for section-scoped commands such as Randomize palette, Normalize weights, Sort glyphs, Clear selection, Duplicate item, or Reset current entity.",
356
+ ],
357
+ doNotReplaceWith: [
358
+ "Do not use Actions for final product export, copy, generate, apply, or download actions.",
359
+ "Do not use Actions for global reset; the panel header owns reset.",
360
+ "Do not use Actions for timeline transport such as Play, Pause, Resume, Restart, or Scrub.",
361
+ ],
362
+ acceptableAlternatives: [
363
+ "Use panelActions for sticky product delivery actions.",
364
+ "Use item-level icon buttons inside custom controls for local item remove/reorder commands.",
365
+ "Use the top TimelinePanel for animation transport commands.",
366
+ ],
367
+ layoutConstraints: [
368
+ "Keep local actions close to the entity they affect.",
369
+ "Keep action labels short and scoped by the section title; prefer Randomize, Clear, Sort, Normalize, Duplicate, or Reset when the section already names the target.",
370
+ ],
371
+ requiredAcceptance: [
372
+ "Prove each action dispatches the intended command or product side effect for the nearby entity only.",
373
+ ],
374
+ }),
375
+ commands: ["controls.reset", "controls.apply"],
376
+ stateMode: "command-only",
377
+ aiUsageRules: [
378
+ "Use Actions for local commands inside the current section when the command affects only the nearby entity or workflow step.",
379
+ "Good Actions examples: Randomize palette, Normalize weights, Sort glyphs, Clear selection, Duplicate item, Reset current layer, Reset current stop, or Shuffle shades.",
380
+ "Do not use Actions for final product delivery actions; use sticky panelActions for Export, Copy, Download, Generate, or Apply.",
381
+ "Do not use Actions for global reset; the controls panel header owns global reset.",
382
+ "Do not use Actions for animation transport; Play, Pause, Resume, Restart, and Scrub belong to the top timeline when timeline behavior exists.",
383
+ 'For local reset-like actions, use product-specific values such as "reset-current-layer" or "reset-palette" and handle them through ToolcraftApp onPanelAction; do not use a bare "reset" value unless the action intentionally runs controls.reset.',
384
+ "Acceptance and browser tests must click each Actions button and prove the product output or runtime state for the nearby entity changed.",
385
+ ],
386
+ },
387
+ panelActions: {
388
+ ...control("panelActions", "PanelActions", "standalone", "component-owned"),
389
+ decisionCatalog: decisionCatalog({
390
+ strictness: "exact-owner",
391
+ ownsValueModel: [
392
+ "sticky final product action",
393
+ "export action",
394
+ "copy action",
395
+ "generate action",
396
+ "apply action",
397
+ ],
398
+ useWhen: [
399
+ "Use panelActions for final product actions such as Export, Copy, Generate, Apply, or Download.",
400
+ ],
401
+ doNotReplaceWith: [
402
+ "Do not place final product action buttons on the canvas.",
403
+ "Do not use regular section Actions for final sticky export or generate actions.",
404
+ "Do not duplicate global Reset in panelActions.",
405
+ ],
406
+ acceptableAlternatives: [
407
+ "Use Actions only for local section commands.",
408
+ ],
409
+ layoutConstraints: [
410
+ "Footer actions are one compact sticky group with secondary on the left and primary on the right.",
411
+ ],
412
+ requiredAcceptance: [
413
+ "Prove panel actions execute real product side effects such as exported bytes, clipboard payload, or generated output.",
414
+ "For async panelActions, prove the sticky footer top accent indicator is visible while the returned Promise is pending, advances when reportProgress is called, and hides after it settles.",
415
+ ],
416
+ }),
417
+ aiUsageRules: [
418
+ "Use panelActions only for sticky footer product actions such as Generate, Export, Copy, or Download.",
419
+ "Do not use panelActions for resetting controls; the controls panel header owns Reset controls.",
420
+ "Handle product-specific panelActions through ToolcraftApp onPanelAction.",
421
+ "Async product actions such as Export, Download, Copy, Generate, or Apply must return the real Promise from onPanelAction and report progress through the onPanelAction reportProgress callback.",
422
+ "The sticky footer top accent indicator is determinate when reportProgress receives 0..1 values and falls back to pending state only when progress is unavailable.",
423
+ "defineToolcraft hoists panelActions into the controls panel sticky footer automatically.",
424
+ "Product-output apps must always include export in panelActions.",
425
+ "Static or still-output apps include Export PNG as the primary footer action.",
426
+ "Animated apps include Export Video as the primary footer action and Export PNG as a secondary footer action.",
427
+ 'Animated apps with Export Video must expose a separate "Video Export" controls section.',
428
+ 'The Video Export section must include format and resolution controls such as targets "export.video.format" and "export.video.resolution".',
429
+ "Use Select controls for Video Export format and resolution; do not use Segmented unless the product has a deliberately tiny fixed output menu and browser tests prove every cell keeps padding.",
430
+ 'Place the Video Export section as the final controls section directly above sticky footer panelActions.',
431
+ 'Video Export format defaults to "mp4"; keep "webm" available as the baseline alternate unless the prompt/reference requires another default.',
432
+ 'Video Export resolution defaults to "current"; keep "4k" available as the high-resolution alternate.',
433
+ "Video Export format and resolution are a compact semantic pair and should use a two-column inline layout by default; use stacked rows only when labels or selected values do not fit without clipping.",
434
+ 'Baseline browser video formats are "mp4" and "webm"; MOV or ProRes require an explicit custom encoder/transcoder and dedicated acceptance plus performance coverage.',
435
+ "Video export code must choose the actual MIME/container through MediaRecorder.isTypeSupported or an equivalent encoder capability check, then fall back safely.",
436
+ "Offline video export duration must be encoded from runtime timeline timestamps. Do not rely on canvas.captureStream plus MediaRecorder wall-clock recording time as the only duration mechanism for rendered-frame export.",
437
+ 'Video resolution must control exported dimensions. Use "current" output size by default; "4K" is an export resolution target, not a hardcoded 3840x2160 canvas lock.',
438
+ "Video export browser coverage must load the exported blob metadata and prove video.duration matches the edited runtime timeline duration; blobSize/blobType checks alone are not enough.",
439
+ "Video export must report frame-based progress through reportProgress during render/encode steps. PNG export should report phase progress for render, blob, and handoff when those phases are asynchronous.",
440
+ "Product-output apps must expose user-facing Background color and Include background controls, then pass the includeBackground runtime value to createToolcraftPngExportCanvas only for PNG alpha.",
441
+ "PNG export must use createToolcraftPngExportCanvas so background transparency and retina sizing are applied consistently without making live preview, workspace canvas backing, or video transparent.",
442
+ "Video export must keep product background and use getToolcraftRetinaExportSize for retina dimensions.",
443
+ "Copy PNG can be a secondary action when clipboard output is useful, but copy does not replace export.",
444
+ "Add Copy PNG as a secondary action only when the prompt/reference includes clipboard output or the product clearly benefits from paste/share workflows.",
445
+ "Footer actions must be one compact horizontal group; do not split them into stacked full-width sections.",
446
+ "If two footer actions are needed, render secondary/outline on the left and primary on the right.",
447
+ "When an odd number of footer actions renders in two columns, the final unpaired action spans the full row width.",
448
+ ],
449
+ commands: ["controls.apply"],
450
+ stateMode: "command-only",
451
+ },
452
+ palette: {
453
+ ...control("palette", "Palette", "standalone", "component-owned"),
454
+ decisionCatalog: decisionCatalog({
455
+ strictness: "best-fit",
456
+ ownsValueModel: [
457
+ "constrained palette choice",
458
+ "palette family and shade",
459
+ "design-token color selection",
460
+ "style-guide color token",
461
+ ],
462
+ useWhen: [
463
+ "Use Palette when users choose from a constrained palette family and shade rather than a free color value.",
464
+ "Use Palette for token-based color choices such as brand palettes, Tailwind-like shade scales, semantic palette families, or style-guide colors.",
465
+ ],
466
+ doNotReplaceWith: [
467
+ "Do not use Palette for arbitrary color picking.",
468
+ "Do not use Palette for gradients, free hex colors, text color inside FontPicker, or a color value that owns opacity.",
469
+ ],
470
+ acceptableAlternatives: [
471
+ "Use Color for a free single color.",
472
+ "Use ColorOpacity when opacity belongs to the same color entity.",
473
+ "Use Gradient for color transitions, gradient fills, stops, type, and angle.",
474
+ "Use FontPicker when the color belongs to product typography.",
475
+ ],
476
+ layoutConstraints: [
477
+ "Palette is a standalone compound control.",
478
+ "Palette renders content-width internal dividers only when it shares a panel section with sibling controls, with 18px vertical spacing between each divider and the control content; if it is the first control in that section, only the bottom internal divider renders, and if it is the only control in the section, only the parent section dividers render.",
479
+ ],
480
+ requiredAcceptance: [
481
+ "Prove palette.family and palette.shade both affect product output.",
482
+ ],
483
+ }),
484
+ aiUsageRules: [
485
+ "Use Palette only when the product value is a constrained design-token palette choice with both family and shade.",
486
+ "Good Palette examples: brand palette family and shade, Tailwind-like token color, style-guide color scale, semantic palette family, or theme accent token.",
487
+ "Do not use Palette for arbitrary free color picking; use Color instead.",
488
+ "Do not use Palette when opacity belongs to the same color entity; use ColorOpacity instead.",
489
+ "Do not use Palette for gradients or color transitions; use Gradient instead.",
490
+ "Do not split typography color out to Palette when the text styling belongs to FontPicker.",
491
+ "Palette is a compound control; acceptance must prove palette.family and palette.shade both affect the product output.",
492
+ "Do not accept a palette test that only changes a swatch preview without proving the renderer/export consumes the selected family and shade.",
493
+ ],
494
+ },
495
+ vector: {
496
+ ...control("vector", "Vector", "standalone", "component-owned"),
497
+ decisionCatalog: decisionCatalog({
498
+ strictness: "exact-owner",
499
+ ownsValueModel: [
500
+ "x/y vector",
501
+ "position",
502
+ "offset",
503
+ "direction",
504
+ "focus point",
505
+ "light vector",
506
+ "color balance pad",
507
+ ],
508
+ useWhen: [
509
+ "Use Vector for paired X/Y values such as position, offset, direction, focus, anchor, light direction, or color-balance movement.",
510
+ ],
511
+ doNotReplaceWith: [
512
+ "Do not replace Vector with two unrelated sliders or text inputs when direct two-axis editing is the product interaction.",
513
+ ],
514
+ acceptableAlternatives: [
515
+ "Use two numeric text fields only when exact numeric entry is the primary product requirement.",
516
+ ],
517
+ layoutConstraints: [
518
+ "One vector renders as a square pad; multiple vectors render compact pads.",
519
+ ],
520
+ requiredAcceptance: [
521
+ "Prove vector.x and vector.y both affect product output.",
522
+ ],
523
+ }),
524
+ aiUsageRules: [
525
+ "If the controls panel contains exactly one vector control, the runtime renders the vector pad as a square.",
526
+ "If the controls panel contains multiple vector controls, the runtime renders compact vector pads.",
527
+ "Multiple vector controls should live in separate semantic sections unless they intentionally belong to the same entity with other related controls.",
528
+ 'Use variant: "whiteBalance" for temperature/tint pads: X maps cool blue to warm amber, Y maps green to magenta.',
529
+ 'Use variant: "colorBalance" for paired color-balance axes such as cyan/red and blue/yellow correction.',
530
+ 'Use variant: "chromaOffset" for RGB/chromatic offset vectors where the X/Y movement controls channel separation.',
531
+ 'Use variant: "toneBias" for split-tone, duotone, or color-grading vectors where both axes describe tone or hue bias.',
532
+ 'Use the default vector variant for spatial values such as position, offset, direction, focus, anchor, and light direction.',
533
+ "Do not add custom vector sizing props in generated schemas; choose the number, variant, and section grouping from product need and let the runtime size the pads.",
534
+ "Vector is a compound control; acceptance must prove vector.x and vector.y both affect the product output.",
535
+ ],
536
+ },
537
+ color: {
538
+ ...control("color", "Color", "standalone", "component-owned"),
539
+ decisionCatalog: decisionCatalog({
540
+ strictness: "best-fit",
541
+ ownsValueModel: [
542
+ "single free color",
543
+ "hex color value",
544
+ "role color",
545
+ ],
546
+ useWhen: [
547
+ "Use Color for one editable free color without opacity or gradient stops.",
548
+ ],
549
+ doNotReplaceWith: [
550
+ "Do not use multiple Color controls as a substitute for an adjustable Gradient.",
551
+ "Do not pair Color with a separate opacity control when ColorOpacity fits.",
552
+ ],
553
+ acceptableAlternatives: [
554
+ "Use ColorOpacity when opacity belongs to the color entity.",
555
+ "Use Gradient for color transitions, fills with stops, or angle/type editing.",
556
+ "Use Palette for constrained design-token choices.",
557
+ ],
558
+ layoutConstraints: [
559
+ "Plain Color controls may render two per row only when no opacity is present.",
560
+ "Color fields in mixed sections need visible labels.",
561
+ ],
562
+ requiredAcceptance: [
563
+ "Prove the selected color affects product output, preview, or export.",
564
+ ],
565
+ }),
566
+ aiUsageRules: [
567
+ "Color controls can be standalone color sections or grouped fields inside a semantic control section.",
568
+ "First identify the semantic entity the color belongs to, such as Square 1, Square 2, Background, Object, Connector, Glow, Tone Mapping, Brand, or Export.",
569
+ "Keep a color inside a section when it configures the same entity as nearby controls. Example: Square 1 (Right) contains Connections, Hover radius, and Color in one section.",
570
+ "Use a standalone color section only when the color itself is the whole semantic section; the section title must describe the product role such as Background, Object, Connector, Accent, Gradient, or Brand.",
571
+ "When color belongs to the same object or effect as nearby controls, keep it inside that section and use a concise field label that is unambiguous in context, such as Color in a Square section or Symbol color in a mixed Style section.",
572
+ "Show visible labels for Color and ColorOpacity controls inside mixed sections that contain any non-color controls.",
573
+ "Omit visible color field labels only when the section contains color controls and no other control types.",
574
+ "The standalone default applies only to color-only sections; mixed semantic sections keep color grouped with nearby controls.",
575
+ "Never use generic Color or Colors as a generated section title. If no meaningful color role exists and the colors are just basic colors, use a neutral section title such as Appearance instead of omitting the title.",
576
+ "Do not split a grouped object section into a separate generated Color section; if the color role is unclear, ask the user before implementation.",
577
+ "When one short numeric/text field and one Color field configure the same entity, keep them in one two-column inline layout group.",
578
+ "Mixed inline rows require visible labels on both controls except for section-title-owned hidden-label toggle plus parameter rows. Color fields in other mixed rows must not be unlabeled.",
579
+ "Plain Color popovers must not show opacity controls. If opacity is editable, use ColorOpacity instead.",
580
+ "Product-output apps always expose renderer-owned output background color as a schema color target such as appearance.background or scene.background.",
581
+ "Pair renderer-owned output background color with export.includeBackground in one Background section. Prefer an inline hidden-label toggle plus color parameter row when the section title supplies the Background context.",
582
+ "Preview, PNG export, and video export must read the runtime background color value instead of hardcoding that background in CSS, Canvas fillStyle, or WebGL clearColor. export.includeBackground controls only PNG alpha; it must not make live preview, workspace canvas backing, or video transparent.",
583
+ "Render multiple related color fields in one section with at most two colors per row.",
584
+ ],
585
+ },
586
+ gradient: {
587
+ ...control("gradient", "Gradient", "standalone", "component-owned"),
588
+ decisionCatalog: decisionCatalog({
589
+ strictness: "exact-owner",
590
+ ownsValueModel: [
591
+ "gradient fill",
592
+ "gradient type",
593
+ "gradient angle",
594
+ "gradient stops",
595
+ "stop colors",
596
+ "stop opacity",
597
+ "stop positions",
598
+ ],
599
+ useWhen: [
600
+ "Use Gradient when the product needs an adjustable gradient, color transition, multi-stop fill, linear fill, radial fill, angular fill, or diamond fill.",
601
+ "Use Gradient when the prompt or reference mentions gradient stops, gradient angle, gradient type, or editable color transition.",
602
+ ],
603
+ doNotReplaceWith: [
604
+ "Do not replace Gradient with two Color controls.",
605
+ "Do not replace Gradient with ColorOpacity plus sliders.",
606
+ "Do not build custom gradient UI unless the built-in Gradient cannot express the interaction and the custom escape hatch is documented.",
607
+ ],
608
+ acceptableAlternatives: [
609
+ "Use Color or ColorOpacity only when the product explicitly needs fixed single colors, not an adjustable gradient.",
610
+ ],
611
+ layoutConstraints: [
612
+ "Gradient is a full standalone compound control.",
613
+ "Gradient renders content-width internal dividers only when it shares a panel section with sibling controls, with 18px vertical spacing between each divider and the control content; if it is the first control in that section, only the bottom internal divider renders, and if it is the only control in the section, only the parent section dividers render.",
614
+ ],
615
+ requiredAcceptance: [
616
+ "Prove gradientType, angle, stop position, stop color, and stop opacity affect product output or export output.",
617
+ ],
618
+ }),
619
+ aiUsageRules: [
620
+ "Gradient is a compound control; acceptance must prove gradient.gradientType, gradient.angle, gradient.stops.position, gradient.stops.color, and gradient.stops.opacity all affect the product output when visible.",
621
+ "Keep Gradient type/angle, draggable stop track, and Stops list inside the built-in Gradient control. The full Gradient control is visually separated with content-width dividers only when it shares a section with sibling controls; do not put dividers only around the Stops list and do not rebuild it as separate schema controls.",
622
+ "Do not accept a gradient test that edits only a stop color; Linear/Radial/Angular/Diamond selection, angle, stop position, stop color, and stop opacity must be wired or the control should be simplified.",
623
+ "If the renderer intentionally supports only a subset of gradient behavior, do not use the full Gradient control; use simpler controls that match the renderer behavior.",
624
+ ],
625
+ },
626
+ fontPicker: {
627
+ ...control("fontPicker", "FontPicker", "standalone", "component-owned"),
628
+ decisionCatalog: decisionCatalog({
629
+ strictness: "exact-owner",
630
+ ownsValueModel: [
631
+ "font family",
632
+ "font preview",
633
+ "font weight",
634
+ "font size",
635
+ "text case",
636
+ "letter spacing",
637
+ "line height",
638
+ "text color",
639
+ "text opacity",
640
+ ],
641
+ useWhen: [
642
+ "Use FontPicker when product typography needs font family, weight, size, case, letter spacing, line height, text color, or text opacity.",
643
+ ],
644
+ doNotReplaceWith: [
645
+ "Do not replace FontPicker with a plain Select plus separate typography controls.",
646
+ "Do not build a custom font popup for product typography.",
647
+ "Do not add sibling controls for text color, text opacity, case, weight, size, letter spacing, or line height when they belong to the same typography entity.",
648
+ ],
649
+ acceptableAlternatives: [
650
+ "Use TextInput or Select only for non-typographic labels or finite text choices.",
651
+ ],
652
+ layoutConstraints: [
653
+ "FontPicker owns its popup and internal footer controls.",
654
+ "FontPicker renders content-width internal dividers only when it shares a panel section with sibling controls, with 18px vertical spacing between each divider and the control content; if it is the first control in that section, only the bottom internal divider renders, and if it is the only control in the section, only the parent section dividers render.",
655
+ ],
656
+ requiredAcceptance: [
657
+ "Prove fontId, fontWeight, fontSize, letterSpacing, lineHeight, textCase, color, and opacity affect actual product text output.",
658
+ ],
659
+ }),
660
+ aiUsageRules: [
661
+ "FontPicker owns the font preview select, virtualized font popup, category filters, search, preview loading, font-weight select, font-size input, text-case select, text color/opacity control, letter-spacing slider, and line-height slider.",
662
+ "Do not recreate FontPicker with a plain Select plus separate sliders; use type: \"fontPicker\" so the popup mechanics and footer controls stay intact.",
663
+ "Use one object value with fontId, fontWeight, fontSize, letterSpacing, lineHeight, textCase, color, and opacity. Keep typography renderers wired to all eight parts.",
664
+ "Any product text controlled by FontPicker must render fontId, fontWeight, fontSize, letterSpacing, lineHeight, textCase, color, and opacity in preview and export; do not leave typography values as panel-only runtime state.",
665
+ "FontPicker is an atomic compound typography control. Do not split any owned typography part into a neighboring schema control for the same product text entity.",
666
+ "Do not put a help tooltip on FontPicker just to list its owned fields. If the section title and FontPicker labels already make the text target clear, omit description.",
667
+ "FontPicker is a compound control; acceptance must prove fontPicker.fontId, fontPicker.fontWeight, fontPicker.fontSize, fontPicker.letterSpacing, fontPicker.lineHeight, fontPicker.textCase, fontPicker.color, and fontPicker.opacity all affect the product output.",
668
+ "FontPicker acceptance must inspect the actual product text output after changing font, weight, size, letter spacing, line height, text case, color, and opacity; runtime state, select labels, or popup preview text alone are not enough.",
669
+ "Browser verification must open the popup, choose a different font, change font weight, change font size, change text case, change text color/opacity, move the letter-spacing footer slider, and move the line-height footer slider.",
670
+ ],
671
+ },
672
+ curves: {
673
+ ...control("curves", "Curves", "standalone", "component-owned"),
674
+ decisionCatalog: decisionCatalog({
675
+ strictness: "exact-owner",
676
+ ownsValueModel: [
677
+ "editable curve",
678
+ "tone curve",
679
+ "response curve",
680
+ "easing curve",
681
+ "remapping curve",
682
+ "channel curve",
683
+ ],
684
+ useWhen: [
685
+ "Use Curves for editable remapping, tone, response, easing, opacity, depth, mask, or channel curves.",
686
+ ],
687
+ doNotReplaceWith: [
688
+ "Do not replace Curves with generic sliders when the product needs an editable curve.",
689
+ "Do not build custom curve UI just to remove RGB tabs; use variant single.",
690
+ ],
691
+ acceptableAlternatives: [
692
+ "Use Slider only when the product needs one scalar strength value, not a curve shape.",
693
+ ],
694
+ layoutConstraints: [
695
+ "Use variant single for one standalone curve and RGB variant only for color-correction or channel-specific curves.",
696
+ "Single Curves is one labeled control and does not render internal dividers, even inside mixed sections.",
697
+ "RGB Curves is a compound channel control and renders content-width internal dividers only when it shares a panel section with sibling controls, with 18px vertical spacing between each rendered divider and the control content; if it is the first control in that section, only the bottom internal divider renders and the top internal padding is removed, and if it is the only control in the section, only the parent section dividers render.",
698
+ ],
699
+ requiredAcceptance: [
700
+ "Prove curves.points affect product output; RGB curves also prove activeChannel affects output.",
701
+ ],
702
+ }),
703
+ aiUsageRules: [
704
+ 'Use Curves for editable remapping curves. RGB/R/G/B tabs are only for color-correction or channel-specific curves; use variant: "single" for one standalone curve without channel tabs.',
705
+ 'Use variant: "single" for a single acceleration, bend, easing, opacity, response, depth, mask, threshold, tone-response, or mapping curve. Do not create a custom curve UI just to remove RGB tabs.',
706
+ "RGB Curves is a color-correction-specific case; do not force RGB/R/G/B tabs onto products that need only one response, bend, depth, or easing curve.",
707
+ 'Use interpolation: "smooth" for photo/editor-like visual tone, color, and RGB curves where the curve should feel like a creative editor spline.',
708
+ 'Use interpolation: "monotone" for depth, response, mask, opacity, threshold, and data-mapping curves where order must be preserved and overshoot is unsafe. Single curves default to monotone unless smooth is explicitly requested.',
709
+ "Single Curves is one labeled control without internal dividers; RGB Curves is the compound variant with channel tabs and section dividers when mixed with sibling controls.",
710
+ "RGB curves acceptance must prove curves.activeChannel and curves.points both affect the product output. Single curves acceptance proves curves.points.",
711
+ "Curves acceptance should include an off-center control point near an edge so smooth-vs-monotone interpolation mistakes are visible in product output.",
712
+ "Do not accept a curves test that only opens the UI or changes selected point state without proving renderer/export output changes.",
713
+ ],
714
+ },
715
+ anchorGrid: {
716
+ ...control("anchorGrid", "AnchorGrid", "standalone", "component-owned"),
717
+ decisionCatalog: decisionCatalog({
718
+ strictness: "best-fit",
719
+ ownsValueModel: [
720
+ "anchor position",
721
+ "edge or corner placement",
722
+ "nine-point alignment",
723
+ ],
724
+ useWhen: [
725
+ "Use AnchorGrid for choosing an anchor, alignment point, or edge/corner placement.",
726
+ ],
727
+ doNotReplaceWith: [
728
+ "Do not use AnchorGrid for freeform two-axis movement; use Vector.",
729
+ ],
730
+ acceptableAlternatives: [
731
+ "Use Vector for continuous position or direction.",
732
+ ],
733
+ layoutConstraints: [
734
+ "AnchorGrid is a standalone position selector.",
735
+ ],
736
+ requiredAcceptance: [
737
+ "Prove selected anchor changes product placement.",
738
+ ],
739
+ }),
740
+ aiUsageRules: [
741
+ "AnchorGrid is a position selector; acceptance must prove anchorGrid.position changes product placement, not only selected button state.",
742
+ "Choose representative edge/corner anchors in browser tests so center-only behavior cannot pass.",
743
+ ],
744
+ },
745
+ channelMixer: {
746
+ ...control("channelMixer", "ChannelMixer", "standalone", "component-owned"),
747
+ decisionCatalog: decisionCatalog({
748
+ strictness: "exact-owner",
749
+ ownsValueModel: [
750
+ "RGB channel mixer",
751
+ "RGB channel matrix",
752
+ "active RGB output channel and RGB source-channel values",
753
+ ],
754
+ useWhen: [
755
+ "Use ChannelMixer only when product behavior edits RGB channel mixing, channel swapping, or an RGB channel matrix.",
756
+ ],
757
+ doNotReplaceWith: [
758
+ "Do not replace ChannelMixer with disconnected sliders for each channel when the active channel matrix matters.",
759
+ "Do not use ChannelMixer for arbitrary non-RGB channels, data channels, audio bands, masks, layers, or option groups.",
760
+ ],
761
+ acceptableAlternatives: [
762
+ "Use Color or Curves for simple color choice or tone curves that are not channel matrix mixing.",
763
+ "Use Select, Segmented, Slider, Curves, or a justified custom control for non-RGB channel-like product domains.",
764
+ ],
765
+ layoutConstraints: [
766
+ "ChannelMixer is a standalone compound control.",
767
+ "ChannelMixer renders content-width internal dividers only when it shares a panel section with sibling controls, with 18px vertical spacing between each divider and the control content; if it is the first control in that section, only the bottom internal divider renders, and if it is the only control in the section, only the parent section dividers render.",
768
+ ],
769
+ requiredAcceptance: [
770
+ "Prove channelMixer.activeChannel and channelMixer.values both affect product output.",
771
+ ],
772
+ }),
773
+ aiUsageRules: [
774
+ "ChannelMixer is RGB-specific: it renders R/G/B tabs and Red, Green, Blue sliders for an RGB channel matrix.",
775
+ "Use ChannelMixer only for RGB channel mixing, channel swapping, or color-correction matrix behavior; do not use it for arbitrary channel lists.",
776
+ "ChannelMixer is a compound control; acceptance must prove channelMixer.activeChannel and channelMixer.values both affect the product output.",
777
+ "Do not accept a channel mixer test that changes only the active tab or only one slider without proving the selected channel matrix is consumed by the renderer/export.",
778
+ ],
779
+ },
780
+ fileDrop: {
781
+ ...control("fileDrop", "FileDrop", "standalone", "component-owned"),
782
+ decisionCatalog: decisionCatalog({
783
+ strictness: "exact-owner",
784
+ ownsValueModel: [
785
+ "source material upload",
786
+ "file import",
787
+ "media import",
788
+ "drop target",
789
+ ],
790
+ useWhen: [
791
+ "Use FileDrop for source material uploads, file import, or drag-and-drop media input.",
792
+ ],
793
+ doNotReplaceWith: [
794
+ "Do not place upload UI on the canvas.",
795
+ "Do not build custom file buttons for source media import.",
796
+ ],
797
+ acceptableAlternatives: [
798
+ "Use ImagePicker when users choose from built-in visual options rather than uploading a file.",
799
+ ],
800
+ layoutConstraints: [
801
+ "FileDrop lives in the controls panel; single-layer apps use its preview and clear behavior.",
802
+ ],
803
+ requiredAcceptance: [
804
+ "Prove file import changes media state and product output; prove clear removes source material.",
805
+ ],
806
+ }),
807
+ aiUsageRules: [
808
+ "Use fileDrop for source material uploads in the controls panel, not on the canvas.",
809
+ "In single-layer apps, the runtime shows the uploaded image as the fileDrop preview and provides the clear action.",
810
+ "In multi-layer apps, deletion and visibility belong to the Layers panel; fileDrop remains an upload target.",
811
+ ],
812
+ commands: ["media.delete", "media.import"],
813
+ },
814
+ imagePicker: {
815
+ ...control("imagePicker", "ImagePicker", "standalone", "component-owned"),
816
+ decisionCatalog: decisionCatalog({
817
+ strictness: "exact-owner",
818
+ ownsValueModel: [
819
+ "visual option choice",
820
+ "thumbnail selection",
821
+ "preset image choice",
822
+ ],
823
+ useWhen: [
824
+ "Use ImagePicker when users choose one visual option from a set of thumbnails or images.",
825
+ ],
826
+ doNotReplaceWith: [
827
+ "Do not recreate ImagePicker grids manually.",
828
+ "Do not show choices that the renderer treats as fallback or no-op.",
829
+ ],
830
+ acceptableAlternatives: [
831
+ "Use Select for non-visual named options.",
832
+ "Use FileDrop for user-uploaded source material.",
833
+ ],
834
+ layoutConstraints: [
835
+ "Runtime owns tile sizing by option count.",
836
+ ],
837
+ requiredAcceptance: [
838
+ "Prove each visible image choice changes product output or selected visual data.",
839
+ ],
840
+ }),
841
+ aiUsageRules: [
842
+ "ImagePicker owns thumbnail layout; pass the item list only and do not recreate the grid manually.",
843
+ "Every visible ImagePicker item must be actionable in the current product context.",
844
+ "Do not show selectable image choices that the renderer later sanitizes to a fallback or no-op.",
845
+ "If available choices depend on another control such as template, mode, or selected object, either make every visible item valid for every mode, split the choice into separate semantic controls, or ask the user before implementation.",
846
+ "A defensive invalid-value fallback is allowed, but it is not acceptance proof for a visible ImagePicker option.",
847
+ "Tests must choose each visible ImagePicker item and assert the selected image, texture, gradient, or exported pixels change in the product output.",
848
+ "Do not accept renderer data attributes, runtime target changes, or option existence as final proof that an image choice works.",
849
+ ],
850
+ },
851
+ code: {
852
+ ...control("code", "CodeTextarea", "standalone", "required"),
853
+ decisionCatalog: decisionCatalog({
854
+ strictness: "best-fit",
855
+ ownsValueModel: [
856
+ "long text",
857
+ "multiline content",
858
+ "structured text",
859
+ "prompt",
860
+ "JSON",
861
+ "CSS",
862
+ "shader code",
863
+ ],
864
+ useWhen: [
865
+ "Use CodeTextarea for potentially long, multiline, or structured text values.",
866
+ ],
867
+ doNotReplaceWith: [
868
+ "Do not use repeated TextInput controls for one long content value.",
869
+ ],
870
+ acceptableAlternatives: [
871
+ "Use TextInput for short single-line values.",
872
+ ],
873
+ layoutConstraints: [
874
+ "CodeTextarea is capped at 12 visible lines and scrolls internally.",
875
+ ],
876
+ requiredAcceptance: [
877
+ "Prove long text edits affect product content while typing.",
878
+ ],
879
+ }),
880
+ aiUsageRules: [
881
+ "CodeTextarea is the multiline text input for any potentially long value, not only source code.",
882
+ "Use text for short single-line strings such as names, small numeric values, compact prompts, titles, and short tokens.",
883
+ "Use code when the user may enter long prompts, multiline text, JSON, CSS, shader code, scripts, templates, or other long structured data.",
884
+ "CodeTextarea is a content editor and applies values while typing; do not wait for blur, Enter, or Cmd/Ctrl+Enter to update runtime state.",
885
+ "CodeTextarea height is capped at 12 visible text lines; long content scrolls inside the textarea instead of making the controls panel taller.",
886
+ "Do not name a section Code unless the product value is actually code; use the product role such as Prompt, Instructions, Template, JSON, Shader, or CSS.",
887
+ ],
888
+ },
889
+ customControl: {
890
+ decisionCatalog: decisionCatalog({
891
+ strictness: "custom-escape-hatch",
892
+ ownsValueModel: [
893
+ "product-specific interaction not expressible by built-in controls",
894
+ ],
895
+ useWhen: [
896
+ "Use custom controls only after checking all relevant built-ins and documenting why the closest built-in is insufficient.",
897
+ ],
898
+ doNotReplaceWith: [
899
+ "Do not use custom controls to recreate built-in controls, runtime panels, toolbar, timeline, layers, canvas, or sticky panel actions.",
900
+ ],
901
+ acceptableAlternatives: [
902
+ "Prefer built-in schema controls plus renderer logic whenever the value model fits an existing control.",
903
+ ],
904
+ layoutConstraints: [
905
+ "Custom UI must use Toolcraft primitives and minimal product-specific chrome.",
906
+ ],
907
+ requiredAcceptance: [
908
+ "Document rejected built-ins, prove runtime-state writes, and prove product output or command side effects.",
909
+ ],
910
+ }),
911
+ aiUsageRules: [
912
+ "Use custom controls only for product interactions that built-in controls cannot express.",
913
+ "Do not use a custom control to recreate a built-in Slider, RangeSlider, Select, Segmented, Switch, Checkbox, Color, ColorOpacity, Gradient, FontPicker, ImagePicker, FileDrop, TextInput, CodeTextarea, RangeInput, Palette, Actions, Curves, AnchorGrid, ChannelMixer, Vector, or PanelActions control.",
914
+ "Custom controls may use Toolcraft primitives for small app-specific chrome, but must not import or render low-level runtime surfaces or duplicate toolbar, timeline, layers, canvas, panel, or built-in control mechanics.",
915
+ "Custom controls must render the minimum UI needed to understand the value, context, and available actions; avoid decorative metadata and text that repeats what the section, label, or visible item already explains.",
916
+ "Every visible custom-control element must justify its space by enabling selection, ordering, preview, removal, upload, editing, or status that affects the product.",
917
+ "Use Toolcraft primitives and tokens for all custom-control chrome; do not hand-style basic buttons, inputs, selects, sliders, scroll areas, or focus states.",
918
+ "Custom-control action buttons must be sized for the interaction. Do not shrink destructive, reorder, upload, or primary actions below comfortable kit button/icon-button sizes just to fit more text.",
919
+ "Choose preview sizes that match the product object scale. A glyph, swatch, chip, or thumbnail can be compact, but its actions and hit targets must stay readable and clickable.",
920
+ "If a custom item needs explanatory context, prefer concise labels such as Darkest, Mid tone, or Lightest; omit file names, long captions, and duplicated helper text unless they are required to distinguish items.",
921
+ "Acceptance and browser tests must prove custom-control interactions work through runtime state and product output, not only that custom markup rendered.",
922
+ ],
923
+ capabilities: ["controlRenderers", "runtime-state", "minimal-ui"],
924
+ commands: [],
925
+ historyPolicy: "patch",
926
+ id: "customControl",
927
+ kind: "control",
928
+ labelPolicy: "required",
929
+ schemaType: "controlRenderers",
930
+ stateMode: "controlled",
931
+ visualComponent: "CustomControlRenderer",
932
+ },
933
+ canvas: {
934
+ aiUsageRules: [
935
+ "Choose canvas.sizing.mode from product context instead of copying a universal 1024px artboard.",
936
+ "Use intrinsic-media for single-layer upload/generation apps so imported media natural size becomes canvas.size.",
937
+ "Use editable-output by default for generated, exportable, shader, poster, badge, wall, banner, thumbnail, and product-output apps where users should see or edit width and height.",
938
+ "A user-provided base/default size is not a reason to remove size controls; model it as canvas.size plus editable-output unless the prompt or reference explicitly locks output dimensions.",
939
+ "Use fixed-output only when the product output size must not be user-editable, and prove that lock with canvasSizingCoverage fixed-output-size acceptance.",
940
+ "Resolved canvas.size exists for every canvas app, but visible Canvas width and Canvas height controls are mandatory only for editable-output sizing and do not depend on settingsTransfer.",
941
+ "If canvas.size is provided without an explicit sizing mode, defineToolcraft treats it as editable-output and adds Canvas width and Canvas height controls.",
942
+ "The runtime Canvas width and Canvas height block uses the technical Setup section and renders without a visible section heading; do not add a separate Canvas section label above these fields.",
943
+ ],
944
+ capabilities: ["drag", "zoom", "radar", "upload", "editable-size"],
945
+ commands: [
946
+ "canvas.setSize",
947
+ "canvas.panBy",
948
+ "canvas.setOffset",
949
+ "canvas.center",
950
+ "canvas.zoomIn",
951
+ "canvas.zoomOut",
952
+ "canvas.zoomReset",
953
+ "media.delete",
954
+ "media.import",
955
+ ],
956
+ historyPolicy: "patch",
957
+ id: "canvas",
958
+ kind: "canvas",
959
+ schemaType: "canvas",
960
+ stateMode: "runtime-owned",
961
+ visualComponent: "CanvasShell",
962
+ },
963
+ persistence: {
964
+ aiUsageRules: [
965
+ "Do not write app state to localStorage directly.",
966
+ "Use schema persistence policy for app state that should survive reload.",
967
+ "Persistence may include values, canvas, panels, timeline, and layers; history and media blobs are not persisted.",
968
+ 'Apps with visible runtime panels and localStorage persistence must include "panels" so dragged panel positions survive reload.',
969
+ 'Apps with localStorage persistence must include acceptance coverage for changing a user setting, reloading the browser page, and seeing the restored value or product output.',
970
+ "Settings import/export is a preset transfer feature for complex apps; it must not be used to hide or replace broken persistence reload behavior.",
971
+ "Do not store media blobs, files, or large generated images in localStorage.",
972
+ ],
973
+ capabilities: ["themePreference", "appStatePolicy"],
974
+ commands: [],
975
+ historyPolicy: "never",
976
+ id: "persistence",
977
+ kind: "persistence",
978
+ schemaType: "persistence",
979
+ stateMode: "runtime-owned",
980
+ visualComponent: "none",
981
+ },
982
+ settingsTransfer: {
983
+ aiUsageRules: [
984
+ 'Use schema settingsTransfer: "auto" for complex apps unless the prompt explicitly disables settings import/export.',
985
+ "After adding, removing, or reorganizing controls, sections, timeline, or layers, recalculate settings-transfer eligibility. The runtime threshold is 12 product controls, 5 product sections, or weighted score 18.",
986
+ "Do not hand-roll settings import/export through app routes, hidden file inputs, or panelActions.",
987
+ "Settings transfer appears as the first technical Setup controls-panel section when enabled and renders without a visible section heading; it imports and exports control values, canvas size, and timeline state.",
988
+ "A settings-transfer section with only Export Settings and Import Settings means canvas sizing is not editable-output or canvas size controls already exist elsewhere.",
989
+ "When settings transfer and editable-output canvas sizing are both enabled, the first technical Setup runtime section contains Export Settings, Import Settings, Canvas width, and Canvas height in that order and renders without a visible section heading.",
990
+ "Keep sticky footer panelActions for product delivery actions only, such as Export PNG, Export Video, Copy, Generate, Apply, or Download.",
991
+ ],
992
+ capabilities: ["settings-import-export"],
993
+ commands: ["controls.setValue", "timeline.setCurrentTime", "timeline.setDuration"],
994
+ historyPolicy: "patch",
995
+ id: "settingsTransfer",
996
+ kind: "settings",
997
+ schemaType: "settingsTransfer",
998
+ stateMode: "runtime-owned",
999
+ visualComponent: "SettingsTransfer",
1000
+ },
1001
+ appEntityAcceptance: {
1002
+ aiUsageRules: [
1003
+ "Every app entity introduced by the AI must have an acceptance test that proves its product responsibility.",
1004
+ "Compound controls must declare controlPartCoverage for every semantic value part required by their control type.",
1005
+ "Compound control browser tests must explicitly exercise each required value part, not only one visible sub-control.",
1006
+ "Acceptance tests must fail when an entity is disconnected from runtime state, renderer output, export output, or command side effects.",
1007
+ "Do not accept typecheck, component existence, registered commands, runtime state mutation, renderer input objects, shader uniform presence, or signature strings as final proof.",
1008
+ "Use product-level observables such as rendered pixels, exported image bytes, canvas hash, clipboard payload, cleared media preview, selected layer result, changed viewport, or timeline-rendered frame.",
1009
+ "A generic canvas hash difference is not enough for workload or semantic controls; assert the intended direction of the effect.",
1010
+ "Component variants are accepted entities too; tests should fail if a non-default Toolcraft control variant falls back to the default variant or custom markup.",
1011
+ "Conditional entities require fixtures that make the condition observable.",
1012
+ "Use visibleWhen for mode-, type-, variant-, or count-exclusive sections or controls that do not belong to the current selected state.",
1013
+ "When a count/quantity control determines how many sibling controls are available, hide unavailable siblings with visibleWhen; do not render all possible controls while the renderer reads only the first N.",
1014
+ "Use disabledWhen for controls that belong to the current entity but are temporarily unavailable for the selected mode; the disabled value must be preserved.",
1015
+ "Do not leave inactive conditional controls visible and enabled while making the renderer ignore them.",
1016
+ "If an entity cannot be tested against a product-level observable, remove it from the app schema or ask whether it is required.",
1017
+ ],
1018
+ capabilities: ["acceptance-tests", "product-output-verification"],
1019
+ commands: [],
1020
+ historyPolicy: "never",
1021
+ id: "appEntityAcceptance",
1022
+ kind: "composition",
1023
+ schemaType: "appEntityAcceptance",
1024
+ stateMode: "runtime-owned",
1025
+ visualComponent: "none",
1026
+ },
1027
+ performanceAcceptance: {
1028
+ aiUsageRules: [
1029
+ "Custom renderers must define performance budgets for media import, preview updates, control drags, and export/copy before implementation.",
1030
+ "Controls that change renderer workload, such as Char Size, Grid Density, Matrix Scale, Sample Count, Resolution, Blur Radius, Iterations, Particle Count, or Quality, must be tested at min, default, and max values.",
1031
+ "Hash differs is not enough for workload controls; tests must assert semantic direction, for example smaller Char Size increases glyph/cell density and larger Char Size decreases it.",
1032
+ "Performance tests must use representative fixtures and the same renderer/export path as the running app, not only tiny 32px fixtures or isolated helper state.",
1033
+ "Expensive renderers must cache decoded media, source pixels, glyph atlases, gradients, and other reusable inputs by media id, canvas size, and stable control keys.",
1034
+ "Slider drags and high-frequency controls must debounce or coalesce preview work, cancel stale async renders, and avoid re-decoding media on every control change.",
1035
+ "Performance matrices must declare rendererWorkload as none, simple-composition, text-output, vector-output, or pixel-output.",
1036
+ "A full performance checkpoint must run with pnpm verify:perf when the first working app version exists, renderer/canvas/animation/export/timeline/layers change, a bug that previously broke functionality is fixed, any performance optimization lands, or the user requests performance, lag, jank, animation speed, or drag/zoom stabilization work.",
1037
+ "Renderer specs must include a Renderer Technique Decision Matrix with sourceRepresentation, productRepresentation, previewRenderer, exportRenderer, rendererWorkload, rendererStrategy, whyNotAlternativeStrategies, fidelityRisks, and performanceRisks.",
1038
+ "Custom renderer apps must mirror the Renderer Technique Decision Matrix in typed rendererTechnique config so validation can reject contradictory renderer choices.",
1039
+ "Custom renderer specs must include a Renderer Layer Inventory and mirror it in typed rendererTechnique.layers so dense raster backgrounds cannot silently rasterize semantic foreground output.",
1040
+ "Semantic foreground output such as product lines, shapes, icons, text, object bounds, and meaningful markers should use DOM or SVG by default; dense raster backgrounds do not justify rasterizing low-count foreground geometry or text.",
1041
+ "Editing handles must be DOM/SVG overlays, excluded from export, and written through runtime state instead of being drawn into the product raster layer.",
1042
+ "Product foreground and editing handle renderer layers must declare uiSelector so browser tests can verify the visible layer exists.",
1043
+ 'productRepresentation "mixed" is valid only when rendererTechnique.layers proves at least two different content families.',
1044
+ "Choose renderer technique from product context, not convenience or novelty. Preserve reference renderer technology in reference-runtime-clone mode unless a concrete blocker and replacement acceptance tests are named.",
1045
+ "Do not switch renderer technology just because it seems more modern or faster. Preview and export may use different renderers only when the decision matrix explains why and export/copy remains product-quality.",
1046
+ "Choose renderer workload by product fidelity before choosing rendering technology: ASCII, glyph grids, code art, subtitles, typography, or monospace text products are text-output unless the product intentionally rasterizes them into per-pixel effects.",
1047
+ "Text-output and vector-output visible previews must preserve native output fidelity. Do not render a low-resolution offscreen canvas or texture and upscale it to the product size.",
1048
+ "Pixel-output renderers must use WebGL or WebGPU even when the scene is static.",
1049
+ "Procedural pixel renderers, shader-like effects, animated mesh gradients, and large exportable previews should use WebGL or WebGPU for pixel work instead of main-thread ImageData loops.",
1050
+ "WebGL and WebGPU renderers must initialize contexts, programs, shaders, pipelines, textures, and large buffers once, then update uniforms or stable buffers when controls change.",
1051
+ "For keyframe or playback renderers, texture upload and media decode must be keyed to source media/resource changes, not to timeline time or evaluated settings. Timeline-only updates must reuse decoded media and existing GPU resources.",
1052
+ "Do not create WebGL/WebGPU contexts, shader programs, textures, or requestAnimationFrame loops directly in the React render path.",
1053
+ "Animation loops must cancel scheduled frames during cleanup.",
1054
+ "Animated preview renderers must suspend or coalesce non-essential animation work while the user drags, pans, pinches, zooms, or centers the canvas viewport, then resume from the correct timeline or autonomous time without changing the user's play/pause state.",
1055
+ "If a generated app uses ImageData, getImageData, or putImageData for procedural output, performance validation must fail unless the renderer is converted to GPU rendering or the CPU path is removed.",
1056
+ "Performance matrices must declare rendererStrategy so tests can distinguish none, dom, svg, canvas-2d, webgl, and webgpu renderer paths.",
1057
+ "Browser verification must interact with the actual UI, exercise worst-case control values, and fail if the app freezes, creates runaway render loops, drops canvas zoom/offset, or misses the performance budget.",
1058
+ "If a renderer cannot meet the budget, reduce the work units, clamp the control range, move work off the critical path, or remove the control.",
1059
+ ],
1060
+ capabilities: ["performance-budgets", "workload-control-tests"],
1061
+ commands: [],
1062
+ historyPolicy: "never",
1063
+ id: "performanceAcceptance",
1064
+ kind: "composition",
1065
+ schemaType: "performanceAcceptance",
1066
+ stateMode: "runtime-owned",
1067
+ visualComponent: "none",
1068
+ },
1069
+ referenceRuntimeClone: {
1070
+ aiUsageRules: [
1071
+ 'Use transferMode: "reference-runtime-clone" when the user asks to port, clone, copy, or reproduce an existing app exactly.',
1072
+ "Preserve the reference runtime as the source of truth instead of replacing it with a new renderer or timeline model.",
1073
+ "Port requestAnimationFrame loops, refs, mutable particle/object state, connection state, spawn/update cadence, lifetime rules, pause/resume, export/copy, canvas sizing, and media lifecycle when the reference depends on them.",
1074
+ "Keep Toolcraft as the shell: defineToolcraft, ToolcraftApp, schema controls, canvasContent, fileDrop, panelActions, and runtime commands.",
1075
+ "Reference clone timeline choice is based on timeline behavior, not only on whether the reference draws a timeline-shaped UI.",
1076
+ "If the reference has Play/Pause, Restart from beginning, current time/progress, duration, loop, scrub, selected range, trim handles, or video export timing, write a Reference Timeline Inventory before choosing a timeline mode.",
1077
+ 'Use referenceTimeline.mode "toolcraft-playback" for plain transport behavior such as play/pause, restart, duration/progress, loop, scrub, or export at time.',
1078
+ 'Use referenceTimeline.mode "toolcraft-keyframes" when controls need keyframe diamonds, expanded keyframe rows, easing, or editable keyframes.',
1079
+ 'Use referenceTimeline.mode "none" only when the reference has no user-facing transport behavior at all.',
1080
+ "Reference clone specs must list every detected transport behavior explicitly, including pause-resume, restart, time-progress, export-at-time, playback, scrub, duration, loop, and keyframes when present.",
1081
+ "Do not create right-panel controls named or targeted as Play, Pause, Paused, Animate, Restart animation, or equivalent app-wide transport toggles.",
1082
+ 'Do not downgrade custom reference timelines to panels.timeline mode "playback". State buttons, trim handles, selected-range playback, or range export require referenceTimeline.mode "custom-reference-timeline" and dedicated acceptance.',
1083
+ "Generated reference clone apps must declare starterTransferMode.referenceTimeline with mode none, toolcraft-playback, toolcraft-keyframes, or custom-reference-timeline.",
1084
+ "Custom reference timeline behavior needs referenceTimelineCoverage entries such as state-jump, trim-range, range-playback, all-range, jump-to-trim-start, and export-range.",
1085
+ "Reference clone acceptance must include referenceCoverage rows for canvas sizing, control mapping, renderer state, and any renderer loop, spawn/update cadence, pause/resume, export/copy, or media lifecycle behavior in the reference.",
1086
+ "Browser tests must compare reference behavior or a reference-derived baseline, not only Toolcraft state mutation.",
1087
+ ],
1088
+ capabilities: [
1089
+ "reference-runtime-clone",
1090
+ "reference-behavior-acceptance",
1091
+ "reference-timeline-inventory",
1092
+ "canvasContent-renderer",
1093
+ ],
1094
+ commands: [],
1095
+ historyPolicy: "never",
1096
+ id: "referenceRuntimeClone",
1097
+ kind: "composition",
1098
+ schemaType: "transferMode",
1099
+ stateMode: "runtime-owned",
1100
+ visualComponent: "canvasContent",
1101
+ },
1102
+ controlLabels: {
1103
+ aiUsageRules: [
1104
+ "Control labels must be short UI names, usually one to three words.",
1105
+ "Do not put explanations, formulas, units, parenthetical hints, or usage instructions in control labels.",
1106
+ "A concise property label such as Speed, Color, Size, or Opacity is allowed when the nearest visible section or group clearly names the affected product entity.",
1107
+ "When the section is generic, mixed, missing, or otherwise weak context, include the affected entity or role in the label: Pattern color, Background opacity, Wave speed, Stroke width.",
1108
+ "Acceptance validators suggest semantic replacement labels for weak generic labels; fix the schema label instead of relying on runtime fallback rewriting.",
1109
+ "Controls-panel sections should stay discrete: two to seven product controls is the normal size, and larger sections must split by product sub-entity or workflow stage.",
1110
+ "Every app-authored controls-panel body section must have a short meaningful visible title. Runtime-created setup/settings sections use the technical title Setup but render without a visible heading; sticky footer action sections use the technical title Export but render without a visible heading.",
1111
+ "Every visible controls-panel section title renders through the standard 36px collapsible header row with vertically centered text and the runtime collapse icon; generated apps must not hand-build section headers.",
1112
+ "Controls-panel section expand and collapse uses the standard runtime height/opacity animation; generated apps must not replace it with instant custom section visibility.",
1113
+ "Ordinary controls-panel section collapsed/expanded state persists as a runtime UI preference per app. It is not undo/redo state, not settings import/export state, and Reset controls must not clear it. Runtime technical Setup/settings sections and sticky footer Export sections are not collapsible.",
1114
+ "Ordinary controls-panel body sections use 8px top spacing and 24px bottom spacing for their control content. Runtime technical Setup/settings sections use 12px top and bottom spacing to match side padding. Sticky footer action sections keep their dedicated spacing.",
1115
+ "Broad section titles such as Flow, Icon, Shapes, Scene, Text, Typography, or Motion are only valid for small cohesive groups; use specific titles such as Flow Motion, Flow Geometry, Letter Burst, Shape Colors, Logo Glow, Logo Plate, or Text Block for larger groups.",
1116
+ "Section titles in one controls panel must be unique.",
1117
+ "Use section titles, option labels, tests, or renderer/spec prose for details instead of long field labels.",
1118
+ "Bad: Grid Density (every Nth). Good: Grid Density, with Every 6th as the select option label.",
1119
+ "Use control.description for the short help tooltip shown beside visible labels. It must describe the product behavior or output affected by the control, not restate the label.",
1120
+ "Do not write label-recap descriptions such as Adjusts Opacity, Controls Speed, or Sets Background.",
1121
+ "If there is no useful product-specific explanation, omit control.description; the runtime should not show a help tooltip for that label.",
1122
+ "For compound controls such as FontPicker, do not use control.description to enumerate the control's owned fields. FontPicker descriptions must not recap font family, weight, size, case, color, opacity, letter spacing, or line height; use description only for non-obvious product scope or omit it.",
1123
+ "The runtime renders a filled Phosphor question icon beside each visible ControlFieldLabel; generated apps must not hand-build their own help icon beside built-in labels.",
1124
+ "If a source label is unavoidably long, keep the visible label concise and rely on the native title tooltip for the full text.",
1125
+ ],
1126
+ capabilities: ["short-labels", "control-description-tooltip", "native-title-tooltip"],
1127
+ commands: [],
1128
+ historyPolicy: "never",
1129
+ id: "controlLabels",
1130
+ kind: "composition",
1131
+ schemaType: "controlLabels",
1132
+ stateMode: "runtime-owned",
1133
+ visualComponent: "ControlFieldLabel",
1134
+ },
1135
+ controlsPanel: panel("controlsPanel", "ControlsPanel", "right", ["left", "right"], "handle"),
1136
+ layersPanel: {
1137
+ ...panel("layersPanel", "LayersPanel", "left", ["left", "right"], "handle"),
1138
+ aiUsageRules: [
1139
+ "Enable panels.layers only when the app needs editable layer selection, ordering, grouping, visibility, or multi-object media management.",
1140
+ "Do not enable the layers panel for single-layer apps.",
1141
+ "If the user intent is ambiguous, ask whether layer management is required before enabling panels.layers.",
1142
+ "When layers are enabled, layer-specific controls should target selectedLayer.* and apply to the currently selected runtime layer.",
1143
+ "Do not use selectedLayer.* targets when panels.layers is disabled; single-layer apps use app-specific targets.",
1144
+ "Layer-enabled apps need layerCoverage acceptance for selection, visibility, reorder, and grouping.",
1145
+ "Every selectedLayer.* control needs selected-layer-controls acceptance proving it edits the currently selected layer output.",
1146
+ "Layer browser coverage must use real LayersPanel rows and buttons, not direct layers.* command dispatch.",
1147
+ "Layer-enabled custom renderers need layers.interactions viewport-stability coverage around real selection, visibility, reorder or grouping, and selected-layer output checks.",
1148
+ ],
1149
+ capabilities: [
1150
+ "draggable",
1151
+ "snap",
1152
+ "doubleClickReset",
1153
+ "dragMode:handle",
1154
+ "groups",
1155
+ "selection",
1156
+ "visibility",
1157
+ ],
1158
+ commands: [
1159
+ "layers.add",
1160
+ "layers.delete",
1161
+ "layers.moveToGroup",
1162
+ "layers.rename",
1163
+ "layers.reorder",
1164
+ "layers.select",
1165
+ "layers.toggleCollapsed",
1166
+ "layers.toggleVisibility",
1167
+ ],
1168
+ },
1169
+ timelinePanel: {
1170
+ ...panel("timelinePanel", "TimelinePanel", "top", ["top", "bottom"], "panel"),
1171
+ aiUsageRules: [
1172
+ "Do not enable the timeline panel just because a renderer is animated.",
1173
+ "Before choosing no timeline for any animated product, write an Animation Intent Inventory: product transport, editable keyframes, or autonomous decorative output, plus the user-facing time behaviors present or intentionally absent.",
1174
+ 'User-requested product animation defaults to panels.timeline mode "playback" unless the spec explicitly declares autonomous decorative/self-running output with no play, pause, scrub, duration, loop, or export-at-time behavior.',
1175
+ 'Use panels.timeline: { mode: "playback" } when the product needs user-facing play, pause, scrubbing, duration, loop, restart, time progress, or export-at-time controls.',
1176
+ "Playback renderers must consume runtime timeline state; pause freezes output, scrubbing renders a deterministic frame, and the full animation cycle maps to state.timeline.durationSeconds instead of a local fixed duration.",
1177
+ "Playback renderers may compute an initial default duration, but must not watch state.timeline.durationSeconds and dispatch timeline.setDuration back to a computed local duration. User-edited timeline duration is the source of truth after initialization or reset.",
1178
+ "When non-looping playback reaches the end, pressing Play again restarts playback from time 0.",
1179
+ "Intrinsic-media upload timelines must stay paused at time 0 until source media exists; clearing the last media asset must pause and reset playback.",
1180
+ 'Use panels.timeline: { mode: "keyframes" } or panels.timeline: true only when controls need keyframe diamonds, expanded timeline rows, easing, or keyframe editing.',
1181
+ "In keyframes mode, Toolcraft infers keyframe diamonds from control type; AI must not manually pick a smaller subset of slider/vector/color-style controls.",
1182
+ "Keyframe state stores typed control values; valueLabel is display-only and must never be parsed by renderers or tests as the source of truth.",
1183
+ "Custom renderers with keyframes must consume evaluateToolcraftTimelineValues or useToolcraftEvaluatedValues for keyframed settings instead of raw state.values for those targets.",
1184
+ "Every inferred keyframe-capable control must be evaluated from runtime timeline keyframes and needs acceptance proving diamond creation, row creation, keyframe updates, scrub/playback evaluation, and product output change.",
1185
+ "Keyframe custom renderers must prove zoom, radar, and canvas viewport stability while expanding the timeline, creating keyframes, and scrubbing or playing the timeline.",
1186
+ "Keyframe renderers must not re-decode media or re-upload source textures on timeline ticks, scrubs, playback, or evaluated setting changes.",
1187
+ "Timeline-driven preview renderers must suspend or coalesce non-essential animation work during canvas drag, pan, pinch, zoom, and radar/center interactions without mutating the user's timeline play/pause state.",
1188
+ "Use keyframeable: false only on controls that are structurally unsupported by the shared keyframe capability helper; capable controls cannot opt out to hide broken animation wiring.",
1189
+ "Right-panel animation controls may tune renderer parameters such as mode, intensity, speed, or stagger only after animation intent is declared; they must not replace top timeline transport.",
1190
+ "Do not put Pause or Resume in panelActions; playback belongs to TimelinePanel transport controls.",
1191
+ "Do not replace TimelinePanel with an app-level playback, transport, or timeline panel to avoid runtime performance issues; fix the Toolcraft runtime clock/state path instead.",
1192
+ 'Custom timeline UI is allowed only for explicit referenceTimeline.mode "custom-reference-timeline" transfers with browser-backed referenceTimelineCoverage.',
1193
+ "Playback-only timelines stay collapsed and do not show keyframe diamonds or expanded keyframe rows.",
1194
+ "If timeline verification fails, wire the renderer to runtime timeline state or remove panels.timeline.",
1195
+ ],
1196
+ capabilities: [
1197
+ "draggable",
1198
+ "snap",
1199
+ "doubleClickReset",
1200
+ "dragMode:panel",
1201
+ "duration",
1202
+ "keyframes",
1203
+ "playback",
1204
+ ],
1205
+ commands: [
1206
+ "timeline.changeKeyframeEasing",
1207
+ "timeline.deleteControlKeyframes",
1208
+ "timeline.deleteKeyframe",
1209
+ "timeline.moveKeyframe",
1210
+ "timeline.selectKeyframe",
1211
+ "timeline.setCurrentTime",
1212
+ "timeline.setDuration",
1213
+ "timeline.setPlaying",
1214
+ "timeline.toggleLoop",
1215
+ "timeline.togglePlayback",
1216
+ ],
1217
+ },
1218
+ toolbar: {
1219
+ ...panel("toolbar", "ToolbarPanel", "bottom", ["top", "bottom"], "panel"),
1220
+ aiUsageRules: [
1221
+ "Toolbar history owns Undo and Redo buttons plus runtime keyboard shortcuts.",
1222
+ "Do not add app-level Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z, or Ctrl+Y listeners; use toolbar history and runtime commands.",
1223
+ "Undo/redo keyboard shortcuts must not fire while the user is typing into inputs, textareas, selects, or contentEditable value labels.",
1224
+ ],
1225
+ capabilities: [
1226
+ "draggable",
1227
+ "snap",
1228
+ "doubleClickReset",
1229
+ "history",
1230
+ "keyboardShortcuts",
1231
+ "zoom",
1232
+ "radar",
1233
+ ],
1234
+ commands: [
1235
+ "history.undo",
1236
+ "history.redo",
1237
+ "canvas.center",
1238
+ "canvas.zoomIn",
1239
+ "canvas.zoomOut",
1240
+ "canvas.zoomReset",
1241
+ ],
1242
+ kind: "toolbar",
1243
+ },
1244
+ } as const satisfies Record<string, ToolcraftComponentContract>;
1245
+
1246
+ export type ToolcraftComponentContractId = keyof typeof TOOLCRAFT_COMPONENT_CONTRACTS;
1247
+
1248
+ export function getToolcraftComponentContract<const Id extends ToolcraftComponentContractId>(
1249
+ id: Id,
1250
+ ): (typeof TOOLCRAFT_COMPONENT_CONTRACTS)[Id] {
1251
+ return TOOLCRAFT_COMPONENT_CONTRACTS[id];
1252
+ }
1253
+
1254
+ function decisionCatalog(
1255
+ catalog: ToolcraftControlDecisionCatalog,
1256
+ ): ToolcraftControlDecisionCatalog {
1257
+ return catalog;
1258
+ }
1259
+
1260
+ function control<
1261
+ const Id extends string,
1262
+ const VisualComponent extends string,
1263
+ const SectionLayout extends ToolcraftSectionLayout,
1264
+ const LabelPolicy extends ToolcraftLabelPolicy,
1265
+ >(
1266
+ id: Id,
1267
+ visualComponent: VisualComponent,
1268
+ defaultSectionLayout: SectionLayout,
1269
+ labelPolicy: LabelPolicy,
1270
+ ): {
1271
+ readonly defaultSectionLayout: SectionLayout;
1272
+ readonly historyPolicy: "patch";
1273
+ readonly id: Id;
1274
+ readonly kind: "control";
1275
+ readonly labelPolicy: LabelPolicy;
1276
+ readonly schemaType: Id;
1277
+ readonly stateMode: "controlled";
1278
+ readonly visualComponent: VisualComponent;
1279
+ } {
1280
+ return {
1281
+ defaultSectionLayout,
1282
+ historyPolicy: "patch",
1283
+ id,
1284
+ kind: "control",
1285
+ labelPolicy,
1286
+ schemaType: id,
1287
+ stateMode: "controlled",
1288
+ visualComponent,
1289
+ };
1290
+ }
1291
+
1292
+ function panel<
1293
+ const Id extends string,
1294
+ const VisualComponent extends string,
1295
+ const Placement extends ToolcraftPanelPlacement,
1296
+ const SnapEdges extends readonly ToolcraftPanelSnapEdge[],
1297
+ const DragMode extends "handle" | "panel",
1298
+ >(
1299
+ id: Id,
1300
+ visualComponent: VisualComponent,
1301
+ defaultPlacement: Placement,
1302
+ snapEdges: SnapEdges,
1303
+ dragMode: DragMode,
1304
+ ): {
1305
+ readonly aiUsageRules: readonly [`Render ${VisualComponent} only through PanelHost.`];
1306
+ readonly capabilities: readonly [
1307
+ "draggable",
1308
+ "snap",
1309
+ "doubleClickReset",
1310
+ `dragMode:${DragMode}`,
1311
+ ];
1312
+ readonly defaultPlacement: Placement;
1313
+ readonly historyPolicy: "optional";
1314
+ readonly id: Id;
1315
+ readonly kind: "panel";
1316
+ readonly requiredWrapper: "PanelHost";
1317
+ readonly schemaType: Id;
1318
+ readonly snapEdges: SnapEdges;
1319
+ readonly stateMode: "runtime-owned";
1320
+ readonly visualComponent: VisualComponent;
1321
+ } {
1322
+ return {
1323
+ aiUsageRules: [`Render ${visualComponent} only through PanelHost.`],
1324
+ capabilities: [
1325
+ "draggable",
1326
+ "snap",
1327
+ "doubleClickReset",
1328
+ `dragMode:${dragMode}` as const,
1329
+ ],
1330
+ defaultPlacement,
1331
+ historyPolicy: "optional",
1332
+ id,
1333
+ kind: "panel",
1334
+ requiredWrapper: "PanelHost",
1335
+ schemaType: id,
1336
+ snapEdges,
1337
+ stateMode: "runtime-owned",
1338
+ visualComponent,
1339
+ };
1340
+ }