@native-sdk/cli 0.10.1 → 0.11.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 (462) hide show
  1. package/README.md +8 -6
  2. package/bin/native.js +2 -1
  3. package/build/app.zig +320 -60
  4. package/build/corewire.zig +53 -0
  5. package/build/test_shards.zig +49 -0
  6. package/build/ts_run.mjs +3 -3
  7. package/build.zig +1796 -83
  8. package/package.json +19 -14
  9. package/packages/core/compile-surface/core.ts +134 -72
  10. package/packages/core/package-lock.json +75 -357
  11. package/packages/core/package.json +25 -4
  12. package/packages/core/scripts/compiler_command.mjs +17 -12
  13. package/packages/core/scripts/compiler_typecheck.mjs +1 -0
  14. package/packages/core/scripts/gen_declarations.mjs +3 -2
  15. package/packages/core/scripts/gen_service_surface.mjs +22 -10
  16. package/packages/core/scripts/install_scriptc.mjs +182 -0
  17. package/packages/core/scripts/invoke_scriptc.mjs +18 -0
  18. package/packages/core/scripts/merge_static_archives.mjs +6 -1
  19. package/packages/core/scripts/npm_static_spike.mjs +2 -2
  20. package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
  21. package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
  22. package/packages/core/scripts/run_library_compiler.mjs +51 -0
  23. package/packages/core/scripts/run_native_tests.mjs +22 -0
  24. package/packages/core/scripts/scriptc-toolchain.json +101 -0
  25. package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
  26. package/packages/core/scripts/stage_external_core.mjs +57 -1
  27. package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
  28. package/packages/core/sdk/bytes.d.ts +2 -0
  29. package/packages/core/sdk/bytes.ts +86 -0
  30. package/packages/core/sdk/core.d.ts +308 -4
  31. package/packages/core/sdk/core.ts +320 -84
  32. package/packages/core/sdk/events.d.ts +247 -0
  33. package/packages/core/sdk/events.ts +230 -2
  34. package/packages/core/sdk/internal/image_identity.d.ts +7 -0
  35. package/packages/core/sdk/internal/image_identity.ts +71 -0
  36. package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
  37. package/packages/core/sdk/internal/markdown_policy.ts +878 -0
  38. package/packages/core/sdk/text.d.ts +27 -0
  39. package/packages/core/sdk/text.ts +206 -15
  40. package/packages/core/sdk/theme.d.ts +251 -0
  41. package/packages/core/sdk/theme.ts +267 -0
  42. package/packages/core/src/authorization.ts +137 -0
  43. package/packages/core/src/automation_commands.ts +201 -0
  44. package/packages/core/src/automation_interactions.ts +92 -0
  45. package/packages/core/src/bridge_descriptors.ts +104 -0
  46. package/packages/core/src/builtin_coordination.ts +172 -0
  47. package/packages/core/src/canvas_frame_coordination.ts +81 -0
  48. package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
  49. package/packages/core/src/canvas_scene_observation.ts +145 -0
  50. package/packages/core/src/chart_content.ts +161 -0
  51. package/packages/core/src/chart_plans.ts +432 -0
  52. package/packages/core/src/checker.ts +166 -19
  53. package/packages/core/src/code_content.ts +580 -0
  54. package/packages/core/src/command_coordination.ts +140 -0
  55. package/packages/core/src/component_composition.ts +94 -0
  56. package/packages/core/src/component_construction.ts +149 -0
  57. package/packages/core/src/contract.ts +25 -7
  58. package/packages/core/src/control_appearance.ts +232 -0
  59. package/packages/core/src/control_commands.ts +115 -0
  60. package/packages/core/src/control_content.ts +105 -0
  61. package/packages/core/src/control_geometry.ts +107 -0
  62. package/packages/core/src/control_payloads.ts +119 -0
  63. package/packages/core/src/control_primitives.ts +134 -0
  64. package/packages/core/src/devhost.ts +82 -7
  65. package/packages/core/src/devhost_journal.mjs +30 -7
  66. package/packages/core/src/effect_plans.ts +71 -0
  67. package/packages/core/src/flow_measurement.ts +121 -0
  68. package/packages/core/src/font_registry.ts +37 -0
  69. package/packages/core/src/glyph_atlas.ts +86 -0
  70. package/packages/core/src/gpu_packet_preparation.ts +130 -0
  71. package/packages/core/src/gpu_planning.ts +123 -0
  72. package/packages/core/src/gpu_presentation.ts +55 -0
  73. package/packages/core/src/host_flow.ts +89 -0
  74. package/packages/core/src/host_input_regions.ts +165 -0
  75. package/packages/core/src/image_registry.ts +66 -0
  76. package/packages/core/src/indicator_plans.ts +132 -0
  77. package/packages/core/src/infer.ts +150 -8
  78. package/packages/core/src/input_composition.ts +116 -0
  79. package/packages/core/src/intrinsic_measure.ts +100 -0
  80. package/packages/core/src/layout_coordination.ts +207 -0
  81. package/packages/core/src/leaf_plans.ts +134 -0
  82. package/packages/core/src/markup_development.ts +160 -0
  83. package/packages/core/src/measurement_coordination.ts +185 -0
  84. package/packages/core/src/modules.ts +1 -1
  85. package/packages/core/src/motion_sampling.ts +100 -0
  86. package/packages/core/src/paragraph_layout.ts +192 -0
  87. package/packages/core/src/portable_sources.json +74 -0
  88. package/packages/core/src/portable_sources.ts +17 -0
  89. package/packages/core/src/registered_font.ts +93 -0
  90. package/packages/core/src/render_animation_lifecycle.ts +128 -0
  91. package/packages/core/src/render_coordination.ts +170 -0
  92. package/packages/core/src/render_resources.ts +234 -0
  93. package/packages/core/src/runtime_policy.ts +3930 -0
  94. package/packages/core/src/scalar_text.ts +84 -0
  95. package/packages/core/src/service_contract.ts +2 -1
  96. package/packages/core/src/session_codecs.ts +309 -0
  97. package/packages/core/src/shell_admission.ts +126 -0
  98. package/packages/core/src/shell_coordination.ts +93 -0
  99. package/packages/core/src/sqlite_cli.ts +11 -0
  100. package/packages/core/src/status_validation.ts +232 -0
  101. package/packages/core/src/stream_policy.ts +63 -0
  102. package/packages/core/src/surface_recipes.ts +136 -0
  103. package/packages/core/src/system_admission.ts +60 -0
  104. package/packages/core/src/terminal_paint.ts +436 -0
  105. package/packages/core/src/text_document_width.ts +81 -0
  106. package/packages/core/src/text_measurement_cache.ts +69 -0
  107. package/packages/core/src/text_query_layout.ts +179 -0
  108. package/packages/core/src/text_run_layout.ts +410 -0
  109. package/packages/core/src/text_span_queries.ts +355 -0
  110. package/packages/core/src/typed_ast.ts +18 -1
  111. package/packages/core/src/types.ts +7 -5
  112. package/packages/core/src/vector_effects.ts +98 -0
  113. package/packages/core/src/vector_raster.ts +243 -0
  114. package/packages/core/src/view_components.ts +2415 -0
  115. package/packages/core/src/view_coordination.ts +198 -0
  116. package/packages/core/src/view_frontend.ts +980 -0
  117. package/packages/core/src/widget_audits.ts +202 -0
  118. package/packages/core/src/widget_changes.ts +258 -0
  119. package/packages/core/src/widget_metrics.ts +139 -0
  120. package/packages/core/src/widget_motion.ts +171 -0
  121. package/packages/core/src/widget_paint.ts +272 -0
  122. package/packages/core/src/widget_paint_walk.ts +203 -0
  123. package/packages/core/src/widget_presentation.ts +141 -0
  124. package/packages/core/src/widget_routing.ts +262 -0
  125. package/packages/core/src/window_lifecycle.ts +92 -0
  126. package/packages/core/testing/index.ts +430 -0
  127. package/schemas/app.schema.json +13 -0
  128. package/skill-data/core/SKILL.md +2 -2
  129. package/skill-data/native-ui/SKILL.md +76 -17
  130. package/skill-data/ts-core/SKILL.md +113 -9
  131. package/skill-data/ts-services/SKILL.md +1 -1
  132. package/skill-data/ts-services/references/service-surface.md +264 -144
  133. package/src/app_runner/root.zig +25 -12
  134. package/src/app_runner/ts_compiled_view.zig +1631 -0
  135. package/src/app_runner/ts_core_main.zig +143 -10
  136. package/src/app_runner/ts_core_mobile.zig +24 -12
  137. package/src/automation/server.zig +1 -3
  138. package/src/automation/snapshot.zig +9 -637
  139. package/src/automation/snapshot_reference.zig +656 -0
  140. package/src/automation/snapshot_serialization.zig +566 -0
  141. package/src/platform/linux/gtk_host.c +36 -24
  142. package/src/platform/linux/gtk_pixels.h +118 -0
  143. package/src/platform/linux/gtk_pixels_test.c +241 -0
  144. package/src/platform/linux/root.zig +2 -0
  145. package/src/platform/macos/appkit_host.m +188 -30
  146. package/src/platform/macos/pointer_motion_test.m +96 -0
  147. package/src/platform/macos/scroll_driver_test.m +105 -0
  148. package/src/platform/macos/spectrum_bins.h +34 -0
  149. package/src/platform/macos/spectrum_bins_test.c +56 -0
  150. package/src/platform/macos/text_keyboard_test.m +80 -0
  151. package/src/platform/macos/widget_focus_test.m +66 -0
  152. package/src/platform/null_platform.zig +26 -2
  153. package/src/platform/null_platform_tests.zig +13 -0
  154. package/src/platform/root.zig +1 -0
  155. package/src/platform/types.zig +13 -0
  156. package/src/platform/windows/root.zig +2 -0
  157. package/src/platform/windows/webview2_host.cpp +7 -2
  158. package/src/primitives/app_manifest/comptime_scene.zig +1 -1
  159. package/src/primitives/app_manifest/root.zig +2 -0
  160. package/src/primitives/app_manifest/tests.zig +4 -1
  161. package/src/primitives/app_manifest/validation.zig +2 -0
  162. package/src/primitives/canvas/a11y_audit.zig +3 -1
  163. package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
  164. package/src/primitives/canvas/chart_content_policy.zig +75 -0
  165. package/src/primitives/canvas/chart_plan_policy.zig +196 -0
  166. package/src/primitives/canvas/code_content_policy.zig +162 -0
  167. package/src/primitives/canvas/commands.zig +29 -1
  168. package/src/primitives/canvas/component_composition.zig +125 -0
  169. package/src/primitives/canvas/component_composition_policy.zig +44 -0
  170. package/src/primitives/canvas/component_construction_policy.zig +187 -0
  171. package/src/primitives/canvas/container_layout_policy.zig +87 -0
  172. package/src/primitives/canvas/control_appearance_policy.zig +142 -0
  173. package/src/primitives/canvas/control_command_policy.zig +75 -0
  174. package/src/primitives/canvas/control_content_policy.zig +90 -0
  175. package/src/primitives/canvas/control_geometry_policy.zig +165 -0
  176. package/src/primitives/canvas/control_payload_policy.zig +48 -0
  177. package/src/primitives/canvas/control_primitive_policy.zig +129 -0
  178. package/src/primitives/canvas/effect_plan_policy.zig +96 -0
  179. package/src/primitives/canvas/events.zig +1027 -1
  180. package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
  181. package/src/primitives/canvas/frame.zig +92 -23
  182. package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
  183. package/src/primitives/canvas/gpu.zig +10 -0
  184. package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
  185. package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
  186. package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
  187. package/src/primitives/canvas/grid_layout_policy.zig +51 -0
  188. package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
  189. package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
  190. package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
  191. package/src/primitives/canvas/layout_audit.zig +5 -2
  192. package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
  193. package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
  194. package/src/primitives/canvas/markdown.zig +13 -3
  195. package/src/primitives/canvas/markdown_content_policy.zig +227 -0
  196. package/src/primitives/canvas/markdown_image_binding.zig +81 -0
  197. package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
  198. package/src/primitives/canvas/numeric_capabilities.zig +14 -0
  199. package/src/primitives/canvas/reference.zig +12 -6
  200. package/src/primitives/canvas/registered_font_policy.zig +152 -0
  201. package/src/primitives/canvas/render.zig +48 -0
  202. package/src/primitives/canvas/render_cache_policy.zig +184 -0
  203. package/src/primitives/canvas/render_coordination_policy.zig +163 -0
  204. package/src/primitives/canvas/render_damage_policy.zig +160 -0
  205. package/src/primitives/canvas/render_effects.zig +14 -0
  206. package/src/primitives/canvas/render_generic_resources.zig +14 -0
  207. package/src/primitives/canvas/render_images.zig +14 -0
  208. package/src/primitives/canvas/render_layers.zig +14 -0
  209. package/src/primitives/canvas/render_override_policy.zig +119 -0
  210. package/src/primitives/canvas/render_paths.zig +14 -0
  211. package/src/primitives/canvas/render_plan_policy.zig +199 -0
  212. package/src/primitives/canvas/render_resource_policy.zig +476 -0
  213. package/src/primitives/canvas/root.zig +100 -0
  214. package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
  215. package/src/primitives/canvas/serialization.zig +8 -1
  216. package/src/primitives/canvas/surface_layout_policy.zig +36 -0
  217. package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
  218. package/src/primitives/canvas/terminal_grid.zig +10 -696
  219. package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
  220. package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
  221. package/src/primitives/canvas/text.zig +1 -0
  222. package/src/primitives/canvas/text_atlas.zig +113 -0
  223. package/src/primitives/canvas/text_cache_policy.zig +94 -0
  224. package/src/primitives/canvas/text_document_policy.zig +120 -0
  225. package/src/primitives/canvas/text_layout.zig +51 -2
  226. package/src/primitives/canvas/text_layout_cache.zig +29 -0
  227. package/src/primitives/canvas/text_layout_hash.zig +1 -0
  228. package/src/primitives/canvas/text_layout_types.zig +3 -0
  229. package/src/primitives/canvas/text_measure_cache.zig +46 -0
  230. package/src/primitives/canvas/text_measurement_policy.zig +124 -0
  231. package/src/primitives/canvas/text_metrics.zig +23 -0
  232. package/src/primitives/canvas/text_query_policy.zig +156 -0
  233. package/src/primitives/canvas/text_run_policy.zig +252 -0
  234. package/src/primitives/canvas/text_scalar_policy.zig +156 -0
  235. package/src/primitives/canvas/text_span_query_policy.zig +232 -0
  236. package/src/primitives/canvas/text_spans.zig +280 -8
  237. package/src/primitives/canvas/text_tests.zig +10 -0
  238. package/src/primitives/canvas/tokens.zig +38 -0
  239. package/src/primitives/canvas/ui.zig +250 -83
  240. package/src/primitives/canvas/ui_markup.zig +139 -33
  241. package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
  242. package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
  243. package/src/primitives/canvas/ui_markup_contract.zig +146 -14
  244. package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
  245. package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
  246. package/src/primitives/canvas/ui_markup_tests.zig +116 -0
  247. package/src/primitives/canvas/ui_markup_view.zig +258 -32
  248. package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
  249. package/src/primitives/canvas/ui_schema.zig +13 -1
  250. package/src/primitives/canvas/ui_schema_tests.zig +11 -7
  251. package/src/primitives/canvas/ui_tests.zig +1 -0
  252. package/src/primitives/canvas/vector.zig +36 -2
  253. package/src/primitives/canvas/vector_effect_policy.zig +236 -0
  254. package/src/primitives/canvas/vector_raster_policy.zig +190 -0
  255. package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
  256. package/src/primitives/canvas/virtual_extents.zig +99 -3
  257. package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
  258. package/src/primitives/canvas/widget_audit_policy.zig +293 -0
  259. package/src/primitives/canvas/widget_change_policy.zig +298 -0
  260. package/src/primitives/canvas/widget_invalidation.zig +113 -2
  261. package/src/primitives/canvas/widget_layout.zig +673 -128
  262. package/src/primitives/canvas/widget_layout_tests.zig +4 -0
  263. package/src/primitives/canvas/widget_metric_policy.zig +126 -0
  264. package/src/primitives/canvas/widget_metrics.zig +45 -6
  265. package/src/primitives/canvas/widget_paint_policy.zig +166 -0
  266. package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
  267. package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
  268. package/src/primitives/canvas/widget_render.zig +744 -74
  269. package/src/primitives/canvas/widget_render_controls.zig +1217 -133
  270. package/src/primitives/canvas/widget_render_scroll.zig +11 -3
  271. package/src/primitives/canvas/widget_render_style.zig +94 -0
  272. package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
  273. package/src/primitives/canvas/widget_routing.zig +75 -0
  274. package/src/primitives/canvas/widget_routing_policy.zig +135 -0
  275. package/src/primitives/canvas/widget_runtime.zig +20 -1
  276. package/src/primitives/canvas/widget_semantics.zig +25 -0
  277. package/src/primitives/canvas/widget_text_input.zig +86 -23
  278. package/src/primitives/canvas/widget_text_select.zig +1 -0
  279. package/src/primitives/canvas/widget_tree.zig +8 -1
  280. package/src/primitives/canvas/widgets.zig +42 -12
  281. package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
  282. package/src/root.zig +21 -0
  283. package/src/runtime/accessibility_policy.zig +122 -0
  284. package/src/runtime/api.zig +28 -0
  285. package/src/runtime/app_dispatch_policy.zig +68 -0
  286. package/src/runtime/authorization_policy.zig +150 -0
  287. package/src/runtime/automation_command_policy.zig +241 -0
  288. package/src/runtime/automation_interaction_policy.zig +107 -0
  289. package/src/runtime/automation_snapshot.zig +52 -22
  290. package/src/runtime/automation_snapshot_reference.zig +290 -0
  291. package/src/runtime/automation_widget_dispatch.zig +267 -355
  292. package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
  293. package/src/runtime/blob_policy.zig +58 -0
  294. package/src/runtime/blob_reference.zig +64 -0
  295. package/src/runtime/bridge_descriptor_policy.zig +206 -0
  296. package/src/runtime/builtin_bridge.zig +180 -44
  297. package/src/runtime/builtin_coordination_policy.zig +121 -0
  298. package/src/runtime/callback_policy_test_reference.zig +97 -0
  299. package/src/runtime/canvas_drag_policy.zig +94 -0
  300. package/src/runtime/canvas_fonts.zig +38 -10
  301. package/src/runtime/canvas_frame.zig +590 -134
  302. package/src/runtime/canvas_frame_helpers.zig +1 -0
  303. package/src/runtime/canvas_hover_policy.zig +131 -0
  304. package/src/runtime/canvas_images.zig +59 -30
  305. package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
  306. package/src/runtime/canvas_limits.zig +1 -1
  307. package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
  308. package/src/runtime/canvas_scene_observation_policy.zig +181 -0
  309. package/src/runtime/canvas_widget_context_menu.zig +4 -4
  310. package/src/runtime/canvas_widget_display.zig +110 -9
  311. package/src/runtime/canvas_widget_events.zig +718 -328
  312. package/src/runtime/canvas_widget_runtime.zig +437 -81
  313. package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
  314. package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
  315. package/src/runtime/canvas_widget_state.zig +93 -56
  316. package/src/runtime/channel_sources.zig +80 -0
  317. package/src/runtime/command_policy.zig +161 -0
  318. package/src/runtime/component_policy.zig +83 -0
  319. package/src/runtime/core.zig +156 -6
  320. package/src/runtime/desktop_files.zig +189 -0
  321. package/src/runtime/effects.zig +466 -29
  322. package/src/runtime/effects_tests.zig +28 -0
  323. package/src/runtime/file_policy_test_reference.zig +113 -0
  324. package/src/runtime/flow.zig +418 -341
  325. package/src/runtime/flow_reference.zig +1426 -0
  326. package/src/runtime/font_registry_policy.zig +72 -0
  327. package/src/runtime/frame_profile.zig +24 -33
  328. package/src/runtime/gpu_surface_events.zig +97 -35
  329. package/src/runtime/host_event_pump.zig +303 -0
  330. package/src/runtime/host_event_pump_reference.zig +268 -0
  331. package/src/runtime/host_flow_policy.zig +155 -0
  332. package/src/runtime/host_input_regions_policy.zig +156 -0
  333. package/src/runtime/image_registry_policy.zig +94 -0
  334. package/src/runtime/input_composition_policy.zig +138 -0
  335. package/src/runtime/journal_policy.zig +66 -0
  336. package/src/runtime/journal_reference.zig +53 -0
  337. package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
  338. package/src/runtime/markup_development_policy.zig +91 -0
  339. package/src/runtime/media_surface.zig +40 -1
  340. package/src/runtime/motion_sampling_policy.zig +159 -0
  341. package/src/runtime/recording_policy.zig +42 -0
  342. package/src/runtime/render_animation_policy.zig +206 -0
  343. package/src/runtime/replay_policy.zig +66 -0
  344. package/src/runtime/replay_policy_reference.zig +326 -0
  345. package/src/runtime/replay_progress_policy.zig +64 -0
  346. package/src/runtime/replay_progress_reference.zig +34 -0
  347. package/src/runtime/request_policy_test_reference.zig +188 -0
  348. package/src/runtime/root.zig +13 -0
  349. package/src/runtime/session_blobs.zig +157 -58
  350. package/src/runtime/session_blobs_reference.zig +692 -0
  351. package/src/runtime/session_codec.zig +361 -0
  352. package/src/runtime/session_codec_reference.zig +1027 -0
  353. package/src/runtime/session_journal.zig +246 -983
  354. package/src/runtime/session_record.zig +224 -45
  355. package/src/runtime/session_replay.zig +157 -415
  356. package/src/runtime/session_tests.zig +552 -0
  357. package/src/runtime/shell_admission_policy.zig +225 -0
  358. package/src/runtime/shell_coordination_policy.zig +138 -0
  359. package/src/runtime/shell_layout.zig +126 -1
  360. package/src/runtime/snapshot_policy.zig +60 -0
  361. package/src/runtime/snapshot_reference.zig +64 -0
  362. package/src/runtime/state.zig +16 -0
  363. package/src/runtime/status_validation.zig +190 -0
  364. package/src/runtime/system_admission_policy.zig +140 -0
  365. package/src/runtime/system_services.zig +46 -36
  366. package/src/runtime/tests.zig +1 -0
  367. package/src/runtime/ts_canvas_hooks.zig +261 -0
  368. package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
  369. package/src/runtime/ts_canvas_icons.zig +234 -0
  370. package/src/runtime/ts_core_host.zig +2325 -411
  371. package/src/runtime/ts_core_host_tests.zig +1982 -0
  372. package/src/runtime/ts_test_host.zig +699 -0
  373. package/src/runtime/ts_ui_app.zig +1087 -45
  374. package/src/runtime/ui_app.zig +1117 -629
  375. package/src/runtime/ui_app_provenance.zig +147 -5
  376. package/src/runtime/ui_app_provenance_reference.zig +370 -0
  377. package/src/runtime/ui_app_tests.zig +619 -9
  378. package/src/runtime/ui_app_window_tests.zig +89 -0
  379. package/src/runtime/view.zig +25 -0
  380. package/src/runtime/view_canvas.zig +30 -6
  381. package/src/runtime/view_coordination_policy.zig +147 -0
  382. package/src/runtime/view_widget_control.zig +51 -14
  383. package/src/runtime/view_widget_scroll.zig +16 -5
  384. package/src/runtime/view_widget_text.zig +153 -68
  385. package/src/runtime/view_widget_tree.zig +460 -56
  386. package/src/runtime/webview_view_bridge_tests.zig +2 -0
  387. package/src/runtime/widget_motion_policy.zig +238 -0
  388. package/src/runtime/window_command_bridge_tests.zig +63 -0
  389. package/src/runtime/window_lifecycle_policy.zig +127 -0
  390. package/src/runtime/window_storage.zig +74 -8
  391. package/src/runtime/window_view_runtime.zig +148 -33
  392. package/src/runtime/window_views.zig +163 -10
  393. package/src/tooling/components/identity_tests.zig +62 -36
  394. package/src/tooling/components/stepper.native +24 -0
  395. package/src/tooling/components/stepper.zig +0 -19
  396. package/src/tooling/components/timeline-item.native +22 -0
  397. package/src/tooling/components/timeline.native +5 -3
  398. package/src/tooling/components/timeline_item.zig +0 -32
  399. package/src/tooling/eject_components.zig +76 -8
  400. package/src/tooling/ios.zig +66 -12
  401. package/src/tooling/manifest.zig +35 -0
  402. package/src/tooling/raw_manifest.zig +6 -0
  403. package/src/tooling/templates.zig +15 -3
  404. package/src/tooling/ts_core.zig +13 -3
  405. package/src/tooling/verbs.zig +22 -0
  406. package/tools/corewire/build_profile.mjs +54 -0
  407. package/tools/corewire/contract_intake.ts +303 -0
  408. package/tools/corewire/contract_intake.zig +82 -0
  409. package/tools/corewire/core.test.ts +166 -0
  410. package/tools/corewire/core_abi.zig +51 -0
  411. package/tools/corewire/core_cases.ts +233 -0
  412. package/tools/corewire/core_contract.ts +407 -0
  413. package/tools/corewire/core_emission.ts +136 -0
  414. package/tools/corewire/core_emission.zig +69 -0
  415. package/tools/corewire/core_goldens.json +3110 -0
  416. package/tools/corewire/core_policy.ts +14 -0
  417. package/tools/corewire/core_policy.zig +48 -0
  418. package/tools/corewire/core_projection.ts +360 -0
  419. package/tools/corewire/core_vocabulary.ts +6 -0
  420. package/tools/corewire/emit.zig +19 -1590
  421. package/tools/corewire/emit_facade.ts +714 -0
  422. package/tools/corewire/emit_facade.zig +10 -3752
  423. package/tools/corewire/emit_mirror.ts +290 -0
  424. package/tools/corewire/emit_profile.ts +50 -0
  425. package/tools/corewire/emit_service.ts +331 -0
  426. package/tools/corewire/emit_service.zig +23 -842
  427. package/tools/corewire/entry.test.ts +95 -0
  428. package/tools/corewire/entry_coordination.ts +127 -0
  429. package/tools/corewire/entry_coordination.zig +190 -0
  430. package/tools/corewire/facade_templates.ts +85 -0
  431. package/tools/corewire/filesystem.test.ts +166 -0
  432. package/tools/corewire/filesystem_coordination.ts +213 -0
  433. package/tools/corewire/filesystem_coordination.zig +245 -0
  434. package/tools/corewire/intake.test.ts +35 -0
  435. package/tools/corewire/intake_cases.ts +55 -0
  436. package/tools/corewire/intake_goldens.json +12237 -0
  437. package/tools/corewire/invocation.test.ts +24 -0
  438. package/tools/corewire/invocation.ts +175 -0
  439. package/tools/corewire/invocation.zig +136 -0
  440. package/tools/corewire/invocation_cases.ts +60 -0
  441. package/tools/corewire/invocation_fixture.ts +33 -0
  442. package/tools/corewire/invocation_goldens.json +1143 -0
  443. package/tools/corewire/invocation_tests.zig +111 -0
  444. package/tools/corewire/invocation_usage.ts +2 -0
  445. package/tools/corewire/lossless_projection.ts +96 -0
  446. package/tools/corewire/main.zig +7 -680
  447. package/tools/corewire/main_reference.zig +415 -0
  448. package/tools/corewire/mirror_templates.ts +55 -0
  449. package/tools/corewire/profile.test.ts +248 -0
  450. package/tools/corewire/profile.zig +56 -0
  451. package/tools/corewire/profile_emission.ts +202 -0
  452. package/tools/corewire/profile_library.json +29 -0
  453. package/tools/corewire/profile_tests.zig +136 -0
  454. package/tools/corewire/service.test.ts +75 -0
  455. package/tools/corewire/service_cases.ts +61 -0
  456. package/tools/corewire/service_contract.zig +40 -146
  457. package/tools/corewire/service_goldens.json +650 -0
  458. package/tools/corewire/service_projection.zig +52 -0
  459. package/tools/corewire/service_templates.ts +14 -0
  460. package/tools/corewire/shim_rt.zig +9 -0
  461. package/tools/corewire/sidecar.zig +267 -1438
  462. package/tools/corewire/emit_profile.zig +0 -521
