@native-sdk/cli 0.9.0 → 0.9.2

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 (181) hide show
  1. package/build/app.zig +357 -33
  2. package/build.zig +234 -11
  3. package/native-sdk.d.ts +8 -0
  4. package/package.json +10 -10
  5. package/packages/core/compile-surface/core.ts +70 -1
  6. package/packages/core/package-lock.json +11 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  9. package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
  10. package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
  11. package/packages/core/scripts/stage_external_services.mjs +1 -1
  12. package/packages/core/sdk/core.d.ts +75 -0
  13. package/packages/core/sdk/core.ts +170 -13
  14. package/packages/core/sdk/events.d.ts +53 -0
  15. package/packages/core/sdk/events.ts +78 -7
  16. package/packages/core/src/checker.ts +470 -2
  17. package/packages/core/src/cli.ts +13 -0
  18. package/packages/core/src/contract.ts +3 -1
  19. package/packages/core/src/devhost.ts +30 -1
  20. package/packages/core/src/devhost_journal.mjs +10 -8
  21. package/packages/core/src/diagnostics.ts +99 -8
  22. package/packages/core/src/frontend.ts +6 -0
  23. package/packages/core/src/infer.ts +24 -0
  24. package/skill-data/automation/SKILL.md +1 -1
  25. package/skill-data/native-ui/SKILL.md +18 -12
  26. package/skill-data/ts-core/SKILL.md +54 -21
  27. package/skill-data/ts-services/SKILL.md +4 -4
  28. package/skill-data/ts-services/references/service-surface.md +2 -1
  29. package/skill-data/zig/SKILL.md +1 -1
  30. package/src/app_runner/root.zig +122 -6
  31. package/src/app_runner/ts_core_main.zig +9 -4
  32. package/src/app_runner/ts_core_mobile.zig +241 -0
  33. package/src/app_runner/window_placement.zig +63 -0
  34. package/src/automation/protocol.zig +5 -1
  35. package/src/automation/snapshot.zig +8 -6
  36. package/src/embed/app_exports.zig +3 -1
  37. package/src/embed/conversions.zig +1 -0
  38. package/src/embed/host.zig +10 -3
  39. package/src/embed/root.zig +2 -0
  40. package/src/embed/tests.zig +41 -1
  41. package/src/embed/types.zig +2 -0
  42. package/src/embed/ui_host.zig +94 -4
  43. package/src/platform/android/NativeSdkActivity.java +49 -4
  44. package/src/platform/android/android_host.c +3 -3
  45. package/src/platform/android/native_sdk_app.h +1 -1
  46. package/src/platform/ios/apple_image_fit.h +38 -0
  47. package/src/platform/ios/files.zig +1 -0
  48. package/src/platform/ios/native_sdk_app.h +1 -1
  49. package/src/platform/ios/uikit_host.m +28 -5
  50. package/src/platform/linux/cef_host.cpp +17 -3
  51. package/src/platform/linux/gtk_host.c +243 -15
  52. package/src/platform/linux/gtk_host.h +5 -4
  53. package/src/platform/linux/root.zig +91 -11
  54. package/src/platform/macos/appkit_host.h +18 -11
  55. package/src/platform/macos/appkit_host.m +402 -128
  56. package/src/platform/macos/cef_host.mm +342 -122
  57. package/src/platform/macos/image_fit_test.m +44 -0
  58. package/src/platform/macos/root.zig +231 -39
  59. package/src/platform/null_platform.zig +251 -54
  60. package/src/platform/null_platform_tests.zig +97 -4
  61. package/src/platform/root.zig +12 -0
  62. package/src/platform/types.zig +174 -35
  63. package/src/platform/windows/root.zig +42 -13
  64. package/src/platform/windows/webview2_host.cpp +72 -11
  65. package/src/primitives/app_manifest/root.zig +3 -0
  66. package/src/primitives/app_manifest/tests.zig +24 -0
  67. package/src/primitives/app_manifest/types.zig +13 -0
  68. package/src/primitives/app_manifest/validation.zig +24 -0
  69. package/src/primitives/canvas/a11y_audit.zig +9 -7
  70. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  71. package/src/primitives/canvas/events.zig +50 -0
  72. package/src/primitives/canvas/layout_audit.zig +6 -6
  73. package/src/primitives/canvas/markdown.zig +4 -0
  74. package/src/primitives/canvas/markdown_tests.zig +1 -0
  75. package/src/primitives/canvas/png.zig +138 -0
  76. package/src/primitives/canvas/root.zig +13 -2
  77. package/src/primitives/canvas/text_span_tests.zig +5 -3
  78. package/src/primitives/canvas/text_spans.zig +2 -0
  79. package/src/primitives/canvas/text_tests.zig +20 -0
  80. package/src/primitives/canvas/ui.zig +55 -2
  81. package/src/primitives/canvas/ui_markup.zig +40 -13
  82. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  83. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  84. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  85. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  86. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  87. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  88. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  89. package/src/primitives/canvas/ui_schema.zig +17 -13
  90. package/src/primitives/canvas/ui_tests.zig +47 -0
  91. package/src/primitives/canvas/widget_access.zig +3 -3
  92. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  93. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  94. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  95. package/src/primitives/canvas/widget_layout.zig +333 -126
  96. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  97. package/src/primitives/canvas/widget_metrics.zig +7 -8
  98. package/src/primitives/canvas/widget_render.zig +76 -44
  99. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  100. package/src/primitives/canvas/widget_render_style.zig +58 -18
  101. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  102. package/src/primitives/canvas/widget_routing.zig +40 -34
  103. package/src/primitives/canvas/widget_runtime.zig +11 -2
  104. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  105. package/src/primitives/canvas/widget_semantics.zig +8 -3
  106. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  107. package/src/primitives/canvas/widget_tree.zig +99 -5
  108. package/src/primitives/canvas/widgets.zig +20 -7
  109. package/src/root.zig +10 -0
  110. package/src/runtime/api.zig +14 -0
  111. package/src/runtime/automation_commands.zig +35 -2
  112. package/src/runtime/automation_snapshot.zig +32 -24
  113. package/src/runtime/automation_widget_dispatch.zig +48 -6
  114. package/src/runtime/bridge_permission_tests.zig +35 -1
  115. package/src/runtime/bridge_responses.zig +1 -1
  116. package/src/runtime/builtin_bridge.zig +16 -3
  117. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  118. package/src/runtime/canvas_image_tests.zig +146 -2
  119. package/src/runtime/canvas_images.zig +35 -16
  120. package/src/runtime/canvas_limits.zig +13 -3
  121. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  122. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  123. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  124. package/src/runtime/canvas_widget_events.zig +151 -26
  125. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  126. package/src/runtime/canvas_widget_runtime.zig +322 -102
  127. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  128. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  129. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  130. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  131. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  132. package/src/runtime/canvas_widget_state.zig +33 -7
  133. package/src/runtime/core.zig +28 -6
  134. package/src/runtime/effects.zig +1337 -49
  135. package/src/runtime/effects_file_tests.zig +587 -0
  136. package/src/runtime/effects_image_tests.zig +91 -0
  137. package/src/runtime/effects_notification_tests.zig +11 -0
  138. package/src/runtime/file_access.zig +400 -0
  139. package/src/runtime/file_effect_crash_helper.zig +28 -0
  140. package/src/runtime/file_effect_crash_tests.zig +37 -0
  141. package/src/runtime/flow.zig +21 -9
  142. package/src/runtime/gpu_surface_events.zig +25 -2
  143. package/src/runtime/native_command_event_tests.zig +44 -2
  144. package/src/runtime/pty.zig +5 -2
  145. package/src/runtime/root.zig +7 -0
  146. package/src/runtime/session_blobs.zig +4 -1
  147. package/src/runtime/session_journal.zig +56 -5
  148. package/src/runtime/session_record.zig +38 -0
  149. package/src/runtime/session_replay.zig +110 -15
  150. package/src/runtime/session_tests.zig +192 -4
  151. package/src/runtime/shell_layout_tests.zig +12 -0
  152. package/src/runtime/state.zig +10 -0
  153. package/src/runtime/system_services.zig +129 -36
  154. package/src/runtime/ts_core_host.zig +281 -11
  155. package/src/runtime/ts_core_host_tests.zig +142 -1
  156. package/src/runtime/ts_ui_app.zig +461 -8
  157. package/src/runtime/ui_app.zig +330 -112
  158. package/src/runtime/ui_app_tests.zig +251 -25
  159. package/src/runtime/ui_app_window_tests.zig +74 -8
  160. package/src/runtime/validation.zig +20 -0
  161. package/src/runtime/view.zig +3 -0
  162. package/src/runtime/view_widget_control.zig +18 -0
  163. package/src/runtime/view_widget_scroll.zig +112 -18
  164. package/src/runtime/view_widget_tree.zig +110 -13
  165. package/src/runtime/widget_bridge.zig +2 -0
  166. package/src/runtime/window_command_bridge_tests.zig +86 -0
  167. package/src/runtime/window_storage.zig +16 -1
  168. package/src/runtime/window_views.zig +1 -0
  169. package/src/tooling/ios.zig +3 -0
  170. package/src/tooling/manifest.zig +90 -2
  171. package/src/tooling/package.zig +67 -2
  172. package/src/tooling/raw_manifest.zig +10 -0
  173. package/src/tooling/templates.zig +156 -18
  174. package/src/tooling/ts_core.zig +83 -0
  175. package/src/tooling/web_engine.zig +1 -1
  176. package/tools/corewire/emit.zig +3 -3
  177. package/tools/corewire/emit_facade.zig +65 -5
  178. package/tools/corewire/emit_profile.zig +2 -2
  179. package/tools/corewire/emit_service.zig +2 -2
  180. package/tools/corewire/service_contract.zig +4 -4
  181. package/tools/corewire/sidecar.zig +4 -4
