@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
|
@@ -35,6 +35,7 @@ const GtkEventKind = enum(c_int) {
|
|
|
35
35
|
audio = 17,
|
|
36
36
|
context_menu_action = 18,
|
|
37
37
|
view_focused = 19,
|
|
38
|
+
notification_command = 20,
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
const GtkEvent = extern struct {
|
|
@@ -47,6 +48,7 @@ const GtkEvent = extern struct {
|
|
|
47
48
|
y: f64,
|
|
48
49
|
open: c_int,
|
|
49
50
|
focused: c_int,
|
|
51
|
+
hidden: c_int,
|
|
50
52
|
label: [*]const u8,
|
|
51
53
|
label_len: usize,
|
|
52
54
|
title: [*]const u8,
|
|
@@ -136,6 +138,7 @@ extern fn native_sdk_gtk_start_timer(host: *GtkHost, timer_id: u64, interval_ns:
|
|
|
136
138
|
extern fn native_sdk_gtk_cancel_timer(host: *GtkHost, timer_id: u64) void;
|
|
137
139
|
extern fn native_sdk_gtk_focus_window(host: *GtkHost, window_id: u64) c_int;
|
|
138
140
|
extern fn native_sdk_gtk_show_window(host: *GtkHost, window_id: u64) c_int;
|
|
141
|
+
extern fn native_sdk_gtk_hide_window(host: *GtkHost, window_id: u64) c_int;
|
|
139
142
|
extern fn native_sdk_gtk_close_window(host: *GtkHost, window_id: u64) c_int;
|
|
140
143
|
extern fn native_sdk_gtk_minimize_window(host: *GtkHost, window_id: u64) c_int;
|
|
141
144
|
extern fn native_sdk_gtk_create_view(host: *GtkHost, window_id: u64, label: [*]const u8, label_len: usize, kind: 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;
|
|
@@ -154,13 +157,14 @@ extern fn native_sdk_gtk_set_webview_layer(host: *GtkHost, window_id: u64, label
|
|
|
154
157
|
extern fn native_sdk_gtk_close_webview(host: *GtkHost, window_id: u64, label: [*]const u8, label_len: usize) c_int;
|
|
155
158
|
extern fn native_sdk_gtk_open_external_url(host: *GtkHost, url: [*]const u8, url_len: usize) c_int;
|
|
156
159
|
extern fn native_sdk_gtk_reveal_path(host: *GtkHost, path: [*]const u8, path_len: usize) c_int;
|
|
157
|
-
extern fn native_sdk_gtk_show_notification(host: *GtkHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize) c_int;
|
|
160
|
+
extern fn native_sdk_gtk_show_notification(host: *GtkHost, 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;
|
|
158
161
|
extern fn native_sdk_gtk_add_recent_document(host: *GtkHost, path: [*]const u8, path_len: usize) c_int;
|
|
159
162
|
extern fn native_sdk_gtk_clear_recent_documents(host: *GtkHost) c_int;
|
|
160
163
|
extern fn native_sdk_gtk_credentials_available(host: *GtkHost) c_int;
|
|
161
164
|
extern fn native_sdk_gtk_set_credential(host: *GtkHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, secret: [*]const u8, secret_len: usize) c_int;
|
|
162
165
|
extern fn native_sdk_gtk_get_credential(host: *GtkHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
163
166
|
extern fn native_sdk_gtk_delete_credential(host: *GtkHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize) c_int;
|
|
167
|
+
extern fn native_sdk_gtk_format_local_time(host: *GtkHost, timestamp_ms: i64, style: c_int, buffer: [*]u8, buffer_len: usize) usize;
|
|
164
168
|
extern fn native_sdk_gtk_audio_available(host: *GtkHost) c_int;
|
|
165
169
|
extern fn native_sdk_gtk_audio_spectrum_available(host: *GtkHost) c_int;
|
|
166
170
|
extern fn native_sdk_gtk_audio_load(host: *GtkHost, path: [*]const u8, path_len: usize) c_int;
|
|
@@ -254,9 +258,8 @@ pub const LinuxPlatform = struct {
|
|
|
254
258
|
app_info: platform_mod.AppInfo,
|
|
255
259
|
surface_value: platform_mod.Surface,
|
|
256
260
|
state: RunState = .{},
|
|
257
|
-
/// Latched when
|
|
258
|
-
///
|
|
259
|
-
/// `PlatformServices.note_channel_wake_abandoned_fn`): the stale
|
|
261
|
+
/// Latched when effects teardown abandons an in-flight platform call
|
|
262
|
+
/// (a channel wake or blocking credential operation): the stale
|
|
260
263
|
/// call still holds this platform as its context and may execute
|
|
261
264
|
/// into it at any later time, so `deinit` must skip destruction
|
|
262
265
|
/// and leak the host, process-lived — and the wrapper struct the
|
|
@@ -329,13 +332,13 @@ pub const LinuxPlatform = struct {
|
|
|
329
332
|
}
|
|
330
333
|
|
|
331
334
|
pub fn deinit(self: *LinuxPlatform) void {
|
|
332
|
-
// An abandoned
|
|
335
|
+
// An abandoned platform call may still enter this host at
|
|
333
336
|
// any later time (see `channel_wake_abandoned`): destroying it
|
|
334
337
|
// would turn that stale call into a use-after-free, so the
|
|
335
338
|
// host is deliberately leaked, process-lived — the
|
|
336
339
|
// abandoned-worker idiom, applied to the platform itself.
|
|
337
340
|
if (self.channel_wake_abandoned.load(.seq_cst)) {
|
|
338
|
-
std.debug.print("linux platform teardown: an abandoned
|
|
341
|
+
std.debug.print("linux 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", .{});
|
|
339
342
|
return;
|
|
340
343
|
}
|
|
341
344
|
native_sdk_gtk_destroy(self.host);
|
|
@@ -363,6 +366,7 @@ pub const LinuxPlatform = struct {
|
|
|
363
366
|
.focus_window_fn = focusWindow,
|
|
364
367
|
.close_window_fn = closeWindow,
|
|
365
368
|
.minimize_window_fn = minimizeWindow,
|
|
369
|
+
.hide_window_fn = hideWindow,
|
|
366
370
|
.show_window_fn = showWindow,
|
|
367
371
|
.quit_app_fn = quitApp,
|
|
368
372
|
.start_window_drag_fn = startWindowDrag,
|
|
@@ -394,6 +398,8 @@ pub const LinuxPlatform = struct {
|
|
|
394
398
|
.set_credential_fn = setCredential,
|
|
395
399
|
.get_credential_fn = getCredential,
|
|
396
400
|
.delete_credential_fn = deleteCredential,
|
|
401
|
+
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
402
|
+
.format_local_time_fn = formatLocalTime,
|
|
397
403
|
.audio_load_fn = audioLoad,
|
|
398
404
|
.audio_load_url_fn = audioLoadUrl,
|
|
399
405
|
.audio_play_fn = audioPlay,
|
|
@@ -444,7 +450,7 @@ pub const LinuxPlatform = struct {
|
|
|
444
450
|
.app_activation_events,
|
|
445
451
|
.gpu_surfaces,
|
|
446
452
|
=> self.web_engine == .system,
|
|
447
|
-
.credentials =>
|
|
453
|
+
.credentials => credentialsAvailable(self.host),
|
|
448
454
|
// Audio rides GStreamer (playbin), runtime-loaded like
|
|
449
455
|
// libsecret: the report is a live probe, so a host without
|
|
450
456
|
// the library honestly answers false and playback degrades
|
|
@@ -572,6 +578,7 @@ fn gtkCallback(context: ?*anyopaque, event: *const GtkEvent) callconv(.c) void {
|
|
|
572
578
|
.scale_factor = @floatCast(event.scale),
|
|
573
579
|
.open = event.open != 0,
|
|
574
580
|
.focused = event.focused != 0,
|
|
581
|
+
.hidden = event.hidden != 0,
|
|
575
582
|
} });
|
|
576
583
|
},
|
|
577
584
|
.view_focused => state.emit(.{ .view_focused = .{
|
|
@@ -593,6 +600,10 @@ fn gtkCallback(context: ?*anyopaque, event: *const GtkEvent) callconv(.c) void {
|
|
|
593
600
|
.name = event.command_name[0..event.command_name_len],
|
|
594
601
|
.window_id = event.window_id,
|
|
595
602
|
} }),
|
|
603
|
+
.notification_command => state.emit(.{ .notification_command = .{
|
|
604
|
+
.name = event.command_name[0..event.command_name_len],
|
|
605
|
+
.window_id = event.window_id,
|
|
606
|
+
} }),
|
|
596
607
|
.files_dropped => {
|
|
597
608
|
var paths_buffer: [platform_mod.max_drop_paths][]const u8 = undefined;
|
|
598
609
|
const paths = platform_mod.splitDropPaths(event.drop_paths[0..event.drop_paths_len], paths_buffer[0..]);
|
|
@@ -854,6 +865,7 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
854
865
|
return switch (mode) {
|
|
855
866
|
.immediate => 0,
|
|
856
867
|
.on_first_present => 1,
|
|
868
|
+
.hidden => 2,
|
|
857
869
|
};
|
|
858
870
|
}
|
|
859
871
|
|
|
@@ -863,6 +875,7 @@ fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
|
863
875
|
if (options.always_on_top) flags |= 1 << 1;
|
|
864
876
|
if (options.click_through) flags |= 1 << 2;
|
|
865
877
|
if (!options.activate_on_show) flags |= 1 << 3;
|
|
878
|
+
if (!options.allows_fullscreen) flags |= 1 << 4;
|
|
866
879
|
return flags;
|
|
867
880
|
}
|
|
868
881
|
|
|
@@ -885,6 +898,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
885
898
|
.scale_factor = 1,
|
|
886
899
|
.open = true,
|
|
887
900
|
.focused = options.activate_on_show and options.show == .immediate,
|
|
901
|
+
.hidden = options.show == .hidden,
|
|
888
902
|
};
|
|
889
903
|
}
|
|
890
904
|
|
|
@@ -903,6 +917,11 @@ fn minimizeWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerr
|
|
|
903
917
|
if (native_sdk_gtk_minimize_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
904
918
|
}
|
|
905
919
|
|
|
920
|
+
fn hideWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
921
|
+
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
922
|
+
if (native_sdk_gtk_hide_window(self.host, window_id) == 0) return error.WindowNotFound;
|
|
923
|
+
}
|
|
924
|
+
|
|
906
925
|
/// GTK has no hide-on-close, but show is still distinct from explicit
|
|
907
926
|
/// focus for passive overlay windows.
|
|
908
927
|
fn showWindow(context: ?*anyopaque, window_id: platform_mod.WindowId) anyerror!void {
|
|
@@ -1316,6 +1335,12 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
|
|
|
1316
1335
|
options.subtitle.len,
|
|
1317
1336
|
options.body.ptr,
|
|
1318
1337
|
options.body.len,
|
|
1338
|
+
options.id.ptr,
|
|
1339
|
+
options.id.len,
|
|
1340
|
+
options.action_label.ptr,
|
|
1341
|
+
options.action_label.len,
|
|
1342
|
+
options.action_command.ptr,
|
|
1343
|
+
options.action_command.len,
|
|
1319
1344
|
) == 0) return error.UnsupportedService;
|
|
1320
1345
|
}
|
|
1321
1346
|
|
|
@@ -1333,9 +1358,8 @@ fn clearRecentDocuments(context: ?*anyopaque) anyerror!void {
|
|
|
1333
1358
|
|
|
1334
1359
|
fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anyerror!void {
|
|
1335
1360
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1336
|
-
if (self.
|
|
1337
|
-
|
|
1338
|
-
if (native_sdk_gtk_set_credential(
|
|
1361
|
+
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.CredentialStoreLocked;
|
|
1362
|
+
const result = native_sdk_gtk_set_credential(
|
|
1339
1363
|
self.host,
|
|
1340
1364
|
credential.service.ptr,
|
|
1341
1365
|
credential.service.len,
|
|
@@ -1343,13 +1367,14 @@ fn setCredential(context: ?*anyopaque, credential: platform_mod.Credential) anye
|
|
|
1343
1367
|
credential.account.len,
|
|
1344
1368
|
credential.secret.ptr,
|
|
1345
1369
|
credential.secret.len,
|
|
1346
|
-
)
|
|
1370
|
+
);
|
|
1371
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
1372
|
+
if (result <= 0) return error.CredentialStoreFailed;
|
|
1347
1373
|
}
|
|
1348
1374
|
|
|
1349
1375
|
fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer: []u8) anyerror![]const u8 {
|
|
1350
1376
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1351
|
-
if (self.
|
|
1352
|
-
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.UnsupportedService;
|
|
1377
|
+
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.CredentialStoreLocked;
|
|
1353
1378
|
const len = native_sdk_gtk_get_credential(
|
|
1354
1379
|
self.host,
|
|
1355
1380
|
key.service.ptr,
|
|
@@ -1359,16 +1384,16 @@ fn getCredential(context: ?*anyopaque, key: platform_mod.CredentialKey, buffer:
|
|
|
1359
1384
|
buffer.ptr,
|
|
1360
1385
|
buffer.len,
|
|
1361
1386
|
);
|
|
1362
|
-
if (len == std.math.maxInt(usize)) return error.
|
|
1363
|
-
if (len ==
|
|
1387
|
+
if (len == std.math.maxInt(usize)) return error.CredentialNotFound;
|
|
1388
|
+
if (len == std.math.maxInt(usize) - 2) return error.CredentialStoreLocked;
|
|
1389
|
+
if (len == std.math.maxInt(usize) - 1) return error.CredentialStoreFailed;
|
|
1364
1390
|
if (len > buffer.len) return error.NoSpaceLeft;
|
|
1365
1391
|
return buffer[0..len];
|
|
1366
1392
|
}
|
|
1367
1393
|
|
|
1368
1394
|
fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyerror!void {
|
|
1369
1395
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1370
|
-
if (self.
|
|
1371
|
-
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.UnsupportedService;
|
|
1396
|
+
if (native_sdk_gtk_credentials_available(self.host) == 0) return error.CredentialStoreLocked;
|
|
1372
1397
|
const result = native_sdk_gtk_delete_credential(
|
|
1373
1398
|
self.host,
|
|
1374
1399
|
key.service.ptr,
|
|
@@ -1376,10 +1401,18 @@ fn deleteCredential(context: ?*anyopaque, key: platform_mod.CredentialKey) anyer
|
|
|
1376
1401
|
key.account.ptr,
|
|
1377
1402
|
key.account.len,
|
|
1378
1403
|
);
|
|
1379
|
-
if (result
|
|
1404
|
+
if (result == -2) return error.CredentialStoreLocked;
|
|
1405
|
+
if (result < 0) return error.CredentialStoreFailed;
|
|
1380
1406
|
if (result == 0) return error.CredentialNotFound;
|
|
1381
1407
|
}
|
|
1382
1408
|
|
|
1409
|
+
fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: platform_mod.LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
|
|
1410
|
+
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
1411
|
+
const len = native_sdk_gtk_format_local_time(self.host, timestamp_ms, @intFromEnum(style), buffer.ptr, buffer.len);
|
|
1412
|
+
if (len == 0 or len > buffer.len) return error.LocalTimeFormatFailed;
|
|
1413
|
+
return buffer[0..len];
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1383
1416
|
/// Map the audio host's synchronous load result: 0 loading (the
|
|
1384
1417
|
/// asynchronous `.loaded` acknowledgment with the decoded duration
|
|
1385
1418
|
/// follows on the main loop), 1 the file is missing, 2 an unusable
|
|
@@ -1458,20 +1491,23 @@ fn videoLoadUrl(context: ?*anyopaque, url: []const u8, token: u64, sink: platfor
|
|
|
1458
1491
|
return videoLoad(context, url, token, sink);
|
|
1459
1492
|
}
|
|
1460
1493
|
|
|
1461
|
-
fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
|
|
1494
|
+
fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
|
|
1462
1495
|
_ = context;
|
|
1496
|
+
_ = status_item_id;
|
|
1463
1497
|
_ = options;
|
|
1464
1498
|
return error.UnsupportedService;
|
|
1465
1499
|
}
|
|
1466
1500
|
|
|
1467
|
-
fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
1501
|
+
fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
1468
1502
|
_ = context;
|
|
1503
|
+
_ = status_item_id;
|
|
1469
1504
|
_ = items;
|
|
1470
1505
|
return error.UnsupportedService;
|
|
1471
1506
|
}
|
|
1472
1507
|
|
|
1473
|
-
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
1508
|
+
fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
|
|
1474
1509
|
_ = context;
|
|
1510
|
+
_ = status_item_id;
|
|
1475
1511
|
return error.UnsupportedService;
|
|
1476
1512
|
}
|
|
1477
1513
|
|
|
@@ -1856,6 +1892,57 @@ test "linux platform module exports type" {
|
|
|
1856
1892
|
_ = LinuxPlatform;
|
|
1857
1893
|
}
|
|
1858
1894
|
|
|
1895
|
+
test "linux message dialogs construct alerts with a non-null format string" {
|
|
1896
|
+
// gtk_alert_dialog_new takes a required printf-style format string.
|
|
1897
|
+
// The host sets the real message below, but NULL still makes GTK
|
|
1898
|
+
// dereference an invalid format pointer during construction.
|
|
1899
|
+
const host_source = @embedFile("gtk_host.c");
|
|
1900
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1901
|
+
u8,
|
|
1902
|
+
host_source,
|
|
1903
|
+
"GtkAlertDialog *dialog = gtk_alert_dialog_new(\"\");",
|
|
1904
|
+
) != null);
|
|
1905
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1906
|
+
u8,
|
|
1907
|
+
host_source,
|
|
1908
|
+
"gtk_alert_dialog_new(NULL)",
|
|
1909
|
+
) == null);
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
test "linux notification actions use process-scoped opaque tokens" {
|
|
1913
|
+
const host_source = @embedFile("gtk_host.c");
|
|
1914
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1915
|
+
u8,
|
|
1916
|
+
host_source,
|
|
1917
|
+
"char *action_token = native_sdk_random_notification_action_token();",
|
|
1918
|
+
) != null);
|
|
1919
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1920
|
+
u8,
|
|
1921
|
+
host_source,
|
|
1922
|
+
"open(\"/dev/urandom\", O_RDONLY | O_CLOEXEC)",
|
|
1923
|
+
) != null);
|
|
1924
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1925
|
+
u8,
|
|
1926
|
+
host_source,
|
|
1927
|
+
"g_variant_new_string(action_token)",
|
|
1928
|
+
) != null);
|
|
1929
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1930
|
+
u8,
|
|
1931
|
+
host_source,
|
|
1932
|
+
"native_sdk_take_notification_action_command(host, token, token_len)",
|
|
1933
|
+
) != null);
|
|
1934
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1935
|
+
u8,
|
|
1936
|
+
host_source,
|
|
1937
|
+
"g_hash_table_remove(host->notification_actions, token);",
|
|
1938
|
+
) != null);
|
|
1939
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1940
|
+
u8,
|
|
1941
|
+
host_source,
|
|
1942
|
+
"g_variant_new_string(command_copy)",
|
|
1943
|
+
) == null);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1859
1946
|
test "linux transparent windows clear the main webview background" {
|
|
1860
1947
|
const host_source = @embedFile("gtk_host.c");
|
|
1861
1948
|
const ensure_at = std.mem.indexOf(
|
|
@@ -2017,7 +2104,7 @@ test "linux first-present windows stay unmapped until present with a cancellable
|
|
|
2017
2104
|
const first_present_at = std.mem.indexOf(
|
|
2018
2105
|
u8,
|
|
2019
2106
|
host_source,
|
|
2020
|
-
"if (first_present && win && !win->shown)",
|
|
2107
|
+
"if (first_present && win && !win->shown && !win->policy_hidden)",
|
|
2021
2108
|
) orelse return error.TestExpectedEqual;
|
|
2022
2109
|
const first_present_tail = host_source[first_present_at..];
|
|
2023
2110
|
const cancel_at = std.mem.indexOf(
|
|
@@ -34,6 +34,8 @@ typedef enum {
|
|
|
34
34
|
NATIVE_SDK_APPKIT_EVENT_AUDIO = 20,
|
|
35
35
|
NATIVE_SDK_APPKIT_EVENT_VIDEO = 21,
|
|
36
36
|
NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED = 22,
|
|
37
|
+
NATIVE_SDK_APPKIT_EVENT_TRAY_COMMAND = 23,
|
|
38
|
+
NATIVE_SDK_APPKIT_EVENT_NOTIFICATION_COMMAND = 24,
|
|
37
39
|
} native_sdk_appkit_event_kind_t;
|
|
38
40
|
|
|
39
41
|
/* Audio player reports (EVENT_AUDIO payloads). LOADED acknowledges a
|
|
@@ -269,6 +271,8 @@ typedef struct {
|
|
|
269
271
|
uint32_t shortcut_modifiers;
|
|
270
272
|
const char *command_name;
|
|
271
273
|
size_t command_name_len;
|
|
274
|
+
/* TRAY_COMMAND: stable owner id for the status item that emitted it. */
|
|
275
|
+
uint32_t status_item_id;
|
|
272
276
|
const char *view_label;
|
|
273
277
|
size_t view_label_len;
|
|
274
278
|
const char *key_text;
|
|
@@ -365,7 +369,8 @@ typedef void (*native_sdk_appkit_bridge_callback_t)(void *context, uint64_t wind
|
|
|
365
369
|
// the first canvas present (present-before-show: the window is created
|
|
366
370
|
// ordered-out and `makeKeyAndOrderFront` runs after the first
|
|
367
371
|
// gpu-surface present lands, with a short fallback deadline so a wedged
|
|
368
|
-
// first frame cannot leave the window invisible)
|
|
372
|
+
// first frame cannot leave the window invisible), 2 = explicitly hidden
|
|
373
|
+
// until a show/focus request.
|
|
369
374
|
//
|
|
370
375
|
// display_name is the human-facing app name (empty = fall back to
|
|
371
376
|
// app_name): it drives the application menu title and its About/Hide/
|
|
@@ -424,11 +429,20 @@ int native_sdk_appkit_close_window(native_sdk_appkit_host_t *host, uint64_t wind
|
|
|
424
429
|
// window controls on chromeless windows. Returns 0 when the window id
|
|
425
430
|
// is unknown.
|
|
426
431
|
int native_sdk_appkit_minimize_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
432
|
+
// Order a live window out without closing it. `show_window` is the inverse.
|
|
433
|
+
int native_sdk_appkit_hide_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
427
434
|
// The show verb: bring the window back to the glass and activate the
|
|
428
435
|
// app (deminiaturize + makeKeyAndOrderFront) — the counterpart to a
|
|
429
436
|
// close_policy .hide hide, and the tray-menu "Open" consequence.
|
|
430
437
|
// Returns 0 when the window id is unknown.
|
|
431
438
|
int native_sdk_appkit_show_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
439
|
+
// Change the process activation policy: visible = regular (Dock/app
|
|
440
|
+
// switcher), hidden = accessory. Returns 1 when applied.
|
|
441
|
+
int native_sdk_appkit_set_dock_presence(native_sdk_appkit_host_t *host, int visible);
|
|
442
|
+
// SMAppService.mainApp status values: 0 not registered, 1 enabled,
|
|
443
|
+
// 2 requires approval, 3 not found; -1 when unavailable.
|
|
444
|
+
int native_sdk_appkit_launch_at_login_status(native_sdk_appkit_host_t *host);
|
|
445
|
+
int native_sdk_appkit_set_launch_at_login(native_sdk_appkit_host_t *host, int enabled);
|
|
432
446
|
// What the user's close affordance does to this window: 0 = quit (the
|
|
433
447
|
// default: really close; last close follows app exit semantics),
|
|
434
448
|
// 1 = hide (order out and keep running — the menu-bar-app shape).
|
|
@@ -633,7 +647,7 @@ int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8
|
|
|
633
647
|
void native_sdk_appkit_clipboard_write(native_sdk_appkit_host_t *host, const char *text, size_t text_len);
|
|
634
648
|
size_t native_sdk_appkit_clipboard_read_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, char *buffer, size_t buffer_len);
|
|
635
649
|
int native_sdk_appkit_clipboard_write_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, const char *bytes, size_t bytes_len);
|
|
636
|
-
int native_sdk_appkit_show_notification(native_sdk_appkit_host_t *host, const char *title, size_t title_len, const char *subtitle, size_t subtitle_len, const char *body, size_t body_len);
|
|
650
|
+
int native_sdk_appkit_show_notification(native_sdk_appkit_host_t *host, const char *title, size_t title_len, const char *subtitle, size_t subtitle_len, const char *body, size_t body_len, const char *notification_id, size_t notification_id_len, const char *action_label, size_t action_label_len, const char *action_command, size_t action_command_len);
|
|
637
651
|
int native_sdk_appkit_open_external_url(native_sdk_appkit_host_t *host, const char *url, size_t url_len);
|
|
638
652
|
int native_sdk_appkit_reveal_path(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
|
|
639
653
|
int native_sdk_appkit_add_recent_document(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
|
|
@@ -641,6 +655,7 @@ int native_sdk_appkit_clear_recent_documents(native_sdk_appkit_host_t *host);
|
|
|
641
655
|
int native_sdk_appkit_set_credential(native_sdk_appkit_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len, const char *secret, size_t secret_len);
|
|
642
656
|
size_t native_sdk_appkit_get_credential(native_sdk_appkit_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len, char *buffer, size_t buffer_len);
|
|
643
657
|
int native_sdk_appkit_delete_credential(native_sdk_appkit_host_t *host, const char *service, size_t service_len, const char *account, size_t account_len);
|
|
658
|
+
size_t native_sdk_appkit_format_local_time(native_sdk_appkit_host_t *host, int64_t timestamp_ms, int style, char *buffer, size_t buffer_len);
|
|
644
659
|
|
|
645
660
|
typedef struct {
|
|
646
661
|
const char *title;
|
|
@@ -685,7 +700,7 @@ typedef struct {
|
|
|
685
700
|
size_t tertiary_button_len;
|
|
686
701
|
} native_sdk_appkit_message_dialog_opts_t;
|
|
687
702
|
|
|
688
|
-
typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t item_id);
|
|
703
|
+
typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t status_item_id, uint32_t item_id);
|
|
689
704
|
|
|
690
705
|
/* One native scroll driver's desired state (see PlatformServices
|
|
691
706
|
* set_gpu_surface_scroll_drivers_fn). Frame coordinates are view-local
|
|
@@ -754,14 +769,16 @@ int native_sdk_appkit_show_context_menu(native_sdk_appkit_host_t *host, uint64_t
|
|
|
754
769
|
native_sdk_appkit_open_dialog_result_t native_sdk_appkit_show_open_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_open_dialog_opts_t *opts, char *buffer, size_t buffer_len);
|
|
755
770
|
size_t native_sdk_appkit_show_save_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_save_dialog_opts_t *opts, char *buffer, size_t buffer_len);
|
|
756
771
|
int native_sdk_appkit_show_message_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_message_dialog_opts_t *opts);
|
|
757
|
-
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len);
|
|
758
|
-
void
|
|
772
|
+
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
773
|
+
void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *tooltip, size_t tooltip_len, int visible, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
774
|
+
void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t status_item_id, const uint32_t *item_ids, const char *const *labels, const size_t *label_lens, const int *separators, const int *enabled_flags, const char *const *details, const size_t *detail_lens, const int *roles, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count);
|
|
759
775
|
/* Retitle the live status item's button without re-creating it (create
|
|
760
776
|
* would flicker and reshuffle the menu bar). Empty title falls back to
|
|
761
777
|
* the icon-only square well, or the app-name initial when there is no
|
|
762
778
|
* icon either — the same fallbacks as create. */
|
|
763
|
-
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, const char *title, size_t title_len);
|
|
764
|
-
void
|
|
779
|
+
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len);
|
|
780
|
+
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced);
|
|
781
|
+
void native_sdk_appkit_remove_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id);
|
|
765
782
|
void native_sdk_appkit_set_tray_callback(native_sdk_appkit_host_t *host, native_sdk_appkit_tray_callback_t callback, void *context);
|
|
766
783
|
|
|
767
784
|
#ifdef __cplusplus
|