@native-sdk/cli 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/build/app.zig +859 -62
  2. package/build.zig +543 -13
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +2 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +365 -2
  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/npm_static_spike.mjs +64 -0
  12. package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
  13. package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
  14. package/packages/core/scripts/stage_external_core.mjs +9 -1
  15. package/packages/core/scripts/stage_external_services.mjs +172 -0
  16. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  17. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  18. package/packages/core/sdk/core.d.ts +149 -0
  19. package/packages/core/sdk/core.ts +529 -12
  20. package/packages/core/sdk/events.d.ts +36 -0
  21. package/packages/core/sdk/events.ts +57 -0
  22. package/packages/core/src/checker.ts +468 -15
  23. package/packages/core/src/cli.ts +143 -3
  24. package/packages/core/src/contract.ts +26 -5
  25. package/packages/core/src/devhost.ts +1847 -16
  26. package/packages/core/src/devhost_journal.mjs +181 -0
  27. package/packages/core/src/devhost_resolver.mjs +17 -1
  28. package/packages/core/src/devhost_service_worker.mjs +90 -0
  29. package/packages/core/src/diagnostics.ts +82 -16
  30. package/packages/core/src/frontend.ts +204 -34
  31. package/packages/core/src/modules.ts +129 -80
  32. package/packages/core/src/service_contract.ts +597 -0
  33. package/packages/core/src/sqlite_cli.ts +93 -0
  34. package/packages/core/src/sqlite_codegen.ts +806 -0
  35. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  36. package/packages/core/src/typed_ast.ts +36 -8
  37. package/skill-data/core/references/project-anatomy.md +1 -1
  38. package/skill-data/native-ui/SKILL.md +47 -0
  39. package/skill-data/ts-core/SKILL.md +80 -31
  40. package/skill-data/ts-services/SKILL.md +126 -0
  41. package/skill-data/ts-services/references/service-surface.md +603 -0
  42. package/skill-data/zig/SKILL.md +1 -1
  43. package/skills/native-sdk/SKILL.md +1 -1
  44. package/src/app_runner/no_migrations.zig +3 -0
  45. package/src/app_runner/no_services.zig +20 -0
  46. package/src/app_runner/root.zig +104 -4
  47. package/src/app_runner/ts_core_main.zig +249 -8
  48. package/src/automation/snapshot.zig +23 -5
  49. package/src/embed/app_exports.zig +11 -1
  50. package/src/embed/c_api.zig +48 -2
  51. package/src/embed/conversions.zig +4 -5
  52. package/src/embed/host.zig +109 -1
  53. package/src/embed/root.zig +7 -0
  54. package/src/embed/tests.zig +213 -0
  55. package/src/embed/types.zig +51 -0
  56. package/src/embed/ui_host.zig +119 -5
  57. package/src/platform/android/NativeSdkActivity.java +131 -0
  58. package/src/platform/android/android_host.c +182 -1
  59. package/src/platform/android/native_sdk_app.h +17 -0
  60. package/src/platform/ios/native_sdk_app.h +17 -0
  61. package/src/platform/ios/uikit_host.m +115 -0
  62. package/src/platform/linux/cef_host.cpp +1 -1
  63. package/src/platform/linux/gtk_host.c +89 -17
  64. package/src/platform/linux/gtk_host.h +3 -0
  65. package/src/platform/linux/root.zig +40 -18
  66. package/src/platform/macos/appkit_host.h +16 -3
  67. package/src/platform/macos/appkit_host.m +536 -36
  68. package/src/platform/macos/cef_host.mm +248 -36
  69. package/src/platform/macos/root.zig +244 -34
  70. package/src/platform/null_platform.zig +223 -19
  71. package/src/platform/null_platform_tests.zig +74 -0
  72. package/src/platform/root.zig +9 -0
  73. package/src/platform/types.zig +179 -15
  74. package/src/platform/windows/root.zig +187 -21
  75. package/src/platform/windows/webview2_host.cpp +293 -46
  76. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  77. package/src/primitives/app_manifest/root.zig +4 -0
  78. package/src/primitives/app_manifest/tests.zig +3 -0
  79. package/src/primitives/app_manifest/types.zig +32 -0
  80. package/src/primitives/app_manifest/validation.zig +19 -1
  81. package/src/root.zig +46 -0
  82. package/src/runtime/api.zig +11 -0
  83. package/src/runtime/automation_snapshot.zig +4 -0
  84. package/src/runtime/bridge_permission_tests.zig +23 -2
  85. package/src/runtime/bridge_responses.zig +3 -1
  86. package/src/runtime/canvas_frame.zig +18 -11
  87. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  88. package/src/runtime/clock.zig +13 -1
  89. package/src/runtime/core.zig +133 -1
  90. package/src/runtime/credentials_store.zig +115 -0
  91. package/src/runtime/effects.zig +2295 -113
  92. package/src/runtime/effects_credentials_tests.zig +332 -0
  93. package/src/runtime/effects_host_tests.zig +208 -1
  94. package/src/runtime/effects_relational_tests.zig +314 -0
  95. package/src/runtime/effects_store_tests.zig +211 -0
  96. package/src/runtime/flow.zig +14 -1
  97. package/src/runtime/gpu_surface_events.zig +6 -1
  98. package/src/runtime/native_command_event_tests.zig +42 -0
  99. package/src/runtime/persist_store.zig +666 -0
  100. package/src/runtime/record_store.zig +788 -0
  101. package/src/runtime/relational_store.zig +854 -0
  102. package/src/runtime/root.zig +49 -0
  103. package/src/runtime/runtime_event_tests.zig +70 -0
  104. package/src/runtime/service_host.zig +711 -0
  105. package/src/runtime/service_pool.zig +1314 -0
  106. package/src/runtime/session_blobs.zig +1 -1
  107. package/src/runtime/session_journal.zig +102 -0
  108. package/src/runtime/session_record.zig +177 -0
  109. package/src/runtime/session_replay.zig +109 -4
  110. package/src/runtime/shell_layout.zig +1 -0
  111. package/src/runtime/shell_layout_tests.zig +120 -0
  112. package/src/runtime/sqlite_engine.zig +474 -0
  113. package/src/runtime/state.zig +6 -0
  114. package/src/runtime/system_services.zig +49 -10
  115. package/src/runtime/tests.zig +4 -0
  116. package/src/runtime/ts_core_host.zig +788 -86
  117. package/src/runtime/ts_core_host_tests.zig +231 -11
  118. package/src/runtime/ts_ui_app.zig +499 -1
  119. package/src/runtime/ui_app.zig +142 -16
  120. package/src/runtime/ui_app_tests.zig +155 -5
  121. package/src/runtime/validation.zig +22 -0
  122. package/src/runtime/view.zig +9 -0
  123. package/src/runtime/window_storage.zig +1 -0
  124. package/src/runtime/window_view_runtime.zig +2 -3
  125. package/src/runtime/window_views.zig +19 -0
  126. package/src/tooling/android.zig +21 -16
  127. package/src/tooling/db.zig +160 -0
  128. package/src/tooling/ios.zig +7 -1
  129. package/src/tooling/manifest.zig +214 -2
  130. package/src/tooling/package.zig +116 -0
  131. package/src/tooling/raw_manifest.zig +30 -0
  132. package/src/tooling/root.zig +1 -0
  133. package/src/tooling/templates.zig +161 -4
  134. package/src/tooling/ts_core.zig +283 -17
  135. package/src/tooling/verbs.zig +7 -0
  136. package/third_party/sqlite/README.md +13 -0
  137. package/third_party/sqlite/sqlite3.c +269649 -0
  138. package/third_party/sqlite/sqlite3.h +14349 -0
  139. package/tools/corewire/core_abi.zig +14 -2
  140. package/tools/corewire/emit.zig +98 -29
  141. package/tools/corewire/emit_facade.zig +378 -23
  142. package/tools/corewire/emit_profile.zig +6 -2
  143. package/tools/corewire/emit_service.zig +924 -0
  144. package/tools/corewire/main.zig +122 -0
  145. package/tools/corewire/service_contract.zig +250 -0
  146. package/tools/corewire/sidecar.zig +26 -15