@@ -670,7 +670,6 @@ fn nativeMainZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
670
670
  \\,
671
671
  \\ .width = window_width,
672
672
  \\ .height = window_height,
673
- \\ .restore_state = false,
674
673
  \\ .views = &shell_views,
675
674
  \\}};
676
675
  \\const shell_scene: native_sdk.ShellConfig = .{ .windows = &shell_windows };
@@ -798,7 +797,6 @@ fn nativeMainZig(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
798
797
  \\,
799
798
  \\ .icon_path = "assets/icon.png",
800
799
  \\ .default_frame = geometry.RectF.init(0, 0, window_width, window_height),
801
- \\ .restore_state = false,
802
800
  \\ .js_window_api = false,
803
801
  \\ .security = .{
804
802
  \\ .permissions = &app_permissions,
@@ -1066,8 +1064,6 @@ fn nativeAppZon(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
1066
1064
  \\,
1067
1065
  \\ .width = 480,
1068
1066
  \\ .height = 320,
1069
- \\ .restore_state = false,
1070
- \\ .restore_policy = "center_on_primary",
1071
1067
  \\ .views = .{
1072
1068
  \\ .{ .label = "main-canvas", .kind = "gpu_surface", .fill = true, .role = "Counter canvas", .accessibility_label = "Counter", .gpu_backend = "metal", .gpu_pixel_format = "bgra8_unorm", .gpu_present_mode = "timer", .gpu_alpha_mode = "opaque", .gpu_color_space = "srgb", .gpu_vsync = true },
1073
1069
  \\ },
@@ -1476,7 +1472,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1476
1472
  \\ app_mod.addImport("native_sdk", native_sdk_mod);
1477
1473
  \\ app_mod.addImport("runner", runner_mod);
1478
1474
  \\ if (app_config.sqlite_capability) addSqliteEngine(b, app_mod, native_sdk_path);
1479
- \\ addMacosPrivacyInfoPlist(b, app_mod, target, app_config);
1475
+ \\ addMacosInfoPlist(b, app_mod, target, app_config);
1480
1476
  \\ const exe = b.addExecutable(.{
1481
1477
  \\ .name = app_exe_name,
1482
1478
  \\ .root_module = app_mod,
@@ -1542,7 +1538,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1542
1538
  \\ package_app_mod.addImport("native_sdk", package_sdk_mod);
1543
1539
  \\ package_app_mod.addImport("runner", package_runner_mod);
1544
1540
  \\ if (app_config.sqlite_capability) addSqliteEngine(b, package_app_mod, native_sdk_path);
1545
- \\ addMacosPrivacyInfoPlist(b, package_app_mod, target, app_config);
1541
+ \\ addMacosInfoPlist(b, package_app_mod, target, app_config);
1546
1542
  \\ const built = b.addExecutable(.{
1547
1543
  \\ .name = app_exe_name,
1548
1544
  \\ .root_module = package_app_mod,
@@ -1614,14 +1610,18 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1614
1610
  \\ return if (target.result.cpu.arch == .x86_64) true else null;
1615
1611
  \\}
1616
1612
  \\
1617
- \\/// Bare Mach-O dev executables have no bundle Info.plist. Embed the
1618
- \\/// capture usage strings derived from app.zon so macOS can present
1619
- \\/// consent instead of terminating the process. Packaged apps also
1620
- \\/// receive the richer external plist from the package command.
1621
- \\fn addMacosPrivacyInfoPlist(b: *std.Build, app_mod: *std.Build.Module, target: std.Build.ResolvedTarget, config: AppManifestBuildConfig) void {
1613
+ \\/// Bare Mach-O dev executables have no bundle Info.plist. Embed launch
1614
+ \\/// policy plus capture usage strings so LaunchServices starts accessory
1615
+ \\/// apps without a transient Dock tile and macOS can present consent.
1616
+ \\/// Packaged apps receive the richer external plist from the package command.
1617
+ \\fn addMacosInfoPlist(b: *std.Build, app_mod: *std.Build.Module, target: std.Build.ResolvedTarget, config: AppManifestBuildConfig) void {
1622
1618
  \\ if (target.result.os.tag != .macos) return;
1623
- \\ if (!config.microphone_permission and !config.system_audio_permission) return;
1619
+ \\ if (config.dock_visible and !config.microphone_permission and !config.system_audio_permission) return;
1624
1620
  \\
1621
+ \\ const launch_policy = if (!config.dock_visible)
1622
+ \\ " <key>LSUIElement</key>\\n <true/>\\n"
1623
+ \\ else
1624
+ \\ "";
1625
1625
  \\ const microphone = if (config.microphone_permission)
1626
1626
  \\ " <key>NSMicrophoneUsageDescription</key>\\n <string>This app captures microphone audio when you start recording.</string>\\n"
1627
1627
  \\ else
@@ -1632,11 +1632,11 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
1632
1632
  \\ else
1633
1633
  \\ "";
1634
1634
  \\ const source = b.fmt(
1635
- \\ \\#define NATIVE_SDK_INFO_PLIST "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" "<plist version=\"1.0\">\n<dict>\n{s}{s}</dict>\n</plist>\n"
1635
+ \\ \\#define NATIVE_SDK_INFO_PLIST "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" "<plist version=\"1.0\">\n<dict>\n{s}{s}{s}</dict>\n</plist>\n"
1636
1636
  \\ \\__attribute__((used, section("__TEXT,__info_plist")))
1637
1637
  \\ \\static const unsigned char native_sdk_info_plist[sizeof(NATIVE_SDK_INFO_PLIST) - 1] = NATIVE_SDK_INFO_PLIST;
1638
1638
  \\ \\
1639
- \\ , .{ microphone, system_audio });
1639
+ \\ , .{ launch_policy, microphone, system_audio });
1640
1640
  \\ const generated = b.addWriteFiles().add("native_sdk_macos_info_plist.c", source);
1641
1641
  \\ app_mod.addCSourceFile(.{ .file = generated, .flags = &.{} });
1642
1642
  \\}
@@ -2041,6 +2041,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
2041
2041
  \\ cef_dir: []const u8 = "third_party/cef/macos",
2042
2042
  \\ cef_auto_install: bool = false,
2043
2043
  \\ webview_layer: WebLayerOption = .auto,
2044
+ \\ dock_visible: bool = true,
2044
2045
  \\ microphone_permission: bool = false,
2045
2046
  \\ system_audio_permission: bool = false,
2046
2047
  \\ sqlite_capability: bool = false,
@@ -2058,6 +2059,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
2058
2059
  \\const InferenceManifest = struct {
2059
2060
  \\ capabilities: []const []const u8 = &.{},
2060
2061
  \\ permissions: []const []const u8 = &.{},
2062
+ \\ dock_visible: bool = true,
2061
2063
  \\ web_engine: []const u8 = "system",
2062
2064
  \\ webview_layer: []const u8 = "auto",
2063
2065
  \\ cef: struct {
@@ -2089,13 +2091,14 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
2089
2091
  \\ // mismatch here is not proof the app declares no web use.
2090
2092
  \\ const fallback: AppManifestBuildConfig = .{ .web_declaration = "an app.zon this build graph could not parse" };
2091
2093
  \\ const source: [:0]const u8 = @embedFile("app.zon");
2092
- \\ @setEvalBranchQuota(2000);
2094
+ \\ @setEvalBranchQuota(4000);
2093
2095
  \\ const raw = std.zon.parse.fromSliceAlloc(InferenceManifest, b.allocator, source, null, .{ .ignore_unknown_fields = true }) catch return fallback;
2094
2096
  \\ var config: AppManifestBuildConfig = .{
2095
2097
  \\ .web_engine = parseWebEngine(raw.web_engine) orelse .system,
2096
2098
  \\ .cef_dir = raw.cef.dir,
2097
2099
  \\ .cef_auto_install = raw.cef.auto_install,
2098
2100
  \\ .webview_layer = parseWebLayer(raw.webview_layer) orelse @panic("app.zon .webview_layer must be \"auto\", \"include\", or \"exclude\""),
2101
+ \\ .dock_visible = raw.dock_visible,
2099
2102
  \\ .microphone_permission = hasManifestPermission(raw.permissions, "microphone"),
2100
2103
  \\ .system_audio_permission = hasManifestPermission(raw.permissions, "system_audio"),
2101
2104
  \\ .sqlite_capability = hasManifestCapability(raw.capabilities, "store") or hasManifestCapability(raw.capabilities, "sqlite"),
@@ -2308,6 +2311,12 @@ fn runnerZig() []const u8 {
2308
2311
  \\const manifest_menus = if (@hasField(@TypeOf(app_manifest), "menus")) app_manifest.menus else .{};
2309
2312
  \\const manifest_windows = if (@hasField(@TypeOf(app_manifest), "windows")) app_manifest.windows else .{};
2310
2313
  \\
2314
+ \\fn manifestImagePixelBudget() usize {
2315
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "images")) return native_sdk.max_registered_canvas_image_pixel_bytes;
2316
+ \\ if (comptime !@hasField(@TypeOf(app_manifest.images), "max_image_pixel_bytes")) return native_sdk.max_registered_canvas_image_pixel_bytes;
2317
+ \\ return app_manifest.images.max_image_pixel_bytes;
2318
+ \\}
2319
+ \\
2311
2320
  \\pub const StdoutTraceSink = struct {
2312
2321
  \\ pub fn sink(self: *StdoutTraceSink) native_sdk.trace.Sink {
2313
2322
  \\ return .{ .context = self, .write_fn = write };
@@ -2337,6 +2346,8 @@ fn runnerZig() []const u8 {
2337
2346
  \\ shortcuts: ?[]const native_sdk.Shortcut = null,
2338
2347
  \\ record_store: ?native_sdk.RecordStoreBinding = null,
2339
2348
  \\ relational_store: ?native_sdk.RelationalStoreBinding = null,
2349
+ \\ file_access: ?native_sdk.FileAccessBinding = null,
2350
+ \\ file_access_enforce: bool = true,
2340
2351
  \\ relational_migrations: []const native_sdk.relational_store.Migration = &built_relational_migrations.migrations,
2341
2352
  \\
2342
2353
  \\ fn appInfo(self: RunOptions, buffers: *StateBuffers) native_sdk.AppInfo {
@@ -2344,6 +2355,7 @@ fn runnerZig() []const u8 {
2344
2355
  \\ .app_name = self.app_name,
2345
2356
  \\ .has_web_content = manifestHasWebContent(),
2346
2357
  \\ .declares_tray = manifestDeclaresTrayCapability(),
2358
+ \\ .dock_visible = manifestDockVisible(),
2347
2359
  \\ .window_title = self.window_title,
2348
2360
  \\ .bundle_id = self.bundle_id,
2349
2361
  \\ .icon_path = self.icon_path,
@@ -2361,8 +2373,12 @@ fn runnerZig() []const u8 {
2361
2373
  \\ // a canvas-first startup window is created ordered-out and
2362
2374
  \\ // shown after its first canvas frame presents, so launch
2363
2375
  \\ // never flashes a blank window.
2376
+ \\ info.main_window.default_frame = manifestShellStartupFrame(info.main_window.default_frame);
2377
+ \\ info.main_window.restore_state = manifestShellStartupRestoreState(info.main_window.restore_state);
2364
2378
  \\ info.main_window.titlebar = manifestShellStartupTitlebar();
2365
2379
  \\ info.main_window.resizable = manifestShellStartupResizable();
2380
+ \\ info.main_window.restore_policy = manifestShellStartupRestorePolicy(info.main_window.restore_policy);
2381
+ \\ info.main_window.initial_placement = manifestShellStartupInitialPlacement(info.main_window.initial_placement);
2366
2382
  \\ info.main_window.show = manifestShellStartupShowMode();
2367
2383
  \\ info.main_window.transparent = manifestShellStartupBool("transparent", false);
2368
2384
  \\ info.main_window.always_on_top = manifestShellStartupBool("always_on_top", false);
@@ -2500,6 +2516,7 @@ fn runnerZig() []const u8 {
2500
2516
  \\ .resizable = windowBool(window, "resizable", true),
2501
2517
  \\ .restore_state = windowBool(window, "restore_state", true),
2502
2518
  \\ .restore_policy = windowRestorePolicy(window),
2519
+ \\ .initial_placement = if (windowHasExplicitOrigin(window)) .explicit else .default,
2503
2520
  \\ .titlebar = windowTitlebarStyle(window),
2504
2521
  \\ .show = if (windowBool(window, "initially_hidden", false)) .hidden else .immediate,
2505
2522
  \\ .transparent = windowBool(window, "transparent", false),
@@ -2543,6 +2560,60 @@ fn runnerZig() []const u8 {
2543
2560
  \\ @compileError("unknown app.zon window restore_policy");
2544
2561
  \\}
2545
2562
  \\
2563
+ \\fn windowHasExplicitOrigin(comptime window: anytype) bool {
2564
+ \\ return @hasField(@TypeOf(window), "x") or @hasField(@TypeOf(window), "y");
2565
+ \\}
2566
+ \\
2567
+ \\/// The host creates the first scene window before the scene loads, so its
2568
+ \\/// authored frame must ride AppInfo with the other creation-time options.
2569
+ \\/// Omitted fields preserve the direct runner fallback independently.
2570
+ \\fn manifestShellStartupFrame(fallback: native_sdk.geometry.RectF) native_sdk.geometry.RectF {
2571
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return fallback;
2572
+ \\ const shell = app_manifest.shell;
2573
+ \\ if (comptime !@hasField(@TypeOf(shell), "windows")) return fallback;
2574
+ \\ if (comptime shell.windows.len == 0) return fallback;
2575
+ \\ const window = shell.windows[0];
2576
+ \\ return native_sdk.geometry.RectF.init(
2577
+ \\ windowFloatFallback(window, "x", fallback.x),
2578
+ \\ windowFloatFallback(window, "y", fallback.y),
2579
+ \\ windowFloatFallback(window, "width", fallback.width),
2580
+ \\ windowFloatFallback(window, "height", fallback.height),
2581
+ \\ );
2582
+ \\}
2583
+ \\
2584
+ \\fn windowFloatFallback(comptime window: anytype, comptime field: []const u8, fallback: f32) f32 {
2585
+ \\ if (comptime @hasField(@TypeOf(window), field)) return @field(window, field);
2586
+ \\ return fallback;
2587
+ \\}
2588
+ \\
2589
+ \\fn manifestShellStartupRestoreState(fallback: bool) bool {
2590
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return fallback;
2591
+ \\ const shell = app_manifest.shell;
2592
+ \\ if (comptime !@hasField(@TypeOf(shell), "windows")) return fallback;
2593
+ \\ if (comptime shell.windows.len == 0) return fallback;
2594
+ \\ const window = shell.windows[0];
2595
+ \\ if (comptime @hasField(@TypeOf(window), "restore_state")) return window.restore_state;
2596
+ \\ return fallback;
2597
+ \\}
2598
+ \\
2599
+ \\fn manifestShellStartupRestorePolicy(fallback: native_sdk.WindowRestorePolicy) native_sdk.WindowRestorePolicy {
2600
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return fallback;
2601
+ \\ const shell = app_manifest.shell;
2602
+ \\ if (comptime !@hasField(@TypeOf(shell), "windows")) return fallback;
2603
+ \\ if (comptime shell.windows.len == 0) return fallback;
2604
+ \\ const window = shell.windows[0];
2605
+ \\ if (comptime !@hasField(@TypeOf(window), "restore_policy")) return fallback;
2606
+ \\ return windowRestorePolicy(window);
2607
+ \\}
2608
+ \\
2609
+ \\fn manifestShellStartupInitialPlacement(fallback: native_sdk.WindowInitialPlacement) native_sdk.WindowInitialPlacement {
2610
+ \\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return fallback;
2611
+ \\ const shell = app_manifest.shell;
2612
+ \\ if (comptime !@hasField(@TypeOf(shell), "windows")) return fallback;
2613
+ \\ if (comptime shell.windows.len == 0) return fallback;
2614
+ \\ return if (windowHasExplicitOrigin(shell.windows[0])) .explicit else fallback;
2615
+ \\}
2616
+ \\
2546
2617
  \\/// Window-enforced content min-size floor from app.zon. Validated at
2547
2618
  \\/// comptime like the titlebar style: a negative floor is an authoring
2548
2619
  \\/// error, not a silent clamp.
@@ -2672,6 +2743,14 @@ fn runnerZig() []const u8 {
2672
2743
  \\ return false;
2673
2744
  \\}
2674
2745
  \\
2746
+ \\fn manifestDockVisible() bool {
2747
+ \\ const visible = if (comptime @hasField(@TypeOf(app_manifest), "dock_visible")) app_manifest.dock_visible else true;
2748
+ \\ if (comptime !visible and !manifestDeclaresTrayCapability()) {
2749
+ \\ @compileError("app.zon dock_visible = false requires the \"tray\" capability: an accessory app has no Dock/app-switcher route back to hidden windows - add \"tray\" to .capabilities and install a status item, or keep dock_visible = true (the default)");
2750
+ \\ }
2751
+ \\ return visible;
2752
+ \\}
2753
+ \\
2675
2754
  \\fn manifestDeclaresStore() bool {
2676
2755
  \\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
2677
2756
  \\ inline for (app_manifest.capabilities) |capability| {
@@ -2732,6 +2811,24 @@ fn runnerZig() []const u8 {
2732
2811
  \\ var record_store_value: RecordStoreType = undefined;
2733
2812
  \\ var record_store_open = false;
2734
2813
  \\ var resolved_options = options;
2814
+ \\ var file_root_buffers: [6][1024]u8 = undefined;
2815
+ \\ var file_roots: [6][]const u8 = undefined;
2816
+ \\ const resolved_file_dirs = native_sdk.app_dirs.resolve(
2817
+ \\ .{ .name = options.bundle_id },
2818
+ \\ native_sdk.app_dirs.currentPlatform(),
2819
+ \\ native_sdk.debug.envFromMap(init.environ_map),
2820
+ \\ native_sdk.app_dirs.Buffers.fromArray(1024, &file_root_buffers),
2821
+ \\ ) catch null;
2822
+ \\ var file_root_count: usize = 0;
2823
+ \\ if (resolved_file_dirs) |dirs| {
2824
+ \\ file_roots = .{ dirs.config, dirs.cache, dirs.data, dirs.state, dirs.logs, dirs.temp };
2825
+ \\ file_root_count = file_roots.len;
2826
+ \\ }
2827
+ \\ resolved_options.file_access = .{
2828
+ \\ .roots = file_roots[0..file_root_count],
2829
+ \\ .permitted = native_sdk.security.hasPermission(options.security.permissions, native_sdk.security.permission_filesystem),
2830
+ \\ .enforce = options.file_access_enforce,
2831
+ \\ };
2735
2832
  \\ if (comptime manifestDeclaresStore()) {
2736
2833
  \\ var data_dir_buffer: [512]u8 = undefined;
2737
2834
  \\ const app_data_dir = native_sdk.app_dirs.resolveOne(
@@ -2821,6 +2918,7 @@ fn runnerZig() []const u8 {
2821
2918
  \\ defer std.heap.page_allocator.destroy(runtime);
2822
2919
  \\ native_sdk.Runtime.initAt(runtime, .{
2823
2920
  \\ .platform = null_platform.platform(),
2921
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2824
2922
  \\ .trace_sink = runtime_trace_sink,
2825
2923
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2826
2924
  \\ .bridge = options.bridge,
@@ -2835,6 +2933,7 @@ fn runnerZig() []const u8 {
2835
2933
  \\ .window_state_store = store,
2836
2934
  \\ .record_store = options.record_store,
2837
2935
  \\ .relational_store = options.relational_store,
2936
+ \\ .file_access = options.file_access,
2838
2937
  \\ .environ = init.minimal.environ,
2839
2938
  \\ });
2840
2939
  \\
@@ -2877,6 +2976,7 @@ fn runnerZig() []const u8 {
2877
2976
  \\ defer std.heap.page_allocator.destroy(runtime);
2878
2977
  \\ native_sdk.Runtime.initAt(runtime, .{
2879
2978
  \\ .platform = mac_platform.platform(),
2979
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2880
2980
  \\ .trace_sink = runtime_trace_sink,
2881
2981
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2882
2982
  \\ .bridge = options.bridge,
@@ -2891,6 +2991,7 @@ fn runnerZig() []const u8 {
2891
2991
  \\ .window_state_store = store,
2892
2992
  \\ .record_store = options.record_store,
2893
2993
  \\ .relational_store = options.relational_store,
2994
+ \\ .file_access = options.file_access,
2894
2995
  \\ .environ = init.minimal.environ,
2895
2996
  \\ });
2896
2997
  \\
@@ -2933,6 +3034,7 @@ fn runnerZig() []const u8 {
2933
3034
  \\ defer std.heap.page_allocator.destroy(runtime);
2934
3035
  \\ native_sdk.Runtime.initAt(runtime, .{
2935
3036
  \\ .platform = linux_platform.platform(),
3037
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2936
3038
  \\ .trace_sink = runtime_trace_sink,
2937
3039
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2938
3040
  \\ .bridge = options.bridge,
@@ -2947,6 +3049,7 @@ fn runnerZig() []const u8 {
2947
3049
  \\ .window_state_store = store,
2948
3050
  \\ .record_store = options.record_store,
2949
3051
  \\ .relational_store = options.relational_store,
3052
+ \\ .file_access = options.file_access,
2950
3053
  \\ .environ = init.minimal.environ,
2951
3054
  \\ });
2952
3055
  \\
@@ -2989,6 +3092,7 @@ fn runnerZig() []const u8 {
2989
3092
  \\ defer std.heap.page_allocator.destroy(runtime);
2990
3093
  \\ native_sdk.Runtime.initAt(runtime, .{
2991
3094
  \\ .platform = windows_platform.platform(),
3095
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2992
3096
  \\ .trace_sink = runtime_trace_sink,
2993
3097
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2994
3098
  \\ .bridge = options.bridge,
@@ -3003,6 +3107,7 @@ fn runnerZig() []const u8 {
3003
3107
  \\ .window_state_store = store,
3004
3108
  \\ .record_store = options.record_store,
3005
3109
  \\ .relational_store = options.relational_store,
3110
+ \\ .file_access = options.file_access,
3006
3111
  \\ .environ = init.minimal.environ,
3007
3112
  \\ });
3008
3113
  \\
@@ -3079,12 +3184,17 @@ fn runnerZig() []const u8 {
3079
3184
  \\ if (!window.restore_state) continue;
3080
3185
  \\ if (store.loadWindow(window.label, &buffers.read) catch null) |saved| {
3081
3186
  \\ window.default_frame = saved.frame;
3082
- \\ if (index == 0) app_info.main_window.default_frame = saved.frame;
3187
+ \\ window.initial_placement = .restored;
3188
+ \\ if (index == 0) {
3189
+ \\ app_info.main_window.default_frame = saved.frame;
3190
+ \\ app_info.main_window.initial_placement = .restored;
3191
+ \\ }
3083
3192
  \\ }
3084
3193
  \\ }
3085
3194
  \\ } else if (app_info.main_window.restore_state) {
3086
3195
  \\ if (store.loadWindow(app_info.main_window.label, &buffers.read) catch null) |saved| {
3087
3196
  \\ app_info.main_window.default_frame = saved.frame;
3197
+ \\ app_info.main_window.initial_placement = .restored;
3088
3198
  \\ }
3089
3199
  \\ }
3090
3200
  \\ return store;
@@ -4023,7 +4133,10 @@ test "writeDefaultApp emits Vite project files" {
4023
4133
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "runner_mod.addImport(\"relational_migrations\", migrations_mod)") != null);
4024
4134
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSMicrophoneUsageDescription") != null);
4025
4135
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSAudioCaptureUsageDescription") != null);
4026
- try std.testing.expect(std.mem.count(u8, build_zig_text, "addMacosPrivacyInfoPlist(b, ") == 2);
4136
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "dock_visible: bool = true") != null);
4137
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, ".dock_visible = raw.dock_visible") != null);
4138
+ try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "LSUIElement") != null);
4139
+ try std.testing.expect(std.mem.count(u8, build_zig_text, "addMacosInfoPlist(b, ") == 2);
4027
4140
  // The generated graph carries the whole web-layer feature: the
4028
4141
  // override option, the app.zon inference with its conflict panic,
4029
4142
  // the option handed to the runner, and the conditional WebView2
@@ -4082,12 +4195,18 @@ test "writeDefaultApp emits Vite project files" {
4082
4195
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "relational_store: ?native_sdk.RelationalStoreBinding = null") != null);
4083
4196
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresSqlite()") != null);
4084
4197
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".relational_store = options.relational_store") != null);
4198
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "file_access: ?native_sdk.FileAccessBinding = null") != null);
4199
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "file_access_enforce: bool = true") != null);
4200
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "native_sdk.app_dirs.Buffers.fromArray") != null);
4201
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".file_access = options.file_access") != null);
4085
4202
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "resolvedShortcuts") != null);
4086
4203
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "const manifest_windows") != null);
4087
4204
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn appInfo(self: RunOptions, buffers: *StateBuffers)") != null);
4088
4205
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestWindowOptions") != null);
4089
4206
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.windows = windows") != null);
4090
4207
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "for (restored_windows, 0..)") != null);
4208
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "window.initial_placement = .restored") != null);
4209
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "app_info.main_window.initial_placement = .restored") != null);
4091
4210
  // The generated manifestWindow must thread every declarable window
