@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,528 @@
1
+ //! The iOS host tier: the toolkit owns the entire iOS app.
2
+ //!
3
+ //! An app directory with app.zon + src/ never contains host code — the
4
+ //! UIKit host lives in the SDK (src/platform/ios/uikit_host.m, embedded
5
+ //! into the CLI below) and drives the app through the embed C ABI. Two
6
+ //! consumers:
7
+ //!
8
+ //! - `native dev --target ios`: build the embed static library for the
9
+ //! simulator, assemble a minimal .app bundle around the toolkit host,
10
+ //! install + launch it via `xcrun simctl`, and stream the app log.
11
+ //! - `native package --target ios` (package.zig): emit a complete Xcode
12
+ //! project (xcodeproj.zig) around the same host sources and a
13
+ //! device-slice library, archive-ready with zero edits.
14
+ //!
15
+ //! Everything app-specific flows from app.zon: bundle id (`id`), names
16
+ //! (`name`/`display_name`), version, and icons (the shared single-source
17
+ //! icon pipeline renders the asset catalog at package time).
18
+
19
+ const std = @import("std");
20
+ const builtin = @import("builtin");
21
+ const buildgraph = @import("buildgraph.zig");
22
+ const embedlib = @import("embedlib.zig");
23
+ const manifest_tool = @import("manifest.zig");
24
+ const process_tree = @import("process_tree.zig");
25
+ const toolchain = @import("toolchain.zig");
26
+
27
+ /// The toolkit-owned UIKit host application (canvas surface view,
28
+ /// touch/keyboard/IME forwarding, CoreText measurement, safe-area
29
+ /// viewport reporting) — the single source of truth compiled by both the
30
+ /// dev loop and the packaged Xcode project. The bytes arrive through the
31
+ /// `ios_host` module (src/platform/ios/files.zig).
32
+ pub const host_source = @import("ios_host").uikit_host_m;
33
+ pub const host_header = @import("ios_host").native_sdk_app_h;
34
+
35
+ pub const host_source_name = "uikit_host.m";
36
+ pub const host_header_name = "native_sdk_app.h";
37
+
38
+ pub const deployment_target = "15.0";
39
+
40
+ pub const Error = error{
41
+ MissingManifest,
42
+ MissingFramework,
43
+ ZigBuildFailed,
44
+ HostCompileFailed,
45
+ SimulatorUnavailable,
46
+ SimulatorCommandFailed,
47
+ };
48
+
49
+ /// Write the host sources into `dir_path` (created if needed).
50
+ pub fn writeHostSources(io: std.Io, dir_path: []const u8) !void {
51
+ var cwd = std.Io.Dir.cwd();
52
+ try cwd.createDirPath(io, dir_path);
53
+ var dir = try cwd.openDir(io, dir_path, .{});
54
+ defer dir.close(io);
55
+ try dir.writeFile(io, .{ .sub_path = host_source_name, .data = host_source });
56
+ try dir.writeFile(io, .{ .sub_path = host_header_name, .data = host_header });
57
+ }
58
+
59
+ /// The iOS bundle identifier for an app.zon `id`: underscores map to
60
+ /// hyphens because Apple's bundle-identifier grammar allows only
61
+ /// alphanumerics, hyphens, and periods (`xcodebuild archive` rejects the
62
+ /// rest) — the mirror of the Android packaging path, which maps hyphens
63
+ /// to underscores for Java package rules.
64
+ pub fn bundleIdAlloc(allocator: std.mem.Allocator, id: []const u8) ![]u8 {
65
+ const out = try allocator.dupe(u8, id);
66
+ for (out) |*ch| {
67
+ if (ch.* == '_') ch.* = '-';
68
+ }
69
+ return out;
70
+ }
71
+
72
+ /// The host-tier Info.plist: app identity from app.zon plus the fixed
73
+ /// UIKit application keys (full-screen launch via the modern
74
+ /// `UILaunchScreen` dictionary — without it iOS letterboxes the app and
75
+ /// safe-area insets lie). `NSAllowsLocalNetworking` scopes an App
76
+ /// Transport Security exception to localhost and the local network only —
77
+ /// the dev loop streams audio and other media from a server on the Mac —
78
+ /// while HTTPS stays required for everything on the internet.
79
+ pub fn infoPlistAlloc(allocator: std.mem.Allocator, metadata: manifest_tool.Metadata) ![]u8 {
80
+ const raw_bundle_id = try bundleIdAlloc(allocator, metadata.id);
81
+ defer allocator.free(raw_bundle_id);
82
+ const bundle_id = try xmlEscapeAlloc(allocator, raw_bundle_id);
83
+ defer allocator.free(bundle_id);
84
+ const name = try xmlEscapeAlloc(allocator, metadata.name);
85
+ defer allocator.free(name);
86
+ const display_name = try xmlEscapeAlloc(allocator, metadata.displayName());
87
+ defer allocator.free(display_name);
88
+ const version = try xmlEscapeAlloc(allocator, metadata.version);
89
+ defer allocator.free(version);
90
+ return std.fmt.allocPrint(allocator,
91
+ \\<?xml version="1.0" encoding="UTF-8"?>
92
+ \\<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
93
+ \\<plist version="1.0">
94
+ \\<dict>
95
+ \\ <key>CFBundleDevelopmentRegion</key>
96
+ \\ <string>en</string>
97
+ \\ <key>CFBundleExecutable</key>
98
+ \\ <string>{s}</string>
99
+ \\ <key>CFBundleIdentifier</key>
100
+ \\ <string>{s}</string>
101
+ \\ <key>CFBundleInfoDictionaryVersion</key>
102
+ \\ <string>6.0</string>
103
+ \\ <key>CFBundleName</key>
104
+ \\ <string>{s}</string>
105
+ \\ <key>CFBundleDisplayName</key>
106
+ \\ <string>{s}</string>
107
+ \\ <key>CFBundlePackageType</key>
108
+ \\ <string>APPL</string>
109
+ \\ <key>CFBundleShortVersionString</key>
110
+ \\ <string>{s}</string>
111
+ \\ <key>CFBundleVersion</key>
112
+ \\ <string>{s}</string>
113
+ \\ <key>LSRequiresIPhoneOS</key>
114
+ \\ <true/>
115
+ \\ <key>MinimumOSVersion</key>
116
+ \\ <string>
117
+ ++ deployment_target ++
118
+ \\</string>
119
+ \\ <key>NSAppTransportSecurity</key>
120
+ \\ <dict>
121
+ \\ <key>NSAllowsLocalNetworking</key>
122
+ \\ <true/>
123
+ \\ </dict>
124
+ \\ <key>UILaunchScreen</key>
125
+ \\ <dict/>
126
+ \\ <key>UISupportedInterfaceOrientations</key>
127
+ \\ <array>
128
+ \\ <string>UIInterfaceOrientationPortrait</string>
129
+ \\ <string>UIInterfaceOrientationLandscapeLeft</string>
130
+ \\ <string>UIInterfaceOrientationLandscapeRight</string>
131
+ \\ </array>
132
+ \\</dict>
133
+ \\</plist>
134
+ \\
135
+ , .{ name, bundle_id, name, display_name, version, version });
136
+ }
137
+
138
+ pub const LibSlice = enum {
139
+ simulator,
140
+ device,
141
+
142
+ /// Zig -Dtarget triple for this slice on the current host arch.
143
+ pub fn zigTriple(self: LibSlice) []const u8 {
144
+ return switch (self) {
145
+ .simulator => if (builtin.cpu.arch == .x86_64) "x86_64-ios-simulator" else "aarch64-ios-simulator",
146
+ .device => "aarch64-ios",
147
+ };
148
+ }
149
+
150
+ /// Clang -target triple matching `zigTriple`.
151
+ pub fn clangTriple(self: LibSlice) []const u8 {
152
+ return switch (self) {
153
+ .simulator => if (builtin.cpu.arch == .x86_64)
154
+ "x86_64-apple-ios" ++ deployment_target ++ "-simulator"
155
+ else
156
+ "arm64-apple-ios" ++ deployment_target ++ "-simulator",
157
+ .device => "arm64-apple-ios" ++ deployment_target,
158
+ };
159
+ }
160
+
161
+ pub fn clangSdk(self: LibSlice) []const u8 {
162
+ return switch (self) {
163
+ .simulator => "iphonesimulator",
164
+ .device => "iphoneos",
165
+ };
166
+ }
167
+ };
168
+
169
+ pub const LibBuildOptions = struct {
170
+ base_env: *std.process.Environ.Map,
171
+ assume_yes: bool = false,
172
+ forwarded_args: []const []const u8 = &.{},
173
+ slice: LibSlice,
174
+ optimize: []const u8 = "Debug",
175
+ };
176
+
177
+ /// Build the app's embed static library via `zig build lib` (the step
178
+ /// `addApp`/`addMobileLib` register for mobile targets), synthesizing the
179
+ /// generated build graph for non-ejected apps exactly like `native
180
+ /// build`. Returns the installed library path, allocator-owned. Expects
181
+ /// the caller to have chdir'd into the app dir.
182
+ ///
183
+ /// The install prefix is keyed by the slice's target triple
184
+ /// (.native/embed/<triple>): the simulator and device slices — and the
185
+ /// Android tier — all build the same `lib` step, and a single shared
186
+ /// destination let whichever slice built last own the bytes, so an
187
+ /// interleaved run for another target poisoned the next host link. A
188
+ /// private per-triple stage removes the collision; content freshness
189
+ /// within the stage is the compiler's content-addressed cache, never
190
+ /// wall-clock time.
191
+ pub fn buildEmbedLib(allocator: std.mem.Allocator, io: std.Io, app_name: []const u8, options: LibBuildOptions) ![]const u8 {
192
+ const zig_exe = try toolchain.resolveZig(allocator, io, options.base_env, .{ .assume_yes = options.assume_yes });
193
+ defer allocator.free(zig_exe);
194
+
195
+ var argv: std.ArrayList([]const u8) = .empty;
196
+ defer argv.deinit(allocator);
197
+ try argv.appendSlice(allocator, &.{ zig_exe, "build", "lib" });
198
+
199
+ const ejected = buildgraph.fileExists(io, "build.zig");
200
+ var build_file: ?[]const u8 = null;
201
+ defer if (build_file) |path| allocator.free(path);
202
+ if (!ejected) {
203
+ const framework_root = try buildgraph.resolveFrameworkRoot(allocator, io, options.base_env) orelse {
204
+ std.debug.print(
205
+ \\cannot locate the Native SDK toolkit for this app.
206
+ \\Set NATIVE_SDK_PATH to your SDK checkout, or run a
207
+ \\`native` binary that lives inside one (zig-out/bin/native).
208
+ \\
209
+ , .{});
210
+ return error.MissingFramework;
211
+ };
212
+ defer allocator.free(framework_root);
213
+ build_file = try buildgraph.ensureGeneratedBuild(allocator, io, ".", .{
214
+ .app_name = app_name,
215
+ .framework_root = framework_root,
216
+ });
217
+ try argv.appendSlice(allocator, &.{ "--build-file", build_file.? });
218
+ }
219
+
220
+ const cwd_path = try std.process.currentPathAlloc(io, allocator);
221
+ defer allocator.free(cwd_path);
222
+ const prefix = try embedlib.prefixAlloc(allocator, cwd_path, options.slice.zigTriple());
223
+ defer allocator.free(prefix);
224
+ try argv.appendSlice(allocator, &.{ "--prefix", prefix });
225
+
226
+ const target_flag = try std.fmt.allocPrint(allocator, "-Dtarget={s}", .{options.slice.zigTriple()});
227
+ defer allocator.free(target_flag);
228
+ try argv.append(allocator, target_flag);
229
+ const optimize_flag = try std.fmt.allocPrint(allocator, "-Doptimize={s}", .{options.optimize});
230
+ defer allocator.free(optimize_flag);
231
+ if (!hasOptimizeFlag(options.forwarded_args)) try argv.append(allocator, optimize_flag);
232
+ try argv.appendSlice(allocator, options.forwarded_args);
233
+
234
+ try runInherit(io, argv.items, error.ZigBuildFailed);
235
+
236
+ const lib_path = try embedlib.libPathAlloc(allocator, options.slice.zigTriple(), app_name);
237
+ errdefer allocator.free(lib_path);
238
+ if (!buildgraph.fileExists(io, lib_path)) {
239
+ std.debug.print("native: expected the embed library at {s} after `zig build lib` - the app build did not install it\n", .{lib_path});
240
+ return error.ZigBuildFailed;
241
+ }
242
+ return lib_path;
243
+ }
244
+
245
+ pub const DevOptions = struct {
246
+ base_env: *std.process.Environ.Map,
247
+ assume_yes: bool = false,
248
+ forwarded_args: []const []const u8 = &.{},
249
+ /// Simulator device name or UDID (`--device`); picked automatically
250
+ /// when unset (a booted device, else the first available iPhone).
251
+ device: ?[]const u8 = null,
252
+ };
253
+
254
+ /// `native dev --target ios`: build for the simulator, install, launch,
255
+ /// and stream the app log until the app exits or Ctrl-C.
256
+ ///
257
+ /// Markup fragment hot reload is not wired to the simulator yet: the
258
+ /// watcher polls source paths relative to the app process's working
259
+ /// directory through an Io the desktop runner supplies, and the embed
260
+ /// host supplies neither — edit + rerun is the loop today.
261
+ pub fn runDev(allocator: std.mem.Allocator, io: std.Io, options: DevOptions) !void {
262
+ if (!buildgraph.fileExists(io, "app.zon")) {
263
+ std.debug.print(
264
+ \\no app.zon here — `native dev --target ios` runs inside an app directory
265
+ \\(or pass one: `native dev path/to/app --target ios`). Start one with `native init`.
266
+ \\
267
+ , .{});
268
+ return error.MissingManifest;
269
+ }
270
+ const metadata = try manifest_tool.readMetadata(allocator, io, "app.zon");
271
+ const bundle_id = try bundleIdAlloc(allocator, metadata.id);
272
+ defer allocator.free(bundle_id);
273
+
274
+ std.debug.print("native dev (ios): building the embed library ({s}, Debug)\n", .{LibSlice.simulator.zigTriple()});
275
+ const lib_path = try buildEmbedLib(allocator, io, metadata.name, .{
276
+ .base_env = options.base_env,
277
+ .assume_yes = options.assume_yes,
278
+ .forwarded_args = options.forwarded_args,
279
+ .slice = .simulator,
280
+ });
281
+ defer allocator.free(lib_path);
282
+
283
+ // Assemble the .app bundle around the toolkit host.
284
+ const bundle_path = try std.fmt.allocPrint(allocator, ".native/ios/{s}.app", .{metadata.name});
285
+ defer allocator.free(bundle_path);
286
+ const executable_path = try std.fs.path.join(allocator, &.{ bundle_path, metadata.name });
287
+ defer allocator.free(executable_path);
288
+ var cwd = std.Io.Dir.cwd();
289
+ cwd.deleteTree(io, bundle_path) catch {};
290
+ try cwd.createDirPath(io, bundle_path);
291
+ try writeHostSources(io, ".native/ios/host");
292
+
293
+ const info_plist = try infoPlistAlloc(allocator, metadata);
294
+ defer allocator.free(info_plist);
295
+ {
296
+ var bundle_dir = try cwd.openDir(io, bundle_path, .{});
297
+ defer bundle_dir.close(io);
298
+ try bundle_dir.writeFile(io, .{ .sub_path = "Info.plist", .data = info_plist });
299
+ }
300
+
301
+ std.debug.print("native dev (ios): compiling the toolkit UIKit host\n", .{});
302
+ // Content gate before the link: a staged archive built for another
303
+ // target (ELF from the Android tier) must fail here with the real
304
+ // cause, not as a confusing linker error.
305
+ embedlib.requireArchiveClass(allocator, io, lib_path, .macho, LibSlice.simulator.zigTriple()) catch return error.HostCompileFailed;
306
+ try runInherit(io, &.{
307
+ "xcrun", "--sdk", LibSlice.simulator.clangSdk(),
308
+ "clang", "-target", LibSlice.simulator.clangTriple(),
309
+ "-fobjc-arc", "-O2", ".native/ios/host/" ++ host_source_name,
310
+ lib_path, "-framework", "UIKit",
311
+ "-framework", "Metal", "-framework",
312
+ "QuartzCore", "-framework", "Foundation",
313
+ "-framework", "CoreGraphics", "-framework",
314
+ "AVFoundation", "-framework", "ImageIO",
315
+ "-o", executable_path,
316
+ }, error.HostCompileFailed);
317
+ try runInherit(io, &.{ "codesign", "--force", "--sign", "-", bundle_path }, error.HostCompileFailed);
318
+
319
+ const device = options.device orelse try pickSimulatorDevice(allocator, io);
320
+ const device_owned = options.device == null;
321
+ defer if (device_owned) allocator.free(device);
322
+
323
+ std.debug.print("native dev (ios): booting simulator \"{s}\"\n", .{device});
324
+ // Idempotent boot: already-booted devices report an error we ignore.
325
+ runQuiet(allocator, io, &.{ "xcrun", "simctl", "boot", device }) catch {};
326
+ try runInherit(io, &.{ "xcrun", "simctl", "bootstatus", device, "-b" }, error.SimulatorCommandFailed);
327
+
328
+ std.debug.print("native dev (ios): installing {s} ({s})\n", .{ bundle_path, bundle_id });
329
+ try runInherit(io, &.{ "xcrun", "simctl", "install", device, bundle_path }, error.SimulatorCommandFailed);
330
+ runQuiet(allocator, io, &.{ "xcrun", "simctl", "terminate", device, bundle_id }) catch {};
331
+
332
+ std.debug.print(
333
+ \\native dev (ios): launching {s} — streaming the app log (Ctrl-C stops it).
334
+ \\ markup hot reload does not reach the simulator yet: edit, then rerun `native dev --target ios`.
335
+ \\
336
+ , .{bundle_id});
337
+ // --console-pty attaches the app's output to this terminal and keeps
338
+ // the command alive for the app's lifetime — the log stream. The
339
+ // child gets its own process group so Ctrl-C/kill of the CLI also
340
+ // stops the attached session (the simulator app itself is terminated
341
+ // on the next dev run's `simctl terminate`).
342
+ var launch_child = try std.process.spawn(io, .{
343
+ .argv = &.{ "xcrun", "simctl", "launch", "--console-pty", device, bundle_id },
344
+ .stdin = .inherit,
345
+ .stdout = .inherit,
346
+ .stderr = .inherit,
347
+ .pgid = process_tree.spawnPgid(),
348
+ });
349
+ const launch_group: i32 = process_tree.groupId(&launch_child);
350
+ if (launch_group > 0) process_tree.own(launch_group);
351
+ defer if (launch_group > 0) process_tree.releaseAndKill(launch_group);
352
+ _ = try launch_child.wait(io);
353
+ }
354
+
355
+ /// Pick a simulator device: a booted one wins, else the first available
356
+ /// iPhone (booted on demand by the caller).
357
+ pub fn pickSimulatorDevice(allocator: std.mem.Allocator, io: std.Io) ![]const u8 {
358
+ const result = std.process.run(allocator, io, .{
359
+ .argv = &.{ "xcrun", "simctl", "list", "devices", "available" },
360
+ .stdout_limit = .limited(1024 * 1024),
361
+ .stderr_limit = .limited(64 * 1024),
362
+ }) catch {
363
+ std.debug.print("native dev (ios): `xcrun simctl` is unavailable - install Xcode and its iOS simulator runtime\n", .{});
364
+ return error.SimulatorUnavailable;
365
+ };
366
+ defer allocator.free(result.stderr);
367
+ defer allocator.free(result.stdout);
368
+ if (result.term != .exited or result.term.exited != 0) {
369
+ std.debug.print("native dev (ios): `xcrun simctl list` failed - install Xcode and its iOS simulator runtime\n", .{});
370
+ return error.SimulatorUnavailable;
371
+ }
372
+
373
+ if (parseSimulatorDeviceList(result.stdout)) |name| {
374
+ return allocator.dupe(u8, name);
375
+ }
376
+ std.debug.print(
377
+ \\native dev (ios): no available iPhone simulator found.
378
+ \\Install an iOS simulator runtime in Xcode, or pass one explicitly:
379
+ \\ native dev --target ios --device "iPhone 16 Pro"
380
+ \\
381
+ , .{});
382
+ return error.SimulatorUnavailable;
383
+ }
384
+
385
+ /// `simctl list devices available` lines look like
386
+ /// ` iPhone 16 Pro (UDID) (Booted)`; prefer a booted device (any
387
+ /// family — the user chose it), else the first iPhone.
388
+ pub fn parseSimulatorDeviceList(listing: []const u8) ?[]const u8 {
389
+ var first_iphone: ?[]const u8 = null;
390
+ var lines = std.mem.splitScalar(u8, listing, '\n');
391
+ while (lines.next()) |line| {
392
+ const trimmed = std.mem.trim(u8, line, " \t\r");
393
+ if (trimmed.len == 0 or std.mem.startsWith(u8, trimmed, "--") or std.mem.startsWith(u8, trimmed, "==")) continue;
394
+ const paren = std.mem.indexOf(u8, trimmed, " (") orelse continue;
395
+ const name = trimmed[0..paren];
396
+ if (std.mem.indexOf(u8, trimmed, "(Booted)") != null) return name;
397
+ if (first_iphone == null and std.mem.startsWith(u8, name, "iPhone")) first_iphone = name;
398
+ }
399
+ return first_iphone;
400
+ }
401
+
402
+ pub fn hasOptimizeFlag(args: []const []const u8) bool {
403
+ for (args) |arg| {
404
+ if (std.mem.startsWith(u8, arg, "-Doptimize")) return true;
405
+ if (std.mem.startsWith(u8, arg, "--release")) return true;
406
+ }
407
+ return false;
408
+ }
409
+
410
+ /// Spawn with inherited stdio and turn a non-zero exit into `fail_error`
411
+ /// after naming the failed step (never fail in silence).
412
+ fn runInherit(io: std.Io, argv: []const []const u8, fail_error: anyerror) !void {
413
+ var child = try std.process.spawn(io, .{
414
+ .argv = argv,
415
+ .stdin = .ignore,
416
+ .stdout = .inherit,
417
+ .stderr = .inherit,
418
+ });
419
+ const term = try child.wait(io);
420
+ switch (term) {
421
+ .exited => |code| if (code == 0) return,
422
+ else => {},
423
+ }
424
+ std.debug.print("native (ios): `{s}` step failed\n", .{argv[0]});
425
+ return fail_error;
426
+ }
427
+
428
+ /// Run capturing (and discarding) output — for idempotent commands whose
429
+ /// failure chatter would only mislead (`simctl boot` on a booted device).
430
+ fn runQuiet(allocator: std.mem.Allocator, io: std.Io, argv: []const []const u8) !void {
431
+ const result = try std.process.run(allocator, io, .{
432
+ .argv = argv,
433
+ .stdout_limit = .limited(64 * 1024),
434
+ .stderr_limit = .limited(64 * 1024),
435
+ });
436
+ allocator.free(result.stdout);
437
+ allocator.free(result.stderr);
438
+ if (result.term != .exited or result.term.exited != 0) return error.SimulatorCommandFailed;
439
+ }
440
+
441
+ fn xmlEscapeAlloc(allocator: std.mem.Allocator, value: []const u8) ![]u8 {
442
+ var out: std.ArrayList(u8) = .empty;
443
+ errdefer out.deinit(allocator);
444
+ for (value) |ch| {
445
+ switch (ch) {
446
+ '&' => try out.appendSlice(allocator, "&amp;"),
447
+ '<' => try out.appendSlice(allocator, "&lt;"),
448
+ '>' => try out.appendSlice(allocator, "&gt;"),
449
+ '"' => try out.appendSlice(allocator, "&quot;"),
450
+ '\'' => try out.appendSlice(allocator, "&apos;"),
451
+ else => try out.append(allocator, ch),
452
+ }
453
+ }
454
+ return out.toOwnedSlice(allocator);
455
+ }
456
+
457
+ test "bundle ids normalize underscores for the Apple identifier grammar" {
458
+ const mapped = try bundleIdAlloc(std.testing.allocator, "dev.native_sdk.ui_inbox");
459
+ defer std.testing.allocator.free(mapped);
460
+ try std.testing.expectEqualStrings("dev.native-sdk.ui-inbox", mapped);
461
+ }
462
+
463
+ test "host info plist carries app identity and full-screen launch keys" {
464
+ const text = try infoPlistAlloc(std.testing.allocator, .{
465
+ .id = "dev.native_sdk.calculator",
466
+ .name = "calculator",
467
+ .display_name = "Calculator <Pro>",
468
+ .version = "0.2.0",
469
+ });
470
+ defer std.testing.allocator.free(text);
471
+ // The bundle id is normalized for iOS (underscore -> hyphen).
472
+ try std.testing.expect(std.mem.indexOf(u8, text, "<string>dev.native-sdk.calculator</string>") != null);
473
+ try std.testing.expect(std.mem.indexOf(u8, text, "<string>calculator</string>") != null);
474
+ try std.testing.expect(std.mem.indexOf(u8, text, "<string>Calculator &lt;Pro&gt;</string>") != null);
475
+ try std.testing.expect(std.mem.indexOf(u8, text, "<string>0.2.0</string>") != null);
476
+ try std.testing.expect(std.mem.indexOf(u8, text, "UILaunchScreen") != null);
477
+ try std.testing.expect(std.mem.indexOf(u8, text, "UISupportedInterfaceOrientations") != null);
478
+ try std.testing.expect(std.mem.indexOf(u8, text, "CFBundleExecutable") != null);
479
+ // The ATS exception is scoped to local networking only (the dev loop
480
+ // streams media from the Mac); arbitrary loads stay forbidden.
481
+ try std.testing.expect(std.mem.indexOf(u8, text, "NSAllowsLocalNetworking") != null);
482
+ try std.testing.expect(std.mem.indexOf(u8, text, "NSAllowsArbitraryLoads") == null);
483
+ }
484
+
485
+ test "the embedded host sources are the toolkit host" {
486
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkCanvasViewController") != null);
487
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_app_viewport") != null);
488
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_app_set_text_measure") != null);
489
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "_dyld_get_image_header_containing_address") != null);
490
+ try std.testing.expect(std.mem.indexOf(u8, host_header, "native_sdk_app_render_pixels") != null);
491
+ // The audio service: registered before start, session category
492
+ // playback, and the interruption handler that pauses the transport
493
+ // and reports the paused state through one immediate position event.
494
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_app_set_audio_service") != null);
495
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "AVAudioSessionCategoryPlayback") != null);
496
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "AVAudioSessionInterruptionNotification") != null);
497
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "handleSessionInterruption") != null);
498
+ try std.testing.expect(std.mem.indexOf(u8, host_header, "native_sdk_audio_service_t") != null);
499
+ try std.testing.expect(std.mem.indexOf(u8, host_header, "native_sdk_app_audio_event") != null);
500
+ // Platform push/pop navigation: the depth projection poll, the REAL
501
+ // interactive pop recognizer, and the completed gesture's exactly-once
502
+ // back-command dispatch.
503
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_app_chrome_navigation_depth") != null);
504
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "interactivePopGestureRecognizer") != null);
505
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "completeInteractivePop") != null);
506
+ try std.testing.expect(std.mem.indexOf(u8, host_header, "native_sdk_app_chrome_navigation_back_command") != null);
507
+ }
508
+
509
+ test "simulator device parsing prefers booted devices then iPhones" {
510
+ const listing =
511
+ \\== Devices ==
512
+ \\-- iOS 18.0 --
513
+ \\ iPad mini (6th generation) (AA773561-F796-439A-90F4-A92ABFB0251C) (Shutdown)
514
+ \\ iPhone 16 Pro (B8BF491D-D3F4-473F-9453-4C1C8017E912) (Shutdown)
515
+ \\ iPhone 16 (A194A9F7-5979-4B39-A5CF-8EB010CF7160) (Booted)
516
+ \\
517
+ ;
518
+ try std.testing.expectEqualStrings("iPhone 16", parseSimulatorDeviceList(listing).?);
519
+
520
+ const shutdown_only =
521
+ \\-- iOS 18.0 --
522
+ \\ iPad mini (6th generation) (AA773561-F796-439A-90F4-A92ABFB0251C) (Shutdown)
523
+ \\ iPhone 16 Pro (B8BF491D-D3F4-473F-9453-4C1C8017E912) (Shutdown)
524
+ \\
525
+ ;
526
+ try std.testing.expectEqualStrings("iPhone 16 Pro", parseSimulatorDeviceList(shutdown_only).?);
527
+ try std.testing.expectEqual(@as(?[]const u8, null), parseSimulatorDeviceList("== Devices ==\n"));
528
+ }