@@ -61,6 +61,8 @@ pub const Error = error{
61
61
  InvalidCredentialOptions,
62
62
  CredentialFieldTooLarge,
63
63
  CredentialNotFound,
64
+ CredentialStoreLocked,
65
+ CredentialStoreFailed,
64
66
  InvalidTrayOptions,
65
67
  TrayFieldTooLarge,
66
68
  InvalidAudioOptions,
@@ -245,13 +247,18 @@ pub const max_clipboard_mime_type_bytes: usize = 128;
245
247
  pub const max_clipboard_data_bytes: usize = 65536;
246
248
  pub const max_credential_service_bytes: usize = 128;
247
249
  pub const max_credential_account_bytes: usize = 256;
248
- pub const max_credential_secret_bytes: usize = 4096;
250
+ /// One honest cross-platform bound: Windows Credential Manager's generic
251
+ /// credential blob is the narrowest first-party backend at 5 * 512 bytes.
252
+ /// Every host accepts this whole range; none silently truncates it.
253
+ pub const max_credential_secret_bytes: usize = 5 * 512;
254
+ pub const max_local_time_text_bytes: usize = 512;
249
255
  pub const max_tray_items: usize = 32;
250
256
  pub const max_tray_icon_path_bytes: usize = 4096;
251
257
  pub const max_tray_title_bytes: usize = 64;
252
258
  pub const max_tray_tooltip_bytes: usize = 256;
253
259
  pub const max_tray_item_label_bytes: usize = 256;
254
260
  pub const max_tray_item_command_bytes: usize = 128;
261
+ pub const max_tray_item_detail_bytes: usize = 256;
255
262
  pub const max_drop_paths_bytes: usize = 8192;
256
263
  pub const max_drop_paths: usize = max_drop_paths_bytes / 2 + 1;
257
264
  pub const max_window_event_name_bytes: usize = 64;
@@ -355,8 +362,7 @@ pub const MenuItem = struct {
355
362
 
356
363
  pub fn validateShortcut(shortcut: Shortcut) Error!void {
357
364
  if (!isValidCommandId(shortcut.id, max_shortcut_id_bytes)) return error.InvalidShortcut;
358
- if (!isValidShortcutKey(shortcut.key)) return error.InvalidShortcut;
359
- if (!shortcut.modifiers.hasAny() and shortcutRequiresModifier(shortcut.key)) return error.InvalidShortcut;
365
+ if (!isValidShortcutBinding(shortcut.key, shortcut.modifiers)) return error.InvalidShortcut;
360
366
  }
361
367
 
362
368
  pub fn validateMenus(menus: []const Menu) Error!void {
@@ -375,9 +381,8 @@ pub fn validateMenuItem(item: MenuItem) Error!void {
375
381
  if (item.label.len == 0 or item.label.len > max_menu_item_label_bytes) return error.InvalidMenuOptions;
376
382
  if (!isValidCommandId(item.command, max_menu_command_bytes)) return error.InvalidCommand;
377
383
  if (item.key.len > 0) {
378
- if (!isValidShortcutKey(item.key)) return error.InvalidShortcut;
379
384
  if (item.key.len > max_menu_key_bytes) return error.InvalidShortcut;
380
- if (!item.modifiers.hasAny() and shortcutRequiresModifier(item.key)) return error.InvalidShortcut;
385
+ if (!isValidShortcutBinding(item.key, item.modifiers)) return error.InvalidShortcut;
381
386
  }
382
387
  }
383
388
 
@@ -435,6 +440,10 @@ pub fn isValidShortcutKey(key: []const u8) bool {
435
440
  return false;
436
441
  }
437
442
 
443
+ pub fn isValidShortcutBinding(key: []const u8, modifiers: ShortcutModifiers) bool {
444
+ return isValidShortcutKey(key) and (modifiers.hasAny() or !shortcutRequiresModifier(key));
445
+ }
446
+
438
447
  fn shortcutRequiresModifier(key: []const u8) bool {
439
448
  if (key.len == 1) return true;
440
449
  return std.ascii.eqlIgnoreCase(key, "space") or
@@ -572,6 +581,11 @@ pub const WindowDragRegion = struct {
572
581
  pub const WindowShowMode = enum {
573
582
  immediate,
574
583
  on_first_present,
584
+ /// Create the native window ordered out and keep it that way until
585
+ /// an explicit `showWindow`/focus request. This is the launch shape
586
+ /// for a menu-bar app whose real surface is its status item: the
587
+ /// host window exists for runtime/view ownership but never flashes.
588
+ hidden,
575
589
  };
576
590
 
577
591
  /// What the user's close affordance (the red traffic light, cmd+W, the
@@ -618,6 +632,12 @@ pub const WindowOptions = struct {
618
632
  /// or `showWindow`) activates the app and takes keyboard focus.
619
633
  /// Explicit `focusWindow` remains an activation request either way.
620
634
  activate_on_show: bool = true,
635
+ /// Whether macOS may move the window into a native fullscreen
636
+ /// Space. False keeps ordinary resizing but removes the green
637
+ /// fullscreen affordance and rejects the fullscreen shortcut.
638
+ /// Other desktop hosts currently have no separate fullscreen mode
639
+ /// at this seam and keep their existing maximize behavior.
640
+ allows_fullscreen: bool = true,
621
641
  /// Content min-size floor the WINDOW enforces (macOS
622
642
  /// `contentMinSize`): the user cannot resize below it, so declared
623
643
  /// layout floors stop clamping/clipping panes instead of stopping
@@ -644,15 +664,14 @@ pub const WindowState = struct {
644
664
  focused: bool = true,
645
665
  maximized: bool = false,
646
666
  fullscreen: bool = false,
647
- /// True while the window is alive but off the glass because its
648
- /// `close_policy = .hide` intercepted a user close (the menu-bar-app
649
- /// shape): the window keeps its views and native identity, `open`
650
- /// stays true, and a show — `Effects.showWindow`, a tray action's
651
- /// consequence, the macOS Dock reopen — flips it back. Distinct from
652
- /// minimized (which keeps a Dock/taskbar affordance) and from
653
- /// closed (`open = false`, the window is gone). Session-transient:
654
- /// never persisted to the window-state store, so every launch
655
- /// starts shown.
667
+ /// True while the window is alive but ordered off the glass: an
668
+ /// explicitly hidden startup window, `Effects.hideWindow`, or a
669
+ /// `close_policy = .hide` user close. The window keeps its views and
670
+ /// native identity, `open` stays true, and show/focus flips it back.
671
+ /// Distinct from minimized (which keeps a Dock/taskbar affordance)
672
+ /// and closed (`open = false`, the window is gone). Session-transient:
673
+ /// it is never restored from the window-state store; each launch uses
674
+ /// the declaration's show policy again.
656
675
  hidden: bool = false,
657
676
  };
658
677
 
@@ -695,6 +714,7 @@ pub const WindowCreateOptions = struct {
695
714
  always_on_top: bool = false,
696
715
  click_through: bool = false,
697
716
  activate_on_show: bool = true,
717
+ allows_fullscreen: bool = true,
698
718
  /// Window-enforced content min-size floor (see
699
719
  /// `WindowOptions.min_width`/`min_height`); 0 = no floor.
700
720
  min_width: f32 = 0,
@@ -718,6 +738,7 @@ pub const WindowCreateOptions = struct {
718
738
  .always_on_top = self.always_on_top,
719
739
  .click_through = self.click_through,
720
740
  .activate_on_show = self.activate_on_show,
741
+ .allows_fullscreen = self.allows_fullscreen,
721
742
  .min_width = self.min_width,
722
743
  .min_height = self.min_height,
723
744
  .close_policy = self.close_policy,
@@ -725,6 +746,18 @@ pub const WindowCreateOptions = struct {
725
746
  }
726
747
  };
727
748
 
749
+ /// The operating system's registration state for launching this app at
750
+ /// user login. `requires_approval` is a successful query, not an I/O
751
+ /// failure: macOS knows the registration but the user must approve it
752
+ /// in System Settings. `not_found` means the current executable is not
753
+ /// an installed application bundle that SMAppService can register.
754
+ pub const LaunchAtLoginStatus = enum {
755
+ disabled,
756
+ enabled,
757
+ requires_approval,
758
+ not_found,
759
+ };
760
+
728
761
  pub const WebViewOptions = struct {
729
762
  window_id: WindowId = 1,
730
763
  label: []const u8,
@@ -967,6 +1000,10 @@ pub const ViewInfo = struct {
967
1000
  gpu_frame_index: u64 = 0,
968
1001
  gpu_timestamp_ns: u64 = 0,
969
1002
  gpu_frame_interval_ns: u64 = default_gpu_frame_interval_ns,
1003
+ /// GPU-surface input events accepted by the runtime for this view.
1004
+ /// Monotonic for the view lifetime; automation uses deltas to separate
1005
+ /// host/input-stack delivery from renderer frame coverage.
1006
+ gpu_input_event_count: u64 = 0,
970
1007
  gpu_input_timestamp_ns: u64 = 0,
971
1008
  gpu_input_latency_ns: u64 = 0,
972
1009
  gpu_input_latency_budget_ns: u64 = default_gpu_frame_interval_ns,
@@ -977,6 +1014,9 @@ pub const ViewInfo = struct {
977
1014
  gpu_first_frame_latency_budget_exceeded_count: usize = 0,
978
1015
  gpu_first_frame_latency_budget_ok: bool = true,
979
1016
  gpu_frame_nonblank: bool = false,
1017
+ /// Whether the most recent host completion was an occluded logical
1018
+ /// heartbeat rather than a presentation that reached the display.
1019
+ gpu_occluded: bool = false,
980
1020
  gpu_sample_color: u32 = 0,
981
1021
  gpu_backend: GpuSurfaceBackend = .none,
982
1022
  gpu_pixel_format: GpuSurfacePixelFormat = .none,
@@ -1348,8 +1388,38 @@ pub const Credential = struct {
1348
1388
  secret: []const u8,
1349
1389
  };
1350
1390
 
1391
+ /// Host-local, locale-aware timestamp presentation. This deliberately lives
1392
+ /// behind PlatformServices: the same epoch can format differently after a
1393
+ /// locale or time-zone change, so app cores must observe it as an effect.
1394
+ pub const LocalTimeStyle = enum(u8) {
1395
+ date,
1396
+ time,
1397
+ datetime,
1398
+ };
1399
+
1351
1400
  pub const TrayItemId = u32;
1352
1401
 
1402
+ /// Visual emphasis for the menu-bar button's live presentation. Hosts
1403
+ /// without a colored-title seam may render every value as `normal`.
1404
+ pub const TrayTone = enum(u8) {
1405
+ normal,
1406
+ warning,
1407
+ critical,
1408
+ };
1409
+
1410
+ /// The model-derived part of a status item. Keeping this separate from
1411
+ /// icon/tooltip/activation options lets UiApp patch presentation without
1412
+ /// recreating the native item.
1413
+ pub const TrayPresentation = struct {
1414
+ title: []const u8 = "",
1415
+ /// Explicit status-item width in points; zero asks the host to choose
1416
+ /// variable width for a title and square width for icon-only state.
1417
+ width: f32 = 0,
1418
+ tone: TrayTone = .normal,
1419
+ icon_opacity: f32 = 1,
1420
+ monospaced: bool = false,
1421
+ };
1422
+
1353
1423
  pub const TrayOptions = struct {
1354
1424
  icon_path: []const u8 = "",
1355
1425
  /// Status-bar button title, shown when no icon resolves (macOS
@@ -1357,6 +1427,25 @@ pub const TrayOptions = struct {
1357
1427
  title: []const u8 = "",
1358
1428
  tooltip: []const u8 = "",
1359
1429
  items: []const TrayMenuItem = &.{},
1430
+ presentation: TrayPresentation = .{},
1431
+ /// Ordinary click, Option-click, and menu-open hooks. Each command
1432
+ /// enters the same on_command route as a selected menu row.
1433
+ activation_command: []const u8 = "",
1434
+ alternate_activation_command: []const u8 = "",
1435
+ open_command: []const u8 = "",
1436
+ };
1437
+
1438
+ /// Semantic status-menu rows. `command` is the ordinary actionable row;
1439
+ /// the others let a capable host render readouts without presenting them
1440
+ /// as disabled actions. Hosts without rich-menu support may degrade them
1441
+ /// to non-actionable text rows.
1442
+ pub const TrayItemRole = enum(u8) {
1443
+ command,
1444
+ info,
1445
+ header,
1446
+ hero,
1447
+ agent,
1448
+ context,
1360
1449
  };
1361
1450
 
1362
1451
  pub const TrayMenuItem = struct {
@@ -1365,6 +1454,10 @@ pub const TrayMenuItem = struct {
1365
1454
  command: []const u8 = "",
1366
1455
  separator: bool = false,
1367
1456
  enabled: bool = true,
1457
+ detail: []const u8 = "",
1458
+ role: TrayItemRole = .command,
1459
+ key: []const u8 = "",
1460
+ modifiers: ShortcutModifiers = .{},
1368
1461
  };
1369
1462
 
1370
1463
  pub const NativeCommandEvent = struct {
@@ -1378,6 +1471,14 @@ pub const MenuCommandEvent = struct {
1378
1471
  window_id: WindowId = 1,
1379
1472
  };
1380
1473
 
1474
+ /// A named command emitted by status-item lifecycle hooks (activation,
1475
+ /// alternate activation, or menu open). Unlike `tray_action`, this command
1476
+ /// does not identify a menu row, but its source is still the tray.
1477
+ pub const TrayCommandEvent = struct {
1478
+ name: []const u8,
1479
+ window_id: WindowId = 1,
1480
+ };
1481
+
1381
1482
  /// Timer ids at or above this value are reserved for the framework's own
1382
1483
  /// internal timers (for example the ui-app markup watch poll). Application
1383
1484
  /// code must pick ids below this value when calling `startTimer`.
@@ -2323,6 +2424,7 @@ pub const Event = union(enum) {
2323
2424
  shortcut: ShortcutEvent,
2324
2425
  native_command: NativeCommandEvent,
2325
2426
  menu_command: MenuCommandEvent,
2427
+ tray_command: TrayCommandEvent,
2326
2428
  timer: TimerEvent,
2327
2429
  /// A cross-thread nudge posted through `PlatformServices.wake_fn`:
2328
2430
  /// worker threads (effect executors) ask the platform loop to deliver
@@ -2360,6 +2462,7 @@ pub const Event = union(enum) {
2360
2462
  .shortcut => "shortcut",
2361
2463
  .native_command => "native_command",
2362
2464
  .menu_command => "menu_command",
2465
+ .tray_command => "tray_command",
2363
2466
  .timer => "timer",
2364
2467
  .wake => "wake",
2365
2468
  .files_dropped => "files_dropped",
@@ -2414,12 +2517,26 @@ pub const PlatformServices = struct {
2414
2517
  /// controls — chromeless windows have no system button to click.
2415
2518
  /// Platforms without the concept leave this null.
2416
2519
  minimize_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
2520
+ /// Keep a live window and all of its views, but order it off the
2521
+ /// glass. The runtime marks `WindowInfo.hidden` while it is out;
2522
+ /// `show_window_fn` is the inverse. Platforms without a reliable
2523
+ /// re-show path leave this null.
2524
+ hide_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
2417
2525
  /// The real OS show verb: unhide + order front. It activates by
2418
2526
  /// default; windows created with `activate_on_show = false` use the
2419
2527
  /// platform's passive variant. This is the counterpart to a
2420
2528
  /// `close_policy = .hide` hide, and the tray "Open" consequence.
2421
2529
  /// Platforms without the concept leave this null.
2422
2530
  show_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
2531
+ /// Change whether the process appears in the Dock/app switcher.
2532
+ /// macOS maps true/false to the regular/accessory activation
2533
+ /// policies; other hosts leave this null.
2534
+ set_dock_presence_fn: ?*const fn (context: ?*anyopaque, visible: bool) anyerror!void = null,
2535
+ /// Query and update the installed app bundle's SMAppService login
2536
+ /// registration. Unbundled development executables and hosts
2537
+ /// without the service leave these null / return UnsupportedService.
2538
+ launch_at_login_status_fn: ?*const fn (context: ?*anyopaque) anyerror!LaunchAtLoginStatus = null,
2539
+ set_launch_at_login_fn: ?*const fn (context: ?*anyopaque, enabled: bool) anyerror!LaunchAtLoginStatus = null,
2423
2540
  /// The graceful app quit: terminate through the SAME shutdown path
2424
2541
  /// a last-window close takes — but the host QUEUES the emit, so
2425
2542
  /// `app_shutdown` dispatches on its NEXT loop turn, only after the
@@ -2485,6 +2602,13 @@ pub const PlatformServices = struct {
2485
2602
  set_credential_fn: ?*const fn (context: ?*anyopaque, credential: Credential) anyerror!void = null,
2486
2603
  get_credential_fn: ?*const fn (context: ?*anyopaque, key: CredentialKey, buffer: []u8) anyerror![]const u8 = null,
2487
2604
  delete_credential_fn: ?*const fn (context: ?*anyopaque, key: CredentialKey) anyerror!void = null,
2605
+ /// Teardown detached a synchronous platform operation which may still
2606
+ /// use `context` after the runtime is gone. The platform must latch this
2607
+ /// notification and skip destruction of everything the callback can
2608
+ /// reach. First-party hosts share the channel-wake abandon latch because
2609
+ /// its lifetime obligation is identical. Loop-thread, teardown-only.
2610
+ note_blocking_call_abandoned_fn: ?*const fn (context: ?*anyopaque) void = null,
2611
+ format_local_time_fn: ?*const fn (context: ?*anyopaque, timestamp_ms: i64, style: LocalTimeStyle, buffer: []u8) anyerror![]const u8 = null,
2488
2612
  open_external_url_fn: ?*const fn (context: ?*anyopaque, url: []const u8) anyerror!void = null,
2489
2613
  reveal_path_fn: ?*const fn (context: ?*anyopaque, path: []const u8) anyerror!void = null,
2490
2614
  add_recent_document_fn: ?*const fn (context: ?*anyopaque, path: []const u8) anyerror!void = null,
@@ -2492,6 +2616,7 @@ pub const PlatformServices = struct {
2492
2616
  create_tray_fn: ?*const fn (context: ?*anyopaque, options: TrayOptions) anyerror!void = null,
2493
2617
  update_tray_menu_fn: ?*const fn (context: ?*anyopaque, items: []const TrayMenuItem) anyerror!void = null,
2494
2618
  update_tray_title_fn: ?*const fn (context: ?*anyopaque, title: []const u8) anyerror!void = null,
2619
+ update_tray_presentation_fn: ?*const fn (context: ?*anyopaque, presentation: TrayPresentation) anyerror!void = null,
2495
2620
  remove_tray_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2496
2621
  configure_security_policy_fn: ?*const fn (context: ?*anyopaque, policy: security.Policy) anyerror!void = null,
2497
2622
  configure_menus_fn: ?*const fn (context: ?*anyopaque, menus: []const Menu) anyerror!void = null,
@@ -2842,11 +2967,31 @@ pub const PlatformServices = struct {
2842
2967
  return minimize_fn(self.context, window_id);
2843
2968
  }
2844
2969
 
2970
+ pub fn hideWindow(self: PlatformServices, window_id: WindowId) anyerror!void {
2971
+ const hide_fn = self.hide_window_fn orelse return error.UnsupportedService;
2972
+ return hide_fn(self.context, window_id);
2973
+ }
2974
+
2845
2975
  pub fn showWindow(self: PlatformServices, window_id: WindowId) anyerror!void {
2846
2976
  const show_fn = self.show_window_fn orelse return error.UnsupportedService;
2847
2977
  return show_fn(self.context, window_id);
2848
2978
  }
2849
2979
 
2980
+ pub fn setDockPresence(self: PlatformServices, visible: bool) anyerror!void {
2981
+ const set_fn = self.set_dock_presence_fn orelse return error.UnsupportedService;
2982
+ return set_fn(self.context, visible);
2983
+ }
2984
+
2985
+ pub fn launchAtLoginStatus(self: PlatformServices) anyerror!LaunchAtLoginStatus {
2986
+ const status_fn = self.launch_at_login_status_fn orelse return error.UnsupportedService;
2987
+ return status_fn(self.context);
2988
+ }
2989
+
2990
+ pub fn setLaunchAtLogin(self: PlatformServices, enabled: bool) anyerror!LaunchAtLoginStatus {
2991
+ const set_fn = self.set_launch_at_login_fn orelse return error.UnsupportedService;
2992
+ return set_fn(self.context, enabled);
2993
+ }
2994
+
2850
2995
  pub fn quitApp(self: PlatformServices) anyerror!void {
2851
2996
  const quit_fn = self.quit_app_fn orelse return error.UnsupportedService;
2852
2997
  return quit_fn(self.context);
@@ -3006,6 +3151,16 @@ pub const PlatformServices = struct {
3006
3151
  return delete_fn(self.context, key);
3007
3152
  }
3008
3153
 
3154
+ pub fn noteBlockingCallAbandoned(self: PlatformServices) void {
3155
+ const note_fn = self.note_blocking_call_abandoned_fn orelse return;
3156
+ note_fn(self.context);
3157
+ }
3158
+
3159
+ pub fn formatLocalTime(self: PlatformServices, timestamp_ms: i64, style: LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
3160
+ const format_fn = self.format_local_time_fn orelse return error.UnsupportedService;
3161
+ return format_fn(self.context, timestamp_ms, style, buffer);
3162
+ }
3163
+
3009
3164
  pub fn openExternalUrl(self: PlatformServices, url: []const u8) anyerror!void {
3010
3165
  const open_fn = self.open_external_url_fn orelse return error.UnsupportedService;
3011
3166
  return open_fn(self.context, url);
@@ -3045,6 +3200,14 @@ pub const PlatformServices = struct {
3045
3200
  return title_fn(self.context, title);
3046
3201
  }
3047
3202
 
3203
+ /// Patch all live menu-bar presentation fields without recreating the
3204
+ /// native item. A host that only implements title updates still gets a
3205
+ /// correct title and intentionally degrades the richer styling.
3206
+ pub fn updateTrayPresentation(self: PlatformServices, presentation: TrayPresentation) anyerror!void {
3207
+ if (self.update_tray_presentation_fn) |update_fn| return update_fn(self.context, presentation);
3208
+ return self.updateTrayTitle(presentation.title);
3209
+ }
3210
+
3048
3211
  pub fn removeTray(self: PlatformServices) anyerror!void {
3049
3212
  const remove_fn = self.remove_tray_fn orelse return error.UnsupportedService;
3050
3213
  return remove_fn(self.context);
@@ -3392,7 +3555,8 @@ fn defaultSupportsFeature(services: PlatformServices, feature: PlatformFeature)
3392
3555
  .reveal_path => services.reveal_path_fn != null,
3393
3556
  .notifications => services.show_notification_fn != null,
3394
3557
  .recent_documents => services.add_recent_document_fn != null or services.clear_recent_documents_fn != null,
3395
- .credentials => services.set_credential_fn != null and services.get_credential_fn != null and services.delete_credential_fn != null,
3558
+ .credentials => services.set_credential_fn != null and services.get_credential_fn != null and services.delete_credential_fn != null and
3559
+ services.note_blocking_call_abandoned_fn != null,
3396
3560
  .file_drops => false,
3397
3561
  .app_activation_events => false,
3398
3562
  .gpu_surfaces => false,