4092
4211
  // option into WindowOptions — a dropped field is a silent no-op for
4093
4212
  // every `native create` app (the manifest accepts the declaration,
@@ -4096,6 +4215,7 @@ test "writeDefaultApp emits Vite project files" {
4096
4215
  // .hide window with no tray to bring it back must fail the build,
4097
4216
  // not strand a hidden window at runtime).
4098
4217
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".restore_policy = windowRestorePolicy(window)") != null);
4218
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".initial_placement = if (windowHasExplicitOrigin(window)) .explicit else .default") != null);
4099
4219
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".titlebar = windowTitlebarStyle(window)") != null);
4100
4220
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".min_width = windowMinSize(window, \"min_width\")") != null);
4101
4221
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".min_height = windowMinSize(window, \"min_height\")") != null);
@@ -4104,10 +4224,14 @@ test "writeDefaultApp emits Vite project files" {
4104
4224
  // The windows-conditional twin: `.hide` hides the taskbar entry and
4105
4225
  // windows has no dock-reopen path, so the declaration requires the
4106
4226
  // "tray" capability (the status item IS the re-show affordance).
4107
- // macOS stays exempt — the Dock reopen path always exists.
4227
+ // macOS regular apps have the Dock reopen path; accessory apps are
4228
+ // separately required to declare a tray by manifestDockVisible.
4108
4229
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "close_policy \\\"hide\\\" on windows requires the \\\"tray\\\" capability") != null);
4109
4230
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresTrayCapability()") != null);
4110
4231
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".declares_tray = manifestDeclaresTrayCapability()") != null);
4232
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDockVisible()") != null);
4233
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".dock_visible = manifestDockVisible()") != null);
4234
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "dock_visible = false requires the \\\"tray\\\" capability") != null);
4111
4235
  // The scene-first twin: an app.zon that declares its one window under
