@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.
Files changed (161) hide show
  1. package/build/app.zig +1178 -74
  2. package/build.zig +715 -17
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +10 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +435 -3
  7. package/packages/core/package-lock.json +11 -11
  8. package/packages/core/package.json +2 -2
  9. package/packages/core/scripts/compiler_typecheck.mjs +116 -15
  10. package/packages/core/scripts/gen_service_surface.mjs +268 -0
  11. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +64 -0
  13. package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
  14. package/packages/core/scripts/run_external_service_compiler.mjs +280 -0
  15. package/packages/core/scripts/stage_external_core.mjs +9 -1
  16. package/packages/core/scripts/stage_external_services.mjs +172 -0
  17. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  18. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  19. package/packages/core/sdk/core.d.ts +224 -0
  20. package/packages/core/sdk/core.ts +694 -22
  21. package/packages/core/sdk/events.d.ts +89 -0
  22. package/packages/core/sdk/events.ts +128 -0
  23. package/packages/core/src/checker.ts +936 -15
  24. package/packages/core/src/cli.ts +156 -3
  25. package/packages/core/src/contract.ts +28 -5
  26. package/packages/core/src/devhost.ts +1876 -16
  27. package/packages/core/src/devhost_journal.mjs +183 -0
  28. package/packages/core/src/devhost_resolver.mjs +17 -1
  29. package/packages/core/src/devhost_service_worker.mjs +90 -0
  30. package/packages/core/src/diagnostics.ts +179 -22
  31. package/packages/core/src/frontend.ts +210 -34
  32. package/packages/core/src/infer.ts +24 -0
  33. package/packages/core/src/modules.ts +129 -80
  34. package/packages/core/src/service_contract.ts +597 -0
  35. package/packages/core/src/sqlite_cli.ts +93 -0
  36. package/packages/core/src/sqlite_codegen.ts +806 -0
  37. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  38. package/packages/core/src/typed_ast.ts +36 -8
  39. package/skill-data/automation/SKILL.md +1 -1
  40. package/skill-data/core/references/project-anatomy.md +1 -1
  41. package/skill-data/native-ui/SKILL.md +58 -5
  42. package/skill-data/ts-core/SKILL.md +123 -41
  43. package/skill-data/ts-services/SKILL.md +126 -0
  44. package/skill-data/ts-services/references/service-surface.md +604 -0
  45. package/skill-data/zig/SKILL.md +1 -1
  46. package/skills/native-sdk/SKILL.md +1 -1
  47. package/src/app_runner/no_migrations.zig +3 -0
  48. package/src/app_runner/no_services.zig +20 -0
  49. package/src/app_runner/root.zig +133 -4
  50. package/src/app_runner/ts_core_main.zig +254 -8
  51. package/src/app_runner/ts_core_mobile.zig +241 -0
  52. package/src/automation/protocol.zig +5 -1
  53. package/src/automation/snapshot.zig +31 -11
  54. package/src/embed/app_exports.zig +12 -1
  55. package/src/embed/c_api.zig +48 -2
  56. package/src/embed/conversions.zig +4 -5
  57. package/src/embed/host.zig +109 -1
  58. package/src/embed/root.zig +8 -0
  59. package/src/embed/tests.zig +241 -0
  60. package/src/embed/types.zig +51 -0
  61. package/src/embed/ui_host.zig +185 -5
  62. package/src/platform/android/NativeSdkActivity.java +131 -0
  63. package/src/platform/android/android_host.c +182 -1
  64. package/src/platform/android/native_sdk_app.h +17 -0
  65. package/src/platform/ios/native_sdk_app.h +17 -0
  66. package/src/platform/ios/uikit_host.m +115 -0
  67. package/src/platform/linux/cef_host.cpp +8 -2
  68. package/src/platform/linux/gtk_host.c +289 -22
  69. package/src/platform/linux/gtk_host.h +5 -1
  70. package/src/platform/linux/root.zig +109 -22
  71. package/src/platform/macos/appkit_host.h +24 -7
  72. package/src/platform/macos/appkit_host.m +686 -64
  73. package/src/platform/macos/cef_host.mm +400 -66
  74. package/src/platform/macos/root.zig +304 -47
  75. package/src/platform/null_platform.zig +435 -48
  76. package/src/platform/null_platform_tests.zig +113 -0
  77. package/src/platform/root.zig +19 -0
  78. package/src/platform/types.zig +281 -28
  79. package/src/platform/windows/root.zig +207 -27
  80. package/src/platform/windows/webview2_host.cpp +334 -51
  81. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  82. package/src/primitives/app_manifest/root.zig +4 -0
  83. package/src/primitives/app_manifest/tests.zig +3 -0
  84. package/src/primitives/app_manifest/types.zig +32 -0
  85. package/src/primitives/app_manifest/validation.zig +19 -1
  86. package/src/root.zig +53 -0
  87. package/src/runtime/api.zig +19 -0
  88. package/src/runtime/automation_commands.zig +35 -2
  89. package/src/runtime/automation_snapshot.zig +32 -20
  90. package/src/runtime/bridge_permission_tests.zig +58 -3
  91. package/src/runtime/bridge_responses.zig +4 -2
  92. package/src/runtime/builtin_bridge.zig +11 -1
  93. package/src/runtime/canvas_frame.zig +18 -11
  94. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  95. package/src/runtime/clock.zig +13 -1
  96. package/src/runtime/core.zig +145 -7
  97. package/src/runtime/credentials_store.zig +115 -0
  98. package/src/runtime/effects.zig +3701 -231
  99. package/src/runtime/effects_credentials_tests.zig +332 -0
  100. package/src/runtime/effects_file_tests.zig +587 -0
  101. package/src/runtime/effects_host_tests.zig +208 -1
  102. package/src/runtime/effects_notification_tests.zig +11 -0
  103. package/src/runtime/effects_relational_tests.zig +314 -0
  104. package/src/runtime/effects_store_tests.zig +211 -0
  105. package/src/runtime/file_access.zig +400 -0
  106. package/src/runtime/file_effect_crash_helper.zig +28 -0
  107. package/src/runtime/file_effect_crash_tests.zig +37 -0
  108. package/src/runtime/flow.zig +35 -10
  109. package/src/runtime/gpu_surface_events.zig +6 -1
  110. package/src/runtime/native_command_event_tests.zig +86 -2
  111. package/src/runtime/persist_store.zig +666 -0
  112. package/src/runtime/pty.zig +5 -2
  113. package/src/runtime/record_store.zig +788 -0
  114. package/src/runtime/relational_store.zig +854 -0
  115. package/src/runtime/root.zig +54 -0
  116. package/src/runtime/runtime_event_tests.zig +70 -0
  117. package/src/runtime/service_host.zig +711 -0
  118. package/src/runtime/service_pool.zig +1314 -0
  119. package/src/runtime/session_blobs.zig +4 -1
  120. package/src/runtime/session_journal.zig +158 -5
  121. package/src/runtime/session_record.zig +215 -0
  122. package/src/runtime/session_replay.zig +206 -11
  123. package/src/runtime/session_tests.zig +81 -0
  124. package/src/runtime/shell_layout.zig +1 -0
  125. package/src/runtime/shell_layout_tests.zig +120 -0
  126. package/src/runtime/sqlite_engine.zig +474 -0
  127. package/src/runtime/state.zig +16 -0
  128. package/src/runtime/system_services.zig +170 -38
  129. package/src/runtime/tests.zig +4 -0
  130. package/src/runtime/ts_core_host.zig +1067 -95
  131. package/src/runtime/ts_core_host_tests.zig +325 -11
  132. package/src/runtime/ts_ui_app.zig +953 -2
  133. package/src/runtime/ui_app.zig +434 -96
  134. package/src/runtime/ui_app_tests.zig +287 -11
  135. package/src/runtime/ui_app_window_tests.zig +61 -7
  136. package/src/runtime/validation.zig +42 -0
  137. package/src/runtime/view.zig +9 -0
  138. package/src/runtime/window_storage.zig +1 -0
  139. package/src/runtime/window_view_runtime.zig +2 -3
  140. package/src/runtime/window_views.zig +19 -0
  141. package/src/tooling/android.zig +21 -16
  142. package/src/tooling/db.zig +160 -0
  143. package/src/tooling/ios.zig +7 -1
  144. package/src/tooling/manifest.zig +214 -2
  145. package/src/tooling/package.zig +116 -0
  146. package/src/tooling/raw_manifest.zig +30 -0
  147. package/src/tooling/root.zig +1 -0
  148. package/src/tooling/templates.zig +189 -4
  149. package/src/tooling/ts_core.zig +366 -17
  150. package/src/tooling/verbs.zig +7 -0
  151. package/third_party/sqlite/README.md +13 -0
  152. package/third_party/sqlite/sqlite3.c +269649 -0
  153. package/third_party/sqlite/sqlite3.h +14349 -0
  154. package/tools/corewire/core_abi.zig +14 -2
  155. package/tools/corewire/emit.zig +98 -29
  156. package/tools/corewire/emit_facade.zig +442 -27
  157. package/tools/corewire/emit_profile.zig +6 -2
  158. package/tools/corewire/emit_service.zig +924 -0
  159. package/tools/corewire/main.zig +122 -0
  160. package/tools/corewire/service_contract.zig +250 -0
  161. package/tools/corewire/sidecar.zig +26 -15
