@native-sdk/cli 0.9.0 → 0.9.2

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 (181) hide show
  1. package/build/app.zig +357 -33
  2. package/build.zig +234 -11
  3. package/native-sdk.d.ts +8 -0
  4. package/package.json +10 -10
  5. package/packages/core/compile-surface/core.ts +70 -1
  6. package/packages/core/package-lock.json +11 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  9. package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
  10. package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
  11. package/packages/core/scripts/stage_external_services.mjs +1 -1
  12. package/packages/core/sdk/core.d.ts +75 -0
  13. package/packages/core/sdk/core.ts +170 -13
  14. package/packages/core/sdk/events.d.ts +53 -0
  15. package/packages/core/sdk/events.ts +78 -7
  16. package/packages/core/src/checker.ts +470 -2
  17. package/packages/core/src/cli.ts +13 -0
  18. package/packages/core/src/contract.ts +3 -1
  19. package/packages/core/src/devhost.ts +30 -1
  20. package/packages/core/src/devhost_journal.mjs +10 -8
  21. package/packages/core/src/diagnostics.ts +99 -8
  22. package/packages/core/src/frontend.ts +6 -0
  23. package/packages/core/src/infer.ts +24 -0
  24. package/skill-data/automation/SKILL.md +1 -1
  25. package/skill-data/native-ui/SKILL.md +18 -12
  26. package/skill-data/ts-core/SKILL.md +54 -21
  27. package/skill-data/ts-services/SKILL.md +4 -4
  28. package/skill-data/ts-services/references/service-surface.md +2 -1
  29. package/skill-data/zig/SKILL.md +1 -1
  30. package/src/app_runner/root.zig +122 -6
  31. package/src/app_runner/ts_core_main.zig +9 -4
  32. package/src/app_runner/ts_core_mobile.zig +241 -0
  33. package/src/app_runner/window_placement.zig +63 -0
  34. package/src/automation/protocol.zig +5 -1
  35. package/src/automation/snapshot.zig +8 -6
  36. package/src/embed/app_exports.zig +3 -1
  37. package/src/embed/conversions.zig +1 -0
  38. package/src/embed/host.zig +10 -3
  39. package/src/embed/root.zig +2 -0
  40. package/src/embed/tests.zig +41 -1
  41. package/src/embed/types.zig +2 -0
  42. package/src/embed/ui_host.zig +94 -4
  43. package/src/platform/android/NativeSdkActivity.java +49 -4
  44. package/src/platform/android/android_host.c +3 -3
  45. package/src/platform/android/native_sdk_app.h +1 -1
  46. package/src/platform/ios/apple_image_fit.h +38 -0
  47. package/src/platform/ios/files.zig +1 -0
  48. package/src/platform/ios/native_sdk_app.h +1 -1
  49. package/src/platform/ios/uikit_host.m +28 -5
  50. package/src/platform/linux/cef_host.cpp +17 -3
  51. package/src/platform/linux/gtk_host.c +243 -15
  52. package/src/platform/linux/gtk_host.h +5 -4
  53. package/src/platform/linux/root.zig +91 -11
  54. package/src/platform/macos/appkit_host.h +18 -11
  55. package/src/platform/macos/appkit_host.m +402 -128
  56. package/src/platform/macos/cef_host.mm +342 -122
  57. package/src/platform/macos/image_fit_test.m +44 -0
  58. package/src/platform/macos/root.zig +231 -39
  59. package/src/platform/null_platform.zig +251 -54
  60. package/src/platform/null_platform_tests.zig +97 -4
  61. package/src/platform/root.zig +12 -0
  62. package/src/platform/types.zig +174 -35
  63. package/src/platform/windows/root.zig +42 -13
  64. package/src/platform/windows/webview2_host.cpp +72 -11
  65. package/src/primitives/app_manifest/root.zig +3 -0
  66. package/src/primitives/app_manifest/tests.zig +24 -0
  67. package/src/primitives/app_manifest/types.zig +13 -0
  68. package/src/primitives/app_manifest/validation.zig +24 -0
  69. package/src/primitives/canvas/a11y_audit.zig +9 -7
  70. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  71. package/src/primitives/canvas/events.zig +50 -0
  72. package/src/primitives/canvas/layout_audit.zig +6 -6
  73. package/src/primitives/canvas/markdown.zig +4 -0
  74. package/src/primitives/canvas/markdown_tests.zig +1 -0
  75. package/src/primitives/canvas/png.zig +138 -0
  76. package/src/primitives/canvas/root.zig +13 -2
  77. package/src/primitives/canvas/text_span_tests.zig +5 -3
  78. package/src/primitives/canvas/text_spans.zig +2 -0
  79. package/src/primitives/canvas/text_tests.zig +20 -0
  80. package/src/primitives/canvas/ui.zig +55 -2
  81. package/src/primitives/canvas/ui_markup.zig +40 -13
  82. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  83. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  84. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  85. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  86. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  87. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  88. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  89. package/src/primitives/canvas/ui_schema.zig +17 -13
  90. package/src/primitives/canvas/ui_tests.zig +47 -0
  91. package/src/primitives/canvas/widget_access.zig +3 -3
  92. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  93. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  94. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  95. package/src/primitives/canvas/widget_layout.zig +333 -126
  96. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  97. package/src/primitives/canvas/widget_metrics.zig +7 -8
  98. package/src/primitives/canvas/widget_render.zig +76 -44
  99. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  100. package/src/primitives/canvas/widget_render_style.zig +58 -18
  101. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  102. package/src/primitives/canvas/widget_routing.zig +40 -34
  103. package/src/primitives/canvas/widget_runtime.zig +11 -2
  104. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  105. package/src/primitives/canvas/widget_semantics.zig +8 -3
  106. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  107. package/src/primitives/canvas/widget_tree.zig +99 -5
  108. package/src/primitives/canvas/widgets.zig +20 -7
  109. package/src/root.zig +10 -0
  110. package/src/runtime/api.zig +14 -0
  111. package/src/runtime/automation_commands.zig +35 -2
  112. package/src/runtime/automation_snapshot.zig +32 -24
  113. package/src/runtime/automation_widget_dispatch.zig +48 -6
  114. package/src/runtime/bridge_permission_tests.zig +35 -1
  115. package/src/runtime/bridge_responses.zig +1 -1
  116. package/src/runtime/builtin_bridge.zig +16 -3
  117. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  118. package/src/runtime/canvas_image_tests.zig +146 -2
  119. package/src/runtime/canvas_images.zig +35 -16
  120. package/src/runtime/canvas_limits.zig +13 -3
  121. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  122. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  123. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  124. package/src/runtime/canvas_widget_events.zig +151 -26
  125. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  126. package/src/runtime/canvas_widget_runtime.zig +322 -102
  127. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  128. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  129. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  130. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  131. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  132. package/src/runtime/canvas_widget_state.zig +33 -7
  133. package/src/runtime/core.zig +28 -6
  134. package/src/runtime/effects.zig +1337 -49
  135. package/src/runtime/effects_file_tests.zig +587 -0
  136. package/src/runtime/effects_image_tests.zig +91 -0
  137. package/src/runtime/effects_notification_tests.zig +11 -0
  138. package/src/runtime/file_access.zig +400 -0
  139. package/src/runtime/file_effect_crash_helper.zig +28 -0
  140. package/src/runtime/file_effect_crash_tests.zig +37 -0
  141. package/src/runtime/flow.zig +21 -9
  142. package/src/runtime/gpu_surface_events.zig +25 -2
  143. package/src/runtime/native_command_event_tests.zig +44 -2
  144. package/src/runtime/pty.zig +5 -2
  145. package/src/runtime/root.zig +7 -0
  146. package/src/runtime/session_blobs.zig +4 -1
  147. package/src/runtime/session_journal.zig +56 -5
  148. package/src/runtime/session_record.zig +38 -0
  149. package/src/runtime/session_replay.zig +110 -15
  150. package/src/runtime/session_tests.zig +192 -4
  151. package/src/runtime/shell_layout_tests.zig +12 -0
  152. package/src/runtime/state.zig +10 -0
  153. package/src/runtime/system_services.zig +129 -36
  154. package/src/runtime/ts_core_host.zig +281 -11
  155. package/src/runtime/ts_core_host_tests.zig +142 -1
  156. package/src/runtime/ts_ui_app.zig +461 -8
  157. package/src/runtime/ui_app.zig +330 -112
  158. package/src/runtime/ui_app_tests.zig +251 -25
  159. package/src/runtime/ui_app_window_tests.zig +74 -8
  160. package/src/runtime/validation.zig +20 -0
  161. package/src/runtime/view.zig +3 -0
  162. package/src/runtime/view_widget_control.zig +18 -0
  163. package/src/runtime/view_widget_scroll.zig +112 -18
  164. package/src/runtime/view_widget_tree.zig +110 -13
  165. package/src/runtime/widget_bridge.zig +2 -0
  166. package/src/runtime/window_command_bridge_tests.zig +86 -0
  167. package/src/runtime/window_storage.zig +16 -1
  168. package/src/runtime/window_views.zig +1 -0
  169. package/src/tooling/ios.zig +3 -0
  170. package/src/tooling/manifest.zig +90 -2
  171. package/src/tooling/package.zig +67 -2
  172. package/src/tooling/raw_manifest.zig +10 -0
  173. package/src/tooling/templates.zig +156 -18
  174. package/src/tooling/ts_core.zig +83 -0
  175. package/src/tooling/web_engine.zig +1 -1
  176. package/tools/corewire/emit.zig +3 -3
  177. package/tools/corewire/emit_facade.zig +65 -5
  178. package/tools/corewire/emit_profile.zig +2 -2
  179. package/tools/corewire/emit_service.zig +2 -2
  180. package/tools/corewire/service_contract.zig +4 -4
  181. package/tools/corewire/sidecar.zig +4 -4
