@native-sdk/cli 0.8.4 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +859 -62
- package/build.zig +543 -13
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +2 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +365 -2
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +149 -0
- package/packages/core/sdk/core.ts +529 -12
- package/packages/core/sdk/events.d.ts +36 -0
- package/packages/core/sdk/events.ts +57 -0
- package/packages/core/src/checker.ts +468 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1847 -16
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +82 -16
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +47 -0
- package/skill-data/ts-core/SKILL.md +80 -31
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +249 -8
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +109 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +119 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +40 -18
- package/src/platform/macos/appkit_host.h +16 -3
- package/src/platform/macos/appkit_host.m +536 -36
- package/src/platform/macos/cef_host.mm +248 -36
- package/src/platform/macos/root.zig +244 -34
- package/src/platform/null_platform.zig +223 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +179 -15
- package/src/platform/windows/root.zig +187 -21
- package/src/platform/windows/webview2_host.cpp +293 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/root.zig +46 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +18 -11
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2295 -113
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +49 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +4 -0
- package/src/runtime/ts_core_host.zig +788 -86
- package/src/runtime/ts_core_host_tests.zig +231 -11
- package/src/runtime/ts_ui_app.zig +499 -1
- package/src/runtime/ui_app.zig +142 -16
- package/src/runtime/ui_app_tests.zig +155 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +9 -0
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +214 -2
- package/src/tooling/package.zig +116 -0
- package/src/tooling/raw_manifest.zig +30 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +161 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +378 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -42,6 +42,7 @@ const AppKitEventKind = enum(c_int) {
|
|
|
42
42
|
audio = 20,
|
|
43
43
|
video = 21,
|
|
44
44
|
view_focused = 22,
|
|
45
|
+
tray_command = 23,
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
const AppKitEvent = extern struct {
|
|
@@ -179,7 +180,11 @@ extern fn native_sdk_appkit_set_window_content_min_size(host: *AppKitHost, windo
|
|
|
179
180
|
extern fn native_sdk_appkit_focus_window(host: *AppKitHost, window_id: u64) c_int;
|
|
180
181
|
extern fn native_sdk_appkit_close_window(host: *AppKitHost, window_id: u64) c_int;
|
|
181
182
|
extern fn native_sdk_appkit_minimize_window(host: *AppKitHost, window_id: u64) c_int;
|
|
183
|
+
extern fn native_sdk_appkit_hide_window(host: *AppKitHost, window_id: u64) c_int;
|
|
182
184
|
extern fn native_sdk_appkit_show_window(host: *AppKitHost, window_id: u64) c_int;
|
|
185
|
+
extern fn native_sdk_appkit_set_dock_presence(host: *AppKitHost, visible: c_int) c_int;
|
|
186
|
+
extern fn native_sdk_appkit_launch_at_login_status(host: *AppKitHost) c_int;
|
|
187
|
+
extern fn native_sdk_appkit_set_launch_at_login(host: *AppKitHost, enabled: c_int) c_int;
|
|
183
188
|
extern fn native_sdk_appkit_set_window_close_policy(host: *AppKitHost, window_id: u64, close_policy: c_int) c_int;
|
|
184
189
|
extern fn native_sdk_appkit_start_window_drag(host: *AppKitHost, window_id: u64) c_int;
|
|
185
190
|
extern fn native_sdk_appkit_window_chrome_insets(host: *AppKitHost, window_id: u64, top: *f64, left: *f64, bottom: *f64, right: *f64, buttons_x: *f64, buttons_y: *f64, buttons_width: *f64, buttons_height: *f64) c_int;
|
|
@@ -249,6 +254,7 @@ extern fn native_sdk_appkit_clear_recent_documents(host: *AppKitHost) c_int;
|
|
|
249
254
|
extern fn native_sdk_appkit_set_credential(host: *AppKitHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, secret: [*]const u8, secret_len: usize) c_int;
|
|
250
255
|
extern fn native_sdk_appkit_get_credential(host: *AppKitHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
251
256
|
extern fn native_sdk_appkit_delete_credential(host: *AppKitHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize) c_int;
|
|
257
|
+
extern fn native_sdk_appkit_format_local_time(host: *AppKitHost, timestamp_ms: i64, style: c_int, buffer: [*]u8, buffer_len: usize) usize;
|
|
252
258
|
|
|
253
259
|
const AppKitScrollOccluder = extern struct {
|
|
254
260
|
x: f64,
|
|
@@ -398,9 +404,10 @@ const AppKitTrayCallback = *const fn (context: ?*anyopaque, item_id: u32) callco
|
|
|
398
404
|
extern fn native_sdk_appkit_show_open_dialog(host: *AppKitHost, opts: *const AppKitOpenDialogOpts, buffer: [*]u8, buffer_len: usize) AppKitOpenDialogResult;
|
|
399
405
|
extern fn native_sdk_appkit_show_save_dialog(host: *AppKitHost, opts: *const AppKitSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
|
|
400
406
|
extern fn native_sdk_appkit_show_message_dialog(host: *AppKitHost, opts: *const AppKitMessageDialogOpts) c_int;
|
|
401
|
-
extern fn native_sdk_appkit_create_tray(host: *AppKitHost, icon_path: [*]const u8, icon_path_len: usize, title: [*]const u8, title_len: usize, tooltip: [*]const u8, tooltip_len: usize) void;
|
|
402
|
-
extern fn native_sdk_appkit_update_tray_menu(host: *AppKitHost, item_ids: [*]const u32, labels: [*]const [*]const u8, label_lens: [*]const usize, separators: [*]const c_int, enabled_flags: [*]const c_int, count: usize) void;
|
|
407
|
+
extern fn native_sdk_appkit_create_tray(host: *AppKitHost, icon_path: [*]const u8, icon_path_len: usize, title: [*]const u8, title_len: usize, tooltip: [*]const u8, tooltip_len: usize, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int, activation_command: [*]const u8, activation_command_len: usize, alternate_activation_command: [*]const u8, alternate_activation_command_len: usize, open_command: [*]const u8, open_command_len: usize) void;
|
|
408
|
+
extern fn native_sdk_appkit_update_tray_menu(host: *AppKitHost, item_ids: [*]const u32, labels: [*]const [*]const u8, label_lens: [*]const usize, separators: [*]const c_int, enabled_flags: [*]const c_int, details: [*]const [*]const u8, detail_lens: [*]const usize, roles: [*]const c_int, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
403
409
|
extern fn native_sdk_appkit_update_tray_title(host: *AppKitHost, title: [*]const u8, title_len: usize) void;
|
|
410
|
+
extern fn native_sdk_appkit_update_tray_presentation(host: *AppKitHost, title: [*]const u8, title_len: usize, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int) void;
|
|
404
411
|
extern fn native_sdk_appkit_remove_tray(host: *AppKitHost) void;
|
|
405
412
|
extern fn native_sdk_appkit_set_tray_callback(host: *AppKitHost, callback: AppKitTrayCallback, context: ?*anyopaque) void;
|
|
406
413
|
|
|
@@ -572,9 +579,8 @@ pub const MacPlatform = struct {
|
|
|
572
579
|
app_info: platform_mod.AppInfo,
|
|
573
580
|
surface_value: platform_mod.Surface,
|
|
574
581
|
state: RunState = .{},
|
|
575
|
-
/// Latched when
|
|
576
|
-
///
|
|
577
|
-
/// `PlatformServices.note_channel_wake_abandoned_fn`): the stale
|
|
582
|
+
/// Latched when effects teardown abandons an in-flight platform call
|
|
583
|
+
/// (a channel wake or blocking credential operation): the stale
|
|
578
584
|
/// call still holds this platform as its context and may execute
|
|
579
585
|
/// into it at any later time, so `deinit` must skip destruction
|
|
580
586
|
/// and leak the host, process-lived — and the wrapper struct the
|
|
@@ -674,13 +680,13 @@ pub const MacPlatform = struct {
|
|
|
674
680
|
}
|
|
675
681
|
|
|
676
682
|
pub fn deinit(self: *MacPlatform) void {
|
|
677
|
-
// An abandoned
|
|
683
|
+
// An abandoned platform call may still enter this host at
|
|
678
684
|
// any later time (see `channel_wake_abandoned`): destroying it
|
|
679
685
|
// would turn that stale call into a use-after-free, so the
|
|
680
686
|
// host is deliberately leaked, process-lived — the
|
|
681
687
|
// abandoned-worker idiom, applied to the platform itself.
|
|
682
688
|
if (self.channel_wake_abandoned.load(.seq_cst)) {
|
|
683
|
-
std.debug.print("macos platform teardown: an abandoned
|
|
689
|
+
std.debug.print("macos platform teardown: an abandoned platform call may still enter this host; skipping destruction and leaking it (and the wrapper it enters through), process-lived, so the stale call stays safe\n", .{});
|
|
684
690
|
return;
|
|
685
691
|
}
|
|
686
692
|
native_sdk_appkit_destroy(self.host);
|
|
@@ -708,7 +714,11 @@ pub const MacPlatform = struct {
|
|
|
708
714
|
.focus_window_fn = focusWindow,
|
|
709
715
|
.close_window_fn = closeWindow,
|
|
710
716
|
.minimize_window_fn = minimizeWindow,
|
|
717
|
+
.hide_window_fn = hideWindow,
|
|
711
718
|
.show_window_fn = showWindow,
|
|
719
|
+
.set_dock_presence_fn = setDockPresence,
|
|
720
|
+
.launch_at_login_status_fn = launchAtLoginStatus,
|
|
721
|
+
.set_launch_at_login_fn = setLaunchAtLogin,
|
|
712
722
|
.quit_app_fn = quitApp,
|
|
713
723
|
.start_window_drag_fn = startWindowDrag,
|
|
714
724
|
.window_chrome_fn = windowChrome,
|
|
@@ -734,6 +744,8 @@ pub const MacPlatform = struct {
|
|
|
734
744
|
.set_credential_fn = setCredential,
|
|
735
745
|
.get_credential_fn = getCredential,
|
|
736
746
|
.delete_credential_fn = deleteCredential,
|
|
747
|
+
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
748
|
+
.format_local_time_fn = formatLocalTime,
|
|
737
749
|
.open_external_url_fn = openExternalUrl,
|
|
738
750
|
.reveal_path_fn = revealPath,
|
|
739
751
|
.add_recent_document_fn = addRecentDocument,
|
|
@@ -741,6 +753,7 @@ pub const MacPlatform = struct {
|
|
|
741
753
|
.create_tray_fn = createTray,
|
|
742
754
|
.update_tray_menu_fn = updateTrayMenu,
|
|
743
755
|
.update_tray_title_fn = updateTrayTitle,
|
|
756
|
+
.update_tray_presentation_fn = updateTrayPresentation,
|
|
744
757
|
.remove_tray_fn = removeTray,
|
|
745
758
|
.configure_security_policy_fn = configureSecurityPolicy,
|
|
746
759
|
.configure_menus_fn = configureMenus,
|
|
@@ -954,6 +967,10 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
|
|
|
954
967
|
.name = event.command_name[0..event.command_name_len],
|
|
955
968
|
.window_id = event.window_id,
|
|
956
969
|
} }),
|
|
970
|
+
.tray_command => state.emit(.{ .tray_command = .{
|
|
971
|
+
.name = event.command_name[0..event.command_name_len],
|
|
972
|
+
.window_id = event.window_id,
|
|
973
|
+
} }),
|
|
957
974
|
.timer => state.emit(.{ .timer = .{
|
|
958
975
|
.id = event.timer_id,
|
|
959
976
|
.timestamp_ns = event.timestamp_ns,
|
|
@@ -1241,6 +1258,7 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
1241
1258
|
return switch (mode) {
|
|
1242
1259
|
.immediate => 0,
|
|
1243
1260
|
.on_first_present => 1,
|
|
1261
|
+
.hidden => 2,
|
|
1244
1262
|
};
|
|
1245
1263
|
}
|
|
1246
1264
|
|
|
@@ -1250,6 +1268,7 @@ fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
|
1250
1268
|
if (options.always_on_top) flags |= 1 << 1;
|
|
1251
1269
|
if (options.click_through) flags |= 1 << 2;
|
|
1252
1270
|
if (!options.activate_on_show) flags |= 1 << 3;
|
|
1271
|
+
if (!options.allows_fullscreen) flags |= 1 << 4;
|
|
1253
1272
|
return flags;
|
|
1254
1273
|
}
|
|
1255
1274
|
|
|
@@ -1300,6 +1319,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
1300
1319
|
.scale_factor = 1,
|
|
1301
1320
|
.open = true,
|
|
1302
1321
|
.focused = options.activate_on_show and options.show == .immediate,
|
|
1322
|
+
.hidden = options.show == .hidden,
|
|
1303
1323
|
};
|
|
1304
1324
|
}
|
|
1305
1325
|
|
|
@@ -1318,11 +1338,42 @@ fn minimizeWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerr
|
|
|
1318
1338
|
if (native_sdk_appkit_minimize_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1319
1339
|
}
|
|
1320
1340
|
|
|
1341
|
+
fn hideWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
1342
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1343
|
+
if (native_sdk_appkit_hide_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1321
1346
|
fn showWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
1322
1347
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1323
1348
|
if (native_sdk_appkit_show_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1324
1349
|
}
|
|
1325
1350
|
|
|
1351
|
+
fn setDockPresence(context: ?*anyopaque, visible: bool) anyerror!void {
|
|
1352
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1353
|
+
if (native_sdk_appkit_set_dock_presence(self.host, if (visible) 1 else 0) == 0) return error.UnsupportedService;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
fn launchAtLoginStatus(context: ?*anyopaque) anyerror!platform_mod.LaunchAtLoginStatus {
|
|
1357
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1358
|
+
return launchAtLoginStatusFromInt(native_sdk_appkit_launch_at_login_status(self.host));
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
fn setLaunchAtLogin(context: ?*anyopaque, enabled: bool) anyerror!platform_mod.LaunchAtLoginStatus {
|
|
1362
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1363
|
+
return launchAtLoginStatusFromInt(native_sdk_appkit_set_launch_at_login(self.host, if (enabled) 1 else 0));
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
fn launchAtLoginStatusFromInt(value: c_int) anyerror!platform_mod.LaunchAtLoginStatus {
|
|
1367
|
+
return switch (value) {
|
|
1368
|
+
0 => .disabled,
|
|
1369
|
+
1 => .enabled,
|
|
1370
|
+
2 => .requires_approval,
|
|
1371
|
+
3 => .not_found,
|
|
1372
|
+
-1 => error.UnsupportedService,
|
|
1373
|
+
else => error.LaunchAtLoginFailed,
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1326
1377
|
/// The graceful quit: the same emitShutdown + stop the last-window
|
|
1327
1378
|
/// close runs, ALWAYS deferred past the dispatch that requested it —
|
|
1328
1379
|
/// this verb arrives mid dispatch (the command whose update returned
|
|
@@ -2063,7 +2114,7 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
|
|
|
2063
2114
|
|
|
2064
2115
|
fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anyerror!void {
|
|
2065
2116
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2066
|
-
|
|
2117
|
+
const result = native_sdk_appkit_set_credential(
|
|
2067
2118
|
self.host,
|
|
2068
2119
|
credential.service.ptr,
|
|
2069
2120
|
credential.service.len,
|
|
@@ -2071,7 +2122,10 @@ fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anye
|
|
|
2071
2122
|
credential.account.len,
|
|
2072
2123
|
credential.secret.ptr,
|
|
2073
2124
|
credential.secret.len,
|
|
2074
|
-
)
|
|
2125
|
+
);
|
|
2126
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
2127
|
+
if (result == -3) return error.AccessDenied;
|
|
2128
|
+
if (result <= 0) return error.CredentialStoreFailed;
|
|
2075
2129
|
}
|
|
2076
2130
|
|
|
2077
2131
|
fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer: []u8) anyerror![]const u8 {
|
|
@@ -2085,20 +2139,34 @@ fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer:
|
|
|
2085
2139
|
buffer.ptr,
|
|
2086
2140
|
buffer.len,
|
|
2087
2141
|
);
|
|
2088
|
-
if (len ==
|
|
2142
|
+
if (len == std.math.maxInt(usize)) return error.CredentialNotFound;
|
|
2143
|
+
if (len == std.math.maxInt(usize) - 2) return error.CredentialStoreLocked;
|
|
2144
|
+
if (len == std.math.maxInt(usize) - 3) return error.AccessDenied;
|
|
2145
|
+
if (len == std.math.maxInt(usize) - 1) return error.CredentialStoreFailed;
|
|
2089
2146
|
if (len > buffer.len) return error.NoSpaceLeft;
|
|
2090
2147
|
return buffer[0..len];
|
|
2091
2148
|
}
|
|
2092
2149
|
|
|
2093
2150
|
fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyerror!void {
|
|
2094
2151
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2095
|
-
|
|
2152
|
+
const result = native_sdk_appkit_delete_credential(
|
|
2096
2153
|
self.host,
|
|
2097
2154
|
key.service.ptr,
|
|
2098
2155
|
key.service.len,
|
|
2099
2156
|
key.account.ptr,
|
|
2100
2157
|
key.account.len,
|
|
2101
|
-
)
|
|
2158
|
+
);
|
|
2159
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
2160
|
+
if (result == -3) return error.AccessDenied;
|
|
2161
|
+
if (result < 0) return error.CredentialStoreFailed;
|
|
2162
|
+
if (result == 0) return error.CredentialNotFound;
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: platform_mod.LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
|
|
2166
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2167
|
+
const len = native_sdk_appkit_format_local_time(self.host, timestamp_ms, @intFromEnum(style), buffer.ptr, buffer.len);
|
|
2168
|
+
if (len == 0 or len > buffer.len) return error.LocalTimeFormatFailed;
|
|
2169
|
+
return buffer[0..len];
|
|
2102
2170
|
}
|
|
2103
2171
|
|
|
2104
2172
|
fn openExternalUrl(context: ?*anyopaque, url: []const u8) anyerror!void {
|
|
@@ -2456,7 +2524,27 @@ const max_tray_items: usize = 32;
|
|
|
2456
2524
|
|
|
2457
2525
|
fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
|
|
2458
2526
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2459
|
-
|
|
2527
|
+
var presentation = options.presentation;
|
|
2528
|
+
if (presentation.title.len == 0) presentation.title = options.title;
|
|
2529
|
+
native_sdk_appkit_create_tray(
|
|
2530
|
+
self.host,
|
|
2531
|
+
options.icon_path.ptr,
|
|
2532
|
+
options.icon_path.len,
|
|
2533
|
+
presentation.title.ptr,
|
|
2534
|
+
presentation.title.len,
|
|
2535
|
+
options.tooltip.ptr,
|
|
2536
|
+
options.tooltip.len,
|
|
2537
|
+
presentation.width,
|
|
2538
|
+
@intFromEnum(presentation.tone),
|
|
2539
|
+
presentation.icon_opacity,
|
|
2540
|
+
if (presentation.monospaced) 1 else 0,
|
|
2541
|
+
options.activation_command.ptr,
|
|
2542
|
+
options.activation_command.len,
|
|
2543
|
+
options.alternate_activation_command.ptr,
|
|
2544
|
+
options.alternate_activation_command.len,
|
|
2545
|
+
options.open_command.ptr,
|
|
2546
|
+
options.open_command.len,
|
|
2547
|
+
);
|
|
2460
2548
|
if (options.items.len > 0) {
|
|
2461
2549
|
try updateTrayMenu(context, options.items);
|
|
2462
2550
|
}
|
|
@@ -2470,14 +2558,30 @@ fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem
|
|
|
2470
2558
|
var label_lens: [max_tray_items]usize = undefined;
|
|
2471
2559
|
var separators: [max_tray_items]c_int = undefined;
|
|
2472
2560
|
var enabled_flags: [max_tray_items]c_int = undefined;
|
|
2561
|
+
var details: [max_tray_items][*]const u8 = undefined;
|
|
2562
|
+
var detail_lens: [max_tray_items]usize = undefined;
|
|
2563
|
+
var roles: [max_tray_items]c_int = undefined;
|
|
2564
|
+
var keys: [max_tray_items][*]const u8 = undefined;
|
|
2565
|
+
var key_lens: [max_tray_items]usize = undefined;
|
|
2566
|
+
var modifiers: [max_tray_items]u32 = undefined;
|
|
2473
2567
|
for (items[0..count], 0..) |item, i| {
|
|
2474
2568
|
ids[i] = item.id;
|
|
2475
2569
|
labels[i] = item.label.ptr;
|
|
2476
2570
|
label_lens[i] = item.label.len;
|
|
2477
2571
|
separators[i] = if (item.separator) 1 else 0;
|
|
2478
2572
|
enabled_flags[i] = if (item.enabled) 1 else 0;
|
|
2573
|
+
details[i] = item.detail.ptr;
|
|
2574
|
+
detail_lens[i] = item.detail.len;
|
|
2575
|
+
roles[i] = @intFromEnum(item.role);
|
|
2576
|
+
keys[i] = item.key.ptr;
|
|
2577
|
+
key_lens[i] = item.key.len;
|
|
2578
|
+
modifiers[i] = @as(u32, @intFromBool(item.modifiers.primary)) |
|
|
2579
|
+
(@as(u32, @intFromBool(item.modifiers.command)) << 1) |
|
|
2580
|
+
(@as(u32, @intFromBool(item.modifiers.control)) << 2) |
|
|
2581
|
+
(@as(u32, @intFromBool(item.modifiers.option)) << 3) |
|
|
2582
|
+
(@as(u32, @intFromBool(item.modifiers.shift)) << 4);
|
|
2479
2583
|
}
|
|
2480
|
-
native_sdk_appkit_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, count);
|
|
2584
|
+
native_sdk_appkit_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count);
|
|
2481
2585
|
}
|
|
2482
2586
|
|
|
2483
2587
|
fn updateTrayTitle(context: ?*anyopaque, title: []const u8) anyerror!void {
|
|
@@ -2485,6 +2589,11 @@ fn updateTrayTitle(context: ?*anyopaque, title: []const u8) anyerror!void {
|
|
|
2485
2589
|
native_sdk_appkit_update_tray_title(self.host, title.ptr, title.len);
|
|
2486
2590
|
}
|
|
2487
2591
|
|
|
2592
|
+
fn updateTrayPresentation(context: ?*anyopaque, presentation: platform_mod.TrayPresentation) anyerror!void {
|
|
2593
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2594
|
+
native_sdk_appkit_update_tray_presentation(self.host, presentation.title.ptr, presentation.title.len, presentation.width, @intFromEnum(presentation.tone), presentation.icon_opacity, if (presentation.monospaced) 1 else 0);
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2488
2597
|
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
2489
2598
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2490
2599
|
native_sdk_appkit_remove_tray(self.host);
|
|
@@ -2517,6 +2626,51 @@ test "mac platform module exports type" {
|
|
|
2517
2626
|
_ = MacPlatform;
|
|
2518
2627
|
}
|
|
2519
2628
|
|
|
2629
|
+
test "mac status agent rows recognize decorated states and stay actionable" {
|
|
2630
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2631
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"configured \"]") != null);
|
|
2632
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"warning \"]") != null);
|
|
2633
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "label.textColor = configured ? successColor : warning ? warningColor : NSColor.secondaryLabelColor;") != null);
|
|
2634
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.tag = itemIds[index];") != null);
|
|
2635
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.enabled = enabled[index].boolValue;") != null);
|
|
2636
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.keyEquivalent = NativeSdkMenuKeyEquivalent(key);") != null);
|
|
2637
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.keyEquivalentModifierMask = NativeSdkMenuModifierFlags(modifiers[index].unsignedIntValue);") != null);
|
|
2638
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "item.keyEquivalent = @\"\";") != null);
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
test "mac title-only tray updates preserve the applied presentation" {
|
|
2642
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2643
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "object.statusPresentationWidth = width;") != null);
|
|
2644
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "object.statusPresentationTone = tone;") != null);
|
|
2645
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "object.statusPresentationIconOpacity = iconOpacity;") != null);
|
|
2646
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "object.statusPresentationMonospaced = monospaced;") != null);
|
|
2647
|
+
const update_at = std.mem.indexOf(u8, host_source, "void native_sdk_appkit_update_tray_title(") orelse return error.TestExpectedEqual;
|
|
2648
|
+
const update_tail = host_source[update_at..];
|
|
2649
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "object.statusPresentationWidth,") != null);
|
|
2650
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "object.statusPresentationTone,") != null);
|
|
2651
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "object.statusPresentationIconOpacity,") != null);
|
|
2652
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "object.statusPresentationMonospaced") != null);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
test "mac status lifecycle hooks emit tray commands" {
|
|
2657
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2658
|
+
const emit_at = std.mem.indexOf(u8, host_source, "- (void)emitStatusCommand:(NSString *)command {") orelse return error.TestExpectedEqual;
|
|
2659
|
+
const emit_tail = host_source[emit_at..];
|
|
2660
|
+
const emit_end = std.mem.indexOf(u8, emit_tail, "- (void)statusItemActivated:") orelse return error.TestExpectedEqual;
|
|
2661
|
+
const emit_source = emit_tail[0..emit_end];
|
|
2662
|
+
try std.testing.expect(std.mem.indexOf(u8, emit_source, "NATIVE_SDK_APPKIT_EVENT_TRAY_COMMAND") != null);
|
|
2663
|
+
try std.testing.expect(std.mem.indexOf(u8, emit_source, "NATIVE_SDK_APPKIT_EVENT_MENU_COMMAND") == null);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
test "mac status menu updates preserve the menu being opened" {
|
|
2668
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2669
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMenu *menu = object.statusMenu;") != null);
|
|
2670
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[menu removeAllItems];") != null);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2520
2674
|
test "mac webview presses report the focused child label" {
|
|
2521
2675
|
// WKWebView owns the page's pointer stream, so the AppKit host
|
|
2522
2676
|
// observes the down before dispatch and emits the explicit inverse
|
|
@@ -2528,15 +2682,15 @@ test "mac webview presses report the focused child label" {
|
|
|
2528
2682
|
}
|
|
2529
2683
|
|
|
2530
2684
|
test "mac active implicit show activates before making the window key" {
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2685
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2686
|
+
const show_at = std.mem.indexOf(u8, host_source, "- (void)orderWindowForImplicitShow:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2687
|
+
const show_tail = host_source[show_at..];
|
|
2688
|
+
const show_end = std.mem.indexOf(u8, show_tail, "- (void)focusWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2689
|
+
const show_body = show_tail[0..show_end];
|
|
2690
|
+
const activate_at = std.mem.indexOf(u8, show_body, "[NSApp activateIgnoringOtherApps:YES];") orelse return error.TestExpectedEqual;
|
|
2691
|
+
const make_key_at = std.mem.indexOf(u8, show_body, "[window makeKeyAndOrderFront:nil];") orelse return error.TestExpectedEqual;
|
|
2692
|
+
try std.testing.expect(activate_at < make_key_at);
|
|
2693
|
+
}
|
|
2540
2694
|
}
|
|
2541
2695
|
|
|
2542
2696
|
test "mac unrestored secondary windows cascade within the active screen" {
|
|
@@ -2553,17 +2707,26 @@ test "mac unrestored secondary windows cascade within the active screen" {
|
|
|
2553
2707
|
}
|
|
2554
2708
|
|
|
2555
2709
|
test "mac explicit focus activates before making the window key" {
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2710
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2711
|
+
const focus_at = std.mem.indexOf(u8, host_source, "- (void)focusWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2712
|
+
const focus_tail = host_source[focus_at..];
|
|
2713
|
+
const focus_end = std.mem.indexOf(u8, focus_tail, "- (void)closeWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2714
|
+
const focus_body = focus_tail[0..focus_end];
|
|
2715
|
+
const activate_at = std.mem.indexOf(u8, focus_body, "[NSApp activateIgnoringOtherApps:YES];") orelse return error.TestExpectedEqual;
|
|
2716
|
+
const make_key_at = std.mem.indexOf(u8, focus_body, "[window makeKeyAndOrderFront:nil];") orelse return error.TestExpectedEqual;
|
|
2717
|
+
try std.testing.expect(activate_at < make_key_at);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
test "mac dock presence changes policy without activating the app" {
|
|
2722
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2723
|
+
const dock_at = std.mem.indexOf(u8, host_source, "int native_sdk_appkit_set_dock_presence(") orelse return error.TestExpectedEqual;
|
|
2724
|
+
const dock_tail = host_source[dock_at..];
|
|
2725
|
+
const dock_end = std.mem.indexOf(u8, dock_tail, "int native_sdk_appkit_launch_at_login_status(") orelse return error.TestExpectedEqual;
|
|
2726
|
+
const dock_body = dock_tail[0..dock_end];
|
|
2727
|
+
try std.testing.expect(std.mem.indexOf(u8, dock_body, "[NSApp setActivationPolicy:policy]") != null);
|
|
2728
|
+
try std.testing.expect(std.mem.indexOf(u8, dock_body, "[NSApp activate") == null);
|
|
2729
|
+
}
|
|
2567
2730
|
}
|
|
2568
2731
|
|
|
2569
2732
|
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
@@ -2885,3 +3048,50 @@ test "mac appearance event carries accessibility preferences" {
|
|
|
2885
3048
|
try std.testing.expect(event.reduce_motion != 0);
|
|
2886
3049
|
try std.testing.expect(event.high_contrast != 0);
|
|
2887
3050
|
}
|
|
3051
|
+
|
|
3052
|
+
test "mac launch-at-login result keeps unsupported separate from operation failure" {
|
|
3053
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.disabled, try launchAtLoginStatusFromInt(0));
|
|
3054
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.enabled, try launchAtLoginStatusFromInt(1));
|
|
3055
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.requires_approval, try launchAtLoginStatusFromInt(2));
|
|
3056
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.not_found, try launchAtLoginStatusFromInt(3));
|
|
3057
|
+
try std.testing.expectError(error.UnsupportedService, launchAtLoginStatusFromInt(-1));
|
|
3058
|
+
try std.testing.expectError(error.LaunchAtLoginFailed, launchAtLoginStatusFromInt(-2));
|
|
3059
|
+
try std.testing.expectError(error.LaunchAtLoginFailed, launchAtLoginStatusFromInt(99));
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
test "both mac hosts carry the menu-bar lifecycle and fullscreen hooks" {
|
|
3063
|
+
const hosts = [_][]const u8{
|
|
3064
|
+
@embedFile("appkit_host.m"),
|
|
3065
|
+
@embedFile("cef_host.mm"),
|
|
3066
|
+
};
|
|
3067
|
+
for (hosts) |host_source| {
|
|
3068
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_hide_window") != null);
|
|
3069
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_set_dock_presence") != null);
|
|
3070
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_launch_at_login_status") != null);
|
|
3071
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_set_launch_at_login") != null);
|
|
3072
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "registerAndReturnError:") != null);
|
|
3073
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "unregisterAndReturnError:") != null);
|
|
3074
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "before == 1 || before == 2") != null);
|
|
3075
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "return succeeded ? NativeSdkLaunchAtLoginStatus() : -2;") != null);
|
|
3076
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "dlopen(") != null);
|
|
3077
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "ServiceManagement.framework/ServiceManagement") != null);
|
|
3078
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSWindowCollectionBehaviorFullScreenNone") != null);
|
|
3079
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "standardWindowButton:NSWindowZoomButton") != null);
|
|
3080
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "1u << 4") != null);
|
|
3081
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "policyHiddenWindows") != null);
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
// AppKit canvas windows also carry a pending first-present/fallback
|
|
3085
|
+
// reveal. An explicit hide must retire that pending reveal before it
|
|
3086
|
+
// records the policy-hidden state.
|
|
3087
|
+
const appkit_source = hosts[0];
|
|
3088
|
+
try std.testing.expect(std.mem.indexOf(u8, appkit_source, "[NSApp activate]") == null);
|
|
3089
|
+
try std.testing.expect(std.mem.indexOf(u8, appkit_source, "[NSApp activateIgnoringOtherApps:YES]") != null);
|
|
3090
|
+
const hide_at = std.mem.indexOf(u8, appkit_source, "- (void)hideWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
3091
|
+
const hide_tail = appkit_source[hide_at..];
|
|
3092
|
+
const show_at = std.mem.indexOf(u8, hide_tail, "- (void)showWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
3093
|
+
const hide_body = hide_tail[0..show_at];
|
|
3094
|
+
const cancel_at = std.mem.indexOf(u8, hide_body, "[self.deferredShowWindows removeObjectForKey:@(windowId)];") orelse return error.TestExpectedEqual;
|
|
3095
|
+
const policy_at = std.mem.indexOf(u8, hide_body, "[self.policyHiddenWindows addObject:@(windowId)];") orelse return error.TestExpectedEqual;
|
|
3096
|
+
try std.testing.expect(cancel_at < policy_at);
|
|
3097
|
+
}
|