@@ -29,11 +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;
40
+ const max_local_time_text_bytes = types.max_local_time_text_bytes;
41
+ const max_status_items = types.max_status_items;
37
42
  const max_tray_items = types.max_tray_items;
38
43
  const max_tray_icon_path_bytes = types.max_tray_icon_path_bytes;
39
44
  const max_tray_title_bytes = types.max_tray_title_bytes;
@@ -110,11 +115,17 @@ const MessageDialogOptions = types.MessageDialogOptions;
110
115
  const NotificationOptions = types.NotificationOptions;
111
116
  const CredentialKey = types.CredentialKey;
112
117
  const Credential = types.Credential;
118
+ const LocalTimeStyle = types.LocalTimeStyle;
119
+ const StatusItemId = types.StatusItemId;
120
+ const TrayShell = types.TrayShell;
113
121
  const TrayItemId = types.TrayItemId;
114
122
  const TrayOptions = types.TrayOptions;
123
+ const TrayPresentation = types.TrayPresentation;
115
124
  const TrayMenuItem = types.TrayMenuItem;
116
125
  const NativeCommandEvent = types.NativeCommandEvent;
117
126
  const MenuCommandEvent = types.MenuCommandEvent;
127
+ const TrayCommandEvent = types.TrayCommandEvent;
128
+ const Event = types.Event;
118
129
  const TimerEvent = types.TimerEvent;
