@native-sdk/cli 0.9.0 → 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 +331 -24
- package/build.zig +179 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +167 -12
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +11 -5
- package/skill-data/ts-core/SKILL.md +53 -20
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +29 -0
- package/src/app_runner/ts_core_main.zig +5 -0
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +1 -0
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +28 -0
- package/src/embed/ui_host.zig +68 -2
- package/src/platform/linux/cef_host.cpp +7 -1
- package/src/platform/linux/gtk_host.c +200 -5
- package/src/platform/linux/gtk_host.h +2 -1
- package/src/platform/linux/root.zig +69 -4
- package/src/platform/macos/appkit_host.h +11 -7
- package/src/platform/macos/appkit_host.m +210 -88
- package/src/platform/macos/cef_host.mm +210 -88
- package/src/platform/macos/root.zig +77 -30
- package/src/platform/null_platform.zig +234 -51
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +10 -0
- package/src/platform/types.zig +105 -16
- package/src/platform/windows/root.zig +20 -6
- package/src/platform/windows/webview2_host.cpp +41 -5
- package/src/root.zig +7 -0
- package/src/runtime/api.zig +8 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +11 -1
- package/src/runtime/core.zig +12 -6
- package/src/runtime/effects.zig +1323 -35
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_notification_tests.zig +11 -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 +21 -9
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +5 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +97 -7
- package/src/runtime/session_tests.zig +81 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +95 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +321 -109
- package/src/runtime/ui_app_tests.zig +132 -6
- package/src/runtime/ui_app_window_tests.zig +61 -7
- package/src/runtime/validation.zig +20 -0
- package/src/tooling/templates.zig +28 -0
- package/src/tooling/ts_core.zig +83 -0
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -29,12 +29,16 @@ const max_recent_document_path_bytes = types.max_recent_document_path_bytes;
|
|
|
29
29
|
const max_notification_title_bytes = types.max_notification_title_bytes;
|
|
30
30
|
const max_notification_subtitle_bytes = types.max_notification_subtitle_bytes;
|
|
31
31
|
const max_notification_body_bytes = types.max_notification_body_bytes;
|
|
32
|
+
const max_notification_id_bytes = types.max_notification_id_bytes;
|
|
33
|
+
const max_notification_action_label_bytes = types.max_notification_action_label_bytes;
|
|
34
|
+
const max_notification_action_command_bytes = types.max_notification_action_command_bytes;
|
|
32
35
|
const max_clipboard_mime_type_bytes = types.max_clipboard_mime_type_bytes;
|
|
33
36
|
const max_clipboard_data_bytes = types.max_clipboard_data_bytes;
|
|
34
37
|
const max_credential_service_bytes = types.max_credential_service_bytes;
|
|
35
38
|
const max_credential_account_bytes = types.max_credential_account_bytes;
|
|
36
39
|
const max_credential_secret_bytes = types.max_credential_secret_bytes;
|
|
37
40
|
const max_local_time_text_bytes = types.max_local_time_text_bytes;
|
|
41
|
+
const max_status_items = types.max_status_items;
|
|
38
42
|
const max_tray_items = types.max_tray_items;
|
|
39
43
|
const max_tray_icon_path_bytes = types.max_tray_icon_path_bytes;
|
|
40
44
|
const max_tray_title_bytes = types.max_tray_title_bytes;
|
|
@@ -112,6 +116,8 @@ const NotificationOptions = types.NotificationOptions;
|
|
|
112
116
|
const CredentialKey = types.CredentialKey;
|
|
113
117
|
const Credential = types.Credential;
|
|
114
118
|
const LocalTimeStyle = types.LocalTimeStyle;
|
|
119
|
+
const StatusItemId = types.StatusItemId;
|
|
120
|
+
const TrayShell = types.TrayShell;
|
|
115
121
|
const TrayItemId = types.TrayItemId;
|
|
116
122
|
const TrayOptions = types.TrayOptions;
|
|
117
123
|
const TrayPresentation = types.TrayPresentation;
|
|
@@ -119,6 +125,7 @@ const TrayMenuItem = types.TrayMenuItem;
|
|
|
119
125
|
const NativeCommandEvent = types.NativeCommandEvent;
|
|
120
126
|
const MenuCommandEvent = types.MenuCommandEvent;
|
|
121
127
|
const TrayCommandEvent = types.TrayCommandEvent;
|
|
128
|
+
const Event = types.Event;
|
|
122
129
|
const TimerEvent = types.TimerEvent;
|
|
123
130
|
const FileDropEvent = types.FileDropEvent;
|
|
124
131
|
const GpuFrame = types.GpuFrame;
|
|
@@ -145,7 +152,6 @@ const WidgetAccessibilityActionEvent = types.WidgetAccessibilityActionEvent;
|
|
|
145
152
|
const ClipboardData = types.ClipboardData;
|
|
146
153
|
const ColorScheme = types.ColorScheme;
|
|
147
154
|
const Appearance = types.Appearance;
|
|
148
|
-
const Event = types.Event;
|
|
149
155
|
const splitDropPaths = types.splitDropPaths;
|
|
150
156
|
const EventHandler = types.EventHandler;
|
|
151
157
|
const PlatformServices = types.PlatformServices;
|
|
@@ -294,6 +300,37 @@ pub const NullAudioCapture = struct {
|
|
|
294
300
|
stop_count: usize = 0,
|
|
295
301
|
};
|
|
296
302
|
|
|
303
|
+
const NullStatusItem = struct {
|
|
304
|
+
id: StatusItemId = 0,
|
|
305
|
+
active: bool = false,
|
|
306
|
+
visible: bool = true,
|
|
307
|
+
icon_path: [max_tray_icon_path_bytes]u8 = undefined,
|
|
308
|
+
icon_path_len: usize = 0,
|
|
309
|
+
title: [max_tray_title_bytes]u8 = undefined,
|
|
310
|
+
title_len: usize = 0,
|
|
311
|
+
tooltip: [max_tray_tooltip_bytes]u8 = undefined,
|
|
312
|
+
tooltip_len: usize = 0,
|
|
313
|
+
activation_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
314
|
+
activation_command_len: usize = 0,
|
|
315
|
+
alternate_activation_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
316
|
+
alternate_activation_command_len: usize = 0,
|
|
317
|
+
open_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
318
|
+
open_command_len: usize = 0,
|
|
319
|
+
presentation: TrayPresentation = .{},
|
|
320
|
+
items: [max_tray_items]TrayMenuItem = undefined,
|
|
321
|
+
item_count: usize = 0,
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const max_null_notifications: usize = 16;
|
|
325
|
+
|
|
326
|
+
const NullNotification = struct {
|
|
327
|
+
active: bool = false,
|
|
328
|
+
id: [max_notification_id_bytes]u8 = undefined,
|
|
329
|
+
id_len: usize = 0,
|
|
330
|
+
action_command: [max_notification_action_command_bytes]u8 = undefined,
|
|
331
|
+
action_command_len: usize = 0,
|
|
332
|
+
};
|
|
333
|
+
|
|
297
334
|
pub const NullPlatform = struct {
|
|
298
335
|
surface_value: Surface = .{},
|
|
299
336
|
web_engine: WebEngine = .system,
|
|
@@ -464,7 +501,15 @@ pub const NullPlatform = struct {
|
|
|
464
501
|
notification_subtitle_len: usize = 0,
|
|
465
502
|
notification_body: [max_notification_body_bytes]u8 = undefined,
|
|
466
503
|
notification_body_len: usize = 0,
|
|
504
|
+
notification_id: [max_notification_id_bytes]u8 = undefined,
|
|
505
|
+
notification_id_len: usize = 0,
|
|
506
|
+
notification_action_label: [max_notification_action_label_bytes]u8 = undefined,
|
|
507
|
+
notification_action_label_len: usize = 0,
|
|
508
|
+
notification_action_command: [max_notification_action_command_bytes]u8 = undefined,
|
|
509
|
+
notification_action_command_len: usize = 0,
|
|
510
|
+
notifications: [max_null_notifications]NullNotification = [_]NullNotification{.{}} ** max_null_notifications,
|
|
467
511
|
notification_count: usize = 0,
|
|
512
|
+
notification_replacement_count: usize = 0,
|
|
468
513
|
clipboard_mime_type: [max_clipboard_mime_type_bytes]u8 = undefined,
|
|
469
514
|
clipboard_mime_type_len: usize = 0,
|
|
470
515
|
clipboard_data: [max_clipboard_data_bytes]u8 = undefined,
|
|
@@ -487,22 +532,10 @@ pub const NullPlatform = struct {
|
|
|
487
532
|
/// fixed offset so suites can pin exact output without ambient state.
|
|
488
533
|
local_time_offset_minutes: i16 = 0,
|
|
489
534
|
webview_navigate_count: usize = 0,
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
tray_title: [max_tray_title_bytes]u8 = undefined,
|
|
493
|
-
tray_title_len: usize = 0,
|
|
494
|
-
tray_tooltip: [max_tray_tooltip_bytes]u8 = undefined,
|
|
495
|
-
tray_tooltip_len: usize = 0,
|
|
496
|
-
tray_activation_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
497
|
-
tray_activation_command_len: usize = 0,
|
|
498
|
-
tray_alternate_activation_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
499
|
-
tray_alternate_activation_command_len: usize = 0,
|
|
500
|
-
tray_open_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
501
|
-
tray_open_command_len: usize = 0,
|
|
502
|
-
tray_presentation: TrayPresentation = .{},
|
|
503
|
-
tray_items: [max_tray_items]TrayMenuItem = undefined,
|
|
504
|
-
tray_item_count: usize = 0,
|
|
535
|
+
status_items: [max_status_items]NullStatusItem = [_]NullStatusItem{.{}} ** max_status_items,
|
|
536
|
+
status_item_count: usize = 0,
|
|
505
537
|
tray_create_count: usize = 0,
|
|
538
|
+
tray_shell_update_count: usize = 0,
|
|
506
539
|
tray_update_count: usize = 0,
|
|
507
540
|
tray_title_update_count: usize = 0,
|
|
508
541
|
tray_remove_count: usize = 0,
|
|
@@ -885,6 +918,7 @@ pub const NullPlatform = struct {
|
|
|
885
918
|
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
886
919
|
.format_local_time_fn = formatLocalTime,
|
|
887
920
|
.create_tray_fn = createTray,
|
|
921
|
+
.update_tray_shell_fn = updateTrayShell,
|
|
888
922
|
.update_tray_menu_fn = updateTrayMenu,
|
|
889
923
|
.update_tray_title_fn = updateTrayTitle,
|
|
890
924
|
.update_tray_presentation_fn = updateTrayPresentation,
|
|
@@ -1541,9 +1575,36 @@ pub const NullPlatform = struct {
|
|
|
1541
1575
|
self.notification_title = undefined;
|
|
1542
1576
|
self.notification_subtitle = undefined;
|
|
1543
1577
|
self.notification_body = undefined;
|
|
1578
|
+
self.notification_id = undefined;
|
|
1579
|
+
self.notification_action_label = undefined;
|
|
1580
|
+
self.notification_action_command = undefined;
|
|
1544
1581
|
self.notification_title_len = (try copyInto(&self.notification_title, options.title)).len;
|
|
1545
1582
|
self.notification_subtitle_len = (try copyInto(&self.notification_subtitle, options.subtitle)).len;
|
|
1546
1583
|
self.notification_body_len = (try copyInto(&self.notification_body, options.body)).len;
|
|
1584
|
+
self.notification_id_len = (try copyInto(&self.notification_id, options.id)).len;
|
|
1585
|
+
self.notification_action_label_len = (try copyInto(&self.notification_action_label, options.action_label)).len;
|
|
1586
|
+
self.notification_action_command_len = (try copyInto(&self.notification_action_command, options.action_command)).len;
|
|
1587
|
+
|
|
1588
|
+
if (options.id.len > 0) {
|
|
1589
|
+
var selected: ?usize = null;
|
|
1590
|
+
var free: ?usize = null;
|
|
1591
|
+
for (&self.notifications, 0..) |*entry, index| {
|
|
1592
|
+
if (!entry.active) {
|
|
1593
|
+
if (free == null) free = index;
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
if (std.mem.eql(u8, entry.id[0..entry.id_len], options.id)) {
|
|
1597
|
+
selected = index;
|
|
1598
|
+
self.notification_replacement_count += 1;
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
const index = selected orelse free orelse (self.notification_count % max_null_notifications);
|
|
1603
|
+
var entry = &self.notifications[index];
|
|
1604
|
+
entry.* = .{ .active = true };
|
|
1605
|
+
entry.id_len = (try copyInto(&entry.id, options.id)).len;
|
|
1606
|
+
entry.action_command_len = (try copyInto(&entry.action_command, options.action_command)).len;
|
|
1607
|
+
}
|
|
1547
1608
|
self.notification_count += 1;
|
|
1548
1609
|
}
|
|
1549
1610
|
|
|
@@ -1657,51 +1718,92 @@ pub const NullPlatform = struct {
|
|
|
1657
1718
|
return .{ .year = @intCast(civil_year), .month = month, .day = day };
|
|
1658
1719
|
}
|
|
1659
1720
|
|
|
1660
|
-
fn
|
|
1721
|
+
fn findStatusItem(self: *NullPlatform, status_item_id: StatusItemId) ?*NullStatusItem {
|
|
1722
|
+
for (&self.status_items) |*item| {
|
|
1723
|
+
if (item.active and item.id == status_item_id) return item;
|
|
1724
|
+
}
|
|
1725
|
+
return null;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
fn findStatusItemConst(self: *const NullPlatform, status_item_id: StatusItemId) ?*const NullStatusItem {
|
|
1729
|
+
for (&self.status_items) |*item| {
|
|
1730
|
+
if (item.active and item.id == status_item_id) return item;
|
|
1731
|
+
}
|
|
1732
|
+
return null;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
fn statusItemSlot(self: *NullPlatform, status_item_id: StatusItemId) anyerror!*NullStatusItem {
|
|
1736
|
+
if (self.findStatusItem(status_item_id)) |item| return item;
|
|
1737
|
+
for (&self.status_items) |*item| {
|
|
1738
|
+
if (!item.active) {
|
|
1739
|
+
item.* = .{ .id = status_item_id, .active = true };
|
|
1740
|
+
self.status_item_count += 1;
|
|
1741
|
+
return item;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
return error.UnsupportedService;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
fn copyTrayShell(item: *NullStatusItem, shell: TrayShell) anyerror!void {
|
|
1748
|
+
item.icon_path_len = (try copyInto(&item.icon_path, shell.icon_path)).len;
|
|
1749
|
+
item.tooltip_len = (try copyInto(&item.tooltip, shell.tooltip)).len;
|
|
1750
|
+
item.activation_command_len = (try copyInto(&item.activation_command, shell.activation_command)).len;
|
|
1751
|
+
item.alternate_activation_command_len = (try copyInto(&item.alternate_activation_command, shell.alternate_activation_command)).len;
|
|
1752
|
+
item.open_command_len = (try copyInto(&item.open_command, shell.open_command)).len;
|
|
1753
|
+
item.visible = shell.visible;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
fn createTray(context: ?*anyopaque, status_item_id: StatusItemId, options: TrayOptions) anyerror!void {
|
|
1661
1757
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
self.tray_tooltip = undefined;
|
|
1665
|
-
self.tray_icon_path_len = (try copyInto(&self.tray_icon_path, options.icon_path)).len;
|
|
1758
|
+
const item = try self.statusItemSlot(status_item_id);
|
|
1759
|
+
try copyTrayShell(item, types.trayShell(options));
|
|
1666
1760
|
var presentation = options.presentation;
|
|
1667
1761
|
if (presentation.title.len == 0) presentation.title = options.title;
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
self.tray_open_command_len = (try copyInto(&self.tray_open_command, options.open_command)).len;
|
|
1673
|
-
self.tray_presentation = presentation;
|
|
1674
|
-
self.tray_presentation.title = self.tray_title[0..self.tray_title_len];
|
|
1675
|
-
try updateTrayMenu(context, options.items);
|
|
1762
|
+
item.title_len = (try copyInto(&item.title, presentation.title)).len;
|
|
1763
|
+
item.presentation = presentation;
|
|
1764
|
+
item.presentation.title = item.title[0..item.title_len];
|
|
1765
|
+
try updateTrayMenu(context, status_item_id, options.items);
|
|
1676
1766
|
self.tray_create_count += 1;
|
|
1677
1767
|
}
|
|
1678
1768
|
|
|
1679
|
-
fn
|
|
1769
|
+
fn updateTrayShell(context: ?*anyopaque, status_item_id: StatusItemId, shell: TrayShell) anyerror!void {
|
|
1680
1770
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
self.
|
|
1771
|
+
const item = self.findStatusItem(status_item_id) orelse return error.InvalidTrayOptions;
|
|
1772
|
+
try copyTrayShell(item, shell);
|
|
1773
|
+
self.tray_shell_update_count += 1;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
fn updateTrayMenu(context: ?*anyopaque, status_item_id: StatusItemId, items: []const TrayMenuItem) anyerror!void {
|
|
1777
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1778
|
+
const status_item = self.findStatusItem(status_item_id) orelse return error.InvalidTrayOptions;
|
|
1779
|
+
if (items.len > status_item.items.len) return error.InvalidTrayOptions;
|
|
1780
|
+
for (items, 0..) |item, index| status_item.items[index] = item;
|
|
1781
|
+
status_item.item_count = items.len;
|
|
1684
1782
|
self.tray_update_count += 1;
|
|
1685
1783
|
}
|
|
1686
1784
|
|
|
1687
|
-
fn updateTrayTitle(context: ?*anyopaque, title: []const u8) anyerror!void {
|
|
1785
|
+
fn updateTrayTitle(context: ?*anyopaque, status_item_id: StatusItemId, title: []const u8) anyerror!void {
|
|
1688
1786
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1689
|
-
self.
|
|
1690
|
-
|
|
1691
|
-
|
|
1787
|
+
const item = self.findStatusItem(status_item_id) orelse return error.InvalidTrayOptions;
|
|
1788
|
+
item.title_len = (try copyInto(&item.title, title)).len;
|
|
1789
|
+
item.presentation.title = item.title[0..item.title_len];
|
|
1692
1790
|
self.tray_title_update_count += 1;
|
|
1693
1791
|
}
|
|
1694
1792
|
|
|
1695
|
-
fn updateTrayPresentation(context: ?*anyopaque, presentation: TrayPresentation) anyerror!void {
|
|
1793
|
+
fn updateTrayPresentation(context: ?*anyopaque, status_item_id: StatusItemId, presentation: TrayPresentation) anyerror!void {
|
|
1696
1794
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1697
|
-
try updateTrayTitle(context, presentation.title);
|
|
1698
|
-
self.
|
|
1699
|
-
|
|
1795
|
+
try updateTrayTitle(context, status_item_id, presentation.title);
|
|
1796
|
+
const item = self.findStatusItem(status_item_id) orelse return error.InvalidTrayOptions;
|
|
1797
|
+
item.presentation = presentation;
|
|
1798
|
+
item.presentation.title = item.title[0..item.title_len];
|
|
1700
1799
|
}
|
|
1701
1800
|
|
|
1702
|
-
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
1801
|
+
fn removeTray(context: ?*anyopaque, status_item_id: StatusItemId) anyerror!void {
|
|
1703
1802
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1704
|
-
self.
|
|
1803
|
+
const item = self.findStatusItem(status_item_id) orelse return;
|
|
1804
|
+
item.active = false;
|
|
1805
|
+
item.item_count = 0;
|
|
1806
|
+
self.status_item_count -= 1;
|
|
1705
1807
|
self.tray_remove_count += 1;
|
|
1706
1808
|
}
|
|
1707
1809
|
|
|
@@ -2979,10 +3081,45 @@ pub const NullPlatform = struct {
|
|
|
2979
3081
|
return self.notification_body[0..self.notification_body_len];
|
|
2980
3082
|
}
|
|
2981
3083
|
|
|
3084
|
+
pub fn lastNotificationId(self: *const NullPlatform) []const u8 {
|
|
3085
|
+
return self.notification_id[0..self.notification_id_len];
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
pub fn lastNotificationActionLabel(self: *const NullPlatform) []const u8 {
|
|
3089
|
+
return self.notification_action_label[0..self.notification_action_label_len];
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
pub fn lastNotificationActionCommand(self: *const NullPlatform) []const u8 {
|
|
3093
|
+
return self.notification_action_command[0..self.notification_action_command_len];
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
/// Deterministically model a user activating the action on a named,
|
|
3097
|
+
/// currently active notification. The returned event borrows this
|
|
3098
|
+
/// platform's fixed storage until the next notification update.
|
|
3099
|
+
pub fn activateNotification(self: *const NullPlatform, id: []const u8) ?Event {
|
|
3100
|
+
for (&self.notifications) |*entry| {
|
|
3101
|
+
if (!entry.active or !std.mem.eql(u8, entry.id[0..entry.id_len], id)) continue;
|
|
3102
|
+
if (entry.action_command_len == 0) return null;
|
|
3103
|
+
return .{ .notification_command = .{ .name = entry.action_command[0..entry.action_command_len] } };
|
|
3104
|
+
}
|
|
3105
|
+
return null;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
/// Anonymous notifications have no replacement key; tests can still
|
|
3109
|
+
/// activate the most recently delivered action through this seam.
|
|
3110
|
+
pub fn activateLastNotification(self: *const NullPlatform) ?Event {
|
|
3111
|
+
if (self.notification_action_command_len == 0) return null;
|
|
3112
|
+
return .{ .notification_command = .{ .name = self.lastNotificationActionCommand() } };
|
|
3113
|
+
}
|
|
3114
|
+
|
|
2982
3115
|
pub fn notificationCount(self: *const NullPlatform) usize {
|
|
2983
3116
|
return self.notification_count;
|
|
2984
3117
|
}
|
|
2985
3118
|
|
|
3119
|
+
pub fn notificationReplacementCount(self: *const NullPlatform) usize {
|
|
3120
|
+
return self.notification_replacement_count;
|
|
3121
|
+
}
|
|
3122
|
+
|
|
2986
3123
|
pub fn lastClipboardMimeType(self: *const NullPlatform) []const u8 {
|
|
2987
3124
|
return self.clipboard_mime_type[0..self.clipboard_mime_type_len];
|
|
2988
3125
|
}
|
|
@@ -3016,35 +3153,77 @@ pub const NullPlatform = struct {
|
|
|
3016
3153
|
}
|
|
3017
3154
|
|
|
3018
3155
|
pub fn lastTrayIconPath(self: *const NullPlatform) []const u8 {
|
|
3019
|
-
return self.
|
|
3156
|
+
return self.statusItemIconPath(types.primary_status_item_id);
|
|
3020
3157
|
}
|
|
3021
3158
|
|
|
3022
3159
|
pub fn lastTrayTitle(self: *const NullPlatform) []const u8 {
|
|
3023
|
-
return self.
|
|
3160
|
+
return self.statusItemTitle(types.primary_status_item_id);
|
|
3024
3161
|
}
|
|
3025
3162
|
|
|
3026
3163
|
pub fn lastTrayTooltip(self: *const NullPlatform) []const u8 {
|
|
3027
|
-
return self.
|
|
3164
|
+
return self.statusItemTooltip(types.primary_status_item_id);
|
|
3028
3165
|
}
|
|
3029
3166
|
|
|
3030
3167
|
pub fn lastTrayActivationCommand(self: *const NullPlatform) []const u8 {
|
|
3031
|
-
|
|
3168
|
+
const item = self.findStatusItemConst(types.primary_status_item_id) orelse return "";
|
|
3169
|
+
return item.activation_command[0..item.activation_command_len];
|
|
3032
3170
|
}
|
|
3033
3171
|
|
|
3034
3172
|
pub fn lastTrayAlternateActivationCommand(self: *const NullPlatform) []const u8 {
|
|
3035
|
-
|
|
3173
|
+
const item = self.findStatusItemConst(types.primary_status_item_id) orelse return "";
|
|
3174
|
+
return item.alternate_activation_command[0..item.alternate_activation_command_len];
|
|
3036
3175
|
}
|
|
3037
3176
|
|
|
3038
3177
|
pub fn lastTrayOpenCommand(self: *const NullPlatform) []const u8 {
|
|
3039
|
-
|
|
3178
|
+
const item = self.findStatusItemConst(types.primary_status_item_id) orelse return "";
|
|
3179
|
+
return item.open_command[0..item.open_command_len];
|
|
3040
3180
|
}
|
|
3041
3181
|
|
|
3042
3182
|
pub fn lastTrayPresentation(self: *const NullPlatform) TrayPresentation {
|
|
3043
|
-
|
|
3183
|
+
const item = self.findStatusItemConst(types.primary_status_item_id) orelse return .{};
|
|
3184
|
+
return item.presentation;
|
|
3044
3185
|
}
|
|
3045
3186
|
|
|
3046
3187
|
pub fn trayItems(self: *const NullPlatform) []const TrayMenuItem {
|
|
3047
|
-
return self.
|
|
3188
|
+
return self.statusItemMenu(types.primary_status_item_id);
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
pub fn statusItemCount(self: *const NullPlatform) usize {
|
|
3192
|
+
return self.status_item_count;
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
pub fn statusItemExists(self: *const NullPlatform, status_item_id: StatusItemId) bool {
|
|
3196
|
+
return self.findStatusItemConst(status_item_id) != null;
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
pub fn statusItemVisible(self: *const NullPlatform, status_item_id: StatusItemId) bool {
|
|
3200
|
+
const item = self.findStatusItemConst(status_item_id) orelse return false;
|
|
3201
|
+
return item.visible;
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3204
|
+
pub fn statusItemIconPath(self: *const NullPlatform, status_item_id: StatusItemId) []const u8 {
|
|
3205
|
+
const item = self.findStatusItemConst(status_item_id) orelse return "";
|
|
3206
|
+
return item.icon_path[0..item.icon_path_len];
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
pub fn statusItemTitle(self: *const NullPlatform, status_item_id: StatusItemId) []const u8 {
|
|
3210
|
+
const item = self.findStatusItemConst(status_item_id) orelse return "";
|
|
3211
|
+
return item.title[0..item.title_len];
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
pub fn statusItemTooltip(self: *const NullPlatform, status_item_id: StatusItemId) []const u8 {
|
|
3215
|
+
const item = self.findStatusItemConst(status_item_id) orelse return "";
|
|
3216
|
+
return item.tooltip[0..item.tooltip_len];
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
pub fn statusItemActivationCommand(self: *const NullPlatform, status_item_id: StatusItemId) []const u8 {
|
|
3220
|
+
const item = self.findStatusItemConst(status_item_id) orelse return "";
|
|
3221
|
+
return item.activation_command[0..item.activation_command_len];
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
pub fn statusItemMenu(self: *const NullPlatform, status_item_id: StatusItemId) []const TrayMenuItem {
|
|
3225
|
+
const item = self.findStatusItemConst(status_item_id) orelse return &.{};
|
|
3226
|
+
return item.items[0..item.item_count];
|
|
3048
3227
|
}
|
|
3049
3228
|
|
|
3050
3229
|
pub fn trayCreateCount(self: *const NullPlatform) usize {
|
|
@@ -3055,6 +3234,10 @@ pub const NullPlatform = struct {
|
|
|
3055
3234
|
return self.tray_update_count;
|
|
3056
3235
|
}
|
|
3057
3236
|
|
|
3237
|
+
pub fn trayShellUpdateCount(self: *const NullPlatform) usize {
|
|
3238
|
+
return self.tray_shell_update_count;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3058
3241
|
pub fn trayTitleUpdateCount(self: *const NullPlatform) usize {
|
|
3059
3242
|
return self.tray_title_update_count;
|
|
3060
3243
|
}
|
|
@@ -283,9 +283,12 @@ test "null platform records OS actions" {
|
|
|
283
283
|
const services = null_platform.platform().services;
|
|
284
284
|
|
|
285
285
|
try services.showNotification(.{
|
|
286
|
+
.id = "build-status",
|
|
286
287
|
.title = "Build finished",
|
|
287
288
|
.subtitle = "native-sdk",
|
|
288
289
|
.body = "All checks passed.",
|
|
290
|
+
.action_label = "Open",
|
|
291
|
+
.action_command = "build.open",
|
|
289
292
|
});
|
|
290
293
|
try services.openExternalUrl("https://example.com/docs");
|
|
291
294
|
try services.revealPath("/tmp/example.txt");
|
|
@@ -306,6 +309,11 @@ test "null platform records OS actions" {
|
|
|
306
309
|
try std.testing.expectEqualStrings("Build finished", null_platform.lastNotificationTitle());
|
|
307
310
|
try std.testing.expectEqualStrings("native-sdk", null_platform.lastNotificationSubtitle());
|
|
308
311
|
try std.testing.expectEqualStrings("All checks passed.", null_platform.lastNotificationBody());
|
|
312
|
+
try std.testing.expectEqualStrings("build-status", null_platform.lastNotificationId());
|
|
313
|
+
try std.testing.expectEqualStrings("Open", null_platform.lastNotificationActionLabel());
|
|
314
|
+
try std.testing.expectEqualStrings("build.open", null_platform.lastNotificationActionCommand());
|
|
315
|
+
const notification_event = null_platform.activateNotification("build-status") orelse return error.TestUnexpectedResult;
|
|
316
|
+
try std.testing.expectEqualStrings("build.open", notification_event.notification_command.name);
|
|
309
317
|
try std.testing.expectEqualStrings("https://example.com/docs", null_platform.lastExternalUrl());
|
|
310
318
|
try std.testing.expectEqualStrings("/tmp/example.txt", null_platform.lastRevealedPath());
|
|
311
319
|
try std.testing.expectEqualStrings("/tmp/recent.txt", null_platform.lastRecentDocumentPath());
|
|
@@ -366,6 +374,37 @@ test "null platform records OS actions" {
|
|
|
366
374
|
try std.testing.expectEqual(@as(usize, 0), null_platform.trayItems().len);
|
|
367
375
|
}
|
|
368
376
|
|
|
377
|
+
test "null platform notification ids replace their action binding" {
|
|
378
|
+
var null_platform = NullPlatform.init(.{});
|
|
379
|
+
defer null_platform.deinit();
|
|
380
|
+
const services = null_platform.platform().services;
|
|
381
|
+
|
|
382
|
+
try services.showNotification(.{
|
|
383
|
+
.id = "sync",
|
|
384
|
+
.title = "Syncing",
|
|
385
|
+
.action_label = "Cancel",
|
|
386
|
+
.action_command = "sync.cancel",
|
|
387
|
+
});
|
|
388
|
+
try services.showNotification(.{
|
|
389
|
+
.id = "other",
|
|
390
|
+
.title = "Other",
|
|
391
|
+
.action_label = "Open",
|
|
392
|
+
.action_command = "other.open",
|
|
393
|
+
});
|
|
394
|
+
try services.showNotification(.{
|
|
395
|
+
.id = "sync",
|
|
396
|
+
.title = "Synced",
|
|
397
|
+
.action_label = "View",
|
|
398
|
+
.action_command = "sync.view",
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
try std.testing.expectEqual(@as(usize, 3), null_platform.notificationCount());
|
|
402
|
+
try std.testing.expectEqual(@as(usize, 1), null_platform.notificationReplacementCount());
|
|
403
|
+
try std.testing.expectEqualStrings("sync.view", null_platform.activateNotification("sync").?.notification_command.name);
|
|
404
|
+
try std.testing.expectEqualStrings("other.open", null_platform.activateNotification("other").?.notification_command.name);
|
|
405
|
+
try std.testing.expect(null_platform.activateNotification("missing") == null);
|
|
406
|
+
}
|
|
407
|
+
|
|
369
408
|
test "null platform records configured shortcuts" {
|
|
370
409
|
const shortcuts = [_]Shortcut{
|
|
371
410
|
.{ .id = "command.palette", .key = "p", .modifiers = .{ .primary = true, .shift = true } },
|
package/src/platform/root.zig
CHANGED
|
@@ -26,12 +26,16 @@ pub const max_recent_document_path_bytes = types.max_recent_document_path_bytes;
|
|
|
26
26
|
pub const max_notification_title_bytes = types.max_notification_title_bytes;
|
|
27
27
|
pub const max_notification_subtitle_bytes = types.max_notification_subtitle_bytes;
|
|
28
28
|
pub const max_notification_body_bytes = types.max_notification_body_bytes;
|
|
29
|
+
pub const max_notification_id_bytes = types.max_notification_id_bytes;
|
|
30
|
+
pub const max_notification_action_label_bytes = types.max_notification_action_label_bytes;
|
|
31
|
+
pub const max_notification_action_command_bytes = types.max_notification_action_command_bytes;
|
|
29
32
|
pub const max_clipboard_mime_type_bytes = types.max_clipboard_mime_type_bytes;
|
|
30
33
|
pub const max_clipboard_data_bytes = types.max_clipboard_data_bytes;
|
|
31
34
|
pub const max_credential_service_bytes = types.max_credential_service_bytes;
|
|
32
35
|
pub const max_credential_account_bytes = types.max_credential_account_bytes;
|
|
33
36
|
pub const max_credential_secret_bytes = types.max_credential_secret_bytes;
|
|
34
37
|
pub const max_local_time_text_bytes = types.max_local_time_text_bytes;
|
|
38
|
+
pub const max_status_items = types.max_status_items;
|
|
35
39
|
pub const max_tray_items = types.max_tray_items;
|
|
36
40
|
pub const max_tray_icon_path_bytes = types.max_tray_icon_path_bytes;
|
|
37
41
|
pub const max_tray_title_bytes = types.max_tray_title_bytes;
|
|
@@ -124,11 +128,16 @@ pub const MessageDialogStyle = types.MessageDialogStyle;
|
|
|
124
128
|
pub const MessageDialogResult = types.MessageDialogResult;
|
|
125
129
|
pub const MessageDialogOptions = types.MessageDialogOptions;
|
|
126
130
|
pub const NotificationOptions = types.NotificationOptions;
|
|
131
|
+
pub const NotificationCommandEvent = types.NotificationCommandEvent;
|
|
127
132
|
pub const CredentialKey = types.CredentialKey;
|
|
128
133
|
pub const Credential = types.Credential;
|
|
129
134
|
pub const LocalTimeStyle = types.LocalTimeStyle;
|
|
135
|
+
pub const StatusItemId = types.StatusItemId;
|
|
136
|
+
pub const primary_status_item_id = types.primary_status_item_id;
|
|
130
137
|
pub const TrayItemId = types.TrayItemId;
|
|
131
138
|
pub const TrayOptions = types.TrayOptions;
|
|
139
|
+
pub const TrayShell = types.TrayShell;
|
|
140
|
+
pub const trayShell = types.trayShell;
|
|
132
141
|
pub const TrayTone = types.TrayTone;
|
|
133
142
|
pub const TrayPresentation = types.TrayPresentation;
|
|
134
143
|
pub const TrayMenuItem = types.TrayMenuItem;
|
|
@@ -136,6 +145,7 @@ pub const TrayItemRole = types.TrayItemRole;
|
|
|
136
145
|
pub const NativeCommandEvent = types.NativeCommandEvent;
|
|
137
146
|
pub const MenuCommandEvent = types.MenuCommandEvent;
|
|
138
147
|
pub const TrayCommandEvent = types.TrayCommandEvent;
|
|
148
|
+
pub const TrayActionEvent = types.TrayActionEvent;
|
|
139
149
|
pub const reserved_timer_id_base = types.reserved_timer_id_base;
|
|
140
150
|
pub const press_hold_timer_id = types.press_hold_timer_id;
|
|
141
151
|
pub const TimerEvent = types.TimerEvent;
|