@@ -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;
@@ -62,6 +66,7 @@ pub const max_widget_accessibility_nodes = types.max_widget_accessibility_nodes;
62
66
  pub const max_gpu_surface_packet_json_bytes = types.max_gpu_surface_packet_json_bytes;
63
67
  pub const max_gpu_surface_packet_binary_bytes = types.max_gpu_surface_packet_binary_bytes;
64
68
  pub const max_gpu_present_fallback_detail_bytes = types.max_gpu_present_fallback_detail_bytes;
69
+ pub const max_decoded_image_dimension = types.max_decoded_image_dimension;
65
70
  pub const max_gpu_surface_image_pixel_bytes = types.max_gpu_surface_image_pixel_bytes;
66
71
  pub const max_gpu_surface_media_image_pixel_bytes = types.max_gpu_surface_media_image_pixel_bytes;
67
72
  pub const max_gpu_surface_font_bytes = types.max_gpu_surface_font_bytes;
@@ -76,6 +81,7 @@ pub const validateMenuItem = types.validateMenuItem;
76
81
  pub const isValidShortcutKey = types.isValidShortcutKey;
77
82
  pub const isValidShortcutBinding = types.isValidShortcutBinding;
78
83
  pub const WindowRestorePolicy = types.WindowRestorePolicy;
84
+ pub const WindowInitialPlacement = types.WindowInitialPlacement;
79
85
  pub const WindowTitlebarStyle = types.WindowTitlebarStyle;
80
86
  pub const WindowChrome = types.WindowChrome;
81
87
  pub const FormFactor = types.FormFactor;
@@ -124,11 +130,16 @@ pub const MessageDialogStyle = types.MessageDialogStyle;
124
130
  pub const MessageDialogResult = types.MessageDialogResult;
125
131
  pub const MessageDialogOptions = types.MessageDialogOptions;
126
132
  pub const NotificationOptions = types.NotificationOptions;
133
+ pub const NotificationCommandEvent = types.NotificationCommandEvent;
127
134
  pub const CredentialKey = types.CredentialKey;
128
135
  pub const Credential = types.Credential;
129
136
  pub const LocalTimeStyle = types.LocalTimeStyle;
137
+ pub const StatusItemId = types.StatusItemId;
138
+ pub const primary_status_item_id = types.primary_status_item_id;
130
139
  pub const TrayItemId = types.TrayItemId;
131
140
  pub const TrayOptions = types.TrayOptions;
141
+ pub const TrayShell = types.TrayShell;
142
+ pub const trayShell = types.trayShell;
132
143
  pub const TrayTone = types.TrayTone;
133
144
  pub const TrayPresentation = types.TrayPresentation;
