@native-sdk/cli 0.9.1 → 0.9.3

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 (156) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +124 -1
  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/packages/core/sdk/events.d.ts +7 -0
  8. package/packages/core/sdk/events.ts +26 -5
  9. package/packages/core/sdk/text.d.ts +4 -0
  10. package/packages/core/sdk/text.ts +51 -0
  11. package/packages/core/src/checker.ts +58 -1
  12. package/packages/core/src/contract.ts +5 -4
  13. package/packages/core/src/devhost_journal.mjs +2 -2
  14. package/packages/core/src/diagnostics.ts +2 -2
  15. package/packages/core/src/service_contract.ts +10 -0
  16. package/packages/core/src/typed_ast.ts +9 -7
  17. package/packages/core/src/types.ts +28 -8
  18. package/skill-data/automation/SKILL.md +4 -3
  19. package/skill-data/native-ui/SKILL.md +10 -8
  20. package/skill-data/ts-core/SKILL.md +8 -5
  21. package/src/app_runner/root.zig +301 -12
  22. package/src/app_runner/ts_core_main.zig +6 -4
  23. package/src/app_runner/window_placement.zig +63 -0
  24. package/src/automation/protocol.zig +5 -1
  25. package/src/automation/snapshot.zig +119 -0
  26. package/src/embed/app_exports.zig +2 -1
  27. package/src/embed/conversions.zig +1 -0
  28. package/src/embed/host.zig +10 -3
  29. package/src/embed/root.zig +1 -0
  30. package/src/embed/tests.zig +13 -1
  31. package/src/embed/types.zig +2 -0
  32. package/src/embed/ui_host.zig +26 -2
  33. package/src/platform/android/NativeSdkActivity.java +49 -4
  34. package/src/platform/android/android_host.c +3 -3
  35. package/src/platform/android/native_sdk_app.h +1 -1
  36. package/src/platform/ios/apple_image_fit.h +38 -0
  37. package/src/platform/ios/files.zig +1 -0
  38. package/src/platform/ios/native_sdk_app.h +1 -1
  39. package/src/platform/ios/uikit_host.m +28 -5
  40. package/src/platform/linux/cef_host.cpp +10 -2
  41. package/src/platform/linux/gtk_host.c +43 -10
  42. package/src/platform/linux/gtk_host.h +3 -3
  43. package/src/platform/linux/root.zig +22 -7
  44. package/src/platform/macos/appkit_host.h +7 -4
  45. package/src/platform/macos/appkit_host.m +271 -52
  46. package/src/platform/macos/cef_host.mm +132 -34
  47. package/src/platform/macos/image_fit_test.m +44 -0
  48. package/src/platform/macos/root.zig +222 -14
  49. package/src/platform/null_platform.zig +17 -3
  50. package/src/platform/null_platform_tests.zig +58 -4
  51. package/src/platform/root.zig +2 -0
  52. package/src/platform/types.zig +69 -19
  53. package/src/platform/windows/root.zig +22 -7
  54. package/src/platform/windows/webview2_host.cpp +31 -6
  55. package/src/primitives/app_manifest/root.zig +3 -0
  56. package/src/primitives/app_manifest/tests.zig +24 -0
  57. package/src/primitives/app_manifest/types.zig +13 -0
  58. package/src/primitives/app_manifest/validation.zig +24 -0
  59. package/src/primitives/canvas/a11y_audit.zig +9 -7
  60. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  61. package/src/primitives/canvas/events.zig +129 -1
  62. package/src/primitives/canvas/layout_audit.zig +6 -6
  63. package/src/primitives/canvas/markdown.zig +4 -0
  64. package/src/primitives/canvas/markdown_tests.zig +1 -0
  65. package/src/primitives/canvas/png.zig +138 -0
  66. package/src/primitives/canvas/root.zig +14 -2
  67. package/src/primitives/canvas/text_interaction.zig +23 -0
  68. package/src/primitives/canvas/text_span_tests.zig +5 -3
  69. package/src/primitives/canvas/text_spans.zig +2 -0
  70. package/src/primitives/canvas/text_tests.zig +65 -0
  71. package/src/primitives/canvas/ui.zig +66 -10
  72. package/src/primitives/canvas/ui_markup.zig +40 -13
  73. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  74. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  75. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  76. package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
  77. package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
  78. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  79. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  80. package/src/primitives/canvas/ui_markup_view_tests.zig +67 -6
  81. package/src/primitives/canvas/ui_schema.zig +17 -13
  82. package/src/primitives/canvas/ui_tests.zig +84 -0
  83. package/src/primitives/canvas/widget_access.zig +3 -3
  84. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  85. package/src/primitives/canvas/widget_builtin_tests.zig +593 -32
  86. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  87. package/src/primitives/canvas/widget_layout.zig +333 -126
  88. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  89. package/src/primitives/canvas/widget_metrics.zig +7 -8
  90. package/src/primitives/canvas/widget_render.zig +76 -44
  91. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  92. package/src/primitives/canvas/widget_render_style.zig +58 -18
  93. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  94. package/src/primitives/canvas/widget_routing.zig +40 -34
  95. package/src/primitives/canvas/widget_runtime.zig +11 -2
  96. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  97. package/src/primitives/canvas/widget_semantics.zig +8 -3
  98. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  99. package/src/primitives/canvas/widget_tree.zig +99 -5
  100. package/src/primitives/canvas/widgets.zig +20 -7
  101. package/src/root.zig +3 -0
  102. package/src/runtime/api.zig +6 -0
  103. package/src/runtime/automation_snapshot.zig +4 -0
  104. package/src/runtime/automation_widget_dispatch.zig +48 -6
  105. package/src/runtime/builtin_bridge.zig +5 -2
  106. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  107. package/src/runtime/canvas_image_tests.zig +146 -2
  108. package/src/runtime/canvas_images.zig +35 -16
  109. package/src/runtime/canvas_limits.zig +13 -3
  110. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  111. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  112. package/src/runtime/canvas_widget_control_tests.zig +33 -1
  113. package/src/runtime/canvas_widget_events.zig +151 -26
  114. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  115. package/src/runtime/canvas_widget_runtime.zig +322 -102
  116. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  117. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  118. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  119. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  120. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  121. package/src/runtime/canvas_widget_state.zig +33 -7
  122. package/src/runtime/canvas_widget_text_tests.zig +124 -0
  123. package/src/runtime/core.zig +16 -0
  124. package/src/runtime/effects.zig +14 -14
  125. package/src/runtime/effects_image_tests.zig +91 -0
  126. package/src/runtime/gpu_surface_events.zig +25 -2
  127. package/src/runtime/native_command_event_tests.zig +29 -0
  128. package/src/runtime/root.zig +2 -0
  129. package/src/runtime/session_journal.zig +21 -2
  130. package/src/runtime/session_replay.zig +13 -8
  131. package/src/runtime/session_tests.zig +111 -4
  132. package/src/runtime/shell_layout_tests.zig +12 -0
  133. package/src/runtime/ts_core_host_tests.zig +47 -0
  134. package/src/runtime/ts_ui_app.zig +164 -1
  135. package/src/runtime/ui_app.zig +100 -21
  136. package/src/runtime/ui_app_tests.zig +351 -32
  137. package/src/runtime/ui_app_window_tests.zig +13 -1
  138. package/src/runtime/view.zig +3 -0
  139. package/src/runtime/view_widget_control.zig +18 -0
  140. package/src/runtime/view_widget_scroll.zig +112 -18
  141. package/src/runtime/view_widget_text.zig +1 -1
  142. package/src/runtime/view_widget_tree.zig +110 -13
  143. package/src/runtime/widget_bridge.zig +2 -0
  144. package/src/runtime/window_command_bridge_tests.zig +86 -0
  145. package/src/runtime/window_storage.zig +16 -1
  146. package/src/runtime/window_views.zig +1 -0
  147. package/src/tooling/ios.zig +3 -0
  148. package/src/tooling/manifest.zig +90 -2
  149. package/src/tooling/package.zig +67 -2
  150. package/src/tooling/raw_manifest.zig +10 -0
  151. package/src/tooling/templates.zig +128 -18
  152. package/src/tooling/verbs.zig +1 -0
  153. package/src/tooling/web_engine.zig +1 -1
  154. package/tools/corewire/emit.zig +31 -12
  155. package/tools/corewire/emit_facade.zig +57 -2
  156. package/tools/corewire/shim_rt.zig +20 -0
