@native-sdk/cli 0.0.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +50 -1
  3. package/app.zon +30 -0
  4. package/bin/native.js +156 -0
  5. package/build/app.zig +716 -0
  6. package/build.zig +2593 -0
  7. package/build.zig.zon +24 -0
  8. package/native-sdk.d.ts +615 -0
  9. package/package.json +44 -8
  10. package/skill-data/automation/SKILL.md +248 -0
  11. package/skill-data/core/SKILL.md +249 -0
  12. package/skill-data/core/references/app-model-runtime.md +141 -0
  13. package/skill-data/core/references/bridge-security-native-capabilities.md +230 -0
  14. package/skill-data/core/references/frontend-assets.md +124 -0
  15. package/skill-data/core/references/project-anatomy.md +108 -0
  16. package/skill-data/core/references/web-engines-packaging-debugging.md +199 -0
  17. package/skill-data/native-ui/SKILL.md +1080 -0
  18. package/skills/native-sdk/SKILL.md +33 -0
  19. package/src/app_runner/root.zig +740 -0
  20. package/src/assets/root.zig +20 -0
  21. package/src/automation/protocol.zig +285 -0
  22. package/src/automation/root.zig +13 -0
  23. package/src/automation/server.zig +506 -0
  24. package/src/automation/snapshot.zig +1202 -0
  25. package/src/automation/watcher.zig +165 -0
  26. package/src/bridge/root.zig +507 -0
  27. package/src/debug/root.zig +246 -0
  28. package/src/embed/app_exports.zig +11 -0
  29. package/src/embed/c_api.zig +793 -0
  30. package/src/embed/c_exports.zig +10 -0
  31. package/src/embed/chrome.zig +168 -0
  32. package/src/embed/conversions.zig +359 -0
  33. package/src/embed/host.zig +960 -0
  34. package/src/embed/root.zig +81 -0
  35. package/src/embed/tests.zig +2552 -0
  36. package/src/embed/types.zig +382 -0
  37. package/src/embed/ui_host.zig +289 -0
  38. package/src/extensions/root.zig +197 -0
  39. package/src/frontend/root.zig +48 -0
  40. package/src/js/root.zig +65 -0
  41. package/src/platform/android/NativeSdkActivity.java +1370 -0
  42. package/src/platform/android/android_host.c +696 -0
  43. package/src/platform/android/files.zig +9 -0
  44. package/src/platform/android/native_sdk_app.h +237 -0
  45. package/src/platform/ios/files.zig +8 -0
  46. package/src/platform/ios/native_sdk_app.h +289 -0
  47. package/src/platform/ios/uikit_host.m +2739 -0
  48. package/src/platform/linux/cef_host.cpp +599 -0
  49. package/src/platform/linux/gtk_host.c +5362 -0
  50. package/src/platform/linux/gtk_host.h +265 -0
  51. package/src/platform/linux/root.zig +1519 -0
  52. package/src/platform/macos/appkit_host.h +604 -0
  53. package/src/platform/macos/appkit_host.m +10392 -0
  54. package/src/platform/macos/automation_host.h +14 -0
  55. package/src/platform/macos/automation_host.m +12 -0
  56. package/src/platform/macos/cef_host.mm +3028 -0
  57. package/src/platform/macos/root.zig +2260 -0
  58. package/src/platform/null_platform.zig +2232 -0
  59. package/src/platform/null_platform_tests.zig +670 -0
  60. package/src/platform/policy_values.zig +14 -0
  61. package/src/platform/root.zig +181 -0
  62. package/src/platform/types.zig +2681 -0
  63. package/src/platform/windows/cef_host.cpp +3 -0
  64. package/src/platform/windows/root.zig +1521 -0
  65. package/src/platform/windows/webview2_host.cpp +6230 -0
  66. package/src/primitives/app_dirs/root.zig +440 -0
  67. package/src/primitives/app_manifest/root.zig +109 -0
  68. package/src/primitives/app_manifest/tests.zig +758 -0
  69. package/src/primitives/app_manifest/types.zig +587 -0
  70. package/src/primitives/app_manifest/validation.zig +828 -0
  71. package/src/primitives/assets/root.zig +520 -0
  72. package/src/primitives/canvas/a11y_audit.zig +390 -0
  73. package/src/primitives/canvas/a11y_audit_tests.zig +225 -0
  74. package/src/primitives/canvas/app_icon.zig +1590 -0
  75. package/src/primitives/canvas/chart.zig +392 -0
  76. package/src/primitives/canvas/chart_tests.zig +751 -0
  77. package/src/primitives/canvas/commands.zig +446 -0
  78. package/src/primitives/canvas/drawing.zig +309 -0
  79. package/src/primitives/canvas/equality.zig +316 -0
  80. package/src/primitives/canvas/events.zig +696 -0
  81. package/src/primitives/canvas/font_coverage.zig +118 -0
  82. package/src/primitives/canvas/font_ttf.zig +510 -0
  83. package/src/primitives/canvas/font_ttf_tests.zig +280 -0
  84. package/src/primitives/canvas/fonts/Geist-Regular.ttf +0 -0
  85. package/src/primitives/canvas/fonts/GeistMono-Regular.ttf +0 -0
  86. package/src/primitives/canvas/frame.zig +679 -0
  87. package/src/primitives/canvas/frame_metrics.zig +462 -0
  88. package/src/primitives/canvas/gpu.zig +639 -0
  89. package/src/primitives/canvas/hash.zig +112 -0
  90. package/src/primitives/canvas/icons/alert.svg +1 -0
  91. package/src/primitives/canvas/icons/archive.svg +1 -0
  92. package/src/primitives/canvas/icons/arrow-down.svg +1 -0
  93. package/src/primitives/canvas/icons/arrow-right.svg +1 -0
  94. package/src/primitives/canvas/icons/arrow-up.svg +1 -0
  95. package/src/primitives/canvas/icons/check-circle.svg +1 -0
  96. package/src/primitives/canvas/icons/check.svg +1 -0
  97. package/src/primitives/canvas/icons/chevron-down.svg +1 -0
  98. package/src/primitives/canvas/icons/chevron-left.svg +1 -0
  99. package/src/primitives/canvas/icons/chevron-right.svg +1 -0
  100. package/src/primitives/canvas/icons/chevron-up.svg +1 -0
  101. package/src/primitives/canvas/icons/circle-dot.svg +1 -0
  102. package/src/primitives/canvas/icons/clock.svg +1 -0
  103. package/src/primitives/canvas/icons/copy.svg +1 -0
  104. package/src/primitives/canvas/icons/download.svg +1 -0
  105. package/src/primitives/canvas/icons/edit.svg +1 -0
  106. package/src/primitives/canvas/icons/ellipsis.svg +1 -0
  107. package/src/primitives/canvas/icons/external-link.svg +1 -0
  108. package/src/primitives/canvas/icons/eye.svg +1 -0
  109. package/src/primitives/canvas/icons/file-text.svg +1 -0
  110. package/src/primitives/canvas/icons/folder-open.svg +1 -0
  111. package/src/primitives/canvas/icons/folder.svg +1 -0
  112. package/src/primitives/canvas/icons/git-branch.svg +1 -0
  113. package/src/primitives/canvas/icons/git-merge.svg +1 -0
  114. package/src/primitives/canvas/icons/git-pull-request.svg +1 -0
  115. package/src/primitives/canvas/icons/info.svg +1 -0
  116. package/src/primitives/canvas/icons/menu.svg +1 -0
  117. package/src/primitives/canvas/icons/missing.svg +1 -0
  118. package/src/primitives/canvas/icons/moon.svg +1 -0
  119. package/src/primitives/canvas/icons/music.svg +1 -0
  120. package/src/primitives/canvas/icons/panel-left.svg +1 -0
  121. package/src/primitives/canvas/icons/panel-right.svg +1 -0
  122. package/src/primitives/canvas/icons/pause.svg +1 -0
  123. package/src/primitives/canvas/icons/play.svg +1 -0
  124. package/src/primitives/canvas/icons/plus.svg +1 -0
  125. package/src/primitives/canvas/icons/refresh-cw.svg +1 -0
  126. package/src/primitives/canvas/icons/repeat.svg +1 -0
  127. package/src/primitives/canvas/icons/save.svg +1 -0
  128. package/src/primitives/canvas/icons/search.svg +1 -0
  129. package/src/primitives/canvas/icons/send.svg +1 -0
  130. package/src/primitives/canvas/icons/settings.svg +1 -0
  131. package/src/primitives/canvas/icons/shuffle.svg +1 -0
  132. package/src/primitives/canvas/icons/skip-back.svg +1 -0
  133. package/src/primitives/canvas/icons/skip-forward.svg +1 -0
  134. package/src/primitives/canvas/icons/sun.svg +1 -0
  135. package/src/primitives/canvas/icons/terminal.svg +1 -0
  136. package/src/primitives/canvas/icons/trash.svg +1 -0
  137. package/src/primitives/canvas/icons/volume.svg +1 -0
  138. package/src/primitives/canvas/icons/wrench.svg +1 -0
  139. package/src/primitives/canvas/icons/x-circle.svg +1 -0
  140. package/src/primitives/canvas/icons/x.svg +1 -0
  141. package/src/primitives/canvas/icons.zig +249 -0
  142. package/src/primitives/canvas/layout_audit.zig +744 -0
  143. package/src/primitives/canvas/layout_audit_tests.zig +426 -0
  144. package/src/primitives/canvas/markdown.zig +1031 -0
  145. package/src/primitives/canvas/markdown_hostile_tests.zig +471 -0
  146. package/src/primitives/canvas/markdown_tests.zig +538 -0
  147. package/src/primitives/canvas/plan_key_index.zig +120 -0
  148. package/src/primitives/canvas/png.zig +355 -0
  149. package/src/primitives/canvas/reference.zig +1457 -0
  150. package/src/primitives/canvas/reference_blur.zig +104 -0
  151. package/src/primitives/canvas/reference_memo.zig +322 -0
  152. package/src/primitives/canvas/reference_paths.zig +184 -0
  153. package/src/primitives/canvas/reference_tests.zig +1650 -0
  154. package/src/primitives/canvas/render.zig +747 -0
  155. package/src/primitives/canvas/render_effects.zig +255 -0
  156. package/src/primitives/canvas/render_fingerprints.zig +256 -0
  157. package/src/primitives/canvas/render_generic_resources.zig +376 -0
  158. package/src/primitives/canvas/render_images.zig +247 -0
  159. package/src/primitives/canvas/render_layers.zig +260 -0
  160. package/src/primitives/canvas/render_paths.zig +347 -0
  161. package/src/primitives/canvas/render_resources.zig +51 -0
  162. package/src/primitives/canvas/render_tests.zig +3186 -0
  163. package/src/primitives/canvas/root.zig +744 -0
  164. package/src/primitives/canvas/serialization.zig +1528 -0
  165. package/src/primitives/canvas/svg_icon.zig +636 -0
  166. package/src/primitives/canvas/svg_icon_tests.zig +312 -0
  167. package/src/primitives/canvas/test_support.zig +422 -0
  168. package/src/primitives/canvas/testdata/markdown_document.md +83 -0
  169. package/src/primitives/canvas/tests.zig +30 -0
  170. package/src/primitives/canvas/text.zig +82 -0
  171. package/src/primitives/canvas/text_atlas.zig +408 -0
  172. package/src/primitives/canvas/text_batch_tests.zig +431 -0
  173. package/src/primitives/canvas/text_interaction.zig +615 -0
  174. package/src/primitives/canvas/text_layout.zig +1069 -0
  175. package/src/primitives/canvas/text_layout_cache.zig +281 -0
  176. package/src/primitives/canvas/text_layout_hash.zig +113 -0
  177. package/src/primitives/canvas/text_layout_types.zig +128 -0
  178. package/src/primitives/canvas/text_measure_cache.zig +279 -0
  179. package/src/primitives/canvas/text_metrics.zig +309 -0
  180. package/src/primitives/canvas/text_metrics_tests.zig +262 -0
  181. package/src/primitives/canvas/text_span_tests.zig +608 -0
  182. package/src/primitives/canvas/text_spans.zig +1010 -0
  183. package/src/primitives/canvas/text_tests.zig +1949 -0
  184. package/src/primitives/canvas/themes/geist.zig +470 -0
  185. package/src/primitives/canvas/tokens.zig +1522 -0
  186. package/src/primitives/canvas/ui.zig +2686 -0
  187. package/src/primitives/canvas/ui_markup.zig +3791 -0
  188. package/src/primitives/canvas/ui_markup_binary.zig +522 -0
  189. package/src/primitives/canvas/ui_markup_binary_tests.zig +591 -0
  190. package/src/primitives/canvas/ui_markup_compiled.zig +2565 -0
  191. package/src/primitives/canvas/ui_markup_compiled_tests.zig +1669 -0
  192. package/src/primitives/canvas/ui_markup_contract.zig +1620 -0
  193. package/src/primitives/canvas/ui_markup_contract_tests.zig +953 -0
  194. package/src/primitives/canvas/ui_markup_edit.zig +416 -0
  195. package/src/primitives/canvas/ui_markup_edit_tests.zig +341 -0
  196. package/src/primitives/canvas/ui_markup_expr.zig +1152 -0
  197. package/src/primitives/canvas/ui_markup_expr_tests.zig +779 -0
  198. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +505 -0
  199. package/src/primitives/canvas/ui_markup_reflect.zig +127 -0
  200. package/src/primitives/canvas/ui_markup_tests.zig +1545 -0
  201. package/src/primitives/canvas/ui_markup_view.zig +2352 -0
  202. package/src/primitives/canvas/ui_markup_view_tests.zig +3709 -0
  203. package/src/primitives/canvas/ui_provenance.zig +96 -0
  204. package/src/primitives/canvas/ui_provenance_tests.zig +186 -0
  205. package/src/primitives/canvas/ui_schema.zig +825 -0
  206. package/src/primitives/canvas/ui_schema_tests.zig +128 -0
  207. package/src/primitives/canvas/ui_tests.zig +1432 -0
  208. package/src/primitives/canvas/vector.zig +919 -0
  209. package/src/primitives/canvas/vector_tests.zig +547 -0
  210. package/src/primitives/canvas/virtual_extent_tests.zig +317 -0
  211. package/src/primitives/canvas/virtual_extents.zig +540 -0
  212. package/src/primitives/canvas/widget_access.zig +208 -0
  213. package/src/primitives/canvas/widget_anchored_tests.zig +264 -0
  214. package/src/primitives/canvas/widget_builtin_tests.zig +3160 -0
  215. package/src/primitives/canvas/widget_invalidation.zig +748 -0
  216. package/src/primitives/canvas/widget_layout.zig +2055 -0
  217. package/src/primitives/canvas/widget_layout_tests.zig +2691 -0
  218. package/src/primitives/canvas/widget_metrics.zig +228 -0
  219. package/src/primitives/canvas/widget_render.zig +2534 -0
  220. package/src/primitives/canvas/widget_render_controls.zig +1563 -0
  221. package/src/primitives/canvas/widget_render_scroll.zig +136 -0
  222. package/src/primitives/canvas/widget_render_style.zig +626 -0
  223. package/src/primitives/canvas/widget_render_surfaces.zig +794 -0
  224. package/src/primitives/canvas/widget_routing.zig +475 -0
  225. package/src/primitives/canvas/widget_runtime.zig +307 -0
  226. package/src/primitives/canvas/widget_runtime_tests.zig +3015 -0
  227. package/src/primitives/canvas/widget_semantics.zig +480 -0
  228. package/src/primitives/canvas/widget_semantics_tests.zig +2129 -0
  229. package/src/primitives/canvas/widget_tests.zig +8 -0
  230. package/src/primitives/canvas/widget_text_input.zig +351 -0
  231. package/src/primitives/canvas/widget_text_select.zig +147 -0
  232. package/src/primitives/canvas/widget_tree.zig +232 -0
  233. package/src/primitives/canvas/widgets.zig +1319 -0
  234. package/src/primitives/diagnostics/root.zig +445 -0
  235. package/src/primitives/geometry/root.zig +889 -0
  236. package/src/primitives/json/root.zig +272 -0
  237. package/src/primitives/platform_info/root.zig +450 -0
  238. package/src/primitives/trace/root.zig +569 -0
  239. package/src/root.zig +165 -0
  240. package/src/runtime/api.zig +431 -0
  241. package/src/runtime/async_bridge.zig +49 -0
  242. package/src/runtime/automation_commands.zig +686 -0
  243. package/src/runtime/automation_liveness_tests.zig +140 -0
  244. package/src/runtime/automation_snapshot.zig +246 -0
  245. package/src/runtime/automation_widget_dispatch.zig +617 -0
  246. package/src/runtime/bridge_dispatch_tests.zig +202 -0
  247. package/src/runtime/bridge_payload.zig +194 -0
  248. package/src/runtime/bridge_permission_tests.zig +551 -0
  249. package/src/runtime/bridge_responses.zig +414 -0
  250. package/src/runtime/builtin_bridge.zig +554 -0
  251. package/src/runtime/canvas_budget_edge_tests.zig +415 -0
  252. package/src/runtime/canvas_font_tests.zig +410 -0
  253. package/src/runtime/canvas_fonts.zig +229 -0
  254. package/src/runtime/canvas_frame.zig +1734 -0
  255. package/src/runtime/canvas_frame_animation_tests.zig +609 -0
  256. package/src/runtime/canvas_frame_cache_tests.zig +333 -0
  257. package/src/runtime/canvas_frame_helpers.zig +414 -0
  258. package/src/runtime/canvas_frame_invalidation_tests.zig +544 -0
  259. package/src/runtime/canvas_frame_packet_tests.zig +1353 -0
  260. package/src/runtime/canvas_frame_patch_tests.zig +1051 -0
  261. package/src/runtime/canvas_frame_retained_tests.zig +753 -0
  262. package/src/runtime/canvas_frame_tests.zig +9 -0
  263. package/src/runtime/canvas_frame_text_layout_budget_tests.zig +149 -0
  264. package/src/runtime/canvas_image_tests.zig +362 -0
  265. package/src/runtime/canvas_images.zig +224 -0
  266. package/src/runtime/canvas_limits.zig +317 -0
  267. package/src/runtime/canvas_screenshot_tests.zig +289 -0
  268. package/src/runtime/canvas_widget_accessibility_tests.zig +1494 -0
  269. package/src/runtime/canvas_widget_anchored_tests.zig +678 -0
  270. package/src/runtime/canvas_widget_chart_tests.zig +249 -0
  271. package/src/runtime/canvas_widget_clipboard_tests.zig +399 -0
  272. package/src/runtime/canvas_widget_context_menu.zig +318 -0
  273. package/src/runtime/canvas_widget_context_menu_tests.zig +462 -0
  274. package/src/runtime/canvas_widget_control_tests.zig +2164 -0
  275. package/src/runtime/canvas_widget_disclosure_tests.zig +440 -0
  276. package/src/runtime/canvas_widget_display.zig +677 -0
  277. package/src/runtime/canvas_widget_event_tests.zig +1779 -0
  278. package/src/runtime/canvas_widget_events.zig +1098 -0
  279. package/src/runtime/canvas_widget_floating_tests.zig +695 -0
  280. package/src/runtime/canvas_widget_layout_tests.zig +26 -0
  281. package/src/runtime/canvas_widget_runtime.zig +1335 -0
  282. package/src/runtime/canvas_widget_scroll_driver_tests.zig +582 -0
  283. package/src/runtime/canvas_widget_scroll_drivers.zig +202 -0
  284. package/src/runtime/canvas_widget_scroll_tests.zig +1549 -0
  285. package/src/runtime/canvas_widget_semantics_tests.zig +810 -0
  286. package/src/runtime/canvas_widget_split_tree_tests.zig +1031 -0
  287. package/src/runtime/canvas_widget_state.zig +798 -0
  288. package/src/runtime/canvas_widget_text_tests.zig +2104 -0
  289. package/src/runtime/canvas_widget_window_drag_tests.zig +284 -0
  290. package/src/runtime/clock.zig +231 -0
  291. package/src/runtime/core.zig +927 -0
  292. package/src/runtime/effects.zig +4197 -0
  293. package/src/runtime/effects_audio_tests.zig +690 -0
  294. package/src/runtime/effects_clipboard_tests.zig +317 -0
  295. package/src/runtime/effects_fetch_tests.zig +1031 -0
  296. package/src/runtime/effects_file_tests.zig +407 -0
  297. package/src/runtime/effects_tests.zig +1251 -0
  298. package/src/runtime/flow.zig +1175 -0
  299. package/src/runtime/frame_profile.zig +221 -0
  300. package/src/runtime/gpu_surface_events.zig +639 -0
  301. package/src/runtime/launch_timing.zig +59 -0
  302. package/src/runtime/markdown_app_tests.zig +224 -0
  303. package/src/runtime/native_command_event_tests.zig +431 -0
  304. package/src/runtime/platform_bridge_tests.zig +8 -0
  305. package/src/runtime/platform_config_tests.zig +392 -0
  306. package/src/runtime/root.zig +150 -0
  307. package/src/runtime/runtime_event_tests.zig +1079 -0
  308. package/src/runtime/session_journal.zig +1522 -0
  309. package/src/runtime/session_record.zig +332 -0
  310. package/src/runtime/session_replay.zig +274 -0
  311. package/src/runtime/session_state.zig +30 -0
  312. package/src/runtime/session_tests.zig +399 -0
  313. package/src/runtime/shell_layout.zig +472 -0
  314. package/src/runtime/shell_layout_tests.zig +1246 -0
  315. package/src/runtime/shell_view_tests.zig +604 -0
  316. package/src/runtime/state.zig +110 -0
  317. package/src/runtime/system_services.zig +392 -0
  318. package/src/runtime/test_support.zig +79 -0
  319. package/src/runtime/tests.zig +30 -0
  320. package/src/runtime/ui_app.zig +3290 -0
  321. package/src/runtime/ui_app_huge_model_tests.zig +351 -0
  322. package/src/runtime/ui_app_provenance.zig +370 -0
  323. package/src/runtime/ui_app_tests.zig +3254 -0
  324. package/src/runtime/ui_app_virtual_variable_tests.zig +485 -0
  325. package/src/runtime/ui_app_window_tests.zig +442 -0
  326. package/src/runtime/validation.zig +206 -0
  327. package/src/runtime/view.zig +908 -0
  328. package/src/runtime/view_canvas.zig +850 -0
  329. package/src/runtime/view_widget_control.zig +433 -0
  330. package/src/runtime/view_widget_scroll.zig +360 -0
  331. package/src/runtime/view_widget_text.zig +275 -0
  332. package/src/runtime/view_widget_tree.zig +843 -0
  333. package/src/runtime/webview_view_bridge_tests.zig +664 -0
  334. package/src/runtime/widget_bridge.zig +231 -0
  335. package/src/runtime/window_command_bridge_tests.zig +403 -0
  336. package/src/runtime/window_storage.zig +255 -0
  337. package/src/runtime/window_view_runtime.zig +727 -0
  338. package/src/runtime/window_views.zig +334 -0
  339. package/src/security/root.zig +118 -0
  340. package/src/tooling/android.zig +1172 -0
  341. package/src/tooling/assets.zig +128 -0
  342. package/src/tooling/buildgraph.zig +379 -0
  343. package/src/tooling/cef.zig +671 -0
  344. package/src/tooling/codesign.zig +172 -0
  345. package/src/tooling/components/identity_tests.zig +185 -0
  346. package/src/tooling/components/stepper.zig +113 -0
  347. package/src/tooling/components/timeline.native +27 -0
  348. package/src/tooling/components/timeline_item.zig +131 -0
  349. package/src/tooling/default_icon.icns +0 -0
  350. package/src/tooling/default_icon.png +0 -0
  351. package/src/tooling/dev.zig +172 -0
  352. package/src/tooling/doctor.zig +349 -0
  353. package/src/tooling/eject_components.zig +170 -0
  354. package/src/tooling/embedlib.zig +290 -0
  355. package/src/tooling/ios.zig +528 -0
  356. package/src/tooling/manifest.zig +1939 -0
  357. package/src/tooling/package.zig +2388 -0
  358. package/src/tooling/process_tree.zig +114 -0
  359. package/src/tooling/raw_manifest.zig +193 -0
  360. package/src/tooling/root.zig +22 -0
  361. package/src/tooling/templates.zig +3191 -0
  362. package/src/tooling/toolchain.zig +371 -0
  363. package/src/tooling/verbs.zig +204 -0
  364. package/src/tooling/web_engine.zig +135 -0
  365. package/src/tooling/xcodeproj.zig +462 -0
  366. package/src/window_state/root.zig +507 -0
  367. package/index.js +0 -2
