@native-sdk/cli 0.0.0 → 0.4.1

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 (373) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +50 -1
  3. package/app.zon +30 -0
  4. package/assets/icon.icns +0 -0
  5. package/assets/icon.ico +0 -0
  6. package/assets/icon.png +0 -0
  7. package/assets/icon.svg +15 -0
  8. package/assets/native-sdk.entitlements +10 -0
  9. package/assets/native-sdk.manifest +12 -0
  10. package/bin/native.js +156 -0
  11. package/build/app.zig +716 -0
  12. package/build.zig +2593 -0
  13. package/build.zig.zon +24 -0
  14. package/native-sdk.d.ts +615 -0
  15. package/package.json +45 -8
  16. package/skill-data/automation/SKILL.md +248 -0
  17. package/skill-data/core/SKILL.md +249 -0
  18. package/skill-data/core/references/app-model-runtime.md +141 -0
  19. package/skill-data/core/references/bridge-security-native-capabilities.md +230 -0
  20. package/skill-data/core/references/frontend-assets.md +124 -0
  21. package/skill-data/core/references/project-anatomy.md +108 -0
  22. package/skill-data/core/references/web-engines-packaging-debugging.md +199 -0
  23. package/skill-data/native-ui/SKILL.md +1080 -0
  24. package/skills/native-sdk/SKILL.md +33 -0
  25. package/src/app_runner/root.zig +740 -0
  26. package/src/assets/root.zig +20 -0
  27. package/src/automation/protocol.zig +285 -0
  28. package/src/automation/root.zig +13 -0
  29. package/src/automation/server.zig +506 -0
  30. package/src/automation/snapshot.zig +1202 -0
  31. package/src/automation/watcher.zig +165 -0
  32. package/src/bridge/root.zig +507 -0
  33. package/src/debug/root.zig +246 -0
  34. package/src/embed/app_exports.zig +11 -0
  35. package/src/embed/c_api.zig +793 -0
  36. package/src/embed/c_exports.zig +10 -0
  37. package/src/embed/chrome.zig +168 -0
  38. package/src/embed/conversions.zig +359 -0
  39. package/src/embed/host.zig +960 -0
  40. package/src/embed/root.zig +81 -0
  41. package/src/embed/tests.zig +2552 -0
  42. package/src/embed/types.zig +382 -0
  43. package/src/embed/ui_host.zig +289 -0
  44. package/src/extensions/root.zig +197 -0
  45. package/src/frontend/root.zig +48 -0
  46. package/src/js/root.zig +65 -0
  47. package/src/platform/android/NativeSdkActivity.java +1370 -0
  48. package/src/platform/android/android_host.c +696 -0
  49. package/src/platform/android/files.zig +9 -0
  50. package/src/platform/android/native_sdk_app.h +237 -0
  51. package/src/platform/ios/files.zig +8 -0
  52. package/src/platform/ios/native_sdk_app.h +289 -0
  53. package/src/platform/ios/uikit_host.m +2739 -0
  54. package/src/platform/linux/cef_host.cpp +599 -0
  55. package/src/platform/linux/gtk_host.c +5362 -0
  56. package/src/platform/linux/gtk_host.h +265 -0
  57. package/src/platform/linux/root.zig +1519 -0
  58. package/src/platform/macos/appkit_host.h +604 -0
  59. package/src/platform/macos/appkit_host.m +10392 -0
  60. package/src/platform/macos/automation_host.h +14 -0
  61. package/src/platform/macos/automation_host.m +12 -0
  62. package/src/platform/macos/cef_host.mm +3028 -0
  63. package/src/platform/macos/root.zig +2260 -0
  64. package/src/platform/null_platform.zig +2232 -0
  65. package/src/platform/null_platform_tests.zig +670 -0
  66. package/src/platform/policy_values.zig +14 -0
  67. package/src/platform/root.zig +181 -0
  68. package/src/platform/types.zig +2681 -0
  69. package/src/platform/windows/cef_host.cpp +3 -0
  70. package/src/platform/windows/root.zig +1521 -0
  71. package/src/platform/windows/webview2_host.cpp +6230 -0
  72. package/src/primitives/app_dirs/root.zig +440 -0
  73. package/src/primitives/app_manifest/root.zig +109 -0
  74. package/src/primitives/app_manifest/tests.zig +758 -0
  75. package/src/primitives/app_manifest/types.zig +587 -0
  76. package/src/primitives/app_manifest/validation.zig +828 -0
  77. package/src/primitives/assets/root.zig +520 -0
  78. package/src/primitives/canvas/a11y_audit.zig +390 -0
  79. package/src/primitives/canvas/a11y_audit_tests.zig +225 -0
  80. package/src/primitives/canvas/app_icon.zig +1590 -0
  81. package/src/primitives/canvas/chart.zig +392 -0
  82. package/src/primitives/canvas/chart_tests.zig +751 -0
  83. package/src/primitives/canvas/commands.zig +446 -0
  84. package/src/primitives/canvas/drawing.zig +309 -0
  85. package/src/primitives/canvas/equality.zig +316 -0
  86. package/src/primitives/canvas/events.zig +696 -0
  87. package/src/primitives/canvas/font_coverage.zig +118 -0
  88. package/src/primitives/canvas/font_ttf.zig +510 -0
  89. package/src/primitives/canvas/font_ttf_tests.zig +280 -0
  90. package/src/primitives/canvas/fonts/Geist-Regular.ttf +0 -0
  91. package/src/primitives/canvas/fonts/GeistMono-Regular.ttf +0 -0
  92. package/src/primitives/canvas/frame.zig +679 -0
  93. package/src/primitives/canvas/frame_metrics.zig +462 -0
  94. package/src/primitives/canvas/gpu.zig +639 -0
  95. package/src/primitives/canvas/hash.zig +112 -0
  96. package/src/primitives/canvas/icons/alert.svg +1 -0
  97. package/src/primitives/canvas/icons/archive.svg +1 -0
  98. package/src/primitives/canvas/icons/arrow-down.svg +1 -0
  99. package/src/primitives/canvas/icons/arrow-right.svg +1 -0
  100. package/src/primitives/canvas/icons/arrow-up.svg +1 -0
  101. package/src/primitives/canvas/icons/check-circle.svg +1 -0
  102. package/src/primitives/canvas/icons/check.svg +1 -0
  103. package/src/primitives/canvas/icons/chevron-down.svg +1 -0
  104. package/src/primitives/canvas/icons/chevron-left.svg +1 -0
  105. package/src/primitives/canvas/icons/chevron-right.svg +1 -0
  106. package/src/primitives/canvas/icons/chevron-up.svg +1 -0
  107. package/src/primitives/canvas/icons/circle-dot.svg +1 -0
  108. package/src/primitives/canvas/icons/clock.svg +1 -0
  109. package/src/primitives/canvas/icons/copy.svg +1 -0
  110. package/src/primitives/canvas/icons/download.svg +1 -0
  111. package/src/primitives/canvas/icons/edit.svg +1 -0
  112. package/src/primitives/canvas/icons/ellipsis.svg +1 -0
  113. package/src/primitives/canvas/icons/external-link.svg +1 -0
  114. package/src/primitives/canvas/icons/eye.svg +1 -0
  115. package/src/primitives/canvas/icons/file-text.svg +1 -0
  116. package/src/primitives/canvas/icons/folder-open.svg +1 -0
  117. package/src/primitives/canvas/icons/folder.svg +1 -0
  118. package/src/primitives/canvas/icons/git-branch.svg +1 -0
  119. package/src/primitives/canvas/icons/git-merge.svg +1 -0
  120. package/src/primitives/canvas/icons/git-pull-request.svg +1 -0
  121. package/src/primitives/canvas/icons/info.svg +1 -0
  122. package/src/primitives/canvas/icons/menu.svg +1 -0
  123. package/src/primitives/canvas/icons/missing.svg +1 -0
  124. package/src/primitives/canvas/icons/moon.svg +1 -0
  125. package/src/primitives/canvas/icons/music.svg +1 -0
  126. package/src/primitives/canvas/icons/panel-left.svg +1 -0
  127. package/src/primitives/canvas/icons/panel-right.svg +1 -0
  128. package/src/primitives/canvas/icons/pause.svg +1 -0
  129. package/src/primitives/canvas/icons/play.svg +1 -0
  130. package/src/primitives/canvas/icons/plus.svg +1 -0
  131. package/src/primitives/canvas/icons/refresh-cw.svg +1 -0
  132. package/src/primitives/canvas/icons/repeat.svg +1 -0
  133. package/src/primitives/canvas/icons/save.svg +1 -0
  134. package/src/primitives/canvas/icons/search.svg +1 -0
  135. package/src/primitives/canvas/icons/send.svg +1 -0
  136. package/src/primitives/canvas/icons/settings.svg +1 -0
  137. package/src/primitives/canvas/icons/shuffle.svg +1 -0
  138. package/src/primitives/canvas/icons/skip-back.svg +1 -0
  139. package/src/primitives/canvas/icons/skip-forward.svg +1 -0
  140. package/src/primitives/canvas/icons/sun.svg +1 -0
  141. package/src/primitives/canvas/icons/terminal.svg +1 -0
  142. package/src/primitives/canvas/icons/trash.svg +1 -0
  143. package/src/primitives/canvas/icons/volume.svg +1 -0
  144. package/src/primitives/canvas/icons/wrench.svg +1 -0
  145. package/src/primitives/canvas/icons/x-circle.svg +1 -0
  146. package/src/primitives/canvas/icons/x.svg +1 -0
  147. package/src/primitives/canvas/icons.zig +249 -0
  148. package/src/primitives/canvas/layout_audit.zig +744 -0
  149. package/src/primitives/canvas/layout_audit_tests.zig +426 -0
  150. package/src/primitives/canvas/markdown.zig +1031 -0
  151. package/src/primitives/canvas/markdown_hostile_tests.zig +471 -0
  152. package/src/primitives/canvas/markdown_tests.zig +538 -0
  153. package/src/primitives/canvas/plan_key_index.zig +120 -0
  154. package/src/primitives/canvas/png.zig +355 -0
  155. package/src/primitives/canvas/reference.zig +1457 -0
  156. package/src/primitives/canvas/reference_blur.zig +104 -0
  157. package/src/primitives/canvas/reference_memo.zig +322 -0
  158. package/src/primitives/canvas/reference_paths.zig +184 -0
  159. package/src/primitives/canvas/reference_tests.zig +1650 -0
  160. package/src/primitives/canvas/render.zig +747 -0
  161. package/src/primitives/canvas/render_effects.zig +255 -0
  162. package/src/primitives/canvas/render_fingerprints.zig +256 -0
  163. package/src/primitives/canvas/render_generic_resources.zig +376 -0
  164. package/src/primitives/canvas/render_images.zig +247 -0
  165. package/src/primitives/canvas/render_layers.zig +260 -0
  166. package/src/primitives/canvas/render_paths.zig +347 -0
  167. package/src/primitives/canvas/render_resources.zig +51 -0
  168. package/src/primitives/canvas/render_tests.zig +3186 -0
  169. package/src/primitives/canvas/root.zig +744 -0
  170. package/src/primitives/canvas/serialization.zig +1528 -0
  171. package/src/primitives/canvas/svg_icon.zig +636 -0
  172. package/src/primitives/canvas/svg_icon_tests.zig +312 -0
  173. package/src/primitives/canvas/test_support.zig +422 -0
  174. package/src/primitives/canvas/testdata/markdown_document.md +83 -0
  175. package/src/primitives/canvas/tests.zig +30 -0
  176. package/src/primitives/canvas/text.zig +82 -0
  177. package/src/primitives/canvas/text_atlas.zig +408 -0
  178. package/src/primitives/canvas/text_batch_tests.zig +431 -0
  179. package/src/primitives/canvas/text_interaction.zig +615 -0
  180. package/src/primitives/canvas/text_layout.zig +1069 -0
  181. package/src/primitives/canvas/text_layout_cache.zig +281 -0
  182. package/src/primitives/canvas/text_layout_hash.zig +113 -0
  183. package/src/primitives/canvas/text_layout_types.zig +128 -0
  184. package/src/primitives/canvas/text_measure_cache.zig +279 -0
  185. package/src/primitives/canvas/text_metrics.zig +309 -0
  186. package/src/primitives/canvas/text_metrics_tests.zig +262 -0
  187. package/src/primitives/canvas/text_span_tests.zig +608 -0
  188. package/src/primitives/canvas/text_spans.zig +1010 -0
  189. package/src/primitives/canvas/text_tests.zig +1949 -0
  190. package/src/primitives/canvas/themes/geist.zig +470 -0
  191. package/src/primitives/canvas/tokens.zig +1522 -0
  192. package/src/primitives/canvas/ui.zig +2686 -0
  193. package/src/primitives/canvas/ui_markup.zig +3791 -0
  194. package/src/primitives/canvas/ui_markup_binary.zig +522 -0
  195. package/src/primitives/canvas/ui_markup_binary_tests.zig +591 -0
  196. package/src/primitives/canvas/ui_markup_compiled.zig +2565 -0
  197. package/src/primitives/canvas/ui_markup_compiled_tests.zig +1669 -0
  198. package/src/primitives/canvas/ui_markup_contract.zig +1620 -0
  199. package/src/primitives/canvas/ui_markup_contract_tests.zig +953 -0
  200. package/src/primitives/canvas/ui_markup_edit.zig +416 -0
  201. package/src/primitives/canvas/ui_markup_edit_tests.zig +341 -0
  202. package/src/primitives/canvas/ui_markup_expr.zig +1152 -0
  203. package/src/primitives/canvas/ui_markup_expr_tests.zig +779 -0
  204. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +505 -0
  205. package/src/primitives/canvas/ui_markup_reflect.zig +127 -0
  206. package/src/primitives/canvas/ui_markup_tests.zig +1545 -0
  207. package/src/primitives/canvas/ui_markup_view.zig +2352 -0
  208. package/src/primitives/canvas/ui_markup_view_tests.zig +3709 -0
  209. package/src/primitives/canvas/ui_provenance.zig +96 -0
  210. package/src/primitives/canvas/ui_provenance_tests.zig +186 -0
  211. package/src/primitives/canvas/ui_schema.zig +825 -0
  212. package/src/primitives/canvas/ui_schema_tests.zig +128 -0
  213. package/src/primitives/canvas/ui_tests.zig +1432 -0
  214. package/src/primitives/canvas/vector.zig +919 -0
  215. package/src/primitives/canvas/vector_tests.zig +547 -0
  216. package/src/primitives/canvas/virtual_extent_tests.zig +317 -0
  217. package/src/primitives/canvas/virtual_extents.zig +540 -0
  218. package/src/primitives/canvas/widget_access.zig +208 -0
  219. package/src/primitives/canvas/widget_anchored_tests.zig +264 -0
  220. package/src/primitives/canvas/widget_builtin_tests.zig +3160 -0
  221. package/src/primitives/canvas/widget_invalidation.zig +748 -0
  222. package/src/primitives/canvas/widget_layout.zig +2055 -0
  223. package/src/primitives/canvas/widget_layout_tests.zig +2691 -0
  224. package/src/primitives/canvas/widget_metrics.zig +228 -0
  225. package/src/primitives/canvas/widget_render.zig +2534 -0
  226. package/src/primitives/canvas/widget_render_controls.zig +1563 -0
  227. package/src/primitives/canvas/widget_render_scroll.zig +136 -0
  228. package/src/primitives/canvas/widget_render_style.zig +626 -0
  229. package/src/primitives/canvas/widget_render_surfaces.zig +794 -0
  230. package/src/primitives/canvas/widget_routing.zig +475 -0
  231. package/src/primitives/canvas/widget_runtime.zig +307 -0
  232. package/src/primitives/canvas/widget_runtime_tests.zig +3015 -0
  233. package/src/primitives/canvas/widget_semantics.zig +480 -0
  234. package/src/primitives/canvas/widget_semantics_tests.zig +2129 -0
  235. package/src/primitives/canvas/widget_tests.zig +8 -0
  236. package/src/primitives/canvas/widget_text_input.zig +351 -0
  237. package/src/primitives/canvas/widget_text_select.zig +147 -0
  238. package/src/primitives/canvas/widget_tree.zig +232 -0
  239. package/src/primitives/canvas/widgets.zig +1319 -0
  240. package/src/primitives/diagnostics/root.zig +445 -0
  241. package/src/primitives/geometry/root.zig +889 -0
  242. package/src/primitives/json/root.zig +272 -0
  243. package/src/primitives/platform_info/root.zig +450 -0
  244. package/src/primitives/trace/root.zig +569 -0
  245. package/src/root.zig +165 -0
  246. package/src/runtime/api.zig +431 -0
  247. package/src/runtime/async_bridge.zig +49 -0
  248. package/src/runtime/automation_commands.zig +686 -0
  249. package/src/runtime/automation_liveness_tests.zig +140 -0
  250. package/src/runtime/automation_snapshot.zig +246 -0
  251. package/src/runtime/automation_widget_dispatch.zig +617 -0
  252. package/src/runtime/bridge_dispatch_tests.zig +202 -0
  253. package/src/runtime/bridge_payload.zig +194 -0
  254. package/src/runtime/bridge_permission_tests.zig +551 -0
  255. package/src/runtime/bridge_responses.zig +414 -0
  256. package/src/runtime/builtin_bridge.zig +554 -0
  257. package/src/runtime/canvas_budget_edge_tests.zig +415 -0
  258. package/src/runtime/canvas_font_tests.zig +410 -0
  259. package/src/runtime/canvas_fonts.zig +229 -0
  260. package/src/runtime/canvas_frame.zig +1734 -0
  261. package/src/runtime/canvas_frame_animation_tests.zig +609 -0
  262. package/src/runtime/canvas_frame_cache_tests.zig +333 -0
  263. package/src/runtime/canvas_frame_helpers.zig +414 -0
  264. package/src/runtime/canvas_frame_invalidation_tests.zig +544 -0
  265. package/src/runtime/canvas_frame_packet_tests.zig +1353 -0
  266. package/src/runtime/canvas_frame_patch_tests.zig +1051 -0
  267. package/src/runtime/canvas_frame_retained_tests.zig +753 -0
  268. package/src/runtime/canvas_frame_tests.zig +9 -0
  269. package/src/runtime/canvas_frame_text_layout_budget_tests.zig +149 -0
  270. package/src/runtime/canvas_image_tests.zig +362 -0
  271. package/src/runtime/canvas_images.zig +224 -0
  272. package/src/runtime/canvas_limits.zig +317 -0
  273. package/src/runtime/canvas_screenshot_tests.zig +289 -0
  274. package/src/runtime/canvas_widget_accessibility_tests.zig +1494 -0
  275. package/src/runtime/canvas_widget_anchored_tests.zig +678 -0
  276. package/src/runtime/canvas_widget_chart_tests.zig +249 -0
  277. package/src/runtime/canvas_widget_clipboard_tests.zig +399 -0
  278. package/src/runtime/canvas_widget_context_menu.zig +318 -0
  279. package/src/runtime/canvas_widget_context_menu_tests.zig +462 -0
  280. package/src/runtime/canvas_widget_control_tests.zig +2164 -0
  281. package/src/runtime/canvas_widget_disclosure_tests.zig +440 -0
  282. package/src/runtime/canvas_widget_display.zig +677 -0
  283. package/src/runtime/canvas_widget_event_tests.zig +1779 -0
  284. package/src/runtime/canvas_widget_events.zig +1098 -0
  285. package/src/runtime/canvas_widget_floating_tests.zig +695 -0
  286. package/src/runtime/canvas_widget_layout_tests.zig +26 -0
  287. package/src/runtime/canvas_widget_runtime.zig +1335 -0
  288. package/src/runtime/canvas_widget_scroll_driver_tests.zig +582 -0
  289. package/src/runtime/canvas_widget_scroll_drivers.zig +202 -0
  290. package/src/runtime/canvas_widget_scroll_tests.zig +1549 -0
  291. package/src/runtime/canvas_widget_semantics_tests.zig +810 -0
  292. package/src/runtime/canvas_widget_split_tree_tests.zig +1031 -0
  293. package/src/runtime/canvas_widget_state.zig +798 -0
  294. package/src/runtime/canvas_widget_text_tests.zig +2104 -0
  295. package/src/runtime/canvas_widget_window_drag_tests.zig +284 -0
  296. package/src/runtime/clock.zig +231 -0
  297. package/src/runtime/core.zig +927 -0
  298. package/src/runtime/effects.zig +4197 -0
  299. package/src/runtime/effects_audio_tests.zig +690 -0
  300. package/src/runtime/effects_clipboard_tests.zig +317 -0
  301. package/src/runtime/effects_fetch_tests.zig +1031 -0
  302. package/src/runtime/effects_file_tests.zig +407 -0
  303. package/src/runtime/effects_tests.zig +1251 -0
  304. package/src/runtime/flow.zig +1175 -0
  305. package/src/runtime/frame_profile.zig +221 -0
  306. package/src/runtime/gpu_surface_events.zig +639 -0
  307. package/src/runtime/launch_timing.zig +59 -0
  308. package/src/runtime/markdown_app_tests.zig +224 -0
  309. package/src/runtime/native_command_event_tests.zig +431 -0
  310. package/src/runtime/platform_bridge_tests.zig +8 -0
  311. package/src/runtime/platform_config_tests.zig +392 -0
  312. package/src/runtime/root.zig +150 -0
  313. package/src/runtime/runtime_event_tests.zig +1079 -0
  314. package/src/runtime/session_journal.zig +1522 -0
  315. package/src/runtime/session_record.zig +332 -0
  316. package/src/runtime/session_replay.zig +274 -0
  317. package/src/runtime/session_state.zig +30 -0
  318. package/src/runtime/session_tests.zig +399 -0
  319. package/src/runtime/shell_layout.zig +472 -0
  320. package/src/runtime/shell_layout_tests.zig +1246 -0
  321. package/src/runtime/shell_view_tests.zig +604 -0
  322. package/src/runtime/state.zig +110 -0
  323. package/src/runtime/system_services.zig +392 -0
  324. package/src/runtime/test_support.zig +79 -0
  325. package/src/runtime/tests.zig +30 -0
  326. package/src/runtime/ui_app.zig +3290 -0
  327. package/src/runtime/ui_app_huge_model_tests.zig +351 -0
  328. package/src/runtime/ui_app_provenance.zig +370 -0
  329. package/src/runtime/ui_app_tests.zig +3254 -0
  330. package/src/runtime/ui_app_virtual_variable_tests.zig +485 -0
  331. package/src/runtime/ui_app_window_tests.zig +442 -0
  332. package/src/runtime/validation.zig +206 -0
  333. package/src/runtime/view.zig +908 -0
  334. package/src/runtime/view_canvas.zig +850 -0
  335. package/src/runtime/view_widget_control.zig +433 -0
  336. package/src/runtime/view_widget_scroll.zig +360 -0
  337. package/src/runtime/view_widget_text.zig +275 -0
  338. package/src/runtime/view_widget_tree.zig +843 -0
  339. package/src/runtime/webview_view_bridge_tests.zig +664 -0
  340. package/src/runtime/widget_bridge.zig +231 -0
  341. package/src/runtime/window_command_bridge_tests.zig +403 -0
  342. package/src/runtime/window_storage.zig +255 -0
  343. package/src/runtime/window_view_runtime.zig +727 -0
  344. package/src/runtime/window_views.zig +334 -0
  345. package/src/security/root.zig +118 -0
  346. package/src/tooling/android.zig +1172 -0
  347. package/src/tooling/assets.zig +128 -0
  348. package/src/tooling/buildgraph.zig +379 -0
  349. package/src/tooling/cef.zig +671 -0
  350. package/src/tooling/codesign.zig +172 -0
  351. package/src/tooling/components/identity_tests.zig +185 -0
  352. package/src/tooling/components/stepper.zig +113 -0
  353. package/src/tooling/components/timeline.native +27 -0
  354. package/src/tooling/components/timeline_item.zig +131 -0
  355. package/src/tooling/default_icon.icns +0 -0
  356. package/src/tooling/default_icon.png +0 -0
  357. package/src/tooling/dev.zig +172 -0
  358. package/src/tooling/doctor.zig +349 -0
  359. package/src/tooling/eject_components.zig +170 -0
  360. package/src/tooling/embedlib.zig +290 -0
  361. package/src/tooling/ios.zig +528 -0
  362. package/src/tooling/manifest.zig +1939 -0
  363. package/src/tooling/package.zig +2388 -0
  364. package/src/tooling/process_tree.zig +114 -0
  365. package/src/tooling/raw_manifest.zig +193 -0
  366. package/src/tooling/root.zig +22 -0
  367. package/src/tooling/templates.zig +3191 -0
  368. package/src/tooling/toolchain.zig +371 -0
  369. package/src/tooling/verbs.zig +204 -0
  370. package/src/tooling/web_engine.zig +135 -0
  371. package/src/tooling/xcodeproj.zig +462 -0
  372. package/src/window_state/root.zig +507 -0
  373. package/index.js +0 -2