@@ -22,7 +22,9 @@ pub const Metadata = struct {
22
22
  platforms: []const []const u8 = &.{},
23
23
  permissions: []const []const u8 = &.{},
24
24
  capabilities: []const []const u8 = &.{},
25
+ dock_visible: bool = true,
25
26
  persist: ?PersistMetadata = null,
27
+ images: ImagesMetadata = .{},
26
28
  service_packages: []const ServicePackageMetadata = &.{},
27
29
  /// Which carrier runs src/services operations: "auto", "in_process",
28
30
  /// or "child". Validated so a typo teaches at check time.
@@ -228,6 +230,10 @@ pub const PersistMetadata = struct {
228
230
  restore: PersistRestoreMetadata,
229
231
  };
230
232
 
233
+ pub const ImagesMetadata = struct {
234
+ max_image_pixel_bytes: usize = 1024 * 1024,
235
+ };
236
+
231
237
  pub const PersistRestoreMetadata = struct {
232
238
  ok: []const u8,
233
239
  none: []const u8,
@@ -495,6 +501,10 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
495
501
  const capabilities = parseCapabilities(allocator, metadata.capabilities) catch return .{ .ok = false, .message = "app.zon capabilities are invalid" };
496
502
  defer allocator.free(capabilities);
497
503
  const persist = convertPersist(metadata.persist);
504
+ app_manifest.validateImages(.{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes }) catch return .{
505
+ .ok = false,
506
+ .message = "app.zon images.max_image_pixel_bytes must be between 1048576 (the default) and 8388608 bytes; allocation is lazy once per used slot, up to 16 slots",
507
+ };
498
508
  if (!validServicePackages(metadata.service_packages)) return .{
499
509
  .ok = false,
500
510
  .message = "app.zon service_packages must use safe npm names, exact X.Y.Z versions, unique names, and lowercase SHA-256 content hashes",
@@ -554,7 +564,9 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
554
564
  .version = parseVersion(metadata.version) catch return .{ .ok = false, .message = "app.zon version is invalid" },
555
565
  .permissions = permissions,
556
566
  .capabilities = capabilities,
567
+ .dock_visible = metadata.dock_visible,
557
568
  .persist = persist,
569
+ .images = .{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes },
558
570
  .bridge = .{ .commands = bridge_commands },
559
571
  .frontend = frontend,
560
572
  .security = security,
@@ -573,6 +585,7 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
573
585
  app_manifest.validateManifest(manifest) catch |err| return .{
574
586
  .ok = false,
575
587
  .message = switch (err) {
588
+ error.MissingTrayCapability => "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)",
576
589
  error.WebViewLayerConflict => web_layer_conflict_message,
577
590
  else => "manifest fields failed semantic validation",
578
591
  },
@@ -591,7 +604,7 @@ fn zonParseFailureMessage(allocator: std.mem.Allocator, source: []const u8) ?[]c
591
604
  const source_z = scratch.dupeZ(u8, source) catch return null;
592
605
  var diag: std.zon.parse.Diagnostics = .{};
593
606
  defer diag.deinit(scratch);
594
- @setEvalBranchQuota(2000);
607
+ @setEvalBranchQuota(4000);
595
608
  if (std.zon.parse.fromSliceAlloc(RawManifest, scratch, source_z, &diag, .{})) |_| {
596
609
  return null;
597
610
  } else |_| {
@@ -614,7 +627,7 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
614
627
  defer arena.deinit();
615
628
  const scratch = arena.allocator();
616
629
  const source_z = try scratch.dupeZ(u8, source);
617
- @setEvalBranchQuota(2000);
630
+ @setEvalBranchQuota(4000);
618
631
  const raw = try std.zon.parse.fromSliceAlloc(RawManifest, scratch, source_z, null, .{});
619
632
  return .{
620
633
  .id = try allocator.dupe(u8, raw.id),
@@ -628,7 +641,9 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
628
641
  .platforms = try duplicateStringList(allocator, raw.platforms),
629
642
  .permissions = try duplicateStringList(allocator, raw.permissions),
630
643
  .capabilities = try duplicateStringList(allocator, raw.capabilities),
644
+ .dock_visible = raw.dock_visible,
631
645
  .persist = try duplicateRawPersist(allocator, raw.persist),
646
+ .images = .{ .max_image_pixel_bytes = raw.images.max_image_pixel_bytes },
632
647
  .service_packages = try duplicateRawServicePackages(allocator, raw.service_packages),
633
648
  .service_carrier = try allocator.dupe(u8, raw.service_carrier),
634
649
  .service_pool_size = if (raw.service_pool_size == 0) null else raw.service_pool_size,
@@ -2507,6 +2522,47 @@ test "manifest metadata parser reads identity version and lists" {
2507
2522
  });
2508
2523
  }
2509
2524
 
2525
+ test "manifest parser reads dock visibility and defaults it to visible" {
2526
+ const accessory = try parseText(std.testing.allocator,
2527
+ \\.{
2528
+ \\ .id = "com.example.menu",
2529
+ \\ .name = "menu",
2530
+ \\ .version = "1.0.0",
2531
+ \\ .capabilities = .{"tray"},
2532
+ \\ .dock_visible = false,
2533
+ \\}
2534
+ );
2535
+ defer accessory.deinit(std.testing.allocator);
2536
+ try std.testing.expect(!accessory.dock_visible);
2537
+
2538
+ const regular = try parseText(std.testing.allocator,
2539
+ \\.{
2540
+ \\ .id = "com.example.regular",
2541
+ \\ .name = "regular",
2542
+ \\ .version = "1.0.0",
2543
+ \\}
2544
+ );
2545
+ defer regular.deinit(std.testing.allocator);
2546
+ try std.testing.expect(regular.dock_visible);
2547
+ }
2548
+
2549
+ test "manifest parser carries and validates registered-image budgets" {
2550
+ const metadata = try parseText(std.testing.allocator,
2551
+ \\.{
2552
+ \\ .id = "com.example.photos",
2553
+ \\ .name = "photos",
2554
+ \\ .version = "1.0.0",
2555
+ \\ .images = .{ .max_image_pixel_bytes = 8388608 },
2556
+ \\}
2557
+ );
2558
+ defer metadata.deinit(std.testing.allocator);
2559
+ try std.testing.expectEqual(@as(usize, 8 * 1024 * 1024), metadata.images.max_image_pixel_bytes);
2560
+ try app_manifest.validateImages(.{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes });
2561
+
2562
+ try std.testing.expectError(error.InvalidDimension, app_manifest.validateImages(.{ .max_image_pixel_bytes = 1048575 }));
2563
+ try std.testing.expectError(error.InvalidDimension, app_manifest.validateImages(.{ .max_image_pixel_bytes = 8388609 }));
2564
+ }
2565
+
2510
2566
  test "manifest metadata parser carries model persistence configuration" {
2511
2567
  const metadata = try parseText(std.testing.allocator,
2512
2568
  \\.{
@@ -3270,6 +3326,38 @@ test "validate rejects a web-declaring manifest that excludes the web layer" {
3270
3326
  try std.testing.expect(std.mem.indexOf(u8, invalid.message, "webview_layer is invalid") != null);
3271
3327
  }
3272
3328
 
3329
+ test "validate rejects accessory startup without a tray capability" {
3330
+ var cwd = std.Io.Dir.cwd();
3331
+ const root = ".zig-cache/test-validate-accessory-tray";
3332
+ try cwd.deleteTree(std.testing.io, root);
3333
+ defer cwd.deleteTree(std.testing.io, root) catch {};
3334
+ try cwd.createDirPath(std.testing.io, root);
3335
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/app.zon", .data =
3336
+ \\.{
3337
+ \\ .id = "dev.example.accessory",
3338
+ \\ .name = "accessory",
3339
+ \\ .version = "1.0.0",
3340
+ \\ .dock_visible = false,
3341
+ \\}
3342
+ });
3343
+
3344
+ const invalid = try validateFile(std.testing.allocator, std.testing.io, root ++ "/app.zon");
3345
+ try std.testing.expect(!invalid.ok);
3346
+ try std.testing.expect(std.mem.indexOf(u8, invalid.message, "dock_visible = false requires the \"tray\" capability") != null);
3347
+
3348
+ try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/app.zon", .data =
3349
+ \\.{
3350
+ \\ .id = "dev.example.accessory",
3351
+ \\ .name = "accessory",
3352
+ \\ .version = "1.0.0",
3353
+ \\ .capabilities = .{"tray"},
3354
+ \\ .dock_visible = false,
3355
+ \\}
3356
+ });
3357
+ const valid = try validateFile(std.testing.allocator, std.testing.io, root ++ "/app.zon");
3358
+ try std.testing.expect(valid.ok);
3359
+ }
3360
+
3273
3361
  test "manifest validates the theme pack name" {
3274
3362
  const metadata = try parseText(std.testing.allocator,
3275
3363
  \\.{
@@ -197,6 +197,15 @@ pub fn artifactName(buffer: []u8, metadata: manifest_tool.Metadata, target: Pack
197
197
  }
198
198
 
199
199
  pub fn createPackage(allocator: std.mem.Allocator, io: std.Io, options: PackageOptions) !PackageStats {
200
+ // Keep the manifest's accessory-app safety invariant at the artifact
201
+ // boundary too. CLI package verbs and direct callers receive Metadata,
202
+ // not the typed manifest that `native validate` checks, so without this
203
+ // guard they could emit LSUIElement=true for an app with no status-item
204
+ // route back to its hidden windows.
205
+ if (!options.metadata.dock_visible and !metadataHasCapability(options.metadata, "tray")) {
206
+ std.debug.print("error: 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)\n", .{});
207
+ return error.MissingTrayCapability;
208
+ }
200
209
  // The package boundary of the reject-conflicts contract: an exclude
201
210
  // (from `--web-layer` or app.zon) against declared web content — or
202
211
  // against a resolved Chromium engine — never becomes an artifact.
@@ -233,6 +242,13 @@ pub fn createPackage(allocator: std.mem.Allocator, io: std.Io, options: PackageO
233
242
  return stats;
234
243
  }
235
244
 
245
+ fn metadataHasCapability(metadata: manifest_tool.Metadata, name: []const u8) bool {
246
+ for (metadata.capabilities) |capability| {
247
+ if (std.mem.eql(u8, capability, name)) return true;
248
+ }
249
+ return false;
250
+ }
251
+
236
252
  fn validateWebEngineTarget(target: PackageTarget, web_engine: WebEngine) !void {
237
253
  if (web_engine != .chromium) return;
238
254
  switch (target) {
@@ -503,6 +519,7 @@ fn createIosArtifact(allocator: std.mem.Allocator, io: std.Io, options: PackageO
503
519
  try dir.createDirPath(io, "Host");
504
520
  try writeFile(dir, io, "Host/" ++ ios_tool.host_source_name, ios_tool.host_source);
505
521
  try writeFile(dir, io, "Host/" ++ ios_tool.host_header_name, ios_tool.host_header);
522
+ try writeFile(dir, io, "Host/" ++ ios_tool.host_image_fit_header_name, ios_tool.host_image_fit_header);
506
523
  const info_plist = try ios_tool.infoPlistAlloc(allocator, options.metadata);
507
524
  defer allocator.free(info_plist);
508
525
  try writeFile(dir, io, "Host/Info.plist", info_plist);
@@ -737,6 +754,10 @@ fn macosInfoPlist(allocator: std.mem.Allocator, metadata: manifest_tool.Metadata
737
754
  defer allocator.free(url_types);
738
755
  const privacy_descriptions = try macosPrivacyUsageDescriptions(allocator, metadata);
739
756
  defer allocator.free(privacy_descriptions);
757
+ const launch_policy = if (!metadata.dock_visible)
758
+ " <key>LSUIElement</key>\n <true/>\n"
759
+ else
760
+ "";
740
761
  // The About panel's bottom line in packaged bundles: the manifest
741
762
  // description rides NSHumanReadableCopyright, the plist key the
742
763
  // standard About panel renders as its footer text — the same line
@@ -773,11 +794,11 @@ fn macosInfoPlist(allocator: std.mem.Allocator, metadata: manifest_tool.Metadata
773
794
  \\ <string>{s}</string>
774
795
  \\ <key>CFBundleVersion</key>
775
796
  \\ <string>{s}</string>
776
- \\{s}{s}{s}{s}
797
+ \\{s}{s}{s}{s}{s}
777
798
  \\</dict>
778
799
  \\</plist>
779
800
  \\
780
- , .{ bundle_id, display_name, display_name, executable, icon, version, version, about_line, privacy_descriptions, document_types, url_types });
801
+ , .{ bundle_id, display_name, display_name, executable, icon, version, version, launch_policy, about_line, privacy_descriptions, document_types, url_types });
781
802
  }
782
803
 
783
804
  fn metadataHasPermission(metadata: manifest_tool.Metadata, name: []const u8) bool {
@@ -3022,6 +3043,14 @@ test "mobile package artifacts use manifest identity metadata" {
3022
3043
  const packaged_activity = try readPath(std.testing.allocator, std.testing.io, ".zig-cache/test-package-mobile-identity/android/Host/NativeSdkActivity.java");
3023
3044
  defer std.testing.allocator.free(packaged_activity);
3024
3045
  try std.testing.expectEqualStrings(android_tool.host_activity_source, packaged_activity);
3046
+ // Decode-to-fit must use ceiling-rounded power-of-two samples for
3047
+ // one-pixel panoramas, then enforce the axis cap only after the exact
3048
+ // resize. Checking the emitted host pins both the source asset and the
3049
+ // ordering that keeps an 8193x1 source loadable as 8192x1.
3050
+ try std.testing.expect(std.mem.indexOf(u8, packaged_activity, "int sampledHeight = (sourceHeight - 1) / nextSampleSize + 1;") != null);
3051
+ const exact_fit_index = std.mem.indexOf(u8, packaged_activity, "Bitmap fitted = Bitmap.createScaledBitmap") orelse return error.TestUnexpectedResult;
3052
+ const final_cap_index = std.mem.indexOf(u8, packaged_activity, "if (width > MAX_DECODED_IMAGE_DIMENSION || height > MAX_DECODED_IMAGE_DIMENSION || width > maxPixels / height)") orelse return error.TestUnexpectedResult;
3053
+ try std.testing.expect(exact_fit_index < final_cap_index);
3025
3054
  const packaged_bridge = try readPath(std.testing.allocator, std.testing.io, ".zig-cache/test-package-mobile-identity/android/Host/android_host.c");
3026
3055
  defer std.testing.allocator.free(packaged_bridge);
3027
3056
  try std.testing.expectEqualStrings(android_tool.host_bridge_source, packaged_bridge);
@@ -3186,6 +3215,42 @@ test "plist capture usage descriptions follow manifest permissions" {
3186
3215
  try std.testing.expect(std.mem.indexOf(u8, bare_plist, "NSScreenCaptureUsageDescription") == null);
3187
3216
  }
3188
3217
 
3218
+ test "plist launch policy follows dock visibility" {
3219
+ const accessory: manifest_tool.Metadata = .{
3220
+ .id = "dev.example.menu",
3221
+ .name = "menu",
3222
+ .version = "1.0.0",
3223
+ .dock_visible = false,
3224
+ };
3225
+ const accessory_plist = try macosInfoPlist(std.testing.allocator, accessory, "menu");
3226
+ defer std.testing.allocator.free(accessory_plist);
3227
+ try std.testing.expect(std.mem.indexOf(u8, accessory_plist, "<key>LSUIElement</key>\n <true/>") != null);
3228
+
3229
+ const regular: manifest_tool.Metadata = .{ .id = "dev.example.app", .name = "demo", .version = "1.0.0" };
3230
+ const regular_plist = try macosInfoPlist(std.testing.allocator, regular, "demo");
3231
+ defer std.testing.allocator.free(regular_plist);
3232
+ try std.testing.expect(std.mem.indexOf(u8, regular_plist, "LSUIElement") == null);
3233
+ }
3234
+
3235
+ test "package rejects accessory startup without a tray before staging an artifact" {
3236
+ var cwd = std.Io.Dir.cwd();
3237
+ const root = ".zig-cache/test-package-accessory-tray";
3238
+ try cwd.deleteTree(std.testing.io, root);
3239
+ defer cwd.deleteTree(std.testing.io, root) catch {};
3240
+
3241
+ try std.testing.expectError(error.MissingTrayCapability, createPackage(std.testing.allocator, std.testing.io, .{
3242
+ .metadata = .{
3243
+ .id = "dev.example.stranded",
3244
+ .name = "stranded",
3245
+ .version = "1.0.0",
3246
+ .dock_visible = false,
3247
+ },
3248
+ .target = .macos,
3249
+ .output_path = root ++ "/Stranded.app",
3250
+ }));
3251
+ try std.testing.expectError(error.FileNotFound, cwd.openDir(std.testing.io, root ++ "/Stranded.app", .{}));
3252
+ }
3253
+
3189
3254
  test "plist template includes document and URL registrations" {
3190
3255
  const extensions = [_][]const u8{ "md", ".markdown" };
3191
3256
  const mime_types = [_][]const u8{"text/markdown"};
@@ -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,