@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.
- package/build/app.zig +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
package/src/tooling/manifest.zig
CHANGED
|
@@ -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(
|
|
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(
|
|
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
|
\\.{
|
package/src/tooling/package.zig
CHANGED
|
@@ -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,
|