@native-sdk/cli 0.10.1 → 0.11.0

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 (462) hide show
  1. package/README.md +8 -6
  2. package/bin/native.js +2 -1
  3. package/build/app.zig +320 -60
  4. package/build/corewire.zig +53 -0
  5. package/build/test_shards.zig +49 -0
  6. package/build/ts_run.mjs +3 -3
  7. package/build.zig +1796 -83
  8. package/package.json +19 -14
  9. package/packages/core/compile-surface/core.ts +134 -72
  10. package/packages/core/package-lock.json +75 -357
  11. package/packages/core/package.json +25 -4
  12. package/packages/core/scripts/compiler_command.mjs +17 -12
  13. package/packages/core/scripts/compiler_typecheck.mjs +1 -0
  14. package/packages/core/scripts/gen_declarations.mjs +3 -2
  15. package/packages/core/scripts/gen_service_surface.mjs +22 -10
  16. package/packages/core/scripts/install_scriptc.mjs +182 -0
  17. package/packages/core/scripts/invoke_scriptc.mjs +18 -0
  18. package/packages/core/scripts/merge_static_archives.mjs +6 -1
  19. package/packages/core/scripts/npm_static_spike.mjs +2 -2
  20. package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
  21. package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
  22. package/packages/core/scripts/run_library_compiler.mjs +51 -0
  23. package/packages/core/scripts/run_native_tests.mjs +22 -0
  24. package/packages/core/scripts/scriptc-toolchain.json +101 -0
  25. package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
  26. package/packages/core/scripts/stage_external_core.mjs +57 -1
  27. package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
  28. package/packages/core/sdk/bytes.d.ts +2 -0
  29. package/packages/core/sdk/bytes.ts +86 -0
  30. package/packages/core/sdk/core.d.ts +308 -4
  31. package/packages/core/sdk/core.ts +320 -84
  32. package/packages/core/sdk/events.d.ts +247 -0
  33. package/packages/core/sdk/events.ts +230 -2
  34. package/packages/core/sdk/internal/image_identity.d.ts +7 -0
  35. package/packages/core/sdk/internal/image_identity.ts +71 -0
  36. package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
  37. package/packages/core/sdk/internal/markdown_policy.ts +878 -0
  38. package/packages/core/sdk/text.d.ts +27 -0
  39. package/packages/core/sdk/text.ts +206 -15
  40. package/packages/core/sdk/theme.d.ts +251 -0
  41. package/packages/core/sdk/theme.ts +267 -0
  42. package/packages/core/src/authorization.ts +137 -0
  43. package/packages/core/src/automation_commands.ts +201 -0
  44. package/packages/core/src/automation_interactions.ts +92 -0
  45. package/packages/core/src/bridge_descriptors.ts +104 -0
  46. package/packages/core/src/builtin_coordination.ts +172 -0
  47. package/packages/core/src/canvas_frame_coordination.ts +81 -0
  48. package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
  49. package/packages/core/src/canvas_scene_observation.ts +145 -0
  50. package/packages/core/src/chart_content.ts +161 -0
  51. package/packages/core/src/chart_plans.ts +432 -0
  52. package/packages/core/src/checker.ts +166 -19
  53. package/packages/core/src/code_content.ts +580 -0
  54. package/packages/core/src/command_coordination.ts +140 -0
  55. package/packages/core/src/component_composition.ts +94 -0
  56. package/packages/core/src/component_construction.ts +149 -0
  57. package/packages/core/src/contract.ts +25 -7
  58. package/packages/core/src/control_appearance.ts +232 -0
  59. package/packages/core/src/control_commands.ts +115 -0
  60. package/packages/core/src/control_content.ts +105 -0
  61. package/packages/core/src/control_geometry.ts +107 -0
  62. package/packages/core/src/control_payloads.ts +119 -0
  63. package/packages/core/src/control_primitives.ts +134 -0
  64. package/packages/core/src/devhost.ts +82 -7
  65. package/packages/core/src/devhost_journal.mjs +30 -7
  66. package/packages/core/src/effect_plans.ts +71 -0
  67. package/packages/core/src/flow_measurement.ts +121 -0
  68. package/packages/core/src/font_registry.ts +37 -0
  69. package/packages/core/src/glyph_atlas.ts +86 -0
  70. package/packages/core/src/gpu_packet_preparation.ts +130 -0
  71. package/packages/core/src/gpu_planning.ts +123 -0
  72. package/packages/core/src/gpu_presentation.ts +55 -0
  73. package/packages/core/src/host_flow.ts +89 -0
  74. package/packages/core/src/host_input_regions.ts +165 -0
  75. package/packages/core/src/image_registry.ts +66 -0
  76. package/packages/core/src/indicator_plans.ts +132 -0
  77. package/packages/core/src/infer.ts +150 -8
  78. package/packages/core/src/input_composition.ts +116 -0
  79. package/packages/core/src/intrinsic_measure.ts +100 -0
  80. package/packages/core/src/layout_coordination.ts +207 -0
  81. package/packages/core/src/leaf_plans.ts +134 -0
  82. package/packages/core/src/markup_development.ts +160 -0
  83. package/packages/core/src/measurement_coordination.ts +185 -0
  84. package/packages/core/src/modules.ts +1 -1
  85. package/packages/core/src/motion_sampling.ts +100 -0
  86. package/packages/core/src/paragraph_layout.ts +192 -0
  87. package/packages/core/src/portable_sources.json +74 -0
  88. package/packages/core/src/portable_sources.ts +17 -0
  89. package/packages/core/src/registered_font.ts +93 -0
  90. package/packages/core/src/render_animation_lifecycle.ts +128 -0
  91. package/packages/core/src/render_coordination.ts +170 -0
  92. package/packages/core/src/render_resources.ts +234 -0
  93. package/packages/core/src/runtime_policy.ts +3930 -0
  94. package/packages/core/src/scalar_text.ts +84 -0
  95. package/packages/core/src/service_contract.ts +2 -1
  96. package/packages/core/src/session_codecs.ts +309 -0
  97. package/packages/core/src/shell_admission.ts +126 -0
  98. package/packages/core/src/shell_coordination.ts +93 -0
  99. package/packages/core/src/sqlite_cli.ts +11 -0
  100. package/packages/core/src/status_validation.ts +232 -0
  101. package/packages/core/src/stream_policy.ts +63 -0
  102. package/packages/core/src/surface_recipes.ts +136 -0
  103. package/packages/core/src/system_admission.ts +60 -0
  104. package/packages/core/src/terminal_paint.ts +436 -0
  105. package/packages/core/src/text_document_width.ts +81 -0
  106. package/packages/core/src/text_measurement_cache.ts +69 -0
  107. package/packages/core/src/text_query_layout.ts +179 -0
  108. package/packages/core/src/text_run_layout.ts +410 -0
  109. package/packages/core/src/text_span_queries.ts +355 -0
  110. package/packages/core/src/typed_ast.ts +18 -1
  111. package/packages/core/src/types.ts +7 -5
  112. package/packages/core/src/vector_effects.ts +98 -0
  113. package/packages/core/src/vector_raster.ts +243 -0
  114. package/packages/core/src/view_components.ts +2415 -0
  115. package/packages/core/src/view_coordination.ts +198 -0
  116. package/packages/core/src/view_frontend.ts +980 -0
  117. package/packages/core/src/widget_audits.ts +202 -0
  118. package/packages/core/src/widget_changes.ts +258 -0
  119. package/packages/core/src/widget_metrics.ts +139 -0
  120. package/packages/core/src/widget_motion.ts +171 -0
  121. package/packages/core/src/widget_paint.ts +272 -0
  122. package/packages/core/src/widget_paint_walk.ts +203 -0
  123. package/packages/core/src/widget_presentation.ts +141 -0
  124. package/packages/core/src/widget_routing.ts +262 -0
  125. package/packages/core/src/window_lifecycle.ts +92 -0
  126. package/packages/core/testing/index.ts +430 -0
  127. package/schemas/app.schema.json +13 -0
  128. package/skill-data/core/SKILL.md +2 -2
  129. package/skill-data/native-ui/SKILL.md +76 -17
  130. package/skill-data/ts-core/SKILL.md +113 -9
  131. package/skill-data/ts-services/SKILL.md +1 -1
  132. package/skill-data/ts-services/references/service-surface.md +264 -144
  133. package/src/app_runner/root.zig +25 -12
  134. package/src/app_runner/ts_compiled_view.zig +1631 -0
  135. package/src/app_runner/ts_core_main.zig +143 -10
  136. package/src/app_runner/ts_core_mobile.zig +24 -12
  137. package/src/automation/server.zig +1 -3
  138. package/src/automation/snapshot.zig +9 -637
  139. package/src/automation/snapshot_reference.zig +656 -0
  140. package/src/automation/snapshot_serialization.zig +566 -0
  141. package/src/platform/linux/gtk_host.c +36 -24
  142. package/src/platform/linux/gtk_pixels.h +118 -0
  143. package/src/platform/linux/gtk_pixels_test.c +241 -0
  144. package/src/platform/linux/root.zig +2 -0
  145. package/src/platform/macos/appkit_host.m +188 -30
  146. package/src/platform/macos/pointer_motion_test.m +96 -0
  147. package/src/platform/macos/scroll_driver_test.m +105 -0
  148. package/src/platform/macos/spectrum_bins.h +34 -0
  149. package/src/platform/macos/spectrum_bins_test.c +56 -0
  150. package/src/platform/macos/text_keyboard_test.m +80 -0
  151. package/src/platform/macos/widget_focus_test.m +66 -0
  152. package/src/platform/null_platform.zig +26 -2
  153. package/src/platform/null_platform_tests.zig +13 -0
  154. package/src/platform/root.zig +1 -0
  155. package/src/platform/types.zig +13 -0
  156. package/src/platform/windows/root.zig +2 -0
  157. package/src/platform/windows/webview2_host.cpp +7 -2
  158. package/src/primitives/app_manifest/comptime_scene.zig +1 -1
  159. package/src/primitives/app_manifest/root.zig +2 -0
  160. package/src/primitives/app_manifest/tests.zig +4 -1
  161. package/src/primitives/app_manifest/validation.zig +2 -0
  162. package/src/primitives/canvas/a11y_audit.zig +3 -1
  163. package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
  164. package/src/primitives/canvas/chart_content_policy.zig +75 -0
  165. package/src/primitives/canvas/chart_plan_policy.zig +196 -0
  166. package/src/primitives/canvas/code_content_policy.zig +162 -0
  167. package/src/primitives/canvas/commands.zig +29 -1
  168. package/src/primitives/canvas/component_composition.zig +125 -0
  169. package/src/primitives/canvas/component_composition_policy.zig +44 -0
  170. package/src/primitives/canvas/component_construction_policy.zig +187 -0
  171. package/src/primitives/canvas/container_layout_policy.zig +87 -0
  172. package/src/primitives/canvas/control_appearance_policy.zig +142 -0
  173. package/src/primitives/canvas/control_command_policy.zig +75 -0
  174. package/src/primitives/canvas/control_content_policy.zig +90 -0
  175. package/src/primitives/canvas/control_geometry_policy.zig +165 -0
  176. package/src/primitives/canvas/control_payload_policy.zig +48 -0
  177. package/src/primitives/canvas/control_primitive_policy.zig +129 -0
  178. package/src/primitives/canvas/effect_plan_policy.zig +96 -0
  179. package/src/primitives/canvas/events.zig +1027 -1
  180. package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
  181. package/src/primitives/canvas/frame.zig +92 -23
  182. package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
  183. package/src/primitives/canvas/gpu.zig +10 -0
  184. package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
  185. package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
  186. package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
  187. package/src/primitives/canvas/grid_layout_policy.zig +51 -0
  188. package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
  189. package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
  190. package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
  191. package/src/primitives/canvas/layout_audit.zig +5 -2
  192. package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
  193. package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
  194. package/src/primitives/canvas/markdown.zig +13 -3
  195. package/src/primitives/canvas/markdown_content_policy.zig +227 -0
  196. package/src/primitives/canvas/markdown_image_binding.zig +81 -0
  197. package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
  198. package/src/primitives/canvas/numeric_capabilities.zig +14 -0
  199. package/src/primitives/canvas/reference.zig +12 -6
  200. package/src/primitives/canvas/registered_font_policy.zig +152 -0
  201. package/src/primitives/canvas/render.zig +48 -0
  202. package/src/primitives/canvas/render_cache_policy.zig +184 -0
  203. package/src/primitives/canvas/render_coordination_policy.zig +163 -0
  204. package/src/primitives/canvas/render_damage_policy.zig +160 -0
  205. package/src/primitives/canvas/render_effects.zig +14 -0
  206. package/src/primitives/canvas/render_generic_resources.zig +14 -0
  207. package/src/primitives/canvas/render_images.zig +14 -0
  208. package/src/primitives/canvas/render_layers.zig +14 -0
  209. package/src/primitives/canvas/render_override_policy.zig +119 -0
  210. package/src/primitives/canvas/render_paths.zig +14 -0
  211. package/src/primitives/canvas/render_plan_policy.zig +199 -0
  212. package/src/primitives/canvas/render_resource_policy.zig +476 -0
  213. package/src/primitives/canvas/root.zig +100 -0
  214. package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
  215. package/src/primitives/canvas/serialization.zig +8 -1
  216. package/src/primitives/canvas/surface_layout_policy.zig +36 -0
  217. package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
  218. package/src/primitives/canvas/terminal_grid.zig +10 -696
  219. package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
  220. package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
  221. package/src/primitives/canvas/text.zig +1 -0
  222. package/src/primitives/canvas/text_atlas.zig +113 -0
  223. package/src/primitives/canvas/text_cache_policy.zig +94 -0
  224. package/src/primitives/canvas/text_document_policy.zig +120 -0
  225. package/src/primitives/canvas/text_layout.zig +51 -2
  226. package/src/primitives/canvas/text_layout_cache.zig +29 -0
  227. package/src/primitives/canvas/text_layout_hash.zig +1 -0
  228. package/src/primitives/canvas/text_layout_types.zig +3 -0
  229. package/src/primitives/canvas/text_measure_cache.zig +46 -0
  230. package/src/primitives/canvas/text_measurement_policy.zig +124 -0
  231. package/src/primitives/canvas/text_metrics.zig +23 -0
  232. package/src/primitives/canvas/text_query_policy.zig +156 -0
  233. package/src/primitives/canvas/text_run_policy.zig +252 -0
  234. package/src/primitives/canvas/text_scalar_policy.zig +156 -0
  235. package/src/primitives/canvas/text_span_query_policy.zig +232 -0
  236. package/src/primitives/canvas/text_spans.zig +280 -8
  237. package/src/primitives/canvas/text_tests.zig +10 -0
  238. package/src/primitives/canvas/tokens.zig +38 -0
  239. package/src/primitives/canvas/ui.zig +250 -83
  240. package/src/primitives/canvas/ui_markup.zig +139 -33
  241. package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
  242. package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
  243. package/src/primitives/canvas/ui_markup_contract.zig +146 -14
  244. package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
  245. package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
  246. package/src/primitives/canvas/ui_markup_tests.zig +116 -0
  247. package/src/primitives/canvas/ui_markup_view.zig +258 -32
  248. package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
  249. package/src/primitives/canvas/ui_schema.zig +13 -1
  250. package/src/primitives/canvas/ui_schema_tests.zig +11 -7
  251. package/src/primitives/canvas/ui_tests.zig +1 -0
  252. package/src/primitives/canvas/vector.zig +36 -2
  253. package/src/primitives/canvas/vector_effect_policy.zig +236 -0
  254. package/src/primitives/canvas/vector_raster_policy.zig +190 -0
  255. package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
  256. package/src/primitives/canvas/virtual_extents.zig +99 -3
  257. package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
  258. package/src/primitives/canvas/widget_audit_policy.zig +293 -0
  259. package/src/primitives/canvas/widget_change_policy.zig +298 -0
  260. package/src/primitives/canvas/widget_invalidation.zig +113 -2
  261. package/src/primitives/canvas/widget_layout.zig +673 -128
  262. package/src/primitives/canvas/widget_layout_tests.zig +4 -0
  263. package/src/primitives/canvas/widget_metric_policy.zig +126 -0
  264. package/src/primitives/canvas/widget_metrics.zig +45 -6
  265. package/src/primitives/canvas/widget_paint_policy.zig +166 -0
  266. package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
  267. package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
  268. package/src/primitives/canvas/widget_render.zig +744 -74
  269. package/src/primitives/canvas/widget_render_controls.zig +1217 -133
  270. package/src/primitives/canvas/widget_render_scroll.zig +11 -3
  271. package/src/primitives/canvas/widget_render_style.zig +94 -0
  272. package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
  273. package/src/primitives/canvas/widget_routing.zig +75 -0
  274. package/src/primitives/canvas/widget_routing_policy.zig +135 -0
  275. package/src/primitives/canvas/widget_runtime.zig +20 -1
  276. package/src/primitives/canvas/widget_semantics.zig +25 -0
  277. package/src/primitives/canvas/widget_text_input.zig +86 -23
  278. package/src/primitives/canvas/widget_text_select.zig +1 -0
  279. package/src/primitives/canvas/widget_tree.zig +8 -1
  280. package/src/primitives/canvas/widgets.zig +42 -12
  281. package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
  282. package/src/root.zig +21 -0
  283. package/src/runtime/accessibility_policy.zig +122 -0
  284. package/src/runtime/api.zig +28 -0
  285. package/src/runtime/app_dispatch_policy.zig +68 -0
  286. package/src/runtime/authorization_policy.zig +150 -0
  287. package/src/runtime/automation_command_policy.zig +241 -0
  288. package/src/runtime/automation_interaction_policy.zig +107 -0
  289. package/src/runtime/automation_snapshot.zig +52 -22
  290. package/src/runtime/automation_snapshot_reference.zig +290 -0
  291. package/src/runtime/automation_widget_dispatch.zig +267 -355
  292. package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
  293. package/src/runtime/blob_policy.zig +58 -0
  294. package/src/runtime/blob_reference.zig +64 -0
  295. package/src/runtime/bridge_descriptor_policy.zig +206 -0
  296. package/src/runtime/builtin_bridge.zig +180 -44
  297. package/src/runtime/builtin_coordination_policy.zig +121 -0
  298. package/src/runtime/callback_policy_test_reference.zig +97 -0
  299. package/src/runtime/canvas_drag_policy.zig +94 -0
  300. package/src/runtime/canvas_fonts.zig +38 -10
  301. package/src/runtime/canvas_frame.zig +590 -134
  302. package/src/runtime/canvas_frame_helpers.zig +1 -0
  303. package/src/runtime/canvas_hover_policy.zig +131 -0
  304. package/src/runtime/canvas_images.zig +59 -30
  305. package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
  306. package/src/runtime/canvas_limits.zig +1 -1
  307. package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
  308. package/src/runtime/canvas_scene_observation_policy.zig +181 -0
  309. package/src/runtime/canvas_widget_context_menu.zig +4 -4
  310. package/src/runtime/canvas_widget_display.zig +110 -9
  311. package/src/runtime/canvas_widget_events.zig +718 -328
  312. package/src/runtime/canvas_widget_runtime.zig +437 -81
  313. package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
  314. package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
  315. package/src/runtime/canvas_widget_state.zig +93 -56
  316. package/src/runtime/channel_sources.zig +80 -0
  317. package/src/runtime/command_policy.zig +161 -0
  318. package/src/runtime/component_policy.zig +83 -0
  319. package/src/runtime/core.zig +156 -6
  320. package/src/runtime/desktop_files.zig +189 -0
  321. package/src/runtime/effects.zig +466 -29
  322. package/src/runtime/effects_tests.zig +28 -0
  323. package/src/runtime/file_policy_test_reference.zig +113 -0
  324. package/src/runtime/flow.zig +418 -341
  325. package/src/runtime/flow_reference.zig +1426 -0
  326. package/src/runtime/font_registry_policy.zig +72 -0
  327. package/src/runtime/frame_profile.zig +24 -33
  328. package/src/runtime/gpu_surface_events.zig +97 -35
  329. package/src/runtime/host_event_pump.zig +303 -0
  330. package/src/runtime/host_event_pump_reference.zig +268 -0
  331. package/src/runtime/host_flow_policy.zig +155 -0
  332. package/src/runtime/host_input_regions_policy.zig +156 -0
  333. package/src/runtime/image_registry_policy.zig +94 -0
  334. package/src/runtime/input_composition_policy.zig +138 -0
  335. package/src/runtime/journal_policy.zig +66 -0
  336. package/src/runtime/journal_reference.zig +53 -0
  337. package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
  338. package/src/runtime/markup_development_policy.zig +91 -0
  339. package/src/runtime/media_surface.zig +40 -1
  340. package/src/runtime/motion_sampling_policy.zig +159 -0
  341. package/src/runtime/recording_policy.zig +42 -0
  342. package/src/runtime/render_animation_policy.zig +206 -0
  343. package/src/runtime/replay_policy.zig +66 -0
  344. package/src/runtime/replay_policy_reference.zig +326 -0
  345. package/src/runtime/replay_progress_policy.zig +64 -0
  346. package/src/runtime/replay_progress_reference.zig +34 -0
  347. package/src/runtime/request_policy_test_reference.zig +188 -0
  348. package/src/runtime/root.zig +13 -0
  349. package/src/runtime/session_blobs.zig +157 -58
  350. package/src/runtime/session_blobs_reference.zig +692 -0
  351. package/src/runtime/session_codec.zig +361 -0
  352. package/src/runtime/session_codec_reference.zig +1027 -0
  353. package/src/runtime/session_journal.zig +246 -983
  354. package/src/runtime/session_record.zig +224 -45
  355. package/src/runtime/session_replay.zig +157 -415
  356. package/src/runtime/session_tests.zig +552 -0
  357. package/src/runtime/shell_admission_policy.zig +225 -0
  358. package/src/runtime/shell_coordination_policy.zig +138 -0
  359. package/src/runtime/shell_layout.zig +126 -1
  360. package/src/runtime/snapshot_policy.zig +60 -0
  361. package/src/runtime/snapshot_reference.zig +64 -0
  362. package/src/runtime/state.zig +16 -0
  363. package/src/runtime/status_validation.zig +190 -0
  364. package/src/runtime/system_admission_policy.zig +140 -0
  365. package/src/runtime/system_services.zig +46 -36
  366. package/src/runtime/tests.zig +1 -0
  367. package/src/runtime/ts_canvas_hooks.zig +261 -0
  368. package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
  369. package/src/runtime/ts_canvas_icons.zig +234 -0
  370. package/src/runtime/ts_core_host.zig +2325 -411
  371. package/src/runtime/ts_core_host_tests.zig +1982 -0
  372. package/src/runtime/ts_test_host.zig +699 -0
  373. package/src/runtime/ts_ui_app.zig +1087 -45
  374. package/src/runtime/ui_app.zig +1117 -629
  375. package/src/runtime/ui_app_provenance.zig +147 -5
  376. package/src/runtime/ui_app_provenance_reference.zig +370 -0
  377. package/src/runtime/ui_app_tests.zig +619 -9
  378. package/src/runtime/ui_app_window_tests.zig +89 -0
  379. package/src/runtime/view.zig +25 -0
  380. package/src/runtime/view_canvas.zig +30 -6
  381. package/src/runtime/view_coordination_policy.zig +147 -0
  382. package/src/runtime/view_widget_control.zig +51 -14
  383. package/src/runtime/view_widget_scroll.zig +16 -5
  384. package/src/runtime/view_widget_text.zig +153 -68
  385. package/src/runtime/view_widget_tree.zig +460 -56
  386. package/src/runtime/webview_view_bridge_tests.zig +2 -0
  387. package/src/runtime/widget_motion_policy.zig +238 -0
  388. package/src/runtime/window_command_bridge_tests.zig +63 -0
  389. package/src/runtime/window_lifecycle_policy.zig +127 -0
  390. package/src/runtime/window_storage.zig +74 -8
  391. package/src/runtime/window_view_runtime.zig +148 -33
  392. package/src/runtime/window_views.zig +163 -10
  393. package/src/tooling/components/identity_tests.zig +62 -36
  394. package/src/tooling/components/stepper.native +24 -0
  395. package/src/tooling/components/stepper.zig +0 -19
  396. package/src/tooling/components/timeline-item.native +22 -0
  397. package/src/tooling/components/timeline.native +5 -3
  398. package/src/tooling/components/timeline_item.zig +0 -32
  399. package/src/tooling/eject_components.zig +76 -8
  400. package/src/tooling/ios.zig +66 -12
  401. package/src/tooling/manifest.zig +35 -0
  402. package/src/tooling/raw_manifest.zig +6 -0
  403. package/src/tooling/templates.zig +15 -3
  404. package/src/tooling/ts_core.zig +13 -3
  405. package/src/tooling/verbs.zig +22 -0
  406. package/tools/corewire/build_profile.mjs +54 -0
  407. package/tools/corewire/contract_intake.ts +303 -0
  408. package/tools/corewire/contract_intake.zig +82 -0
  409. package/tools/corewire/core.test.ts +166 -0
  410. package/tools/corewire/core_abi.zig +51 -0
  411. package/tools/corewire/core_cases.ts +233 -0
  412. package/tools/corewire/core_contract.ts +407 -0
  413. package/tools/corewire/core_emission.ts +136 -0
  414. package/tools/corewire/core_emission.zig +69 -0
  415. package/tools/corewire/core_goldens.json +3110 -0
  416. package/tools/corewire/core_policy.ts +14 -0
  417. package/tools/corewire/core_policy.zig +48 -0
  418. package/tools/corewire/core_projection.ts +360 -0
  419. package/tools/corewire/core_vocabulary.ts +6 -0
  420. package/tools/corewire/emit.zig +19 -1590
  421. package/tools/corewire/emit_facade.ts +714 -0
  422. package/tools/corewire/emit_facade.zig +10 -3752
  423. package/tools/corewire/emit_mirror.ts +290 -0
  424. package/tools/corewire/emit_profile.ts +50 -0
  425. package/tools/corewire/emit_service.ts +331 -0
  426. package/tools/corewire/emit_service.zig +23 -842
  427. package/tools/corewire/entry.test.ts +95 -0
  428. package/tools/corewire/entry_coordination.ts +127 -0
  429. package/tools/corewire/entry_coordination.zig +190 -0
  430. package/tools/corewire/facade_templates.ts +85 -0
  431. package/tools/corewire/filesystem.test.ts +166 -0
  432. package/tools/corewire/filesystem_coordination.ts +213 -0
  433. package/tools/corewire/filesystem_coordination.zig +245 -0
  434. package/tools/corewire/intake.test.ts +35 -0
  435. package/tools/corewire/intake_cases.ts +55 -0
  436. package/tools/corewire/intake_goldens.json +12237 -0
  437. package/tools/corewire/invocation.test.ts +24 -0
  438. package/tools/corewire/invocation.ts +175 -0
  439. package/tools/corewire/invocation.zig +136 -0
  440. package/tools/corewire/invocation_cases.ts +60 -0
  441. package/tools/corewire/invocation_fixture.ts +33 -0
  442. package/tools/corewire/invocation_goldens.json +1143 -0
  443. package/tools/corewire/invocation_tests.zig +111 -0
  444. package/tools/corewire/invocation_usage.ts +2 -0
  445. package/tools/corewire/lossless_projection.ts +96 -0
  446. package/tools/corewire/main.zig +7 -680
  447. package/tools/corewire/main_reference.zig +415 -0
  448. package/tools/corewire/mirror_templates.ts +55 -0
  449. package/tools/corewire/profile.test.ts +248 -0
  450. package/tools/corewire/profile.zig +56 -0
  451. package/tools/corewire/profile_emission.ts +202 -0
  452. package/tools/corewire/profile_library.json +29 -0
  453. package/tools/corewire/profile_tests.zig +136 -0
  454. package/tools/corewire/service.test.ts +75 -0
  455. package/tools/corewire/service_cases.ts +61 -0
  456. package/tools/corewire/service_contract.zig +40 -146
  457. package/tools/corewire/service_goldens.json +650 -0
  458. package/tools/corewire/service_projection.zig +52 -0
  459. package/tools/corewire/service_templates.ts +14 -0
  460. package/tools/corewire/shim_rt.zig +9 -0
  461. package/tools/corewire/sidecar.zig +267 -1438
  462. package/tools/corewire/emit_profile.zig +0 -521