@@ -24,6 +24,9 @@ const code_model = @import("code.zig");
24
24
  const font_coverage = @import("font_coverage.zig");
25
25
  const geometry = @import("geometry");
26
26
  const canvas = @import("root.zig");
27
+ const composition_recipes = @import("component_composition_policy.zig");
28
+ const composer = @import("component_composition.zig");
29
+ const construction = @import("component_construction_policy.zig");
27
30
  const reflect = @import("ui_markup_reflect.zig");
28
31
  const ui_provenance = @import("ui_provenance.zig");
29
32
 
@@ -393,6 +396,7 @@ fn colorTokenValue(colors: canvas.ColorTokens, ref: ColorTokenName) canvas.Color
393
396
 
394
397
  fn radiusTokenValue(radius: canvas.RadiusTokens, ref: RadiusTokenName) f32 {
395
398
  return switch (ref) {
399
+ .none => 0,
396
400
  inline else => |tag| @field(radius, @tagName(tag)),
397
401
  };
398
402
  }
@@ -429,6 +433,13 @@ pub fn Ui(comptime Msg: type) type {
429
433
 
430
434
  arena: std.mem.Allocator,
431
435
  failed: bool = false,
436
+ /// Compiled apps own portable recipes and construction. Native
437
+ /// extensions retain the reference when the corresponding owner is absent.
438
+ composition_policy: ?composition_recipes.Policy = null,
439
+ code_content_policy: ?canvas.CodeContentPolicy.Policy = null,
440
+ chart_content_policy: ?canvas.ChartContentPolicy.Policy = null,
441
+ markdown_content_policy: ?canvas.MarkdownContentPolicy.Policy = null,
442
+ construction_policy: ?construction.Policy = null,
432
443
  /// Window source for `virtualWindow` (see `VirtualWindowSourceFn`):
433
444
  /// null outside an app loop, where builds fall back to each
434
445
  /// request's `viewport_fallback` at offset 0.
@@ -439,6 +450,7 @@ pub fn Ui(comptime Msg: type) type {
439
450
  /// variable windows compute from estimates alone.
440
451
  virtual_extent_context: ?*anyopaque = null,
441
452
  virtual_extent_source: ?VirtualExtentSourceFn = null,
453
+ virtual_extent_policy: ?@import("virtual_extent_policy.zig").Policy = null,
442
454
  /// The windowed virtual lists this build declared (`virtualList`),
443
455
  /// for the app loop's coverage check and scroll re-derivation.
444
456
  virtual_window_records: [max_virtual_windows]VirtualWindowRecord = [_]VirtualWindowRecord{.{}} ** max_virtual_windows,
@@ -494,6 +506,7 @@ pub fn Ui(comptime Msg: type) type {
494
506
  /// Null outside an app loop (bare builders, tests that stamp
495
507
  /// grids by hand), where terminals render unbound.
496
508
  terminal_lookup: ?TerminalGridLookup = null,
509
+ pty_key_resolver: ?*const fn ([]const u8) u64 = null,
497
510
  /// The `<video src>` declaration this build recorded (see
498
511
  /// `video`): last-wins, mirroring `loadVideo`'s replace
499
512
  /// semantics — one player is the whole playback surface. The
@@ -534,6 +547,8 @@ pub fn Ui(comptime Msg: type) type {
534
547
  /// this with their content argument.
535
548
  text: []const u8 = "",
536
549
  placeholder: []const u8 = "",
550
+ /// Command dispatched by the runtime on eligible activation.
551
+ command: []const u8 = "",
537
552
  value: f32 = 0,
538
553
  /// HORIZONTAL scroll offset for a horizontal-capable
539
554
  /// `scroll` container (markup `value-x`) — the sideways
@@ -621,6 +636,8 @@ pub fn Ui(comptime Msg: type) type {
621
636
  submit_on_enter: bool = false,
622
637
  variant: canvas.WidgetVariant = .default,
623
638
  size: canvas.WidgetSize = .default,
639
+ /// Resolve backdrop blur against the live design-token register.
640
+ backdrop_blur_token: @FieldType(Widget, "backdrop_blur_token") = null,
624
641
  /// Definite width: the widget is exactly this wide (the value
625
642
  /// becomes both the min and max bound), so intrinsic content
626
643
  /// can neither shrink nor silently overflow the box. 0 keeps
@@ -780,6 +797,8 @@ pub fn Ui(comptime Msg: type) type {
780
797
  /// paints the honest empty surface. Meaningless on every
781
798
  /// other element.
782
799
  pty: u64 = 0,
800
+ /// Byte-named PTY capability. Resolution stays in the native host.
801
+ pty_name: []const u8 = "",
783
802
  /// The `.terminal` element's scrollback offset in rows
784
803
  /// above the live screen (markup `scrollback=`), following
785
804
  /// the scroll `value` source-wins reconcile rule: echo the
@@ -1525,7 +1544,7 @@ pub fn Ui(comptime Msg: type) type {
1525
1544
  if (locally_derived) |text_edit| {
1526
1545
  // Direct Tree consumers still sanitize locally:
1527
1546
  // these bytes have not crossed the runtime seam.
1528
- if (canvas.sanitizedSingleLineTextInputEvent(widget.kind, text_edit)) |sanitized| {
1547
+ if (canvas.sanitizedTextInputEventForWidget(widget, text_edit)) |sanitized| {
1529
1548
  if (self.msgForTextEdit(target_id, sanitized)) |msg| return msg;
1530
1549
  }
1531
1550
  }
@@ -1581,7 +1600,10 @@ pub fn Ui(comptime Msg: type) type {
1581
1600
  pub fn el(self: *Self, kind: WidgetKind, options: ElementOptions, children: anytype) Node {
1582
1601
  if (options.on_dismiss != null) warnDismissHandlerKind(kind);
1583
1602
  if (options.on_resize != null) warnResizeHandlerKind(kind);
1584
- var widget = widgetFromOptions(kind, options);
1603
+ var widget = self.widgetFromOptions(kind, options);
1604
+ if (kind == .terminal and options.pty_name.len > 0) {
1605
+ widget.terminal.pty = if (self.pty_key_resolver) |resolve| resolve(options.pty_name) else 0;
1606
+ }
1585
1607
  if (kind == .media_surface) self.stampVideoSurfaceFit(&widget);
1586
1608
  return .{
1587
1609
  .widget = widget,
@@ -1829,6 +1851,7 @@ pub fn Ui(comptime Msg: type) type {
1829
1851
  break :blk null;
1830
1852
  };
1831
1853
  var range_options = canvas.VirtualVariableRangeOptions{
1854
+ .policy = self.virtual_extent_policy,
1832
1855
  .item_count = options.item_count,
1833
1856
  .gap = options.gap,
1834
1857
  .viewport_extent = viewport,
@@ -1840,6 +1863,7 @@ pub fn Ui(comptime Msg: type) type {
1840
1863
  .uniform_estimate = options.item_extent,
1841
1864
  };
1842
1865
  if (table) |retained| {
1866
+ retained.policy = self.virtual_extent_policy;
1843
1867
  _ = retained.sync(.{
1844
1868
  .id = id,
1845
1869
  .item_count = options.item_count,
@@ -1851,20 +1875,25 @@ pub fn Ui(comptime Msg: type) type {
1851
1875
  });
1852
1876
  // Corrections and prepends land here, together with the
1853
1877
  // patched offsets below — the anchoring invariant.
1854
- offset += retained.takePendingOffsetDelta();
1878
+ const pending = retained.takePendingOffsetDelta();
1855
1879
  const total = retained.totalExtent();
1856
- if (options.anchor == .trailing) {
1857
- if (!state.mounted) {
1858
- offset = @max(0, total - viewport);
1859
- } else if (retained.last_build_total >= 0) {
1860
- // Was-at-the-bottom re-pin: the RETAINED offset
1861
- // is compared against the geometry it was
1862
- // scrolled under (last build's total), so both
1863
- // appends and measured corrections keep a
1864
- // pinned transcript pinned — while a viewport
1865
- // scrolled away is never yanked.
1866
- const old_max = @max(0, retained.last_build_total - retained.last_build_viewport);
1867
- if (state.offset >= old_max - trailing_stick_slop) offset = @max(0, total - viewport);
1880
+ if (self.virtual_extent_policy) |policy| {
1881
+ offset = @import("virtual_extent_policy.zig").windowOffset(policy, state.offset, pending, total, viewport, retained.last_build_total, retained.last_build_viewport, options.anchor == .trailing, state.mounted, true);
1882
+ } else {
1883
+ offset += pending;
1884
+ if (options.anchor == .trailing) {
1885
+ if (!state.mounted) {
1886
+ offset = @max(0, total - viewport);
1887
+ } else if (retained.last_build_total >= 0) {
1888
+ // Was-at-the-bottom re-pin: the RETAINED offset
1889
+ // is compared against the geometry it was
1890
+ // scrolled under (last build's total), so both
1891
+ // appends and measured corrections keep a
1892
+ // pinned transcript pinned — while a viewport
1893
+ // scrolled away is never yanked.
1894
+ const old_max = @max(0, retained.last_build_total - retained.last_build_viewport);
1895
+ if (state.offset >= old_max - trailing_stick_slop) offset = @max(0, total - viewport);
1896
+ }
1868
1897
  }
1869
1898
  }
1870
1899
  retained.last_build_total = total;
@@ -1874,7 +1903,10 @@ pub fn Ui(comptime Msg: type) type {
1874
1903
  // estimated bottom (one extra estimate pass — bare-build
1875
1904
  // pricing only; app loops always install a table).
1876
1905
  const probe = canvas.virtualVariableListRange(range_options, null);
1877
- offset = @max(0, probe.content_extent - viewport);
1906
+ offset = if (self.virtual_extent_policy) |policy|
1907
+ @import("virtual_extent_policy.zig").windowOffset(policy, state.offset, 0, probe.content_extent, viewport, -1, 0, true, false, false)
1908
+ else
1909
+ @max(0, probe.content_extent - viewport);
1878
1910
  }
1879
1911
  range_options.scroll_offset = offset;
1880
1912
  const variable = canvas.virtualVariableListRange(range_options, table);
@@ -2467,6 +2499,10 @@ pub fn Ui(comptime Msg: type) type {
2467
2499
  /// in a panel or card when those presentation choices are wanted.
2468
2500
  /// Markdown fences lower through this same component.
2469
2501
  pub fn code(self: *Self, options: CodeOptions, source: []const u8) Node {
2502
+ if (self.code_content_policy) |policy| return self.codeOwned(policy, options, source) catch {
2503
+ self.failed = true;
2504
+ return self.column(.{}, .{});
2505
+ };
2470
2506
  const line_count = codeLineCount(source, options.editable);
2471
2507
  const terminal_editor_line = options.editable and source.len > 0 and source[source.len - 1] == '\n';
2472
2508
  const numbered = options.line_numbers and line_count - @intFromBool(terminal_editor_line) <=
@@ -2585,6 +2621,66 @@ pub fn Ui(comptime Msg: type) type {
2585
2621
  return root;
2586
2622
  }
2587
2623
 
2624
+ // Assemble the copied portable recipe in the host arena. Identity,
2625
+ // owned text/spans and typed input routes remain native capabilities.
2626
+ fn codeOwned(self: *Self, policy: canvas.CodeContentPolicy.Policy, options: CodeOptions, source: []const u8) !Node {
2627
+ const plan = try canvas.CodeContentPolicy.recipe(policy, self.arena, source, @as(u8, @intFromBool(options.editable)) | (@as(u8, @intFromBool(options.wrap)) << 1) |
2628
+ (@as(u8, @intFromBool(options.line_numbers)) << 2) | (@as(u8, @intFromBool(options.height > 0)) << 3), options.added_lines, options.removed_lines);
2629
+ if (plan.flags & 4 != 0) self.failed = true;
2630
+ const diff: ?canvas.CodeDiffLines = if (plan.flags & 2 != 0) .{ .added = plan.added, .removed = plan.removed } else null;
2631
+ if (plan.content == 2) {
2632
+ const retained = if (options.wrap) blk: {
2633
+ var state: code_model.HighlightState = .{};
2634
+ break :blk self.codeParagraphWithState(source, options.language, true, options.grow, &state, null);
2635
+ } else blk: {
2636
+ const span = [_]canvas.TextSpan{.{ .text = source, .monospace = true, .color = .syntax_plain }};
2637
+ break :blk self.paragraph(.{ .wrap = false, .grow = options.grow }, &span);
2638
+ };
2639
+ var editor = self.el(.textarea, .{ .key = options.key, .global_key = options.global_key, .width = options.width, .height = options.height, .min_width = options.min_width, .grow = options.grow, .semantics = options.semantics, .on_input = options.on_input }, .{});
2640
+ editor.widget.text = retained.widget.text;
2641
+ editor.widget.spans = retained.widget.spans;
2642
+ editor.widget.text_no_wrap = !options.wrap;
2643
+ editor.widget.code_line_number_digits = plan.digits;
2644
+ if (diff) |lines| editor.widget.setCodeDiffLines(lines);
2645
+ editor.widget.runtime_flags.code_editor = true;
2646
+ editor.widget.code_language = options.language;
2647
+ editor.widget.layout.clip_content = true;
2648
+ return editor;
2649
+ }
2650
+ const content = if (plan.content == 1)
2651
+ self.decoratedCodeParagraph(source, options.language, options.wrap, plan.digits, diff)
2652
+ else blk: {
2653
+ const ends = try canvas.CodeContentPolicy.chunks(policy, self.arena, source, options.wrap, plan.chunk_count);
2654
+ var state: code_model.HighlightState = .{};
2655
+ var budget: CodeSpanBudget = .{ .remaining_chunks = ends.len };
2656
+ const grow: f32 = if (options.wrap) 1 else 0;
2657
+ if (ends.len == 1) break :blk self.codeParagraphWithState(source, options.language, options.wrap, grow, &state, &budget);
2658
+ const nodes = try self.arena.alloc(Node, ends.len);
2659
+ const fingerprint = std.hash.Wyhash.hash(0, source) | 1;
2660
+ var start: usize = 0;
2661
+ for (ends, nodes) |end, *item| {
2662
+ item.* = self.codeParagraphWithState(source[start..end], options.language, options.wrap, 0, &state, &budget);
2663
+ item.static_text_group_fingerprint = fingerprint;
2664
+ item.widget.static_text_group_offset = @intCast(start);
2665
+ start = end;
2666
+ }
2667
+ break :blk self.column(.{ .grow = grow }, .{nodes});
2668
+ };
2669
+ const body = switch (plan.axes) {
2670
+ 0 => content,
2671
+ 1 => blk: {
2672
+ var tracked = content;
2673
+ tracked.widget.layout.grow = 0;
2674
+ break :blk self.scroll(.{ .axis = .vertical, .grow = 1 }, .{self.column(.{}, .{tracked})});
2675
+ },
2676
+ 2, 3 => self.scroll(.{ .axis = if (plan.axes == 2) .horizontal else .both, .grow = 1 }, .{self.column(.{}, .{ content, self.el(.stack, .{ .height = 8 }, .{}) })}),
2677
+ else => unreachable,
2678
+ };
2679
+ var root = self.el(.column, .{ .key = options.key, .global_key = options.global_key, .width = options.width, .height = options.height, .min_width = options.min_width, .grow = options.grow, .semantics = options.semantics }, .{body});
2680
+ root.widget.layout.clip_content = true;
2681
+ return root;
2682
+ }
2683
+
2588
2684
  /// Keep numbered source in one selectable paragraph. The renderer
2589
2685
  /// owns its muted gutter, so marker digits never enter retained
2590
2686
  /// text or clipboard bytes; it derives each marker baseline from
@@ -2705,8 +2801,18 @@ pub fn Ui(comptime Msg: type) type {
2705
2801
  var highlighted = if (source.len == 0) blk: {
2706
2802
  storage[0] = .{ .text = source, .monospace = true, .color = .syntax_plain };
2707
2803
  break :blk storage[0..1];
2708
- } else code_model.highlightWithState(source, language, &storage, state);
2804
+ } else canvas.CodeContentPolicy.highlight(self.code_content_policy, source, language, &storage, state);
2709
2805
  if (budget) |span_budget| {
2806
+ if (self.code_content_policy) |policy| {
2807
+ const plan = canvas.CodeContentPolicy.spanBudget(policy, span_budget.used, span_budget.remaining_chunks, highlighted.len);
2808
+ span_budget.used = plan.used;
2809
+ span_budget.remaining_chunks = plan.remaining;
2810
+ if (plan.plain) {
2811
+ storage[0] = .{ .text = source, .monospace = true, .color = .syntax_plain };
2812
+ highlighted = storage[0..1];
2813
+ }
2814
+ return self.paragraph(.{ .wrap = wrap, .grow = grow }, highlighted);
2815
+ }
2710
2816
  std.debug.assert(span_budget.remaining_chunks > 0);
2711
2817
  span_budget.remaining_chunks -= 1;
2712
2818
  const highlighted_total = span_budget.used +
@@ -2887,6 +2993,24 @@ pub fn Ui(comptime Msg: type) type {
2887
2993
  .style = .{ .stroke_width = options.stroke_width },
2888
2994
  .semantics = options.semantics,
2889
2995
  }, .{});
2996
+ if (self.chart_content_policy) |policy| {
2997
+ const prepared = canvas.ChartContentPolicy.prepare(self.arena, policy, series) catch {
2998
+ self.failed = true;
2999
+ return node;
3000
+ };
3001
+ node.widget.chart = .{
3002
+ .series = prepared.series,
3003
+ .y_min = options.y_min,
3004
+ .y_max = options.y_max,
3005
+ .grid_lines = options.grid_lines,
3006
+ .baseline = options.baseline,
3007
+ .x_labels = if (prepared.downsampled) &.{} else options.x_labels,
3008
+ .y_labels = options.y_labels,
3009
+ .hover_details = options.hover_details,
3010
+ };
3011
+ if (node.widget.semantics.label.len == 0) node.widget.semantics.label = prepared.summary;
3012
+ return node;
3013
+ }
2890
3014
  const stored = self.arena.alloc(canvas.ChartSeries, series.len) catch {
2891
3015
  self.failed = true;
2892
3016
  return node;
@@ -2976,6 +3100,7 @@ pub fn Ui(comptime Msg: type) type {
2976
3100
  /// FIRST (document order is focus order); build the accessory
2977
3101
  /// row with `inputGroupActions`.
2978
3102
  pub fn inputGroup(self: *Self, options: InputGroupOptions, entry: Node, actions: ?Node) Node {
3103
+ if (self.composition_policy != null) return composer.Composer(Self).inputGroup(self, options, entry, actions);
2979
3104
  var semantics = options.semantics;
2980
3105
  if (semantics.role == .none) semantics.role = .group;
2981
3106
  var entry_node = entry;
@@ -3007,6 +3132,7 @@ pub fn Ui(comptime Msg: type) type {
3007
3132
  /// keep ghost/icon buttons optically inside the field's own text
3008
3133
  /// inset without double-padding the seam.
3009
3134
  pub fn inputGroupActions(self: *Self, options: InputGroupActionsOptions, children: anytype) Node {
3135
+ if (self.composition_policy != null) return composer.Composer(Self).inputActions(self, options, children);
3010
3136
  var node = self.el(.row, .{
3011
3137
  .key = options.key,
3012
3138
  .global_key = options.global_key,
@@ -3070,6 +3196,7 @@ pub fn Ui(comptime Msg: type) type {
3070
3196
  /// number otherwise — and hairline separators connect the steps.
3071
3197
  /// Display-only: driving `active` belongs to the app model.
3072
3198
  pub fn stepper(self: *Self, options: StepperOptions, steps: []const StepperStep) Node {
3199
+ if (self.composition_policy != null) return composer.Composer(Self).stepper(self, options, steps);
3073
3200
  var semantics = options.semantics;
3074
3201
  if (semantics.role == .none) semantics.role = .list;
3075
3202
  const node_count = if (steps.len == 0) 0 else steps.len * 2 - 1;
@@ -3139,11 +3266,12 @@ pub fn Ui(comptime Msg: type) type {
3139
3266
  /// `timelineItem` nodes.
3140
3267
  pub fn timeline(self: *Self, options: TimelineOptions, items: anytype) Node {
3141
3268
  var semantics = options.semantics;
3142
- if (semantics.role == .none) semantics.role = .list;
3269
+ const compiled = if (self.composition_policy) |owner| composition_recipes.plan(owner, .timeline, 0, semantics.role, 0, 0, 0, 0, options.gap) else null;
3270
+ if (compiled) |p| semantics.role = p.role() else if (semantics.role == .none) semantics.role = .list;
3143
3271
  return self.el(.column, .{
3144
3272
  .key = options.key,
3145
3273
  .global_key = options.global_key,
3146
- .gap = options.gap,
3274
+ .gap = if (compiled) |p| p.float(0) else options.gap,
3147
3275
  .grow = options.grow,
3148
3276
  .semantics = semantics,
3149
3277
  }, items);
@@ -3186,6 +3314,7 @@ pub fn Ui(comptime Msg: type) type {
3186
3314
  /// pressable — a trailing chevron with `on_press` bound to the
3187
3315
  /// item's root (presses on the content fall through to it).
3188
3316
  pub fn timelineItem(self: *Self, options: TimelineItemOptions) Node {
3317
+ if (self.composition_policy != null) return composer.Composer(Self).timelineItem(self, options);
3189
3318
  const dot = options.indicator.len == 0 and options.icon.len == 0;
3190
3319
  const indicator = self.el(.badge, .{
3191
3320
  .variant = options.variant,
@@ -3288,6 +3417,7 @@ pub fn Ui(comptime Msg: type) type {
3288
3417
  var semantics = options.semantics;
3289
3418
  if (semantics.role == .none) semantics.role = .group;
3290
3419
  const page_nodes = self.childNodes(pages);
3420
+ if (self.composition_policy != null) return composer.Composer(Self).nav(self, options, page_nodes);
3291
3421
  if (page_nodes.len == 0) {
3292
3422
  return self.el(.stack, .{
3293
3423
  .key = options.key,
@@ -3404,14 +3534,23 @@ pub fn Ui(comptime Msg: type) type {
3404
3534
  warnUncoveredText(widget.kind, widget.placeholder);
3405
3535
  warnInertWrap(widget.kind, node.wrap);
3406
3536
  warnTextSizeKind(widget.kind, widget.size);
3407
- applyStyleTokens(&widget.style, node.style_tokens, tokens);
3537
+ const construction_plan: construction.FinalPlan = if (self.construction_policy) |policy|
3538
+ construction.finalize(policy, &widget, node.style_tokens, tokens.*, node.wrap, node.nodes.len == 2, constructionHandlers(node))
3539
+ else blk: {
3540
+ applyStyleTokens(&widget.style, node.style_tokens, tokens);
3541
+ if (node.wrap == false and widget.kind == .text) widget.text_no_wrap = true;
3542
+ break :blk .{
3543
+ .make_span = node.wrap == true and widget.kind == .text and widget.spans.len == 0 and widget.text.len > 0,
3544
+ .split = widget.kind == .split and node.nodes.len == 2,
3545
+ };
3546
+ };
3408
3547
  // Opt-in text wrapping reuses the span paragraph machinery: a
3409
3548
  // wrapped text leaf becomes a single-span paragraph over its
3410
3549
  // own bytes (the span invariant: span text subslices
3411
3550
  // `widget.text`), so wrapping, intrinsic sizing, wrapped
3412
3551
  // height reservation, and rendering are all the existing span
3413
3552
  // path — no forked text pipeline.
3414
- if (node.wrap == true and widget.kind == .text and widget.spans.len == 0 and widget.text.len > 0) {
3553
+ if (construction_plan.make_span) {
3415
3554
  const spans = try self.arena.alloc(canvas.TextSpan, 1);
3416
3555
  spans[0] = .{ .text = widget.text };
3417
3556
  widget.spans = spans;
@@ -3424,9 +3563,6 @@ pub fn Ui(comptime Msg: type) type {
3424
3563
  // Span paragraphs honor the same explicit no-wrap policy.
3425
3564
  // `Ui.code` uses this to keep highlighted logical lines
3426
3565
  // intact inside its horizontal scroll region.
3427
- if (node.wrap == false and widget.kind == .text) {
3428
- widget.text_no_wrap = true;
3429
- }
3430
3566
  widget.id = if (node.global_key) |global_key|
3431
3567
  structuralId(global_id_seed, widget.kind, global_key)
3432
3568
  else
@@ -3454,34 +3590,36 @@ pub fn Ui(comptime Msg: type) type {
3454
3590
  sink.record(widget.id, source, key_trail.items(), key_trail.truncated);
3455
3591
  }
3456
3592
  }
3457
- // Typed handlers imply the matching accessibility actions, the
3458
- // same way a stringly `command` does for engine-owned dispatch.
3459
- if (node.on_press != null) widget.semantics.actions.press = true;
3460
- if (node.on_drag != null) widget.semantics.actions.drag = true;
3461
- // A double-press handler makes the element pressable too:
3462
- // the double-click's first release must land somewhere, and
3463
- // an element that acts on double click without claiming
3464
- // presses would be unreachable by pointer at all.
3465
- if (node.on_double_press != null) widget.semantics.actions.press = true;
3466
- if (node.on_toggle != null) widget.semantics.actions.toggle = true;
3467
- // A hold handler makes the element pressable (hit target +
3468
- // press claimer), like on_press: the hold gesture starts as a
3469
- // press, and the classic list-row shape (press to open, hold
3470
- // for the menu) pairs the two on one element.
3471
- if (node.on_hold != null) widget.semantics.actions.press = true;
3472
- // Hover family: binding either edge makes the element
3473
- // hover-hittable (`Widget.hover_msgs` — the chart
3474
- // hover-details shape, a hit target that claims no
3475
- // presses), never pressable: hover is not an action a
3476
- // screen reader can invoke, so no semantic action is
3477
- // stamped.
3478
- if (node.on_hover_enter != null or node.on_hover_leave != null) widget.hover_msgs = true;
3479
- if (node.on_input != null) widget.semantics.actions.set_text = true;
3480
- if (widget.kind == .slider and (node.on_value != null or node.on_change != null)) {
3481
- widget.semantics.actions.increment = true;
3482
- widget.semantics.actions.decrement = true;
3483
- }
3484
- if (widget.kind == .split and node.nodes.len == 2) {
3593
+ if (self.construction_policy == null) {
3594
+ // Typed handlers imply the matching accessibility actions, the
3595
+ // same way a stringly `command` does for engine-owned dispatch.
3596
+ if (node.on_press != null) widget.semantics.actions.press = true;
3597
+ if (node.on_drag != null) widget.semantics.actions.drag = true;
3598
+ // A double-press handler makes the element pressable too:
3599
+ // the double-click's first release must land somewhere, and
3600
+ // an element that acts on double click without claiming
3601
+ // presses would be unreachable by pointer at all.
3602
+ if (node.on_double_press != null) widget.semantics.actions.press = true;
3603
+ if (node.on_toggle != null) widget.semantics.actions.toggle = true;
3604
+ // A hold handler makes the element pressable (hit target +
3605
+ // press claimer), like on_press: the hold gesture starts as a
3606
+ // press, and the classic list-row shape (press to open, hold
3607
+ // for the menu) pairs the two on one element.
3608
+ if (node.on_hold != null) widget.semantics.actions.press = true;
3609
+ // Hover family: binding either edge makes the element
3610
+ // hover-hittable (`Widget.hover_msgs` — the chart
3611
+ // hover-details shape, a hit target that claims no
3612
+ // presses), never pressable: hover is not an action a
3613
+ // screen reader can invoke, so no semantic action is
3614
+ // stamped.
3615
+ if (node.on_hover_enter != null or node.on_hover_leave != null) widget.hover_msgs = true;
3616
+ if (node.on_input != null) widget.semantics.actions.set_text = true;
3617
+ if (widget.kind == .slider and (node.on_value != null or node.on_change != null)) {
3618
+ widget.semantics.actions.increment = true;
3619
+ widget.semantics.actions.decrement = true;
3620
+ }
3621
+ }
3622
+ if (construction_plan.split) {
3485
3623
  // Synthesize the draggable divider between the two panes.
3486
3624
  // Both markup engines build through this finalize, so the
3487
3625
  // handle exists everywhere a split does. Pane keys keep
@@ -3492,7 +3630,7 @@ pub fn Ui(comptime Msg: type) type {
3492
3630
  // into the neighbor.
3493
3631
  const child_widgets = try self.arena.alloc(Widget, 3);
3494
3632
  child_widgets[0] = try self.finalizeNode(node.nodes[0], widget.id, node.nodes[0].key orelse UiKey{ .index = 0 }, handlers, handler_len, tokens, key_trail);
3495
- child_widgets[1] = splitDividerWidget(widget);
3633
+ child_widgets[1] = try self.splitDividerWidget(widget);
3496
3634
  child_widgets[2] = try self.finalizeNode(node.nodes[1], widget.id, node.nodes[1].key orelse UiKey{ .index = 1 }, handlers, handler_len, tokens, key_trail);
3497
3635
  child_widgets[0].layout.clip_content = true;
3498
3636
  child_widgets[2].layout.clip_content = true;
@@ -3600,13 +3738,30 @@ pub fn Ui(comptime Msg: type) type {
3600
3738
  /// native selection resolves.
3601
3739
  fn appendContextMenuFallbackSurface(self: *Self, widget: *Widget, declared: []const ContextMenuItem) error{OutOfMemory}!void {
3602
3740
  if (declared.len == 0) return;
3603
- const surface_id = structuralId(widget.id, .dropdown_menu, UiKey{ .str = "context-menu" });
3741
+ var surface = if (self.construction_policy) |policy|
3742
+ (try construction.synthesize(policy, 2, false, false, false, 0, self.context_menu_fallback_point, self.arena)).widget
3743
+ else
3744
+ Widget{ .kind = .dropdown_menu, .semantics = .{ .label = "Context menu" } };
3745
+ const surface_id = structuralId(widget.id, surface.kind, UiKey{ .str = "context-menu" });
3746
+ surface.id = surface_id;
3747
+ surface.appearance_policy = widget.appearance_policy;
3604
3748
  const item_widgets = try self.arena.alloc(Widget, declared.len);
3605
3749
  const item_ids = try self.arena.alloc(ObjectId, declared.len);
3606
3750
  for (declared, 0..) |item, index| {
3751
+ if (self.construction_policy) |policy| {
3752
+ const descriptor = try construction.synthesize(policy, 1, false, item.separator, item.enabled, 0, null, self.arena);
3753
+ var item_widget = descriptor.widget;
3754
+ item_widget.id = structuralId(surface_id, item_widget.kind, UiKey{ .int = @intCast(index) });
3755
+ item_widget.appearance_policy = widget.appearance_policy;
3756
+ if (descriptor.item_identity) item_widget.text = item.label;
3757
+ item_widgets[index] = item_widget;
3758
+ item_ids[index] = if (descriptor.item_identity) item_widget.id else 0;
3759
+ continue;
3760
+ }
3607
3761
  if (item.separator) {
3608
3762
  item_widgets[index] = .{
3609
3763
  .kind = .separator,
3764
+ .appearance_policy = widget.appearance_policy,
3610
3765
  .id = structuralId(surface_id, .separator, UiKey{ .int = @intCast(index) }),
3611
3766
  };
3612
3767
  item_ids[index] = 0;
@@ -3614,6 +3769,7 @@ pub fn Ui(comptime Msg: type) type {
3614
3769
  }
3615
3770
  var item_widget = Widget{
3616
3771
  .kind = .menu_item,
3772
+ .appearance_policy = widget.appearance_policy,
3617
3773
  .id = structuralId(surface_id, .menu_item, UiKey{ .int = @intCast(index) }),
3618
3774
  .text = item.label,
3619
3775
  .state = .{ .disabled = !item.enabled },
@@ -3622,19 +3778,14 @@ pub fn Ui(comptime Msg: type) type {
3622
3778
  item_widgets[index] = item_widget;
3623
3779
  item_ids[index] = item_widget.id;
3624
3780
  }
3625
- var surface = Widget{
3626
- .kind = .dropdown_menu,
3627
- .id = surface_id,
3628
- .semantics = .{ .label = "Context menu" },
3629
- .children = item_widgets,
3630
- };
3781
+ surface.children = item_widgets;
3631
3782
  // Anchor at the recorded click point when the request carried
3632
3783
  // one (offset 0: the surface corner sits at the pointer, the
3633
3784
  // native-menu convention); the widget-edge anchor remains the
3634
3785
  // pointer-less floor. Either way the anchored-surface edge
3635
3786
  // rules apply: flip above the anchor when the surface would
3636
3787
  // cross the bottom edge, clamp into the window.
3637
- surface.layout.anchor = if (self.context_menu_fallback_point) |point|
3788
+ if (self.construction_policy == null) surface.layout.anchor = if (self.context_menu_fallback_point) |point|
3638
3789
  .{ .placement = .below, .alignment = .start, .offset = 0, .point = point }
3639
3790
  else
3640
3791
  .{ .placement = .below, .alignment = .start };
@@ -3649,6 +3800,14 @@ pub fn Ui(comptime Msg: type) type {
3649
3800
  };
3650
3801
  }
3651
3802
 
3803
+ fn constructionHandlers(node: Node) u16 {
3804
+ var mask: u16 = 0;
3805
+ inline for (.{ "on_press", "on_drag", "on_double_press", "on_toggle", "on_hold", "on_hover_enter", "on_hover_leave", "on_input", "on_value", "on_change" }, 0..) |name, i| {
3806
+ if (@field(node, name) != null) mask |= @as(u16, 1) << @intCast(i);
3807
+ }
3808
+ return mask;
3809
+ }
3810
+
3652
3811
  fn appendHandler(handlers: []Handler, handler_len: *usize, id: ObjectId, event: UiHandlerEvent, msg: ?Msg) void {
3653
3812
  const value = msg orelse return;
3654
3813
  handlers[handler_len.*] = .{ .id = id, .event = event, .action = .{ .message = value } };
@@ -3749,7 +3908,7 @@ pub fn Ui(comptime Msg: type) type {
3749
3908
  }
3750
3909
  }
3751
3910
 
3752
- fn widgetFromOptions(kind: WidgetKind, options: ElementOptions) Widget {
3911
+ fn widgetFromOptions(self: *Self, kind: WidgetKind, options: ElementOptions) Widget {
3753
3912
  warnStackContainerGap(kind, options.gap);
3754
3913
  warnUnknownIconName(options.icon);
3755
3914
  warnInertScrollAxis(kind, .{ .virtualized = options.virtualized, .axis = options.axis, .value_x = options.value_x });
@@ -3760,6 +3919,7 @@ pub fn Ui(comptime Msg: type) type {
3760
3919
  .transform = options.transform,
3761
3920
  .text = options.text,
3762
3921
  .placeholder = options.placeholder,
3922
+ .command = options.command,
3763
3923
  .icon = options.icon,
3764
3924
  .icon_placement = options.icon_placement,
3765
3925
  .text_alignment = options.text_alignment,
@@ -3775,8 +3935,9 @@ pub fn Ui(comptime Msg: type) type {
3775
3935
  .scroll_axes = options.axis,
3776
3936
  .variant = options.variant,
3777
3937
  .size = options.size,
3938
+ .backdrop_blur_token = options.backdrop_blur_token,
3778
3939
  .state = .{
3779
- .selected = options.checked or options.selected,
3940
+ .selected = false,
3780
3941
  .expanded = options.expanded,
3781
3942
  .disabled = options.disabled,
3782
3943
  },
@@ -3800,15 +3961,6 @@ pub fn Ui(comptime Msg: type) type {
3800
3961
  .virtual_anchor_index = options.virtual_anchor_index,
3801
3962
  .virtual_anchor_extent = options.virtual_anchor_extent,
3802
3963
  .virtual_total_extent = options.virtual_total_extent,
3803
- .min_size = .{ .width = @max(options.width, options.min_width), .height = options.height },
3804
- // Explicit sizes are definite (min AND max). Resizable
3805
- // is the exception: width documents the initial width
3806
- // and the engine's drag handle keeps writing larger
3807
- // frames past it.
3808
- .max_size = if (kind == .resizable) .{} else .{
3809
- .width = if (options.width > 0) options.width else options.max_width,
3810
- .height = options.height,
3811
- },
3812
3964
  },
3813
3965
  .style = options.style,
3814
3966
  .semantics = options.semantics,
@@ -3819,6 +3971,21 @@ pub fn Ui(comptime Msg: type) type {
3819
3971
  .resize_origin = options.resize_origin,
3820
3972
  .tooltip_delay_ms = options.tooltip_delay,
3821
3973
  };
3974
+ if (self.construction_policy) |policy| {
3975
+ construction.element(policy, &widget, options);
3976
+ return widget;
3977
+ }
3978
+ widget.state.selected = options.checked or options.selected;
3979
+ widget.layout.min_size = .{ .width = @max(options.width, options.min_width), .height = options.height };
3980
+ // Authored sizes are definite; resizable width seeds a frame
3981
+ // that the drag capability may grow beyond that initial size.
3982
+ widget.layout.max_size = if (kind == .resizable) .{} else .{
3983
+ .width = if (options.width > 0) options.width else options.max_width,
3984
+ .height = options.height,
3985
+ };
3986
+ // A checked radio starts with the same canonical value as a
3987
+ // retained selection, so activating it is not a change edge.
3988
+ if (kind == .radio and widget.state.selected) widget.value = 1;
3822
3989
  applyKindDefaultLayout(kind, options, &widget.layout);
3823
3990
  return widget;
3824
3991
  }
@@ -3828,11 +3995,20 @@ pub fn Ui(comptime Msg: type) type {
3828
3995
  /// Its `value` is stamped with the EFFECTIVE fraction by the
3829
3996
  /// layout pass; the authored value seeds keyboard steps before
3830
3997
  /// the first layout.
3831
- fn splitDividerWidget(split_widget: Widget) Widget {
3998
+ fn splitDividerWidget(self: *Self, split_widget: Widget) error{OutOfMemory}!Widget {
3999
+ if (self.construction_policy) |policy| {
4000
+ var result = (try construction.synthesize(policy, 0, split_widget.state.disabled, false, false, split_widget.value, null, self.arena)).widget;
4001
+ result.id = structuralId(split_widget.id, result.kind, UiKey{ .str = "divider" });
4002
+ result.interaction_policy = split_widget.interaction_policy;
4003
+ result.appearance_policy = split_widget.appearance_policy;
4004
+ return result;
4005
+ }
3832
4006
  return .{
3833
4007
  .kind = .split_divider,
3834
4008
  .id = structuralId(split_widget.id, .split_divider, UiKey{ .str = "divider" }),
3835
4009
  .value = split_widget.value,
4010
+ .interaction_policy = split_widget.interaction_policy,
4011
+ .appearance_policy = split_widget.appearance_policy,
3836
4012
  .state = .{ .disabled = split_widget.state.disabled },
3837
4013
  .semantics = .{ .label = "Split divider" },
3838
4014
  };
@@ -3897,19 +4073,10 @@ fn isTextEntryWidget(widget: Widget) bool {
3897
4073
  }
3898
4074
 
3899
4075
  fn isSubmitKeyboard(widget: Widget, keyboard: canvas.WidgetKeyboardEvent) bool {
4076
+ if (canvas.isWidgetTextEntry(widget)) return canvas.widgetKeyboardTextSubmit(widget, keyboard);
3900
4077
  if (widget.state.disabled or keyboard.phase != .key_down) return false;
3901
4078
  if (!std.ascii.eqlIgnoreCase(keyboard.key, "enter")) return false;
3902
4079
  return switch (widget.kind) {
3903
- // Single-line entry: plain Enter submits.
3904
- .text_field, .search_field, .input, .combobox => !keyboard.modifiers.hasNavigationModifier(),
3905
- // Multi-line entry: Enter edits (newline), so submit rides the
3906
- // primary chord — cmd+Enter on macOS, ctrl+Enter elsewhere.
3907
- // Shift/alt variants stay free for apps.
3908
- .textarea => if (widget.submit_on_enter)
3909
- (!keyboard.modifiers.hasNavigationModifier() and !keyboard.modifiers.shift) or
3910
- (keyboard.modifiers.hasCommandModifier() and !keyboard.modifiers.alt and !keyboard.modifiers.shift)
3911
- else
3912
- keyboard.modifiers.hasCommandModifier() and !keyboard.modifiers.alt and !keyboard.modifiers.shift,
3913
4080
  // List rows: plain Enter is the row's primary action when the
3914
4081
  // app binds `on_submit` (play the track, open the record); the
3915
4082
  // select activation keeps Space. `msgForKeyboard` resolves the