@@ -0,0 +1,825 @@
1
+ //! The UI schema registry: ONE authoritative statement of the markup
2
+ //! vocabulary, as data.
3
+ //!
4
+ //! Every parallel list the markup stack used to keep in lockstep by hand —
5
+ //! element names, text-leaf names, option attributes, events, the
6
+ //! element-scoped predicate sets (hit-target, stacking, dismissible,
7
+ //! anchorable, icon-attr), the rendered-text attribute set, and the
8
+ //! token/icon vocabularies — is DERIVED from this one registry at comptime
9
+ //! (see the derivation section at the bottom). The validator, both markup
10
+ //! engines, the contract checker, the LSP, the CLI's did-you-mean, and the
11
+ //! canonical binary encoding all consume it, so a vocabulary fact is
12
+ //! stated exactly once.
13
+ //!
14
+ //! Vocabulary is data; judgment stays code. The registry names WHAT exists
15
+ //! (elements, their codes, their attribute/event sets, their structural
16
+ //! predicates) and, for the composite elements, WHICH named rule hook owns
17
+ //! their bespoke validation — but the rules themselves (markdown's closed
18
+ //! attribute set, the stepper's step-children shape, ...) remain ordinary
19
+ //! Zig in ui_markup.zig, dispatched by hook name. Forcing them into
20
+ //! declarative data would breed a worse inner language.
21
+ //!
22
+ //! Stable codes: every element, attribute, and event carries a u16 code
23
+ //! assigned at birth and NEVER reused or reassigned — codes, not names or
24
+ //! declaration order, are what serialized documents and hashes reference,
25
+ //! so a rename or reorder here can never silently change what persisted
26
+ //! artifacts mean. Code 0 is reserved (it marks "no entry" on the wire).
27
+ //! New entries take the next unused code regardless of where they sit in
28
+ //! the tables; the registry integrity test pins uniqueness.
29
+ //!
30
+ //! The engine predicates the structural fields mirror
31
+ //! (`canvas.widgetKindHitTarget`, `canvas.widgetKindStacksChildren`,
32
+ //! `canvas.widgetKindDismissibleSurface`) stay the source of truth for
33
+ //! runtime behavior; registry↔engine conformance tests in
34
+ //! ui_markup_view_tests.zig hold this data equal to those predicates over
35
+ //! every element, so drift is impossible. This module stays std-only (it
36
+ //! rides in the `native` CLI and the LSP standalone), which is why widget
37
+ //! kinds are referenced by tag NAME here and resolved to `WidgetKind` by
38
+ //! the canvas-layer consumers.
39
+
40
+ const std = @import("std");
41
+
42
+ /// The UI document schema version: ONE number covering the document shape,
43
+ /// the registry's semantics (codes, classes, predicates), and the
44
+ /// evaluation semantics — including the structural-id algorithm — because
45
+ /// a change to any one changes what a persisted document MEANS. Additive
46
+ /// changes (new elements, attributes, events, expression forms under
47
+ /// fresh codes) do not bump it: codes are assigned at birth and readers
48
+ /// refuse codes they do not know, loudly. Renames, retypes, removals, or
49
+ /// evaluation-semantics changes bump it, and persisted artifacts (NSUI
50
+ /// documents, journals, serialized contracts) carry it; readers reach
51
+ /// older artifacts through document→document migrations, never silent
52
+ /// reinterpretation.
53
+ pub const schema_version: u16 = 1;
54
+
55
+ /// Value type-class of an attribute: what shape of value the engines
56
+ /// accept for it. `option` values name a Zig enum member (the enum itself
57
+ /// is derived from the `ElementOptions` field type, so it cannot be
58
+ /// restated here); `binding_only` attributes require one `{binding}` and
59
+ /// never take literals (runtime image ids, markdown sources).
60
+ pub const ValueClass = enum {
61
+ text,
62
+ number,
63
+ whole,
64
+ flag,
65
+ option,
66
+ key,
67
+ token_color,
68
+ token_radius,
69
+ icon,
70
+ binding_only,
71
+ };
72
+
73
+ /// Which validation surface an attribute belongs to. `option` attributes
74
+ /// are the generic per-element set (the validator's known-option list);
75
+ /// the others are scoped or structural and validated by their own rules.
76
+ pub const AttrGroup = enum {
77
+ /// Generic option attributes every element may carry (subject to the
78
+ /// element-scoped rules): the engines apply the `field`-named
79
+ /// `ElementOptions` member, or their own special handling when
80
+ /// `field` is empty (key, role, label).
81
+ option,
82
+ /// Color style-token references (`background="surface"`).
83
+ style_color,
84
+ /// The radius style-token reference.
85
+ style_radius,
86
+ /// Element-scoped specials with bespoke rules (icon names, avatar
87
+ /// image bindings, anchor placement).
88
+ element,
89
+ /// Composite-element attributes (markdown, stepper, timeline).
90
+ composite,
91
+ /// Structure-tag attributes (`for each`, `if test`, template wiring)
92
+ /// and tooling hints.
93
+ structure,
94
+ };
95
+
96
+ pub const AttrInfo = struct {
97
+ /// Stable code, assigned at birth, never reused. Nonzero.
98
+ code: u16,
99
+ /// Markup attribute name (kebab-case).
100
+ name: []const u8,
101
+ class: ValueClass,
102
+ group: AttrGroup,
103
+ /// `Ui.ElementOptions` field the generic engines set; empty for
104
+ /// attributes the engines handle specially.
105
+ field: []const u8 = "",
106
+ /// Literal values of this attribute render as label text, so the
107
+ /// font-coverage (tofu) guard applies to them.
108
+ rendered_text: bool = false,
109
+ };
110
+
111
+ /// How an event's payload reaches the Msg: `message` events take a tag
112
+ /// with an optional `{binding}` payload; the others require a bare tag
113
+ /// whose payload the RUNTIME supplies (TextInputEvent, ScrollState, the
114
+ /// split fraction).
115
+ pub const EventPayload = enum { message, text_input, scroll_state, fraction };
116
+
117
+ pub const EventInfo = struct {
118
+ /// Stable code, assigned at birth, never reused. Nonzero.
119
+ code: u16,
120
+ /// Event name; the markup attribute is `on-<name>`.
121
+ name: []const u8,
122
+ payload: EventPayload = .message,
123
+ /// The single element name the runtime emits this event for, when the
124
+ /// event is element-scoped (scroll offsets exist only on scroll
125
+ /// containers, fractions only on splits).
126
+ only_on_element: ?[]const u8 = null,
127
+ /// Only dismissible surfaces (the `dismissible` element predicate)
128
+ /// ever receive this event.
129
+ dismissible_only: bool = false,
130
+ /// This handler binds control/text behavior a non-hit-target element
131
+ /// does not have, so it is a dead handler there (press/toggle are
132
+ /// exempt: a bound press handler makes any element pressable).
133
+ dead_on_non_hit_target: bool = false,
134
+ };
135
+
136
+ /// How the accessible-name lint treats an element. The rubric is whether
137
+ /// a screen reader user is FULLY BLOCKED without the name:
138
+ /// - `control`: an interactive control announced with no name at all
139
+ /// cannot be operated blind — a missing name is an ERROR. Name sources:
140
+ /// nonblank text content, a nonblank `text` attribute, or `label`.
141
+ /// - `editable`: text-entry controls, plus `select` (which shows its
142
+ /// placeholder while empty). The accessibility bridges announce the
143
+ /// placeholder as the fallback name, so missing BOTH label and
144
+ /// placeholder is the ERROR.
145
+ /// - `image`: pictorial content. An unnamed image degrades (announced as
146
+ /// an unnamed image) but does not block, so a missing alt-equivalent
147
+ /// label is a WARNING; an explicit `label=""` marks it decorative.
148
+ /// - `none`: layout, decoration, and content whose name IS its text.
149
+ pub const A11yNameRule = enum {
150
+ none,
151
+ control,
152
+ editable,
153
+ image,
154
+ };
155
+
156
+ pub const ElementInfo = struct {
157
+ /// Stable code, assigned at birth, never reused. Nonzero.
158
+ code: u16,
159
+ /// Markup element name (kebab-case).
160
+ name: []const u8,
161
+ /// `canvas.WidgetKind` tag name this element lowers to; empty for
162
+ /// composite elements, which lower through their library views or
163
+ /// builder sugar (markdown, stepper, timeline, chart) or are consumed
164
+ /// by a parent composite (step, timeline-item, series).
165
+ widget_kind: []const u8 = "",
166
+ /// Content is a single run of text (with interpolation); no element
167
+ /// children (unless `takes_children` also holds).
168
+ takes_text: bool = false,
169
+ /// Content may ALSO be element children instead of the text run (the
170
+ /// list-row composite): with children the element is a flow container
171
+ /// inside its own chrome, with a text run it draws that label itself,
172
+ /// and mixing the two is a teaching error. Only meaningful alongside
173
+ /// `takes_text`.
174
+ takes_children: bool = false,
175
+ /// The engine hit-tests this element's widget kind. Mirrors
176
+ /// `canvas.widgetKindHitTarget` (conformance-tested).
177
+ hit_target: bool = true,
178
+ /// The widget kind layers children on top of each other (gap can
179
+ /// never space them). Mirrors `canvas.widgetKindStacksChildren`
180
+ /// (conformance-tested).
181
+ stacks_children: bool = false,
182
+ /// The runtime's dismissal machinery (Escape, click outside,
183
+ /// automation dismiss) closes this surface. Mirrors the markup subset
184
+ /// of `canvas.widgetKindDismissibleSurface`.
185
+ dismissible: bool = false,
186
+ /// May float as an anchored surface (`anchor="below"`).
187
+ anchorable: bool = false,
188
+ /// Its `icon` attribute draws an inline vector icon as part of the
189
+ /// element's own rendering (one hit target, one tint).
190
+ icon_attr: bool = false,
191
+ /// What the accessible-name lint requires of this element (see
192
+ /// `A11yNameRule` for the error/warning rubric). Conformance-tested
193
+ /// against the canvas layer's control predicates so an element the
194
+ /// engine treats as an operable control can never skip the lint.
195
+ a11y_name: A11yNameRule = .none,
196
+ /// Named bespoke validation rule for composite elements. The rule's
197
+ /// existence and attachment are registry data; the rule itself stays
198
+ /// code in ui_markup.zig, dispatched by this name.
199
+ rule_hook: ?[]const u8 = null,
200
+ };
201
+
202
+ // --------------------------------------------------------------- elements
203
+ //
204
+ // Codes 1..53 are the plain elements (assigned at birth in the vocabulary's
205
+ // documented grouping); 54 onward are the composites. The grouping comments
206
+ // mirror the authoring docs; they carry no meaning — codes do.
207
+
208
+ pub const elements = [_]ElementInfo{
209
+ // Flex, overlay, and scrolling containers.
210
+ .{ .code = 1, .name = "row", .widget_kind = "row", .hit_target = false },
211
+ .{ .code = 2, .name = "column", .widget_kind = "column", .hit_target = false },
212
+ .{ .code = 3, .name = "stack", .widget_kind = "stack", .hit_target = false, .stacks_children = true },
213
+ .{ .code = 4, .name = "panel", .widget_kind = "panel", .stacks_children = true },
214
+ .{ .code = 5, .name = "scroll", .widget_kind = "scroll_view" },
215
+ .{ .code = 6, .name = "list", .widget_kind = "list", .hit_target = false },
216
+ .{ .code = 7, .name = "grid", .widget_kind = "grid", .hit_target = false },
217
+ .{ .code = 8, .name = "card", .widget_kind = "card", .stacks_children = true },
218
+ .{ .code = 9, .name = "split", .widget_kind = "split", .hit_target = false },
219
+ .{ .code = 10, .name = "tree", .widget_kind = "tree", .hit_target = false },
220
+ // Row containers (children flow along the horizontal main axis).
221
+ .{ .code = 11, .name = "breadcrumb", .widget_kind = "breadcrumb", .hit_target = false },
222
+ .{ .code = 12, .name = "button-group", .widget_kind = "button_group", .hit_target = false },
223
+ .{ .code = 13, .name = "pagination", .widget_kind = "pagination", .hit_target = false },
224
+ .{ .code = 14, .name = "radio-group", .widget_kind = "radio_group", .hit_target = false },
225
+ .{ .code = 15, .name = "tabs", .widget_kind = "tabs", .hit_target = false },
226
+ .{ .code = 16, .name = "toggle-group", .widget_kind = "toggle_group", .hit_target = false },
227
+ // Vertical containers.
228
+ .{ .code = 17, .name = "table", .widget_kind = "table", .hit_target = false },
229
+ .{ .code = 18, .name = "table-row", .widget_kind = "data_row", .hit_target = false },
230
+ .{ .code = 19, .name = "dropdown-menu", .widget_kind = "dropdown_menu", .dismissible = true, .anchorable = true },
231
+ // Overlay/surface containers (title via the text attribute).
232
+ .{ .code = 20, .name = "accordion", .widget_kind = "accordion" },
233
+ .{ .code = 21, .name = "alert", .widget_kind = "alert", .stacks_children = true },
234
+ .{ .code = 22, .name = "bubble", .widget_kind = "bubble", .stacks_children = true },
235
+ .{ .code = 23, .name = "dialog", .widget_kind = "dialog", .stacks_children = true, .dismissible = true },
236
+ .{ .code = 24, .name = "drawer", .widget_kind = "drawer", .stacks_children = true, .dismissible = true },
237
+ .{ .code = 25, .name = "sheet", .widget_kind = "sheet", .stacks_children = true, .dismissible = true },
238
+ .{ .code = 26, .name = "resizable", .widget_kind = "resizable", .stacks_children = true },
239
+ // Text-bearing leaves (label is the element content).
240
+ .{ .code = 27, .name = "text", .widget_kind = "text", .takes_text = true },
241
+ .{ .code = 28, .name = "badge", .widget_kind = "badge", .takes_text = true, .hit_target = false, .icon_attr = true },
242
+ .{ .code = 29, .name = "button", .widget_kind = "button", .takes_text = true, .icon_attr = true, .a11y_name = .control },
243
+ .{ .code = 30, .name = "toggle", .widget_kind = "toggle", .takes_text = true, .a11y_name = .control },
244
+ .{ .code = 31, .name = "list-item", .widget_kind = "list_item", .takes_text = true, .takes_children = true, .icon_attr = true, .a11y_name = .control },
245
+ .{ .code = 32, .name = "menu-item", .widget_kind = "menu_item", .takes_text = true, .icon_attr = true, .a11y_name = .control },
246
+ .{ .code = 33, .name = "status-bar", .widget_kind = "status_bar", .takes_text = true },
247
+ .{ .code = 34, .name = "avatar", .widget_kind = "avatar", .takes_text = true, .hit_target = false, .a11y_name = .image },
248
+ .{ .code = 35, .name = "select", .widget_kind = "select", .takes_text = true, .a11y_name = .editable },
249
+ .{ .code = 36, .name = "switch", .widget_kind = "switch_control", .takes_text = true, .a11y_name = .control },
250
+ .{ .code = 37, .name = "table-cell", .widget_kind = "data_cell", .takes_text = true },
251
+ .{ .code = 38, .name = "toggle-button", .widget_kind = "toggle_button", .takes_text = true, .icon_attr = true, .a11y_name = .control },
252
+ .{ .code = 39, .name = "tooltip", .widget_kind = "tooltip", .takes_text = true, .hit_target = false },
253
+ // Value controls and text entry.
254
+ .{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .a11y_name = .control },
255
+ .{ .code = 41, .name = "radio", .widget_kind = "radio", .a11y_name = .control },
256
+ .{ .code = 42, .name = "slider", .widget_kind = "slider", .a11y_name = .control },
257
+ .{ .code = 43, .name = "progress", .widget_kind = "progress" },
258
+ .{ .code = 44, .name = "text-field", .widget_kind = "text_field", .a11y_name = .editable },
259
+ .{ .code = 45, .name = "search-field", .widget_kind = "search_field", .a11y_name = .editable },
260
+ .{ .code = 46, .name = "textarea", .widget_kind = "textarea", .a11y_name = .editable },
261
+ .{ .code = 47, .name = "input", .widget_kind = "input", .a11y_name = .editable },
262
+ .{ .code = 48, .name = "combobox", .widget_kind = "combobox", .a11y_name = .editable },
263
+ // Plain leaves.
264
+ .{ .code = 49, .name = "separator", .widget_kind = "separator", .hit_target = false },
265
+ .{ .code = 50, .name = "spacer", .widget_kind = "stack", .hit_target = false, .stacks_children = true },
266
+ .{ .code = 51, .name = "skeleton", .widget_kind = "skeleton", .hit_target = false },
267
+ .{ .code = 52, .name = "spinner", .widget_kind = "spinner", .hit_target = false },
268
+ .{ .code = 53, .name = "icon", .widget_kind = "icon", .hit_target = false },
269
+ // Composite elements: bespoke shapes validated by named rule hooks
270
+ // (the hooks live in ui_markup.zig) and built by bespoke builders in
271
+ // both engines. They lower through library views, not a single
272
+ // widget kind.
273
+ .{ .code = 54, .name = "markdown", .rule_hook = "markdown" },
274
+ .{ .code = 55, .name = "stepper", .rule_hook = "stepper" },
275
+ .{ .code = 56, .name = "step", .rule_hook = "step" },
276
+ .{ .code = 57, .name = "timeline", .rule_hook = "timeline" },
277
+ .{ .code = 58, .name = "timeline-item", .rule_hook = "timeline-item" },
278
+ .{ .code = 59, .name = "chart", .rule_hook = "chart" },
279
+ .{ .code = 60, .name = "series", .rule_hook = "series" },
280
+ // Consumed by its parent element: lowers to the parent's declared
281
+ // context-menu items (the platform-menu channel), never to a widget
282
+ // of its own.
283
+ .{ .code = 61, .name = "context-menu", .rule_hook = "context-menu" },
284
+ // The composer-grade grouped input: one bordered field wrapping a
285
+ // textarea plus an optional accessory row (input-group-actions) —
286
+ // the group wears the focus ring, the inner textarea's chrome
287
+ // dissolves. Lowers through `Ui.inputGroup` to the `input_group`
288
+ // widget kind; the actions row is consumed by its parent and lowers
289
+ // to a plain row inside the group's border.
290
+ .{ .code = 62, .name = "input-group", .rule_hook = "input-group" },
291
+ .{ .code = 63, .name = "input-group-actions", .rule_hook = "input-group-actions" },
292
+ // Inline styled run inside a <text> paragraph: consumed by its parent
293
+ // text leaf (lowered into the paragraph's flat span list, never to a
294
+ // widget of its own), exactly like step/series/context-menu. Spans
295
+ // carry weight, mono, italic, scale, underline, and the existing
296
+ // foreground token channel; everything else about the paragraph
297
+ // (wrap, alignment, events, identity) stays on the enclosing text
298
+ // element.
299
+ .{ .code = 64, .name = "span", .rule_hook = "span" },
300
+ // Consumed by its parent bubble (like step/series/context-menu are
301
+ // consumed by theirs): the reaction pill — one small muted capsule
302
+ // docked at the bubble's bottom edge, straddling it the way the
303
+ // reference overlaps reactions on a chat message. Its single text
304
+ // run lowers onto the bubble widget's chrome-text channel and its
305
+ // dock side rides the existing `text-alignment` attribute (default
306
+ // end, the reference's trailing dock), so the element mints ONE
307
+ // code and no attribute codes at all.
308
+ .{ .code = 65, .name = "reactions", .rule_hook = "reactions" },
309
+ };
310
+
311
+ // ------------------------------------------------------------- attributes
312
+ //
313
+ // Codes 1..28 are the generic option attributes (the order is also the
314
+ // did-you-mean/completion display order), 29..35 the style-token
315
+ // references, 36..41 the element-scoped specials, 42..50 the composite
316
+ // attributes, 51..57 the structure/tooling attributes, 58..64 the
317
+ // chart composite attributes, and 65 onward later additions under fresh
318
+ // codes (grouping comments carry no meaning — codes do).
319
+
320
+ pub const attrs = [_]AttrInfo{
321
+ .{ .code = 1, .name = "text", .class = .text, .group = .option, .field = "text", .rendered_text = true },
322
+ .{ .code = 2, .name = "placeholder", .class = .text, .group = .option, .field = "placeholder", .rendered_text = true },
323
+ .{ .code = 3, .name = "value", .class = .number, .group = .option, .field = "value", .rendered_text = true },
324
+ .{ .code = 4, .name = "checked", .class = .flag, .group = .option, .field = "checked" },
325
+ .{ .code = 5, .name = "selected", .class = .flag, .group = .option, .field = "selected" },
326
+ .{ .code = 6, .name = "disabled", .class = .flag, .group = .option, .field = "disabled" },
327
+ .{ .code = 7, .name = "variant", .class = .option, .group = .option, .field = "variant" },
328
+ .{ .code = 8, .name = "size", .class = .option, .group = .option, .field = "size" },
329
+ .{ .code = 9, .name = "width", .class = .number, .group = .option, .field = "width" },
330
+ .{ .code = 10, .name = "height", .class = .number, .group = .option, .field = "height" },
331
+ .{ .code = 11, .name = "grow", .class = .number, .group = .option, .field = "grow" },
332
+ .{ .code = 12, .name = "gap", .class = .number, .group = .option, .field = "gap" },
333
+ .{ .code = 13, .name = "padding", .class = .number, .group = .option, .field = "padding" },
334
+ .{ .code = 14, .name = "main", .class = .option, .group = .option, .field = "main" },
335
+ .{ .code = 15, .name = "cross", .class = .option, .group = .option, .field = "cross" },
336
+ .{ .code = 16, .name = "wrap", .class = .flag, .group = .option, .field = "wrap" },
337
+ .{ .code = 17, .name = "key", .class = .key, .group = .option },
338
+ .{ .code = 18, .name = "global-key", .class = .key, .group = .option },
339
+ .{ .code = 19, .name = "text-alignment", .class = .option, .group = .option, .field = "text_alignment" },
340
+ .{ .code = 20, .name = "columns", .class = .whole, .group = .option, .field = "columns" },
341
+ .{ .code = 21, .name = "virtualized", .class = .flag, .group = .option, .field = "virtualized" },
342
+ .{ .code = 22, .name = "virtual-item-extent", .class = .number, .group = .option, .field = "virtual_item_extent" },
343
+ .{ .code = 23, .name = "role", .class = .option, .group = .option },
344
+ .{ .code = 24, .name = "label", .class = .text, .group = .option, .rendered_text = true },
345
+ .{ .code = 25, .name = "autofocus", .class = .flag, .group = .option, .field = "autofocus" },
346
+ .{ .code = 26, .name = "min-width", .class = .number, .group = .option, .field = "min_width" },
347
+ .{ .code = 27, .name = "expanded", .class = .flag, .group = .option, .field = "expanded" },
348
+ .{ .code = 28, .name = "window-drag", .class = .flag, .group = .option, .field = "window_drag" },
349
+ // Color style-token references (`StyleTokenRefs` fields) + radius.
350
+ .{ .code = 29, .name = "background", .class = .token_color, .group = .style_color, .field = "background" },
351
+ .{ .code = 30, .name = "foreground", .class = .token_color, .group = .style_color, .field = "foreground" },
352
+ .{ .code = 31, .name = "accent", .class = .token_color, .group = .style_color, .field = "accent" },
353
+ .{ .code = 32, .name = "accent-foreground", .class = .token_color, .group = .style_color, .field = "accent_foreground" },
354
+ .{ .code = 33, .name = "border-color", .class = .token_color, .group = .style_color, .field = "border_color" },
355
+ .{ .code = 34, .name = "focus-ring", .class = .token_color, .group = .style_color, .field = "focus_ring" },
356
+ .{ .code = 35, .name = "radius", .class = .token_radius, .group = .style_radius },
357
+ // Element-scoped specials.
358
+ .{ .code = 36, .name = "name", .class = .icon, .group = .element },
359
+ .{ .code = 37, .name = "icon", .class = .icon, .group = .element },
360
+ .{ .code = 38, .name = "image", .class = .binding_only, .group = .element },
361
+ .{ .code = 39, .name = "anchor", .class = .option, .group = .element },
362
+ .{ .code = 40, .name = "anchor-alignment", .class = .option, .group = .element },
363
+ .{ .code = 41, .name = "anchor-offset", .class = .number, .group = .element },
364
+ // Composite-element attributes.
365
+ .{ .code = 42, .name = "source", .class = .binding_only, .group = .composite },
366
+ .{ .code = 43, .name = "active", .class = .whole, .group = .composite },
367
+ .{ .code = 44, .name = "title", .class = .text, .group = .composite, .rendered_text = true },
368
+ .{ .code = 45, .name = "description", .class = .text, .group = .composite, .rendered_text = true },
369
+ .{ .code = 46, .name = "meta", .class = .text, .group = .composite, .rendered_text = true },
370
+ .{ .code = 47, .name = "indicator", .class = .text, .group = .composite, .rendered_text = true },
371
+ .{ .code = 48, .name = "connector", .class = .flag, .group = .composite },
372
+ .{ .code = 49, .name = "issue-link-base", .class = .text, .group = .composite },
373
+ .{ .code = 50, .name = "details-expanded", .class = .binding_only, .group = .composite },
374
+ // Structure-tag attributes and tooling hints.
375
+ .{ .code = 51, .name = "each", .class = .text, .group = .structure },
376
+ .{ .code = 52, .name = "as", .class = .text, .group = .structure },
377
+ .{ .code = 53, .name = "test", .class = .flag, .group = .structure },
378
+ .{ .code = 54, .name = "template", .class = .text, .group = .structure },
379
+ .{ .code = 55, .name = "args", .class = .text, .group = .structure },
380
+ .{ .code = 56, .name = "src", .class = .text, .group = .structure },
381
+ .{ .code = 57, .name = "kind", .class = .text, .group = .structure },
382
+ // Chart composite attributes (fresh codes, assigned at birth).
383
+ .{ .code = 58, .name = "values", .class = .binding_only, .group = .composite },
384
+ .{ .code = 59, .name = "y-min", .class = .number, .group = .composite },
385
+ .{ .code = 60, .name = "y-max", .class = .number, .group = .composite },
386
+ .{ .code = 61, .name = "grid-lines", .class = .whole, .group = .composite },
387
+ .{ .code = 62, .name = "baseline", .class = .flag, .group = .composite },
388
+ .{ .code = 63, .name = "stroke-width", .class = .number, .group = .composite },
389
+ .{ .code = 64, .name = "color", .class = .token_color, .group = .composite },
390
+ // Scroll-region edge behavior (scroll only; the validator scopes it).
391
+ .{ .code = 65, .name = "overscroll", .class = .option, .group = .option, .field = "overscroll" },
392
+ // 66: icon-placement briefly collided with 65 during development and
393
+ // was re-minted here at birth, before either landed anywhere
394
+ // serialized.
395
+ .{ .code = 66, .name = "icon-placement", .class = .option, .group = .option, .field = "icon_placement" },
396
+ // Single-line text overflow policy (text leaves only; the validator
397
+ // scopes it): ellipsis (the default) or clip. 67: re-minted at birth
398
+ // from a development-time collision on 66, before landing anywhere
399
+ // serialized.
400
+ .{ .code = 67, .name = "overflow", .class = .option, .group = .option, .field = "overflow" },
401
+ // Inline span attributes (the <span> composite; its rule hook owns
402
+ // the closed set). weight names a text-span weight rung (regular,
403
+ // medium — the semibold rung — or bold); mono selects the mono face;
404
+ // italic slants the run. Span color rides the existing foreground
405
+ // token attribute (code 30), so no fresh code is minted for it.
406
+ .{ .code = 68, .name = "weight", .class = .option, .group = .composite },
407
+ .{ .code = 69, .name = "mono", .class = .flag, .group = .composite },
408
+ .{ .code = 70, .name = "italic", .class = .flag, .group = .composite },
409
+ // Split layout-tween declaration (split only; the validator scopes
410
+ // both). resize-duration in whole milliseconds — 0 (and absent) is
411
+ // today's snap, so every existing document keeps its behavior —
412
+ // makes the split's `value` a TARGET the runtime eases the rendered
413
+ // fraction toward, one step per presented frame. resize-easing names
414
+ // a `canvas.Easing` member (linear, standard, emphasized, spring)
415
+ // and is only meaningful with a nonzero duration (easing without a
416
+ // duration is a teaching error, not silence). Reduced-motion
417
+ // appearances snap inside the runtime; documents declare nothing.
418
+ .{ .code = 71, .name = "resize-duration", .class = .whole, .group = .option, .field = "resize_duration" },
419
+ .{ .code = 72, .name = "resize-easing", .class = .option, .group = .option, .field = "resize_easing" },
420
+ // Chart axis/hover attributes (fresh codes, assigned at birth).
421
+ // x-labels binds a model iterable
422
+ // of strings (one category label per sample, the same resolution
423
+ // set series values use), y-labels flags numeric ticks on,
424
+ // hover-details flags the pointer-hover detail card on.
425
+ .{ .code = 73, .name = "x-labels", .class = .binding_only, .group = .composite },
426
+ .{ .code = 74, .name = "y-labels", .class = .flag, .group = .composite },
427
+ .{ .code = 75, .name = "hover-details", .class = .flag, .group = .composite },
428
+ // The later span additions (the <span> composite; its rule hook
429
+ // owns the closed set): scale and underline. scale multiplies the
430
+ // paragraph's base
431
+ // size — the text element's size rung included — so a 1.5 run inside
432
+ // a heading paragraph draws at heading x 1.5; the engine treats only
433
+ // positive finite multipliers as scaling, so markup requires exactly
434
+ // that. underline is the span model's underline decoration (purely
435
+ // visual, like every span channel).
436
+ .{ .code = 76, .name = "scale", .class = .number, .group = .composite },
437
+ .{ .code = 77, .name = "underline", .class = .flag, .group = .composite },
438
+ // Split enter-from fraction (split only, needs resize-duration; the
439
+ // validator scopes both, mirroring resize-easing): a freshly
440
+ // MOUNTED split slides its pane boundary in from this fraction
441
+ // toward its declared value instead of popping there. Negative
442
+ // (absent) declares no origin, so every existing document keeps
443
+ // its mount-never-animates behavior.
444
+ .{ .code = 78, .name = "resize-origin", .class = .number, .group = .option, .field = "resize_origin" },
445
+ };
446
+
447
+ // ----------------------------------------------------------------- events
448
+
449
+ pub const events = [_]EventInfo{
450
+ .{ .code = 1, .name = "press" },
451
+ .{ .code = 2, .name = "toggle" },
452
+ .{ .code = 3, .name = "change", .dead_on_non_hit_target = true },
453
+ .{ .code = 4, .name = "submit", .dead_on_non_hit_target = true },
454
+ .{ .code = 5, .name = "input", .payload = .text_input, .dead_on_non_hit_target = true },
455
+ .{ .code = 6, .name = "scroll", .payload = .scroll_state, .only_on_element = "scroll" },
456
+ .{ .code = 7, .name = "dismiss", .dismissible_only = true },
457
+ .{ .code = 8, .name = "hold" },
458
+ .{ .code = 9, .name = "resize", .payload = .fraction, .only_on_element = "split" },
459
+ .{ .code = 10, .name = "reach-end", .only_on_element = "scroll" },
460
+ };
461
+
462
+ // ------------------------------------------------------- token vocabulary
463
+ //
464
+ // Token and icon sections reference their live sources: the color/radius
465
+ // names mirror the `canvas.ColorTokens`/`canvas.RadiusTokens` field sets
466
+ // and the icon names mirror the comptime-parsed `canvas.icons` registry
467
+ // (this module stays std-only, so the mirrors are data here and lockstep
468
+ // tests in ui_markup_view_tests.zig hold them equal to the live structs).
469
+
470
+ pub const color_token_names = [_][]const u8{
471
+ "background", "surface", "surface_subtle", "surface_pressed",
472
+ "text", "text_muted", "border", "accent",
473
+ "accent_text", "destructive", "destructive_text", "success",
474
+ "success_text", "warning", "warning_text", "info",
475
+ "info_text", "focus_ring", "shadow", "scrim",
476
+ "disabled",
477
+ };
478
+
479
+ pub const radius_token_names = [_][]const u8{ "sm", "md", "lg", "xl" };
480
+
481
+ /// The `size` attribute's CONTROL-scale values, accepted on every sized
482
+ /// element: the control register of `canvas.WidgetSize`, mirrored as data
483
+ /// here (this module stays std-only) with a lockstep test in
484
+ /// ui_markup_view_tests.zig holding the mirror equal to the live enum.
485
+ pub const control_size_value_names = [_][]const u8{ "default", "sm", "lg", "icon" };
486
+
487
+ /// The `size` attribute's TYPOGRAPHY rungs, accepted on TEXT elements
488
+ /// only: named typography-token steps (heading_size, display_size) above
489
+ /// the title rung. A different axis from the control scale — the
490
+ /// validator and both engines reject them on controls with a teaching
491
+ /// error. Same lockstep test as `control_size_value_names`.
492
+ pub const text_size_value_names = [_][]const u8{ "heading", "display" };
493
+
494
+ pub const icon_names = [_][]const u8{
495
+ "alert", "archive", "arrow-down", "arrow-right", "arrow-up",
496
+ "check", "check-circle", "chevron-down", "chevron-left", "chevron-right",
497
+ "chevron-up", "circle-dot", "clock", "copy", "download",
498
+ "edit", "ellipsis", "external-link", "eye", "file-text",
499
+ "folder", "folder-open", "git-branch", "git-merge", "git-pull-request",
500
+ "info", "menu", "moon", "music", "panel-left",
501
+ "panel-right", "pause", "play", "plus", "refresh-cw",
502
+ "repeat", "save", "search", "send", "settings",
503
+ "shuffle", "skip-back", "skip-forward", "sun", "terminal",
504
+ "trash", "volume", "wrench", "x", "x-circle",
505
+ };
506
+
507
+ /// The semantic role vocabulary the `role` attribute accepts: the field
508
+ /// names of `canvas.WidgetRole`, mirrored as data here (this module stays
509
+ /// std-only) with a lockstep test in ui_markup_view_tests.zig holding the
510
+ /// mirror equal to the live enum.
511
+ pub const role_names = [_][]const u8{
512
+ "none", "group", "text", "link", "image",
513
+ "button", "textbox", "tooltip", "dialog", "menu",
514
+ "menuitem", "list", "listitem", "row", "grid",
515
+ "gridcell", "tab", "checkbox", "radio", "switch_control",
516
+ "slider", "progressbar", "chart", "tree", "treeitem",
517
+ "separator",
518
+ };
519
+
520
+ /// Roles that promise CHILD STRUCTURE to assistive tech (rows, items,
521
+ /// cells, dialog content). Stamping one on an element that provably
522
+ /// cannot hold element children (see `elementHoldsChildren`) is role
523
+ /// misuse the registry can see: the promise can never be kept.
524
+ pub const container_role_names = [_][]const u8{
525
+ "tree", "list", "menu", "grid", "row", "dialog",
526
+ };
527
+
528
+ /// Whether markup can put element children inside this element: text
529
+ /// leaves hold a single text run and the icon leaf holds nothing (both
530
+ /// enforced by the validator), so a container role there is provably
531
+ /// misuse. Other leaves (separator, value controls) structurally accept
532
+ /// children, so the lint stays quiet about them.
533
+ pub fn elementHoldsChildren(entry: *const ElementInfo) bool {
534
+ if (entry.takes_children) return true;
535
+ if (entry.takes_text) return false;
536
+ return !std.mem.eql(u8, entry.name, "icon");
537
+ }
538
+
539
+ // ---------------------------------------------------------------- lookups
540
+
541
+ pub fn elementByName(name: []const u8) ?*const ElementInfo {
542
+ for (&elements) |*entry| {
543
+ if (std.mem.eql(u8, entry.name, name)) return entry;
544
+ }
545
+ return null;
546
+ }
547
+
548
+ pub fn elementByCode(code: u16) ?*const ElementInfo {
549
+ for (&elements) |*entry| {
550
+ if (entry.code == code) return entry;
551
+ }
552
+ return null;
553
+ }
554
+
555
+ pub fn attrByName(name: []const u8) ?*const AttrInfo {
556
+ for (&attrs) |*entry| {
557
+ if (std.mem.eql(u8, entry.name, name)) return entry;
558
+ }
559
+ return null;
560
+ }
561
+
562
+ pub fn attrByCode(code: u16) ?*const AttrInfo {
563
+ for (&attrs) |*entry| {
564
+ if (entry.code == code) return entry;
565
+ }
566
+ return null;
567
+ }
568
+
569
+ pub fn eventByName(name: []const u8) ?*const EventInfo {
570
+ for (&events) |*entry| {
571
+ if (std.mem.eql(u8, entry.name, name)) return entry;
572
+ }
573
+ return null;
574
+ }
575
+
576
+ pub fn eventByCode(code: u16) ?*const EventInfo {
577
+ for (&events) |*entry| {
578
+ if (entry.code == code) return entry;
579
+ }
580
+ return null;
581
+ }
582
+
583
+ // ------------------------------------------------------------ derivations
584
+ //
585
+ // The comptime-derived name lists the rest of the stack consumes. Each is
586
+ // a plain array (so `&list` coerces to a slice exactly like the hand-kept
587
+ // lists these replace), generated by one bounded comptime pass over the
588
+ // registry; the quota guard is explicit so a grown registry fails loudly
589
+ // at the derivation, never mysteriously downstream.
590
+
591
+ const derivation_quota = 40_000;
592
+
593
+ fn ElementPredicate(comptime field: []const u8) fn (ElementInfo) bool {
594
+ return struct {
595
+ fn includes(entry: ElementInfo) bool {
596
+ return @field(entry, field);
597
+ }
598
+ }.includes;
599
+ }
600
+
601
+ fn plainElement(entry: ElementInfo) bool {
602
+ return entry.rule_hook == null;
603
+ }
604
+
605
+ fn nonHitTargetElement(entry: ElementInfo) bool {
606
+ return plainElement(entry) and !entry.hit_target;
607
+ }
608
+
609
+ fn elementNamesWhere(comptime includes: fn (ElementInfo) bool) [countElements(includes)][]const u8 {
610
+ comptime {
611
+ @setEvalBranchQuota(derivation_quota);
612
+ var names: [countElements(includes)][]const u8 = undefined;
613
+ var index: usize = 0;
614
+ for (elements) |entry| {
615
+ if (!includes(entry)) continue;
616
+ names[index] = entry.name;
617
+ index += 1;
618
+ }
619
+ return names;
620
+ }
621
+ }
622
+
623
+ fn countElements(comptime includes: fn (ElementInfo) bool) usize {
624
+ comptime {
625
+ @setEvalBranchQuota(derivation_quota);
626
+ var count: usize = 0;
627
+ for (elements) |entry| {
628
+ if (includes(entry)) count += 1;
629
+ }
630
+ return count;
631
+ }
632
+ }
633
+
634
+ fn attrNamesWhere(comptime includes: fn (AttrInfo) bool) [countAttrs(includes)][]const u8 {
635
+ comptime {
636
+ @setEvalBranchQuota(derivation_quota);
637
+ var names: [countAttrs(includes)][]const u8 = undefined;
638
+ var index: usize = 0;
639
+ for (attrs) |entry| {
640
+ if (!includes(entry)) continue;
641
+ names[index] = entry.name;
642
+ index += 1;
643
+ }
644
+ return names;
645
+ }
646
+ }
647
+
648
+ fn countAttrs(comptime includes: fn (AttrInfo) bool) usize {
649
+ comptime {
650
+ @setEvalBranchQuota(derivation_quota);
651
+ var count: usize = 0;
652
+ for (attrs) |entry| {
653
+ if (includes(entry)) count += 1;
654
+ }
655
+ return count;
656
+ }
657
+ }
658
+
659
+ fn optionAttr(entry: AttrInfo) bool {
660
+ return entry.group == .option;
661
+ }
662
+
663
+ fn styleColorAttr(entry: AttrInfo) bool {
664
+ return entry.group == .style_color;
665
+ }
666
+
667
+ fn renderedTextAttr(entry: AttrInfo) bool {
668
+ return entry.rendered_text;
669
+ }
670
+
671
+ /// Element names the grammar accepts as plain (non-composite) elements —
672
+ /// the validator's element vocabulary and the did-you-mean list.
673
+ pub const element_names = elementNamesWhere(plainElement);
674
+
675
+ /// Elements whose content is a single run of text.
676
+ pub const text_leaf_element_names = elementNamesWhere(ElementPredicate("takes_text"));
677
+
678
+ /// Text-taking elements that ALSO accept element children in place of
679
+ /// the text run (the list-row composite).
680
+ pub const text_or_children_element_names = elementNamesWhere(ElementPredicate("takes_children"));
681
+
682
+ /// Elements whose widget kind the engine never hit-tests.
683
+ pub const non_hit_target_element_names = elementNamesWhere(nonHitTargetElement);
684
+
685
+ /// Elements whose widget kind layers its children (gap is dead there).
686
+ pub const stack_container_element_names = elementNamesWhere(ElementPredicate("stacks_children"));
687
+
688
+ /// Elements the runtime's dismissal machinery closes.
689
+ pub const dismiss_element_names = elementNamesWhere(ElementPredicate("dismissible"));
690
+
691
+ /// Elements that may float as anchored surfaces.
692
+ pub const anchor_element_names = elementNamesWhere(ElementPredicate("anchorable"));
693
+
694
+ /// Elements whose `icon` attribute draws an inline vector icon.
695
+ pub const icon_attr_element_names = elementNamesWhere(ElementPredicate("icon_attr"));
696
+
697
+ /// The generic option attributes (the validator's known-attribute set).
698
+ pub const option_attr_names = attrNamesWhere(optionAttr);
699
+
700
+ /// The color style-token attributes.
701
+ pub const color_style_attr_names = attrNamesWhere(styleColorAttr);
702
+
703
+ /// Attributes whose literal values render as label text (tofu guard).
704
+ pub const rendered_text_attr_names = attrNamesWhere(renderedTextAttr);
705
+
706
+ /// The events' markup ATTRIBUTE spellings (`on-<name>`), index-aligned
707
+ /// with `events` — the serialized form and the engines restore attribute
708
+ /// names from these, so the spelling exists exactly once.
709
+ pub const event_attr_names = blk: {
710
+ @setEvalBranchQuota(derivation_quota);
711
+ var names: [events.len][]const u8 = undefined;
712
+ for (events, 0..) |entry, index| {
713
+ names[index] = "on-" ++ entry.name;
714
+ }
715
+ break :blk names;
716
+ };
717
+
718
+ /// The event attribute spelling for a registry event code.
719
+ pub fn eventAttrNameByCode(code: u16) ?[]const u8 {
720
+ for (&events, 0..) |*entry, index| {
721
+ if (entry.code == code) return event_attr_names[index];
722
+ }
723
+ return null;
724
+ }
725
+
726
+ /// The event vocabulary (markup attributes are `on-<name>`).
727
+ pub const event_names = blk: {
728
+ @setEvalBranchQuota(derivation_quota);
729
+ var names: [events.len][]const u8 = undefined;
730
+ for (events, 0..) |entry, index| {
731
+ names[index] = entry.name;
732
+ }
733
+ break :blk names;
734
+ };
735
+
736
+ /// Markup attribute name → engine field-name pairs, for the engines'
737
+ /// generic option application and the style-token table. The pair type is
738
+ /// declared here so ui_markup_view.zig and the contract stay one import
739
+ /// away from the registry (std-only both ways).
740
+ pub const NamePair = struct { markup: []const u8, zig: []const u8 };
741
+
742
+ fn fieldBackedOption(entry: AttrInfo) bool {
743
+ return entry.group == .option and entry.field.len > 0;
744
+ }
745
+
746
+ fn pairsWhere(comptime includes: fn (AttrInfo) bool) [countAttrs(includes)]NamePair {
747
+ comptime {
748
+ @setEvalBranchQuota(derivation_quota);
749
+ var pairs: [countAttrs(includes)]NamePair = undefined;
750
+ var index: usize = 0;
751
+ for (attrs) |entry| {
752
+ if (!includes(entry)) continue;
753
+ pairs[index] = .{ .markup = entry.name, .zig = entry.field };
754
+ index += 1;
755
+ }
756
+ return pairs;
757
+ }
758
+ }
759
+
760
+ /// Generic option attributes backed by an `ElementOptions` field.
761
+ pub const option_field_pairs = pairsWhere(fieldBackedOption);
762
+
763
+ /// Color style attributes → `StyleTokenRefs` fields.
764
+ pub const color_style_field_pairs = pairsWhere(styleColorAttr);
765
+
766
+ // ---------------------------------------------------------- registry law
767
+ //
768
+ // Integrity invariants a comptime block enforces at build time (cheaper
769
+ // and earlier than a test): codes are nonzero and unique per table, and
770
+ // names are unique per table. Reuse of a retired code or a copy-pasted
771
+ // duplicate cannot compile.
772
+
773
+ /// Order-independent fingerprint over a table's (code, name) pairs,
774
+ /// sorted by code: reordering a table is free (codes carry the meaning),
775
+ /// renumbering or renaming an existing entry is not. Stated once here so
776
+ /// the stability test (ui_schema_tests.zig) and the `zig build
777
+ /// print-pins` step can never disagree about what a fingerprint is.
778
+ pub fn tableFingerprint(comptime Entry: type, entries: []const Entry) u64 {
779
+ var codes: [256]u16 = undefined;
780
+ var names: [256][]const u8 = undefined;
781
+ for (entries, 0..) |entry, index| {
782
+ codes[index] = entry.code;
783
+ names[index] = entry.name;
784
+ }
785
+ // Insertion sort by code (tables are small and this is tooling-only).
786
+ for (1..entries.len) |i| {
787
+ var j = i;
788
+ while (j > 0 and codes[j - 1] > codes[j]) : (j -= 1) {
789
+ std.mem.swap(u16, &codes[j - 1], &codes[j]);
790
+ std.mem.swap([]const u8, &names[j - 1], &names[j]);
791
+ }
792
+ }
793
+ var hasher = std.hash.Wyhash.init(0);
794
+ for (codes[0..entries.len], names[0..entries.len]) |code, name| {
795
+ hasher.update(std.mem.asBytes(&code));
796
+ hasher.update(name);
797
+ hasher.update(&.{0});
798
+ }
799
+ return hasher.final();
800
+ }
801
+
802
+ comptime {
803
+ @setEvalBranchQuota(derivation_quota);
804
+ for (elements, 0..) |entry, index| {
805
+ if (entry.code == 0) @compileError("element code 0 is reserved: " ++ entry.name);
806
+ for (elements[0..index]) |earlier| {
807
+ if (earlier.code == entry.code) @compileError("duplicate element code: " ++ entry.name);
808
+ if (std.mem.eql(u8, earlier.name, entry.name)) @compileError("duplicate element name: " ++ entry.name);
809
+ }
810
+ }
811
+ for (attrs, 0..) |entry, index| {
812
+ if (entry.code == 0) @compileError("attr code 0 is reserved: " ++ entry.name);
813
+ for (attrs[0..index]) |earlier| {
814
+ if (earlier.code == entry.code) @compileError("duplicate attr code: " ++ entry.name);
815
+ if (std.mem.eql(u8, earlier.name, entry.name)) @compileError("duplicate attr name: " ++ entry.name);
816
+ }
817
+ }
818
+ for (events, 0..) |entry, index| {
819
+ if (entry.code == 0) @compileError("event code 0 is reserved: " ++ entry.name);
820
+ for (events[0..index]) |earlier| {
821
+ if (earlier.code == entry.code) @compileError("duplicate event code: " ++ entry.name);
822
+ if (std.mem.eql(u8, earlier.name, entry.name)) @compileError("duplicate event name: " ++ entry.name);
823
+ }
824
+ }
825
+ }