4112
4236
  // `.shell.windows` (the default `native init` shape) hits the
4113
4237
  // windows.len == 0 branch, and the startup window's host-create state
@@ -4119,6 +4243,14 @@ test "writeDefaultApp emits Vite project files" {
4119
4243
  // shell path carries the same Linux comptime refusal pinned above.
4120
4244
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.titlebar = manifestShellStartupTitlebar()") != null);
4121
4245
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.resizable = manifestShellStartupResizable()") != null);
4246
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.default_frame = manifestShellStartupFrame(info.main_window.default_frame)") != null);
4247
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "windowFloatFallback(window, \"x\", fallback.x)") != null);
4248
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.restore_state = manifestShellStartupRestoreState(info.main_window.restore_state)") != null);
4249
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "if (comptime @hasField(@TypeOf(window), \"restore_state\")) return window.restore_state") != null);
4250
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.restore_policy = manifestShellStartupRestorePolicy(info.main_window.restore_policy)") != null);
4251
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.initial_placement = manifestShellStartupInitialPlacement(info.main_window.initial_placement)") != null);
4252
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "if (comptime !@hasField(@TypeOf(window), \"restore_policy\")) return fallback") != null);
4253
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "return if (windowHasExplicitOrigin(shell.windows[0])) .explicit else fallback") != null);
4122
4254
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.show = manifestShellStartupShowMode()") != null);
4123
4255
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.min_width = manifestShellStartupMinSize(\"min_width\")") != null);
4124
4256
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.min_height = manifestShellStartupMinSize(\"min_height\")") != null);
@@ -4130,6 +4262,12 @@ test "writeDefaultApp emits Vite project files" {
4130
4262
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "defer std.heap.page_allocator.destroy(runtime)") != null);
4131
4263
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "native_sdk.Runtime.initAt(runtime, .{") != null);
4132
4264
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "Runtime.init(.{") == null);
4265
+ // Every generated desktop runner freezes the app.zon registered-image
4266
+ // budget into Runtime options, with a compatibility fallback for
4267
+ // manifests generated before the images block existed.
4268
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestImagePixelBudget() usize") != null);
4269
+ try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "@hasField(@TypeOf(app_manifest), \"images\")") != null);
4270
+ try std.testing.expectEqual(@as(usize, 4), std.mem.count(u8, runner_zig_text, ".max_image_pixel_bytes = manifestImagePixelBudget(),"));
4133
4271
  // The generated runner consumes the same web-layer contract: the
