@native-sdk/cli 0.8.4 → 0.9.1
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 +1178 -74
- package/build.zig +715 -17
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +10 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +435 -3
- 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/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +280 -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 +224 -0
- package/packages/core/sdk/core.ts +694 -22
- package/packages/core/sdk/events.d.ts +89 -0
- package/packages/core/sdk/events.ts +128 -0
- package/packages/core/src/checker.ts +936 -15
- package/packages/core/src/cli.ts +156 -3
- package/packages/core/src/contract.ts +28 -5
- package/packages/core/src/devhost.ts +1876 -16
- package/packages/core/src/devhost_journal.mjs +183 -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 +179 -22
- package/packages/core/src/frontend.ts +210 -34
- package/packages/core/src/infer.ts +24 -0
- 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/automation/SKILL.md +1 -1
- package/skill-data/core/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +58 -5
- package/skill-data/ts-core/SKILL.md +123 -41
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +604 -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 +133 -4
- package/src/app_runner/ts_core_main.zig +254 -8
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +31 -11
- package/src/embed/app_exports.zig +12 -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 +8 -0
- package/src/embed/tests.zig +241 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +185 -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 +8 -2
- package/src/platform/linux/gtk_host.c +289 -22
- package/src/platform/linux/gtk_host.h +5 -1
- package/src/platform/linux/root.zig +109 -22
- package/src/platform/macos/appkit_host.h +24 -7
- package/src/platform/macos/appkit_host.m +686 -64
- package/src/platform/macos/cef_host.mm +400 -66
- package/src/platform/macos/root.zig +304 -47
- package/src/platform/null_platform.zig +435 -48
- package/src/platform/null_platform_tests.zig +113 -0
- package/src/platform/root.zig +19 -0
- package/src/platform/types.zig +281 -28
- package/src/platform/windows/root.zig +207 -27
- package/src/platform/windows/webview2_host.cpp +334 -51
- 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 +53 -0
- package/src/runtime/api.zig +19 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -20
- package/src/runtime/bridge_permission_tests.zig +58 -3
- package/src/runtime/bridge_responses.zig +4 -2
- package/src/runtime/builtin_bridge.zig +11 -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 +145 -7
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +3701 -231
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -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 +35 -10
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +86 -2
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +54 -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 +4 -1
- package/src/runtime/session_journal.zig +158 -5
- package/src/runtime/session_record.zig +215 -0
- package/src/runtime/session_replay.zig +206 -11
- package/src/runtime/session_tests.zig +81 -0
- 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 +16 -0
- package/src/runtime/system_services.zig +170 -38
- package/src/runtime/tests.zig +4 -0
- package/src/runtime/ts_core_host.zig +1067 -95
- package/src/runtime/ts_core_host_tests.zig +325 -11
- package/src/runtime/ts_ui_app.zig +953 -2
- package/src/runtime/ui_app.zig +434 -96
- package/src/runtime/ui_app_tests.zig +287 -11
- package/src/runtime/ui_app_window_tests.zig +61 -7
- package/src/runtime/validation.zig +42 -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 +189 -4
- package/src/tooling/ts_core.zig +366 -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 +442 -27
- 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,8 @@ const AppKitEventKind = enum(c_int) {
|
|
|
42
42
|
audio = 20,
|
|
43
43
|
video = 21,
|
|
44
44
|
view_focused = 22,
|
|
45
|
+
tray_command = 23,
|
|
46
|
+
notification_command = 24,
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
const AppKitEvent = extern struct {
|
|
@@ -66,6 +68,7 @@ const AppKitEvent = extern struct {
|
|
|
66
68
|
shortcut_modifiers: u32,
|
|
67
69
|
command_name: [*]const u8,
|
|
68
70
|
command_name_len: usize,
|
|
71
|
+
status_item_id: u32,
|
|
69
72
|
view_label: [*]const u8,
|
|
70
73
|
view_label_len: usize,
|
|
71
74
|
key_text: [*]const u8,
|
|
@@ -179,7 +182,11 @@ extern fn native_sdk_appkit_set_window_content_min_size(host: *AppKitHost, windo
|
|
|
179
182
|
extern fn native_sdk_appkit_focus_window(host: *AppKitHost, window_id: u64) c_int;
|
|
180
183
|
extern fn native_sdk_appkit_close_window(host: *AppKitHost, window_id: u64) c_int;
|
|
181
184
|
extern fn native_sdk_appkit_minimize_window(host: *AppKitHost, window_id: u64) c_int;
|
|
185
|
+
extern fn native_sdk_appkit_hide_window(host: *AppKitHost, window_id: u64) c_int;
|
|
182
186
|
extern fn native_sdk_appkit_show_window(host: *AppKitHost, window_id: u64) c_int;
|
|
187
|
+
extern fn native_sdk_appkit_set_dock_presence(host: *AppKitHost, visible: c_int) c_int;
|
|
188
|
+
extern fn native_sdk_appkit_launch_at_login_status(host: *AppKitHost) c_int;
|
|
189
|
+
extern fn native_sdk_appkit_set_launch_at_login(host: *AppKitHost, enabled: c_int) c_int;
|
|
183
190
|
extern fn native_sdk_appkit_set_window_close_policy(host: *AppKitHost, window_id: u64, close_policy: c_int) c_int;
|
|
184
191
|
extern fn native_sdk_appkit_start_window_drag(host: *AppKitHost, window_id: u64) c_int;
|
|
185
192
|
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;
|
|
@@ -241,7 +248,7 @@ extern fn native_sdk_appkit_decode_image(bytes: [*]const u8, bytes_len: usize, p
|
|
|
241
248
|
extern fn native_sdk_appkit_clipboard_write(host: *AppKitHost, text: [*]const u8, text_len: usize) void;
|
|
242
249
|
extern fn native_sdk_appkit_clipboard_read_data(host: *AppKitHost, mime_type: [*]const u8, mime_type_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
243
250
|
extern fn native_sdk_appkit_clipboard_write_data(host: *AppKitHost, mime_type: [*]const u8, mime_type_len: usize, bytes: [*]const u8, bytes_len: usize) c_int;
|
|
244
|
-
extern fn native_sdk_appkit_show_notification(host: *AppKitHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize) c_int;
|
|
251
|
+
extern fn native_sdk_appkit_show_notification(host: *AppKitHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize, notification_id: [*]const u8, notification_id_len: usize, action_label: [*]const u8, action_label_len: usize, action_command: [*]const u8, action_command_len: usize) c_int;
|
|
245
252
|
extern fn native_sdk_appkit_open_external_url(host: *AppKitHost, url: [*]const u8, url_len: usize) c_int;
|
|
246
253
|
extern fn native_sdk_appkit_reveal_path(host: *AppKitHost, path: [*]const u8, path_len: usize) c_int;
|
|
247
254
|
extern fn native_sdk_appkit_add_recent_document(host: *AppKitHost, path: [*]const u8, path_len: usize) c_int;
|
|
@@ -249,6 +256,7 @@ extern fn native_sdk_appkit_clear_recent_documents(host: *AppKitHost) c_int;
|
|
|
249
256
|
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
257
|
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
258
|
extern fn native_sdk_appkit_delete_credential(host: *AppKitHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize) c_int;
|
|
259
|
+
extern fn native_sdk_appkit_format_local_time(host: *AppKitHost, timestamp_ms: i64, style: c_int, buffer: [*]u8, buffer_len: usize) usize;
|
|
252
260
|
|
|
253
261
|
const AppKitScrollOccluder = extern struct {
|
|
254
262
|
x: f64,
|
|
@@ -393,15 +401,17 @@ const widget_action_drag: u32 = 1 << 8;
|
|
|
393
401
|
const widget_action_drop_files: u32 = 1 << 9;
|
|
394
402
|
const widget_action_dismiss: u32 = 1 << 10;
|
|
395
403
|
|
|
396
|
-
const AppKitTrayCallback = *const fn (context: ?*anyopaque, item_id: u32) callconv(.c) void;
|
|
404
|
+
const AppKitTrayCallback = *const fn (context: ?*anyopaque, status_item_id: u32, item_id: u32) callconv(.c) void;
|
|
397
405
|
|
|
398
406
|
extern fn native_sdk_appkit_show_open_dialog(host: *AppKitHost, opts: *const AppKitOpenDialogOpts, buffer: [*]u8, buffer_len: usize) AppKitOpenDialogResult;
|
|
399
407
|
extern fn native_sdk_appkit_show_save_dialog(host: *AppKitHost, opts: *const AppKitSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
|
|
400
408
|
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
|
|
403
|
-
extern fn
|
|
404
|
-
extern fn
|
|
409
|
+
extern fn native_sdk_appkit_create_tray(host: *AppKitHost, status_item_id: u32, icon_path: [*]const u8, icon_path_len: usize, title: [*]const u8, title_len: usize, tooltip: [*]const u8, tooltip_len: usize, visible: c_int, 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;
|
|
410
|
+
extern fn native_sdk_appkit_update_tray_shell(host: *AppKitHost, status_item_id: u32, icon_path: [*]const u8, icon_path_len: usize, tooltip: [*]const u8, tooltip_len: usize, visible: 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;
|
|
411
|
+
extern fn native_sdk_appkit_update_tray_menu(host: *AppKitHost, status_item_id: u32, 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;
|
|
412
|
+
extern fn native_sdk_appkit_update_tray_title(host: *AppKitHost, status_item_id: u32, title: [*]const u8, title_len: usize) void;
|
|
413
|
+
extern fn native_sdk_appkit_update_tray_presentation(host: *AppKitHost, status_item_id: u32, title: [*]const u8, title_len: usize, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int) void;
|
|
414
|
+
extern fn native_sdk_appkit_remove_tray(host: *AppKitHost, status_item_id: u32) void;
|
|
405
415
|
extern fn native_sdk_appkit_set_tray_callback(host: *AppKitHost, callback: AppKitTrayCallback, context: ?*anyopaque) void;
|
|
406
416
|
|
|
407
417
|
/// Whether a Dock icon path names a raw image source (.png/.svg) that
|
|
@@ -572,9 +582,8 @@ pub const MacPlatform = struct {
|
|
|
572
582
|
app_info: platform_mod.AppInfo,
|
|
573
583
|
surface_value: platform_mod.Surface,
|
|
574
584
|
state: RunState = .{},
|
|
575
|
-
/// Latched when
|
|
576
|
-
///
|
|
577
|
-
/// `PlatformServices.note_channel_wake_abandoned_fn`): the stale
|
|
585
|
+
/// Latched when effects teardown abandons an in-flight platform call
|
|
586
|
+
/// (a channel wake or blocking credential operation): the stale
|
|
578
587
|
/// call still holds this platform as its context and may execute
|
|
579
588
|
/// into it at any later time, so `deinit` must skip destruction
|
|
580
589
|
/// and leak the host, process-lived — and the wrapper struct the
|
|
@@ -674,13 +683,13 @@ pub const MacPlatform = struct {
|
|
|
674
683
|
}
|
|
675
684
|
|
|
676
685
|
pub fn deinit(self: *MacPlatform) void {
|
|
677
|
-
// An abandoned
|
|
686
|
+
// An abandoned platform call may still enter this host at
|
|
678
687
|
// any later time (see `channel_wake_abandoned`): destroying it
|
|
679
688
|
// would turn that stale call into a use-after-free, so the
|
|
680
689
|
// host is deliberately leaked, process-lived — the
|
|
681
690
|
// abandoned-worker idiom, applied to the platform itself.
|
|
682
691
|
if (self.channel_wake_abandoned.load(.seq_cst)) {
|
|
683
|
-
std.debug.print("macos platform teardown: an abandoned
|
|
692
|
+
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
693
|
return;
|
|
685
694
|
}
|
|
686
695
|
native_sdk_appkit_destroy(self.host);
|
|
@@ -708,7 +717,11 @@ pub const MacPlatform = struct {
|
|
|
708
717
|
.focus_window_fn = focusWindow,
|
|
709
718
|
.close_window_fn = closeWindow,
|
|
710
719
|
.minimize_window_fn = minimizeWindow,
|
|
720
|
+
.hide_window_fn = hideWindow,
|
|
711
721
|
.show_window_fn = showWindow,
|
|
722
|
+
.set_dock_presence_fn = setDockPresence,
|
|
723
|
+
.launch_at_login_status_fn = launchAtLoginStatus,
|
|
724
|
+
.set_launch_at_login_fn = setLaunchAtLogin,
|
|
712
725
|
.quit_app_fn = quitApp,
|
|
713
726
|
.start_window_drag_fn = startWindowDrag,
|
|
714
727
|
.window_chrome_fn = windowChrome,
|
|
@@ -734,13 +747,17 @@ pub const MacPlatform = struct {
|
|
|
734
747
|
.set_credential_fn = setCredential,
|
|
735
748
|
.get_credential_fn = getCredential,
|
|
736
749
|
.delete_credential_fn = deleteCredential,
|
|
750
|
+
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
751
|
+
.format_local_time_fn = formatLocalTime,
|
|
737
752
|
.open_external_url_fn = openExternalUrl,
|
|
738
753
|
.reveal_path_fn = revealPath,
|
|
739
754
|
.add_recent_document_fn = addRecentDocument,
|
|
740
755
|
.clear_recent_documents_fn = clearRecentDocuments,
|
|
741
756
|
.create_tray_fn = createTray,
|
|
757
|
+
.update_tray_shell_fn = updateTrayShell,
|
|
742
758
|
.update_tray_menu_fn = updateTrayMenu,
|
|
743
759
|
.update_tray_title_fn = updateTrayTitle,
|
|
760
|
+
.update_tray_presentation_fn = updateTrayPresentation,
|
|
744
761
|
.remove_tray_fn = removeTray,
|
|
745
762
|
.configure_security_policy_fn = configureSecurityPolicy,
|
|
746
763
|
.configure_menus_fn = configureMenus,
|
|
@@ -954,6 +971,15 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
|
|
|
954
971
|
.name = event.command_name[0..event.command_name_len],
|
|
955
972
|
.window_id = event.window_id,
|
|
956
973
|
} }),
|
|
974
|
+
.tray_command => state.emit(.{ .tray_command = .{
|
|
975
|
+
.name = event.command_name[0..event.command_name_len],
|
|
976
|
+
.window_id = event.window_id,
|
|
977
|
+
.status_item_id = event.status_item_id,
|
|
978
|
+
} }),
|
|
979
|
+
.notification_command => state.emit(.{ .notification_command = .{
|
|
980
|
+
.name = event.command_name[0..event.command_name_len],
|
|
981
|
+
.window_id = event.window_id,
|
|
982
|
+
} }),
|
|
957
983
|
.timer => state.emit(.{ .timer = .{
|
|
958
984
|
.id = event.timer_id,
|
|
959
985
|
.timestamp_ns = event.timestamp_ns,
|
|
@@ -1241,6 +1267,7 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
1241
1267
|
return switch (mode) {
|
|
1242
1268
|
.immediate => 0,
|
|
1243
1269
|
.on_first_present => 1,
|
|
1270
|
+
.hidden => 2,
|
|
1244
1271
|
};
|
|
1245
1272
|
}
|
|
1246
1273
|
|
|
@@ -1250,6 +1277,7 @@ fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
|
1250
1277
|
if (options.always_on_top) flags |= 1 << 1;
|
|
1251
1278
|
if (options.click_through) flags |= 1 << 2;
|
|
1252
1279
|
if (!options.activate_on_show) flags |= 1 << 3;
|
|
1280
|
+
if (!options.allows_fullscreen) flags |= 1 << 4;
|
|
1253
1281
|
return flags;
|
|
1254
1282
|
}
|
|
1255
1283
|
|
|
@@ -1300,6 +1328,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
1300
1328
|
.scale_factor = 1,
|
|
1301
1329
|
.open = true,
|
|
1302
1330
|
.focused = options.activate_on_show and options.show == .immediate,
|
|
1331
|
+
.hidden = options.show == .hidden,
|
|
1303
1332
|
};
|
|
1304
1333
|
}
|
|
1305
1334
|
|
|
@@ -1318,11 +1347,42 @@ fn minimizeWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerr
|
|
|
1318
1347
|
if (native_sdk_appkit_minimize_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1319
1348
|
}
|
|
1320
1349
|
|
|
1350
|
+
fn hideWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
1351
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1352
|
+
if (native_sdk_appkit_hide_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1321
1355
|
fn showWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
1322
1356
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1323
1357
|
if (native_sdk_appkit_show_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1324
1358
|
}
|
|
1325
1359
|
|
|
1360
|
+
fn setDockPresence(context: ?*anyopaque, visible: bool) anyerror!void {
|
|
1361
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1362
|
+
if (native_sdk_appkit_set_dock_presence(self.host, if (visible) 1 else 0) == 0) return error.UnsupportedService;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
fn launchAtLoginStatus(context: ?*anyopaque) anyerror!platform_mod.LaunchAtLoginStatus {
|
|
1366
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1367
|
+
return launchAtLoginStatusFromInt(native_sdk_appkit_launch_at_login_status(self.host));
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
fn setLaunchAtLogin(context: ?*anyopaque, enabled: bool) anyerror!platform_mod.LaunchAtLoginStatus {
|
|
1371
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1372
|
+
return launchAtLoginStatusFromInt(native_sdk_appkit_set_launch_at_login(self.host, if (enabled) 1 else 0));
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
fn launchAtLoginStatusFromInt(value: c_int) anyerror!platform_mod.LaunchAtLoginStatus {
|
|
1376
|
+
return switch (value) {
|
|
1377
|
+
0 => .disabled,
|
|
1378
|
+
1 => .enabled,
|
|
1379
|
+
2 => .requires_approval,
|
|
1380
|
+
3 => .not_found,
|
|
1381
|
+
-1 => error.UnsupportedService,
|
|
1382
|
+
else => error.LaunchAtLoginFailed,
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1326
1386
|
/// The graceful quit: the same emitShutdown + stop the last-window
|
|
1327
1387
|
/// close runs, ALWAYS deferred past the dispatch that requested it —
|
|
1328
1388
|
/// this verb arrives mid dispatch (the command whose update returned
|
|
@@ -2058,12 +2118,18 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
|
|
|
2058
2118
|
options.subtitle.len,
|
|
2059
2119
|
options.body.ptr,
|
|
2060
2120
|
options.body.len,
|
|
2121
|
+
options.id.ptr,
|
|
2122
|
+
options.id.len,
|
|
2123
|
+
options.action_label.ptr,
|
|
2124
|
+
options.action_label.len,
|
|
2125
|
+
options.action_command.ptr,
|
|
2126
|
+
options.action_command.len,
|
|
2061
2127
|
) == 0) return error.UnsupportedService;
|
|
2062
2128
|
}
|
|
2063
2129
|
|
|
2064
2130
|
fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anyerror!void {
|
|
2065
2131
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2066
|
-
|
|
2132
|
+
const result = native_sdk_appkit_set_credential(
|
|
2067
2133
|
self.host,
|
|
2068
2134
|
credential.service.ptr,
|
|
2069
2135
|
credential.service.len,
|
|
@@ -2071,7 +2137,10 @@ fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anye
|
|
|
2071
2137
|
credential.account.len,
|
|
2072
2138
|
credential.secret.ptr,
|
|
2073
2139
|
credential.secret.len,
|
|
2074
|
-
)
|
|
2140
|
+
);
|
|
2141
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
2142
|
+
if (result == -3) return error.AccessDenied;
|
|
2143
|
+
if (result <= 0) return error.CredentialStoreFailed;
|
|
2075
2144
|
}
|
|
2076
2145
|
|
|
2077
2146
|
fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer: []u8) anyerror![]const u8 {
|
|
@@ -2085,20 +2154,34 @@ fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer:
|
|
|
2085
2154
|
buffer.ptr,
|
|
2086
2155
|
buffer.len,
|
|
2087
2156
|
);
|
|
2088
|
-
if (len ==
|
|
2157
|
+
if (len == std.math.maxInt(usize)) return error.CredentialNotFound;
|
|
2158
|
+
if (len == std.math.maxInt(usize) - 2) return error.CredentialStoreLocked;
|
|
2159
|
+
if (len == std.math.maxInt(usize) - 3) return error.AccessDenied;
|
|
2160
|
+
if (len == std.math.maxInt(usize) - 1) return error.CredentialStoreFailed;
|
|
2089
2161
|
if (len > buffer.len) return error.NoSpaceLeft;
|
|
2090
2162
|
return buffer[0..len];
|
|
2091
2163
|
}
|
|
2092
2164
|
|
|
2093
2165
|
fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyerror!void {
|
|
2094
2166
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2095
|
-
|
|
2167
|
+
const result = native_sdk_appkit_delete_credential(
|
|
2096
2168
|
self.host,
|
|
2097
2169
|
key.service.ptr,
|
|
2098
2170
|
key.service.len,
|
|
2099
2171
|
key.account.ptr,
|
|
2100
2172
|
key.account.len,
|
|
2101
|
-
)
|
|
2173
|
+
);
|
|
2174
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
2175
|
+
if (result == -3) return error.AccessDenied;
|
|
2176
|
+
if (result < 0) return error.CredentialStoreFailed;
|
|
2177
|
+
if (result == 0) return error.CredentialNotFound;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: platform_mod.LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
|
|
2181
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2182
|
+
const len = native_sdk_appkit_format_local_time(self.host, timestamp_ms, @intFromEnum(style), buffer.ptr, buffer.len);
|
|
2183
|
+
if (len == 0 or len > buffer.len) return error.LocalTimeFormatFailed;
|
|
2184
|
+
return buffer[0..len];
|
|
2102
2185
|
}
|
|
2103
2186
|
|
|
2104
2187
|
fn openExternalUrl(context: ?*anyopaque, url: []const u8) anyerror!void {
|
|
@@ -2311,6 +2394,31 @@ fn isSupportedNativeViewKind(kind: platform_mod.ViewKind) bool {
|
|
|
2311
2394
|
};
|
|
2312
2395
|
}
|
|
2313
2396
|
|
|
2397
|
+
test "macos notification actions use process-scoped opaque tokens" {
|
|
2398
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2399
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2400
|
+
u8,
|
|
2401
|
+
host_source,
|
|
2402
|
+
"NSString *actionToken = [NSUUID UUID].UUIDString;",
|
|
2403
|
+
) != null);
|
|
2404
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2405
|
+
u8,
|
|
2406
|
+
host_source,
|
|
2407
|
+
"notification.userInfo = @{ @\"native-sdk-action-token\": actionToken };",
|
|
2408
|
+
) != null);
|
|
2409
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2410
|
+
u8,
|
|
2411
|
+
host_source,
|
|
2412
|
+
"self.notificationActionCommands[token]",
|
|
2413
|
+
) != null);
|
|
2414
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2415
|
+
u8,
|
|
2416
|
+
host_source,
|
|
2417
|
+
"@\"native-sdk-action-command\"",
|
|
2418
|
+
) == null);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2314
2422
|
test "macos supports native container and control kinds" {
|
|
2315
2423
|
try std.testing.expect(isSupportedNativeViewKind(.split));
|
|
2316
2424
|
try std.testing.expect(isSupportedNativeViewKind(.stack));
|
|
@@ -2454,15 +2562,42 @@ fn showMessageDialog(context: ?*anyopaque, options: platform_mod.MessageDialogOp
|
|
|
2454
2562
|
|
|
2455
2563
|
const max_tray_items: usize = 32;
|
|
2456
2564
|
|
|
2457
|
-
fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
|
|
2565
|
+
fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
|
|
2458
2566
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2459
|
-
|
|
2567
|
+
var presentation = options.presentation;
|
|
2568
|
+
if (presentation.title.len == 0) presentation.title = options.title;
|
|
2569
|
+
native_sdk_appkit_create_tray(
|
|
2570
|
+
self.host,
|
|
2571
|
+
status_item_id,
|
|
2572
|
+
options.icon_path.ptr,
|
|
2573
|
+
options.icon_path.len,
|
|
2574
|
+
presentation.title.ptr,
|
|
2575
|
+
presentation.title.len,
|
|
2576
|
+
options.tooltip.ptr,
|
|
2577
|
+
options.tooltip.len,
|
|
2578
|
+
if (options.visible) 1 else 0,
|
|
2579
|
+
presentation.width,
|
|
2580
|
+
@intFromEnum(presentation.tone),
|
|
2581
|
+
presentation.icon_opacity,
|
|
2582
|
+
if (presentation.monospaced) 1 else 0,
|
|
2583
|
+
options.activation_command.ptr,
|
|
2584
|
+
options.activation_command.len,
|
|
2585
|
+
options.alternate_activation_command.ptr,
|
|
2586
|
+
options.alternate_activation_command.len,
|
|
2587
|
+
options.open_command.ptr,
|
|
2588
|
+
options.open_command.len,
|
|
2589
|
+
);
|
|
2460
2590
|
if (options.items.len > 0) {
|
|
2461
|
-
try updateTrayMenu(context, options.items);
|
|
2591
|
+
try updateTrayMenu(context, status_item_id, options.items);
|
|
2462
2592
|
}
|
|
2463
2593
|
}
|
|
2464
2594
|
|
|
2465
|
-
fn
|
|
2595
|
+
fn updateTrayShell(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, shell: platform_mod.TrayShell) anyerror!void {
|
|
2596
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2597
|
+
native_sdk_appkit_update_tray_shell(self.host, status_item_id, shell.icon_path.ptr, shell.icon_path.len, shell.tooltip.ptr, shell.tooltip.len, if (shell.visible) 1 else 0, shell.activation_command.ptr, shell.activation_command.len, shell.alternate_activation_command.ptr, shell.alternate_activation_command.len, shell.open_command.ptr, shell.open_command.len);
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
2466
2601
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2467
2602
|
const count = @min(items.len, max_tray_items);
|
|
2468
2603
|
var ids: [max_tray_items]u32 = undefined;
|
|
@@ -2470,29 +2605,50 @@ fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem
|
|
|
2470
2605
|
var label_lens: [max_tray_items]usize = undefined;
|
|
2471
2606
|
var separators: [max_tray_items]c_int = undefined;
|
|
2472
2607
|
var enabled_flags: [max_tray_items]c_int = undefined;
|
|
2608
|
+
var details: [max_tray_items][*]const u8 = undefined;
|
|
2609
|
+
var detail_lens: [max_tray_items]usize = undefined;
|
|
2610
|
+
var roles: [max_tray_items]c_int = undefined;
|
|
2611
|
+
var keys: [max_tray_items][*]const u8 = undefined;
|
|
2612
|
+
var key_lens: [max_tray_items]usize = undefined;
|
|
2613
|
+
var modifiers: [max_tray_items]u32 = undefined;
|
|
2473
2614
|
for (items[0..count], 0..) |item, i| {
|
|
2474
2615
|
ids[i] = item.id;
|
|
2475
2616
|
labels[i] = item.label.ptr;
|
|
2476
2617
|
label_lens[i] = item.label.len;
|
|
2477
2618
|
separators[i] = if (item.separator) 1 else 0;
|
|
2478
2619
|
enabled_flags[i] = if (item.enabled) 1 else 0;
|
|
2620
|
+
details[i] = item.detail.ptr;
|
|
2621
|
+
detail_lens[i] = item.detail.len;
|
|
2622
|
+
roles[i] = @intFromEnum(item.role);
|
|
2623
|
+
keys[i] = item.key.ptr;
|
|
2624
|
+
key_lens[i] = item.key.len;
|
|
2625
|
+
modifiers[i] = @as(u32, @intFromBool(item.modifiers.primary)) |
|
|
2626
|
+
(@as(u32, @intFromBool(item.modifiers.command)) << 1) |
|
|
2627
|
+
(@as(u32, @intFromBool(item.modifiers.control)) << 2) |
|
|
2628
|
+
(@as(u32, @intFromBool(item.modifiers.option)) << 3) |
|
|
2629
|
+
(@as(u32, @intFromBool(item.modifiers.shift)) << 4);
|
|
2479
2630
|
}
|
|
2480
|
-
native_sdk_appkit_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, count);
|
|
2631
|
+
native_sdk_appkit_update_tray_menu(self.host, status_item_id, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count);
|
|
2481
2632
|
}
|
|
2482
2633
|
|
|
2483
|
-
fn updateTrayTitle(context: ?*anyopaque, title: []const u8) anyerror!void {
|
|
2634
|
+
fn updateTrayTitle(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, title: []const u8) anyerror!void {
|
|
2484
2635
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2485
|
-
native_sdk_appkit_update_tray_title(self.host, title.ptr, title.len);
|
|
2636
|
+
native_sdk_appkit_update_tray_title(self.host, status_item_id, title.ptr, title.len);
|
|
2486
2637
|
}
|
|
2487
2638
|
|
|
2488
|
-
fn
|
|
2639
|
+
fn updateTrayPresentation(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, presentation: platform_mod.TrayPresentation) anyerror!void {
|
|
2489
2640
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2490
|
-
|
|
2641
|
+
native_sdk_appkit_update_tray_presentation(self.host, status_item_id, presentation.title.ptr, presentation.title.len, presentation.width, @intFromEnum(presentation.tone), presentation.icon_opacity, if (presentation.monospaced) 1 else 0);
|
|
2491
2642
|
}
|
|
2492
2643
|
|
|
2493
|
-
fn
|
|
2644
|
+
fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
|
|
2645
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2646
|
+
native_sdk_appkit_remove_tray(self.host, status_item_id);
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
fn appkitTrayCallback(context: ?*anyopaque, status_item_id: u32, item_id: u32) callconv(.c) void {
|
|
2494
2650
|
const state: *RunState = @ptrCast(@alignCast(context.?));
|
|
2495
|
-
state.emit(.{ .tray_action = item_id });
|
|
2651
|
+
state.emit(.{ .tray_action = .{ .status_item_id = status_item_id, .item_id = item_id } });
|
|
2496
2652
|
}
|
|
2497
2653
|
|
|
2498
2654
|
fn flattenFilters(filters: []const platform_mod.FileFilter, buffer: []u8) []const u8 {
|
|
@@ -2517,6 +2673,51 @@ test "mac platform module exports type" {
|
|
|
2517
2673
|
_ = MacPlatform;
|
|
2518
2674
|
}
|
|
2519
2675
|
|
|
2676
|
+
test "mac status agent rows recognize decorated states and stay actionable" {
|
|
2677
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2678
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"configured \"]") != null);
|
|
2679
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"warning \"]") != null);
|
|
2680
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "label.textColor = configured ? successColor : warning ? warningColor : NSColor.secondaryLabelColor;") != null);
|
|
2681
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.tag = (NSInteger)(((uint64_t)statusItemId << 32) | itemIds[index]);") != null);
|
|
2682
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.enabled = enabled[index].boolValue;") != null);
|
|
2683
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.keyEquivalent = NativeSdkMenuKeyEquivalent(key);") != null);
|
|
2684
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.keyEquivalentModifierMask = NativeSdkMenuModifierFlags(modifiers[index].unsignedIntValue);") != null);
|
|
2685
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "item.keyEquivalent = @\"\";") != null);
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
test "mac title-only tray updates preserve the applied presentation" {
|
|
2689
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2690
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationWidth = width;") != null);
|
|
2691
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationTone = tone;") != null);
|
|
2692
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationIconOpacity = iconOpacity;") != null);
|
|
2693
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationMonospaced = monospaced;") != null);
|
|
2694
|
+
const update_at = std.mem.indexOf(u8, host_source, "void native_sdk_appkit_update_tray_title(") orelse return error.TestExpectedEqual;
|
|
2695
|
+
const update_tail = host_source[update_at..];
|
|
2696
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationWidth,") != null);
|
|
2697
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationTone,") != null);
|
|
2698
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationIconOpacity,") != null);
|
|
2699
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationMonospaced") != null);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
test "mac status lifecycle hooks emit tray commands" {
|
|
2704
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2705
|
+
const emit_at = std.mem.indexOf(u8, host_source, "- (void)emitStatusCommand:(NSString *)command statusItemId:(uint32_t)statusItemId {") orelse return error.TestExpectedEqual;
|
|
2706
|
+
const emit_tail = host_source[emit_at..];
|
|
2707
|
+
const emit_end = std.mem.indexOf(u8, emit_tail, "- (void)statusItemActivated:") orelse return error.TestExpectedEqual;
|
|
2708
|
+
const emit_source = emit_tail[0..emit_end];
|
|
2709
|
+
try std.testing.expect(std.mem.indexOf(u8, emit_source, "NATIVE_SDK_APPKIT_EVENT_TRAY_COMMAND") != null);
|
|
2710
|
+
try std.testing.expect(std.mem.indexOf(u8, emit_source, "NATIVE_SDK_APPKIT_EVENT_MENU_COMMAND") == null);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
test "mac status menu updates preserve the menu being opened" {
|
|
2715
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2716
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMenu *menu = entry.menu;") != null);
|
|
2717
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[menu removeAllItems];") != null);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2520
2721
|
test "mac webview presses report the focused child label" {
|
|
2521
2722
|
// WKWebView owns the page's pointer stream, so the AppKit host
|
|
2522
2723
|
// observes the down before dispatch and emits the explicit inverse
|
|
@@ -2528,15 +2729,15 @@ test "mac webview presses report the focused child label" {
|
|
|
2528
2729
|
}
|
|
2529
2730
|
|
|
2530
2731
|
test "mac active implicit show activates before making the window key" {
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2732
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2733
|
+
const show_at = std.mem.indexOf(u8, host_source, "- (void)orderWindowForImplicitShow:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2734
|
+
const show_tail = host_source[show_at..];
|
|
2735
|
+
const show_end = std.mem.indexOf(u8, show_tail, "- (void)focusWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2736
|
+
const show_body = show_tail[0..show_end];
|
|
2737
|
+
const activate_at = std.mem.indexOf(u8, show_body, "[NSApp activateIgnoringOtherApps:YES];") orelse return error.TestExpectedEqual;
|
|
2738
|
+
const make_key_at = std.mem.indexOf(u8, show_body, "[window makeKeyAndOrderFront:nil];") orelse return error.TestExpectedEqual;
|
|
2739
|
+
try std.testing.expect(activate_at < make_key_at);
|
|
2740
|
+
}
|
|
2540
2741
|
}
|
|
2541
2742
|
|
|
2542
2743
|
test "mac unrestored secondary windows cascade within the active screen" {
|
|
@@ -2553,17 +2754,26 @@ test "mac unrestored secondary windows cascade within the active screen" {
|
|
|
2553
2754
|
}
|
|
2554
2755
|
|
|
2555
2756
|
test "mac explicit focus activates before making the window key" {
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2757
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2758
|
+
const focus_at = std.mem.indexOf(u8, host_source, "- (void)focusWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2759
|
+
const focus_tail = host_source[focus_at..];
|
|
2760
|
+
const focus_end = std.mem.indexOf(u8, focus_tail, "- (void)closeWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
2761
|
+
const focus_body = focus_tail[0..focus_end];
|
|
2762
|
+
const activate_at = std.mem.indexOf(u8, focus_body, "[NSApp activateIgnoringOtherApps:YES];") orelse return error.TestExpectedEqual;
|
|
2763
|
+
const make_key_at = std.mem.indexOf(u8, focus_body, "[window makeKeyAndOrderFront:nil];") orelse return error.TestExpectedEqual;
|
|
2764
|
+
try std.testing.expect(activate_at < make_key_at);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
test "mac dock presence changes policy without activating the app" {
|
|
2769
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2770
|
+
const dock_at = std.mem.indexOf(u8, host_source, "int native_sdk_appkit_set_dock_presence(") orelse return error.TestExpectedEqual;
|
|
2771
|
+
const dock_tail = host_source[dock_at..];
|
|
2772
|
+
const dock_end = std.mem.indexOf(u8, dock_tail, "int native_sdk_appkit_launch_at_login_status(") orelse return error.TestExpectedEqual;
|
|
2773
|
+
const dock_body = dock_tail[0..dock_end];
|
|
2774
|
+
try std.testing.expect(std.mem.indexOf(u8, dock_body, "[NSApp setActivationPolicy:policy]") != null);
|
|
2775
|
+
try std.testing.expect(std.mem.indexOf(u8, dock_body, "[NSApp activate") == null);
|
|
2776
|
+
}
|
|
2567
2777
|
}
|
|
2568
2778
|
|
|
2569
2779
|
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
@@ -2885,3 +3095,50 @@ test "mac appearance event carries accessibility preferences" {
|
|
|
2885
3095
|
try std.testing.expect(event.reduce_motion != 0);
|
|
2886
3096
|
try std.testing.expect(event.high_contrast != 0);
|
|
2887
3097
|
}
|
|
3098
|
+
|
|
3099
|
+
test "mac launch-at-login result keeps unsupported separate from operation failure" {
|
|
3100
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.disabled, try launchAtLoginStatusFromInt(0));
|
|
3101
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.enabled, try launchAtLoginStatusFromInt(1));
|
|
3102
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.requires_approval, try launchAtLoginStatusFromInt(2));
|
|
3103
|
+
try std.testing.expectEqual(platform_mod.LaunchAtLoginStatus.not_found, try launchAtLoginStatusFromInt(3));
|
|
3104
|
+
try std.testing.expectError(error.UnsupportedService, launchAtLoginStatusFromInt(-1));
|
|
3105
|
+
try std.testing.expectError(error.LaunchAtLoginFailed, launchAtLoginStatusFromInt(-2));
|
|
3106
|
+
try std.testing.expectError(error.LaunchAtLoginFailed, launchAtLoginStatusFromInt(99));
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
test "both mac hosts carry the menu-bar lifecycle and fullscreen hooks" {
|
|
3110
|
+
const hosts = [_][]const u8{
|
|
3111
|
+
@embedFile("appkit_host.m"),
|
|
3112
|
+
@embedFile("cef_host.mm"),
|
|
3113
|
+
};
|
|
3114
|
+
for (hosts) |host_source| {
|
|
3115
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_hide_window") != null);
|
|
3116
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_set_dock_presence") != null);
|
|
3117
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_launch_at_login_status") != null);
|
|
3118
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_set_launch_at_login") != null);
|
|
3119
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "registerAndReturnError:") != null);
|
|
3120
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "unregisterAndReturnError:") != null);
|
|
3121
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "before == 1 || before == 2") != null);
|
|
3122
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "return succeeded ? NativeSdkLaunchAtLoginStatus() : -2;") != null);
|
|
3123
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "dlopen(") != null);
|
|
3124
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "ServiceManagement.framework/ServiceManagement") != null);
|
|
3125
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSWindowCollectionBehaviorFullScreenNone") != null);
|
|
3126
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "standardWindowButton:NSWindowZoomButton") != null);
|
|
3127
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "1u << 4") != null);
|
|
3128
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "policyHiddenWindows") != null);
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3131
|
+
// AppKit canvas windows also carry a pending first-present/fallback
|
|
3132
|
+
// reveal. An explicit hide must retire that pending reveal before it
|
|
3133
|
+
// records the policy-hidden state.
|
|
3134
|
+
const appkit_source = hosts[0];
|
|
3135
|
+
try std.testing.expect(std.mem.indexOf(u8, appkit_source, "[NSApp activate]") == null);
|
|
3136
|
+
try std.testing.expect(std.mem.indexOf(u8, appkit_source, "[NSApp activateIgnoringOtherApps:YES]") != null);
|
|
3137
|
+
const hide_at = std.mem.indexOf(u8, appkit_source, "- (void)hideWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
3138
|
+
const hide_tail = appkit_source[hide_at..];
|
|
3139
|
+
const show_at = std.mem.indexOf(u8, hide_tail, "- (void)showWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
3140
|
+
const hide_body = hide_tail[0..show_at];
|
|
3141
|
+
const cancel_at = std.mem.indexOf(u8, hide_body, "[self.deferredShowWindows removeObjectForKey:@(windowId)];") orelse return error.TestExpectedEqual;
|
|
3142
|
+
const policy_at = std.mem.indexOf(u8, hide_body, "[self.policyHiddenWindows addObject:@(windowId)];") orelse return error.TestExpectedEqual;
|
|
3143
|
+
try std.testing.expect(cancel_at < policy_at);
|
|
3144
|
+
}
|