@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
|
@@ -40,6 +40,8 @@ const WindowsEventKind = enum(c_int) {
|
|
|
40
40
|
audio = 18,
|
|
41
41
|
context_menu_action = 19,
|
|
42
42
|
view_focused = 20,
|
|
43
|
+
tray_command = 21,
|
|
44
|
+
notification_command = 22,
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
const WindowsEvent = extern struct {
|
|
@@ -159,6 +161,7 @@ extern fn native_sdk_windows_cancel_timer(host: *WindowsHost, timer_id: u64) voi
|
|
|
159
161
|
extern fn native_sdk_windows_focus_window(host: *WindowsHost, window_id: u64) c_int;
|
|
160
162
|
extern fn native_sdk_windows_close_window(host: *WindowsHost, window_id: u64) c_int;
|
|
161
163
|
extern fn native_sdk_windows_minimize_window(host: *WindowsHost, window_id: u64) c_int;
|
|
164
|
+
extern fn native_sdk_windows_hide_window(host: *WindowsHost, window_id: u64) c_int;
|
|
162
165
|
extern fn native_sdk_windows_show_window(host: *WindowsHost, window_id: u64) c_int;
|
|
163
166
|
extern fn native_sdk_windows_set_window_close_policy(host: *WindowsHost, window_id: u64, close_policy: c_int) c_int;
|
|
164
167
|
extern fn native_sdk_windows_create_view(host: *WindowsHost, window_id: u64, label: [*]const u8, label_len: usize, kind: c_int, gpu_backend_request: c_int, parent: [*]const u8, parent_len: usize, x: f64, y: f64, width: f64, height: f64, layer: c_int, visible: c_int, enabled: c_int, role: [*]const u8, role_len: usize, accessibility_label: [*]const u8, accessibility_label_len: usize, text: [*]const u8, text_len: usize, command: [*]const u8, command_len: usize) c_int;
|
|
@@ -186,15 +189,16 @@ extern fn native_sdk_windows_reveal_path(host: *WindowsHost, path: [*]const u8,
|
|
|
186
189
|
extern fn native_sdk_windows_show_open_dialog(host: *WindowsHost, opts: *const WindowsOpenDialogOpts, buffer: [*]u8, buffer_len: usize) WindowsOpenDialogResult;
|
|
187
190
|
extern fn native_sdk_windows_show_save_dialog(host: *WindowsHost, opts: *const WindowsSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
|
|
188
191
|
extern fn native_sdk_windows_show_message_dialog(host: *WindowsHost, opts: *const WindowsMessageDialogOpts) c_int;
|
|
189
|
-
extern fn native_sdk_windows_show_notification(host: *WindowsHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize) c_int;
|
|
190
|
-
extern fn native_sdk_windows_create_tray(host: *WindowsHost, icon_path: [*]const u8, icon_path_len: usize, tooltip: [*]const u8, tooltip_len: usize) c_int;
|
|
191
|
-
extern fn native_sdk_windows_update_tray_menu(host: *WindowsHost, item_ids: [*]const u32, labels: [*]const [*]const u8, label_lens: [*]const usize, separators: [*]const c_int, enabled_flags: [*]const c_int, count: usize) c_int;
|
|
192
|
+
extern fn native_sdk_windows_show_notification(host: *WindowsHost, 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;
|
|
193
|
+
extern fn native_sdk_windows_create_tray(host: *WindowsHost, icon_path: [*]const u8, icon_path_len: usize, tooltip: [*]const u8, tooltip_len: usize, 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) c_int;
|
|
194
|
+
extern fn native_sdk_windows_update_tray_menu(host: *WindowsHost, 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) c_int;
|
|
192
195
|
extern fn native_sdk_windows_remove_tray(host: *WindowsHost) void;
|
|
193
196
|
extern fn native_sdk_windows_add_recent_document(host: *WindowsHost, path: [*]const u8, path_len: usize) c_int;
|
|
194
197
|
extern fn native_sdk_windows_clear_recent_documents(host: *WindowsHost) c_int;
|
|
195
198
|
extern fn native_sdk_windows_set_credential(host: *WindowsHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, secret: [*]const u8, secret_len: usize) c_int;
|
|
196
199
|
extern fn native_sdk_windows_get_credential(host: *WindowsHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
197
200
|
extern fn native_sdk_windows_delete_credential(host: *WindowsHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize) c_int;
|
|
201
|
+
extern fn native_sdk_windows_format_local_time(host: *WindowsHost, timestamp_ms: i64, style: c_int, buffer: [*]u8, buffer_len: usize) usize;
|
|
198
202
|
extern fn native_sdk_windows_clipboard_read(host: *WindowsHost, buffer: [*]u8, buffer_len: usize) usize;
|
|
199
203
|
extern fn native_sdk_windows_clipboard_write(host: *WindowsHost, text: [*]const u8, text_len: usize) void;
|
|
200
204
|
extern fn native_sdk_windows_clipboard_read_data(host: *WindowsHost, mime_type: [*]const u8, mime_type_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
@@ -306,9 +310,8 @@ pub const WindowsPlatform = struct {
|
|
|
306
310
|
/// later runtime-created alpha window can fail with the precise
|
|
307
311
|
/// transparency error before crossing the C ABI.
|
|
308
312
|
menus_active: bool = false,
|
|
309
|
-
/// Latched when
|
|
310
|
-
///
|
|
311
|
-
/// `PlatformServices.note_channel_wake_abandoned_fn`): the stale
|
|
313
|
+
/// Latched when effects teardown abandons an in-flight platform call
|
|
314
|
+
/// (a channel wake or blocking credential operation): the stale
|
|
312
315
|
/// call still holds this platform as its context and may execute
|
|
313
316
|
/// into it at any later time, so `deinit` must skip destruction
|
|
314
317
|
/// and leak the host, process-lived — and the wrapper struct the
|
|
@@ -399,13 +402,13 @@ pub const WindowsPlatform = struct {
|
|
|
399
402
|
}
|
|
400
403
|
|
|
401
404
|
pub fn deinit(self: *WindowsPlatform) void {
|
|
402
|
-
// An abandoned
|
|
405
|
+
// An abandoned platform call may still enter this host at
|
|
403
406
|
// any later time (see `channel_wake_abandoned`): destroying it
|
|
404
407
|
// would turn that stale call into a use-after-free, so the
|
|
405
408
|
// host is deliberately leaked, process-lived — the
|
|
406
409
|
// abandoned-worker idiom, applied to the platform itself.
|
|
407
410
|
if (self.channel_wake_abandoned.load(.seq_cst)) {
|
|
408
|
-
std.debug.print("windows platform teardown: an abandoned
|
|
411
|
+
std.debug.print("windows 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", .{});
|
|
409
412
|
return;
|
|
410
413
|
}
|
|
411
414
|
native_sdk_windows_destroy(self.host);
|
|
@@ -433,6 +436,7 @@ pub const WindowsPlatform = struct {
|
|
|
433
436
|
.focus_window_fn = focusWindow,
|
|
434
437
|
.close_window_fn = closeWindow,
|
|
435
438
|
.minimize_window_fn = minimizeWindow,
|
|
439
|
+
.hide_window_fn = hideWindow,
|
|
436
440
|
.show_window_fn = showWindow,
|
|
437
441
|
.quit_app_fn = quitApp,
|
|
438
442
|
.start_window_drag_fn = startWindowDrag,
|
|
@@ -473,6 +477,8 @@ pub const WindowsPlatform = struct {
|
|
|
473
477
|
.set_credential_fn = setCredential,
|
|
474
478
|
.get_credential_fn = getCredential,
|
|
475
479
|
.delete_credential_fn = deleteCredential,
|
|
480
|
+
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
481
|
+
.format_local_time_fn = formatLocalTime,
|
|
476
482
|
.audio_load_fn = audioLoad,
|
|
477
483
|
.audio_load_url_fn = audioLoadUrl,
|
|
478
484
|
.audio_play_fn = audioPlay,
|
|
@@ -519,7 +525,6 @@ pub const WindowsPlatform = struct {
|
|
|
519
525
|
.reveal_path,
|
|
520
526
|
.notifications,
|
|
521
527
|
.recent_documents,
|
|
522
|
-
.credentials,
|
|
523
528
|
.file_drops,
|
|
524
529
|
.app_activation_events,
|
|
525
530
|
.gpu_surfaces,
|
|
@@ -528,6 +533,9 @@ pub const WindowsPlatform = struct {
|
|
|
528
533
|
.microphone_capture,
|
|
529
534
|
.system_audio_capture,
|
|
530
535
|
=> self.web_engine == .system,
|
|
536
|
+
// Credential Manager backs both core effects and the builtin
|
|
537
|
+
// bridge and does not depend on WebView2 being selected.
|
|
538
|
+
.credentials => true,
|
|
531
539
|
// close_policy .hide: WM_CLOSE hides (ShowWindow SW_HIDE),
|
|
532
540
|
// the window stays in the host map, and the tray is the
|
|
533
541
|
// ONLY re-show affordance — SW_HIDE removes the taskbar
|
|
@@ -668,7 +676,15 @@ fn windowsCallback(context: ?*anyopaque, event: *const WindowsEvent) callconv(.c
|
|
|
668
676
|
.name = event.command_name[0..event.command_name_len],
|
|
669
677
|
.window_id = event.window_id,
|
|
670
678
|
} }),
|
|
671
|
-
.tray_action => state.emit(.{ .tray_action = event.tray_item_id }),
|
|
679
|
+
.tray_action => state.emit(.{ .tray_action = .{ .item_id = event.tray_item_id } }),
|
|
680
|
+
.tray_command => state.emit(.{ .tray_command = .{
|
|
681
|
+
.name = event.command_name[0..event.command_name_len],
|
|
682
|
+
.window_id = event.window_id,
|
|
683
|
+
} }),
|
|
684
|
+
.notification_command => state.emit(.{ .notification_command = .{
|
|
685
|
+
.name = event.command_name[0..event.command_name_len],
|
|
686
|
+
.window_id = event.window_id,
|
|
687
|
+
} }),
|
|
672
688
|
.gpu_surface_frame => state.emit(.{ .gpu_surface_frame = gpuSurfaceFrameEventFromWindowsEvent(event) }),
|
|
673
689
|
.gpu_surface_resize => state.emit(.{ .gpu_surface_resized = .{
|
|
674
690
|
.window_id = event.window_id,
|
|
@@ -931,6 +947,7 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
931
947
|
return switch (mode) {
|
|
932
948
|
.immediate => 0,
|
|
933
949
|
.on_first_present => 1,
|
|
950
|
+
.hidden => 2,
|
|
934
951
|
};
|
|
935
952
|
}
|
|
936
953
|
|
|
@@ -940,6 +957,7 @@ fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
|
940
957
|
if (options.always_on_top) flags |= 1 << 1;
|
|
941
958
|
if (options.click_through) flags |= 1 << 2;
|
|
942
959
|
if (!options.activate_on_show) flags |= 1 << 3;
|
|
960
|
+
if (!options.allows_fullscreen) flags |= 1 << 4;
|
|
943
961
|
return flags;
|
|
944
962
|
}
|
|
945
963
|
|
|
@@ -978,6 +996,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
978
996
|
.scale_factor = 1,
|
|
979
997
|
.open = true,
|
|
980
998
|
.focused = options.activate_on_show and options.show == .immediate,
|
|
999
|
+
.hidden = options.show == .hidden,
|
|
981
1000
|
};
|
|
982
1001
|
}
|
|
983
1002
|
|
|
@@ -996,6 +1015,11 @@ fn minimizeWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerr
|
|
|
996
1015
|
if (native_sdk_windows_minimize_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
997
1016
|
}
|
|
998
1017
|
|
|
1018
|
+
fn hideWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
1019
|
+
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1020
|
+
if (native_sdk_windows_hide_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
999
1023
|
fn showWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
1000
1024
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1001
1025
|
if (native_sdk_windows_show_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
@@ -1469,22 +1493,42 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
|
|
|
1469
1493
|
options.subtitle.len,
|
|
1470
1494
|
options.body.ptr,
|
|
1471
1495
|
options.body.len,
|
|
1496
|
+
options.id.ptr,
|
|
1497
|
+
options.id.len,
|
|
1498
|
+
options.action_label.ptr,
|
|
1499
|
+
options.action_label.len,
|
|
1500
|
+
options.action_command.ptr,
|
|
1501
|
+
options.action_command.len,
|
|
1472
1502
|
) == 0) return error.UnsupportedService;
|
|
1473
1503
|
}
|
|
1474
1504
|
|
|
1475
1505
|
const max_tray_items: usize = 32;
|
|
1476
1506
|
|
|
1477
|
-
fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
|
|
1507
|
+
fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
|
|
1478
1508
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1509
|
+
if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
|
|
1479
1510
|
if (self.web_engine != .system) return error.UnsupportedService;
|
|
1480
|
-
if (native_sdk_windows_create_tray(
|
|
1511
|
+
if (native_sdk_windows_create_tray(
|
|
1512
|
+
self.host,
|
|
1513
|
+
options.icon_path.ptr,
|
|
1514
|
+
options.icon_path.len,
|
|
1515
|
+
options.tooltip.ptr,
|
|
1516
|
+
options.tooltip.len,
|
|
1517
|
+
options.activation_command.ptr,
|
|
1518
|
+
options.activation_command.len,
|
|
1519
|
+
options.alternate_activation_command.ptr,
|
|
1520
|
+
options.alternate_activation_command.len,
|
|
1521
|
+
options.open_command.ptr,
|
|
1522
|
+
options.open_command.len,
|
|
1523
|
+
) == 0) return error.UnsupportedService;
|
|
1481
1524
|
if (options.items.len > 0) {
|
|
1482
|
-
try updateTrayMenu(context, options.items);
|
|
1525
|
+
try updateTrayMenu(context, status_item_id, options.items);
|
|
1483
1526
|
}
|
|
1484
1527
|
}
|
|
1485
1528
|
|
|
1486
|
-
fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
1529
|
+
fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
1487
1530
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1531
|
+
if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
|
|
1488
1532
|
if (self.web_engine != .system) return error.UnsupportedService;
|
|
1489
1533
|
const count = @min(items.len, max_tray_items);
|
|
1490
1534
|
var ids: [max_tray_items]u32 = undefined;
|
|
@@ -1492,23 +1536,42 @@ fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem
|
|
|
1492
1536
|
var label_lens: [max_tray_items]usize = undefined;
|
|
1493
1537
|
var separators: [max_tray_items]c_int = undefined;
|
|
1494
1538
|
var enabled_flags: [max_tray_items]c_int = undefined;
|
|
1539
|
+
var details: [max_tray_items][*]const u8 = undefined;
|
|
1540
|
+
var detail_lens: [max_tray_items]usize = undefined;
|
|
1541
|
+
var roles: [max_tray_items]c_int = undefined;
|
|
1542
|
+
var keys: [max_tray_items][*]const u8 = undefined;
|
|
1543
|
+
var key_lens: [max_tray_items]usize = undefined;
|
|
1544
|
+
var modifiers: [max_tray_items]u32 = undefined;
|
|
1495
1545
|
// Tray labels are app-supplied too, so they get the same mnemonic
|
|
1496
|
-
// escape as context-menu items
|
|
1497
|
-
|
|
1546
|
+
// escape as context-menu items. Detail is appended to the visible
|
|
1547
|
+
// Windows fallback label, so escape it too (the host copies both before
|
|
1548
|
+
// returning). Doubling covers the all-ampersands worst case.
|
|
1549
|
+
var label_pool: [max_tray_items * (platform_mod.max_tray_item_label_bytes + platform_mod.max_tray_item_detail_bytes) * 2]u8 = undefined;
|
|
1498
1550
|
var pool_used: usize = 0;
|
|
1499
1551
|
for (items[0..count], 0..) |item, index| {
|
|
1500
1552
|
const label = escapeMenuLabelAmpersands(item.label, &label_pool, &pool_used);
|
|
1553
|
+
const detail = escapeMenuLabelAmpersands(item.detail, &label_pool, &pool_used);
|
|
1501
1554
|
ids[index] = item.id;
|
|
1502
1555
|
labels[index] = label.ptr;
|
|
1503
1556
|
label_lens[index] = label.len;
|
|
1504
1557
|
separators[index] = if (item.separator) 1 else 0;
|
|
1505
|
-
|
|
1558
|
+
// Windows has no custom status-menu row seam. Preserve semantic
|
|
1559
|
+
// readouts as visible detail text, while only command/agent rows can
|
|
1560
|
+
// become actions.
|
|
1561
|
+
enabled_flags[index] = if (item.enabled and (item.role == .command or item.role == .agent)) 1 else 0;
|
|
1562
|
+
details[index] = detail.ptr;
|
|
1563
|
+
detail_lens[index] = detail.len;
|
|
1564
|
+
roles[index] = @intFromEnum(item.role);
|
|
1565
|
+
keys[index] = item.key.ptr;
|
|
1566
|
+
key_lens[index] = item.key.len;
|
|
1567
|
+
modifiers[index] = shortcutModifierFlags(item.modifiers);
|
|
1506
1568
|
}
|
|
1507
|
-
if (native_sdk_windows_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, count) == 0) return error.UnsupportedService;
|
|
1569
|
+
if (native_sdk_windows_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count) == 0) return error.UnsupportedService;
|
|
1508
1570
|
}
|
|
1509
1571
|
|
|
1510
|
-
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
1572
|
+
fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
|
|
1511
1573
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1574
|
+
if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
|
|
1512
1575
|
if (self.web_engine != .system) return error.UnsupportedService;
|
|
1513
1576
|
native_sdk_windows_remove_tray(self.host);
|
|
1514
1577
|
}
|
|
@@ -1539,8 +1602,7 @@ fn clearRecentDocuments(context: ?*anyopaque) anyerror!void {
|
|
|
1539
1602
|
|
|
1540
1603
|
fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anyerror!void {
|
|
1541
1604
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1542
|
-
|
|
1543
|
-
if (native_sdk_windows_set_credential(
|
|
1605
|
+
const result = native_sdk_windows_set_credential(
|
|
1544
1606
|
self.host,
|
|
1545
1607
|
credential.service.ptr,
|
|
1546
1608
|
credential.service.len,
|
|
@@ -1548,12 +1610,14 @@ fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anye
|
|
|
1548
1610
|
credential.account.len,
|
|
1549
1611
|
credential.secret.ptr,
|
|
1550
1612
|
credential.secret.len,
|
|
1551
|
-
)
|
|
1613
|
+
);
|
|
1614
|
+
if (result == -3) return error.AccessDenied;
|
|
1615
|
+
if (result == -4) return error.CredentialFieldTooLarge;
|
|
1616
|
+
if (result <= 0) return error.CredentialStoreFailed;
|
|
1552
1617
|
}
|
|
1553
1618
|
|
|
1554
1619
|
fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer: []u8) anyerror![]const u8 {
|
|
1555
1620
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1556
|
-
if (self.web_engine != .system) return error.UnsupportedService;
|
|
1557
1621
|
const len = native_sdk_windows_get_credential(
|
|
1558
1622
|
self.host,
|
|
1559
1623
|
key.service.ptr,
|
|
@@ -1563,21 +1627,32 @@ fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer:
|
|
|
1563
1627
|
buffer.ptr,
|
|
1564
1628
|
buffer.len,
|
|
1565
1629
|
);
|
|
1566
|
-
if (len ==
|
|
1630
|
+
if (len == std.math.maxInt(usize)) return error.CredentialNotFound;
|
|
1631
|
+
if (len == std.math.maxInt(usize) - 3) return error.AccessDenied;
|
|
1632
|
+
if (len == std.math.maxInt(usize) - 1) return error.CredentialStoreFailed;
|
|
1567
1633
|
if (len > buffer.len) return error.NoSpaceLeft;
|
|
1568
1634
|
return buffer[0..len];
|
|
1569
1635
|
}
|
|
1570
1636
|
|
|
1571
1637
|
fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyerror!void {
|
|
1572
1638
|
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1573
|
-
|
|
1574
|
-
if (native_sdk_windows_delete_credential(
|
|
1639
|
+
const result = native_sdk_windows_delete_credential(
|
|
1575
1640
|
self.host,
|
|
1576
1641
|
key.service.ptr,
|
|
1577
1642
|
key.service.len,
|
|
1578
1643
|
key.account.ptr,
|
|
1579
1644
|
key.account.len,
|
|
1580
|
-
)
|
|
1645
|
+
);
|
|
1646
|
+
if (result == -3) return error.AccessDenied;
|
|
1647
|
+
if (result < 0) return error.CredentialStoreFailed;
|
|
1648
|
+
if (result == 0) return error.CredentialNotFound;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: platform_mod.LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
|
|
1652
|
+
const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
|
|
1653
|
+
const len = native_sdk_windows_format_local_time(self.host, timestamp_ms, @intFromEnum(style), buffer.ptr, buffer.len);
|
|
1654
|
+
if (len == 0 or len > buffer.len) return error.LocalTimeFormatFailed;
|
|
1655
|
+
return buffer[0..len];
|
|
1581
1656
|
}
|
|
1582
1657
|
|
|
1583
1658
|
/// Map the audio host's synchronous load result: 0 loaded, 1 the file is
|
|
@@ -2052,6 +2127,47 @@ test "windows hide-on-close support requires the declared tray (the only re-show
|
|
|
2052
2127
|
try std.testing.expect(!WindowsPlatform.supportsFeature(&chromium, .window_hide_on_close));
|
|
2053
2128
|
}
|
|
2054
2129
|
|
|
2130
|
+
test "windows local time conversion applies the timestamp's dynamic daylight rules" {
|
|
2131
|
+
// The Win32 host cannot execute in this portable suite, so pin the API
|
|
2132
|
+
// sequence Microsoft requires: first expose the UTC SYSTEMTIME, then let
|
|
2133
|
+
// the active dynamic time zone select the offset for that instant. Using
|
|
2134
|
+
// FileTimeToLocalFileTime here would instead apply the current DST bias.
|
|
2135
|
+
const host_source = @embedFile("webview2_host.cpp");
|
|
2136
|
+
const format_at = std.mem.indexOf(u8, host_source, "size_t native_sdk_windows_format_local_time(") orelse return error.TestExpectedEqual;
|
|
2137
|
+
const format_tail = host_source[format_at..];
|
|
2138
|
+
const format_end = std.mem.indexOf(u8, format_tail, "size_t native_sdk_windows_clipboard_read(") orelse return error.TestExpectedEqual;
|
|
2139
|
+
const format_source = format_tail[0..format_end];
|
|
2140
|
+
const utc_at = std.mem.indexOf(u8, format_source, "FileTimeToSystemTime(&utc, &utc_system_time)") orelse return error.TestExpectedEqual;
|
|
2141
|
+
const local_at = std.mem.indexOf(u8, format_source, "SystemTimeToTzSpecificLocalTimeEx(nullptr, &utc_system_time, &system_time)") orelse return error.TestExpectedEqual;
|
|
2142
|
+
try std.testing.expect(utc_at < local_at);
|
|
2143
|
+
try std.testing.expect(std.mem.indexOf(u8, format_source, "FileTimeToLocalFileTime") == null);
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
test "windows tray carries lifecycle commands rich rows and key equivalents into the host" {
|
|
2147
|
+
// These are native Win32 behaviors, so the portable suite pins the
|
|
2148
|
+
// compiled host seam. Windows packaging builds cross-compile the same
|
|
2149
|
+
// source and catch signature/type drift.
|
|
2150
|
+
const host_source = @embedFile("webview2_host.cpp");
|
|
2151
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "host->tray_activation_command = slice(activation_command, activation_command_len);") != null);
|
|
2152
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "emitStatusCommand(host, hwnd, host->tray_alternate_activation_command);") != null);
|
|
2153
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "emitStatusCommand(host, hwnd, host->tray_activation_command);") != null);
|
|
2154
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "emitStatusCommand(host, hwnd, host->tray_open_command);") != null);
|
|
2155
|
+
const emit_at = std.mem.indexOf(u8, host_source, "static bool emitStatusCommand(") orelse return error.TestExpectedEqual;
|
|
2156
|
+
const emit_tail = host_source[emit_at..];
|
|
2157
|
+
const emit_end = std.mem.indexOf(u8, emit_tail, "static void showTrayMenu(") orelse return error.TestExpectedEqual;
|
|
2158
|
+
const emit_source = emit_tail[0..emit_end];
|
|
2159
|
+
try std.testing.expect(std.mem.indexOf(u8, emit_source, "event.kind = kTrayCommand;") != null);
|
|
2160
|
+
try std.testing.expect(std.mem.indexOf(u8, emit_source, "event.kind = kMenuCommand;") == null);
|
|
2161
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "item.detail = slice(details[index], detail_lens[index]);") != null);
|
|
2162
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "item.key = lowerAscii(slice(keys[index], key_lens[index]));") != null);
|
|
2163
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "item.modifiers = modifiers[index];") != null);
|
|
2164
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "display_label += shortcutSuffix(item.key, item.modifiers);") != null);
|
|
2165
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "const std::vector<TrayItem> displayed_items = host->tray_items;") != null);
|
|
2166
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "emitTrayActionForCommandId(host, displayed_items, command_id);") != null);
|
|
2167
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "return emitTrayActionForCommandId(host, host->tray_items, item.command_id);") != null);
|
|
2168
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "tray_event == NIN_SELECT || tray_event == NIN_KEYSELECT || tray_event == WM_LBUTTONUP") != null);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2055
2171
|
test "windows refuses a tray-less .hide main window at platform init instead of stranding it hidden" {
|
|
2056
2172
|
// The pre-created MAIN window never passes through the runtime's
|
|
2057
2173
|
// create gate, so the platform's init gate must hold the same line
|
|
@@ -2382,6 +2498,70 @@ test "windows first-present windows have a fallback reveal deadline" {
|
|
|
2382
2498
|
host_source,
|
|
2383
2499
|
"window.deferred_show_started_ms = window.show_on_first_present ? GetTickCount64() : 0;",
|
|
2384
2500
|
) != null);
|
|
2501
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2502
|
+
u8,
|
|
2503
|
+
host_source,
|
|
2504
|
+
"if (!window.hwnd || window.shown || window.policy_hidden) return;",
|
|
2505
|
+
) != null);
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
test "windows busy message loop drains due gpu frames outside input callbacks" {
|
|
2509
|
+
// The waitable timer is the precise idle wake source, but queued input
|
|
2510
|
+
// may win the message-loop race. Pin the complementary post-dispatch
|
|
2511
|
+
// drain: it must run only after DispatchMessage returns (outside the
|
|
2512
|
+
// runtime callback that requested the frame) while the host is still
|
|
2513
|
+
// running. The helper must retire the one-shot before emitting so
|
|
2514
|
+
// synchronous presentation can re-arm it, and abort if that callback
|
|
2515
|
+
// stops the host so no later due surface receives a post-shutdown event.
|
|
2516
|
+
const host_source = @embedFile("webview2_host.cpp");
|
|
2517
|
+
const run_at = std.mem.indexOf(u8, host_source, "void native_sdk_windows_run(") orelse return error.TestExpectedEqual;
|
|
2518
|
+
const run_tail = host_source[run_at..];
|
|
2519
|
+
const dispatch_at = std.mem.indexOf(u8, run_tail, "DispatchMessageW(&message);") orelse return error.TestExpectedEqual;
|
|
2520
|
+
const post_dispatch = run_tail[dispatch_at..];
|
|
2521
|
+
try std.testing.expect(std.mem.indexOf(u8, post_dispatch, "if (host->running) gpuSurfaceDrainDueFrameEmissions(host);") != null);
|
|
2522
|
+
|
|
2523
|
+
const helper_at = std.mem.indexOf(u8, host_source, "static void gpuSurfaceDrainDueFrameEmissions(Host *host)") orelse return error.TestExpectedEqual;
|
|
2524
|
+
const helper_tail = host_source[helper_at..];
|
|
2525
|
+
const helper_end = std.mem.indexOf(u8, helper_tail, "static void paintGpuSurface(") orelse return error.TestExpectedEqual;
|
|
2526
|
+
const helper = helper_tail[0..helper_end];
|
|
2527
|
+
try std.testing.expect(std.mem.indexOf(u8, helper, "if (!host || !host->running) return;") != null);
|
|
2528
|
+
const loop_at = std.mem.indexOf(u8, helper, "for (const std::string &key : due_keys)") orelse return error.TestExpectedEqual;
|
|
2529
|
+
const loop = helper[loop_at..];
|
|
2530
|
+
const before_emit_guard_at = std.mem.indexOf(u8, loop, "if (!host->running) return;") orelse return error.TestExpectedEqual;
|
|
2531
|
+
const kill_at = std.mem.indexOf(u8, helper, "KillTimer(hwnd, kGpuEmitTimerId);") orelse return error.TestExpectedEqual;
|
|
2532
|
+
const clear_at = std.mem.indexOf(u8, helper, "view.gpu_emission_scheduled = false;") orelse return error.TestExpectedEqual;
|
|
2533
|
+
const emit_at = std.mem.indexOf(u8, helper, "gpuSurfaceEmitFrame(host, view, hwnd);") orelse return error.TestExpectedEqual;
|
|
2534
|
+
const after_emit = helper[emit_at + "gpuSurfaceEmitFrame(host, view, hwnd);".len ..];
|
|
2535
|
+
try std.testing.expect(std.mem.indexOf(u8, after_emit, "if (!host->running) return;") != null);
|
|
2536
|
+
try std.testing.expect(loop_at + before_emit_guard_at < emit_at);
|
|
2537
|
+
try std.testing.expect(kill_at < clear_at);
|
|
2538
|
+
try std.testing.expect(clear_at < emit_at);
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
test "windows gpu frame deadlines use a high resolution waitable timer" {
|
|
2542
|
+
// A nominal 16.67 ms SetTimer is commonly rounded to the legacy timer
|
|
2543
|
+
// grid. Pin the host's precise path: one process-owned high-resolution
|
|
2544
|
+
// waitable timer follows the earliest scheduled surface, participates in
|
|
2545
|
+
// the message loop, refreshes after an emission, and closes at teardown.
|
|
2546
|
+
const host_source = @embedFile("webview2_host.cpp");
|
|
2547
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "CREATE_WAITABLE_TIMER_HIGH_RESOLUTION") != null);
|
|
2548
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "SetWaitableTimer(host->gpu_frame_wake_timer") != null);
|
|
2549
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "MsgWaitForMultipleObjectsEx(") != null);
|
|
2550
|
+
|
|
2551
|
+
const schedule_at = std.mem.indexOf(u8, host_source, "static void gpuSurfaceScheduleFrameEmission(Host *host, NativeView &view)") orelse return error.TestExpectedEqual;
|
|
2552
|
+
const schedule_tail = host_source[schedule_at..];
|
|
2553
|
+
const schedule_end = std.mem.indexOf(u8, schedule_tail, "static void gpuSurfaceDrainDueFrameEmissions(") orelse return error.TestExpectedEqual;
|
|
2554
|
+
const schedule = schedule_tail[0..schedule_end];
|
|
2555
|
+
const scheduled_at = std.mem.indexOf(u8, schedule, "view.gpu_emission_scheduled = true;") orelse return error.TestExpectedEqual;
|
|
2556
|
+
const wake_at = std.mem.indexOf(u8, schedule, "gpuSurfaceRefreshFrameWakeTimer(host);") orelse return error.TestExpectedEqual;
|
|
2557
|
+
try std.testing.expect(scheduled_at < wake_at);
|
|
2558
|
+
|
|
2559
|
+
const timer_at = std.mem.indexOf(u8, host_source, "if (wparam == kGpuEmitTimerId)") orelse return error.TestExpectedEqual;
|
|
2560
|
+
const timer_tail = host_source[timer_at..];
|
|
2561
|
+
const emit_at = std.mem.indexOf(u8, timer_tail, "gpuSurfaceEmitFrame(host, *view, hwnd);") orelse return error.TestExpectedEqual;
|
|
2562
|
+
const refresh_at = std.mem.indexOf(u8, timer_tail, "gpuSurfaceRefreshFrameWakeTimer(host);") orelse return error.TestExpectedEqual;
|
|
2563
|
+
try std.testing.expect(emit_at < refresh_at);
|
|
2564
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "gpuSurfaceDestroyFrameWakeTimer(host);") != null);
|
|
2385
2565
|
}
|
|
2386
2566
|
|
|
2387
2567
|
test "windows window focus includes focused native child views" {
|