4134
4272
  // shared inference for honest menus, the build option threaded into
4135
4273
  // every runtime init, and the comptime conflict guard.
@@ -27,6 +27,7 @@ pub const Error = error{
27
27
  MissingTranspiler,
28
28
  BrokenToolchainInstall,
29
29
  ToolchainVersionMismatch,
30
+ InvalidWindowViewLabel,
30
31
  CoreCheckFailed,
31
32
  DevHostFailed,
32
33
  };
@@ -412,6 +413,48 @@ pub const PersistRoutes = struct {
412
413
  err: []const u8,
413
414
  };
414
415
 
416
+ /// Direct `src/windows/<label>.native` roots, sorted by label. Nested files
417
+ /// are import components, never independently addressable windows.
418
+ pub fn collectWindowViewLabels(allocator: std.mem.Allocator, io: std.Io, app_root: []const u8) ![][]const u8 {
419
+ const windows_path = try std.fs.path.join(allocator, &.{ app_root, "src", "windows" });
420
+ defer allocator.free(windows_path);
421
+ var cwd = std.Io.Dir.cwd();
422
+ var dir = cwd.openDir(io, windows_path, .{ .iterate = true }) catch return try allocator.alloc([]const u8, 0);
423
+ defer dir.close(io);
424
+ var labels: std.ArrayList([]const u8) = .empty;
425
+ errdefer {
426
+ for (labels.items) |label| allocator.free(label);
427
+ labels.deinit(allocator);
428
+ }
429
+ var it = dir.iterate();
430
+ while (try it.next(io)) |entry| {
431
+ if (entry.kind != .file or !std.mem.endsWith(u8, entry.name, ".native")) continue;
432
+ const label = entry.name[0 .. entry.name.len - ".native".len];
433
+ if (label.len == 0 or label.len > 64 or std.mem.eql(u8, label, ".") or std.mem.eql(u8, label, "..")) {
434
+ std.debug.print("invalid TypeScript secondary-window view filename '{s}': use src/windows/<label>.native with a non-empty label of at most 64 bytes\n", .{entry.name});
435
+ return error.InvalidWindowViewLabel;
436
+ }
437
+ for (label) |ch| {
438
+ if (ch == 0 or ch == '/' or ch == '\\') {
439
+ std.debug.print("invalid TypeScript secondary-window view filename '{s}': the filename stem must be a valid window label\n", .{entry.name});
440
+ return error.InvalidWindowViewLabel;
441
+ }
442
+ }
443
+ try labels.append(allocator, try allocator.dupe(u8, label));
444
+ }
445
+ std.mem.sort([]const u8, labels.items, {}, struct {
446
+ fn lessThan(_: void, a: []const u8, b: []const u8) bool {
447
+ return std.mem.order(u8, a, b) == .lt;
448
+ }
449
+ }.lessThan);
450
+ return try labels.toOwnedSlice(allocator);
451
+ }
452
+
453
+ pub fn freeWindowViewLabels(allocator: std.mem.Allocator, labels: [][]const u8) void {
454
+ for (labels) |label| allocator.free(label);
455
+ allocator.free(labels);
456
+ }
457
+
415
458
  /// Run the real-SQLite schema/query lane used by the build and return the