134
145
  pub const TrayMenuItem = types.TrayMenuItem;
@@ -136,6 +147,7 @@ pub const TrayItemRole = types.TrayItemRole;
136
147
  pub const NativeCommandEvent = types.NativeCommandEvent;
137
148
  pub const MenuCommandEvent = types.MenuCommandEvent;
138
149
  pub const TrayCommandEvent = types.TrayCommandEvent;
150
+ pub const TrayActionEvent = types.TrayActionEvent;
139
151
  pub const reserved_timer_id_base = types.reserved_timer_id_base;
140
152
  pub const press_hold_timer_id = types.press_hold_timer_id;
141
153
  pub const TimerEvent = types.TimerEvent;
@@ -243,6 +243,9 @@ pub const max_recent_document_path_bytes: usize = 4096;
243
243
  pub const max_notification_title_bytes: usize = 128;
244
244
  pub const max_notification_subtitle_bytes: usize = 128;
245
245
  pub const max_notification_body_bytes: usize = 1024;
246
+ pub const max_notification_id_bytes: usize = 128;
247
+ pub const max_notification_action_label_bytes: usize = 128;
248
+ pub const max_notification_action_command_bytes: usize = 128;
246
249
  pub const max_clipboard_mime_type_bytes: usize = 128;
247
250
  pub const max_clipboard_data_bytes: usize = 65536;
248
251
  pub const max_credential_service_bytes: usize = 128;
@@ -252,6 +255,10 @@ pub const max_credential_account_bytes: usize = 256;
252
255
  /// Every host accepts this whole range; none silently truncates it.
253
256
  pub const max_credential_secret_bytes: usize = 5 * 512;
254
257
  pub const max_local_time_text_bytes: usize = 512;
258
+ /// A desktop app may own a small bounded set of independent status items.
259
+ /// macOS implements the whole set; hosts whose tray API is singular accept
260
+ /// only `primary_status_item_id` and reject additional identifiers.
261
+ pub const max_status_items: usize = 8;
255
262
  pub const max_tray_items: usize = 32;
256
263
  pub const max_tray_icon_path_bytes: usize = 4096;
257
264
  pub const max_tray_title_bytes: usize = 64;
@@ -296,14 +303,20 @@ pub const max_gpu_surface_packet_binary_bytes: usize = 512 * 1024;
296
303
  /// packet present falls back because a command is not representable
297
304
  /// (fits every `CanvasCommand` tag name).
298
305
  pub const max_gpu_present_fallback_detail_bytes: usize = 32;
306
+ /// Longest decoded-image side accepted by the registered-image codec seam.
307
+ /// Source metadata may exceed this: conforming platform codecs combine this
308
+ /// axis ceiling with the caller's `max_pixels` area target and downsample
309
+ /// during decode. Keeping the decoded side bounded protects codec and GPU
310
+ /// upload paths from pathological panoramas without refusing them outright.
311
+ pub const max_decoded_image_dimension: usize = 8192;
299
312
  /// Per-image bound for the binary gpu-surface image upload side-channel;
300
- /// matches the runtime registry's per-slot bound
301
- /// (`canvas_limits.max_registered_canvas_image_pixel_bytes`). Applies to
302
- /// ORDINARY registered-image ids only: the registry refuses anything
303
- /// larger at registration, so an over-bound upload of a registered image
304
- /// can only be an engine bug and is refused loudly here rather than
305
- /// copied into host allocations.
306
- pub const max_gpu_surface_image_pixel_bytes: usize = 1024 * 1024;
313
+ /// matches the runtime registry's app-configurable ceiling
314
+ /// (`canvas_limits.max_registered_canvas_image_pixel_bytes_ceiling`).
315
+ /// Applies to ORDINARY registered-image ids only: the runtime's frozen
316
+ /// app budget may be lower, but anything it accepts must remain uploadable
317
+ /// on packet hosts. An upload past the SDK ceiling is still an engine bug
318
+ /// and is refused loudly rather than copied into host allocations.
319
+ pub const max_gpu_surface_image_pixel_bytes: usize = 8 * 1024 * 1024;
307
320
  /// Per-image bound for uploads in the media-surface texture namespace
308
321
  /// (ids with `canvas.media_surface_image_id_bit` set — producer-pushed
309
322
  /// dynamic textures, structurally disjoint from registered-image ids):
@@ -457,6 +470,16 @@ pub const WindowRestorePolicy = enum {
457
470
  center_on_primary,
458
471
  };
459
472
 
473
+ /// Why the host is receiving the window's initial frame. Persistence policy
474
+ /// (`restore_state`) is deliberately separate: only the state-store loader can
475
+ /// say `.restored`, while an authored x/y origin says `.explicit`; every other
476
+ /// fresh window uses `.default` platform placement.
477
+ pub const WindowInitialPlacement = enum {
478
+ restored,
479
+ explicit,
480
+ default,
481
+ };
482
+
460
483
  /// How the window draws its titlebar chrome.
461
484
  /// `.hidden_inset` is the modern editor-app shape: content extends under a
462
485
  /// transparent titlebar with the title hidden (macOS:
