@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
package/src/root.zig ADDED
@@ -0,0 +1,165 @@
1
+ pub const geometry = @import("geometry");
2
+ pub const assets = @import("assets");
3
+ pub const app_dirs = @import("app_dirs");
4
+ pub const app_manifest = @import("app_manifest");
5
+ pub const trace = @import("trace");
6
+ pub const diagnostics = @import("diagnostics");
7
+ pub const platform_info = @import("platform_info");
8
+ pub const canvas = @import("canvas");
9
+ pub const markdown = canvas.markdown;
10
+
11
+ pub const runtime = @import("runtime/root.zig");
12
+ pub const platform = @import("platform/root.zig");
13
+ pub const window_state = @import("window_state/root.zig");
14
+ pub const asset_server = @import("assets/root.zig");
15
+ pub const debug = @import("debug/root.zig");
16
+ pub const automation = @import("automation/root.zig");
17
+ pub const embed = @import("embed/root.zig");
18
+ pub const extensions = @import("extensions/root.zig");
19
+ pub const js = @import("js/root.zig");
20
+ pub const bridge = @import("bridge/root.zig");
21
+ pub const frontend = @import("frontend/root.zig");
22
+ pub const security = @import("security/root.zig");
23
+
24
+ pub const Runtime = runtime.Runtime;
25
+ pub const RuntimeOptions = runtime.Options;
26
+ pub const App = runtime.App;
27
+ pub const Event = runtime.Event;
28
+ pub const LifecycleEvent = runtime.LifecycleEvent;
29
+ pub const Command = runtime.Command;
30
+ pub const CommandEvent = runtime.CommandEvent;
31
+ pub const CommandSource = runtime.CommandSource;
32
+ pub const TestHarness = runtime.TestHarness;
33
+ pub const UiApp = runtime.UiApp;
34
+ pub const UiAppWithFeatures = runtime.UiAppWithFeatures;
35
+ pub const UiAppFeatures = runtime.UiAppFeatures;
36
+ pub const Effects = runtime.Effects;
37
+ pub const EffectLine = runtime.EffectLine;
38
+ pub const EffectExit = runtime.EffectExit;
39
+ pub const EffectExitReason = runtime.EffectExitReason;
40
+ pub const EffectExecutor = runtime.EffectExecutor;
41
+ pub const EffectOutputMode = runtime.EffectOutputMode;
42
+ pub const FetchResponseMode = runtime.FetchResponseMode;
43
+ pub const EffectResponse = runtime.EffectResponse;
44
+ pub const EffectFetchOutcome = runtime.EffectFetchOutcome;
45
+ pub const EffectFileOp = runtime.EffectFileOp;
46
+ pub const EffectFileOutcome = runtime.EffectFileOutcome;
47
+ pub const EffectFileResult = runtime.EffectFileResult;
48
+ pub const effect_error_exit_code = runtime.effect_error_exit_code;
49
+ pub const max_effects = runtime.max_effects;
50
+ pub const max_effect_argv = runtime.max_effect_argv;
51
+ pub const max_effect_argv_bytes = runtime.max_effect_argv_bytes;
52
+ pub const max_effect_stdin_bytes = runtime.max_effect_stdin_bytes;
53
+ pub const max_effect_line_bytes = runtime.max_effect_line_bytes;
54
+ pub const max_effect_line_bytes_ceiling = runtime.max_effect_line_bytes_ceiling;
55
+ pub const max_effect_collect_bytes = runtime.max_effect_collect_bytes;
56
+ pub const max_effect_stderr_tail_bytes = runtime.max_effect_stderr_tail_bytes;
57
+ pub const max_effect_queue_entries = runtime.max_effect_queue_entries;
58
+ pub const max_effect_url_bytes = runtime.max_effect_url_bytes;
59
+ pub const max_effect_fetch_headers = runtime.max_effect_fetch_headers;
60
+ pub const max_effect_fetch_header_bytes = runtime.max_effect_fetch_header_bytes;
61
+ pub const max_effect_fetch_payload_bytes = runtime.max_effect_fetch_payload_bytes;
62
+ pub const max_effect_body_bytes = runtime.max_effect_body_bytes;
63
+ pub const default_effect_fetch_timeout_ms = runtime.default_effect_fetch_timeout_ms;
64
+ pub const max_effect_file_path_bytes = runtime.max_effect_file_path_bytes;
65
+ pub const max_effect_file_bytes = runtime.max_effect_file_bytes;
66
+ pub const EffectClipboardOp = runtime.EffectClipboardOp;
67
+ pub const EffectClipboardOutcome = runtime.EffectClipboardOutcome;
68
+ pub const EffectClipboardResult = runtime.EffectClipboardResult;
69
+ pub const max_effect_clipboard_bytes = runtime.max_effect_clipboard_bytes;
70
+ pub const TimerMode = runtime.TimerMode;
71
+ pub const EffectTimer = runtime.EffectTimer;
72
+ pub const EffectTimerOutcome = runtime.EffectTimerOutcome;
73
+ pub const max_effect_timers = runtime.max_effect_timers;
74
+ pub const EffectAudio = runtime.EffectAudio;
75
+ pub const EffectAudioEventKind = runtime.EffectAudioEventKind;
76
+ pub const EffectAudioSource = runtime.EffectAudioSource;
77
+ pub const audioCachePath = runtime.audioCachePath;
78
+ pub const max_effect_audio_path_bytes = runtime.max_effect_audio_path_bytes;
79
+ pub const Clock = runtime.Clock;
80
+ pub const TestClock = runtime.TestClock;
81
+ pub const nowMs = runtime.nowMs;
82
+ pub const nowNanoseconds = runtime.nowNanoseconds;
83
+ pub const monotonicMs = runtime.monotonicMs;
84
+ pub const monotonicNanoseconds = runtime.monotonicNanoseconds;
85
+ pub const setFreestandingMonotonicNanoseconds = runtime.setFreestandingMonotonicNanoseconds;
86
+ pub const RegisteredImage = runtime.RegisteredImage;
87
+ pub const max_registered_canvas_images = runtime.max_registered_canvas_images;
88
+ pub const max_registered_canvas_image_pixel_bytes = runtime.max_registered_canvas_image_pixel_bytes;
89
+ pub const ShellConfig = app_manifest.ShellConfig;
90
+ pub const ShellWindow = app_manifest.ShellWindow;
91
+ pub const ShellView = app_manifest.ShellView;
92
+ pub const ShellEdge = app_manifest.ShellEdge;
93
+ pub const ShellAxis = app_manifest.ShellAxis;
94
+ pub const ShellTab = app_manifest.ShellTab;
95
+ pub const ShellPrimaryAction = app_manifest.ShellPrimaryAction;
96
+ pub const ShellChrome = app_manifest.ShellChrome;
97
+
98
+ pub const WebViewSource = platform.WebViewSource;
99
+ pub const WebViewSourceKind = platform.WebViewSourceKind;
100
+ pub const WebViewAssetSource = platform.WebViewAssetSource;
101
+ pub const WebEngine = platform.WebEngine;
102
+ pub const PlatformFeature = platform.PlatformFeature;
103
+ pub const ViewKind = platform.ViewKind;
104
+ pub const ViewOptions = platform.ViewOptions;
105
+ pub const ViewPatch = platform.ViewPatch;
106
+ pub const ViewInfo = platform.ViewInfo;
107
+ pub const GpuFrame = platform.GpuFrame;
108
+ pub const GpuSurfaceOptions = platform.GpuSurfaceOptions;
109
+ pub const GpuSurfaceBackend = platform.GpuSurfaceBackend;
110
+ pub const GpuSurfacePixelFormat = platform.GpuSurfacePixelFormat;
111
+ pub const GpuSurfacePresentMode = platform.GpuSurfacePresentMode;
112
+ pub const GpuSurfaceAlphaMode = platform.GpuSurfaceAlphaMode;
113
+ pub const GpuSurfaceColorSpace = platform.GpuSurfaceColorSpace;
114
+ pub const GpuSurfaceStatus = platform.GpuSurfaceStatus;
115
+ pub const CanvasFrameProfileRisk = platform.CanvasFrameProfileRisk;
116
+ pub const AppInfo = platform.AppInfo;
117
+ pub const Platform = platform.Platform;
118
+ pub const NullPlatform = platform.NullPlatform;
119
+ pub const WindowId = platform.WindowId;
120
+ pub const WindowOptions = platform.WindowOptions;
121
+ pub const WindowCreateOptions = platform.WindowCreateOptions;
122
+ pub const WindowInfo = platform.WindowInfo;
123
+ pub const WindowState = platform.WindowState;
124
+ pub const WindowRestorePolicy = platform.WindowRestorePolicy;
125
+ pub const WindowTitlebarStyle = platform.WindowTitlebarStyle;
126
+ pub const WindowChrome = platform.WindowChrome;
127
+ pub const FormFactor = platform.FormFactor;
128
+ pub const WindowDragRegion = platform.WindowDragRegion;
129
+ pub const WindowShowMode = platform.WindowShowMode;
130
+ pub const Menu = platform.Menu;
131
+ pub const MenuItem = platform.MenuItem;
132
+ pub const Shortcut = platform.Shortcut;
133
+ pub const ShortcutModifiers = platform.ShortcutModifiers;
134
+ pub const ShortcutEvent = platform.ShortcutEvent;
135
+ pub const TimerEvent = platform.TimerEvent;
136
+ pub const reserved_timer_id_base = platform.reserved_timer_id_base;
137
+ pub const ColorScheme = platform.ColorScheme;
138
+ pub const Appearance = platform.Appearance;
139
+ pub const GpuSurfaceFrameEvent = platform.GpuSurfaceFrameEvent;
140
+ pub const GpuSurfaceResizeEvent = platform.GpuSurfaceResizeEvent;
141
+ pub const GpuSurfaceInputKind = platform.GpuSurfaceInputKind;
142
+ pub const GpuSurfaceInputEvent = platform.GpuSurfaceInputEvent;
143
+ pub const FileFilter = platform.FileFilter;
144
+ pub const OpenDialogOptions = platform.OpenDialogOptions;
145
+ pub const OpenDialogResult = platform.OpenDialogResult;
146
+ pub const SaveDialogOptions = platform.SaveDialogOptions;
147
+ pub const MessageDialogStyle = platform.MessageDialogStyle;
148
+ pub const MessageDialogResult = platform.MessageDialogResult;
149
+ pub const MessageDialogOptions = platform.MessageDialogOptions;
150
+ pub const TrayItemId = platform.TrayItemId;
151
+ pub const TrayOptions = platform.TrayOptions;
152
+ pub const TrayMenuItem = platform.TrayMenuItem;
153
+ pub const BridgeDispatcher = bridge.Dispatcher;
154
+ pub const BridgePolicy = bridge.Policy;
155
+ pub const BridgeCommandPolicy = bridge.CommandPolicy;
156
+ pub const BridgeHandler = bridge.Handler;
157
+ pub const BridgeRegistry = bridge.Registry;
158
+ pub const SecurityPolicy = security.Policy;
159
+ pub const NavigationPolicy = security.NavigationPolicy;
160
+ pub const ExternalLinkPolicy = security.ExternalLinkPolicy;
161
+ pub const ExternalLinkAction = security.ExternalLinkAction;
162
+
163
+ test {
164
+ @import("std").testing.refAllDecls(@This());
165
+ }
@@ -0,0 +1,431 @@
1
+ const std = @import("std");
2
+ const trace = @import("trace");
3
+ const canvas = @import("canvas");
4
+ const automation = @import("../automation/root.zig");
5
+ const bridge = @import("../bridge/root.zig");
6
+ const extensions = @import("../extensions/root.zig");
7
+ const app_manifest = @import("app_manifest");
8
+ const platform = @import("../platform/root.zig");
9
+ const runtime_effects = @import("effects.zig");
10
+ const runtime_session_record = @import("session_record.zig");
11
+ const runtime_view = @import("view.zig");
12
+ const security = @import("../security/root.zig");
13
+ const widget_bridge = @import("widget_bridge.zig");
14
+ const window_state = @import("../window_state/root.zig");
15
+
16
+ pub const LifecycleEvent = enum {
17
+ start,
18
+ activate,
19
+ deactivate,
20
+ frame,
21
+ stop,
22
+ };
23
+
24
+ pub const CommandEvent = struct {
25
+ name: []const u8,
26
+ source: CommandSource = .runtime,
27
+ window_id: platform.WindowId = 0,
28
+ view_label: []const u8 = "",
29
+ tray_item_id: platform.TrayItemId = 0,
30
+ };
31
+
32
+ pub const Command = app_manifest.Command;
33
+
34
+ pub const CommandSource = enum {
35
+ runtime,
36
+ menu,
37
+ shortcut,
38
+ toolbar,
39
+ tray,
40
+ native_view,
41
+ bridge,
42
+ };
43
+
44
+ pub const ShortcutEvent = platform.ShortcutEvent;
45
+ pub const TimerEvent = platform.TimerEvent;
46
+ pub const Appearance = platform.Appearance;
47
+ pub const GpuFrame = platform.GpuFrame;
48
+ pub const GpuSurfaceFrameEvent = platform.GpuSurfaceFrameEvent;
49
+ pub const GpuSurfaceResizeEvent = platform.GpuSurfaceResizeEvent;
50
+ pub const GpuSurfaceInputEvent = platform.GpuSurfaceInputEvent;
51
+
52
+ pub const CanvasWidgetPointerEvent = struct {
53
+ window_id: platform.WindowId = 1,
54
+ view_label: []const u8,
55
+ pointer: canvas.WidgetPointerEvent,
56
+ target: ?canvas.WidgetHit = null,
57
+ /// Where a press on `target` actually lands: the deepest widget on the
58
+ /// hit path that claims presses — equal to `target` for interactive
59
+ /// widgets, the nearest pressable ancestor when the raw hit is plain
60
+ /// text/decoration, and null when nothing on the path is pressable OR
61
+ /// when this `.up` ended a text-selection drag (dragging selects,
62
+ /// clicking presses). Press-family dispatch (typed `on_press`, engine
63
+ /// `command`s, control activation) resolves through this; hover,
64
+ /// cursor, and text selection stay on `target`.
65
+ press_target: ?canvas.WidgetHit = null,
66
+ route: []const canvas.WidgetEventRouteEntry = &.{},
67
+ /// A text edit this pointer gesture performed on `target` (the
68
+ /// search field's built-in clear affordance). The runtime already
69
+ /// applied it (the optimistic echo; the source tree is truth on the
70
+ /// next rebuild); `UiApp` maps it through the tree's handler table
71
+ /// to the field's `on_input` Msg so a model-owned buffer clears too.
72
+ edit: ?canvas.TextInputEvent = null,
73
+ };
74
+
75
+ pub const CanvasWidgetKeyboardEvent = struct {
76
+ window_id: platform.WindowId = 1,
77
+ view_label: []const u8,
78
+ keyboard: canvas.WidgetKeyboardEvent,
79
+ target: ?canvas.WidgetFocusTarget = null,
80
+ route: []const canvas.WidgetEventRouteEntry = &.{},
81
+ };
82
+
83
+ /// A scroll container's offset changed from a user gesture (wheel,
84
+ /// kinetic momentum steps, keyboard, or an accessibility scroll action).
85
+ /// `scroll` is the post-change state — offset, viewport and content
86
+ /// extents (`maxOffset()` derives the range) — read at dispatch time, so
87
+ /// rapid motion coalesces into the latest state per node. Programmatic
88
+ /// source-tree offset changes do not emit this event: the model already
89
+ /// knows those.
90
+ pub const CanvasWidgetScrollEvent = struct {
91
+ window_id: platform.WindowId = 1,
92
+ view_label: []const u8,
93
+ /// The scroll container's structural widget id.
94
+ id: canvas.ObjectId,
95
+ scroll: canvas.ScrollState,
96
+ };
97
+
98
+ pub const CanvasWidgetDisplayListChrome = runtime_view.CanvasWidgetDisplayListChrome;
99
+
100
+ pub const CanvasPresentationMode = enum {
101
+ skipped,
102
+ gpu_packet,
103
+ pixels,
104
+ };
105
+
106
+ pub const CanvasPresentationResult = struct {
107
+ frame: canvas.CanvasFrame,
108
+ mode: CanvasPresentationMode = .skipped,
109
+ packet_command_count: usize = 0,
110
+ packet_cache_action_count: usize = 0,
111
+ packet_cached_resource_command_count: usize = 0,
112
+ packet_unsupported_command_count: usize = 0,
113
+ packet_representable: bool = true,
114
+ };
115
+
116
+ pub const CanvasWidgetAccessibilityActionKind = widget_bridge.CanvasWidgetAccessibilityActionKind;
117
+ pub const CanvasWidgetAccessibilityAction = widget_bridge.CanvasWidgetAccessibilityAction;
118
+
119
+ pub const CanvasWidgetFileDropEvent = struct {
120
+ window_id: platform.WindowId = 1,
121
+ view_label: []const u8,
122
+ drop: canvas.WidgetFileDropEvent,
123
+ target: ?canvas.WidgetHit = null,
124
+ route: []const canvas.WidgetEventRouteEntry = &.{},
125
+ };
126
+
127
+ pub const CanvasWidgetDragEvent = struct {
128
+ window_id: platform.WindowId = 1,
129
+ view_label: []const u8,
130
+ drag: canvas.WidgetDragEvent,
131
+ source: ?canvas.WidgetHit = null,
132
+ route: []const canvas.WidgetEventRouteEntry = &.{},
133
+ };
134
+
135
+ /// A dismissible floating surface (dialog, drawer, sheet, popover,
136
+ /// menu-surface, dropdown-menu) was dismissed by a user gesture — Escape,
137
+ /// a pointer press outside it, or an automation/accessibility dismiss
138
+ /// action. The runtime hides the surface immediately (the optimistic
139
+ /// echo; the source tree is truth on the next rebuild) and delivers this
140
+ /// event so a TEA model can OWN the close: `UiApp` maps it through the
141
+ /// tree's handler table to the surface's `on_dismiss` Msg.
142
+ pub const CanvasWidgetDismissEvent = struct {
143
+ window_id: platform.WindowId = 1,
144
+ view_label: []const u8,
145
+ /// The dismissed surface's structural widget id.
146
+ id: canvas.ObjectId,
147
+ };
148
+
149
+ /// A split container's fraction changed from a user resize — divider
150
+ /// drag, keyboard adjustment on the focused divider, or an assistive
151
+ /// increment/decrement. The runtime already applied the fraction (the
152
+ /// optimistic echo; the source tree is truth on the next rebuild) and
153
+ /// delivers this event so a TEA model can OWN it: `UiApp` maps it
154
+ /// through the tree's handler table to the split's `on_resize` Msg.
155
+ pub const CanvasWidgetResizeEvent = struct {
156
+ window_id: platform.WindowId = 1,
157
+ view_label: []const u8,
158
+ /// The split container's structural widget id.
159
+ id: canvas.ObjectId,
160
+ /// The applied first-pane fraction (already clamped against the
161
+ /// panes' min widths).
162
+ fraction: f32,
163
+ };
164
+
165
+ /// A slider's value changed from a pointer gesture — a click on the rail
166
+ /// (the thumb jumps to the pressed point) or a scrubbing drag. The
167
+ /// runtime already applied the value (the optimistic echo; the source
168
+ /// tree is truth on the next rebuild) and delivers this event so a TEA
169
+ /// model can OWN it: `UiApp` maps it through the tree's handler table to
170
+ /// the slider's `on_value`/`on_change` Msg. Keyboard steps and assistive
171
+ /// increment/decrement do not emit this event — they already dispatch
172
+ /// through the keyboard path (`msgForKeyboard`).
173
+ pub const CanvasWidgetChangeEvent = struct {
174
+ window_id: platform.WindowId = 1,
175
+ view_label: []const u8,
176
+ /// The slider's structural widget id.
177
+ id: canvas.ObjectId,
178
+ /// The applied value (already clamped to 0...1).
179
+ value: f32,
180
+ };
181
+
182
+ /// A secondary-button press (right/ctrl-click, touch long-press) whose
183
+ /// route offered NO context menu — no app-declared items, no editable or
184
+ /// selected-text default. Delivered with the resolved press target so
185
+ /// `UiApp` can treat it as the press-and-hold alternative: the target's
186
+ /// `on_hold` Msg dispatches immediately. Widgets with a declared context
187
+ /// menu never see this — the native menu wins.
188
+ pub const CanvasWidgetContextPressEvent = struct {
189
+ window_id: platform.WindowId = 1,
190
+ view_label: []const u8,
191
+ /// The deepest press-claiming widget on the hit route (the same
192
+ /// resolution primary presses use).
193
+ press_target: ?canvas.WidgetHit = null,
194
+ };
195
+
196
+ /// The user selected an item from a widget's app-declared native context
197
+ /// menu (`ElementOptions.context_menu`). `item_index` indexes the
198
+ /// widget's declared items; `UiApp` maps it to the item's `Msg` through
199
+ /// the tree's handler table (`Tree.msgForContextMenu`).
200
+ pub const CanvasWidgetContextMenuEvent = struct {
201
+ window_id: platform.WindowId = 1,
202
+ view_label: []const u8,
203
+ target_id: canvas.ObjectId,
204
+ item_index: usize,
205
+ };
206
+
207
+ /// A right/ctrl-click landed on a widget with a declared context menu,
208
+ /// but the platform could not present it natively (this host has no
209
+ /// native menu presenter, or presenting failed). The app loop answers by
210
+ /// presenting the SAME declared items as an anchored canvas surface —
211
+ /// one authored menu, platform-appropriate presentation.
212
+ pub const CanvasWidgetContextMenuRequestEvent = struct {
213
+ window_id: platform.WindowId = 1,
214
+ view_label: []const u8,
215
+ target_id: canvas.ObjectId,
216
+ };
217
+
218
+ /// A window the RUNTIME knew as open was closed by the platform — the
219
+ /// user clicked its close button (or the host tore it down). Never
220
+ /// emitted for `runtime.closeWindow` calls the app itself made through
221
+ /// the reconcile path before the platform echo arrives with the window
222
+ /// already forgotten. The model owns the consequence, matching the
223
+ /// dismissal precedent: `UiApp` maps this to the declared window's
224
+ /// `on_close` Msg, and the next rebuild's declared window set is truth —
225
+ /// a model that keeps declaring the window gets it back.
226
+ pub const WindowClosedEvent = struct {
227
+ window_id: platform.WindowId,
228
+ /// The window's label from runtime storage (stable for the dispatch).
229
+ label: []const u8,
230
+ };
231
+
232
+ /// An automation `provenance` query for a live widget: the runtime has
233
+ /// already resolved the view and (for point queries) hit-tested the
234
+ /// widget id; the app that authored the view answers from its retained
235
+ /// provenance table and publishes the response through the automation
236
+ /// server. Slices are valid for the synchronous dispatch only.
237
+ pub const AutomationProvenanceEvent = struct {
238
+ window_id: platform.WindowId,
239
+ view_label: []const u8,
240
+ widget_id: u64,
241
+ };
242
+
243
+ pub const InvalidationReason = enum {
244
+ startup,
245
+ surface_resize,
246
+ command,
247
+ state,
248
+ };
249
+
250
+ pub const FrameDiagnostics = struct {
251
+ frame_index: u64 = 0,
252
+ command_count: usize = 0,
253
+ dirty_region_count: usize = 0,
254
+ resource_upload_count: usize = 0,
255
+ duration_ns: u64 = 0,
256
+ };
257
+
258
+ pub const Event = union(enum) {
259
+ lifecycle: LifecycleEvent,
260
+ appearance_changed: Appearance,
261
+ command: CommandEvent,
262
+ shortcut: ShortcutEvent,
263
+ timer: TimerEvent,
264
+ /// The platform loop was nudged from another thread
265
+ /// (`PlatformServices.wake_fn`): apps drain their effect completion
266
+ /// queues here, on the loop thread, and dispatch the resulting Msgs.
267
+ effects_wake,
268
+ /// A platform audio player report (load acknowledgment, position
269
+ /// tick, completion, failure): the ui-app layer routes it back
270
+ /// through `Effects.takeAudioMsg` into the app's `on_event` Msg.
271
+ audio: platform.AudioEvent,
272
+ files_dropped: platform.FileDropEvent,
273
+ gpu_surface_frame: GpuSurfaceFrameEvent,
274
+ gpu_surface_resized: GpuSurfaceResizeEvent,
275
+ gpu_surface_input: GpuSurfaceInputEvent,
276
+ canvas_widget_pointer: CanvasWidgetPointerEvent,
277
+ canvas_widget_keyboard: CanvasWidgetKeyboardEvent,
278
+ canvas_widget_scroll: CanvasWidgetScrollEvent,
279
+ canvas_widget_file_drop: CanvasWidgetFileDropEvent,
280
+ canvas_widget_drag: CanvasWidgetDragEvent,
281
+ canvas_widget_context_menu: CanvasWidgetContextMenuEvent,
282
+ canvas_widget_context_menu_request: CanvasWidgetContextMenuRequestEvent,
283
+ canvas_widget_dismiss: CanvasWidgetDismissEvent,
284
+ canvas_widget_context_press: CanvasWidgetContextPressEvent,
285
+ canvas_widget_resize: CanvasWidgetResizeEvent,
286
+ canvas_widget_change: CanvasWidgetChangeEvent,
287
+ window_closed: WindowClosedEvent,
288
+ automation_provenance: AutomationProvenanceEvent,
289
+
290
+ pub fn name(self: Event) []const u8 {
291
+ return switch (self) {
292
+ .lifecycle => |event_value| @tagName(event_value),
293
+ .appearance_changed => "appearance_changed",
294
+ .command => |event_value| event_value.name,
295
+ .shortcut => "shortcut",
296
+ .timer => "timer",
297
+ .effects_wake => "effects_wake",
298
+ .audio => "audio",
299
+ .files_dropped => "files_dropped",
300
+ .gpu_surface_frame => "gpu_surface_frame",
301
+ .gpu_surface_resized => "gpu_surface_resized",
302
+ .gpu_surface_input => "gpu_surface_input",
303
+ .canvas_widget_pointer => "canvas_widget_pointer",
304
+ .canvas_widget_keyboard => "canvas_widget_keyboard",
305
+ .canvas_widget_scroll => "canvas_widget_scroll",
306
+ .canvas_widget_file_drop => "canvas_widget_file_drop",
307
+ .canvas_widget_drag => "canvas_widget_drag",
308
+ .canvas_widget_context_menu => "canvas_widget_context_menu",
309
+ .canvas_widget_context_menu_request => "canvas_widget_context_menu_request",
310
+ .canvas_widget_dismiss => "canvas_widget_dismiss",
311
+ .canvas_widget_context_press => "canvas_widget_context_press",
312
+ .canvas_widget_resize => "canvas_widget_resize",
313
+ .canvas_widget_change => "canvas_widget_change",
314
+ .window_closed => "window_closed",
315
+ .automation_provenance => "automation_provenance",
316
+ };
317
+ }
318
+ };
319
+
320
+ /// Session-replay control, type-erased over the app's Msg union so the
321
+ /// replay driver can steer any app through its `App` value: `.arm`
322
+ /// switches the app's effects channel into replay mode (fake executor,
323
+ /// journaled results as the only terminal source) before the first
324
+ /// replayed event; `.feed` delivers one journaled effect result into
325
+ /// the stub executor's pending request with the matching key.
326
+ pub const ReplayControl = union(enum) {
327
+ arm,
328
+ feed: runtime_effects.EffectResultRecord,
329
+ };
330
+
331
+ pub fn App(comptime Runtime: type) type {
332
+ return struct {
333
+ const Self = @This();
334
+ const StartFn = *const fn (context: *anyopaque, runtime: *Runtime) anyerror!void;
335
+ const EventFn = *const fn (context: *anyopaque, runtime: *Runtime, event: Event) anyerror!void;
336
+ const SourceFn = *const fn (context: *anyopaque) anyerror!platform.WebViewSource;
337
+ const SceneFn = *const fn (context: *anyopaque) anyerror!app_manifest.ShellConfig;
338
+ const StopFn = *const fn (context: *anyopaque, runtime: *Runtime) anyerror!void;
339
+ const ReplayFn = *const fn (context: *anyopaque, control: ReplayControl) anyerror!void;
340
+
341
+ context: *anyopaque,
342
+ name: []const u8,
343
+ source: platform.WebViewSource = platform.WebViewSource.html(""),
344
+ source_fn: ?SourceFn = null,
345
+ scene_fn: ?SceneFn = null,
346
+ start_fn: ?StartFn = null,
347
+ event_fn: ?EventFn = null,
348
+ stop_fn: ?StopFn = null,
349
+ /// Session-replay hook (`UiApp` wires it automatically). Null
350
+ /// means the app cannot be replayed with effect stubbing —
351
+ /// replay refuses journals that carry effect results for it.
352
+ replay_fn: ?ReplayFn = null,
353
+
354
+ pub fn start(self: Self, runtime: *Runtime) anyerror!void {
355
+ if (self.start_fn) |start_fn| try start_fn(self.context, runtime);
356
+ }
357
+
358
+ pub fn event(self: Self, runtime: *Runtime, event_value: Event) anyerror!void {
359
+ if (self.event_fn) |event_fn| try event_fn(self.context, runtime, event_value);
360
+ }
361
+
362
+ pub fn webViewSource(self: Self) anyerror!platform.WebViewSource {
363
+ if (self.source_fn) |source_fn| return source_fn(self.context);
364
+ return self.source;
365
+ }
366
+
367
+ pub fn scene(self: Self) anyerror!?app_manifest.ShellConfig {
368
+ if (self.scene_fn) |scene_fn| return try scene_fn(self.context);
369
+ return null;
370
+ }
371
+
372
+ pub fn stop(self: Self, runtime: *Runtime) anyerror!void {
373
+ if (self.stop_fn) |stop_fn| try stop_fn(self.context, runtime);
374
+ }
375
+
376
+ /// Steer the app's replay hook. `error.ReplayUnsupported` when
377
+ /// the app registered none.
378
+ pub fn replayControl(self: Self, control: ReplayControl) anyerror!void {
379
+ const replay_fn = self.replay_fn orelse return error.ReplayUnsupported;
380
+ try replay_fn(self.context, control);
381
+ }
382
+ };
383
+ }
384
+
385
+ pub const Options = struct {
386
+ platform: platform.Platform,
387
+ trace_sink: ?trace.Sink = null,
388
+ log_path: ?[]const u8 = null,
389
+ extensions: ?extensions.ModuleRegistry = null,
390
+ bridge: ?bridge.Dispatcher = null,
391
+ builtin_bridge: bridge.Policy = .{},
392
+ security: security.Policy = .{},
393
+ commands: []const Command = &.{},
394
+ menus: []const platform.Menu = &.{},
395
+ shortcuts: []const platform.Shortcut = &.{},
396
+ automation: ?automation.Server = null,
397
+ window_state_store: ?window_state.Store = null,
398
+ js_window_api: bool = false,
399
+ gpu_surface_frame_diagnostics: bool = true,
400
+ /// Pixels-only presentation hosts (the mobile embed host) opt in to
401
+ /// keeping the view's keyed command mirror alive across PIXEL
402
+ /// presents: the mirror then describes what the presented pixel
403
+ /// buffer shows, so the next frame's dirty bounds refine to the
404
+ /// commands that actually changed (a keystroke repaints the field,
405
+ /// not the window) instead of degrading to the summary union on
406
+ /// every Msg rebuild. Must stay false on any platform that wires a
407
+ /// gpu-surface packet presenter — a later packet patch would target
408
+ /// a dictionary the host never adopted (the patch gate additionally
409
+ /// refuses pixel-adopted baselines as defense in depth).
410
+ pixel_present_retained_baseline: bool = false,
411
+ /// Optional render memo for the CPU pixel present path (see
412
+ /// `canvas.ReferenceRenderMemo`): pixels-only hosts that re-render
413
+ /// the retained scene every changed frame attach one so heavyweight
414
+ /// per-pixel commands replay their stored output and scaled image
415
+ /// draws blend from scale-once panels. Purely an optimization —
416
+ /// output bytes are identical with or without it. Must outlive the
417
+ /// runtime; null (the default) changes nothing.
418
+ pixel_present_render_memo: ?*canvas.ReferenceRenderMemo = null,
419
+ /// The process environment spawned effect children inherit (the app
420
+ /// runner threads it through from `std.process.Init`). `null` lets
421
+ /// the effect system resolve a fallback for hosts without a process
422
+ /// `Init` (embed/mobile): the libc/PEB environment where available,
423
+ /// `.empty` otherwise.
424
+ environ: ?std.process.Environ = null,
425
+ /// Session recorder (record/replay): when set, the dispatch choke
426
+ /// point journals every platform event, the effects channel journals
427
+ /// every drained result, and each published frame appends a state
428
+ /// fingerprint checkpoint. The app runner arms this from
429
+ /// `NATIVE_SDK_SESSION_RECORD=<path>`.
430
+ session_recorder: ?*runtime_session_record.SessionRecorder = null,
431
+ };
@@ -0,0 +1,49 @@
1
+ const bridge = @import("../bridge/root.zig");
2
+ const platform = @import("../platform/root.zig");
3
+
4
+ pub const max_async_bridge_responses: usize = 64;
5
+ pub const max_bridge_origin_bytes: usize = 512;
6
+
7
+ pub fn AsyncBridgeResponseSlot(comptime Runtime: type) type {
8
+ return struct {
9
+ const Self = @This();
10
+
11
+ in_use: bool = false,
12
+ runtime: ?*Runtime = null,
13
+ source: bridge.Source = .{},
14
+ origin_storage: [max_bridge_origin_bytes]u8 = undefined,
15
+ webview_label_storage: [platform.max_webview_label_bytes]u8 = undefined,
16
+
17
+ pub fn init(self: *Self, runtime: *Runtime, source: bridge.Source) !void {
18
+ if (source.origin.len > self.origin_storage.len) return error.BridgeOriginTooLarge;
19
+ if (source.webview_label.len > self.webview_label_storage.len) return error.WebViewLabelTooLarge;
20
+ self.runtime = runtime;
21
+ self.source = .{
22
+ .origin = try copyInto(&self.origin_storage, source.origin),
23
+ .window_id = source.window_id,
24
+ .webview_label = try copyInto(&self.webview_label_storage, source.webview_label),
25
+ };
26
+ self.in_use = true;
27
+ }
28
+
29
+ pub fn release(self: *Self) void {
30
+ self.in_use = false;
31
+ self.runtime = null;
32
+ self.source = .{};
33
+ }
34
+
35
+ pub fn respond(self: *Self, response: []const u8) anyerror!void {
36
+ if (!self.in_use) return error.AsyncBridgeResponseAlreadyCompleted;
37
+ const runtime = self.runtime orelse return error.AsyncBridgeResponseAlreadyCompleted;
38
+ const source = self.source;
39
+ defer self.release();
40
+ try runtime.respondToBridge(source, response);
41
+ }
42
+ };
43
+ }
44
+
45
+ fn copyInto(buffer: []u8, value: []const u8) ![]const u8 {
46
+ if (value.len > buffer.len) return error.NoSpaceLeft;
47
+ @memcpy(buffer[0..value.len], value);
48
+ return buffer[0..value.len];
49
+ }