package/build/app.zig CHANGED
@@ -122,6 +122,10 @@ const WebLayerOption = web_layer_contract.WebViewLayer;
122
122
 
123
123
  pub const AppOptions = struct {
124
124
  name: []const u8,
125
+ /// Expose the embed archive on a desktop host as well as mobile targets.
126
+ /// The core is staged through the ordinary app build, including compiled
127
+ /// TypeScript wiring, before addMobileLib consumes it.
128
+ mobile_lib: bool = false,
125
129
  /// Explicit manifest path. Null auto-detects app.json first, then app.zon,
126
130
  /// so older owned build.zig files can adopt JSON without a build edit.
127
131
  manifest: ?[]const u8 = null,
@@ -201,7 +205,7 @@ const TsWindowView = struct {
201
205
  staged_path: []const u8,
202
206
  };
203
207
 
204
- const TsWindowSource = struct {
208
+ const TsMarkupSource = struct {
205
209
  set_path: []const u8,
206
210
  source_path: []const u8,
207
211
  staged_path: []const u8,
@@ -209,9 +213,52 @@ const TsWindowSource = struct {
209
213
 
210
214
  const TsWindowViews = struct {
211
215
  views: []const TsWindowView,
212
- sources: []const TsWindowSource,
216
+ sources: []const TsMarkupSource,
213
217
  };
214
218
 
219
+ const TsAppMarkupSources = struct {
220
+ /// Non-root, non-window files discovered under src/. Window files are
221
+ /// staged by the existing secondary-window registry and must not be
222
+ /// copied a second time.
223
+ files: []const TsMarkupSource,
224
+ /// The root view's embedded resolver set. Its path keys are relative to
225
+ /// src/, matching the root disk watcher; existing window sources are
226
+ /// projected under their staged `windows/...` names.
227
+ sources: []const TsMarkupSource,
228
+ };
229
+
230
+ const max_markup_source_path_len = 200;
231
+ const max_markup_source_path_segments = 24;
232
+ const root_markup_source_prefix = "src/";
233
+
234
+ /// Whether a path relative to `src/` fits the markup resolver once the
235
+ /// generated desktop watch and `native check` address it as `src/<path>`.
236
+ /// The compiled source set drops that prefix, but accepting a path only the
237
+ /// compiled resolver can represent would make development and release
238
+ /// disagree at the boundary.
239
+ pub fn markupSourcePathWithinBudget(path: []const u8) bool {
240
+ var segments: usize = 1; // the disk resolver's leading `src` segment
241
+ var it = std.mem.tokenizeScalar(u8, path, '/');
242
+ while (it.next() != null) segments += 1;
243
+ return root_markup_source_prefix.len + path.len <= max_markup_source_path_len and
244
+ segments <= max_markup_source_path_segments;
245
+ }
246
+
247
+ fn validateMarkupSourcePath(path: []const u8) void {
248
+ if (!markupSourcePathWithinBudget(path)) {
249
+ std.debug.panic(
250
+ "\nTypeScript markup source path `src/{s}` exceeds the import resolver budget: the full app-relative path, including `src/`, must be at most {d} bytes and {d} segments\n",
251
+ .{ path, max_markup_source_path_len, max_markup_source_path_segments },
252
+ );
253
+ }
254
+ }
255
+
256
+ pub fn isRootMarkupSourcePath(path: []const u8) bool {
257
+ return std.mem.endsWith(u8, path, ".native") and
258
+ !std.mem.eql(u8, path, "app.native") and
259
+ !std.mem.startsWith(u8, path, "windows/");
260
+ }
261
+
215
262
  /// Default TypeScript secondary-window views are statically discovered under
216
263
  /// `src/windows/`: `settings.native` serves descriptor label `settings`.
217
264
  /// Direct files form the generated launcher's closed, comptime-compiled view
@@ -224,7 +271,7 @@ fn collectTsWindowViews(b: *std.Build, app_root: []const u8) TsWindowViews {
224
271
  var walker = dir.walk(b.allocator) catch return .{ .views = &.{}, .sources = &.{} };
225
272
  defer walker.deinit();
226
273
  var views: std.ArrayList(TsWindowView) = .empty;
227
- var sources: std.ArrayList(TsWindowSource) = .empty;
274
+ var sources: std.ArrayList(TsMarkupSource) = .empty;
228
275
  while (walker.next(b.graph.io) catch null) |entry| {
229
276
  if (entry.kind != .file or !std.mem.endsWith(u8, entry.path, ".native")) continue;
230
277
  const normalized_path = b.dupe(entry.path);
@@ -261,14 +308,85 @@ fn collectTsWindowViews(b: *std.Build, app_root: []const u8) TsWindowViews {
261
308
  }.than;
262
309
  std.mem.sort(TsWindowView, views.items, {}, less);
263
310
  const source_less = struct {
264
- fn than(_: void, a: TsWindowSource, z: TsWindowSource) bool {
311
+ fn than(_: void, a: TsMarkupSource, z: TsMarkupSource) bool {
265
312
  return std.mem.order(u8, a.set_path, z.set_path) == .lt;
266
313
  }
267
314
  }.than;
268
- std.mem.sort(TsWindowSource, sources.items, {}, source_less);
315
+ std.mem.sort(TsMarkupSource, sources.items, {}, source_less);
269
316
  return .{ .views = views.items, .sources = sources.items };
270
317
  }
271
318
 
319
+ /// The root TypeScript view resolves imports from every `.native` file under
320
+ /// `src/` except itself. Window files already come from collectTsWindowViews;
321
+ /// append those under `windows/...` keys so this set matches the root disk
322
+ /// resolver without changing the separate window resolver root.
323
+ fn collectAppMarkupSources(b: *std.Build, app_root: []const u8, window_views: TsWindowViews) TsAppMarkupSources {
324
+ const src_path = appPath(b, app_root, "src");
325
+ var dir = b.build_root.handle.openDir(b.graph.io, src_path, .{ .iterate = true }) catch
326
+ return .{ .files = &.{}, .sources = &.{} };
327
+ defer dir.close(b.graph.io);
328
+ var walker = dir.walk(b.allocator) catch return .{ .files = &.{}, .sources = &.{} };
329
+ defer walker.deinit();
330
+
331
+ var files: std.ArrayList(TsMarkupSource) = .empty;
332
+ while (walker.next(b.graph.io) catch null) |entry| {
333
+ if (entry.kind != .file or !std.mem.endsWith(u8, entry.path, ".native")) continue;
334
+ const normalized_path = b.dupe(entry.path);
335
+ for (normalized_path) |*char| {
336
+ if (char.* == '\\') char.* = '/';
337
+ }
338
+ if (!isRootMarkupSourcePath(normalized_path)) continue;
339
+ validateMarkupSourcePath(normalized_path);
340
+ files.append(b.allocator, .{
341
+ .set_path = normalized_path,
342
+ .source_path = b.fmt("src/{s}", .{normalized_path}),
343
+ .staged_path = normalized_path,
344
+ }) catch @panic("OOM");
345
+ }
346
+
347
+ const less = struct {
348
+ fn than(_: void, a: TsMarkupSource, z: TsMarkupSource) bool {
349
+ return std.mem.order(u8, a.set_path, z.set_path) == .lt;
350
+ }
351
+ }.than;
352
+ std.mem.sort(TsMarkupSource, files.items, {}, less);
353
+
354
+ var sources: std.ArrayList(TsMarkupSource) = .empty;
355
+ sources.ensureTotalCapacity(b.allocator, files.items.len + window_views.sources.len) catch @panic("OOM");
356
+ sources.appendSliceAssumeCapacity(files.items);
357
+ for (window_views.sources) |source| {
358
+ validateMarkupSourcePath(source.staged_path);
359
+ sources.appendAssumeCapacity(.{
360
+ .set_path = source.staged_path,
361
+ .source_path = source.source_path,
362
+ .staged_path = source.staged_path,
363
+ });
364
+ }
365
+ std.mem.sort(TsMarkupSource, sources.items, {}, less);
366
+ return .{ .files = files.items, .sources = sources.items };
367
+ }
368
+
369
+ fn tsAppMarkupSourcesSource(b: *std.Build, registry: TsAppMarkupSources) []const u8 {
370
+ var out: std.ArrayList(u8) = .empty;
371
+ out.appendSlice(b.allocator,
372
+ \\//! Generated by build/app.zig from src/**/*.native.
373
+ \\const native_sdk = @import("native_sdk");
374
+ \\const canvas = native_sdk.canvas;
375
+ \\pub const sources = [_]canvas.ui_markup.SourceFile{
376
+ \\
377
+ ) catch @panic("OOM");
378
+ for (registry.sources) |source| {
379
+ const line = std.fmt.allocPrint(
380
+ b.allocator,
381
+ " .{{ .path = \"{f}\", .source = @embedFile(\"{f}\") }},\n",
382
+ .{ std.zig.fmtString(source.set_path), std.zig.fmtString(source.staged_path) },
383
+ ) catch @panic("OOM");
384
+ out.appendSlice(b.allocator, line) catch @panic("OOM");
385
+ }
386
+ out.appendSlice(b.allocator, "};\n") catch @panic("OOM");
387
+ return out.items;
388
+ }
389
+
272
390
  fn tsWindowRegistrySource(b: *std.Build, registry: TsWindowViews) []const u8 {
273
391
  const views = registry.views;
274
392
  var out: std.ArrayList(u8) = .empty;
@@ -369,6 +487,10 @@ const TsCoreStage = struct {
369
487
  /// mirror/registry files): the embed static library's `app`
370
488
  /// module roots here on iOS/Android targets.
371
489
  mobile_root: std.Build.LazyPath,
490
+ /// Release/mobile-only module embedding src/app.native. It lives in a
491
+ /// separate generated directory so a Debug app-code module never gains
492
+ /// the root markup as a transitive file input; Debug links markup_c.
493
+ app_markup_root: std.Build.LazyPath,
372
494
  /// The compiled-core archive: the app module links it (with libc,
373
495
  /// for the toolchain's runtime) beside the staged mirror.
374
496
  archive: std.Build.LazyPath,
@@ -708,22 +830,32 @@ fn tsParseQuotedManifestValue(manifest_json: []const u8, comptime key: []const u
708
830
  return suffix;
709
831
  }
710
832
 
711
- /// PR 166 adds both the published compile-cache bootstrap and the optional
712
- /// library-profile optimization field. The installed bootstrap is therefore
713
- /// the capability marker: keep older exact pins byte-for-byte compatible;
714
- /// once that release is installed, Debug/native-dev gets `dev` and
715
- /// release/package artifacts get `release` automatically.
833
+ /// App and root fixture builds share the same scriptc optimization policy.
834
+ pub fn scriptcOptimizationForMode(optimize: std.builtin.OptimizeMode) []const u8 {
835
+ return if (optimize == .Debug) "dev" else "release";
836
+ }
837
+
838
+ /// The library-profile optimization field first shipped with the Node
839
+ /// bootstrap. scriptc installs a native binary instead, so either
840
+ /// published entrypoint marks a compiler that accepts the field.
716
841
  fn scriptcProfileOptimization(b: *std.Build, dep: *std.Build.Dependency, optimize: std.builtin.OptimizeMode) ?[]const u8 {
717
842
  const sdk_root = tsSdkRoot(b.allocator, b.graph.io, dep);
843
+ const release_marker = b.pathJoin(&.{ sdk_root, "packages", "core", "scripts", "scriptc-toolchain.json" });
844
+ if (std.Io.Dir.cwd().access(b.graph.io, release_marker, .{})) |_| {
845
+ return scriptcOptimizationForMode(optimize);
846
+ } else |_| {}
718
847
  var dir: []const u8 = b.pathJoin(&.{ sdk_root, "packages", "core" });
719
848
  while (true) {
720
849
  if (!std.mem.eql(u8, std.fs.path.basename(dir), "node_modules")) {
721
- const marker = b.pathJoin(&.{ dir, "node_modules", "scriptc", "dist", "bootstrap.js" });
722
- std.Io.Dir.cwd().access(b.graph.io, marker, .{}) catch {
723
- dir = std.fs.path.dirname(dir) orelse return null;
724
- continue;
850
+ const native_marker = b.pathJoin(&.{ dir, "node_modules", "scriptc", "bin", "scriptc.exe" });
851
+ std.Io.Dir.cwd().access(b.graph.io, native_marker, .{}) catch {
852
+ const bootstrap_marker = b.pathJoin(&.{ dir, "node_modules", "scriptc", "dist", "bootstrap.js" });
853
+ std.Io.Dir.cwd().access(b.graph.io, bootstrap_marker, .{}) catch {
854
+ dir = std.fs.path.dirname(dir) orelse return null;
855
+ continue;
856
+ };
725
857
  };
726
- return if (optimize == .Debug) "dev" else "release";
858
+ return scriptcOptimizationForMode(optimize);
727
859
  }
728
860
  dir = std.fs.path.dirname(dir) orelse return null;
729
861
  }
@@ -857,9 +989,11 @@ fn tsCoreStage(
857
989
  service_pool_workers: ?u8,
858
990
  build_trace: bool,
859
991
  scriptc_optimization: ?[]const u8,
992
+ typescript_view: bool,
860
993
  ) TsCoreStage {
861
994
  const node = tsCorePreflight(b, dep, app_root);
862
995
  const window_views = collectTsWindowViews(b, app_root);
996
+ const app_markup_sources = collectAppMarkupSources(b, app_root, window_views);
863
997
  const has_services = appHasServiceFiles(b, app_root);
864
998
  if (!scriptcCompileSupported(b.graph.host.result, target)) {
865
999
  panicUnsupportedScriptcTarget(b, b.graph.host.result, target);
@@ -914,7 +1048,7 @@ fn tsCoreStage(
914
1048
  }
915
1049
  sqlite_check.addFileInput(dep.path("packages/core/src/sqlite_codegen.ts"));
916
1050
  sqlite_check.addFileInput(dep.path("packages/core/src/sqlite_runtime_policy.ts"));
917
- for ([_][]const u8{ "events.ts", "text.ts", "bytes_text_methods.d.ts", "events.d.ts", "text.d.ts" }) |source| {
1051
+ for ([_][]const u8{ "bytes.ts", "bytes.d.ts", "events.ts", "text.ts", "bytes_text_methods.d.ts", "events.d.ts", "text.d.ts", "theme.ts", "theme.d.ts", "internal/image_identity.ts", "internal/image_identity.d.ts", "internal/markdown_policy.ts", "internal/markdown_policy.d.ts" }) |source| {
918
1052
  sqlite_check.addFileInput(dep.path(b.fmt("packages/core/sdk/{s}", .{source})));
919
1053
  }
920
1054
  addAppSqlDirInputs(b, sqlite_check, appPath(b, app_root, "src"));
@@ -986,7 +1120,7 @@ fn tsCoreStage(
986
1120
  // corewire, compiled from the SDK dependency for the build host: one
987
1121
  // invocation projects the generated compile entry and its profile,
988
1122
  // so the profile's entry spelling and the facade file can never skew.
989
- const corewire_exe = corewireExe(b, dep);
1123
+ const corewire_exe = @import("corewire.zig").executable(b, dep.builder, node, .Debug, useLlvmWorkaround(b.graph.host));
990
1124
  const project = b.addRunArtifact(corewire_exe);
991
1125
  project.setName("native corewire (core facade + profile)");
992
1126
  project.addArg("--sidecar");
@@ -1059,6 +1193,8 @@ fn tsCoreStage(
1059
1193
  if (build_trace) service_compile.setEnvironmentVariable("SCRIPTC_TIMING", "1");
1060
1194
  service_compile.addFileArg(dep.path("packages/core/scripts/run_external_service_compiler.mjs"));
1061
1195
  service_compile.addFileInput(dep.path("packages/core/scripts/compiler_command.mjs"));
1196
+ service_compile.addFileInput(dep.path("packages/core/scripts/scriptc_toolchain.mjs"));
1197
+ service_compile.addFileInput(dep.path("packages/core/scripts/scriptc-toolchain.json"));
1062
1198
  service_compile.addArg("--stage");
1063
1199
  service_compile.addDirectoryArg(service_stage_dir);
1064
1200
  service_compile.addArg("--manifest");
@@ -1113,6 +1249,19 @@ fn tsCoreStage(
1113
1249
  stage_run.addFileArg(facade);
1114
1250
  stage_run.addArg("--profile");
1115
1251
  stage_run.addFileArg(profile);
1252
+ addViewFrontendInputs(b, dep.builder, stage_run);
1253
+ if (typescript_view) {
1254
+ stage_run.addArg("--view-markup");
1255
+ stage_run.addFileArg(b.path(appPath(b, app_root, "src/app.native")));
1256
+ stage_run.addArg("--view-contract");
1257
+ stage_run.addFileArg(contract);
1258
+ for (app_markup_sources.files) |source| {
1259
+ stage_run.addFileInput(b.path(appPath(b, app_root, source.source_path)));
1260
+ }
1261
+ for (window_views.sources) |source| {
1262
+ stage_run.addFileInput(b.path(appPath(b, app_root, source.source_path)));
1263
+ }
1264
+ }
1116
1265
  if (service_client) |client| {
1117
1266
  stage_run.addArg("--services-client");
1118
1267
  stage_run.addFileArg(client);
@@ -1137,6 +1286,9 @@ fn tsCoreStage(
1137
1286
  if (build_trace) compile.setEnvironmentVariable("SCRIPTC_TIMING", "1");
1138
1287
  compile.addFileArg(dep.path("packages/core/scripts/run_external_core_compiler.mjs"));
1139
1288
  compile.addFileInput(dep.path("packages/core/scripts/compiler_command.mjs"));
1289
+ compile.addFileInput(dep.path("packages/core/scripts/scriptc_toolchain.mjs"));
1290
+ compile.addFileInput(dep.path("packages/core/scripts/scriptc-toolchain.json"));
1291
+ compile.addFileInput(dep.path("packages/core/scripts/run_library_compiler.mjs"));
1140
1292
  compile.addArg("--stage");
1141
1293
  compile.addDirectoryArg(stage_dir);
1142
1294
  compile.addArgs(&.{ "--name", symbol_name });
@@ -1182,6 +1334,7 @@ fn tsCoreStage(
1182
1334
  _ = staged.addCopyFile(shim, "core.zig");
1183
1335
  _ = staged.addCopyFile(dep.path("tools/corewire/shim_rt.zig"), "shim_rt.zig");
1184
1336
  _ = staged.addCopyFile(dep.path("tools/corewire/core_abi.zig"), "core_abi.zig");
1337
+ _ = staged.addCopyFile(dep.path("src/app_runner/ts_compiled_view.zig"), "compiled_view.zig");
1185
1338
  _ = staged.addCopyFile(service_registry, "services.zig");
1186
1339
  // The carrier selection, as one staged constant module: the generated
1187
1340
  // wiring comptime-switches its service transport on it.
@@ -1195,9 +1348,19 @@ fn tsCoreStage(
1195
1348
  \\
1196
1349
  , .{ service_carrier, service_pool_workers }));
1197
1350
  _ = staged.addCopyFile(migrations_zig, "migrations.zig");
1351
+ // Every imported file is an input to Debug's embedded source resolver and
1352
+ // the release/mobile compiled view, so stage those beside the runner.
1353
+ // Keep the ROOT out of this directory: changing any file in one WriteFiles
1354
+ // output changes its directory identity, and the runner lives here. Root
1355
+ // markup gets a separate release-only module below; Debug keeps the small
1356
+ // linked C data object, preserving its link-only edit path.
1357
+ for (app_markup_sources.files) |source| {
1358
+ _ = staged.addCopyFile(b.path(appPath(b, app_root, source.source_path)), source.staged_path);
1359
+ }
1198
1360
  // Primary markup bytes live in their own tiny C translation unit. They
1199
- // no longer participate in Zig source analysis, so a markup edit reuses
1200
- // the compiled app/SDK graph and performs only C data compile + relink.
1361
+ // drive Debug desktop without participating in Zig source analysis, so a
1362
+ // root markup edit there reuses the compiled app/SDK graph and performs
1363
+ // only C data compile + relink.
1201
1364
  const markup_embed = b.addSystemCommand(&.{node});
1202
1365
  markup_embed.setName("native embed primary markup data");
1203
1366
  markup_embed.addFileArg(dep.path("packages/core/scripts/embed_markup_c.mjs"));
@@ -1206,15 +1369,24 @@ fn tsCoreStage(
1206
1369
  for (window_views.sources) |source| {
1207
1370
  _ = staged.addCopyFile(b.path(appPath(b, app_root, source.source_path)), source.staged_path);
1208
1371
  }
1209
- _ = staged.add("window_views.zig", tsWindowRegistrySource(b, window_views));
1372
+ _ = staged.add("app_sources.zig", tsAppMarkupSourcesSource(b, app_markup_sources));
1373
+ _ = staged.add("window_views.zig", tsWindowRegistrySource(b, if (typescript_view) .{ .views = &.{}, .sources = &.{} } else window_views));
1210
1374
  const main_root = staged.addCopyFile(dep.path("src/app_runner/ts_core_main.zig"), "main.zig");
1211
1375
  // The mobile wiring stages beside the desktop entry: same mirror, same
1212
1376
  // registry, same carrier constant — only the shell differs (the embed
1213
1377
  // host's AppDef contract instead of a process `main`).
1214
1378
  const mobile_root = staged.addCopyFile(dep.path("src/app_runner/ts_core_mobile.zig"), "mobile.zig");
1379
+ const release_markup = b.addWriteFiles();
1380
+ _ = release_markup.addCopyFile(b.path(appPath(b, app_root, "src/app.native")), "app.native");
1381
+ const app_markup_root = release_markup.add("app_markup_root.zig",
1382
+ \\//! Generated release/mobile embedding for the TypeScript root view.
1383
+ \\pub const source = @embedFile("app.native");
1384
+ \\
1385
+ );
1215
1386
  return .{
1216
1387
  .main_root = main_root,
1217
1388
  .mobile_root = mobile_root,
1389
+ .app_markup_root = app_markup_root,
1218
1390
  .archive = archive,
1219
1391
  .service_exe = service_exe,
1220
1392
  .service_archive = service_archive,
@@ -1253,21 +1425,6 @@ fn addAppSqlDirInputs(b: *std.Build, run: *std.Build.Step.Run, src_path: []const
1253
1425
  }
1254
1426
  }
1255
1427
 
1256
- /// corewire (the contract-sidecar shim generator), compiled from the SDK
1257
- /// dependency's sources for the build host.
1258
- fn corewireExe(b: *std.Build, dep: *std.Build.Dependency) *std.Build.Step.Compile {
1259
- const mod = b.createModule(.{
1260
- .root_source_file = dep.path("tools/corewire/main.zig"),
1261
- .target = b.graph.host,
1262
- .optimize = .Debug,
1263
- });
1264
- return b.addExecutable(.{
1265
- .name = "corewire",
1266
- .root_module = mod,
1267
- .use_llvm = useLlvmWorkaround(b.graph.host),
1268
- });
1269
- }
1270
-
1271
1428
  /// The archive's symbol-safe stem (`<app>_core` with every non-identifier
1272
1429
  /// byte folded to '_'), the -o name the external compile builds under.
1273
1430
  fn externalCoreSymbolName(b: *std.Build, app_name: []const u8) []const u8 {
@@ -1327,6 +1484,21 @@ fn addAppCoreTsDirInputs(b: *std.Build, stage: *std.Build.Step.Run, src_path: []
1327
1484
  }
1328
1485
  }
1329
1486
 
1487
+ /// Track exactly the ordered portable policies joined by the TypeScript view
1488
+ /// frontend. Both app and repository fixture stages use this inventory, so a
1489
+ /// policy edit or a new manifest entry invalidates a warm staging cache.
1490
+ pub fn addViewFrontendInputs(b: *std.Build, sdk_builder: *std.Build, stage: *std.Build.Step.Run) void {
1491
+ const manifest = "packages/core/src/portable_sources.json";
1492
+ const sources = std.json.parseFromSliceLeaky([]const []const u8, b.allocator, @embedFile("../packages/core/src/portable_sources.json"), .{}) catch
1493
+ @panic("invalid portable source inventory");
1494
+ stage.addFileInput(sdk_builder.path(manifest));
1495
+ stage.addFileInput(sdk_builder.path("packages/core/src/portable_sources.ts"));
1496
+ stage.addFileInput(sdk_builder.path("packages/core/src/view_frontend.ts"));
1497
+ for (sources) |source| {
1498
+ stage.addFileInput(sdk_builder.path(b.fmt("packages/core/{s}", .{source})));
1499
+ }
1500
+ }
1501
+
1330
1502
  /// Declare the SDK implementation modules copied by
1331
1503
  /// stage_external_core.mjs. A directory LazyPath supplies ordering only for
1332
1504
  /// this source tree; these file inputs make implementation-only SDK edits
@@ -1334,7 +1506,7 @@ fn addAppCoreTsDirInputs(b: *std.Build, stage: *std.Build.Step.Run, src_path: []
1334
1506
  /// contract remains byte-identical. Public for the repository fixture graph,
1335
1507
  /// which exercises the same compiler boundary as app builds.
1336
1508
  pub fn addStagedCoreSdkInputs(b: *std.Build, sdk_builder: *std.Build, stage: *std.Build.Step.Run) void {
1337
- for ([_][]const u8{ "text.ts", "events.ts" }) |source| {
1509
+ for ([_][]const u8{ "bytes.ts", "text.ts", "events.ts", "theme.ts", "internal/image_identity.ts", "internal/markdown_policy.ts" }) |source| {
1338
1510
  stage.addFileInput(sdk_builder.path(b.fmt("packages/core/sdk/{s}", .{source})));
1339
1511
  }
1340
1512
  }
@@ -1453,11 +1625,12 @@ pub const MobileLibOptions = struct {
1453
1625
  pub const MobileTsCore = struct {
1454
1626
  /// The staged mobile wiring (mobile.zig beside the generated mirror).
1455
1627
  main_root: std.Build.LazyPath,
1628
+ /// Separate root-markup module consumed by the compiled mobile view.
1629
+ app_markup_root: std.Build.LazyPath,
1456
1630
  /// The compiled-core archive; merged into the embed library.
1457
1631
  archive: std.Build.LazyPath,
1458
1632
  /// The in-process service archive, when src/services exists.
1459
1633
  service_archive: ?std.Build.LazyPath,
1460
- markup_c: std.Build.LazyPath,
1461
1634
  /// The app.zon module the mobile wiring reads scene chrome, identity,
1462
1635
  /// and theme from (`app_manifest_zon`).
1463
1636
  manifest_mod: *std.Build.Module,
@@ -1522,6 +1695,11 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
1522
1695
  .optimize = optimize,
1523
1696
  });
1524
1697
  mod.addImport("app_manifest_zon", ts.manifest_mod);
1698
+ mod.addImport("app_markup_root", b.createModule(.{
1699
+ .root_source_file = ts.app_markup_root,
1700
+ .target = target,
1701
+ .optimize = optimize,
1702
+ }));
1525
1703
  break :ts_app mod;
1526
1704
  } else localModule(b, target, optimize, options.main);
1527
1705
  app_mod.addImport("native_sdk", native_sdk_mod);
@@ -1536,7 +1714,6 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
1536
1714
  // host link already passes).
1537
1715
  exports_mod.link_libc = true;
1538
1716
  exports_mod.addObjectFile(ts.archive);
1539
- exports_mod.addObjectFile(markupDataObject(b, target, optimize, ts.markup_c).getEmittedBin());
1540
1717
  if (ts.service_archive) |service_archive| exports_mod.addObjectFile(service_archive);
1541
1718
  }
1542
1719
  if (options.store_capability or options.relational_capability) {
@@ -1562,15 +1739,20 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
1562
1739
  .use_llvm = useLlvmWorkaround(target),
1563
1740
  });
1564
1741
 
1742
+ if (options.ts_core != null) {
1743
+ // The compiled view decodes JSON numbers through Zig's f128
1744
+ // helpers. C/Objective-C hosts link this archive directly rather
1745
+ // than through Zig, so it must carry its compiler runtime too.
1746
+ lib.bundle_compiler_rt = true;
1747
+ }
1748
+
1565
1749
  const lib_step = b.step("lib", "Build the mobile embed static library");
1566
- if (options.ts_core != null and target.result.abi.isAndroid()) {
1567
- // Zig's ELF static-library emission stores the compiled TypeScript
1568
- // archives as nested members instead of merging their objects (the
1569
- // Mach-O emission merges), and the NDK's -shared host link would
1570
- // skip those blobs with only a warning. Flatten to one plain
1571
- // object archive so the Android host tier keeps linking exactly
1572
- // the archive it already stages.
1573
- const merged = mergeMobileArchive(b, dep, lib, options.name);
1750
+ if (options.ts_core != null and (target.result.os.tag == .ios or target.result.abi.isAndroid())) {
1751
+ // Android's ELF archive contains nested TypeScript archives that
1752
+ // the NDK linker skips. On iOS, Zig's Mach-O archive can place
1753
+ // members off an 8-byte boundary, which Apple ld64 rejects.
1754
+ // Rebuild either output as a plain object archive before install.
1755
+ const merged = mergeMobileArchive(b, dep, lib, options.name, if (target.result.os.tag == .ios) "darwin" else "gnu");
1574
1756
  const lib_name = b.fmt("lib{s}.a", .{options.name});
1575
1757
  b.getInstallStep().dependOn(&b.addInstallFileWithDir(merged, .lib, lib_name).step);
1576
1758
  lib_step.dependOn(&b.addInstallFileWithDir(merged, .lib, lib_name).step);
@@ -1580,15 +1762,14 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
1580
1762
  }
1581
1763
  }
1582
1764
 
1583
- /// Flatten an Android embed library whose members include the compiled
1584
- /// TypeScript archives (see the call site above). Runs under node like the
1585
- /// rest of the TypeScript lane's drivers.
1586
- fn mergeMobileArchive(b: *std.Build, dep: *std.Build.Dependency, lib: *std.Build.Step.Compile, name: []const u8) std.Build.LazyPath {
1765
+ /// Rebuild a TypeScript embed library from its object members. Android
1766
+ /// needs flattening; iOS needs Darwin archive member alignment.
1767
+ fn mergeMobileArchive(b: *std.Build, dep: *std.Build.Dependency, lib: *std.Build.Step.Compile, name: []const u8, format: []const u8) std.Build.LazyPath {
1587
1768
  const node = b.findProgram(&.{"node"}, &.{}) catch
1588
1769
  @panic("\nmerging the mobile TypeScript archives needs node on PATH (the TypeScript core lane already requires it).\n");
1589
1770
  const merge = b.addSystemCommand(&.{node});
1590
1771
  merge.addFileArg(dep.path("packages/core/scripts/merge_static_archives.mjs"));
1591
- merge.addArgs(&.{ "--zig", b.graph.zig_exe, "--format", "gnu" });
1772
+ merge.addArgs(&.{ "--zig", b.graph.zig_exe, "--format", format });
1592
1773
  merge.addArg("--out");
1593
1774
  const merged = merge.addOutputFileArg(b.fmt("lib{s}.a", .{name}));
1594
1775
  merge.addArg("--in");
@@ -1627,6 +1808,8 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1627
1808
  detectCoreTree(b, app_options.app_root)
1628
1809
  else
1629
1810
  .zig;
1811
+ const typescript_view = b.option(bool, "typescript-view", "Compile Native markup beside the TypeScript model (default for TypeScript apps; rebuild after markup edits)") orelse (core_tree == .ts);
1812
+ if (typescript_view and core_tree != .ts) @panic("-Dtypescript-view requires src/core.ts");
1630
1813
  if (core_tree == .both) {
1631
1814
  @panic("\nthis app declares two cores: src/core.ts (TypeScript) and src/main.zig (Zig)." ++
1632
1815
  "\nAn app has exactly one core - the tree is the truth. Keep src/core.ts and delete" ++
@@ -1681,6 +1864,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1681
1864
  service_pool_workers,
1682
1865
  build_trace,
1683
1866
  scriptc_optimization,
1867
+ typescript_view,
1684
1868
  )
1685
1869
  else
1686
1870
  null;
@@ -1698,7 +1882,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1698
1882
  // `-Dtarget`. Desktop targets keep the step absent. A TypeScript core
1699
1883
  // roots the library's app module at the staged mobile wiring and
1700
1884
  // merges the compiled archives into it.
1701
- if (target.result.os.tag == .ios or target.result.abi.isAndroid()) {
1885
+ if (app_options.mobile_lib or target.result.os.tag == .ios or target.result.abi.isAndroid()) {
1702
1886
  addMobileLibWithTarget(b, dep, target, optimize, .{
1703
1887
  .name = app_options.name,
1704
1888
  .main = appPath(b, app_options.app_root, app_options.main),
@@ -1712,9 +1896,9 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1712
1896
  .max_image_pixel_bytes = app_config.max_image_pixel_bytes,
1713
1897
  .ts_core = if (ts_stage) |stage| .{
1714
1898
  .main_root = stage.mobile_root,
1899
+ .app_markup_root = stage.app_markup_root,
1715
1900
  .archive = stage.archive,
1716
1901
  .service_archive = stage.service_archive,
1717
- .markup_c = stage.markup_c,
1718
1902
  .manifest_mod = appManifestModule(b, app_options.app_root, manifest_name),
1719
1903
  } else null,
1720
1904
  });
@@ -1768,13 +1952,21 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1768
1952
  options.addOption(bool, "web_layer", web_layer);
1769
1953
  const options_mod = options.createModule();
1770
1954
 
1771
- const app_mod = appModule(b, dep, target, app_optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config);
1955
+ const defer_ts_archives = target.result.ofmt == .elf;
1956
+ const app_mod = appModule(b, dep, target, app_optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config, !defer_ts_archives);
1772
1957
  // TypeScript app code and platform hosts are expensive Zig/Clang semantic
1773
1958
  // work but do not depend on primary markup bytes. Compile them once into
1774
1959
  // an object, then make the executable a link-only artifact over that
1775
1960
  // cached object plus the tiny generated markup-data object. A markup edit
1776
1961
  // therefore avoids re-analyzing the SDK and app runner entirely.
1777
1962
  const exe_root = if (ts_stage) |stage| root: {
1963
+ // COFF has no relocatable link for merging the compiled core archive
1964
+ // and platform C/C++ objects into one object. Keep all those inputs
1965
+ // on the executable's final link instead, including Debug markup.
1966
+ if (target.result.os.tag == .windows) {
1967
+ if (app_optimize == .Debug) app_mod.addObject(markupDataObject(b, target, app_optimize, stage.markup_c));
1968
+ break :root app_mod;
1969
+ }
1778
1970
  const app_code = b.addObject(.{
1779
1971
  .name = b.fmt("{s}-app-code", .{app_options.name}),
1780
1972
  .root_module = app_mod,
@@ -1782,7 +1974,14 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1782
1974
  });
1783
1975
  const link_mod = b.createModule(.{ .target = target, .optimize = app_optimize });
1784
1976
  link_mod.addObject(app_code);
1785
- link_mod.addObject(markupDataObject(b, target, app_optimize, stage.markup_c));
1977
+ // ELF relocatable links can leave an archive's unwind terminator
1978
+ // before later .eh_frame records. Keep the compiled archives on the
1979
+ // final link, preserving unwind data and the cached app-code split.
1980
+ if (defer_ts_archives) {
1981
+ link_mod.addObjectFile(stage.archive);
1982
+ if (stage.service_archive) |service_archive| link_mod.addObjectFile(service_archive);
1983
+ }
1984
+ if (app_optimize == .Debug) link_mod.addObject(markupDataObject(b, target, app_optimize, stage.markup_c));
1786
1985
  // Object dependencies propagate framework/system-library NAMES, but
1787
1986
  // Zig does not propagate the search paths or rpaths recorded on the
1788
1987
  // module that produced an object. Restate those path-only facts on
@@ -1849,14 +2048,48 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1849
2048
  // the production app module feeds the cached app-code object and must not
1850
2049
  // absorb the separately linked markup data object.
1851
2050
  const test_app_mod = if (ts_stage != null or app_optimize != optimize)
1852
- appModule(b, dep, target, optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config)
2051
+ appModule(b, dep, target, optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config, true)
1853
2052
  else
1854
2053
  app_mod;
1855
- if (ts_stage) |stage| test_app_mod.addObject(markupDataObject(b, target, optimize, stage.markup_c));
2054
+ if (ts_stage) |stage| {
2055
+ if (optimize == .Debug) test_app_mod.addObject(markupDataObject(b, target, optimize, stage.markup_c));
2056
+ }
1856
2057
  const tests = b.addTest(.{ .root_module = test_app_mod, .use_llvm = useLlvmWorkaround(target) });
1857
2058
  const test_step = b.step("test", "Run tests");
1858
2059
  test_step.dependOn(&b.addRunArtifact(tests).step);
1859
2060
 
2061
+ // Authored Node tests drive a separately linked native TestHarness host.
2062
+ // Apps without tests pay no extra compile/link cost.
2063
+ if (ts_stage != null and hasTypeScriptTests(b, app_options.app_root)) {
2064
+ const host_root = b.addWriteFiles().add("native_test_main.zig",
2065
+ \\pub const main = @import("app").testMain;
2066
+ \\
2067
+ );
2068
+ const host_mod = b.createModule(.{ .root_source_file = host_root, .target = target, .optimize = optimize });
2069
+ host_mod.addImport("app", test_app_mod);
2070
+ // The headless host bypasses linkPlatform, but the compiled core's
2071
+ // runtime still references the Windows networking and crypto APIs.
2072
+ if (target.result.os.tag == .windows) {
2073
+ host_mod.linkSystemLibrary("ws2_32", .{});
2074
+ host_mod.linkSystemLibrary("iphlpapi", .{});
2075
+ host_mod.linkSystemLibrary("advapi32", .{});
2076
+ }
2077
+ const host = b.addExecutable(.{
2078
+ .name = b.fmt("{s}-test-host", .{app_options.name}),
2079
+ .root_module = host_mod,
2080
+ .use_llvm = useLlvmWorkaround(target),
2081
+ });
2082
+ const node_tests = b.addSystemCommand(&.{tsToolingPreflight(b, dep, .app_core)});
2083
+ node_tests.addArgs(&.{ "--test-reporter=spec", "--test-reporter-destination=stderr" });
2084
+ node_tests.addFileArg(dep.path("build/ts_run.mjs"));
2085
+ node_tests.addFileArg(dep.path("packages/core/scripts/run_native_tests.mjs"));
2086
+ node_tests.addArtifactArg(host);
2087
+ node_tests.addDirectoryArg(b.path(appPath(b, app_options.app_root, "tests")));
2088
+ node_tests.setCwd(b.path(app_options.app_root));
2089
+ node_tests.has_side_effects = true;
2090
+ test_step.dependOn(&node_tests.step);
2091
+ }
2092
+
1860
2093
  // `native test` must surface the app's compile-time teaching errors,
1861
2094
  // not just its test failures. Test builds never analyze `main` (the
1862
2095
  // test runner replaces the entry point), so rules that fire inside it
@@ -2026,7 +2259,7 @@ fn exampleOptimizeMode(b: *std.Build, requested: ?std.builtin.OptimizeMode, defa
2026
2259
  };
2027
2260
  }
2028
2261
 
2029
- fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, app_options: AppOptions, manifest_name: []const u8, options_mod: *std.Build.Module, ts_stage: ?TsCoreStage, relational_migrations: std.Build.LazyPath, app_config: AppManifestBuildConfig) *std.Build.Module {
2262
+ fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, app_options: AppOptions, manifest_name: []const u8, options_mod: *std.Build.Module, ts_stage: ?TsCoreStage, relational_migrations: std.Build.LazyPath, app_config: AppManifestBuildConfig, link_ts_archives: bool) *std.Build.Module {
2030
2263
  const native_sdk_mod = nativeSdkModuleWithTerminal(b, dep, target, optimize, app_options.terminal_sessions);
2031
2264
  const runner_mod = b.createModule(.{
2032
2265
  .root_source_file = dep.path("src/app_runner/root.zig"),
@@ -2062,10 +2295,23 @@ fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Resolv
2062
2295
  // The compiled-core archive links behind the staged mirror; the
2063
2296
  // toolchain's runtime needs libc.
2064
2297
  app_mod.link_libc = true;
2065
- app_mod.addObjectFile(stage.archive);
2298
+ if (link_ts_archives) app_mod.addObjectFile(stage.archive);
2299
+ // Debug reads src/app.native only through the separately linked C
2300
+ // data object. Supplying this generated module in Debug would put
2301
+ // the authored root back into the app-code dependency graph even
2302
+ // though the runner's comptime branch never imports it.
2303
+ if (optimize != .Debug) {
2304
+ app_mod.addImport("app_markup_root", b.createModule(.{
2305
+ .root_source_file = stage.app_markup_root,
2306
+ .target = target,
2307
+ .optimize = optimize,
2308
+ }));
2309
+ }
2066
2310
  // The in-process service archive links beside it (distinct symbol
2067
2311
  // prefix; its runtime internals are localized).
2068
- if (stage.service_archive) |service_archive| app_mod.addObjectFile(service_archive);
2312
+ if (link_ts_archives) {
2313
+ if (stage.service_archive) |service_archive| app_mod.addObjectFile(service_archive);
2314
+ }
2069
2315
  }
2070
2316
  if (app_config.sqlite_capability) {
2071
2317
  // `store` and the relational `sqlite` tier share this exact object.
@@ -2893,3 +3139,17 @@ fn resolveWebLayer(config: AppManifestBuildConfig, web_engine: WebEngineOption,
2893
3139
  );
2894
3140
  return decision.enabled;
2895
3141
  }
3142
+
3143
+ /// One explicit discovery convention, shared with run_native_tests.mjs.
3144
+ fn hasTypeScriptTests(b: *std.Build, app_root: []const u8) bool {
3145
+ var dir = std.Io.Dir.cwd().openDir(b.graph.io, b.pathFromRoot(appPath(b, app_root, "tests")), .{ .iterate = true }) catch |err| switch (err) {
3146
+ error.FileNotFound => return false,
3147
+ else => @panic("cannot read app tests directory"),
3148
+ };
3149
+ defer dir.close(b.graph.io);
3150
+ var iterator = dir.iterate();
3151
+ while (iterator.next(b.graph.io) catch @panic("cannot enumerate app tests")) |entry| {
3152
+ if (entry.kind == .file and std.mem.endsWith(u8, entry.name, ".test.ts")) return true;
3153
+ }
3154
+ return false;
3155
+ }