416
459
  /// generated SDK core path that exposes this app's Cmd.q/Sub.q surface.
417
460
  /// Generated outputs live under ignored .native/cache. The append-only
@@ -487,6 +530,7 @@ pub fn checkCore(
487
530
  persist_version: ?u64,
488
531
  persist_routes: ?PersistRoutes,
489
532
  sdk_core_path: ?[]const u8,
533
+ window_views: []const []const u8,
490
534
  ) !void {
491
535
  const cli_path = try transpilerPath(allocator, io, framework_root, "src/cli.ts");
492
536
  defer allocator.free(cli_path);
@@ -536,6 +580,8 @@ pub fn checkCore(
536
580
  });
537
581
  }
538
582
  if (sdk_core_path) |sdk_core| try argv.appendSlice(allocator, &.{ "--sdk-core", sdk_core });
583
+ try argv.append(allocator, "--window-views");
584
+ for (window_views) |label| try argv.appendSlice(allocator, &.{ "--window-view", label });
539
585
  var child = std.process.spawn(io, .{
540
586
  .argv = argv.items,
541
587
  .stdin = .ignore,
@@ -605,6 +651,7 @@ pub const DevHostOptions = struct {
605
651
  watch: bool = false,
606
652
  persist_routes: ?PersistRoutes = null,
607
653
  service_packages: []const ServicePackage = &.{},
654
+ window_views: []const []const u8 = &.{},
608
655
  };
609
656
 
610
657
  /// `native dev --core`: the node dev-harness over src/core.ts — the
@@ -696,6 +743,8 @@ pub fn runDevHost(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
696
743
  for (options.permissions) |permission| {
697
744
  try argv.appendSlice(allocator, &.{ "--permission", permission });
698
745
  }
746
+ try argv.append(allocator, "--window-views");
747
+ for (options.window_views) |label| try argv.appendSlice(allocator, &.{ "--window-view", label });
699
748
  if (sqlite_source) |sdk_core| {
700
749
  try argv.appendSlice(allocator, &.{ "--sdk-core", sdk_core, "--sqlite-src", "src" });
701
750
  }
@@ -954,6 +1003,40 @@ test "a stray package.json is not a language marker: detection keys on the core
954
1003
  try std.testing.expectEqual(CoreTree.ts, detectAt(io, root));
955
1004
  }
956
1005
 
1006
+ test "window view discovery includes only direct native roots and sorts labels" {
1007
+ const io = std.testing.io;
1008
+ var cwd = std.Io.Dir.cwd();
1009
+ const root = ".zig-cache/test-ts-window-view-labels";
1010
+ cwd.deleteTree(io, root) catch {};
1011
+ defer cwd.deleteTree(io, root) catch {};
1012
+ try cwd.createDirPath(io, root ++ "/src/windows/components");
1013
+ try cwd.writeFile(io, .{ .sub_path = root ++ "/src/windows/settings.native", .data = "<column/>" });
1014
+ try cwd.writeFile(io, .{ .sub_path = root ++ "/src/windows/about.native", .data = "<column/>" });
1015
+ try cwd.writeFile(io, .{ .sub_path = root ++ "/src/windows/ignored.txt", .data = "" });
1016
+ try cwd.writeFile(io, .{ .sub_path = root ++ "/src/windows/components/shared.native", .data = "<template name=\"shared\"/>" });
1017
+
1018
+ const labels = try collectWindowViewLabels(std.testing.allocator, io, root);
1019
+ defer freeWindowViewLabels(std.testing.allocator, labels);
1020
+ try std.testing.expectEqual(@as(usize, 2), labels.len);
1021
+ try std.testing.expectEqualStrings("about", labels[0]);
1022
+ try std.testing.expectEqualStrings("settings", labels[1]);
1023
+ }
1024
+
1025
+ test "window view discovery rejects labels beyond the platform budget" {
1026
+ const io = std.testing.io;
1027
+ var cwd = std.Io.Dir.cwd();
1028
+ const root = ".zig-cache/test-ts-window-view-label-budget";
1029
+ cwd.deleteTree(io, root) catch {};
1030
+ defer cwd.deleteTree(io, root) catch {};
1031
+ try cwd.createDirPath(io, root ++ "/src/windows");
1032
+ try cwd.writeFile(io, .{
1033
+ .sub_path = root ++ "/src/windows/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.native",
1034
+ .data = "<column/>",
1035
+ });
1036
+
1037
+ try std.testing.expectError(error.InvalidWindowViewLabel, collectWindowViewLabels(std.testing.allocator, io, root));
1038
+ }
1039
+
957
1040
  test "package.json version extraction" {
958
1041
  try std.testing.expectEqualStrings("0.0.1", parsePackageVersion(
959
1042
  \\{
@@ -80,7 +80,7 @@ pub fn parseManifestConfig(allocator: std.mem.Allocator, source: []const u8) !Ma
80
80
  defer arena.deinit();
81
81
  const scratch = arena.allocator();
82
82
  const source_z = try scratch.dupeZ(u8, source);
83
- @setEvalBranchQuota(2000);
83
+ @setEvalBranchQuota(4000);
84
84
  const raw = try std.zon.parse.fromSliceAlloc(raw_manifest.RawManifest, scratch, source_z, null, .{});
85
85
  return .{
86
86
  .web_engine = try allocator.dupe(u8, raw.web_engine),
@@ -1764,7 +1764,7 @@ test "a u64 attestation on chrome geometry refuses at check time" {
1764
1764
  // class cannot carry.
1765
1765
  const source =
1766
1766
  \\{
1767
- \\ "format": 1, "wire_version": 4, "abi_version": 2,
1767
+ \\ "format": 1, "wire_version": 7, "abi_version": 2,
1768
1768
  \\ "compiler_version": "0.0.1", "entry": "src/core.ts",
1769
1769
  \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface", "model_fingerprint": "00000000a11ce001",
1770
1770
  \\ "types": {
@@ -1945,7 +1945,7 @@ test "a shared authored type spelling like a synthesized name stays a top-level
1945
1945
  // first site would leave the second dangling.
1946
1946
  const source =
1947
1947
  \\{
1948
- \\ "format": 1, "wire_version": 4, "abi_version": 2,
1948
+ \\ "format": 1, "wire_version": 7, "abi_version": 2,
1949
1949
  \\ "compiler_version": "0.0.1", "entry": "src/core.ts",
1950
1950
  \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface", "model_fingerprint": "00000000a11ce001",
1951
1951
  \\ "types": {
@@ -2381,7 +2381,7 @@ test "a chrome arm holding its insets by reference refuses" {
2381
2381
  // node (by-reference) insets record cannot take that construction.
2382
2382
  const source =
2383
2383
  \\{
2384
- \\ "format": 1, "wire_version": 4, "abi_version": 2,
2384
+ \\ "format": 1, "wire_version": 7, "abi_version": 2,
2385
2385
  \\ "compiler_version": "0.0.1", "entry": "src/core.ts",
2386
2386
  \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface", "model_fingerprint": "00000000a11ce001",
2387
2387
  \\ "types": {