@native-sdk/cli 0.9.1 → 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 (130) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +55 -0
  3. package/package.json +9 -9
  4. package/packages/core/package-lock.json +2 -2
  5. package/packages/core/package.json +1 -1
  6. package/packages/core/sdk/core.ts +3 -1
  7. package/skill-data/native-ui/SKILL.md +7 -7
  8. package/skill-data/ts-core/SKILL.md +1 -1
  9. package/src/app_runner/root.zig +93 -6
  10. package/src/app_runner/ts_core_main.zig +4 -4
  11. package/src/app_runner/window_placement.zig +63 -0
  12. package/src/embed/app_exports.zig +2 -1
  13. package/src/embed/conversions.zig +1 -0
  14. package/src/embed/host.zig +10 -3
  15. package/src/embed/root.zig +1 -0
  16. package/src/embed/tests.zig +13 -1
  17. package/src/embed/types.zig +2 -0
  18. package/src/embed/ui_host.zig +26 -2
  19. package/src/platform/android/NativeSdkActivity.java +49 -4
  20. package/src/platform/android/android_host.c +3 -3
  21. package/src/platform/android/native_sdk_app.h +1 -1
  22. package/src/platform/ios/apple_image_fit.h +38 -0
  23. package/src/platform/ios/files.zig +1 -0
  24. package/src/platform/ios/native_sdk_app.h +1 -1
  25. package/src/platform/ios/uikit_host.m +28 -5
  26. package/src/platform/linux/cef_host.cpp +10 -2
  27. package/src/platform/linux/gtk_host.c +43 -10
  28. package/src/platform/linux/gtk_host.h +3 -3
  29. package/src/platform/linux/root.zig +22 -7
  30. package/src/platform/macos/appkit_host.h +7 -4
  31. package/src/platform/macos/appkit_host.m +192 -40
  32. package/src/platform/macos/cef_host.mm +132 -34
  33. package/src/platform/macos/image_fit_test.m +44 -0
  34. package/src/platform/macos/root.zig +154 -9
  35. package/src/platform/null_platform.zig +17 -3
  36. package/src/platform/null_platform_tests.zig +58 -4
  37. package/src/platform/root.zig +2 -0
  38. package/src/platform/types.zig +69 -19
  39. package/src/platform/windows/root.zig +22 -7
  40. package/src/platform/windows/webview2_host.cpp +31 -6
  41. package/src/primitives/app_manifest/root.zig +3 -0
  42. package/src/primitives/app_manifest/tests.zig +24 -0
  43. package/src/primitives/app_manifest/types.zig +13 -0
  44. package/src/primitives/app_manifest/validation.zig +24 -0
  45. package/src/primitives/canvas/a11y_audit.zig +9 -7
  46. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  47. package/src/primitives/canvas/events.zig +50 -0
  48. package/src/primitives/canvas/layout_audit.zig +6 -6
  49. package/src/primitives/canvas/markdown.zig +4 -0
  50. package/src/primitives/canvas/markdown_tests.zig +1 -0
  51. package/src/primitives/canvas/png.zig +138 -0
  52. package/src/primitives/canvas/root.zig +13 -2
  53. package/src/primitives/canvas/text_span_tests.zig +5 -3
  54. package/src/primitives/canvas/text_spans.zig +2 -0
  55. package/src/primitives/canvas/text_tests.zig +20 -0
  56. package/src/primitives/canvas/ui.zig +55 -2
  57. package/src/primitives/canvas/ui_markup.zig +40 -13
  58. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  59. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  60. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  62. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  63. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  64. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  65. package/src/primitives/canvas/ui_schema.zig +17 -13
  66. package/src/primitives/canvas/ui_tests.zig +47 -0
  67. package/src/primitives/canvas/widget_access.zig +3 -3
  68. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  69. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  70. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  71. package/src/primitives/canvas/widget_layout.zig +333 -126
  72. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  73. package/src/primitives/canvas/widget_metrics.zig +7 -8
  74. package/src/primitives/canvas/widget_render.zig +76 -44
  75. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  76. package/src/primitives/canvas/widget_render_style.zig +58 -18
  77. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  78. package/src/primitives/canvas/widget_routing.zig +40 -34
  79. package/src/primitives/canvas/widget_runtime.zig +11 -2
  80. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  81. package/src/primitives/canvas/widget_semantics.zig +8 -3
  82. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  83. package/src/primitives/canvas/widget_tree.zig +99 -5
  84. package/src/primitives/canvas/widgets.zig +20 -7
  85. package/src/root.zig +3 -0
  86. package/src/runtime/api.zig +6 -0
  87. package/src/runtime/automation_widget_dispatch.zig +48 -6
  88. package/src/runtime/builtin_bridge.zig +5 -2
  89. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  90. package/src/runtime/canvas_image_tests.zig +146 -2
  91. package/src/runtime/canvas_images.zig +35 -16
  92. package/src/runtime/canvas_limits.zig +13 -3
  93. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  94. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  95. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  96. package/src/runtime/canvas_widget_events.zig +151 -26
  97. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  98. package/src/runtime/canvas_widget_runtime.zig +322 -102
  99. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  100. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  101. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  102. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  103. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  104. package/src/runtime/canvas_widget_state.zig +33 -7
  105. package/src/runtime/core.zig +16 -0
  106. package/src/runtime/effects.zig +14 -14
  107. package/src/runtime/effects_image_tests.zig +91 -0
  108. package/src/runtime/gpu_surface_events.zig +25 -2
  109. package/src/runtime/root.zig +2 -0
  110. package/src/runtime/session_replay.zig +13 -8
  111. package/src/runtime/session_tests.zig +111 -4
  112. package/src/runtime/shell_layout_tests.zig +12 -0
  113. package/src/runtime/ts_core_host_tests.zig +47 -0
  114. package/src/runtime/ui_app.zig +9 -3
  115. package/src/runtime/ui_app_tests.zig +119 -19
  116. package/src/runtime/ui_app_window_tests.zig +13 -1
  117. package/src/runtime/view.zig +3 -0
  118. package/src/runtime/view_widget_control.zig +18 -0
  119. package/src/runtime/view_widget_scroll.zig +112 -18
  120. package/src/runtime/view_widget_tree.zig +110 -13
  121. package/src/runtime/widget_bridge.zig +2 -0
  122. package/src/runtime/window_command_bridge_tests.zig +86 -0
  123. package/src/runtime/window_storage.zig +16 -1
  124. package/src/runtime/window_views.zig +1 -0
  125. package/src/tooling/ios.zig +3 -0
  126. package/src/tooling/manifest.zig +90 -2
  127. package/src/tooling/package.zig +67 -2
  128. package/src/tooling/raw_manifest.zig +10 -0
  129. package/src/tooling/templates.zig +128 -18
  130. package/src/tooling/web_engine.zig +1 -1