@@ -614,6 +637,7 @@ pub const WindowOptions = struct {
614
637
  resizable: bool = true,
615
638
  restore_state: bool = true,
616
639
  restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
640
+ initial_placement: WindowInitialPlacement = .default,
617
641
  titlebar: WindowTitlebarStyle = .standard,
618
642
  show: WindowShowMode = .immediate,
619
643
  /// Make the top-level window and its rendering surface alpha-capable.
@@ -708,6 +732,7 @@ pub const WindowCreateOptions = struct {
708
732
  resizable: bool = true,
709
733
  restore_state: bool = true,
710
734
  restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
735
+ initial_placement: WindowInitialPlacement = .default,
711
736
  titlebar: WindowTitlebarStyle = .standard,
712
737
  show: WindowShowMode = .immediate,
713
738
  transparent: bool = false,
@@ -732,6 +757,15 @@ pub const WindowCreateOptions = struct {
732
757
  .resizable = self.resizable,
733
758
  .restore_state = self.restore_state,
734
759
  .restore_policy = self.restore_policy,
760
+ // Preserve the historical direct-runtime shape where a non-zero
761
+ // `default_frame` origin meant explicit placement. Callers that
762
+ // intentionally need the visible-screen origin can state
763
+ // `.explicit`; optional-origin APIs already do so even at 0,0.
764
+ .initial_placement = if (self.initial_placement == .default and
765
+ (self.default_frame.x != 0 or self.default_frame.y != 0))
766
+ .explicit
767
+ else
768
+ self.initial_placement,
735
769
  .titlebar = self.titlebar,
736
770
  .show = self.show,
737
771
  .transparent = self.transparent,
@@ -1256,9 +1290,14 @@ pub const AppInfo = struct {
1256
1290
  /// built-in re-show affordance: hiding a window on windows removes
1257
1291
  /// its taskbar entry and windows has no dock-reopen path, so only a
1258
1292
  /// tray icon can bring the hidden window back. The Windows host
1259
- /// folds this into its `window_hide_on_close` answer; macOS ignores
1260
- /// it (the Dock reopen path always exists).
1293
+ /// folds this into its `window_hide_on_close` answer. On macOS the
1294
+ /// Dock is a reopen path only while `dock_visible` is true; manifest
1295
+ /// validation therefore requires a tray for accessory startup.
1261
1296
  declares_tray: bool = false,
1297
+ /// Initial Dock/app-switcher presence. The macOS hosts translate
1298
+ /// false to Accessory before configuring the app or creating its
1299
+ /// startup window; `setDockPresence` can change it later.
1300
+ dock_visible: bool = true,
1262
1301
  window_title: []const u8 = "",
1263
1302
  bundle_id: []const u8 = "dev.native_sdk.app",
1264
1303
  icon_path: []const u8 = "",
@@ -1282,6 +1321,7 @@ pub const AppInfo = struct {
1282
1321
  pub fn resolvedMainWindow(self: AppInfo) WindowOptions {
1283
1322
  var window = self.main_window;
1284
1323
  if (window.title.len == 0) window.title = self.resolvedWindowTitle();
1324
+ inferLegacyExplicitOrigin(&window);
1285
1325
  return window;
1286
1326
  }
1287
1327
 
@@ -1296,8 +1336,17 @@ pub const AppInfo = struct {
1296
1336
  }
1297
1337
  if (window.label.len == 0) window.label = if (index == 0) "main" else "window";
1298
1338
  if (window.title.len == 0) window.title = self.resolvedWindowTitle();
1339
+ inferLegacyExplicitOrigin(&window);
1299
1340
  return window;
1300
1341
  }
1342
+
1343
+ fn inferLegacyExplicitOrigin(window: *WindowOptions) void {
1344
+ if (window.initial_placement == .default and
1345
+ (window.default_frame.x != 0 or window.default_frame.y != 0))
1346
+ {
1347
+ window.initial_placement = .explicit;
1348
+ }
1349
+ }
1301
1350
  };
1302
1351
 
1303
1352
  pub const Surface = struct {
@@ -1372,9 +1421,17 @@ pub const MessageDialogOptions = struct {
1372
1421
  };
1373
1422
 
1374
1423
  pub const NotificationOptions = struct {
1424
+ /// Stable host identity. Reissuing a non-empty id replaces the
1425
+ /// notification with that id and its action binding.
1426
+ id: []const u8 = "",
1375
1427
  title: []const u8,
1376
1428
  subtitle: []const u8 = "",
1377
1429
  body: []const u8 = "",
1430
+ /// Action fields are paired: both empty means display-only; both
1431
+ /// non-empty presents the label and routes activation as an ordinary
1432
+ /// application command.
1433
+ action_label: []const u8 = "",
1434
+ action_command: []const u8 = "",
1378
1435
  };
1379
1436
 
1380
1437
  pub const CredentialKey = struct {
@@ -1397,6 +1454,8 @@ pub const LocalTimeStyle = enum(u8) {
1397
1454
  datetime,
1398
1455
  };
1399
1456
 
1457
+ pub const StatusItemId = u32;
1458
+ pub const primary_status_item_id: StatusItemId = 1;
1400
1459
  pub const TrayItemId = u32;
1401
1460
 
1402
1461
  /// Visual emphasis for the menu-bar button's live presentation. Hosts
@@ -1426,6 +1485,9 @@ pub const TrayOptions = struct {
1426
1485
  /// `NSStatusItem` menu-bar extras render it directly in the menu bar).
1427
1486
  title: []const u8 = "",
1428
1487
  tooltip: []const u8 = "",
1488
+ /// Whether the native item occupies the menu bar/tray. False preserves
1489
+ /// its native identity so making it visible again does not reshuffle it.
1490
+ visible: bool = true,
1429
1491
  items: []const TrayMenuItem = &.{},
1430
1492
  presentation: TrayPresentation = .{},
1431
1493
  /// Ordinary click, Option-click, and menu-open hooks. Each command
@@ -1435,6 +1497,29 @@ pub const TrayOptions = struct {
1435
1497
  open_command: []const u8 = "",
1436
1498
  };
1437
1499
 
1500
+ /// The independently live shell fields of a status item. Presentation and
1501
+ /// menu have their own patch seams so changing this state never rebuilds a
1502
+ /// menu and changing a menu never recreates the native item.
1503
+ pub const TrayShell = struct {
1504
+ icon_path: []const u8 = "",
1505
+ tooltip: []const u8 = "",
1506
+ visible: bool = true,
1507
+ activation_command: []const u8 = "",
1508
+ alternate_activation_command: []const u8 = "",
1509
+ open_command: []const u8 = "",
1510
+ };
1511
+
1512
+ pub fn trayShell(options: TrayOptions) TrayShell {
1513
+ return .{
1514
+ .icon_path = options.icon_path,
1515
+ .tooltip = options.tooltip,
1516
+ .visible = options.visible,
1517
+ .activation_command = options.activation_command,
1518
+ .alternate_activation_command = options.alternate_activation_command,
1519
+ .open_command = options.open_command,
1520
+ };
1521
+ }
1522
+
1438
1523
  /// Semantic status-menu rows. `command` is the ordinary actionable row;
1439
1524
  /// the others let a capable host render readouts without presenting them
1440
1525
  /// as disabled actions. Hosts without rich-menu support may degrade them
@@ -1477,6 +1562,22 @@ pub const MenuCommandEvent = struct {
1477
1562
  pub const TrayCommandEvent = struct {
1478
1563
  name: []const u8,
1479
1564
  window_id: WindowId = 1,
1565
+ status_item_id: StatusItemId = primary_status_item_id,
1566
+ };
1567
+
1568
+ /// A notification action activated while the app process is live. The
1569
+ /// platform keeps replacement identity private; only the validated command
1570
+ /// crosses into the runtime, where it follows the normal command path.
1571
+ pub const NotificationCommandEvent = struct {
1572
+ name: []const u8,
1573
+ window_id: WindowId = 1,
1574
+ };
1575
+
1576
+ /// A selected row is namespaced by its owning status item. Row ids only
1577
+ /// need to be unique inside one menu.
1578
+ pub const TrayActionEvent = struct {
1579
+ status_item_id: StatusItemId = primary_status_item_id,
1580
+ item_id: TrayItemId,
1480
1581
  };
1481
1582
 
1482
1583
  /// Timer ids at or above this value are reserved for the framework's own
@@ -2289,6 +2390,7 @@ pub const WidgetAccessibilityRole = enum(c_int) {
2289
2390
  slider = 18,
2290
2391
  progressbar = 19,
2291
2392
  radio = 20,
2393
+ radiogroup = 21,
2292
2394
  };
2293
2395
 
2294
2396
  pub const WidgetAccessibilityActions = struct {
@@ -2420,11 +2522,12 @@ pub const Event = union(enum) {
2420
2522
  window_focused: WindowId,
2421
2523
  view_focused: ViewFocusEvent,
2422
2524
  bridge_message: BridgeMessage,
2423
- tray_action: TrayItemId,
2525
+ tray_action: TrayActionEvent,
2424
2526
  shortcut: ShortcutEvent,
2425
2527
  native_command: NativeCommandEvent,
2426
2528
  menu_command: MenuCommandEvent,
2427
2529
  tray_command: TrayCommandEvent,
2530
+ notification_command: NotificationCommandEvent,
2428
2531
  timer: TimerEvent,
2429
2532
  /// A cross-thread nudge posted through `PlatformServices.wake_fn`:
2430
2533
  /// worker threads (effect executors) ask the platform loop to deliver
@@ -2463,6 +2566,7 @@ pub const Event = union(enum) {
2463
2566
  .native_command => "native_command",
2464
2567
  .menu_command => "menu_command",
2465
2568
  .tray_command => "tray_command",
2569
+ .notification_command => "notification_command",
2466
2570
  .timer => "timer",
2467
2571
  .wake => "wake",
2468
2572
  .files_dropped => "files_dropped",
@@ -2613,11 +2717,12 @@ pub const PlatformServices = struct {
2613
2717
  reveal_path_fn: ?*const fn (context: ?*anyopaque, path: []const u8) anyerror!void = null,
2614
2718
  add_recent_document_fn: ?*const fn (context: ?*anyopaque, path: []const u8) anyerror!void = null,
2615
2719
  clear_recent_documents_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2616
- create_tray_fn: ?*const fn (context: ?*anyopaque, options: TrayOptions) anyerror!void = null,
2617
- update_tray_menu_fn: ?*const fn (context: ?*anyopaque, items: []const TrayMenuItem) anyerror!void = null,
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,
2620
- remove_tray_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2720
+ create_tray_fn: ?*const fn (context: ?*anyopaque, status_item_id: StatusItemId, options: TrayOptions) anyerror!void = null,
2721
+ update_tray_shell_fn: ?*const fn (context: ?*anyopaque, status_item_id: StatusItemId, shell: TrayShell) anyerror!void = null,
2722
+ update_tray_menu_fn: ?*const fn (context: ?*anyopaque, status_item_id: StatusItemId, items: []const TrayMenuItem) anyerror!void = null,
2723
+ update_tray_title_fn: ?*const fn (context: ?*anyopaque, status_item_id: StatusItemId, title: []const u8) anyerror!void = null,
2724
+ update_tray_presentation_fn: ?*const fn (context: ?*anyopaque, status_item_id: StatusItemId, presentation: TrayPresentation) anyerror!void = null,
2725
+ remove_tray_fn: ?*const fn (context: ?*anyopaque, status_item_id: StatusItemId) anyerror!void = null,
2621
2726
  configure_security_policy_fn: ?*const fn (context: ?*anyopaque, policy: security.Policy) anyerror!void = null,
2622
2727
  configure_menus_fn: ?*const fn (context: ?*anyopaque, menus: []const Menu) anyerror!void = null,
2623
2728
  configure_shortcuts_fn: ?*const fn (context: ?*anyopaque, shortcuts: []const Shortcut) anyerror!void = null,
@@ -2888,12 +2993,16 @@ pub const PlatformServices = struct {
2888
2993
  /// framework bundles no image decoders: macOS decodes through
2889
2994
  /// CGImageSource (ImageIO), GTK through gdk-pixbuf, Win32 through WIC.
2890
2995
  /// Implementations may use `buffer` as decode scratch, so callers size
2891
- /// it for their pixel bound, not the exact image. Errors:
2996
+ /// it for their pixel bound, not the exact image. `max_pixels` is a
2997
+ /// pixel-count cap, not a width/height box: codecs preserve aspect and
2998
+ /// decode down when source pixels exceed it or either decoded side would
2999
+ /// exceed `max_decoded_image_dimension`. Errors:
2892
3000
  /// `error.ImageDecodeFailed` for undecodable bytes,
2893
- /// `error.ImageTooLarge` when the decoded pixels do not fit `buffer`.
3001
+ /// `error.ImageTooLarge` when the fitted pixels violate either bound or
3002
+ /// do not fit `buffer`.
2894
3003
  /// Null on platforms without a codec (the null platform by default),
2895
3004
  /// which surfaces as `error.UnsupportedService`.
2896
- decode_image_fn: ?*const fn (context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!DecodedImage = null,
3005
+ decode_image_fn: ?*const fn (context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!DecodedImage = null,
2897
3006
 
2898
3007
  pub fn readClipboard(self: PlatformServices, buffer: []u8) anyerror![]const u8 {
2899
3008
  const read_fn = self.read_clipboard_fn orelse return error.UnsupportedService;
@@ -3181,36 +3290,63 @@ pub const PlatformServices = struct {
3181
3290
  return clear_fn(self.context);
3182
3291
  }
3183
3292
 
3184
- pub fn createTray(self: PlatformServices, options: TrayOptions) anyerror!void {
3293
+ pub fn createStatusItem(self: PlatformServices, status_item_id: StatusItemId, options: TrayOptions) anyerror!void {
3185
3294
  const tray_fn = self.create_tray_fn orelse return error.UnsupportedService;
3186
- return tray_fn(self.context, options);
3295
+ return tray_fn(self.context, status_item_id, options);
3187
3296
  }
3188
3297
 
3189
- pub fn updateTrayMenu(self: PlatformServices, items: []const TrayMenuItem) anyerror!void {
3298
+ pub fn updateStatusItemShell(self: PlatformServices, status_item_id: StatusItemId, shell: TrayShell) anyerror!void {
3299
+ const update_fn = self.update_tray_shell_fn orelse return error.UnsupportedService;
3300
+ return update_fn(self.context, status_item_id, shell);
3301
+ }
3302
+
3303
+ pub fn updateStatusItemMenu(self: PlatformServices, status_item_id: StatusItemId, items: []const TrayMenuItem) anyerror!void {
3190
3304
  const update_fn = self.update_tray_menu_fn orelse return error.UnsupportedService;
3191
- return update_fn(self.context, items);
3305
+ return update_fn(self.context, status_item_id, items);
3192
3306
  }
3193
3307
 
3194
3308
  /// Retitle the live status-bar button without re-creating the item
3195
3309
  /// (re-creating flickers and can reshuffle the macOS menu bar). Added
3196
3310
  /// for model-driven tray state (e.g. an open-count badge in the
3197
3311
  /// title).
3198
- pub fn updateTrayTitle(self: PlatformServices, title: []const u8) anyerror!void {
3312
+ pub fn updateStatusItemTitle(self: PlatformServices, status_item_id: StatusItemId, title: []const u8) anyerror!void {
3199
3313
  const title_fn = self.update_tray_title_fn orelse return error.UnsupportedService;
3200
- return title_fn(self.context, title);
3314
+ return title_fn(self.context, status_item_id, title);
3201
3315
  }
3202
3316
 
3203
3317
  /// Patch all live menu-bar presentation fields without recreating the
3204
3318
  /// native item. A host that only implements title updates still gets a
3205
3319
  /// correct title and intentionally degrades the richer styling.
3320
+ pub fn updateStatusItemPresentation(self: PlatformServices, status_item_id: StatusItemId, presentation: TrayPresentation) anyerror!void {
3321
+ if (self.update_tray_presentation_fn) |update_fn| return update_fn(self.context, status_item_id, presentation);
3322
+ return self.updateStatusItemTitle(status_item_id, presentation.title);
3323
+ }
3324
+
3325
+ pub fn removeStatusItem(self: PlatformServices, status_item_id: StatusItemId) anyerror!void {
3326
+ const remove_fn = self.remove_tray_fn orelse return error.UnsupportedService;
3327
+ return remove_fn(self.context, status_item_id);
3328
+ }
3329
+
3330
+ // Backward-compatible singular tray surface. The reserved primary id is
3331
+ // the exact item older apps have always addressed implicitly.
3332
+ pub fn createTray(self: PlatformServices, options: TrayOptions) anyerror!void {
3333
+ return self.createStatusItem(primary_status_item_id, options);
3334
+ }
3335
+
3336
+ pub fn updateTrayMenu(self: PlatformServices, items: []const TrayMenuItem) anyerror!void {
3337
+ return self.updateStatusItemMenu(primary_status_item_id, items);
3338
+ }
3339
+
3340
+ pub fn updateTrayTitle(self: PlatformServices, title: []const u8) anyerror!void {
3341
+ return self.updateStatusItemTitle(primary_status_item_id, title);
3342
+ }
3343
+
3206
3344
  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);
3345
+ return self.updateStatusItemPresentation(primary_status_item_id, presentation);
3209
3346
  }
3210
3347
 
3211
3348
  pub fn removeTray(self: PlatformServices) anyerror!void {
3212
- const remove_fn = self.remove_tray_fn orelse return error.UnsupportedService;
3213
- return remove_fn(self.context);
3349
+ return self.removeStatusItem(primary_status_item_id);
3214
3350
  }
3215
3351
 
3216
3352
  pub fn configureSecurityPolicy(self: PlatformServices, policy: security.Policy) anyerror!void {
@@ -3452,11 +3588,10 @@ pub const PlatformServices = struct {
3452
3588
  // Two honest bounds, keyed by the id namespace: hosts copy every
3453
3589
  // upload into host-owned allocations (AppKit's NSData + NSImage
3454
3590
  // store), so each bound teaches the real cost of its id space.
3455
- // Ordinary registered images are avatar-scale by the registry's
3456
- // own slot bound; media-surface textures (the reserved high-bit
3457
- // namespace) are video-scale by the producer channel's frame
3458
- // budget — the bound the producer already enforced, so nothing a
3459
- // producer staged can fail here.
3591
+ // Ordinary registered images use the registry's configurable
3592
+ // ceiling; media-surface textures (the reserved high-bit namespace)
3593
+ // use the producer channel's frame budget — the bound the producer
3594
+ // already enforced, so nothing either source accepted can fail here.
3460
3595
  const bound = if ((image.id & canvas.media_surface_image_id_bit) != 0)
3461
3596
  max_gpu_surface_media_image_pixel_bytes
3462
3597
  else
@@ -3500,10 +3635,14 @@ pub const PlatformServices = struct {
3500
3635
 
3501
3636
  /// Decode encoded image bytes through the platform codec into
3502
3637
  /// straight-alpha RGBA8 (see `decode_image_fn`). Loop-thread only.
3503
- pub fn decodeImage(self: PlatformServices, bytes: []const u8, buffer: []u8) anyerror!DecodedImage {
3638
+ pub fn decodeImage(self: PlatformServices, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!DecodedImage {
3504
3639
  if (bytes.len == 0) return error.ImageDecodeFailed;
3640
+ if (max_pixels == 0) return error.ImageTooLarge;
3505
3641
  const decode_fn = self.decode_image_fn orelse return error.UnsupportedService;
3506
- return decode_fn(self.context, bytes, buffer);
3642
+ const decoded = try decode_fn(self.context, bytes, buffer, max_pixels);
3643
+ const pixels = std.math.mul(usize, decoded.width, decoded.height) catch return error.ImageTooLarge;
3644
+ if (decoded.width > max_decoded_image_dimension or decoded.height > max_decoded_image_dimension or pixels > max_pixels) return error.ImageTooLarge;
3645
+ return decoded;
3507
3646
  }
3508
3647
  };
3509
3648
 
@@ -41,6 +41,7 @@ const WindowsEventKind = enum(c_int) {
41
41
  context_menu_action = 19,
42
42
  view_focused = 20,
43
43
  tray_command = 21,
44
+ notification_command = 22,
44
45
  };
45
46
 
46
47
  const WindowsEvent = extern struct {
@@ -134,13 +135,13 @@ const shortcut_modifier_control: u32 = 1 << 2;
134
135
  const shortcut_modifier_option: u32 = 1 << 3;
135
136
  const shortcut_modifier_shift: u32 = 1 << 4;
136
137
 
137
- extern fn native_sdk_windows_create(app_name: [*]const u8, app_name_len: usize, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) ?*WindowsHost;
138
+ extern fn native_sdk_windows_create(app_name: [*]const u8, app_name_len: usize, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, initial_placement: c_int, restore_policy: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) ?*WindowsHost;
138
139
  extern fn native_sdk_windows_destroy(host: *WindowsHost) void;
139
140
  extern fn native_sdk_windows_run(host: *WindowsHost, callback: WindowsCallback, context: ?*anyopaque) void;
140
141
  extern fn native_sdk_windows_stop(host: *WindowsHost) void;
141
142
  extern fn native_sdk_windows_wake(host: *WindowsHost) void;
142
143
  extern fn native_sdk_windows_request_frame(host: *WindowsHost) void;
143
- extern fn native_sdk_windows_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, out_width: *usize, out_height: *usize) c_int;
144
+ extern fn native_sdk_windows_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, max_pixels: usize, out_width: *usize, out_height: *usize) c_int;
144
145
  extern fn native_sdk_windows_load_webview(host: *WindowsHost, source: [*]const u8, source_len: usize, source_kind: c_int, asset_root: [*]const u8, asset_root_len: usize, asset_entry: [*]const u8, asset_entry_len: usize, asset_origin: [*]const u8, asset_origin_len: usize, spa_fallback: c_int) void;
145
146
  extern fn native_sdk_windows_load_window_webview(host: *WindowsHost, window_id: u64, source: [*]const u8, source_len: usize, source_kind: c_int, asset_root: [*]const u8, asset_root_len: usize, asset_entry: [*]const u8, asset_entry_len: usize, asset_origin: [*]const u8, asset_origin_len: usize, spa_fallback: c_int) c_int;
146
147
  extern fn native_sdk_windows_set_bridge_callback(host: *WindowsHost, callback: WindowsBridgeCallback, context: ?*anyopaque) void;
@@ -151,7 +152,7 @@ extern fn native_sdk_windows_emit_window_event(host: *WindowsHost, window_id: u6
151
152
  extern fn native_sdk_windows_set_security_policy(host: *WindowsHost, allowed_origins: [*]const u8, allowed_origins_len: usize, external_urls: [*]const u8, external_urls_len: usize, external_action: c_int) void;
152
153
  extern fn native_sdk_windows_set_menus(host: *WindowsHost, menu_titles: [*]const [*]const u8, menu_title_lens: [*]const usize, menu_count: usize, item_menu_indices: [*]const u32, item_labels: [*]const [*]const u8, item_label_lens: [*]const usize, item_commands: [*]const [*]const u8, item_command_lens: [*]const usize, item_keys: [*]const [*]const u8, item_key_lens: [*]const usize, item_modifiers: [*]const u32, item_separators: [*]const c_int, item_enabled: [*]const c_int, item_checked: [*]const c_int, item_count: usize) c_int;
153
154
  extern fn native_sdk_windows_set_shortcuts(host: *WindowsHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
154
- extern fn native_sdk_windows_create_window(host: *WindowsHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) c_int;
155
+ extern fn native_sdk_windows_create_window(host: *WindowsHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, initial_placement: c_int, restore_policy: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) c_int;
155
156
  extern fn native_sdk_windows_start_window_drag(host: *WindowsHost, window_id: u64) c_int;
156
157
  extern fn native_sdk_windows_set_window_drag_regions(host: *WindowsHost, window_id: u64, label: [*]const u8, label_len: usize, rects: [*]const f64, exclusions: [*]const c_int, count: usize) c_int;
157
158
  extern fn native_sdk_windows_window_chrome(host: *WindowsHost, window_id: u64, top: *f64, left: *f64, bottom: *f64, right: *f64, buttons_x: *f64, buttons_y: *f64, buttons_width: *f64, buttons_height: *f64) c_int;
@@ -188,7 +189,7 @@ extern fn native_sdk_windows_reveal_path(host: *WindowsHost, path: [*]const u8,
188
189
  extern fn native_sdk_windows_show_open_dialog(host: *WindowsHost, opts: *const WindowsOpenDialogOpts, buffer: [*]u8, buffer_len: usize) WindowsOpenDialogResult;
189
190
  extern fn native_sdk_windows_show_save_dialog(host: *WindowsHost, opts: *const WindowsSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
190
191
  extern fn native_sdk_windows_show_message_dialog(host: *WindowsHost, opts: *const WindowsMessageDialogOpts) c_int;
191
- extern fn native_sdk_windows_show_notification(host: *WindowsHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize) c_int;
192
+ extern fn native_sdk_windows_show_notification(host: *WindowsHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize, notification_id: [*]const u8, notification_id_len: usize, action_label: [*]const u8, action_label_len: usize, action_command: [*]const u8, action_command_len: usize) c_int;
192
193
  extern fn native_sdk_windows_create_tray(host: *WindowsHost, icon_path: [*]const u8, icon_path_len: usize, tooltip: [*]const u8, tooltip_len: usize, activation_command: [*]const u8, activation_command_len: usize, alternate_activation_command: [*]const u8, alternate_activation_command_len: usize, open_command: [*]const u8, open_command_len: usize) c_int;
193
194
  extern fn native_sdk_windows_update_tray_menu(host: *WindowsHost, item_ids: [*]const u32, labels: [*]const [*]const u8, label_lens: [*]const usize, separators: [*]const c_int, enabled_flags: [*]const c_int, details: [*]const [*]const u8, detail_lens: [*]const usize, roles: [*]const c_int, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) c_int;
194
195
  extern fn native_sdk_windows_remove_tray(host: *WindowsHost) void;
@@ -343,7 +344,7 @@ pub const WindowsPlatform = struct {
343
344
  try refuseUnsupportedTransparentWindow(window_options, false);
344
345
  const window_title = window_options.resolvedTitle(app_info.app_name);
345
346
  const frame = window_options.default_frame;
346
- const host = native_sdk_windows_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
347
+ const host = native_sdk_windows_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, initialPlacementInt(window_options.initial_placement), restorePolicyInt(window_options.restore_policy), if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
347
348
  // Packet text must use the same Geist metrics the engine planned
348
349
  // against. Register both built-in faces directly from their
349
350
  // compile-time bytes; custom application fonts keep the public
@@ -675,11 +676,15 @@ fn windowsCallback(context: ?*anyopaque, event: *const WindowsEvent) callconv(.c
675
676
  .name = event.command_name[0..event.command_name_len],
676
677
  .window_id = event.window_id,
677
678
  } }),
678
- .tray_action => state.emit(.{ .tray_action = event.tray_item_id }),
679
+ .tray_action => state.emit(.{ .tray_action = .{ .item_id = event.tray_item_id } }),
679
680
  .tray_command => state.emit(.{ .tray_command = .{
680
681
  .name = event.command_name[0..event.command_name_len],
681
682
  .window_id = event.window_id,
682
683
  } }),
684
+ .notification_command => state.emit(.{ .notification_command = .{
685
+ .name = event.command_name[0..event.command_name_len],
686
+ .window_id = event.window_id,
687
+ } }),
683
688
  .gpu_surface_frame => state.emit(.{ .gpu_surface_frame = gpuSurfaceFrameEventFromWindowsEvent(event) }),
684
689
  .gpu_surface_resize => state.emit(.{ .gpu_surface_resized = .{
685
690
  .window_id = event.window_id,
@@ -918,11 +923,11 @@ pub fn installHeadlessImageCodec(services: *platform_mod.PlatformServices) void
918
923
 
919
924
  /// WIC-backed image decoding (PNG, JPEG, ... — every codec the OS
920
925
  /// ships) into straight-alpha RGBA8.
921
- fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
926
+ fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
922
927
  _ = context;
923
928
  var width: usize = 0;
924
929
  var height: usize = 0;
925
- return switch (native_sdk_windows_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
930
+ return switch (native_sdk_windows_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
926
931
  1 => .{ .width = width, .height = height, .rgba8 = buffer[0 .. width * height * 4] },
927
932
  -1 => error.ImageTooLarge,
928
933
  else => error.ImageDecodeFailed,
@@ -938,6 +943,21 @@ fn titlebarStyleInt(style: platform_mod.WindowTitlebarStyle) c_int {
938
943
  };
939
944
  }
940
945
 
946
+ fn initialPlacementInt(placement: platform_mod.WindowInitialPlacement) c_int {
947
+ return switch (placement) {
948
+ .restored => 0,
949
+ .explicit => 1,
950
+ .default => 2,
951
+ };
952
+ }
953
+
954
+ fn restorePolicyInt(policy: platform_mod.WindowRestorePolicy) c_int {
955
+ return switch (policy) {
956
+ .clamp_to_visible_screen => 0,
957
+ .center_on_primary => 1,
958
+ };
959
+ }
960
+
941
961
  fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
942
962
  return switch (mode) {
943
963
  .immediate => 0,
@@ -981,7 +1001,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
981
1001
  try refuseUnsupportedTransparentWindow(options, self.menus_active);
982
1002
  const title = options.resolvedTitle(self.app_info.app_name);
983
1003
  const frame = options.default_frame;
984
- if (native_sdk_windows_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), minSizeFloor(options.min_width), minSizeFloor(options.min_height), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
1004
+ if (native_sdk_windows_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, initialPlacementInt(options.initial_placement), restorePolicyInt(options.restore_policy), if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), minSizeFloor(options.min_width), minSizeFloor(options.min_height), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
985
1005
  applyWindowClosePolicy(self.host, options.id, options.close_policy);
986
1006
  return .{
987
1007
  .id = options.id,
@@ -1488,13 +1508,20 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
1488
1508
  options.subtitle.len,
1489
1509
  options.body.ptr,
1490
1510
  options.body.len,
1511
+ options.id.ptr,
1512
+ options.id.len,
1513
+ options.action_label.ptr,
1514
+ options.action_label.len,
1515
+ options.action_command.ptr,
1516
+ options.action_command.len,
1491
1517
  ) == 0) return error.UnsupportedService;
1492
1518
  }
1493
1519
 
1494
1520
  const max_tray_items: usize = 32;
1495
1521
 
1496
- fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
1522
+ fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
1497
1523
  const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1524
+ if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
1498
1525
  if (self.web_engine != .system) return error.UnsupportedService;
1499
1526
  if (native_sdk_windows_create_tray(
1500
1527
  self.host,
@@ -1510,12 +1537,13 @@ fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!
1510
1537
  options.open_command.len,
1511
1538
  ) == 0) return error.UnsupportedService;
1512
1539
  if (options.items.len > 0) {
1513
- try updateTrayMenu(context, options.items);
1540
+ try updateTrayMenu(context, status_item_id, options.items);
1514
1541
  }
1515
1542
  }
1516
1543
 
1517
- fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem) anyerror!void {
1544
+ fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, items: []const platform_mod.TrayMenuItem) anyerror!void {
1518
1545
  const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1546
+ if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
1519
1547
  if (self.web_engine != .system) return error.UnsupportedService;
1520
1548
  const count = @min(items.len, max_tray_items);
1521
1549
  var ids: [max_tray_items]u32 = undefined;
@@ -1556,8 +1584,9 @@ fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem
1556
1584
  if (native_sdk_windows_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count) == 0) return error.UnsupportedService;
1557
1585
  }
1558
1586
 
1559
- fn removeTray(context: ?*anyopaque) anyerror!void {
1587
+ fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
1560
1588
  const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1589
+ if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
1561
1590
  if (self.web_engine != .system) return error.UnsupportedService;
1562
1591
  native_sdk_windows_remove_tray(self.host);
1563
1592
  }