@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
@@ -102,6 +102,10 @@ const Fixture = struct {
102
102
  app: core.App,
103
103
 
104
104
  fn create() !Fixture {
105
+ return createWithPolicy(null);
106
+ }
107
+
108
+ fn createWithPolicy(policy: ?*const fn ([]const u8, []u8) usize) !Fixture {
105
109
  const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
106
110
  errdefer harness.destroy(std.testing.allocator);
107
111
  harness.null_platform.gpu_surfaces = true;
@@ -112,6 +116,7 @@ const Fixture = struct {
112
116
  .update = panelUpdate,
113
117
  .view = panelView,
114
118
  .windows_fn = panelWindows,
119
+ .window_policy = policy,
115
120
  .window_view = panelWindowView,
116
121
  });
117
122
  const app = app_state.app();
@@ -1645,3 +1650,87 @@ test "closing the pin-owning window releases its snapshot and pin" {
1645
1650
  } });
1646
1651
  try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.sends);
1647
1652
  }
1653
+
1654
+ // These intentionally choose outcomes independently of the reference key
1655
+ // lookup, proving the native consumer applies the policy's decisions.
1656
+ const WindowPolicyProbe = struct {
1657
+ var refuse_create = false;
1658
+ var retire_once = false;
1659
+ var has_window = false;
1660
+ var calls: usize = 0;
1661
+
1662
+ fn decide(request: []const u8, output: []u8) usize {
1663
+ calls += 1;
1664
+ output[0] = 0;
1665
+ output[1] = 255;
1666
+ if (request[0] == 0) {
1667
+ if (retire_once and has_window) {
1668
+ output[1] = 0;
1669
+ retire_once = false;
1670
+ has_window = false;
1671
+ }
1672
+ } else if (refuse_create) {
1673
+ output[0] = 2;
1674
+ } else if (has_window) {
1675
+ output[0] = 1;
1676
+ output[1] = 0;
1677
+ } else {
1678
+ has_window = true;
1679
+ }
1680
+ return 2;
1681
+ }
1682
+ };
1683
+
1684
+ test "window consumer follows policy admission retirement and existing-slot decisions" {
1685
+ WindowPolicyProbe.refuse_create = true;
1686
+ WindowPolicyProbe.retire_once = false;
1687
+ WindowPolicyProbe.has_window = false;
1688
+ WindowPolicyProbe.calls = 0;
1689
+ const fixture = try Fixture.createWithPolicy(WindowPolicyProbe.decide);
1690
+ defer fixture.destroy();
1691
+ try fixture.clickSettingsButton();
1692
+ try std.testing.expect(fixture.app_state.model.settings_open);
1693
+ try std.testing.expect(fixture.settingsWindowInfo() == null);
1694
+ WindowPolicyProbe.refuse_create = false;
1695
+ try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
1696
+ const first = fixture.settingsWindowInfo().?.id;
1697
+ try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
1698
+ try std.testing.expectEqual(first, fixture.settingsWindowInfo().?.id);
1699
+ WindowPolicyProbe.retire_once = true;
1700
+ try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
1701
+ try std.testing.expect(fixture.settingsWindowInfo().?.id != first);
1702
+ try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.user_closes);
1703
+ try std.testing.expect(WindowPolicyProbe.calls >= 9);
1704
+ }
1705
+
1706
+ test "failed native create leaves the next policy decision's window table empty" {
1707
+ const AdmissionProbe = struct {
1708
+ fn decide(request: []const u8, output: []u8) usize {
1709
+ output[0] = 0;
1710
+ output[1] = 255;
1711
+ if (request[0] == 1) {
1712
+ var at: usize = 1;
1713
+ for (0..3) |_| {
1714
+ const length = std.mem.readInt(u32, request[at..][0..4], .little);
1715
+ at += 4 + length;
1716
+ }
1717
+ if (request[at] != 0) {
1718
+ output[0] = 1;
1719
+ output[1] = 0;
1720
+ }
1721
+ }
1722
+ return 2;
1723
+ }
1724
+ };
1725
+ const fixture = try Fixture.createWithPolicy(AdmissionProbe.decide);
1726
+ defer fixture.destroy();
1727
+ fixture.app_state.model.settings_open = true;
1728
+ fixture.harness.null_platform.fail_next_create_window = true;
1729
+ try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
1730
+ try std.testing.expect(fixture.settingsWindowInfo() == null);
1731
+ try std.testing.expectEqual(@as(usize, 0), fixture.app_state.window_slot_count);
1732
+ try fixture.app_state.rebuild(&fixture.harness.runtime, 1);
1733
+ try std.testing.expect(fixture.settingsWindowInfo() != null);
1734
+ try std.testing.expectEqual(@as(usize, 1), fixture.app_state.window_slot_count);
1735
+ try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.user_closes);
1736
+ }
@@ -144,6 +144,16 @@ pub const CanvasWidgetClaimedKeyGrace = enum {
144
144
  /// the one focused now, so the grace and its owner pin die at blur (the
145
145
  /// target-less twin too, when the blurred view owns it).
146
146
  pub fn clearImeGraceOnViewBlur(runtime: anytype, view: *RuntimeView) void {
147
+ const composition = @import("input_composition_policy.zig");
148
+ const input = platform.GpuSurfaceInputEvent{ .window_id = view.window_id, .label = view.label, .kind = .ime_cancel_composition };
149
+ if (composition.plan(view.canvas_widget_surface_scope_policy, .retire, input, composition.observations(runtime, view))) |program| {
150
+ composition.installWidget(view, program);
151
+ view.canvas_widget_tab_input_focus_entry_held = false;
152
+ view.canvas_widget_terminal_paste_v_held = false;
153
+ if (program.has(512)) runtime.targetless_ime_preedit_len = 0;
154
+ if (program.has(2048)) runtime.targetless_ime_commit_grace = false;
155
+ return;
156
+ }
147
157
  // The owner pin clears UNCONDITIONALLY, not only when a grace is
148
158
  // armed: an active (never-cancelled) composition's owner surviving
149
159
  // a view blur would redirect post-refocus input to the stale editor
@@ -446,6 +456,15 @@ pub const RuntimeView = struct {
446
456
  widget_layout_nodes: [max_canvas_widget_nodes_per_view]canvas.WidgetLayoutNode = undefined,
447
457
  widget_layout_node_count: usize = 0,
448
458
  widget_layout_root_bounds: ?geometry.RectF = null,
459
+ /// Optional compiled traversal for this retained view. A function
460
+ /// pointer survives window compaction without retaining arena data.
461
+ canvas_widget_tab_focus_policy: ?*const fn ([]const u8, []u8) usize = null,
462
+ /// Portable anchored-surface ownership over native retained facts.
463
+ canvas_widget_surface_scope_policy: ?*const fn ([]const u8, []u8) usize = null,
464
+ /// Portable focus return; native keeps IDs and focus effects.
465
+ canvas_widget_focus_return_policy: ?*const fn ([]const u8, []u8) usize = null,
466
+ /// Portable tooltip ownership and binding survival over retained facts.
467
+ canvas_widget_tooltip_policy: ?*const fn ([]const u8, []u8) usize = null,
449
468
  widget_semantics_nodes: [max_canvas_widget_semantics_per_view]canvas.WidgetSemanticsNode = undefined,
450
469
  widget_semantics_node_count: usize = 0,
451
470
  /// Fingerprint of the last accessibility tree actually handed to the
@@ -922,6 +941,7 @@ pub const RuntimeView = struct {
922
941
  pub const copyCanvasFrameRenderOverrides = CanvasFrameMethods.copyCanvasFrameRenderOverrides;
923
942
  pub const compactCanvasFrameRenderOverrideNoops = CanvasFrameMethods.compactCanvasFrameRenderOverrideNoops;
924
943
  pub const sampleCanvasRenderAnimations = CanvasFrameMethods.sampleCanvasRenderAnimations;
944
+ pub const sampleCanvasRenderAnimationsWithPolicy = CanvasFrameMethods.sampleCanvasRenderAnimationsWithPolicy;
925
945
  pub const pruneCompletedNoopCanvasRenderAnimations = CanvasFrameMethods.pruneCompletedNoopCanvasRenderAnimations;
926
946
  pub const canvasRenderAnimationsActive = CanvasFrameMethods.canvasRenderAnimationsActive;
927
947
  pub const copyCanvasFramePipelineCache = CanvasFrameMethods.copyCanvasFramePipelineCache;
@@ -931,9 +951,12 @@ pub const RuntimeView = struct {
931
951
  pub const recordCanvasFramePresentationComplete = CanvasFrameMethods.recordCanvasFramePresentationComplete;
932
952
  pub const refreshCanvasFrameBudgetStatus = CanvasFrameMethods.refreshCanvasFrameBudgetStatus;
933
953
  pub const copyPresentedCanvasSummary = CanvasFrameMethods.copyPresentedCanvasSummary;
954
+ pub const copyPresentedCanvasSummaryWithPolicy = CanvasFrameMethods.copyPresentedCanvasSummaryWithPolicy;
934
955
  pub const copyPresentedCanvasSummaryFrom = CanvasFrameMethods.copyPresentedCanvasSummaryFrom;
935
956
  pub const currentCanvasHasUnkeyed = CanvasFrameMethods.currentCanvasHasUnkeyed;
957
+ pub const currentCanvasHasUnkeyedWithPolicy = CanvasFrameMethods.currentCanvasHasUnkeyedWithPolicy;
936
958
  pub const diffPresentedCanvasSummary = CanvasFrameMethods.diffPresentedCanvasSummary;
959
+ pub const diffPresentedCanvasSummaryWithPolicy = CanvasFrameMethods.diffPresentedCanvasSummaryWithPolicy;
937
960
  pub const currentCanvasCommandById = CanvasFrameMethods.currentCanvasCommandById;
938
961
  pub const presentedCanvasCommandById = CanvasFrameMethods.presentedCanvasCommandById;
939
962
  pub const copyCanvasCommand = CanvasFrameMethods.copyCanvasCommand;
@@ -971,6 +994,8 @@ pub const RuntimeView = struct {
971
994
  pub const canvasWidgetOwnedMenuSurfaceIndex = CanvasWidgetTreeMethods.canvasWidgetOwnedMenuSurfaceIndex;
972
995
  pub const canvasWidgetOwnedTooltipIndex = CanvasWidgetTreeMethods.canvasWidgetOwnedTooltipIndex;
973
996
  pub const canvasWidgetOwnedTooltipIdForOwner = CanvasWidgetTreeMethods.canvasWidgetOwnedTooltipIdForOwner;
997
+ pub const CanvasTooltipIntentCause = CanvasWidgetTreeMethods.CanvasTooltipIntentCause;
998
+ pub const applyCompiledCanvasTooltipIntent = CanvasWidgetTreeMethods.applyCompiledCanvasTooltipIntent;
974
999
  pub const applyCanvasTooltipVisibility = CanvasWidgetTreeMethods.applyCanvasTooltipVisibility;
975
1000
  pub const applyCanvasTooltipVisibilityToNodes = CanvasWidgetTreeMethods.applyCanvasTooltipVisibilityToNodes;
976
1001
  pub const applyCanvasTooltipVisibilityToNodesForShownId = CanvasWidgetTreeMethods.applyCanvasTooltipVisibilityToNodesForShownId;
@@ -1,3 +1,5 @@
1
+ const scene_policy = @import("canvas_scene_observation_policy.zig");
2
+ const sampling_policy = @import("motion_sampling_policy.zig");
1
3
  const geometry = @import("geometry");
2
4
  const canvas = @import("canvas");
3
5
  const canvas_frame_helpers = @import("canvas_frame.zig");
@@ -435,6 +437,11 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
435
437
  return canvas.sampleCanvasRenderAnimations(self.canvasRenderAnimations(), timestamp_ns, output);
436
438
  }
437
439
 
440
+ pub fn sampleCanvasRenderAnimationsWithPolicy(self: *const RuntimeView, timestamp_ns: u64, output: []canvas.CanvasRenderOverride, policy: ?sampling_policy.Policy) anyerror![]const canvas.CanvasRenderOverride {
441
+ if (policy) |owner| return sampling_policy.sample(self.canvasRenderAnimations(), timestamp_ns, output, owner);
442
+ return self.sampleCanvasRenderAnimations(timestamp_ns, output);
443
+ }
444
+
438
445
  pub fn pruneCompletedNoopCanvasRenderAnimations(self: *RuntimeView, timestamp_ns: u64) bool {
439
446
  var len: usize = 0;
440
447
  var pruned = false;
@@ -479,13 +486,14 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
479
486
  pub fn recordCanvasFrame(self: *RuntimeView, frame: canvas.CanvasFrame) void {
480
487
  const render_pass = frame.renderPass();
481
488
  const gpu_packet_summary = frame.gpuPacketSummary();
489
+ const encoder_counts = render_pass.encoderCounts();
482
490
  self.canvas_frame_requires_render = frame.requiresRender();
483
491
  self.canvas_frame_full_repaint = frame.full_repaint;
484
492
  self.canvas_frame_batch_count = frame.batch_plan.batchCount();
485
- self.canvas_frame_encoder_command_count = render_pass.encoderCommandCount();
486
- self.canvas_frame_encoder_cache_action_count = render_pass.encoderCacheActionCount();
487
- self.canvas_frame_encoder_bind_pipeline_count = render_pass.encoderBindPipelineCount();
488
- self.canvas_frame_encoder_draw_batch_count = render_pass.encoderDrawBatchCount();
493
+ self.canvas_frame_encoder_command_count = encoder_counts.commands;
494
+ self.canvas_frame_encoder_cache_action_count = encoder_counts.caches;
495
+ self.canvas_frame_encoder_bind_pipeline_count = encoder_counts.binds;
496
+ self.canvas_frame_encoder_draw_batch_count = encoder_counts.draws;
489
497
  self.canvas_frame_pipeline_count = frame.pipeline_cache_plan.entryCount();
490
498
  self.canvas_frame_pipeline_upload_count = frame.pipeline_cache_plan.uploadCount();
491
499
  self.canvas_frame_pipeline_retain_count = frame.pipeline_cache_plan.retainCount();
@@ -533,7 +541,7 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
533
541
  self.canvas_frame_gpu_packet_representable = gpu_packet_summary.fullyRepresentable();
534
542
  self.canvas_frame_change_count = frame.changes.len;
535
543
  self.canvas_frame_budget = frame.budget;
536
- self.canvas_frame_budget_status = frame.budgetStatus();
544
+ self.canvas_frame_budget_status = frame.budgetStatusFromPlanningSummaries(gpu_packet_summary, encoder_counts);
537
545
  self.canvas_frame_dirty_bounds = frame.dirty_bounds;
538
546
  const profile = frame.profile();
539
547
  self.canvas_frame_profile_work_units = profile.work_units;
@@ -546,6 +554,7 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
546
554
  pub fn recordCanvasFramePresentationComplete(self: *RuntimeView, frame: canvas.CanvasFrame) void {
547
555
  if (!self.presented_canvas_valid or self.presented_canvas_revision != self.canvas_revision) return;
548
556
  self.recordCanvasFrame(.{
557
+ .gpu_plan_policy = frame.gpu_plan_policy,
549
558
  .frame_index = frame.frame_index,
550
559
  .timestamp_ns = frame.timestamp_ns,
551
560
  .surface_size = frame.surface_size,
@@ -612,6 +621,10 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
612
621
  }
613
622
 
614
623
  pub fn copyPresentedCanvasSummary(self: *RuntimeView, display_list: canvas.DisplayList, surface_size: geometry.SizeF, scale: f32) anyerror!void {
624
+ return self.copyPresentedCanvasSummaryWithPolicy(display_list, surface_size, scale, null);
625
+ }
626
+
627
+ pub fn copyPresentedCanvasSummaryWithPolicy(self: *RuntimeView, display_list: canvas.DisplayList, surface_size: geometry.SizeF, scale: f32, owner: ?scene_policy.Policy) anyerror!void {
615
628
  _ = try CanvasResourceCounts.fromDisplayList(display_list);
616
629
 
617
630
  self.presented_canvas_valid = true;
@@ -631,9 +644,10 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
631
644
  .id = id,
632
645
  .bounds = command_bounds,
633
646
  };
634
- if (id == null and command_bounds != null) self.presented_canvas_has_unkeyed = true;
647
+ if (owner == null and id == null and command_bounds != null) self.presented_canvas_has_unkeyed = true;
635
648
  self.presented_canvas_command_count += 1;
636
649
  }
650
+ if (owner) |policy| self.presented_canvas_has_unkeyed = scene_policy.summaryHasUnkeyed(self.presented_canvas_commands[0..self.presented_canvas_command_count], policy);
637
651
  self.presented_canvas_revision = self.canvas_revision;
638
652
  }
639
653
 
@@ -648,6 +662,11 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
648
662
  }
649
663
 
650
664
  pub fn currentCanvasHasUnkeyed(self: *const RuntimeView) bool {
665
+ return self.currentCanvasHasUnkeyedWithPolicy(null);
666
+ }
667
+
668
+ pub fn currentCanvasHasUnkeyedWithPolicy(self: *const RuntimeView, owner: ?scene_policy.Policy) bool {
669
+ if (owner) |policy| return scene_policy.currentHasUnkeyed(self.canvasDisplayList().commands, policy);
651
670
  for (self.canvasDisplayList().commands) |command| {
652
671
  if (command.objectId() == null and command.bounds() != null) return true;
653
672
  }
@@ -655,6 +674,11 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
655
674
  }
656
675
 
657
676
  pub fn diffPresentedCanvasSummary(self: *const RuntimeView, output: []canvas.DiffChange) anyerror![]const canvas.DiffChange {
677
+ return self.diffPresentedCanvasSummaryWithPolicy(output, null);
678
+ }
679
+
680
+ pub fn diffPresentedCanvasSummaryWithPolicy(self: *const RuntimeView, output: []canvas.DiffChange, owner: ?scene_policy.Policy) anyerror![]const canvas.DiffChange {
681
+ if (owner) |policy| return scene_policy.diff(self, output, policy);
658
682
  if (self.canvas_revision == self.presented_canvas_revision) return output[0..0];
659
683
 
660
684
  // Id lookups ride the probe-table index whenever the lists
@@ -0,0 +1,147 @@
1
+ //! Copies raw window/view observations; native owns storage and OS execution.
2
+ const std = @import("std");
3
+ const geometry = @import("geometry");
4
+ const platform = @import("../platform/root.zig");
5
+ pub const Policy = *const fn ([]const u8, []u8) usize;
6
+ pub const Mode = enum(u8) { list, adjacent, repair, parent, absolute, platform_frame, local_frame, children, subtree, mutation, window };
7
+ pub const Kind = enum(u32) { none, main, native, webview };
8
+ pub const Selection = struct { kind: Kind = .none, slot: usize = 0 };
9
+ pub const Options = struct {
10
+ window_id: platform.WindowId,
11
+ label: []const u8 = "",
12
+ parent: ?[]const u8 = null,
13
+ variant: u8 = 0,
14
+ capacity: usize = platform.max_views + platform.max_webviews + 1,
15
+ depth: usize = 0,
16
+ cursor: usize = 0,
17
+ clear: bool = false,
18
+ frame: geometry.RectF = .zero(),
19
+ };
20
+ pub const Program = struct {
21
+ status: u32,
22
+ decision: u32,
23
+ selected: Selection,
24
+ count: usize,
25
+ selections: [platform.max_views + platform.max_webviews + 1]Selection = undefined,
26
+ frame: geometry.RectF = .zero(),
27
+ pub fn admitted(self: *const Program) !void {
28
+ return switch (self.status) {
29
+ 0 => {},
30
+ 1 => error.WindowNotFound,
31
+ 2 => error.ViewNotFound,
32
+ 3 => error.InvalidViewOptions,
33
+ 4 => error.UnsupportedViewFocus,
34
+ else => unreachable,
35
+ };
36
+ }
37
+ };
38
+ comptime {
39
+ if (platform.max_windows != 16 or platform.max_views != 32 or platform.max_webviews != 16 or platform.max_view_label_bytes != 64 or platform.max_webview_label_bytes != 64)
40
+ @compileError("update view coordination packet capacities");
41
+ }
42
+ fn put(bytes: []u8, at: usize, value: u32) void {
43
+ std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
44
+ }
45
+ fn word(bytes: []const u8, at: usize) u32 {
46
+ return std.mem.readInt(u32, bytes[at..][0..4], .little);
47
+ }
48
+ fn writeRect(bytes: []u8, at: usize, frame: geometry.RectF) void {
49
+ for ([_]f32{ frame.x, frame.y, frame.width, frame.height }, 0..) |value, i| put(bytes, at + i * 4, @bitCast(value));
50
+ }
51
+ fn readRect(bytes: []const u8, at: usize) geometry.RectF {
52
+ return .init(@bitCast(word(bytes, at)), @bitCast(word(bytes, at + 4)), @bitCast(word(bytes, at + 8)), @bitCast(word(bytes, at + 12)));
53
+ }
54
+ fn text(bytes: []u8, at: usize, length_at: usize, value: []const u8) void {
55
+ put(bytes, length_at, std.math.cast(u32, value.len) orelse std.math.maxInt(u32));
56
+ @memcpy(bytes[at..][0..@min(value.len, 64)], value[0..@min(value.len, 64)]);
57
+ }
58
+ fn selection(bytes: []const u8, at: usize, runtime: anytype) Selection {
59
+ const kind = std.enums.fromInt(Kind, word(bytes, at)) orelse @panic("invalid compiled view selection kind");
60
+ const slot = word(bytes, at + 4);
61
+ const count = switch (kind) {
62
+ .none => 1,
63
+ .main => runtime.window_count,
64
+ .native => runtime.view_count,
65
+ .webview => runtime.webview_count,
66
+ };
67
+ if (slot >= count) @panic("invalid compiled view selection slot");
68
+ return .{ .kind = kind, .slot = slot };
69
+ }
70
+ pub fn plan(policy: Policy, runtime: anytype, mode: Mode, options: Options) Program {
71
+ if (runtime.window_count > platform.max_windows or runtime.view_count > platform.max_views or runtime.webview_count > platform.max_webviews)
72
+ @panic("view coordination observation capacity");
73
+ var request: [192 + platform.max_windows * 64 + (platform.max_views + platform.max_webviews) * 192]u8 = @splat(0);
74
+ request[0..4].* = .{ 80, 1, @intFromEnum(mode), options.variant };
75
+ put(&request, 4, @intCast(runtime.window_count));
76
+ put(&request, 8, @intCast(runtime.view_count));
77
+ put(&request, 12, @intCast(runtime.webview_count));
78
+ std.mem.writeInt(u64, request[16..24], options.window_id, .little);
79
+ text(&request, 64, 24, options.label);
80
+ put(&request, 28, std.math.maxInt(u32));
81
+ if (options.parent) |parent| text(&request, 128, 28, parent);
82
+ put(&request, 32, @intCast(@min(options.capacity, platform.max_views + platform.max_webviews + 1)));
83
+ put(&request, 36, std.math.cast(u32, options.depth) orelse std.math.maxInt(u32));
84
+ put(&request, 40, std.math.cast(u32, options.cursor) orelse std.math.maxInt(u32));
85
+ put(&request, 44, @intFromBool(options.clear));
86
+ writeRect(&request, 48, options.frame);
87
+ for (runtime.windows[0..runtime.window_count], 0..) |*window, i| {
88
+ const at = 192 + i * 64;
89
+ std.mem.writeInt(u64, request[at..][0..8], window.info.id, .little);
90
+ put(&request, at + 8, @as(u32, @intFromBool(window.info.open)) | (@as(u32, @intFromBool(window.source != null)) << 1) | (@as(u32, @intFromBool(window.main_focused)) << 2) | (@as(u32, @intFromBool(window.main_frame_set)) << 3));
91
+ writeRect(&request, at + 16, window.info.frame);
92
+ writeRect(&request, at + 32, window.main_frame);
93
+ std.mem.writeInt(u64, request[at + 48 ..][0..8], window.main_view_id, .little);
94
+ }
95
+ var at = 192 + runtime.window_count * 64;
96
+ for (runtime.views[0..runtime.view_count]) |*view| {
97
+ writeView(&request, at, view, view.visible, view.enabled);
98
+ at += 192;
99
+ }
100
+ for (runtime.webviews[0..runtime.webview_count]) |*view| {
101
+ writeView(&request, at, view, true, true);
102
+ at += 192;
103
+ }
104
+ var output: [32 + (platform.max_views + platform.max_webviews + 1) * 8]u8 = @splat(0xa5);
105
+ const length = policy(request[0..at], &output);
106
+ if (length < 32 or length > output.len or word(&output, 0) != 1 or word(&output, 4) != @intFromEnum(mode) or word(&output, 8) > 4 or word(&output, 28) != 0)
107
+ @panic("invalid compiled view coordination header");
108
+ var result = Program{ .status = word(&output, 8), .decision = word(&output, 12), .selected = selection(&output, 16, runtime), .count = word(&output, 24) };
109
+ const has_frame = result.status == 0 and (mode == .absolute or mode == .platform_frame or mode == .local_frame);
110
+ if (result.count > result.selections.len or length != 32 + result.count * 8 + @as(usize, if (has_frame) 16 else 0) or ((mode != .list and mode != .children) and result.count != 0) or (mode == .list and result.count > options.capacity) or (result.status != 0 and (result.count != 0 or result.selected.kind != .none or result.decision != 0)))
111
+ @panic("invalid compiled view coordination shape");
112
+ const decision_limit: u32 = switch (mode) {
113
+ .repair, .children => 2,
114
+ .subtree => 1,
115
+ .mutation => 7,
116
+ else => 0,
117
+ };
118
+ if (result.decision > decision_limit or (result.selected.kind != .none and mode != .adjacent and mode != .repair and mode != .mutation))
119
+ @panic("invalid compiled view coordination decision");
120
+ const status_valid = switch (mode) {
121
+ .list, .repair, .children, .subtree, .mutation => result.status == 0,
122
+ .adjacent => result.status == 0 or result.status == 1 or result.status == 4,
123
+ .parent => result.status == 0 or result.status == 2 or result.status == 3,
124
+ .absolute, .platform_frame, .local_frame => result.status <= 3,
125
+ .window => result.status == 0 or result.status == 1,
126
+ };
127
+ if (!status_valid or (mode == .adjacent and result.status == 0 and result.selected.kind == .none) or (mode == .repair and ((result.decision == 2) != (result.selected.kind != .none))) or (mode == .children and (result.decision != @as(u32, options.variant) + 1 or (options.cursor != 0 and result.count > 1))) or (mode == .mutation and ((result.decision & 1 != 0) != (result.selected.kind != .none) or (result.decision & 4 != 0 and result.decision & 2 != 0))))
128
+ @panic("invalid compiled view coordination admission");
129
+ for (result.selections[0..result.count], 0..) |*selected, i| {
130
+ selected.* = selection(&output, 32 + i * 8, runtime);
131
+ if (selected.kind == .none or (mode == .children and selected.kind == .main)) @panic("invalid compiled view coordination list member");
132
+ if (mode == .children and options.cursor != 0 and options.cursor != (if (selected.kind == .native) selected.slot + 1 else selected.slot + 33)) @panic("invalid compiled descendant cursor result");
133
+ }
134
+ if (has_frame) result.frame = readRect(&output, 32);
135
+ return result;
136
+ }
137
+ fn writeView(bytes: []u8, at: usize, view: anytype, visible: bool, enabled: bool) void {
138
+ if (view.label.len > 64 or (view.parent != null and view.parent.?.len > 64)) @panic("view coordination label capacity");
139
+ std.mem.writeInt(u64, bytes[at..][0..8], view.window_id, .little);
140
+ put(bytes, at + 8, @as(u32, @intFromBool(view.open)) | (@as(u32, @intFromBool(visible)) << 1) | (@as(u32, @intFromBool(enabled)) << 2) | (@as(u32, @intFromBool(view.focused)) << 3));
141
+ text(bytes, at + 64, at + 16, view.label);
142
+ put(bytes, at + 20, std.math.maxInt(u32));
143
+ if (view.parent) |parent| text(bytes, at + 128, at + 20, parent);
144
+ std.mem.writeInt(u64, bytes[at + 24 ..][0..8], view.id, .little);
145
+ writeRect(bytes, at + 32, view.frame);
146
+ if (comptime @hasField(@TypeOf(view.*), "local_frame")) writeRect(bytes, at + 48, view.local_frame);
147
+ }
@@ -158,8 +158,8 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
158
158
  const available = @max(0, content.width - divider_extent);
159
159
  const first_min = @max(0, self.widget_layout_nodes[first_index].widget.layout.min_size.width);
160
160
  const second_min = @max(0, self.widget_layout_nodes[second_index].widget.layout.min_size.width);
161
- const fraction = canvas.splitEffectiveFraction(@max(requested_fraction, 0.0001), available, first_min, second_min);
162
- const previous_fraction = canvas.splitEffectiveFraction(self.widget_layout_nodes[handle_index].widget.value, available, first_min, second_min);
161
+ const fraction = canvas.widgetSplitEffectiveFraction(split_node.widget, requested_fraction, available, first_min, second_min, true);
162
+ const previous_fraction = canvas.widgetSplitEffectiveFraction(split_node.widget, self.widget_layout_nodes[handle_index].widget.value, available, first_min, second_min, false);
163
163
  if (fraction == previous_fraction) return null;
164
164
 
165
165
  const first_width = available * fraction;
@@ -234,7 +234,8 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
234
234
 
235
235
  const previous_frame = self.widget_layout_nodes[index].frame;
236
236
  const min_width = canvasWidgetResizableMinWidth(widget);
237
- const next_width = @max(min_width, previous_frame.width + delta_x);
237
+ const next_width = canvas.widgetCompiledResizableWidth(widget, 0, previous_frame.width, delta_x) orelse
238
+ @max(min_width, previous_frame.width + delta_x);
238
239
  if (next_width == previous_frame.width) return null;
239
240
 
240
241
  self.widget_layout_nodes[index].frame.width = next_width;
@@ -316,7 +317,7 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
316
317
  const widget = self.widget_layout_nodes[index].widget;
317
318
  if (widget.kind != .slider or widget.state.disabled or widget.frame.width <= 0) return null;
318
319
 
319
- const next_value = std.math.clamp((point.x - widget.frame.x) / widget.frame.width, 0, 1);
320
+ const next_value = (point.x - widget.frame.x) / widget.frame.width;
320
321
  const dirty = try self.setCanvasWidgetValue(index, next_value) orelse return null;
321
322
  self.noteCanvasWidgetChangeEvent(id);
322
323
  return dirty;
@@ -327,9 +328,10 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
327
328
  const widget = self.widget_layout_nodes[index].widget;
328
329
  if ((widget.kind != .accordion and widget.kind != .checkbox and widget.kind != .toggle_button and widget.kind != .toggle and !canvasWidgetSwitchControlKind(widget.kind)) or widget.state.disabled) return null;
329
330
 
330
- const selected = canvasWidgetBooleanSelected(widget);
331
- self.widget_layout_nodes[index].widget.state.selected = !selected;
332
- self.widget_layout_nodes[index].widget.value = if (!selected) 1 else 0;
331
+ const selected = canvas_widget_runtime.canvasWidgetCompiledToggleSelected(widget, 8, false, false) orelse
332
+ canvas_widget_runtime.canvasWidgetCompiledAccordionSelected(widget, 8, null, false) orelse !canvasWidgetBooleanSelected(widget);
333
+ self.widget_layout_nodes[index].widget.state.selected = selected;
334
+ self.widget_layout_nodes[index].widget.value = if (selected) 1 else 0;
333
335
  // Disclosure widgets note the toggle for the NEXT rebuild:
334
336
  // this optimistic echo already flipped the retained state,
335
337
  // so the rebuild-time flip detection that arms the
@@ -360,7 +362,15 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
360
362
  // a "Duplicate" row must never come back checked. The group's
361
363
  // declared row is the whole distinction; there is no separate
362
364
  // menu mode flag.
363
- if (selected and widget.kind == .menu_item and !canvasWidgetMenuGroupHasCommittedRow(self, index)) return null;
365
+ var menu_clear: [1025]u8 = undefined;
366
+ const menu_policy_len = if (selected and widget.kind == .menu_item)
367
+ canvas_widget_runtime.canvasWidgetMenuPolicy(self.widgetLayoutTree(), index, 8, &menu_clear)
368
+ else
369
+ null;
370
+ if (menu_policy_len) |len| {
371
+ if (len != self.widget_layout_node_count + 1) @panic("invalid menu selection policy result");
372
+ if (menu_clear[0] == 0) return null;
373
+ } else if (selected and widget.kind == .menu_item and !canvasWidgetMenuGroupHasCommittedRow(self, index)) return null;
364
374
 
365
375
  var dirty: ?geometry.RectF = null;
366
376
  var changed = false;
@@ -368,11 +378,16 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
368
378
  // Tree selection is single-select across the WHOLE tree
369
379
  // scope (rows nest at any depth, so parent-scoped
370
380
  // clearing would leave one selection per level).
371
- const scope = canvas_widget_runtime.canvasWidgetTreeScopeIndex(self.widgetLayoutTree(), index);
381
+ var clear: [1024]u8 = undefined;
382
+ const policy_len = canvas_widget_runtime.canvasWidgetTreePolicy(self.widgetLayoutTree(), index, 8, &clear);
383
+ if (policy_len) |len| if (len != self.widget_layout_node_count) @panic("invalid tree selection policy result");
384
+ const scope = if (policy_len == null) canvas_widget_runtime.canvasWidgetTreeScopeIndex(self.widgetLayoutTree(), index) else null;
372
385
  for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, row_index| {
373
386
  if (row_index == index) continue;
374
387
  if (node.widget.semantics.role != .treeitem) continue;
375
- if (canvas_widget_runtime.canvasWidgetTreeScopeIndex(self.widgetLayoutTree(), row_index) != scope) continue;
388
+ if (policy_len != null) {
389
+ if (clear[row_index] == 0) continue;
390
+ } else if (canvas_widget_runtime.canvasWidgetTreeScopeIndex(self.widgetLayoutTree(), row_index) != scope) continue;
376
391
  if (!canvasWidgetSelectableSelected(node.widget)) continue;
377
392
  node.widget.state.selected = false;
378
393
  node.widget.value = 0;
@@ -384,11 +399,18 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
384
399
  // layout containers wrap its radios. Nearest-ancestor
385
400
  // resolution also isolates nested radio groups. A bare
386
401
  // radio deliberately falls back to its direct parent.
387
- const scope = canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), index);
402
+ var clear: [1024]u8 = undefined;
403
+ const policy_len = canvas_widget_runtime.canvasWidgetRadioPolicy(self.widgetLayoutTree(), index, 8, &clear);
404
+ if (policy_len) |len| {
405
+ if (len != self.widget_layout_node_count) @panic("invalid radio selection policy result");
406
+ }
407
+ const scope = if (policy_len == null) canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), index) else null;
388
408
  const parent_index = self.widget_layout_nodes[index].parent_index;
389
409
  for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, radio_index| {
390
410
  if (radio_index == index or node.widget.kind != .radio) continue;
391
- if (scope) |radio_group_index| {
411
+ if (policy_len != null) {
412
+ if (clear[radio_index] == 0) continue;
413
+ } else if (scope) |radio_group_index| {
392
414
  if (canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), radio_index) != radio_group_index) continue;
393
415
  } else if (node.parent_index != parent_index or canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), radio_index) != null) continue;
394
416
  if (!canvasWidgetSelectableSelected(node.widget)) continue;
@@ -398,10 +420,22 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
398
420
  changed = true;
399
421
  }
400
422
  } else if (selected and canvasWidgetSelectionClearsSiblings(widget.kind)) {
423
+ var clear: [1024]u8 = undefined;
424
+ const policy_len = if (widget.kind == .segmented_control)
425
+ canvas_widget_runtime.canvasWidgetTabsPolicy(self.widgetLayoutTree(), index, 8, &clear)
426
+ else if (widget.kind == .list_item)
427
+ canvas_widget_runtime.canvasWidgetListPolicy(self.widgetLayoutTree(), index, 8, &clear)
428
+ else
429
+ null;
430
+ if (policy_len) |len| if (len != self.widget_layout_node_count) @panic("invalid sibling selection policy result");
401
431
  const parent_index = self.widget_layout_nodes[index].parent_index;
402
432
  for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, sibling_index| {
403
433
  if (sibling_index == index) continue;
404
- if (node.parent_index != parent_index or node.widget.kind != widget.kind) continue;
434
+ if (menu_policy_len != null) {
435
+ if (menu_clear[sibling_index + 1] == 0) continue;
436
+ } else if (policy_len != null) {
437
+ if (clear[sibling_index] == 0) continue;
438
+ } else if (node.parent_index != parent_index or node.widget.kind != widget.kind) continue;
405
439
  if (!canvasWidgetSelectableSelected(node.widget)) continue;
406
440
  node.widget.state.selected = false;
407
441
  node.widget.value = 0;
@@ -440,7 +474,10 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
440
474
  pub fn setCanvasWidgetValue(self: *RuntimeView, index: usize, value: f32) anyerror!?geometry.RectF {
441
475
  if (index >= self.widget_layout_node_count) return null;
442
476
  const widget = self.widget_layout_nodes[index].widget;
443
- const next_value = std.math.clamp(value, 0, 1);
477
+ if (!std.math.isFinite(value)) return null;
478
+ var candidate = widget;
479
+ candidate.value = value;
480
+ const next_value = canvas.widgetCompiledSliderValue(candidate, 0, null, 0, false) orelse std.math.clamp(value, 0, 1);
444
481
  if (next_value == widget.value) return null;
445
482
  self.widget_layout_nodes[index].widget.value = next_value;
446
483
  try self.refreshCanvasWidgetSemantics();
@@ -13,6 +13,7 @@ const canvasWidgetSingleLineTextKind = canvas_widget_runtime.canvasWidgetSingleL
13
13
  pub const CanvasWidgetScrollSource = enum {
14
14
  discrete,
15
15
  wheel,
16
+ detented_wheel,
16
17
  };
17
18
 
18
19
  /// Virtualized containers whose scroll offset stays MODEL-driven (the
@@ -196,6 +197,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
196
197
  if (viewport.isEmpty()) return false;
197
198
 
198
199
  const current = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport).axis(axis);
200
+ if (canvas.widgetCompiledScrollResult(scroll_node.widget, .{ .operation = 14, .current = current.offset, .viewport = current.viewport_extent, .content = current.content_extent, .delta = delta })) |result| return result.dx != 0;
199
201
  const max_offset = current.maxOffset();
200
202
  if (current.offset < 0) return delta > 0;
201
203
  if (current.offset > max_offset) return delta < 0;
@@ -234,18 +236,24 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
234
236
  // pull it back.
235
237
  const physics = canvas.widgetScrollPhysics(scroll_node.widget, self.widget_tokens.scroll);
236
238
  const rubberband = allow_rubberband and !scroll_node.widget.runtime_flags.native_scroll;
237
- const next = switch (source) {
238
- .wheel => if (rubberband)
239
+ var next = switch (source) {
240
+ .wheel, .detented_wheel => if (rubberband)
239
241
  current.applyWheel(delta, physics)
240
242
  else
241
243
  current.applyWheelClamped(delta, physics),
242
244
  .discrete => discrete: {
243
245
  var axis_state = current;
246
+ if (canvas.widgetCompiledScrollResult(scroll_node.widget, .{ .operation = 1, .current = current.offset, .viewport = current.viewport_extent, .content = current.content_extent, .delta = delta })) |result| {
247
+ axis_state.offset = result.dx;
248
+ axis_state.velocity = 0;
249
+ break :discrete axis_state;
250
+ }
244
251
  axis_state.offset += delta;
245
252
  axis_state.velocity = 0;
246
253
  break :discrete axis_state.clamped();
247
254
  },
248
255
  };
256
+ if (source == .detented_wheel) next.velocity = 0;
249
257
  self.widget_scroll_states[scroll_index] = state.withAxis(axis, next);
250
258
  if (next.offset == current.offset) return null;
251
259
 
@@ -290,7 +298,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
290
298
  canvas.textInputContentWidthForWidget(widget, self.widget_tokens),
291
299
  };
292
300
  const next = switch (source) {
293
- .wheel => current.applyWheelClamped(delta, self.widget_tokens.scroll),
301
+ .wheel, .detented_wheel => current.applyWheelClamped(delta, self.widget_tokens.scroll),
294
302
  .discrete => discrete: {
295
303
  var state = current;
296
304
  state.offset += delta;
@@ -366,7 +374,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
366
374
  var next = current;
367
375
  if (canvas.widgetScrollsAxis(scroll_node.widget, .vertical)) {
368
376
  var axis_state = current.axis(.vertical);
369
- axis_state.offset = switch (target) {
377
+ axis_state.offset = if (canvas.widgetCompiledScrollResult(scroll_node.widget, .{ .operation = if (target == .start) 12 else 13, .viewport = axis_state.viewport_extent, .content = axis_state.content_extent })) |result| result.dx else switch (target) {
370
378
  .start => 0,
371
379
  .end => axis_state.maxOffset(),
372
380
  };
@@ -375,7 +383,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
375
383
  }
376
384
  if (canvas.widgetScrollsAxis(scroll_node.widget, .horizontal)) {
377
385
  var axis_state = current.axis(.horizontal);
378
- axis_state.offset = switch (target) {
386
+ axis_state.offset = if (canvas.widgetCompiledScrollResult(scroll_node.widget, .{ .operation = if (target == .start) 12 else 13, .viewport = axis_state.viewport_extent, .content = axis_state.content_extent })) |result| result.dx else switch (target) {
379
387
  .start => 0,
380
388
  .end => axis_state.maxOffset(),
381
389
  };
@@ -516,6 +524,9 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
516
524
 
517
525
  const current_axis = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport).axis(axis);
518
526
  var next_axis = current_axis;
527
+ if (canvas.widgetCompiledScrollResult(scroll_node.widget, .{ .operation = 1, .current = current_axis.offset, .viewport = current_axis.viewport_extent, .content = current_axis.content_extent, .delta = requested })) |result| {
528
+ return result.dx - current_axis.offset;
529
+ }
519
530
  next_axis.offset += requested;
520
531
  next_axis.velocity = 0;
521
532
  next_axis = next_axis.clamped();