@@ -10,7 +10,13 @@ pub const RawManifest = struct {
10
10
  platforms: []const []const u8 = &.{},
11
11
  permissions: []const []const u8 = &.{},
12
12
  capabilities: []const []const u8 = &.{},
13
+ /// Whether the app launches with a Dock/app-switcher presence on
14
+ /// macOS. False selects the accessory activation policy before any
15
+ /// startup window is created; the runtime dock-presence command may
16
+ /// still promote or demote the app later.
17
+ dock_visible: bool = true,
13
18
  persist: ?RawPersist = null,
19
+ images: RawImages = .{},
14
20
  service_packages: []const RawServicePackage = &.{},
15
21
  /// Which carrier runs src/services operations: "auto" (the default child
16
22
  /// carrier), "in_process", or "child".
@@ -41,6 +47,10 @@ pub const RawManifest = struct {
41
47
  dmg: RawDmg = .{},
42
48
  };
43
49
 
50
+ pub const RawImages = struct {
51
+ max_image_pixel_bytes: usize = 1024 * 1024,
52
+ };
53
+
44
54
  pub const RawServicePackage = struct {
45
55
  name: []const u8,
46
56
  version: []const u8,
@@ -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 };
@@ -2346,6 +2355,7 @@ fn runnerZig() []const u8 {
2346
2355
  \\ .app_name = self.app_name,
2347
2356
  \\ .has_web_content = manifestHasWebContent(),
2348
2357
  \\ .declares_tray = manifestDeclaresTrayCapability(),
2358
+ \\ .dock_visible = manifestDockVisible(),
2349
2359
  \\ .window_title = self.window_title,
2350
2360
  \\ .bundle_id = self.bundle_id,
2351
2361
  \\ .icon_path = self.icon_path,
@@ -2363,8 +2373,12 @@ fn runnerZig() []const u8 {
2363
2373
  \\ // a canvas-first startup window is created ordered-out and
2364
2374
  \\ // shown after its first canvas frame presents, so launch
2365
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);
2366
2378
  \\ info.main_window.titlebar = manifestShellStartupTitlebar();
2367
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);
2368
2382
  \\ info.main_window.show = manifestShellStartupShowMode();
2369
2383
  \\ info.main_window.transparent = manifestShellStartupBool("transparent", false);
2370
2384
  \\ info.main_window.always_on_top = manifestShellStartupBool("always_on_top", false);
@@ -2502,6 +2516,7 @@ fn runnerZig() []const u8 {
2502
2516
  \\ .resizable = windowBool(window, "resizable", true),
2503
2517
  \\ .restore_state = windowBool(window, "restore_state", true),
2504
2518
  \\ .restore_policy = windowRestorePolicy(window),
2519
+ \\ .initial_placement = if (windowHasExplicitOrigin(window)) .explicit else .default,
2505
2520
  \\ .titlebar = windowTitlebarStyle(window),
2506
2521
  \\ .show = if (windowBool(window, "initially_hidden", false)) .hidden else .immediate,
2507
2522
  \\ .transparent = windowBool(window, "transparent", false),
@@ -2545,6 +2560,60 @@ fn runnerZig() []const u8 {
2545
2560
  \\ @compileError("unknown app.zon window restore_policy");
2546
2561
  \\}
2547
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
+ \\
2548
2617
  \\/// Window-enforced content min-size floor from app.zon. Validated at
2549
2618
  \\/// comptime like the titlebar style: a negative floor is an authoring
2550
2619
  \\/// error, not a silent clamp.
@@ -2674,6 +2743,14 @@ fn runnerZig() []const u8 {
2674
2743
  \\ return false;
2675
2744
  \\}
2676
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
+ \\
2677
2754
  \\fn manifestDeclaresStore() bool {
2678
2755
  \\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
2679
2756
  \\ inline for (app_manifest.capabilities) |capability| {
@@ -2841,6 +2918,7 @@ fn runnerZig() []const u8 {
2841
2918
  \\ defer std.heap.page_allocator.destroy(runtime);
2842
2919
  \\ native_sdk.Runtime.initAt(runtime, .{
2843
2920
  \\ .platform = null_platform.platform(),
2921
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2844
2922
  \\ .trace_sink = runtime_trace_sink,
2845
2923
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2846
2924
  \\ .bridge = options.bridge,
@@ -2898,6 +2976,7 @@ fn runnerZig() []const u8 {
2898
2976
  \\ defer std.heap.page_allocator.destroy(runtime);
2899
2977
  \\ native_sdk.Runtime.initAt(runtime, .{
2900
2978
  \\ .platform = mac_platform.platform(),
2979
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2901
2980
  \\ .trace_sink = runtime_trace_sink,
2902
2981
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2903
2982
  \\ .bridge = options.bridge,
@@ -2955,6 +3034,7 @@ fn runnerZig() []const u8 {
2955
3034
  \\ defer std.heap.page_allocator.destroy(runtime);
2956
3035
  \\ native_sdk.Runtime.initAt(runtime, .{
2957
3036
  \\ .platform = linux_platform.platform(),
3037
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
2958
3038
  \\ .trace_sink = runtime_trace_sink,
2959
3039
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
2960
3040
  \\ .bridge = options.bridge,
@@ -3012,6 +3092,7 @@ fn runnerZig() []const u8 {
3012
3092
  \\ defer std.heap.page_allocator.destroy(runtime);
3013
3093
  \\ native_sdk.Runtime.initAt(runtime, .{
3014
3094
  \\ .platform = windows_platform.platform(),
3095
+ \\ .max_image_pixel_bytes = manifestImagePixelBudget(),
3015
3096
  \\ .trace_sink = runtime_trace_sink,
3016
3097
  \\ .log_path = if (log_setup) |setup| setup.paths.log_file else null,
3017
3098
  \\ .bridge = options.bridge,
@@ -3103,12 +3184,17 @@ fn runnerZig() []const u8 {
3103
3184
  \\ if (!window.restore_state) continue;
3104
3185
  \\ if (store.loadWindow(window.label, &buffers.read) catch null) |saved| {
3105
3186
  \\ window.default_frame = saved.frame;
3106
- \\ 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
+ \\ }
3107
3192
  \\ }
3108
3193
  \\ }
3109
3194
  \\ } else if (app_info.main_window.restore_state) {
3110
3195
  \\ if (store.loadWindow(app_info.main_window.label, &buffers.read) catch null) |saved| {
3111
3196
  \\ app_info.main_window.default_frame = saved.frame;
3197
+ \\ app_info.main_window.initial_placement = .restored;
3112
3198
  \\ }
3113
3199
  \\ }
3114
3200
  \\ return store;
@@ -4047,7 +4133,10 @@ test "writeDefaultApp emits Vite project files" {
4047
4133
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "runner_mod.addImport(\"relational_migrations\", migrations_mod)") != null);
4048
4134
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSMicrophoneUsageDescription") != null);
4049
4135
  try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSAudioCaptureUsageDescription") != null);
4050
- 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);
4051
4140
  // The generated graph carries the whole web-layer feature: the
4052
4141
  // override option, the app.zon inference with its conflict panic,
4053
4142
  // the option handed to the runner, and the conditional WebView2
@@ -4116,6 +4205,8 @@ test "writeDefaultApp emits Vite project files" {
4116
4205
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestWindowOptions") != null);
4117
4206
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.windows = windows") != null);
4118
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);
4119
4210
  // The generated manifestWindow must thread every declarable window
4120
4211
  // option into WindowOptions — a dropped field is a silent no-op for
4121
4212
  // every `native create` app (the manifest accepts the declaration,
@@ -4124,6 +4215,7 @@ test "writeDefaultApp emits Vite project files" {
4124
4215
  // .hide window with no tray to bring it back must fail the build,
4125
4216
  // not strand a hidden window at runtime).
4126
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);
4127
4219
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".titlebar = windowTitlebarStyle(window)") != null);
4128
4220
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".min_width = windowMinSize(window, \"min_width\")") != null);
4129
4221
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".min_height = windowMinSize(window, \"min_height\")") != null);
@@ -4132,10 +4224,14 @@ test "writeDefaultApp emits Vite project files" {
4132
4224
  // The windows-conditional twin: `.hide` hides the taskbar entry and
4133
4225
  // windows has no dock-reopen path, so the declaration requires the
4134
4226
  // "tray" capability (the status item IS the re-show affordance).
4135
- // 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.
4136
4229
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "close_policy \\\"hide\\\" on windows requires the \\\"tray\\\" capability") != null);
4137
4230
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresTrayCapability()") != null);
4138
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);
4139
4235
  // The scene-first twin: an app.zon that declares its one window under
4140
4236
  // `.shell.windows` (the default `native init` shape) hits the
4141
4237
  // windows.len == 0 branch, and the startup window's host-create state
@@ -4147,6 +4243,14 @@ test "writeDefaultApp emits Vite project files" {
4147
4243
  // shell path carries the same Linux comptime refusal pinned above.
4148
4244
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.titlebar = manifestShellStartupTitlebar()") != null);
4149
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);
4150
4254
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.show = manifestShellStartupShowMode()") != null);
4151
4255
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.min_width = manifestShellStartupMinSize(\"min_width\")") != null);
4152
4256
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.min_height = manifestShellStartupMinSize(\"min_height\")") != null);
@@ -4158,6 +4262,12 @@ test "writeDefaultApp emits Vite project files" {
4158
4262
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "defer std.heap.page_allocator.destroy(runtime)") != null);
4159
4263
  try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "native_sdk.Runtime.initAt(runtime, .{") != null);
4160
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(),"));
4161
4271
  // The generated runner consumes the same web-layer contract: the
4162
4272
  // shared inference for honest menus, the build option threaded into
4163
4273
  // every runtime init, and the comptime conflict guard.
@@ -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),