119
130
  const FileDropEvent = types.FileDropEvent;
120
131
  const GpuFrame = types.GpuFrame;
@@ -141,7 +152,6 @@ const WidgetAccessibilityActionEvent = types.WidgetAccessibilityActionEvent;
141
152
  const ClipboardData = types.ClipboardData;
142
153
  const ColorScheme = types.ColorScheme;
143
154
  const Appearance = types.Appearance;
144
- const Event = types.Event;
145
155
  const splitDropPaths = types.splitDropPaths;
146
156
  const EventHandler = types.EventHandler;
147
157
  const PlatformServices = types.PlatformServices;
@@ -290,6 +300,37 @@ pub const NullAudioCapture = struct {
290
300
  stop_count: usize = 0,
291
301
  };
292
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
+
293
334
  pub const NullPlatform = struct {
294
335
  surface_value: Surface = .{},
295
336
  web_engine: WebEngine = .system,
@@ -340,11 +381,13 @@ pub const NullPlatform = struct {
340
381
  window_always_on_top: [max_windows]bool = [_]bool{false} ** max_windows,
341
382
  window_click_through: [max_windows]bool = [_]bool{false} ** max_windows,
342
383
  window_activate_on_show: [max_windows]bool = [_]bool{true} ** max_windows,
384
+ window_allows_fullscreen: [max_windows]bool = [_]bool{true} ** max_windows,
343
385
  /// Minimize calls per window (`minimize_window_fn`), indexed like
344
386
  /// `windows`: the observable seam for app-drawn minimize controls —
345
387
  /// the null platform has no Dock to genie into, so the count IS the
346
388
  /// behavior tests pin.
347
389
  window_minimize_count: [max_windows]u32 = [_]u32{0} ** max_windows,
390
+ window_hide_count: [max_windows]u32 = [_]u32{0} ** max_windows,
348
391
  /// Show calls per window (`show_window_fn`), indexed like `windows`
349
392
  /// — the counterpart seam (tray "Open", the un-hide verb).
350
393
  window_show_count: [max_windows]u32 = [_]u32{0} ** max_windows,
@@ -391,6 +434,11 @@ pub const NullPlatform = struct {
391
434
  /// runtime's `showWindow` rollback test uses to assert a refused
392
435
  /// show restores hidden and moves no focus.
393
436
  fail_next_show_window: bool = false,
437
+ fail_next_hide_window: bool = false,
438
+ dock_visible: bool = true,
439
+ dock_presence_count: u32 = 0,
440
+ launch_at_login_status: types.LaunchAtLoginStatus = .disabled,
441
+ launch_at_login_set_count: u32 = 0,
394
442
  /// Captured `WindowOptions.min_width`/`min_height` per created
395
443
  /// window — the content min-size floor that must survive to the
396
444
  /// create seam (macOS applies it as `contentMinSize`); same
@@ -453,7 +501,15 @@ pub const NullPlatform = struct {
453
501
  notification_subtitle_len: usize = 0,
454
502
  notification_body: [max_notification_body_bytes]u8 = undefined,
455
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,
456
511
  notification_count: usize = 0,
512
+ notification_replacement_count: usize = 0,
457
513
  clipboard_mime_type: [max_clipboard_mime_type_bytes]u8 = undefined,
458
514
  clipboard_mime_type_len: usize = 0,
459
515
  clipboard_data: [max_clipboard_data_bytes]u8 = undefined,
@@ -463,20 +519,23 @@ pub const NullPlatform = struct {
463
519
  credential_service_len: usize = 0,
464
520
  credential_account: [max_credential_account_bytes]u8 = undefined,
465
521
  credential_account_len: usize = 0,
466
- credential_secret: [max_credential_secret_bytes]u8 = undefined,
467
- credential_secret_len: usize = 0,
522
+ /// Hermetic process-local keychain. Real credential effects use four
523
+ /// worker threads, so the fake must be synchronized too; one old
524
+ /// bridge-era "last secret" buffer silently lost distinct keys.
525
+ credential_mutex: std.atomic.Mutex = .unlocked,
526
+ credential_entries: std.StringHashMapUnmanaged([]u8) = .empty,
527
+ credential_last_secret: ?[]const u8 = null,
468
528
  credential_set_count: usize = 0,
469
529
  credential_delete_count: usize = 0,
530
+ /// Deterministic local-zone model for tests. Real hosts consult the OS
531
+ /// zone (including DST at the requested instant); the null host uses this
532
+ /// fixed offset so suites can pin exact output without ambient state.
533
+ local_time_offset_minutes: i16 = 0,
470
534
  webview_navigate_count: usize = 0,
471
- tray_icon_path: [max_tray_icon_path_bytes]u8 = undefined,
472
- tray_icon_path_len: usize = 0,
473
- tray_title: [max_tray_title_bytes]u8 = undefined,
474
- tray_title_len: usize = 0,
475
- tray_tooltip: [max_tray_tooltip_bytes]u8 = undefined,
476
- tray_tooltip_len: usize = 0,
477
- tray_items: [max_tray_items]TrayMenuItem = undefined,
478
- tray_item_count: usize = 0,
535
+ status_items: [max_status_items]NullStatusItem = [_]NullStatusItem{.{}} ** max_status_items,
536
+ status_item_count: usize = 0,
479
537
  tray_create_count: usize = 0,
538
+ tray_shell_update_count: usize = 0,
480
539
  tray_update_count: usize = 0,
481
540
  tray_title_update_count: usize = 0,
482
541
  tray_remove_count: usize = 0,
@@ -671,9 +730,8 @@ pub const NullPlatform = struct {
671
730
  /// embed host drain it on their own thread via `takeWake` and then
672
731
  /// dispatch the `.wake` platform event themselves.
673
732
  wake_count: std.atomic.Value(usize) = std.atomic.Value(usize).init(0),
674
- /// Latched when the runtime's effects teardown abandons an in-flight
675
- /// channel `wake_fn` call (see
676
- /// `PlatformServices.note_channel_wake_abandoned_fn`): the stale call
733
+ /// Latched when effects teardown abandons an in-flight platform call
734
+ /// (a channel wake or blocking credential operation): the stale call
677
735
  /// still holds this platform as its context, so `deinit` must skip
678
736
  /// destruction and leak the host, process-lived — the reference model
679
737
  /// of the real hosts' destroy gate, and the seam channel teardown
@@ -788,9 +846,21 @@ pub const NullPlatform = struct {
788
846
  /// which is exactly what makes the gate observable in tests.
789
847
  pub fn deinit(self: *NullPlatform) void {
790
848
  if (self.channel_wake_abandoned.load(.seq_cst)) {
791
- std.debug.print("null platform teardown: an abandoned channel wake call may still enter this host; skipping destruction and leaking it, process-lived, so the stale call stays safe\n", .{});
849
+ std.debug.print("null platform teardown: an abandoned platform call may still enter this host; skipping destruction and leaking it, process-lived, so the stale call stays safe\n", .{});
792
850
  return;
793
851
  }
852
+ if (self.destroyed) return;
853
+ self.lockCredentials();
854
+ var credentials = self.credential_entries.iterator();
855
+ while (credentials.next()) |entry| {
856
+ @memset(entry.value_ptr.*, 0);
857
+ std.heap.page_allocator.free(entry.value_ptr.*);
858
+ std.heap.page_allocator.free(entry.key_ptr.*);
859
+ }
860
+ self.credential_entries.deinit(std.heap.page_allocator);
861
+ self.credential_entries = .empty;
862
+ self.credential_last_secret = null;
863
+ self.credential_mutex.unlock();
794
864
  self.destroyed = true;
795
865
  }
796
866
 
@@ -816,7 +886,11 @@ pub const NullPlatform = struct {
816
886
  .focus_window_fn = focusWindow,
817
887
  .close_window_fn = closeWindow,
818
888
  .minimize_window_fn = minimizeWindow,
889
+ .hide_window_fn = hideWindow,
819
890
  .show_window_fn = showWindow,
891
+ .set_dock_presence_fn = setDockPresence,
892
+ .launch_at_login_status_fn = launchAtLoginStatus,
893
+ .set_launch_at_login_fn = setLaunchAtLogin,
820
894
  .quit_app_fn = quitApp,
821
895
  .start_window_drag_fn = startWindowDrag,
822
896
  .window_chrome_fn = windowChrome,
@@ -841,9 +915,13 @@ pub const NullPlatform = struct {
841
915
  .set_credential_fn = setCredential,
842
916
  .get_credential_fn = getCredential,
843
917
  .delete_credential_fn = deleteCredential,
918
+ .note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
919
+ .format_local_time_fn = formatLocalTime,
844
920
  .create_tray_fn = createTray,
921
+ .update_tray_shell_fn = updateTrayShell,
845
922
  .update_tray_menu_fn = updateTrayMenu,
846
923
  .update_tray_title_fn = updateTrayTitle,
924
+ .update_tray_presentation_fn = updateTrayPresentation,
847
925
  .remove_tray_fn = removeTray,
848
926
  .open_external_url_fn = openExternalUrl,
849
927
  .reveal_path_fn = revealPath,
@@ -957,6 +1035,7 @@ pub const NullPlatform = struct {
957
1035
  .scale_factor = self.surface_value.scale_factor,
958
1036
  .open = true,
959
1037
  .focused = index == 0 and window.activate_on_show and window.show == .immediate,
1038
+ .hidden = window.show == .hidden,
960
1039
  } });
961
1040
  }
962
1041
  var frame: u32 = 0;
@@ -1068,6 +1147,7 @@ pub const NullPlatform = struct {
1068
1147
  .scale_factor = self.surface_value.scale_factor,
1069
1148
  .open = true,
1070
1149
  .focused = focused,
1150
+ .hidden = options.show == .hidden,
1071
1151
  };
1072
1152
  self.windows[self.window_count] = info;
1073
1153
  self.window_resizable[self.window_count] = options.resizable;
@@ -1076,6 +1156,7 @@ pub const NullPlatform = struct {
1076
1156
  self.window_always_on_top[self.window_count] = options.always_on_top;
1077
1157
  self.window_click_through[self.window_count] = options.click_through;
1078
1158
  self.window_activate_on_show[self.window_count] = options.activate_on_show;
1159
+ self.window_allows_fullscreen[self.window_count] = options.allows_fullscreen;
1079
1160
  self.window_show[self.window_count] = options.show;
1080
1161
  self.window_close_policy[self.window_count] = options.close_policy;
1081
1162
  self.window_min_width[self.window_count] = options.min_width;
@@ -1104,7 +1185,10 @@ pub const NullPlatform = struct {
1104
1185
  self.show_op_seq += 1;
1105
1186
  self.window_first_present_seq[index] = self.show_op_seq;
1106
1187
  }
1107
- if (!self.window_visible[index] and self.window_show[index] == .on_first_present) {
1188
+ if (!self.windows[index].hidden and
1189
+ !self.window_visible[index] and
1190
+ self.window_show[index] == .on_first_present)
1191
+ {
1108
1192
  self.window_visible[index] = true;
1109
1193
  self.show_op_seq += 1;
1110
1194
  self.window_shown_seq[index] = self.show_op_seq;
@@ -1151,6 +1235,7 @@ pub const NullPlatform = struct {
1151
1235
  }
1152
1236
  // An explicit focus shows a still-deferred window (the macOS
1153
1237
  // host's makeKeyAndOrderFront override of present-before-show).
1238
+ self.windows[focused_index].hidden = false;
1154
1239
  if (!self.window_visible[focused_index]) {
1155
1240
  self.window_visible[focused_index] = true;
1156
1241
  self.show_op_seq += 1;
@@ -1220,6 +1305,37 @@ pub const NullPlatform = struct {
1220
1305
  self.window_show_count[index] += 1;
1221
1306
  }
1222
1307
 
1308
+ fn hideWindow(context: ?*anyopaque, window_id: WindowId) anyerror!void {
1309
+ const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1310
+ if (self.fail_next_hide_window) {
1311
+ self.fail_next_hide_window = false;
1312
+ return error.HideFailed;
1313
+ }
1314
+ const index = self.findWindowIndex(window_id) orelse return error.WindowNotFound;
1315
+ self.windows[index].hidden = true;
1316
+ self.windows[index].focused = false;
1317
+ self.window_visible[index] = false;
1318
+ self.window_hide_count[index] += 1;
1319
+ }
1320
+
1321
+ fn setDockPresence(context: ?*anyopaque, visible: bool) anyerror!void {
1322
+ const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1323
+ self.dock_visible = visible;
1324
+ self.dock_presence_count += 1;
1325
+ }
1326
+
1327
+ fn launchAtLoginStatus(context: ?*anyopaque) anyerror!types.LaunchAtLoginStatus {
1328
+ const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1329
+ return self.launch_at_login_status;
1330
+ }
1331
+
1332
+ fn setLaunchAtLogin(context: ?*anyopaque, enabled: bool) anyerror!types.LaunchAtLoginStatus {
1333
+ const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1334
+ self.launch_at_login_set_count += 1;
1335
+ self.launch_at_login_status = if (enabled) .enabled else .disabled;
1336
+ return self.launch_at_login_status;
1337
+ }
1338
+
1223
1339
  fn quitApp(context: ?*anyopaque) anyerror!void {
1224
1340
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1225
1341
  self.quit_request_count += 1;
@@ -1459,68 +1575,235 @@ pub const NullPlatform = struct {
1459
1575
  self.notification_title = undefined;
1460
1576
  self.notification_subtitle = undefined;
1461
1577
  self.notification_body = undefined;
1578
+ self.notification_id = undefined;
1579
+ self.notification_action_label = undefined;
1580
+ self.notification_action_command = undefined;
1462
1581
  self.notification_title_len = (try copyInto(&self.notification_title, options.title)).len;
1463
1582
  self.notification_subtitle_len = (try copyInto(&self.notification_subtitle, options.subtitle)).len;
1464
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
+ }
1465
1608
  self.notification_count += 1;
1466
1609
  }
1467
1610
 
1611
+ const max_credential_identity_bytes = max_credential_service_bytes + 1 + max_credential_account_bytes;
1612
+
1613
+ fn lockCredentials(self: *NullPlatform) void {
1614
+ while (!self.credential_mutex.tryLock()) std.atomic.spinLoopHint();
1615
+ }
1616
+
1617
+ fn credentialIdentity(buffer: *[max_credential_identity_bytes]u8, key: CredentialKey) anyerror![]const u8 {
1618
+ if (key.service.len == 0 or key.service.len > max_credential_service_bytes or
1619
+ key.account.len == 0 or key.account.len > max_credential_account_bytes)
1620
+ {
1621
+ return error.CredentialFieldTooLarge;
1622
+ }
1623
+ @memcpy(buffer[0..key.service.len], key.service);
1624
+ buffer[key.service.len] = 0;
1625
+ @memcpy(buffer[key.service.len + 1 ..][0..key.account.len], key.account);
1626
+ return buffer[0 .. key.service.len + 1 + key.account.len];
1627
+ }
1628
+
1468
1629
  fn setCredential(context: ?*anyopaque, credential: Credential) anyerror!void {
1469
1630
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1631
+ if (credential.secret.len > max_credential_secret_bytes) return error.CredentialFieldTooLarge;
1632
+ var identity_storage: [max_credential_identity_bytes]u8 = undefined;
1633
+ const identity = try credentialIdentity(&identity_storage, .{
1634
+ .service = credential.service,
1635
+ .account = credential.account,
1636
+ });
1637
+
1638
+ self.lockCredentials();
1639
+ defer self.credential_mutex.unlock();
1640
+ const secret = try std.heap.page_allocator.dupe(u8, credential.secret);
1641
+ errdefer std.heap.page_allocator.free(secret);
1642
+ if (self.credential_entries.getPtr(identity)) |existing| {
1643
+ @memset(existing.*, 0);
1644
+ std.heap.page_allocator.free(existing.*);
1645
+ existing.* = secret;
1646
+ } else {
1647
+ const owned_identity = try std.heap.page_allocator.dupe(u8, identity);
1648
+ errdefer std.heap.page_allocator.free(owned_identity);
1649
+ try self.credential_entries.put(std.heap.page_allocator, owned_identity, secret);
1650
+ }
1651
+
1470
1652
  self.credential_service = undefined;
1471
1653
  self.credential_account = undefined;
1472
- self.credential_secret = undefined;
1473
- self.credential_service_len = (try copyInto(&self.credential_service, credential.service)).len;
1474
- self.credential_account_len = (try copyInto(&self.credential_account, credential.account)).len;
1475
- self.credential_secret_len = (try copyInto(&self.credential_secret, credential.secret)).len;
1654
+ @memcpy(self.credential_service[0..credential.service.len], credential.service);
1655
+ @memcpy(self.credential_account[0..credential.account.len], credential.account);
1656
+ self.credential_service_len = credential.service.len;
1657
+ self.credential_account_len = credential.account.len;
1658
+ self.credential_last_secret = secret;
1476
1659
  self.credential_set_count += 1;
1477
1660
  }
1478
1661
 
1479
1662
  fn getCredential(context: ?*anyopaque, key: CredentialKey, buffer: []u8) anyerror![]const u8 {
1480
1663
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1481
- if (self.credential_secret_len == 0) return error.CredentialNotFound;
1482
- if (!std.mem.eql(u8, key.service, self.lastCredentialService()) or !std.mem.eql(u8, key.account, self.lastCredentialAccount())) return error.CredentialNotFound;
1483
- return try copyInto(buffer, self.lastCredentialSecret());
1664
+ var identity_storage: [max_credential_identity_bytes]u8 = undefined;
1665
+ const identity = try credentialIdentity(&identity_storage, key);
1666
+ self.lockCredentials();
1667
+ defer self.credential_mutex.unlock();
1668
+ const secret = self.credential_entries.get(identity) orelse return error.CredentialNotFound;
1669
+ return try copyInto(buffer, secret);
1484
1670
  }
1485
1671
 
1486
1672
  fn deleteCredential(context: ?*anyopaque, key: CredentialKey) anyerror!void {
1487
1673
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1488
- if (self.credential_secret_len == 0) return error.CredentialNotFound;
1489
- if (!std.mem.eql(u8, key.service, self.lastCredentialService()) or !std.mem.eql(u8, key.account, self.lastCredentialAccount())) return error.CredentialNotFound;
1490
- self.credential_secret_len = 0;
1674
+ var identity_storage: [max_credential_identity_bytes]u8 = undefined;
1675
+ const identity = try credentialIdentity(&identity_storage, key);
1676
+ self.lockCredentials();
1677
+ defer self.credential_mutex.unlock();
1678
+ const removed = self.credential_entries.fetchRemove(identity) orelse return error.CredentialNotFound;
1679
+ if (self.credential_last_secret) |last| {
1680
+ if (last.ptr == removed.value.ptr) self.credential_last_secret = null;
1681
+ }
1682
+ @memset(removed.value, 0);
1683
+ std.heap.page_allocator.free(removed.value);
1684
+ std.heap.page_allocator.free(removed.key);
1491
1685
  self.credential_delete_count += 1;
1492
1686
  }
1493
1687
 
1494
- fn createTray(context: ?*anyopaque, options: TrayOptions) anyerror!void {
1688
+ fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
1689
+ const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1690
+ const seconds = @divFloor(timestamp_ms, 1000) + @as(i64, self.local_time_offset_minutes) * 60;
1691
+ const days = @divFloor(seconds, 86_400);
1692
+ const second_of_day: u32 = @intCast(@mod(seconds, 86_400));
1693
+ const parts = localCivilFromDays(days) orelse return error.InvalidTimestamp;
1694
+ const hour = second_of_day / 3600;
1695
+ const minute = (second_of_day % 3600) / 60;
1696
+ const second = second_of_day % 60;
1697
+ return switch (style) {
1698
+ .date => try std.fmt.bufPrint(buffer, "{d:0>4}-{d:0>2}-{d:0>2}", .{ parts.year, parts.month, parts.day }),
1699
+ .time => try std.fmt.bufPrint(buffer, "{d:0>2}:{d:0>2}:{d:0>2}", .{ hour, minute, second }),
1700
+ .datetime => try std.fmt.bufPrint(buffer, "{d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2}", .{ parts.year, parts.month, parts.day, hour, minute, second }),
1701
+ };
1702
+ }
1703
+
1704
+ const LocalCivilDate = struct { year: u32, month: u32, day: u32 };
1705
+
1706
+ fn localCivilFromDays(days: i64) ?LocalCivilDate {
1707
+ const shifted = days + 719_468;
1708
+ const era = @divFloor(shifted, 146_097);
1709
+ const day_of_era: u32 = @intCast(shifted - era * 146_097);
1710
+ const year_of_era = (day_of_era - day_of_era / 1460 + day_of_era / 36_524 - day_of_era / 146_096) / 365;
1711
+ const year = @as(i64, year_of_era) + era * 400;
1712
+ const day_of_year = day_of_era - (365 * year_of_era + year_of_era / 4 - year_of_era / 100);
1713
+ const month_index = (5 * day_of_year + 2) / 153;
1714
+ const day = day_of_year - (153 * month_index + 2) / 5 + 1;
1715
+ const month = if (month_index < 10) month_index + 3 else month_index - 9;
1716
+ const civil_year = if (month <= 2) year + 1 else year;
1717
+ if (civil_year < 1 or civil_year > 9999) return null;
1718
+ return .{ .year = @intCast(civil_year), .month = month, .day = day };
1719
+ }
1720
+
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 {
1495
1757
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1496
- self.tray_icon_path = undefined;
1497
- self.tray_title = undefined;
1498
- self.tray_tooltip = undefined;
1499
- self.tray_icon_path_len = (try copyInto(&self.tray_icon_path, options.icon_path)).len;
1500
- self.tray_title_len = (try copyInto(&self.tray_title, options.title)).len;
1501
- self.tray_tooltip_len = (try copyInto(&self.tray_tooltip, options.tooltip)).len;
1502
- try updateTrayMenu(context, options.items);
1758
+ const item = try self.statusItemSlot(status_item_id);
1759
+ try copyTrayShell(item, types.trayShell(options));
1760
+ var presentation = options.presentation;
1761
+ if (presentation.title.len == 0) presentation.title = options.title;
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);
1503
1766
  self.tray_create_count += 1;
1504
1767
  }
1505
1768
 
1506
- fn updateTrayMenu(context: ?*anyopaque, items: []const TrayMenuItem) anyerror!void {
1769
+ fn updateTrayShell(context: ?*anyopaque, status_item_id: StatusItemId, shell: TrayShell) anyerror!void {
1507
1770
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1508
- if (items.len > self.tray_items.len) return error.InvalidTrayOptions;
1509
- for (items, 0..) |item, index| self.tray_items[index] = item;
1510
- self.tray_item_count = items.len;
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;
1511
1782
  self.tray_update_count += 1;
1512
1783
  }
1513
1784
 
1514
- fn updateTrayTitle(context: ?*anyopaque, title: []const u8) anyerror!void {
1785
+ fn updateTrayTitle(context: ?*anyopaque, status_item_id: StatusItemId, title: []const u8) anyerror!void {
1515
1786
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1516
- self.tray_title = undefined;
1517
- self.tray_title_len = (try copyInto(&self.tray_title, title)).len;
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];
1518
1790
  self.tray_title_update_count += 1;
1519
1791
  }
1520
1792
 
1521
- fn removeTray(context: ?*anyopaque) anyerror!void {
1793
+ fn updateTrayPresentation(context: ?*anyopaque, status_item_id: StatusItemId, presentation: TrayPresentation) anyerror!void {
1522
1794
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1523
- self.tray_item_count = 0;
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];
1799
+ }
1800
+
1801
+ fn removeTray(context: ?*anyopaque, status_item_id: StatusItemId) anyerror!void {
1802
+ const self: *NullPlatform = @ptrCast(@alignCast(context.?));
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;
1524
1807
  self.tray_remove_count += 1;
1525
1808
  }
1526
1809
 
@@ -2632,6 +2915,11 @@ pub const NullPlatform = struct {
2632
2915
  return self.window_minimize_count[index];
2633
2916
  }
2634
2917
 
2918
+ pub fn hideCountForWindow(self: *const NullPlatform, window_id: WindowId) u32 {
2919
+ const index = self.findWindowIndex(window_id) orelse return 0;
2920
+ return self.window_hide_count[index];
2921
+ }
2922
+
2635
2923
  /// Test seam: show calls observed for a window (the un-hide verb's
2636
2924
  /// pinned observable, like `minimizeCountForWindow`).
2637
2925
  pub fn showCountForWindow(self: *const NullPlatform, window_id: WindowId) u32 {
@@ -2673,6 +2961,7 @@ pub const NullPlatform = struct {
2673
2961
  self.window_always_on_top[cursor] = self.window_always_on_top[cursor + 1];
2674
2962
  self.window_click_through[cursor] = self.window_click_through[cursor + 1];
2675
2963
  self.window_activate_on_show[cursor] = self.window_activate_on_show[cursor + 1];
2964
+ self.window_allows_fullscreen[cursor] = self.window_allows_fullscreen[cursor + 1];
2676
2965
  self.window_show[cursor] = self.window_show[cursor + 1];
2677
2966
  self.window_visible[cursor] = self.window_visible[cursor + 1];
2678
2967
  self.window_first_present_seq[cursor] = self.window_first_present_seq[cursor + 1];
@@ -2680,6 +2969,7 @@ pub const NullPlatform = struct {
2680
2969
  self.window_min_width[cursor] = self.window_min_width[cursor + 1];
2681
2970
  self.window_min_height[cursor] = self.window_min_height[cursor + 1];
2682
2971
  self.window_minimize_count[cursor] = self.window_minimize_count[cursor + 1];
2972
+ self.window_hide_count[cursor] = self.window_hide_count[cursor + 1];
2683
2973
  self.window_show_count[cursor] = self.window_show_count[cursor + 1];
2684
2974
  self.window_occluded[cursor] = self.window_occluded[cursor + 1];
2685
2975
  self.window_close_policy[cursor] = self.window_close_policy[cursor + 1];
@@ -2791,10 +3081,45 @@ pub const NullPlatform = struct {
2791
3081
  return self.notification_body[0..self.notification_body_len];
2792
3082
  }
2793
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
+
2794
3115
  pub fn notificationCount(self: *const NullPlatform) usize {
2795
3116
  return self.notification_count;
2796
3117
  }
2797
3118
 
3119
+ pub fn notificationReplacementCount(self: *const NullPlatform) usize {
3120
+ return self.notification_replacement_count;
3121
+ }
3122
+
2798
3123
  pub fn lastClipboardMimeType(self: *const NullPlatform) []const u8 {
2799
3124
  return self.clipboard_mime_type[0..self.clipboard_mime_type_len];
2800
3125
  }
@@ -2816,7 +3141,7 @@ pub const NullPlatform = struct {
2816
3141
  }
2817
3142
 
2818
3143
  pub fn lastCredentialSecret(self: *const NullPlatform) []const u8 {
2819
- return self.credential_secret[0..self.credential_secret_len];
3144
+ return self.credential_last_secret orelse "";
2820
3145
  }
2821
3146
 
2822
3147
  pub fn credentialSetCount(self: *const NullPlatform) usize {
@@ -2828,19 +3153,77 @@ pub const NullPlatform = struct {
2828
3153
  }
2829
3154
 
2830
3155
  pub fn lastTrayIconPath(self: *const NullPlatform) []const u8 {
2831
- return self.tray_icon_path[0..self.tray_icon_path_len];
3156
+ return self.statusItemIconPath(types.primary_status_item_id);
2832
3157
  }
2833
3158
 
2834
3159
  pub fn lastTrayTitle(self: *const NullPlatform) []const u8 {
2835
- return self.tray_title[0..self.tray_title_len];
3160
+ return self.statusItemTitle(types.primary_status_item_id);
2836
3161
  }
2837
3162
 
2838
3163
  pub fn lastTrayTooltip(self: *const NullPlatform) []const u8 {
2839
- return self.tray_tooltip[0..self.tray_tooltip_len];
3164
+ return self.statusItemTooltip(types.primary_status_item_id);
3165
+ }
3166
+
3167
+ pub fn lastTrayActivationCommand(self: *const NullPlatform) []const u8 {
3168
+ const item = self.findStatusItemConst(types.primary_status_item_id) orelse return "";
3169
+ return item.activation_command[0..item.activation_command_len];
3170
+ }
3171
+
3172
+ pub fn lastTrayAlternateActivationCommand(self: *const NullPlatform) []const u8 {
3173
+ const item = self.findStatusItemConst(types.primary_status_item_id) orelse return "";
3174
+ return item.alternate_activation_command[0..item.alternate_activation_command_len];
3175
+ }
3176
+
3177
+ pub fn lastTrayOpenCommand(self: *const NullPlatform) []const u8 {
3178
+ const item = self.findStatusItemConst(types.primary_status_item_id) orelse return "";
3179
+ return item.open_command[0..item.open_command_len];
3180
+ }
3181
+
3182
+ pub fn lastTrayPresentation(self: *const NullPlatform) TrayPresentation {
3183
+ const item = self.findStatusItemConst(types.primary_status_item_id) orelse return .{};
3184
+ return item.presentation;
2840
3185
  }
2841
3186
 
2842
3187
  pub fn trayItems(self: *const NullPlatform) []const TrayMenuItem {
2843
- return self.tray_items[0..self.tray_item_count];
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];
2844
3227
  }
2845
3228
 
2846
3229
  pub fn trayCreateCount(self: *const NullPlatform) usize {
@@ -2851,6 +3234,10 @@ pub const NullPlatform = struct {
2851
3234
  return self.tray_update_count;
2852
3235
  }
2853
3236
 
3237
+ pub fn trayShellUpdateCount(self: *const NullPlatform) usize {
3238
+ return self.tray_shell_update_count;
3239
+ }
3240
+
2854
3241
  pub fn trayTitleUpdateCount(self: *const NullPlatform) usize {
2855
3242
  return self.tray_title_update_count;
2856
3243
  }