@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,224 @@
1
+ //! Runtime canvas image registry: decoded RGBA pixels registered at
2
+ //! runtime under caller-chosen `ImageId`s (the effect-key spirit — store
3
+ //! the id in the model, no handles to leak) and referenced from
4
+ //! image/icon/avatar widgets.
5
+ //!
6
+ //! The registry is the missing bridge between fetched/decoded bytes and
7
+ //! the canvas image pipeline, which was already id+fingerprint based end
8
+ //! to end: `registerCanvasImage` copies pixels into a bounded
9
+ //! runtime-owned pool, and the frame planner threads the registered set
10
+ //! into `CanvasFrameOptions.image_resources` for every view — the CPU
11
+ //! reference renderer (presentation, screenshots, goldens) and the GPU
12
+ //! packet planner (upload/retain/evict actions keyed by pixel
13
+ //! fingerprint) both consume it with no further plumbing. Pixel bytes
14
+ //! reach GPU packet hosts through the platform's binary upload
15
+ //! side-channel (`uploadGpuSurfaceImage`, driven by packet upload cache
16
+ //! actions at present time; `removeGpuSurfaceImage` at unregister) —
17
+ //! packets carry only id + fingerprint references, so registered images
18
+ //! never inflate packet JSON past its transport bound. Re-registering an
19
+ //! id replaces its pixels: the content fingerprint changes, so caches
20
+ //! re-upload without any explicit invalidation call.
21
+ //!
22
+ //! Capacities follow `canvas_limits`: `max_registered_canvas_images`
23
+ //! slots of `max_registered_canvas_image_pixel_bytes` each, overflow is
24
+ //! `error.ImageRegistryFull` / `error.ImageTooLarge` — never silent.
25
+
26
+ const std = @import("std");
27
+ const canvas = @import("canvas");
28
+ const canvas_frame_module = @import("canvas_frame.zig");
29
+ const canvas_limits = @import("canvas_limits.zig");
30
+ const effects_mod = @import("effects.zig");
31
+
32
+ pub const max_registered_canvas_images = canvas_limits.max_registered_canvas_images;
33
+ pub const max_registered_canvas_image_pixel_bytes = canvas_limits.max_registered_canvas_image_pixel_bytes;
34
+
35
+ /// One registered image's metadata; pixels live in the runtime's slot
36
+ /// pool at the same index.
37
+ pub const CanvasImageEntry = struct {
38
+ id: canvas.ImageId = 0,
39
+ width: usize = 0,
40
+ height: usize = 0,
41
+ byte_len: usize = 0,
42
+ };
43
+
44
+ /// Dimensions of a successfully registered image (the decode-and-register
45
+ /// path reports what the platform codec produced).
46
+ pub const RegisteredCanvasImage = struct {
47
+ width: usize = 0,
48
+ height: usize = 0,
49
+ };
50
+
51
+ /// Decode scratch for `registerCanvasImageBytes`. Sized past the slot
52
+ /// bound because decoders may need in-buffer scratch beyond the tight
53
+ /// pixel bytes (the null platform's strict PNG parser keeps one filter
54
+ /// byte per row: raw stream <= pixels + pixels/4 since a row is at least
55
+ /// 4 pixel bytes). Loop-thread only, like the frame scratch.
56
+ threadlocal var canvas_image_decode_scratch: [max_registered_canvas_image_pixel_bytes + max_registered_canvas_image_pixel_bytes / 4]u8 = undefined;
57
+
58
+ pub fn RuntimeCanvasImages(comptime Runtime: type) type {
59
+ return struct {
60
+ /// Register (or replace) decoded pixels under `id`: tightly
61
+ /// packed, row-major, straight-alpha RGBA8, exactly
62
+ /// `width * height * 4` bytes. The runtime copies the pixels, so
63
+ /// the caller's buffer is free when this returns. Every
64
+ /// gpu_surface view repaints with the new image on its next
65
+ /// frame; replacing an id changes the content fingerprint, so
66
+ /// GPU-side caches re-upload without explicit invalidation.
67
+ /// Errors: `error.InvalidImageId` (id 0 is the "no image"
68
+ /// sentinel), `error.InvalidImageDimensions` (zero/overflowing
69
+ /// dimensions or a pixel slice that is not exactly
70
+ /// `width * height * 4`), `error.ImageTooLarge` (over the
71
+ /// per-image slot bound), `error.ImageRegistryFull` (all
72
+ /// `max_registered_canvas_images` slots hold other ids).
73
+ pub fn registerCanvasImage(self: *Runtime, id: canvas.ImageId, width: usize, height: usize, rgba8: []const u8) anyerror!void {
74
+ if (id == 0) return error.InvalidImageId;
75
+ if (width == 0 or height == 0) return error.InvalidImageDimensions;
76
+ const row_len = std.math.mul(usize, width, 4) catch return error.InvalidImageDimensions;
77
+ const byte_len = std.math.mul(usize, row_len, height) catch return error.InvalidImageDimensions;
78
+ if (rgba8.len != byte_len) return error.InvalidImageDimensions;
79
+ if (byte_len > max_registered_canvas_image_pixel_bytes) return error.ImageTooLarge;
80
+
81
+ const index = findCanvasImageIndex(self, id) orelse blk: {
82
+ if (self.canvas_image_count >= max_registered_canvas_images) return error.ImageRegistryFull;
83
+ const index = self.canvas_image_count;
84
+ self.canvas_image_count += 1;
85
+ break :blk index;
86
+ };
87
+ @memcpy(self.canvas_image_pixels[index][0..byte_len], rgba8);
88
+ self.canvas_image_entries[index] = .{
89
+ .id = id,
90
+ .width = width,
91
+ .height = height,
92
+ .byte_len = byte_len,
93
+ };
94
+ // No pixel push here: GPU packet hosts receive the bytes
95
+ // through the binary upload side-channel when a packet's
96
+ // upload cache action first references the new content
97
+ // fingerprint (`uploadCanvasPacketImages` on the packet
98
+ // present path), which also covers caller-supplied
99
+ // `image_resources` sets that never pass through this
100
+ // registry.
101
+ noteCanvasImagesChanged(self);
102
+ }
103
+
104
+ /// Decode encoded image bytes (PNG, JPEG, ... — whatever the
105
+ /// platform codec supports) through
106
+ /// `PlatformServices.decode_image_fn` and register the pixels
107
+ /// under `id` in one step — the fetch-avatar path:
108
+ /// `fx.fetch` bytes in `update`, decode+register here, store the
109
+ /// id in the model. On top of `registerCanvasImage`'s errors:
110
+ /// `error.UnsupportedService` (platform has no codec),
111
+ /// `error.ImageDecodeFailed` (undecodable bytes),
112
+ /// `error.ImageTooLarge` (decoded pixels over the slot bound).
113
+ pub fn registerCanvasImageBytes(self: *Runtime, id: canvas.ImageId, bytes: []const u8) anyerror!RegisteredCanvasImage {
114
+ if (id == 0) return error.InvalidImageId;
115
+ const decoded = try self.options.platform.services.decodeImage(bytes, &canvas_image_decode_scratch);
116
+ if (decoded.rgba8.len > max_registered_canvas_image_pixel_bytes) return error.ImageTooLarge;
117
+ try registerCanvasImage(self, id, decoded.width, decoded.height, decoded.rgba8);
118
+ return .{ .width = decoded.width, .height = decoded.height };
119
+ }
120
+
121
+ /// Remove `id` from the registry, freeing its slot. Returns
122
+ /// whether the id was registered. Views repaint without the
123
+ /// image on their next frame (draws referencing a missing id
124
+ /// skip, exactly like an unregistered id).
125
+ pub fn unregisterCanvasImage(self: *Runtime, id: canvas.ImageId) bool {
126
+ const index = findCanvasImageIndex(self, id) orelse return false;
127
+ const last = self.canvas_image_count - 1;
128
+ if (index != last) {
129
+ self.canvas_image_entries[index] = self.canvas_image_entries[last];
130
+ @memcpy(
131
+ self.canvas_image_pixels[index][0..self.canvas_image_entries[index].byte_len],
132
+ self.canvas_image_pixels[last][0..self.canvas_image_entries[index].byte_len],
133
+ );
134
+ }
135
+ self.canvas_image_entries[last] = .{};
136
+ self.canvas_image_count = last;
137
+ // Best-effort drop of the platform-side texture: platforms
138
+ // without the upload seam report UnsupportedService, and a
139
+ // failed removal only costs the host a stale (unreferenced)
140
+ // texture until the id is re-uploaded — never a wrong frame,
141
+ // since packets key uploads by content fingerprint.
142
+ self.options.platform.services.removeGpuSurfaceImage(id) catch {};
143
+ noteCanvasImagesChanged(self);
144
+ return true;
145
+ }
146
+
147
+ /// The registered set as the `ReferenceImage` slice both
148
+ /// renderers consume, rebuilt into runtime scratch (pixels are
149
+ /// borrowed from the slot pool, valid until the next
150
+ /// register/unregister).
151
+ pub fn registeredCanvasImages(self: *Runtime) []const canvas.ReferenceImage {
152
+ for (self.canvas_image_entries[0..self.canvas_image_count], 0..) |entry, index| {
153
+ self.canvas_image_resources_scratch[index] = .{
154
+ .id = entry.id,
155
+ .width = entry.width,
156
+ .height = entry.height,
157
+ .pixels = self.canvas_image_pixels[index][0..entry.byte_len],
158
+ };
159
+ }
160
+ return self.canvas_image_resources_scratch[0..self.canvas_image_count];
161
+ }
162
+
163
+ /// Dimensions of a registered image, or null when `id` is not
164
+ /// registered.
165
+ pub fn registeredCanvasImage(self: *const Runtime, id: canvas.ImageId) ?RegisteredCanvasImage {
166
+ const index = findCanvasImageIndex(self, id) orelse return null;
167
+ const entry = self.canvas_image_entries[index];
168
+ return .{ .width = entry.width, .height = entry.height };
169
+ }
170
+
171
+ pub fn registeredCanvasImageCount(self: *const Runtime) usize {
172
+ return self.canvas_image_count;
173
+ }
174
+
175
+ /// The registry as the type-erased binding `Effects(Msg)` carries
176
+ /// so `update` can register fetched pixels (`fx.registerImage`,
177
+ /// `fx.registerImageBytes`, `fx.unregisterImage`). `UiApp` binds
178
+ /// this alongside the platform services.
179
+ pub fn canvasImageRegistryBinding(self: *Runtime) effects_mod.ImageRegistryBinding {
180
+ const Adapter = struct {
181
+ fn register(context: *anyopaque, id: u64, width: usize, height: usize, rgba8: []const u8) anyerror!void {
182
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
183
+ return registerCanvasImage(runtime, id, width, height, rgba8);
184
+ }
185
+ fn registerBytes(context: *anyopaque, id: u64, bytes: []const u8) anyerror!effects_mod.RegisteredImage {
186
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
187
+ const info = try registerCanvasImageBytes(runtime, id, bytes);
188
+ return .{ .width = info.width, .height = info.height };
189
+ }
190
+ fn unregister(context: *anyopaque, id: u64) bool {
191
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
192
+ return unregisterCanvasImage(runtime, id);
193
+ }
194
+ };
195
+ return .{
196
+ .context = self,
197
+ .register_fn = Adapter.register,
198
+ .register_bytes_fn = Adapter.registerBytes,
199
+ .unregister_fn = Adapter.unregister,
200
+ };
201
+ }
202
+
203
+ fn findCanvasImageIndex(self: *const Runtime, id: canvas.ImageId) ?usize {
204
+ for (self.canvas_image_entries[0..self.canvas_image_count], 0..) |entry, index| {
205
+ if (entry.id == id) return index;
206
+ }
207
+ return null;
208
+ }
209
+
210
+ /// Registered pixels changed: force every gpu_surface view to
211
+ /// re-render its next frame (an image swap with an unchanged
212
+ /// display list would otherwise take the skip path) and request
213
+ /// frames so the repaint is not gated on other input.
214
+ fn noteCanvasImagesChanged(self: *Runtime) void {
215
+ const frame_methods = canvas_frame_module.RuntimeCanvasFrames(Runtime);
216
+ for (self.views[0..self.view_count], 0..) |*view, index| {
217
+ if (!view.open or view.kind != .gpu_surface) continue;
218
+ view.presented_canvas_valid = false;
219
+ self.invalidateFor(.state, view.frame);
220
+ frame_methods.requestCanvasFrameForView(self, index) catch {};
221
+ }
222
+ }
223
+ };
224
+ }
@@ -0,0 +1,317 @@
1
+ // Per-view canvas budgets. Fixed, documented, loud: capacities are compile
2
+ // time constants sized for a dense desktop view, overflow errors name the
3
+ // budget, and the automation snapshot reports headroom (widget_nodes=N/MAX).
4
+ //
5
+ // Raised after measuring a real three-pane desktop app (sidebar tree +
6
+ // markdown detail pane + run surface): it spent more design effort
7
+ // budgeting nodes than building UI at the old 256-node cap. The
8
+ // widget-node budget quadrupled (256 -> 1024: the measured worst realistic
9
+ // three-pane view is ~500 nodes, so 1024 leaves comfortable headroom), and
10
+ // the frame-content budgets doubled (commands 1024 -> 2048, glyphs
11
+ // 4096 -> 8192, text 16 KiB -> 32 KiB: visible content per frame grows with
12
+ // surface density, not with the retained-node cap — a full-height monospace
13
+ // diff pane is ~7200 glyphs). Memory cost is fixed-capacity address space
14
+ // in the Runtime (in-place constructed, large fields left uninitialized),
15
+ // measured at 61.3 MiB -> 119.3 MiB (RuntimeView 1.12 MiB -> 2.65 MiB x 32
16
+ // view slots); pages are only touched as views use their capacity.
17
+ pub const max_canvas_commands_per_view: usize = 2048;
18
+ pub const max_canvas_gradient_stops_per_view: usize = 64;
19
+ // Raised 128 -> 2048 with icon-in-button and the 41-icon registry: vector
20
+ // icons are path commands, and a curated stroke icon lowers to ~10-25
21
+ // elements (folder 10, sun 21, settings 25). A realistic dense view — a
22
+ // sidebar of icon rows, an icon toolbar, a transport — shows ~40 icons,
23
+ // ~800 elements; the notes example hit the old 128 the moment its folder
24
+ // rows wore icons. 2048 also gives path-drawn charts real room (three
25
+ // 60-point polylines ~ 360 elements — the system-monitor sparklines had
26
+ // to become bars under the old cap). Memory is fixed-capacity address
27
+ // space: one PathElement is 28 B, so 2048 x 28 B = 56 KiB per view for
28
+ // each of the two per-view arrays (retained canvas + display-list
29
+ // scratch), x 32 view slots ~ 3.6 MiB total, pages touched only as views
30
+ // draw paths.
31
+ pub const max_canvas_path_elements_per_view: usize = 2048;
32
+ pub const max_canvas_glyphs_per_view: usize = 8192;
33
+ pub const max_canvas_text_bytes_per_view: usize = 32768;
34
+ // Retained packet commands per gpu-surface view: the host-side command
35
+ // dictionary that incremental (`patch`) presents edit, and the engine's
36
+ // per-view key+fingerprint mirror that derives those patches. Derived
37
+ // from the command budget because every retained command is born from
38
+ // exactly one display-list command — the command budget fails first,
39
+ // loudly, before this one can. The AppKit host pins the same value
40
+ // (NATIVE_SDK_PACKET_RETAINED_COMMAND_CAP in appkit_host.m); a frame past
41
+ // either side's cap presents FULL (and the host drops its retained
42
+ // state), never a partial dictionary. Engine memory is two u64 arrays:
43
+ // 16 B x 2048 = 32 KiB per view x 32 view slots = 1 MiB fixed address
44
+ // space; host memory is the decoded command dictionaries, realistically
45
+ // a few hundred KB for a dense view.
46
+ pub const max_canvas_retained_packet_commands_per_view: usize = max_canvas_commands_per_view;
47
+ pub const max_canvas_diff_changes_per_view: usize = max_canvas_commands_per_view * 2 + 1;
48
+ pub const max_canvas_render_animations_per_view: usize = max_canvas_commands_per_view;
49
+ // Sized to the widget loop-animation budget below plus caret headroom:
50
+ // every armed loop registers its command's bounds here so damage stays
51
+ // tight, and a segmented spinner alone registers one entry per segment.
52
+ // (Damage stays CORRECT past the cap — the general override diff in
53
+ // canvas_frame.zig recomputes changed-command bounds from the commands
54
+ // themselves — this registry just keeps the fast path covering them.)
55
+ pub const max_canvas_render_animation_dirty_bounds_per_view: usize = 72;
56
+ pub const max_canvas_render_overrides_per_view: usize = max_canvas_commands_per_view;
57
+ pub const max_canvas_pipelines_per_view: usize = 8;
58
+ pub const max_canvas_pipeline_cache_actions_per_view: usize = max_canvas_pipelines_per_view * 2;
59
+ pub const max_canvas_path_geometries_per_view: usize = max_canvas_commands_per_view;
60
+ pub const max_canvas_path_geometry_cache_actions_per_view: usize = max_canvas_path_geometries_per_view * 2;
61
+ pub const max_canvas_images_per_view: usize = max_canvas_commands_per_view;
62
+ pub const max_canvas_image_cache_actions_per_view: usize = max_canvas_images_per_view * 2;
63
+ pub const max_canvas_layers_per_view: usize = max_canvas_commands_per_view;
64
+ pub const max_canvas_layer_cache_actions_per_view: usize = max_canvas_layers_per_view * 2;
65
+ pub const max_canvas_resources_per_view: usize = max_canvas_commands_per_view;
66
+ pub const max_canvas_resource_cache_actions_per_view: usize = max_canvas_resources_per_view * 2;
67
+ pub const max_canvas_visual_effects_per_view: usize = max_canvas_commands_per_view;
68
+ pub const max_canvas_visual_effect_cache_actions_per_view: usize = max_canvas_visual_effects_per_view * 2;
69
+ // Text layout plans per frame. Raised because a real agent transcript
70
+ // (long wrapped chat turns in a 380px pane) put >512 draw_text
71
+ // commands in one frame and killed renders with TextLayoutPlanListFull,
72
+ // invisible outside one log line. Every plan is born from exactly one
73
+ // `draw_text` command in a display list bounded by the command budget, so
74
+ // deriving this from `max_canvas_commands_per_view` makes plan-list
75
+ // overflow structurally unreachable — the command budget fails first,
76
+ // loudly, at build time. Memory is scratch + per-view cache: the
77
+ // per-frame planning arrays are threadlocal (TextLayoutPlan 96 B x 2048 =
78
+ // 192 KiB, cache entries 96 B x 2048 = 192 KiB, cache actions 96 B x
79
+ // 4096 = 384 KiB — ~0.8 MiB once per thread, was ~0.2 MiB), and each
80
+ // RuntimeView retains one cache-entry array (96 B x 2048 = 192 KiB x 32
81
+ // view slots = 6 MiB fixed address space, was 1.5 MiB; pages touch only
82
+ // as views lay out text).
83
+ pub const max_canvas_text_layouts_per_view: usize = max_canvas_commands_per_view;
84
+ // Wrapped text lines across all of a frame's layout plans (the plan
85
+ // arrays above index into one shared line pool). Sized with the
86
+ // long-transcript shape in mind — a long agent transcript's wrapped lines
87
+ // are what blew the old shared cap: plans grow with COMMAND count, lines
88
+ // grow with WRAP count — a
89
+ // 32 KiB frame-text budget wrapped at ~50 chars/line in a narrow pane is
90
+ // ~650 lines, so 8192 (matching the frame glyph budget: a rendered line
91
+ // costs at least one glyph) gives >10x headroom over the worst measured
92
+ // real view. TextLine is 56 B: 56 B x 8192 = 448 KiB of threadlocal
93
+ // scratch (was 28 KiB at the old shared 512 cap). Overflow stays a loud
94
+ // `TextLayoutLineListFull` with a teaching diagnostic naming this budget.
95
+ pub const max_canvas_text_layout_lines_per_view: usize = 8192;
96
+
97
+ // Runtime-registered canvas images: decoded RGBA pixel buffers apps
98
+ // register under a caller-chosen ImageId and reference from image/icon/
99
+ // avatar widgets. Slots are runtime-wide (all views share the registry;
100
+ // the frame planner threads it into every view's `image_resources`), and
101
+ // the runtime owns the pixel copies — the app's source buffer is free the
102
+ // moment registration returns. The per-image ceiling is avatar/icon
103
+ // scale (512x512 RGBA8), not photo scale; oversized registrations and
104
+ // decodes fail loudly with `error.ImageTooLarge`.
105
+ pub const max_registered_canvas_images: usize = 16;
106
+ pub const max_registered_canvas_image_pixel_bytes: usize = 1024 * 1024;
107
+
108
+ // Runtime-registered font faces: TrueType bytes apps register under a
109
+ // caller-chosen FontId (>= canvas.min_registered_font_id) so their own
110
+ // typefaces resolve everywhere a font id rides — token overrides, text
111
+ // runs, atlas keys, fingerprints, both renderers. Slots are runtime-wide
112
+ // and the runtime owns the byte copies (an app may register from a
113
+ // transient buffer, not just @embedFile). Registration is startup-shaped
114
+ // and permanent for the runtime's lifetime: glyph atlas and text-layout
115
+ // caches key glyphs by (font id, glyph id) with no content fingerprint,
116
+ // so re-registering an id with different bytes would serve stale glyphs —
117
+ // re-use of a registered id fails loudly instead (`error.FontIdInUse`).
118
+ // The slot count covers a real brand set (a text family in 2-3 weights
119
+ // plus a display and a mono face); the per-font bound fits full
120
+ // static-instance UI faces (the bundled faces are 71/116 KB; a large
121
+ // Latin+Cyrillic+Greek UI face is a few hundred KB) while refusing
122
+ // multi-megabyte CJK/variable fonts the glyph pipeline is not sized for.
123
+ // Memory is fixed-capacity address space in the Runtime: 8 x 2 MiB =
124
+ // 16 MiB, pages touched only as fonts register; oversized files and a
125
+ // ninth font fail loudly (`error.FontTooLarge` / `error.FontRegistryFull`).
126
+ pub const max_registered_canvas_fonts: usize = 8;
127
+ pub const max_registered_canvas_font_bytes: usize = 2 * 1024 * 1024;
128
+
129
+ // The retained widget-tree budgets (raised 256 -> 1024; see the header
130
+ // comment). `automation.snapshot.max_widgets_per_view`
131
+ // mirrors the node cap so snapshots never silently truncate widget
132
+ // enumeration; a test in canvas_widget_layout_tests.zig keeps them in
133
+ // lockstep.
134
+ pub const max_canvas_widget_nodes_per_view: usize = 1024;
135
+ pub const max_canvas_widget_semantics_per_view: usize = 1024;
136
+ // Raised from 2048 with the inline-span/markdown work: a rendered document
137
+ // retains its full plain text (paragraph bytes are stored once; span slices
138
+ // rebase into them) plus link payloads, and 2048 bytes could not hold a
139
+ // README-sized document. Raised again with the node-budget raise:
140
+ // a 1024-node view retains proportionally more text.
141
+ pub const max_canvas_widget_text_bytes_per_view: usize = 65536;
142
+ pub const max_canvas_widget_source_text_entries_per_view: usize = 256;
143
+ // Inline styled runs retained across all `.text` widgets of a view. Each
144
+ // span is a small struct (style flags + slices into the widget text
145
+ // bytes); per-paragraph capacity is `canvas.max_text_spans_per_paragraph`.
146
+ pub const max_canvas_widget_spans_per_view: usize = 1024;
147
+ // Declared native context-menu entries retained across all widgets of a
148
+ // view (labels live in the widget text bytes). Raised because the budget
149
+ // sums across every widget of the view, and a real desktop view hit 128
150
+ // fast — a 24-row sidebar with 4 items + separator per row, a detail-pane
151
+ // menu, and per-step ledger menus measured 124/128 before the app was
152
+ // finished. Quadrupled (128 -> 512)
153
+ // so declared menus scale with the 1024-node budget instead of becoming
154
+ // the next design-effort cliff. Memory cost is one 24-byte entry (a
155
+ // 16-byte label slice + enabled/separator flags) per slot: 24 B x 512 =
156
+ // 12 KiB per view (was 3 KiB at 128), x 32 view slots = 384 KiB total
157
+ // (was 96 KiB) of fixed-capacity address space; label bytes come out of
158
+ // the existing widget-text budget, and pages are only touched as views
159
+ // declare menus. Distinct from the platform's `max_context_menu_items`
160
+ // (32), which caps ONE presented menu (a single NSMenu popped at the
161
+ // pointer, truncated at presentation) — that stays small deliberately
162
+ // because a menu nobody can scan is a design bug, while this budget
163
+ // bounds the retained declarations across all widgets of the view.
164
+ pub const max_canvas_widget_context_menu_items_per_view: usize = 512;
165
+ // Window-drag region mirror per view (the Windows WM_NCHITTEST seam):
166
+ // drag-region rects plus the press-claiming exclusions inside them. A
167
+ // hidden-titlebar app has ONE header band and a handful of controls in
168
+ // it; 32 leaves room for split headers without retaining a second
169
+ // widget tree. Overflow drops the drag REGION rects beyond the cap
170
+ // (never the exclusions inside kept rects — see the collector), so a
171
+ // too-busy tree degrades to fewer draggable bands, never to stolen
172
+ // widget presses.
173
+ pub const max_canvas_widget_window_drag_regions_per_view: usize = 32;
174
+ // Chart series and points retained across all `.chart` widgets of a
175
+ // view. `Ui.chart` downsamples every series to
176
+ // `canvas.max_chart_points_per_series` (256) before it reaches the
177
+ // retained tree, so the points pool is sized as 64 maximal line/bar
178
+ // series: a dashboard of 16 charts x 3 series x 256 points fills it
179
+ // exactly, and realistic sparkline tiles (60 points) fit hundreds of
180
+ // series. Band series charge the pool twice (values + low), so 32
181
+ // maximal bands also fill it — the points budget can overflow before
182
+ // the series budget through bands, and the teaching error names the
183
+ // right cliff (pinned in canvas_budget_edge_tests.zig). Memory
184
+ // is fixed-capacity address space: series entries are ~64 B (slices +
185
+ // flags) x 64 = 4 KiB per view, points are 4 B x 16384 = 64 KiB per
186
+ // view, x 32 view slots = ~2.1 MiB total, pages touched only as views
187
+ // chart. Overflow is loud (`WidgetChartSeriesLimitReached` /
188
+ // `WidgetChartPointsLimitReached`), same contract as every widget budget;
189
+ // series labels ride the existing widget-text budget.
190
+ pub const max_canvas_widget_chart_series_per_view: usize = 64;
191
+ pub const max_canvas_widget_chart_points_per_view: usize = 16384;
192
+ // Chart x-axis category labels retained across all `.chart` widgets of
193
+ // a view: one entry per labeled sample (a slice header; the bytes ride
194
+ // the widget-text budget like series labels). `Ui.chart` drops labels
195
+ // on any downsampled series, so a labeled chart carries at most
196
+ // `canvas.max_chart_points_per_series` (256) of them — two maximal
197
+ // labeled charts fill the pool, a dashboard of month-scale charts (12
198
+ // labels) fits dozens. Entries are 16 B x 512 = 8 KiB per view.
199
+ // Overflow is loud (`WidgetChartLabelsLimitReached`).
200
+ pub const max_canvas_widget_chart_x_labels_per_view: usize = 512;
201
+ pub const max_canvas_widget_invalidations_per_view: usize = max_canvas_widget_nodes_per_view * 2 + 1;
202
+ // Scroll containers whose offset changed since the last app dispatch:
203
+ // entries are node ids, deduped, and the dispatched event reads the
204
+ // CURRENT scroll state, so coalescing wheel + kinetic steps into one
205
+ // pending entry is lossless. A view realistically has 1-2 concurrently
206
+ // moving scrollables; ids past the bound are dropped (the offsets still
207
+ // apply and repaint — only the observation Msg is skipped).
208
+ pub const max_canvas_widget_scroll_events_per_view: usize = 8;
209
+ // Split containers whose fraction changed since the last app dispatch
210
+ // (divider drag, keyboard adjustment, assistive increment/decrement):
211
+ // same shape as the scroll-event set above — entries are split node
212
+ // ids, deduped, and the dispatched event reads the CURRENT fraction, so
213
+ // coalescing several drag steps into one pending entry is lossless. A
214
+ // pointer drags exactly one divider at a time, so 4 covers every
215
+ // realistic view (nested splits still resize one seam per input); ids
216
+ // past the bound are dropped (the fraction still applies and repaints —
217
+ // only the observation Msg is skipped).
218
+ pub const max_canvas_widget_resize_events_per_view: usize = 4;
219
+ // Sliders whose value changed from a pointer gesture since the last app
220
+ // dispatch (rail click, thumb drag): same shape as the scroll- and
221
+ // resize-event sets above — entries are slider node ids, deduped, and
222
+ // the dispatched event reads the CURRENT value, so coalescing several
223
+ // drag steps into one pending entry is lossless. A pointer scrubs
224
+ // exactly one slider at a time, so 4 covers every realistic view; ids
225
+ // past the bound are dropped (the value still applies and repaints —
226
+ // only the observation Msg is skipped).
227
+ pub const max_canvas_widget_change_events_per_view: usize = 4;
228
+
229
+ // Anchored floating surfaces (widgets with `layout.anchor` set: anchored
230
+ // dropdown menus, popovers) mounted at once per view. Not a memory bound —
231
+ // the render and hit-test hoists scan the existing node array, no extra
232
+ // storage — but an honesty bound: realistically 1-3 anchored surfaces are
233
+ // ever open (a picker, maybe a nested submenu), each one costs the late
234
+ // z-pass and hit-test pre-pass a full-tree scan, and the likely way past
235
+ // 16 is an `anchor` accidentally inside a `<for>` body (one floating menu
236
+ // PER ROW). That mistake fails loudly at layout apply
237
+ // (`error.WidgetAnchoredSurfaceLimitReached`), never degrades every frame.
238
+ pub const max_canvas_widget_anchored_per_view: usize = 16;
239
+
240
+ /// Autofocus requests tracked per view for edge detection: the ids whose
241
+ /// SOURCE `autofocus` flag was set on the last applied layout, so a
242
+ /// rebuild only moves focus when the flag TURNS ON (or its widget
243
+ /// mounts), never while it merely stays on. 8 B x 16 x 32 view slots =
244
+ /// 4 KiB fixed address space; layouts declaring more than 16 autofocus
245
+ /// widgets track the first 16 (one focus target per rebuild wins
246
+ /// anyway).
247
+ pub const max_canvas_widget_autofocus_per_view: usize = 16;
248
+
249
+ /// COMMANDS carrying an engine-armed LOOPING render animation per view
250
+ /// (spinner rotations, per-segment spinner opacity loops, skeleton
251
+ /// pulses). Each armed command is one render animation slot plus one
252
+ /// dirty-bounds entry, sampled every frame while visible. An arc
253
+ /// spinner or skeleton arms one loop, but a segmented-register spinner
254
+ /// arms one loop PER SEGMENT (up to 15) — 64 covers a handful of
255
+ /// simultaneous indicators in either register; showing more at once is
256
+ /// a design smell, so the extras render static instead of degrading
257
+ /// the frame budget. Memory is one ObjectId per slot (64 x 8 B x 32
258
+ /// view slots = 16 KiB fixed address space).
259
+ pub const max_canvas_widget_loop_animations_per_view: usize = 64;
260
+
261
+ /// Concurrent runtime-driven LAYOUT tweens per view (split fractions
262
+ /// animating toward declared targets). Layout tweens are gesture-scale
263
+ /// — a pane collapse, a drawer slide — so a handful covers real apps;
264
+ /// a start past the budget snaps the value to its target instead of
265
+ /// dropping the state change (motion degrades, truth never does).
266
+ pub const max_canvas_widget_layout_tweens_per_view: usize = 8;
267
+
268
+ /// Nodes one disclosure tween may move per view: a disclosure flip
269
+ /// reflows the flipped item plus everything stacked below it (siblings,
270
+ /// content-hugging ancestors, and THEIR following siblings), and the
271
+ /// tween replays exactly that recorded reflow. A flip that moves more
272
+ /// nodes than this snaps to its target instead of animating a partial
273
+ /// pose (motion degrades under pressure, the state change always
274
+ /// lands).
275
+ pub const max_canvas_widget_disclosure_moves_per_view: usize = 256;
276
+
277
+ /// Disclosure widgets one rebuild may animate at once (an exclusive
278
+ /// accordion closes one section while opening another — two; a "expand
279
+ /// all" affordance can flip more). Flips past the budget snap the whole
280
+ /// rebuild: a half-animated, half-snapped reflow would tear.
281
+ pub const max_canvas_widget_disclosure_flips_per_view: usize = 8;
282
+
283
+ // Widget provenance (write-back's read half; `UiApp` retains it only in
284
+ // markup-interpreter builds, and only fills it when automation is on).
285
+ // One record per markup-authored widget of the main canvas view, so the
286
+ // cap mirrors the layout node budget -- layout rejects a deeper tree
287
+ // before the provenance pool can saturate, which a lockstep test pins.
288
+ pub const max_canvas_widget_provenance_records_per_view: usize = max_canvas_widget_nodes_per_view;
289
+ // Source files a provenance table can name: the markup root plus the
290
+ // import-closure cap (`canvas.ui_markup.max_imported_files`).
291
+ pub const max_canvas_widget_provenance_files: usize = 33;
292
+ // Per-entry path storage: `canvas.ui_markup.max_import_path_len` plus
293
+ // headroom for the watch-path prefix the app joins on.
294
+ pub const max_canvas_widget_provenance_path_bytes: usize = 240;
295
+ // Template instantiation chain depth a record reports (outermost use
296
+ // sites first). Deeper chains truncate the REPORT, never identity: four
297
+ // levels names the whole chain for every real component tree while
298
+ // keeping the record small enough to retain per widget.
299
+ pub const max_canvas_widget_provenance_chain: usize = 4;
300
+ // Rendered iteration-key text per record ("card-12/3"): keys beyond
301
+ // this truncate with an honest marker in the record.
302
+ pub const max_canvas_widget_provenance_key_bytes: usize = 48;
303
+
304
+ // Model-declared secondary windows per `UiApp` (`Options.windows_fn`
305
+ // descriptors — settings, about, inspectors), on top of the scene's main
306
+ // window. Sized for the classic desktop-client shape: one settings window,
307
+ // maybe an auxiliary panel or two, never a window per document (that is
308
+ // a different architecture — one Runtime hosts `platform.max_windows`
309
+ // = 16 windows total, and the startup window plus tool windows must all
310
+ // fit). The cost is NOT the runtime window (those are platform-capped):
311
+ // each UiApp slot retains two arena allocators whose high-water mark is
312
+ // that window's built view, plus a retained widget tree, and EVERY
313
+ // dispatched Msg rebuilds every open window's view — 4 keeps the
314
+ // rebuild-per-Msg bill visible-by-construction. Declaring more windows
315
+ // than this warns loudly (naming this budget) and ignores the excess;
316
+ // it never takes the render loop down.
317
+ pub const max_ui_app_windows: usize = 4;