@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,172 @@
1
+ const std = @import("std");
2
+
3
+ pub const SignResult = struct {
4
+ ok: bool,
5
+ message: []const u8,
6
+ };
7
+
8
+ pub const CodesignArgs = struct {
9
+ app_path: []const u8,
10
+ identity: []const u8 = "-",
11
+ entitlements: ?[]const u8 = null,
12
+ hardened_runtime: bool = false,
13
+ deep: bool = true,
14
+ };
15
+
16
+ pub const NotarizeArgs = struct {
17
+ app_path: []const u8,
18
+ team_id: []const u8,
19
+ apple_id: ?[]const u8 = null,
20
+ password_keychain_item: ?[]const u8 = null,
21
+ };
22
+
23
+ pub fn buildSignCommand(buffer: []u8, args: CodesignArgs) ![]const u8 {
24
+ var writer = std.Io.Writer.fixed(buffer);
25
+ try writer.writeAll("codesign --sign ");
26
+ try writer.writeAll(args.identity);
27
+ try writer.writeAll(" --force");
28
+ if (args.deep) try writer.writeAll(" --deep");
29
+ if (args.hardened_runtime) try writer.writeAll(" --options runtime");
30
+ if (args.entitlements) |ent| {
31
+ try writer.writeAll(" --entitlements ");
32
+ try writer.writeAll(ent);
33
+ }
34
+ try writer.writeAll(" ");
35
+ try writer.writeAll(args.app_path);
36
+ return writer.buffered();
37
+ }
38
+
39
+ pub fn buildNotarizeSubmitCommand(buffer: []u8, zip_path: []const u8, args: NotarizeArgs) ![]const u8 {
40
+ var writer = std.Io.Writer.fixed(buffer);
41
+ try writer.writeAll("xcrun notarytool submit ");
42
+ try writer.writeAll(zip_path);
43
+ try writer.writeAll(" --team-id ");
44
+ try writer.writeAll(args.team_id);
45
+ if (args.apple_id) |apple_id| {
46
+ try writer.writeAll(" --apple-id ");
47
+ try writer.writeAll(apple_id);
48
+ }
49
+ if (args.password_keychain_item) |item| {
50
+ try writer.writeAll(" --password @keychain:");
51
+ try writer.writeAll(item);
52
+ }
53
+ try writer.writeAll(" --wait");
54
+ return writer.buffered();
55
+ }
56
+
57
+ pub fn buildStapleCommand(buffer: []u8, app_path: []const u8) ![]const u8 {
58
+ var writer = std.Io.Writer.fixed(buffer);
59
+ try writer.writeAll("xcrun stapler staple ");
60
+ try writer.writeAll(app_path);
61
+ return writer.buffered();
62
+ }
63
+
64
+ pub fn buildZipCommand(buffer: []u8, app_path: []const u8, zip_path: []const u8) ![]const u8 {
65
+ var writer = std.Io.Writer.fixed(buffer);
66
+ try writer.writeAll("ditto -c -k --keepParent ");
67
+ try writer.writeAll(app_path);
68
+ try writer.writeAll(" ");
69
+ try writer.writeAll(zip_path);
70
+ return writer.buffered();
71
+ }
72
+
73
+ pub fn signAdHoc(io: std.Io, app_path: []const u8) !SignResult {
74
+ return runSign(io, .{ .app_path = app_path, .identity = "-", .deep = true });
75
+ }
76
+
77
+ pub fn signIdentity(io: std.Io, app_path: []const u8, identity: []const u8, entitlements: ?[]const u8) !SignResult {
78
+ return runSign(io, .{
79
+ .app_path = app_path,
80
+ .identity = identity,
81
+ .entitlements = entitlements,
82
+ .hardened_runtime = true,
83
+ .deep = true,
84
+ });
85
+ }
86
+
87
+ pub fn notarize(allocator: std.mem.Allocator, io: std.Io, args: NotarizeArgs) !SignResult {
88
+ const zip_path = try std.fmt.allocPrint(allocator, "{s}.zip", .{args.app_path});
89
+ defer allocator.free(zip_path);
90
+
91
+ var zip_buf: [1024]u8 = undefined;
92
+ const zip_cmd = try buildZipCommand(&zip_buf, args.app_path, zip_path);
93
+ var zip_result = runShell(io, zip_cmd) catch return .{ .ok = false, .message = "failed to zip app for notarization" };
94
+ _ = &zip_result;
95
+
96
+ var submit_buf: [1024]u8 = undefined;
97
+ const submit_cmd = try buildNotarizeSubmitCommand(&submit_buf, zip_path, args);
98
+ runShell(io, submit_cmd) catch return .{ .ok = false, .message = "notarytool submit failed" };
99
+
100
+ var staple_buf: [512]u8 = undefined;
101
+ const staple_cmd = try buildStapleCommand(&staple_buf, args.app_path);
102
+ runShell(io, staple_cmd) catch return .{ .ok = false, .message = "stapler staple failed" };
103
+
104
+ return .{ .ok = true, .message = "notarization complete" };
105
+ }
106
+
107
+ fn runSign(io: std.Io, args: CodesignArgs) !SignResult {
108
+ var buffer: [1024]u8 = undefined;
109
+ const cmd = try buildSignCommand(&buffer, args);
110
+ runShell(io, cmd) catch return .{ .ok = false, .message = "codesign failed" };
111
+ return .{ .ok = true, .message = "signed" };
112
+ }
113
+
114
+ /// Run one shell command and FAIL on a non-zero exit: a codesign that
115
+ /// exits 1 (or a host without codesign at all, exit 127) must surface as
116
+ /// an error so callers record the bundle as unsigned instead of
117
+ /// reporting a signature that does not exist.
118
+ fn runShell(io: std.Io, cmd: []const u8) !void {
119
+ const argv = [_][]const u8{ "sh", "-c", cmd };
120
+ var child = try std.process.spawn(io, .{
121
+ .argv = &argv,
122
+ .stdin = .ignore,
123
+ .stdout = .inherit,
124
+ .stderr = .inherit,
125
+ });
126
+ const term = try child.wait(io);
127
+ switch (term) {
128
+ .exited => |code| if (code != 0) return error.CommandFailed,
129
+ else => return error.CommandFailed,
130
+ }
131
+ }
132
+
133
+ test "ad-hoc sign command is well-formed" {
134
+ var buffer: [512]u8 = undefined;
135
+ const cmd = try buildSignCommand(&buffer, .{ .app_path = "/tmp/Test.app" });
136
+ try std.testing.expectEqualStrings("codesign --sign - --force --deep /tmp/Test.app", cmd);
137
+ }
138
+
139
+ test "identity sign command includes runtime and entitlements" {
140
+ var buffer: [512]u8 = undefined;
141
+ const cmd = try buildSignCommand(&buffer, .{
142
+ .app_path = "/tmp/Test.app",
143
+ .identity = "Developer ID Application: Test",
144
+ .entitlements = "assets/native-sdk.entitlements",
145
+ .hardened_runtime = true,
146
+ });
147
+ try std.testing.expectEqualStrings(
148
+ "codesign --sign Developer ID Application: Test --force --deep --options runtime --entitlements assets/native-sdk.entitlements /tmp/Test.app",
149
+ cmd,
150
+ );
151
+ }
152
+
153
+ test "notarize submit command includes team id and wait" {
154
+ var buffer: [512]u8 = undefined;
155
+ const cmd = try buildNotarizeSubmitCommand(&buffer, "/tmp/Test.app.zip", .{
156
+ .app_path = "/tmp/Test.app",
157
+ .team_id = "ABCD1234",
158
+ });
159
+ try std.testing.expectEqualStrings("xcrun notarytool submit /tmp/Test.app.zip --team-id ABCD1234 --wait", cmd);
160
+ }
161
+
162
+ test "staple command targets app path" {
163
+ var buffer: [256]u8 = undefined;
164
+ const cmd = try buildStapleCommand(&buffer, "/tmp/Test.app");
165
+ try std.testing.expectEqualStrings("xcrun stapler staple /tmp/Test.app", cmd);
166
+ }
167
+
168
+ test "zip command uses ditto" {
169
+ var buffer: [256]u8 = undefined;
170
+ const cmd = try buildZipCommand(&buffer, "/tmp/Test.app", "/tmp/Test.app.zip");
171
+ try std.testing.expectEqualStrings("ditto -c -k --keepParent /tmp/Test.app /tmp/Test.app.zip", cmd);
172
+ }
@@ -0,0 +1,185 @@
1
+ //! Widget-identity proofs for the ejectable components.
2
+ //!
3
+ //! `native eject component <name>` copies the canonical sources next to
4
+ //! this file into an app. These tests are what keeps those copies
5
+ //! honest: each builds the ejected form and the library form against
6
+ //! the same inputs and requires the two widget trees to be IDENTICAL —
7
+ //! every id, every field, every handler — so ejecting is never a visual
8
+ //! or behavioral change, only an ownership change. A library refactor
9
+ //! that drifts a composite's tree fails here until the canonical source
10
+ //! is updated to match.
11
+ //!
12
+ //! This file is its own test module (wired in build.zig as
13
+ //! `test-eject-components`, part of `zig build test`) because the
14
+ //! canonical Zig sources import `native_sdk` exactly as they will
15
+ //! inside an app — compiling them verbatim is half the proof.
16
+
17
+ const std = @import("std");
18
+ const testing = std.testing;
19
+ const native_sdk = @import("native_sdk");
20
+ const canvas = native_sdk.canvas;
21
+
22
+ const stepper_component = @import("stepper.zig");
23
+ const timeline_item_component = @import("timeline_item.zig");
24
+ const timeline_template = @embedFile("timeline.native");
25
+
26
+ /// A stand-in app model/message pair: the composites under test bind no
27
+ /// model state themselves (their inputs arrive as options/args), so an
28
+ /// empty model and one payload-carrying message tag cover the surface.
29
+ const Model = struct {};
30
+ const Msg = union(enum) { open: u32 };
31
+ const Ui = canvas.Ui(Msg);
32
+
33
+ test "ejected stepper builds the library stepper's exact tree" {
34
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
35
+ defer arena_state.deinit();
36
+ const arena = arena_state.allocator();
37
+
38
+ const labels = [_][]const u8{ "Plan", "Work", "Ship" };
39
+ // Every derived step state in one sweep: active in range (mixed
40
+ // completed/active/pending), zero (nothing completed), and past the
41
+ // end (everything completed).
42
+ for ([_]usize{ 1, 0, labels.len }) |active| {
43
+ var library_ui = Ui.init(arena);
44
+ const library_steps = [_]Ui.StepperStep{
45
+ .{ .label = labels[0] }, .{ .label = labels[1] }, .{ .label = labels[2] },
46
+ };
47
+ const library_tree = try library_ui.finalize(library_ui.stepper(.{ .active = active }, &library_steps));
48
+
49
+ var ejected_ui = Ui.init(arena);
50
+ const ejected_steps = [_]stepper_component.Step{
51
+ .{ .label = labels[0] }, .{ .label = labels[1] }, .{ .label = labels[2] },
52
+ };
53
+ const ejected_tree = try ejected_ui.finalize(stepper_component.build(&ejected_ui, .{ .active = active }, &ejected_steps));
54
+
55
+ try testing.expectEqualDeep(library_tree.root, ejected_tree.root);
56
+ try testing.expectEqualDeep(library_tree.handlers, ejected_tree.handlers);
57
+ }
58
+ }
59
+
60
+ test "ejected timeline item builds the library item's exact tree, press handler included" {
61
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
62
+ defer arena_state.deinit();
63
+ const arena = arena_state.allocator();
64
+
65
+ const TimelineItem = timeline_item_component.TimelineItem(Msg);
66
+
67
+ // The full shape: indicator variant, description, meta, connector,
68
+ // selection, and a whole-item press (which grows the chevron and
69
+ // binds the handler on the item root).
70
+ var library_ui = Ui.init(arena);
71
+ const library_tree = try library_ui.finalize(library_ui.timelineItem(.{
72
+ .key = .{ .int = 7 },
73
+ .icon = "check",
74
+ .variant = .primary,
75
+ .title = "Build the release",
76
+ .description = "Compile, test, and package the app",
77
+ .meta = "2m 14s",
78
+ .selected = true,
79
+ .on_press = .{ .open = 7 },
80
+ }));
81
+
82
+ var ejected_ui = Ui.init(arena);
83
+ const ejected_tree = try ejected_ui.finalize(TimelineItem.build(&ejected_ui, .{
84
+ .key = .{ .int = 7 },
85
+ .icon = "check",
86
+ .variant = .primary,
87
+ .title = "Build the release",
88
+ .description = "Compile, test, and package the app",
89
+ .meta = "2m 14s",
90
+ .selected = true,
91
+ .on_press = .{ .open = 7 },
92
+ }));
93
+
94
+ try testing.expectEqualDeep(library_tree.root, ejected_tree.root);
95
+ try testing.expectEqualDeep(library_tree.handlers, ejected_tree.handlers);
96
+ // The press is real in both forms, not just structurally equal.
97
+ try testing.expectEqual(Msg{ .open = 7 }, ejected_tree.msgForPointer(ejected_tree.root.id, .up).?);
98
+
99
+ // The minimal shape: dot indicator (no badge content), title only,
100
+ // no connector, no press — the other half of every conditional.
101
+ var minimal_library_ui = Ui.init(arena);
102
+ const minimal_library = try minimal_library_ui.finalize(minimal_library_ui.timelineItem(.{
103
+ .title = "Queued",
104
+ .connector = false,
105
+ }));
106
+ var minimal_ejected_ui = Ui.init(arena);
107
+ const minimal_ejected = try minimal_ejected_ui.finalize(TimelineItem.build(&minimal_ejected_ui, .{
108
+ .title = "Queued",
109
+ .connector = false,
110
+ }));
111
+ try testing.expectEqualDeep(minimal_library.root, minimal_ejected.root);
112
+ try testing.expectEqualDeep(minimal_library.handlers, minimal_ejected.handlers);
113
+ }
114
+
115
+ /// Build a markup view over the test Model through the interpreter,
116
+ /// resolving imports from an embedded source set (the same loader shape
117
+ /// apps use for their import closures).
118
+ fn buildMarkupTree(arena: std.mem.Allocator, ui: *Ui, root_source: []const u8, files: []const canvas.ui_markup.SourceFile) !Ui.Tree {
119
+ var set_loader = canvas.ui_markup.SourceSetLoader{ .set = files };
120
+ var diagnostic: canvas.ui_markup.MarkupErrorInfo = .{};
121
+ const document = canvas.ui_markup.resolveImports(arena, "app.native", root_source, set_loader.loader(), &diagnostic) catch |err| {
122
+ std.debug.print("markup resolve failed: {s} ({s}:{d}:{d})\n", .{ diagnostic.message, diagnostic.path, diagnostic.line, diagnostic.column });
123
+ return err;
124
+ };
125
+ var interpreter = canvas.MarkupView(Model, Msg).fromDocument(try canvas.ui_markup.canonicalize(arena, document));
126
+ var model = Model{};
127
+ return ui.finalize(try interpreter.build(ui, &model));
128
+ }
129
+
130
+ test "the ejected timeline template builds the library <timeline> element's exact tree" {
131
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
132
+ defer arena_state.deinit();
133
+ const arena = arena_state.allocator();
134
+
135
+ // Identical item children on both sides; only the container differs:
136
+ // the built-in element versus the ejected template reached through
137
+ // <use> (which inlines its body, so ids hash as if written in place).
138
+ const items =
139
+ \\ <timeline-item title="Cloned" description="Fetched the sources" icon="check" variant="primary" />
140
+ \\ <timeline-item title="Building" meta="just now" connector="false" />
141
+ \\
142
+ ;
143
+ const element_source = "<timeline gap=\"4\" label=\"Activity\">\n" ++ items ++ "</timeline>\n";
144
+ const template_source = "<import src=\"components/timeline.native\"/>\n" ++
145
+ "<use template=\"timeline\" gap=\"4\" label=\"Activity\">\n" ++ items ++ "</use>\n";
146
+ const files = [_]canvas.ui_markup.SourceFile{
147
+ .{ .path = "components/timeline.native", .source = timeline_template },
148
+ };
149
+
150
+ var element_ui = Ui.init(arena);
151
+ const element_tree = try buildMarkupTree(arena, &element_ui, element_source, &files);
152
+ var template_ui = Ui.init(arena);
153
+ const template_tree = try buildMarkupTree(arena, &template_ui, template_source, &files);
154
+
155
+ try testing.expectEqualDeep(element_tree.root, template_tree.root);
156
+ try testing.expectEqualDeep(element_tree.handlers.len, template_tree.handlers.len);
157
+ // Spot-check the facts the deep compare rests on: the container is
158
+ // the list-role column the library builds, at the declared gap.
159
+ try testing.expectEqual(canvas.WidgetKind.column, template_tree.root.kind);
160
+ try testing.expectEqual(canvas.WidgetRole.list, template_tree.root.semantics.role);
161
+ try testing.expectEqual(@as(f32, 4), template_tree.root.layout.gap);
162
+ try testing.expectEqualStrings("Activity", template_tree.root.semantics.label);
163
+ try testing.expectEqual(@as(usize, 2), template_tree.root.children.len);
164
+ }
165
+
166
+ test "the ejected timeline template's defaults match the library element's defaults" {
167
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
168
+ defer arena_state.deinit();
169
+ const arena = arena_state.allocator();
170
+
171
+ const items = "<timeline-item title=\"Only\" connector=\"false\" />";
172
+ const element_source = "<timeline>" ++ items ++ "</timeline>";
173
+ const template_source = "<import src=\"components/timeline.native\"/>\n" ++
174
+ "<use template=\"timeline\">" ++ items ++ "</use>";
175
+ const files = [_]canvas.ui_markup.SourceFile{
176
+ .{ .path = "components/timeline.native", .source = timeline_template },
177
+ };
178
+
179
+ var element_ui = Ui.init(arena);
180
+ const element_tree = try buildMarkupTree(arena, &element_ui, element_source, &files);
181
+ var template_ui = Ui.init(arena);
182
+ const template_tree = try buildMarkupTree(arena, &template_ui, template_source, &files);
183
+
184
+ try testing.expectEqualDeep(element_tree.root, template_tree.root);
185
+ }
@@ -0,0 +1,113 @@
1
+ //! Your app's stepper.
2
+ //! Ejected from the Native SDK component library.
3
+ //!
4
+ //! This file now belongs to your app: edit it freely, and SDK updates
5
+ //! never touch it. It builds the same widget tree `ui.stepper` produced
6
+ //! at the moment it was ejected, so migrating a call site is a rename:
7
+ //!
8
+ //! const stepper = @import("components/stepper.zig");
9
+ //!
10
+ //! // before: ui.stepper(.{ .active = model.stage }, &steps)
11
+ //! // after: stepper.build(&ui, .{ .active = model.stage }, &steps)
12
+ //!
13
+ //! The library form stays available — call sites you have not migrated
14
+ //! keep rendering the stock stepper, and deleting this file costs
15
+ //! nothing (`native eject component stepper` writes it again).
16
+ //!
17
+ //! The composition, in one glance: a horizontal row of steps whose
18
+ //! completed/active/pending states derive from `Options.active`.
19
+ //! Indicators are badges — a vector check icon for completed steps, the
20
+ //! step number otherwise — and hairline separators connect the steps.
21
+ //! Display-only: driving `active` belongs to the app model.
22
+
23
+ const std = @import("std");
24
+ const native_sdk = @import("native_sdk");
25
+ const canvas = native_sdk.canvas;
26
+
27
+ /// Visual state of a step, derived from its index against
28
+ /// `Options.active`.
29
+ pub const StepState = enum { completed, active, pending };
30
+
31
+ pub const Step = struct {
32
+ /// Step label ("Work", "Review · round 2").
33
+ label: []const u8,
34
+ };
35
+
36
+ pub const Options = struct {
37
+ /// Index of the active step: earlier steps render completed (check
38
+ /// indicator), later ones pending. An index past the last step
39
+ /// renders every step completed.
40
+ active: usize = 0,
41
+ key: ?canvas.UiKey = null,
42
+ global_key: ?canvas.UiKey = null,
43
+ grow: f32 = 0,
44
+ /// Row semantics; role defaults to `list` (each step is a `listitem`
45
+ /// carrying its label, state, and position).
46
+ semantics: canvas.WidgetSemantics = .{},
47
+ };
48
+
49
+ pub fn stepState(active: usize, index: usize) StepState {
50
+ if (index < active) return .completed;
51
+ if (index == active) return .active;
52
+ return .pending;
53
+ }
54
+
55
+ /// Build the stepper into the app's view. `ui` is the app's typed view
56
+ /// builder (`*canvas.Ui(Msg)`); taking it generically keeps this file
57
+ /// independent of your app's message type.
58
+ pub fn build(ui: anytype, options: Options, steps: []const Step) @TypeOf(ui.*).Node {
59
+ var semantics = options.semantics;
60
+ if (semantics.role == .none) semantics.role = .list;
61
+ const node_count = if (steps.len == 0) 0 else steps.len * 2 - 1;
62
+ const nodes = ui.arena.alloc(@TypeOf(ui.*).Node, node_count) catch {
63
+ ui.failed = true;
64
+ return ui.el(.row, .{ .semantics = semantics }, .{});
65
+ };
66
+ for (steps, 0..) |step, index| {
67
+ nodes[index * 2] = stepNode(ui, options.active, index, steps.len, step);
68
+ if (index + 1 < steps.len) {
69
+ // The connector between steps: a bare separator inside a row
70
+ // renders as a hairline across the space it grows into.
71
+ nodes[index * 2 + 1] = ui.el(.separator, .{ .grow = 1 }, .{});
72
+ }
73
+ }
74
+ return ui.el(.row, .{
75
+ .key = options.key,
76
+ .global_key = options.global_key,
77
+ .gap = 8,
78
+ .cross = .center,
79
+ .grow = options.grow,
80
+ .semantics = semantics,
81
+ }, .{nodes});
82
+ }
83
+
84
+ fn stepNode(ui: anytype, active: usize, index: usize, count: usize, step: Step) @TypeOf(ui.*).Node {
85
+ const state = stepState(active, index);
86
+ // Completed steps wear the vector `check` icon — a check text glyph
87
+ // is outside the bundled font's coverage and would render as a tofu
88
+ // box on the reference/screenshot paths.
89
+ const indicator = ui.el(.badge, .{
90
+ .variant = if (state == .pending) canvas.WidgetVariant.outline else .primary,
91
+ .icon = if (state == .completed) "check" else "",
92
+ .text = if (state == .completed) "" else ui.fmt("{d}", .{index + 1}),
93
+ }, .{});
94
+ const label = switch (state) {
95
+ // The active step reads bold; a single bold span is the wrapped
96
+ // text machinery, so the emphasis costs no second text pipeline.
97
+ .active => ui.paragraph(.{}, &.{.{ .text = step.label, .weight = .bold }}),
98
+ .completed => ui.text(.{}, step.label),
99
+ .pending => ui.text(.{ .style_tokens = .{ .foreground = .text_muted } }, step.label),
100
+ };
101
+ return ui.el(.row, .{
102
+ .key = .{ .int = @intCast(index) },
103
+ .gap = 6,
104
+ .cross = .center,
105
+ .selected = state == .active,
106
+ .semantics = .{
107
+ .role = .listitem,
108
+ .label = ui.fmt("{s} ({s})", .{ step.label, @tagName(state) }),
109
+ .list_item_index = @intCast(index),
110
+ .list_item_count = @intCast(count),
111
+ },
112
+ }, .{ indicator, label });
113
+ }
@@ -0,0 +1,27 @@
1
+ <!-- Your app's timeline container.
2
+ Ejected from the Native SDK component library.
3
+
4
+ This file now belongs to your app: edit it freely, and SDK updates
5
+ never touch it. The template builds the same widget tree the
6
+ built-in <timeline> element produced at the moment it was ejected -
7
+ a list-role column the items flow into - so migrating a call site
8
+ swaps the element for the template:
9
+
10
+ before: <timeline gap="4" label="Activity">...</timeline>
11
+ after: <import src="components/timeline.native"/>
12
+ ...
13
+ <use template="timeline" gap="4" label="Activity">...</use>
14
+
15
+ `timeline` here is a TEMPLATE name, never a new element: templates
16
+ are only reachable through <use>, so the built-in <timeline> element
17
+ keeps meaning what it always did at call sites you have not
18
+ migrated. <timeline-item> children work unchanged inside the <use> -
19
+ they land at the <slot/> below.
20
+
21
+ Deleting this file costs nothing; `native eject component timeline`
22
+ writes it again. -->
23
+ <template name="timeline" args="gap=0 grow=0 label=">
24
+ <column role="list" gap="{gap}" grow="{grow}" label="{label}">
25
+ <slot/>
26
+ </column>
27
+ </template>
@@ -0,0 +1,131 @@
1
+ //! Your app's timeline item.
2
+ //! Ejected from the Native SDK component library.
3
+ //!
4
+ //! This file now belongs to your app: edit it freely, and SDK updates
5
+ //! never touch it. It builds the same widget tree `ui.timelineItem`
6
+ //! produced at the moment it was ejected, so migrating a call site is a
7
+ //! rename (the type takes your app's message union once, because a
8
+ //! pressable item carries a typed `on_press`):
9
+ //!
10
+ //! const timeline_item = @import("components/timeline_item.zig");
11
+ //! const TimelineItem = timeline_item.TimelineItem(Msg);
12
+ //!
13
+ //! // before: ui.timelineItem(.{ .title = run.title, .on_press = .{ .open = run.id } })
14
+ //! // after: TimelineItem.build(&ui, .{ .title = run.title, .on_press = .{ .open = run.id } })
15
+ //!
16
+ //! The library form stays available — call sites you have not migrated
17
+ //! keep rendering the stock item, and deleting this file costs nothing
18
+ //! (`native eject component timeline-item` writes it again).
19
+ //!
20
+ //! The composition, in one glance: a leading status indicator (badge or
21
+ //! dot, plus a hairline connector toward the next item), a
22
+ //! title/description/meta content column, and — when pressable — a
23
+ //! trailing chevron with `on_press` bound to the item's root, so presses
24
+ //! on the plain text fall through to the item.
25
+
26
+ const std = @import("std");
27
+ const native_sdk = @import("native_sdk");
28
+ const canvas = native_sdk.canvas;
29
+
30
+ pub fn TimelineItem(comptime Msg: type) type {
31
+ return struct {
32
+ const Ui = canvas.Ui(Msg);
33
+
34
+ pub const Options = struct {
35
+ key: ?canvas.UiKey = null,
36
+ global_key: ?canvas.UiKey = null,
37
+ /// Indicator badge text ("3"); empty (with no `icon`)
38
+ /// renders a small dot. Prefer `icon` for symbols — text
39
+ /// glyphs outside the bundled font render as tofu boxes on
40
+ /// the reference/screenshot paths.
41
+ indicator: []const u8 = "",
42
+ /// Vector icon indicator (registry name, e.g. "check"):
43
+ /// drawn inside the badge with the variant's tint. Wins the
44
+ /// badge's content slot alongside `indicator` text.
45
+ icon: []const u8 = "",
46
+ /// Indicator color variant — map item outcomes here (primary
47
+ /// for done, destructive for errors, outline for stopped, ...).
48
+ variant: canvas.WidgetVariant = .outline,
49
+ title: []const u8,
50
+ /// Wrapped muted preview under the title.
51
+ description: []const u8 = "",
52
+ /// Muted trailing meta line ("claude · sonnet · 1m 12s").
53
+ meta: []const u8 = "",
54
+ /// Hairline connector from the indicator toward the next
55
+ /// item; clear it on the last item.
56
+ connector: bool = true,
57
+ /// Whole-item press: adds a trailing chevron and binds the
58
+ /// press to the item's root, focusable with role `listitem`.
59
+ /// A click anywhere on the item dispatches — presses on the
60
+ /// title/description/meta text fall through to the root
61
+ /// (dragging still selects the text).
62
+ on_press: ?Msg = null,
63
+ selected: bool = false,
64
+ };
65
+
66
+ pub fn build(ui: *Ui, options: Options) Ui.Node {
67
+ const dot = options.indicator.len == 0 and options.icon.len == 0;
68
+ const indicator = ui.el(.badge, .{
69
+ .variant = options.variant,
70
+ .text = options.indicator,
71
+ .icon = options.icon,
72
+ .width = if (dot) 10 else 0,
73
+ .height = if (dot) 10 else 0,
74
+ }, .{});
75
+ const lead = if (options.connector)
76
+ ui.el(.column, .{ .cross = .center, .gap = 4 }, .{
77
+ indicator,
78
+ ui.el(.separator, .{ .grow = 1, .width = 1 }, .{}),
79
+ })
80
+ else
81
+ ui.el(.column, .{ .cross = .center }, .{indicator});
82
+
83
+ const content_nodes = ui.arena.alloc(Ui.Node, 3) catch {
84
+ ui.failed = true;
85
+ return ui.el(.stack, .{}, .{});
86
+ };
87
+ content_nodes[0] = ui.paragraph(.{}, &.{.{ .text = options.title, .weight = .bold }});
88
+ var content_len: usize = 1;
89
+ if (options.description.len > 0) {
90
+ content_nodes[content_len] = ui.text(.{ .wrap = true, .style_tokens = .{ .foreground = .text_muted } }, options.description);
91
+ content_len += 1;
92
+ }
93
+ if (options.meta.len > 0) {
94
+ content_nodes[content_len] = ui.paragraph(.{}, &.{.{ .text = options.meta, .color = .text_muted, .scale = 0.9 }});
95
+ content_len += 1;
96
+ }
97
+ const content = ui.el(.column, .{ .grow = 1, .gap = 2 }, .{content_nodes[0..content_len]});
98
+
99
+ const item_semantics = canvas.WidgetSemantics{
100
+ .role = .listitem,
101
+ .label = options.title,
102
+ .focusable = options.on_press != null,
103
+ };
104
+ const row_children = ui.arena.alloc(Ui.Node, 3) catch {
105
+ ui.failed = true;
106
+ return ui.el(.stack, .{}, .{});
107
+ };
108
+ row_children[0] = lead;
109
+ row_children[1] = content;
110
+ var row_len: usize = 2;
111
+ if (options.on_press != null) {
112
+ row_children[row_len] = ui.text(.{ .style_tokens = .{ .foreground = .text_muted } }, "›");
113
+ row_len += 1;
114
+ }
115
+ const row_node = ui.el(.row, .{ .gap = 10, .padding = 8 }, .{row_children[0..row_len]});
116
+
117
+ // The press binds to the item's root: a bound handler makes
118
+ // the stack a hit target, and presses on the plain
119
+ // title/description/meta text fall through to it (dragging
120
+ // still selects the text). No overlay, no duplicated
121
+ // handlers.
122
+ return ui.el(.stack, .{
123
+ .key = options.key,
124
+ .global_key = options.global_key,
125
+ .selected = options.selected,
126
+ .semantics = item_semantics,
127
+ .on_press = options.on_press,
128
+ }, .{row_node});
129
+ }
130
+ };
131
+ }
Binary file
Binary file