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