@@ -0,0 +1,798 @@
1
+ const std = @import("std");
2
+ const geometry = @import("geometry");
3
+ const canvas = @import("canvas");
4
+ const platform = @import("../platform/root.zig");
5
+ const validation = @import("validation.zig");
6
+ const runtime_api = @import("api.zig");
7
+ const canvas_limits = @import("canvas_limits.zig");
8
+ const canvas_frame_helpers = @import("canvas_frame.zig");
9
+ const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
10
+ const runtime_canvas_widget_scroll_drivers = @import("canvas_widget_scroll_drivers.zig");
11
+ const launch_timing = @import("launch_timing.zig");
12
+ const runtime_canvas_widget_display = @import("canvas_widget_display.zig");
13
+ const runtime_view = @import("view.zig");
14
+ const runtime_canvas_widget_events = @import("canvas_widget_events.zig");
15
+ const runtime_automation_widget_dispatch = @import("automation_widget_dispatch.zig");
16
+ const widget_bridge = @import("widget_bridge.zig");
17
+
18
+ const validateViewLabel = validation.validateViewLabel;
19
+ const max_canvas_widget_nodes_per_view = canvas_limits.max_canvas_widget_nodes_per_view;
20
+ const max_canvas_widget_semantics_per_view = canvas_limits.max_canvas_widget_semantics_per_view;
21
+ const max_canvas_widget_text_bytes_per_view = canvas_limits.max_canvas_widget_text_bytes_per_view;
22
+ const max_canvas_widget_invalidations_per_view = canvas_limits.max_canvas_widget_invalidations_per_view;
23
+ const CanvasWidgetControlReconcileEntry = canvas_widget_runtime.CanvasWidgetControlReconcileEntry;
24
+ const CanvasWidgetTextReconcileEntry = canvas_widget_runtime.CanvasWidgetTextReconcileEntry;
25
+ const canvasWidgetLayoutTreeWithRuntimeReconcileState = canvas_widget_runtime.canvasWidgetLayoutTreeWithRuntimeReconcileState;
26
+ const canvasWidgetEditableTextKind = canvas_widget_runtime.canvasWidgetEditableTextKind;
27
+ const canvasWidgetAccessibilityActionSupported = widget_bridge.canvasWidgetAccessibilityActionSupported;
28
+ const canvasWidgetBooleanSelected = canvas_widget_runtime.canvasWidgetBooleanSelected;
29
+
30
+ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
31
+ return struct {
32
+ pub fn setCanvasWidgetLayout(self: *Runtime, window_id: platform.WindowId, label: []const u8, layout: canvas.WidgetLayoutTree) anyerror!platform.ViewInfo {
33
+ try validateRuntimeViewParent(self, window_id);
34
+ try validateViewLabel(label);
35
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
36
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
37
+ if (layout.nodes.len > max_canvas_widget_nodes_per_view) return error.WidgetNodeLimitReached;
38
+
39
+ // Frame-profile `reconcile` stage: reconcile + diff + state
40
+ // copies, ending BEFORE the display-list refresh below so the
41
+ // `emit` stage (stamped at its own choke point) is never
42
+ // double-counted. No-op unless profiling is on.
43
+ const reconcile_begin = self.frame_profile.begin();
44
+ // Launch lap (env-gated, once per process): the startup
45
+ // frame's reconcile begins here, splitting view build from
46
+ // reconcile+emit inside the built -> emitted window.
47
+ launch_timing.lapOnce("first_reconcile_begin");
48
+
49
+ // Source-driven autofocus resolves against the PREVIOUS
50
+ // rebuild's flags (edge-triggered) before any state is
51
+ // replaced; the focus applies after the new tree lands.
52
+ const autofocus_target = self.views[index].canvasWidgetAutofocusTarget(layout);
53
+ const previous_layout = self.views[index].widgetLayoutTree();
54
+ const source_semantics = try layout.collectSemantics(&self.canvas_widget_source_semantics_scratch);
55
+ const reconciled_nodes = &self.canvas_widget_reconcile_nodes;
56
+ const tokens = self.views[index].widget_tokens;
57
+ // Reconcile scratch lives on the Runtime, not the stack: at
58
+ // the 1024-node budget these arrays total several hundred
59
+ // KiB, and the single-threaded event loop makes the shared
60
+ // buffers safe.
61
+ // Armed split-tween ids (plus the pressed split, if any):
62
+ // the reconcile's split restore uses these to pick the
63
+ // slide shape — keep the source's target-fraction child
64
+ // layout and move the boundary geometrically — over the
65
+ // re-lay shape a settled fraction (or a live drag) takes.
66
+ var armed_tween_ids: [canvas_limits.max_canvas_widget_layout_tweens_per_view]canvas.ObjectId = undefined;
67
+ const armed_tween_count = self.views[index].canvas_widget_layout_tween_count;
68
+ for (self.views[index].canvas_widget_layout_tweens[0..armed_tween_count], 0..) |tween, tween_index| {
69
+ armed_tween_ids[tween_index] = tween.spec.id;
70
+ }
71
+ const reconciled_layout = try canvasWidgetLayoutTreeWithRuntimeReconcileState(
72
+ previous_layout,
73
+ layout,
74
+ source_semantics,
75
+ self.views[index].widgetSourceTextEntries(),
76
+ self.views[index].widgetSourceScrollEntries(),
77
+ self.views[index].widgetSourceControlEntries(),
78
+ reconciled_nodes,
79
+ &self.canvas_widget_reconcile_control_entries,
80
+ &self.canvas_widget_reconcile_scroll_entries,
81
+ &self.canvas_widget_reconcile_text_entries,
82
+ &self.canvas_widget_reconcile_text_bytes,
83
+ tokens,
84
+ armed_tween_ids[0..armed_tween_count],
85
+ canvasWidgetPressedSplitId(self, index),
86
+ );
87
+ // Native scroll drivers: mark natively driven scroll
88
+ // regions before the copy so rebuild-time clamping and display
89
+ // emission both see the flag (engine scrollbar + engine clamp
90
+ // stand down; the OS scroller owns them).
91
+ ScrollDriverMethods(Runtime).stampCanvasWidgetNativeScroll(self, reconciled_nodes[0..reconciled_layout.nodes.len]);
92
+ // Engine-side rebuild clamp AFTER the stamp: natively driven
93
+ // regions skip it, so a rebuild landing mid-rubber-band keeps
94
+ // the OS scroller's overscrolled offset instead of clamping it
95
+ // and force-pushing the clamp into the live bounce (visible
96
+ // jitter). Non-driver platforms clamp exactly as before.
97
+ canvas_widget_runtime.clampCanvasWidgetLayoutScrollOffsets(reconciled_nodes[0..reconciled_layout.nodes.len], null);
98
+ const invalidations = try canvas.WidgetLayoutTree.diffWithTokens(previous_layout, reconciled_layout, tokens, &self.canvas_widget_invalidations_scratch);
99
+ const previous_render_state = self.views[index].canvasWidgetRenderState();
100
+ const next_render_state = CanvasWidgetEventMethods(Runtime).canvasWidgetRenderStateAfterLayout(previous_render_state, reconciled_layout);
101
+ const render_state_changed = !CanvasWidgetEventMethods(Runtime).canvasWidgetRenderStatesEqual(previous_render_state, next_render_state);
102
+ const render_state_dirty = if (render_state_changed)
103
+ previous_layout.renderStateDirtyBoundsWithTokens(previous_render_state, next_render_state, tokens)
104
+ else
105
+ null;
106
+ // Disclosure tween planning reads BOTH poses — the retained
107
+ // tree the user is looking at and the reconciled tree this
108
+ // rebuild declared — so it runs before the copy below
109
+ // replaces the former. The plan applies after the copy,
110
+ // where it can restore the previous pose onto the freshly
111
+ // retained nodes.
112
+ const disclosure_plan = planCanvasWidgetDisclosureTween(self, index, previous_layout, reconciled_layout);
113
+ const previous_cursor = self.views[index].canvas_widget_cursor;
114
+ const previous_widget_revision = self.views[index].widget_revision;
115
+ try self.views[index].copyWidgetLayoutTree(reconciled_layout, &self.canvas_widget_copy_scratch);
116
+ try self.views[index].copyCanvasWidgetSourceText(layout);
117
+ self.views[index].copyCanvasWidgetSourceScroll(layout);
118
+ self.views[index].copyCanvasWidgetSourceControls(layout);
119
+ // Push the reconciled regions (frames, content extents,
120
+ // diverged offsets) to the native scroll drivers.
121
+ ScrollDriverMethods(Runtime).syncCanvasWidgetScrollDriversForView(self, index);
122
+ // Mirror the window-drag regions to hit-testing platforms
123
+ // (Windows WM_NCHITTEST); no-op wherever the service is
124
+ // absent, and pushes only on actual change.
125
+ try CanvasWidgetEventMethods(Runtime).syncCanvasWidgetWindowDragRegionsForView(self, index);
126
+ const widget_revision_changed = self.views[index].widget_revision != previous_widget_revision;
127
+ if (previous_cursor != self.views[index].canvas_widget_cursor) try CanvasWidgetEventMethods(Runtime).syncCanvasWidgetCursorForView(self, index);
128
+ CanvasWidgetEventMethods(Runtime).invalidateForWidgetInvalidations(self, self.views[index].frame, invalidations);
129
+ if (render_state_changed) CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetRenderStateDirty(self, index, render_state_dirty);
130
+ const layout_dirty = invalidations.len > 0 or render_state_changed;
131
+ if (autofocus_target) |autofocus_id| {
132
+ // The same focus write every other focus source performs
133
+ // (view focus + focused/visible ids + invalidation);
134
+ // widgets that are not focusable ignore the request.
135
+ if (self.views[index].widgetLayoutTree().focusTargetById(autofocus_id) != null) {
136
+ try AutomationWidgetMethods(Runtime).focusAutomationCanvasWidget(self, index, autofocus_id);
137
+ }
138
+ }
139
+ self.frame_profile.end(.reconcile, reconcile_begin);
140
+ // Source-declared layout tweens, AFTER the reconciled tree is
141
+ // retained (the arm reads the kept fraction as its `from`)
142
+ // and BEFORE the display refresh (a reduced-motion snap must
143
+ // paint in this rebuild's frame, not the next one). Both
144
+ // markup engines and the Zig builder lower `resize-duration`
145
+ // into the same widget fields, so this one walk is the whole
146
+ // consumer.
147
+ try armSourceDeclaredLayoutTweens(self, index, layout);
148
+ // Disclosure tween application, still BEFORE the display
149
+ // refresh: an armed reveal restores the previous pose onto
150
+ // the retained frames so THIS rebuild keeps painting what
151
+ // the user was looking at, and the tween walks it to the
152
+ // declared pose one presented frame at a time.
153
+ try applyCanvasWidgetDisclosureTweenPlan(self, index, disclosure_plan);
154
+ const requested_frame = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
155
+ if ((layout_dirty or widget_revision_changed) and !requested_frame) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
156
+ return self.views[index].info();
157
+ }
158
+
159
+ pub fn canvasWidgetLayout(self: *const Runtime, window_id: platform.WindowId, label: []const u8) anyerror!canvas.WidgetLayoutTree {
160
+ try validateRuntimeViewParent(self, window_id);
161
+ try validateViewLabel(label);
162
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
163
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
164
+ return self.views[index].widgetLayoutTree();
165
+ }
166
+
167
+ pub fn canvasWidgetSemantics(self: *const Runtime, window_id: platform.WindowId, label: []const u8) anyerror![]const canvas.WidgetSemanticsNode {
168
+ try validateRuntimeViewParent(self, window_id);
169
+ try validateViewLabel(label);
170
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
171
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
172
+ return self.views[index].widgetSemantics();
173
+ }
174
+
175
+ pub fn dispatchCanvasWidgetAccessibilityAction(
176
+ self: *Runtime,
177
+ app: runtime_api.App(Runtime),
178
+ window_id: platform.WindowId,
179
+ label: []const u8,
180
+ action: runtime_api.CanvasWidgetAccessibilityAction,
181
+ ) anyerror!platform.ViewInfo {
182
+ try validateRuntimeViewParent(self, window_id);
183
+ try validateViewLabel(label);
184
+ if (action.id == 0) return error.InvalidCommand;
185
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
186
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
187
+ const actions = AutomationWidgetMethods(Runtime).canvasWidgetActionsForId(self, index, action.id) orelse return error.InvalidCommand;
188
+ if (!canvasWidgetAccessibilityActionSupported(actions, action.action)) return error.InvalidCommand;
189
+
190
+ // Every assistive action rides the SAME machinery the
191
+ // automation widget verbs use — the key-driven activation for
192
+ // press/toggle/increment/decrement (quiet-list-row ring
193
+ // escalation included), the text editor for set_text and the
194
+ // composition family, the selection/dismiss verbs for the
195
+ // rest. An earlier "direct" shortcut here applied semantic
196
+ // control intents to the retained tree instead: it flipped
197
+ // echoes (toggle state, slider value) and dispatched only the
198
+ // widget's `command` string, so a widget wired through message
199
+ // handlers (an `on_press` tab, an `on_toggle` checkbox) kept
200
+ // reporting success while the app's model never heard the
201
+ // action — an advertised action an assistive-technology user
202
+ // could not actually invoke. The key-driven route reaches the
203
+ // same typed dispatch a real keyboard user's activation does,
204
+ // so anything a keyboard can actuate, an AX client can too.
205
+ switch (action.action) {
206
+ .focus => try AutomationWidgetMethods(Runtime).focusAutomationCanvasWidget(self, index, action.id),
207
+ .press => try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, "enter"),
208
+ .toggle => try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, "space"),
209
+ .increment => try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, self.views[index].canvasWidgetStepKey(action.id, .increment)),
210
+ .decrement => try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, self.views[index].canvasWidgetStepKey(action.id, .decrement)),
211
+ .set_text => try AutomationWidgetMethods(Runtime).setAutomationCanvasWidgetText(self, app, index, action.id, action.text),
212
+ .set_selection => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .{ .set_selection = action.selection orelse return error.InvalidCommand }),
213
+ .set_composition => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .{ .set_composition = .{ .text = action.text } }),
214
+ .commit_composition => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .commit_composition),
215
+ .cancel_composition => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .cancel_composition),
216
+ .select => try AutomationWidgetMethods(Runtime).selectAutomationCanvasWidget(self, index, action.id),
217
+ .drag => try AutomationWidgetMethods(Runtime).dispatchAutomationCanvasWidgetDrag(self, app, index, action.id, action.text),
218
+ .drop_files => try AutomationWidgetMethods(Runtime).dispatchAutomationCanvasWidgetFileDrop(self, app, index, action.id, action.text),
219
+ .dismiss => try AutomationWidgetMethods(Runtime).dismissAutomationCanvasWidget(self, app, index, action.id),
220
+ }
221
+ // Key-driven action routes above dispatch real input events
222
+ // whose refresh batches defer the platform publish; the AX
223
+ // client reads the tree next, so force-flush here too.
224
+ try CanvasWidgetDisplayMethods(Runtime).flushDeferredCanvasWidgetAccessibility(self);
225
+ return self.views[index].info();
226
+ }
227
+
228
+ pub fn stepCanvasWidgetKineticScroll(self: *Runtime, window_id: platform.WindowId, label: []const u8, dt_ms: f32) anyerror!platform.ViewInfo {
229
+ try validateRuntimeViewParent(self, window_id);
230
+ try validateViewLabel(label);
231
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
232
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
233
+
234
+ const dirty = try self.views[index].stepCanvasWidgetKineticScroll(dt_ms) orelse return self.views[index].info();
235
+ const previous_cursor = self.views[index].canvas_widget_cursor;
236
+ self.views[index].reconcileCanvasWidgetRenderStateAfterScroll(null);
237
+ if (previous_cursor != self.views[index].canvas_widget_cursor) try CanvasWidgetEventMethods(Runtime).syncCanvasWidgetCursorForView(self, index);
238
+ try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, index, dirty);
239
+ _ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
240
+ return self.views[index].info();
241
+ }
242
+
243
+ /// Arm (or retarget) a runtime-driven layout tween: the split's
244
+ /// first-pane fraction eases from its CURRENT retained value to
245
+ /// `tween.to` over `tween.duration_ms`, one step per presented
246
+ /// frame, sampled from the frame event's recorded timestamp —
247
+ /// so a recorded session replays to identical frames and idle
248
+ /// apps present nothing (the tween itself keeps the frame
249
+ /// channel armed only while it runs).
250
+ ///
251
+ /// Contract, in declaration order:
252
+ /// - id 0 or a non-split id is a teaching error;
253
+ /// - already at the target (and nothing armed): no-op;
254
+ /// - reduce-motion appearance or duration 0: SNAP through the
255
+ /// same mutation path a divider drag uses (dirty region,
256
+ /// resize event, reconcile survival), never animate;
257
+ /// - re-declared with the same target while armed: no-op —
258
+ /// the per-rebuild declarative hook calls this every
259
+ /// rebuild and must not restart the clock;
260
+ /// - re-declared with a NEW target while armed: retarget from
261
+ /// the current animated value, fresh clock;
262
+ /// - every tween slot taken: snap (motion degrades under
263
+ /// pressure; the state change always lands).
264
+ ///
265
+ /// Resize echoes: arming (or retargeting) notes ONE resize
266
+ /// event carrying the DESTINATION, and the settle step notes
267
+ /// one with the applied fraction — never one per step. The arm
268
+ /// echo is what lets a controlled split's model rebuild at the
269
+ /// target ONCE, so the reconcile keeps the target-wrapped
270
+ /// content and the tween slides it under the pane clip with
271
+ /// zero mid-flight re-wraps (the disclosure doctrine,
272
+ /// horizontal). A divider DRAG keeps its per-step echoes: a
273
+ /// drag tracks the pointer and must re-wrap live.
274
+ pub fn startCanvasWidgetLayoutTween(self: *Runtime, window_id: platform.WindowId, label: []const u8, tween: canvas.CanvasWidgetLayoutTween) anyerror!platform.ViewInfo {
275
+ try validateRuntimeViewParent(self, window_id);
276
+ try validateViewLabel(label);
277
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
278
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
279
+ try startCanvasWidgetLayoutTweenForView(self, index, tween, true);
280
+ return self.views[index].info();
281
+ }
282
+
283
+ /// The tween contract's core, shared by the public command above
284
+ /// and the source-declared lowering in `setCanvasWidgetLayout`
285
+ /// (a split whose SOURCE declares `resize_duration_ms` arms the
286
+ /// same tween the Zig hook would, so both authoring surfaces
287
+ /// step identical fractions on identical frame clocks).
288
+ /// `announce` notes the destination resize event on a fresh arm
289
+ /// or retarget — true for the command/hook path (the app's
290
+ /// model has not seen the target yet and needs one rebuild at
291
+ /// it), false for the source-declared path (the source that
292
+ /// armed this tween IS the target declaration; echoing it back
293
+ /// would be a redundant rebuild).
294
+ fn startCanvasWidgetLayoutTweenForView(self: *Runtime, index: usize, tween: canvas.CanvasWidgetLayoutTween, announce: bool) anyerror!void {
295
+ if (tween.id == 0) return error.InvalidCommand;
296
+ if (!std.math.isFinite(tween.to)) return error.InvalidCommand;
297
+ const node_index = self.views[index].canvasWidgetNodeIndexById(tween.id) orelse return error.InvalidCommand;
298
+ if (self.views[index].widget_layout_nodes[node_index].widget.kind != .split) return error.InvalidCommand;
299
+ const current = self.views[index].widget_layout_nodes[node_index].widget.value;
300
+
301
+ const snap = self.appearance.reduce_motion or tween.duration_ms == 0;
302
+ if (self.views[index].findCanvasWidgetLayoutTween(tween.id)) |active| {
303
+ if (snap) {
304
+ // Reduce motion arrived (or the declaration turned
305
+ // instant) while armed: retire the tween and land
306
+ // on the target through the snap path below.
307
+ self.views[index].removeCanvasWidgetLayoutTween(tween.id);
308
+ } else {
309
+ if (active.spec.to == tween.to) return;
310
+ active.spec = tween;
311
+ active.from = current;
312
+ active.start_ns = 0;
313
+ if (announce) self.views[index].noteCanvasWidgetResizeEvent(tween.id);
314
+ try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
315
+ return;
316
+ }
317
+ }
318
+ if (current == tween.to) return;
319
+
320
+ if (!snap and self.views[index].armCanvasWidgetLayoutTween(.{ .spec = tween, .from = current })) {
321
+ if (announce) self.views[index].noteCanvasWidgetResizeEvent(tween.id);
322
+ try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
323
+ return;
324
+ }
325
+ if (try self.views[index].applyCanvasWidgetSplitFraction(node_index, tween.to)) |dirty| {
326
+ try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, index, dirty);
327
+ }
328
+ }
329
+
330
+ /// The SOURCE-declared half of the layout tween: a split whose
331
+ /// tree declares a nonzero `resize_duration_ms` treats its
332
+ /// declared `value` as the tween target. Called by
333
+ /// `setCanvasWidgetLayout` after the reconciled tree lands (the
334
+ /// reconcile kept the rendered fraction instead of snapping it
335
+ /// to the moved source), so every rebuild re-declares the tween
336
+ /// exactly like the Zig `layout_tweens` hook does — idempotent
337
+ /// per target, retargeting on a new one, snapping under reduced
338
+ /// motion. Skips:
339
+ /// - value 0: the "unset" sentinel (a bare split lays out at
340
+ /// 0.5); nothing declares a target, so nothing tweens;
341
+ /// - a pressed divider: a live drag owns the fraction — the
342
+ /// tween re-arms on the first rebuild after release.
343
+ fn armSourceDeclaredLayoutTweens(self: *Runtime, index: usize, source: canvas.WidgetLayoutTree) anyerror!void {
344
+ for (source.nodes) |node| {
345
+ if (node.widget.kind != .split or node.widget.id == 0) continue;
346
+ if (node.widget.resize_duration_ms == 0) continue;
347
+ if (node.widget.value == 0) continue;
348
+ if (canvasWidgetSplitDividerPressed(self, index, node.widget.id)) continue;
349
+ startCanvasWidgetLayoutTweenForView(self, index, .{
350
+ .id = node.widget.id,
351
+ .to = node.widget.value,
352
+ .duration_ms = node.widget.resize_duration_ms,
353
+ .easing = node.widget.resize_easing,
354
+ }, false) catch |err| switch (err) {
355
+ // The id vanished in reconcile (hidden pane, dropped
356
+ // subtree): nothing to move — same tolerance as the
357
+ // Zig hook's stale-id skip.
358
+ error.InvalidCommand => continue,
359
+ else => return err,
360
+ };
361
+ }
362
+ }
363
+
364
+ /// Whether the RETAINED tree's pressed widget is this split's
365
+ /// synthesized divider — a live drag. The drag owns the fraction
366
+ /// while it lasts, so the source-declared tween stands down and
367
+ /// re-arms on the first rebuild after release.
368
+ fn canvasWidgetSplitDividerPressed(self: *Runtime, index: usize, split_id: canvas.ObjectId) bool {
369
+ return canvasWidgetPressedSplitId(self, index) == split_id and split_id != 0;
370
+ }
371
+
372
+ /// The split whose synthesized divider the RETAINED tree holds
373
+ /// pressed (0 when no divider is pressed): the reconcile keeps
374
+ /// live re-wrap for exactly this split while a drag lasts.
375
+ fn canvasWidgetPressedSplitId(self: *Runtime, index: usize) canvas.ObjectId {
376
+ const pressed_id = self.views[index].canvas_widget_pressed_id;
377
+ if (pressed_id == 0) return 0;
378
+ const divider_index = self.views[index].canvasWidgetNodeIndexById(pressed_id) orelse return 0;
379
+ const divider = self.views[index].widget_layout_nodes[divider_index];
380
+ if (divider.widget.kind != .split_divider) return 0;
381
+ const parent_index = divider.parent_index orelse return 0;
382
+ if (parent_index >= self.views[index].widget_layout_node_count) return 0;
383
+ return self.views[index].widget_layout_nodes[parent_index].widget.id;
384
+ }
385
+
386
+ /// What `setCanvasWidgetLayout` should do about DISCLOSURE
387
+ /// motion this rebuild, decided by diffing the two poses:
388
+ /// - `arm`: the rebuild flipped at least one disclosure
389
+ /// widget and the reflow is pure vertical — play the diff;
390
+ /// - `refresh`: no flip, but a tween is in flight — re-point
391
+ /// its targets at the new tree and re-apply the mid-flight
392
+ /// pose the copy just stomped;
393
+ /// - `retire`: an in-flight tween can no longer replay (the
394
+ /// node sequence changed, motion got disabled, or the
395
+ /// reflow stopped being disclosure-shaped) — the new pose
396
+ /// stands snapped;
397
+ /// - `none`: nothing armed, nothing to arm.
398
+ const CanvasWidgetDisclosureAction = enum { none, arm, refresh, retire };
399
+
400
+ const CanvasWidgetDisclosurePlan = struct {
401
+ action: CanvasWidgetDisclosureAction = .none,
402
+ duration_ms: u32 = 0,
403
+ revealing_ids: [canvas_limits.max_canvas_widget_disclosure_flips_per_view]canvas.ObjectId = undefined,
404
+ revealing_id_count: usize = 0,
405
+ moves: [canvas_limits.max_canvas_widget_disclosure_moves_per_view]runtime_view.CanvasWidgetDisclosureMove = undefined,
406
+ move_count: usize = 0,
407
+ };
408
+
409
+ /// The planning half of the disclosure tween (see
410
+ /// `CanvasWidgetDisclosureTweenState` for the design): pure
411
+ /// reads over the previous retained pose and the reconciled
412
+ /// next pose, no mutation — the caller applies the plan after
413
+ /// the reconciled tree is retained.
414
+ fn planCanvasWidgetDisclosureTween(self: *Runtime, view_index: usize, previous: canvas.WidgetLayoutTree, next: canvas.WidgetLayoutTree) CanvasWidgetDisclosurePlan {
415
+ var plan = CanvasWidgetDisclosurePlan{};
416
+ const view = &self.views[view_index];
417
+ const was_active = view.canvas_widget_disclosure_tween.active;
418
+ const retire_or_none: CanvasWidgetDisclosureAction = if (was_active) .retire else .none;
419
+
420
+ // The tween replays frame motion BY NODE INDEX, which is
421
+ // only meaningful while both rebuilds describe the same
422
+ // node sequence. A pure disclosure flip preserves it —
423
+ // children lay out open or closed — so a mismatch means
424
+ // this rebuild changed more than disclosure: snap.
425
+ if (previous.nodes.len != next.nodes.len) {
426
+ plan.action = retire_or_none;
427
+ return plan;
428
+ }
429
+ for (previous.nodes, next.nodes) |previous_node, next_node| {
430
+ if (previous_node.widget.kind != next_node.widget.kind or previous_node.widget.id != next_node.widget.id) {
431
+ plan.action = retire_or_none;
432
+ return plan;
433
+ }
434
+ }
435
+
436
+ // Flips: a disclosure widget whose OPEN state changed
437
+ // across the rebuild, or whose toggle the runtime echoed
438
+ // since the last one (the echo already flipped the retained
439
+ // state, so the state comparison alone would miss it).
440
+ var flips_overflowed = false;
441
+ for (next.nodes, 0..) |node, node_index| {
442
+ if (!canvas.widgetKindDisclosureAnimated(node.widget.kind) or node.widget.id == 0) continue;
443
+ const was_open = canvasWidgetBooleanSelected(previous.nodes[node_index].widget);
444
+ const now_open = canvasWidgetBooleanSelected(node.widget);
445
+ if (was_open == now_open and !view.canvasWidgetDisclosureTogglePending(node.widget.id)) continue;
446
+ if (plan.revealing_id_count >= plan.revealing_ids.len) {
447
+ flips_overflowed = true;
448
+ break;
449
+ }
450
+ plan.revealing_ids[plan.revealing_id_count] = node.widget.id;
451
+ plan.revealing_id_count += 1;
452
+ }
453
+ if (flips_overflowed) {
454
+ plan.action = retire_or_none;
455
+ return plan;
456
+ }
457
+ if (plan.revealing_id_count == 0) {
458
+ plan.action = if (was_active) .refresh else .none;
459
+ return plan;
460
+ }
461
+
462
+ // Default-on motion from the register: the `normal` class
463
+ // duration and house easing, no app declaration anywhere.
464
+ // Reduced motion (or a zeroed register) snaps.
465
+ plan.duration_ms = view.widget_tokens.motion.durationMs(.normal);
466
+ if (self.appearance.reduce_motion or plan.duration_ms == 0) {
467
+ plan.action = retire_or_none;
468
+ return plan;
469
+ }
470
+
471
+ // The layout diff this tween will play. Disclosure reflow is
472
+ // vertical by construction; any horizontal delta means the
473
+ // rebuild moved more than disclosure (a resize riding the
474
+ // same dispatch), and a diff too large to record cannot
475
+ // replay honestly — both snap.
476
+ for (previous.nodes, next.nodes, 0..) |previous_node, next_node, node_index| {
477
+ if (previous_node.frame.x != next_node.frame.x or previous_node.frame.width != next_node.frame.width) {
478
+ plan.action = retire_or_none;
479
+ return plan;
480
+ }
481
+ if (previous_node.frame.y == next_node.frame.y and previous_node.frame.height == next_node.frame.height) continue;
482
+ if (plan.move_count >= plan.moves.len) {
483
+ plan.action = retire_or_none;
484
+ return plan;
485
+ }
486
+ plan.moves[plan.move_count] = .{
487
+ .node_index = node_index,
488
+ .from_y = previous_node.frame.y,
489
+ .from_height = previous_node.frame.height,
490
+ .to_y = next_node.frame.y,
491
+ .to_height = next_node.frame.height,
492
+ };
493
+ plan.move_count += 1;
494
+ }
495
+ // A flip that moved nothing (an empty section, or a toggle
496
+ // echo the model ignored) has no motion to play.
497
+ if (plan.move_count == 0) {
498
+ plan.action = if (was_active) .refresh else .none;
499
+ return plan;
500
+ }
501
+ plan.action = .arm;
502
+ return plan;
503
+ }
504
+
505
+ /// The applying half: runs after the reconciled tree is
506
+ /// retained. Arming restores the PREVIOUS pose onto the
507
+ /// retained frames (the user keeps looking at what they were
508
+ /// looking at; the tween walks it to the declared pose on the
509
+ /// frame clock); refreshing re-applies an in-flight pose that
510
+ /// the copy stomped. Toggle-echo notes are consumed here on
511
+ /// every rebuild — applied or ignored, a note never outlives
512
+ /// the rebuild that had the chance to animate it.
513
+ fn applyCanvasWidgetDisclosureTweenPlan(self: *Runtime, view_index: usize, plan: CanvasWidgetDisclosurePlan) anyerror!void {
514
+ const view = &self.views[view_index];
515
+ view.canvas_widget_disclosure_pending_count = 0;
516
+ switch (plan.action) {
517
+ .none => {},
518
+ .retire => view.clearCanvasWidgetDisclosureTween(),
519
+ .refresh => try refreshCanvasWidgetDisclosurePose(self, view_index),
520
+ .arm => {
521
+ view.canvas_widget_disclosure_tween = .{
522
+ .active = true,
523
+ .duration_ms = plan.duration_ms,
524
+ .easing = view.widget_tokens.motion.easing,
525
+ .spring = view.widget_tokens.motion.spring,
526
+ };
527
+ const tween = &view.canvas_widget_disclosure_tween;
528
+ @memcpy(tween.revealing_ids[0..plan.revealing_id_count], plan.revealing_ids[0..plan.revealing_id_count]);
529
+ tween.revealing_id_count = plan.revealing_id_count;
530
+ @memcpy(tween.moves[0..plan.move_count], plan.moves[0..plan.move_count]);
531
+ tween.move_count = plan.move_count;
532
+ for (tween.moves[0..tween.move_count]) |move| {
533
+ if (move.node_index >= view.widget_layout_node_count) continue;
534
+ const node = &view.widget_layout_nodes[move.node_index];
535
+ node.frame.y = move.from_y;
536
+ node.frame.height = move.from_height;
537
+ node.widget.frame = node.frame;
538
+ }
539
+ view.widget_revision += 1;
540
+ try view.refreshCanvasWidgetSemantics();
541
+ try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, view_index);
542
+ },
543
+ }
544
+ }
545
+
546
+ /// A rebuild landed while a disclosure tween is in flight
547
+ /// without flipping anything (the split tween's "same target
548
+ /// re-declared" case): the copy stomped the mid-flight pose
549
+ /// with the target pose, so re-point each move's target at the
550
+ /// fresh tree and re-apply the pose at the last eased progress —
551
+ /// the user never sees the one-frame pop, and the clock keeps
552
+ /// running.
553
+ fn refreshCanvasWidgetDisclosurePose(self: *Runtime, view_index: usize) anyerror!void {
554
+ const view = &self.views[view_index];
555
+ const tween = &view.canvas_widget_disclosure_tween;
556
+ var moved = false;
557
+ for (tween.moves[0..tween.move_count]) |*move| {
558
+ if (move.node_index >= view.widget_layout_node_count) continue;
559
+ const node = &view.widget_layout_nodes[move.node_index];
560
+ move.to_y = node.frame.y;
561
+ move.to_height = node.frame.height;
562
+ const y = move.from_y + (move.to_y - move.from_y) * tween.progress;
563
+ const height = move.from_height + (move.to_height - move.from_height) * tween.progress;
564
+ if (node.frame.y == y and node.frame.height == height) continue;
565
+ node.frame.y = y;
566
+ node.frame.height = height;
567
+ node.widget.frame = node.frame;
568
+ moved = true;
569
+ }
570
+ if (moved) {
571
+ view.widget_revision += 1;
572
+ try view.refreshCanvasWidgetSemantics();
573
+ }
574
+ try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, view_index);
575
+ }
576
+
577
+ /// One presented frame's worth of disclosure motion for a view,
578
+ /// the layout tween advance's sibling: sample the eased progress
579
+ /// at the frame's RECORDED timestamp (replay-deterministic, no
580
+ /// wall clock), walk every recorded move to its interpolated
581
+ /// frame, and land dirty regions through the same widget-dirty
582
+ /// path a drag uses — so mid-tween presents stay region-scoped
583
+ /// patches. The settle frame snaps every move to its exact
584
+ /// target, retires the tween (emptying the revealing set, which
585
+ /// drops a closing item's clipped content from the next
586
+ /// emission), and stops requesting frames.
587
+ pub fn advanceCanvasWidgetDisclosureTweenForFrame(self: *Runtime, view_index: usize, timestamp_ns: u64) anyerror!void {
588
+ if (view_index >= self.view_count) return;
589
+ if (self.views[view_index].kind != .gpu_surface) return;
590
+ const view = &self.views[view_index];
591
+ if (!view.canvas_widget_disclosure_tween.active) return;
592
+ const tween = &view.canvas_widget_disclosure_tween;
593
+
594
+ // First advancing frame stamps the clock — the split
595
+ // tween's discipline, so the ramp runs on the frame clock
596
+ // from the first frame that could have painted it.
597
+ if (tween.start_ns == 0 or timestamp_ns < tween.start_ns) {
598
+ tween.start_ns = timestamp_ns;
599
+ }
600
+ const progress = canvas.layoutTweenProgress(tween.easing, tween.spring, tween.start_ns, tween.duration_ms, timestamp_ns);
601
+ const done = progress >= 1;
602
+ tween.progress = progress;
603
+
604
+ var dirty: ?geometry.RectF = null;
605
+ for (tween.moves[0..tween.move_count]) |move| {
606
+ if (move.node_index >= view.widget_layout_node_count) continue;
607
+ const node = &view.widget_layout_nodes[move.node_index];
608
+ const y = if (done) move.to_y else move.from_y + (move.to_y - move.from_y) * progress;
609
+ const height = if (done) move.to_height else move.from_height + (move.to_height - move.from_height) * progress;
610
+ if (node.frame.y == y and node.frame.height == height) continue;
611
+ dirty = unionDisclosureDirty(dirty, node.frame.normalized());
612
+ node.frame.y = y;
613
+ node.frame.height = height;
614
+ node.widget.frame = node.frame;
615
+ dirty = unionDisclosureDirty(dirty, node.frame.normalized());
616
+ }
617
+ // Retire BEFORE the refresh below so the settle emission
618
+ // paints with an empty revealing set.
619
+ if (done) view.clearCanvasWidgetDisclosureTween();
620
+ if (dirty) |region| {
621
+ view.widget_revision += 1;
622
+ try view.refreshCanvasWidgetSemantics();
623
+ try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, view_index, region);
624
+ } else if (done) {
625
+ // Nothing moved on the settle frame, but the revealing
626
+ // set just emptied — re-emit so closing items drop
627
+ // their clipped content.
628
+ _ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, view_index);
629
+ }
630
+ if (!done) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, view_index);
631
+ }
632
+
633
+ /// One presented frame's worth of layout-tween motion for a
634
+ /// view, called from the frame event dispatch (the kinetic
635
+ /// scroll's sibling). Each active tween samples its eased
636
+ /// fraction at the frame's timestamp and lands it through the
637
+ /// split-drag GEOMETRY (pane frames move, the second pane's
638
+ /// subtree translates, dirty regions ride the retained diff) —
639
+ /// but NOT the drag's per-step resize echo: mid-flight steps
640
+ /// slide content the reconcile already laid out at the tween's
641
+ /// target fraction, cropped by the pane's built-in clip, so a
642
+ /// per-step echo would rebuild and re-wrap the panes every
643
+ /// frame for nothing (the exact cost this doctrine retires).
644
+ /// The settle step snaps to the exact target, notes the ONE
645
+ /// resize echo carrying the applied fraction (the controlled
646
+ /// echo and any structural swap ride it), and retires; while
647
+ /// any tween remains active the next frame is requested, so
648
+ /// the channel disarms itself the frame after the last one
649
+ /// settles.
650
+ pub fn advanceCanvasWidgetLayoutTweensForFrame(self: *Runtime, view_index: usize, timestamp_ns: u64) anyerror!void {
651
+ if (view_index >= self.view_count) return;
652
+ if (self.views[view_index].kind != .gpu_surface) return;
653
+ if (!self.views[view_index].canvasWidgetLayoutTweensActive()) return;
654
+
655
+ var tween_index: usize = 0;
656
+ while (tween_index < self.views[view_index].canvas_widget_layout_tween_count) {
657
+ const tween = &self.views[view_index].canvas_widget_layout_tweens[tween_index];
658
+ // The widget vanished from the tree (the model dropped
659
+ // the split): retire silently, nothing to move.
660
+ const node_index = self.views[view_index].canvasWidgetNodeIndexById(tween.spec.id) orelse {
661
+ self.views[view_index].removeCanvasWidgetLayoutTween(tween.spec.id);
662
+ continue;
663
+ };
664
+ // First advancing frame stamps the clock: the ramp runs
665
+ // on the frame clock from the first frame that could
666
+ // have painted it, the manual idiom's discipline.
667
+ if (tween.start_ns == 0 or timestamp_ns < tween.start_ns) {
668
+ tween.start_ns = timestamp_ns;
669
+ }
670
+ const progress = canvas.layoutTweenProgress(tween.spec.easing, tween.spec.spring, tween.start_ns, tween.spec.duration_ms, timestamp_ns);
671
+ const done = progress >= 1;
672
+ const value = if (done) tween.spec.to else tween.from + (tween.spec.to - tween.from) * progress;
673
+ const dirty = if (done)
674
+ try self.views[view_index].applyCanvasWidgetSplitFraction(node_index, value)
675
+ else
676
+ try self.views[view_index].applyCanvasWidgetSplitFractionSlide(node_index, value);
677
+ if (dirty) |region| {
678
+ try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, view_index, region);
679
+ }
680
+ if (done) {
681
+ // A settle that moved nothing because the last step
682
+ // already sat EXACTLY on the target still owes the
683
+ // app its one settle echo. A settle that moved
684
+ // nothing because the pane-min clamp PARKED the
685
+ // fraction short of the target owes nothing: the
686
+ // model already holds the target it declared, and
687
+ // echoing the parked fraction every settle would
688
+ // rebuild-and-re-arm forever.
689
+ if (dirty == null and self.views[view_index].widget_layout_nodes[node_index].widget.value == tween.spec.to) {
690
+ self.views[view_index].noteCanvasWidgetResizeEvent(tween.spec.id);
691
+ }
692
+ // removeCanvasWidgetLayoutTween swap-removes, so the
693
+ // slot at tween_index now holds an unvisited tween.
694
+ self.views[view_index].removeCanvasWidgetLayoutTween(tween.spec.id);
695
+ continue;
696
+ }
697
+ tween_index += 1;
698
+ }
699
+ if (self.views[view_index].canvasWidgetLayoutTweensActive()) {
700
+ try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, view_index);
701
+ }
702
+ }
703
+
704
+ pub fn setCanvasWidgetDesignTokens(self: *Runtime, window_id: platform.WindowId, label: []const u8, tokens: canvas.DesignTokens) anyerror!platform.ViewInfo {
705
+ try validateRuntimeViewParent(self, window_id);
706
+ try validateViewLabel(label);
707
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
708
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
709
+ if (std.meta.eql(self.views[index].widget_tokens, tokens)) return self.views[index].info();
710
+ self.views[index].widget_tokens = tokens;
711
+ self.views[index].widget_revision += 1;
712
+ if (self.views[index].canvas_display_list_widget_owned) {
713
+ _ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayList(self, index);
714
+ }
715
+ return self.views[index].info();
716
+ }
717
+
718
+ pub fn canvasWidgetDesignTokens(self: *const Runtime, window_id: platform.WindowId, label: []const u8) anyerror!canvas.DesignTokens {
719
+ try validateRuntimeViewParent(self, window_id);
720
+ try validateViewLabel(label);
721
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
722
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
723
+ return self.views[index].widget_tokens;
724
+ }
725
+
726
+ pub fn canvasWidgetTextGeometry(self: *const Runtime, window_id: platform.WindowId, label: []const u8, id: canvas.ObjectId) anyerror!canvas.WidgetTextGeometry {
727
+ try validateRuntimeViewParent(self, window_id);
728
+ try validateViewLabel(label);
729
+ if (id == 0) return error.InvalidCommand;
730
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
731
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
732
+ const node = self.views[index].widgetLayoutTree().findById(id) orelse return error.InvalidCommand;
733
+ if (!canvasWidgetEditableTextKind(node.widget.kind)) return error.InvalidCommand;
734
+ return canvas.textGeometryForWidget(node.widget, self.views[index].widget_tokens);
735
+ }
736
+
737
+ pub fn editCanvasWidgetText(self: *Runtime, window_id: platform.WindowId, label: []const u8, id: canvas.ObjectId, edit: canvas.TextInputEvent) anyerror!platform.ViewInfo {
738
+ try validateRuntimeViewParent(self, window_id);
739
+ try validateViewLabel(label);
740
+ if (id == 0) return error.InvalidCommand;
741
+ const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
742
+ if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
743
+ if (!self.views[index].canEditCanvasWidgetText(id)) return error.InvalidCommand;
744
+
745
+ const dirty = try self.views[index].applyCanvasWidgetTextEdit(id, edit) orelse return self.views[index].info();
746
+ try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, index, dirty);
747
+ _ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
748
+ return self.views[index].info();
749
+ }
750
+ };
751
+ }
752
+
753
+ fn CanvasFrameMethods(comptime Runtime: type) type {
754
+ return canvas_frame_helpers.RuntimeCanvasFrames(Runtime);
755
+ }
756
+
757
+ fn CanvasWidgetDisplayMethods(comptime Runtime: type) type {
758
+ return runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime);
759
+ }
760
+
761
+ fn CanvasWidgetEventMethods(comptime Runtime: type) type {
762
+ return runtime_canvas_widget_events.RuntimeCanvasWidgetEvents(Runtime);
763
+ }
764
+
765
+ fn AutomationWidgetMethods(comptime Runtime: type) type {
766
+ return runtime_automation_widget_dispatch.RuntimeAutomationWidgetDispatch(Runtime);
767
+ }
768
+
769
+ fn ScrollDriverMethods(comptime Runtime: type) type {
770
+ return runtime_canvas_widget_scroll_drivers.RuntimeCanvasWidgetScrollDrivers(Runtime);
771
+ }
772
+
773
+ /// Dirty-region accumulation for disclosure steps: the union of every
774
+ /// moved frame's before and after — the moving band, not the surface.
775
+ fn unionDisclosureDirty(current: ?geometry.RectF, frame: geometry.RectF) ?geometry.RectF {
776
+ if (frame.isEmpty()) return current;
777
+ const existing = current orelse return frame;
778
+ return geometry.RectF.unionWith(existing, frame);
779
+ }
780
+
781
+ fn validateRuntimeViewParent(self: anytype, window_id: platform.WindowId) !void {
782
+ const index = runtimeFindWindowIndexById(self, window_id) orelse return error.WindowNotFound;
783
+ if (!self.windows[index].info.open) return error.WindowNotFound;
784
+ }
785
+
786
+ fn runtimeFindWindowIndexById(self: anytype, id: platform.WindowId) ?usize {
787
+ for (self.windows[0..self.window_count], 0..) |window, index| {
788
+ if (window.info.id == id) return index;
789
+ }
790
+ return null;
791
+ }
792
+
793
+ fn runtimeFindViewIndex(self: anytype, window_id: platform.WindowId, label: []const u8) ?usize {
794
+ for (self.views[0..self.view_count], 0..) |*view, index| {
795
+ if (view.open and view.window_id == window_id and std.mem.eql(u8, view.label, label)) return index;
796
+ }
797
+ return null;
798
+ }