@native-sdk/cli 0.5.3 → 0.6.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 (172) hide show
  1. package/build/app.zig +91 -2
  2. package/build.zig +756 -5
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +19 -1
  5. package/package.json +9 -9
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/rt/rt.zig +416 -9
  9. package/packages/core/sdk/core.ts +706 -5
  10. package/packages/core/sdk/events.ts +17 -8
  11. package/packages/core/src/checker.ts +305 -2
  12. package/packages/core/src/diagnostics.ts +12 -0
  13. package/packages/core/src/emitter.ts +3187 -264
  14. package/packages/core/src/typed_ast.ts +51 -4
  15. package/packages/core/src/types.ts +34 -1
  16. package/skill-data/native-ui/SKILL.md +42 -4
  17. package/skill-data/ts-core/SKILL.md +13 -3
  18. package/src/app_runner/root.zig +112 -10
  19. package/src/app_runner/ts_core_main.zig +4 -0
  20. package/src/automation/layout_fingerprint.zig +160 -0
  21. package/src/automation/protocol.zig +82 -33
  22. package/src/automation/root.zig +1 -0
  23. package/src/automation/server.zig +1 -1
  24. package/src/automation/snapshot.zig +68 -9
  25. package/src/automation/watcher.zig +1 -1
  26. package/src/embed/host.zig +5 -0
  27. package/src/embed/tests.zig +119 -1
  28. package/src/embed/ui_host.zig +13 -0
  29. package/src/platform/linux/gtk_host.c +639 -16
  30. package/src/platform/linux/gtk_host.h +25 -0
  31. package/src/platform/linux/root.zig +351 -7
  32. package/src/platform/macos/appkit_host.h +152 -8
  33. package/src/platform/macos/appkit_host.m +1816 -100
  34. package/src/platform/macos/cef_host.mm +372 -11
  35. package/src/platform/macos/root.zig +379 -11
  36. package/src/platform/null_platform.zig +696 -9
  37. package/src/platform/null_platform_tests.zig +35 -0
  38. package/src/platform/root.zig +42 -0
  39. package/src/platform/types.zig +524 -18
  40. package/src/platform/windows/root.zig +432 -9
  41. package/src/platform/windows/webview2_host.cpp +482 -45
  42. package/src/primitives/app_manifest/comptime_scene.zig +5 -0
  43. package/src/primitives/app_manifest/root.zig +1 -0
  44. package/src/primitives/app_manifest/types.zig +32 -0
  45. package/src/primitives/app_manifest/validation.zig +18 -0
  46. package/src/primitives/canvas/a11y_audit.zig +33 -11
  47. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  48. package/src/primitives/canvas/drawing.zig +25 -0
  49. package/src/primitives/canvas/equality.zig +8 -0
  50. package/src/primitives/canvas/events.zig +103 -16
  51. package/src/primitives/canvas/frame.zig +125 -1
  52. package/src/primitives/canvas/layout_audit.zig +22 -5
  53. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  54. package/src/primitives/canvas/render_tests.zig +13 -10
  55. package/src/primitives/canvas/root.zig +48 -0
  56. package/src/primitives/canvas/terminal_box.zig +471 -0
  57. package/src/primitives/canvas/terminal_grid.zig +978 -0
  58. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  59. package/src/primitives/canvas/test_support.zig +1 -0
  60. package/src/primitives/canvas/tests.zig +2 -0
  61. package/src/primitives/canvas/text_tests.zig +39 -4
  62. package/src/primitives/canvas/tokens.zig +115 -12
  63. package/src/primitives/canvas/ui.zig +535 -12
  64. package/src/primitives/canvas/ui_markup.zig +253 -36
  65. package/src/primitives/canvas/ui_markup_binary.zig +4 -1
  66. package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
  67. package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
  68. package/src/primitives/canvas/ui_markup_contract.zig +89 -6
  69. package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
  70. package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
  71. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  72. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  73. package/src/primitives/canvas/ui_markup_tests.zig +178 -9
  74. package/src/primitives/canvas/ui_markup_view.zig +220 -11
  75. package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
  76. package/src/primitives/canvas/ui_schema.zig +110 -17
  77. package/src/primitives/canvas/ui_schema_tests.zig +18 -10
  78. package/src/primitives/canvas/ui_tests.zig +141 -9
  79. package/src/primitives/canvas/widget_access.zig +28 -2
  80. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  81. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  82. package/src/primitives/canvas/widget_layout.zig +59 -11
  83. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  84. package/src/primitives/canvas/widget_render.zig +272 -18
  85. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  86. package/src/primitives/canvas/widget_routing.zig +59 -7
  87. package/src/primitives/canvas/widget_runtime.zig +23 -0
  88. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  89. package/src/primitives/canvas/widget_semantics.zig +119 -11
  90. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  91. package/src/primitives/canvas/widget_tree.zig +17 -0
  92. package/src/primitives/canvas/widgets.zig +132 -0
  93. package/src/root.zig +23 -0
  94. package/src/runtime/api.zig +76 -5
  95. package/src/runtime/automation_commands.zig +20 -1
  96. package/src/runtime/automation_snapshot.zig +25 -1
  97. package/src/runtime/automation_widget_dispatch.zig +73 -8
  98. package/src/runtime/bridge_payload.zig +8 -0
  99. package/src/runtime/bridge_responses.zig +5 -0
  100. package/src/runtime/builtin_bridge.zig +9 -4
  101. package/src/runtime/canvas_font_tests.zig +439 -2
  102. package/src/runtime/canvas_fonts.zig +61 -6
  103. package/src/runtime/canvas_frame.zig +62 -7
  104. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  105. package/src/runtime/canvas_frame_helpers.zig +190 -1
  106. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  107. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  108. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  109. package/src/runtime/canvas_image_tests.zig +195 -0
  110. package/src/runtime/canvas_images.zig +45 -12
  111. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  112. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  113. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  114. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  115. package/src/runtime/canvas_widget_display.zig +1 -1
  116. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  117. package/src/runtime/canvas_widget_events.zig +240 -24
  118. package/src/runtime/canvas_widget_runtime.zig +213 -29
  119. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  120. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  121. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  122. package/src/runtime/canvas_widget_state.zig +6 -0
  123. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  124. package/src/runtime/core.zig +131 -13
  125. package/src/runtime/effects.zig +8136 -180
  126. package/src/runtime/effects_channel_tests.zig +3519 -0
  127. package/src/runtime/effects_fetch_tests.zig +89 -1
  128. package/src/runtime/effects_file_tests.zig +41 -1
  129. package/src/runtime/effects_image_tests.zig +1304 -0
  130. package/src/runtime/effects_pty_tests.zig +1362 -0
  131. package/src/runtime/effects_tests.zig +167 -9
  132. package/src/runtime/effects_video_tests.zig +3609 -0
  133. package/src/runtime/flow.zig +42 -4
  134. package/src/runtime/gpu_surface_events.zig +473 -13
  135. package/src/runtime/media_surface.zig +116 -11
  136. package/src/runtime/media_surface_tests.zig +61 -0
  137. package/src/runtime/pty.zig +1252 -0
  138. package/src/runtime/pty_windows.zig +1780 -0
  139. package/src/runtime/root.zig +36 -0
  140. package/src/runtime/runtime_event_tests.zig +20 -1
  141. package/src/runtime/session_blobs.zig +689 -0
  142. package/src/runtime/session_journal.zig +432 -62
  143. package/src/runtime/session_record.zig +43 -2
  144. package/src/runtime/session_replay.zig +556 -20
  145. package/src/runtime/session_tests.zig +2087 -1
  146. package/src/runtime/shell_layout.zig +7 -0
  147. package/src/runtime/terminal_session.zig +1569 -0
  148. package/src/runtime/terminal_session_tests.zig +450 -0
  149. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  150. package/src/runtime/terminal_vt_stub.zig +13 -0
  151. package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
  152. package/src/runtime/testdata/fonts/OFL.txt +93 -0
  153. package/src/runtime/tests.zig +8 -0
  154. package/src/runtime/ts_core_host.zig +1320 -45
  155. package/src/runtime/ts_core_host_tests.zig +1100 -1
  156. package/src/runtime/ts_ui_app.zig +23 -5
  157. package/src/runtime/ui_app.zig +2444 -69
  158. package/src/runtime/ui_app_tests.zig +3171 -744
  159. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  160. package/src/runtime/ui_app_window_tests.zig +736 -0
  161. package/src/runtime/view.zig +190 -2
  162. package/src/runtime/view_widget_scroll.zig +218 -68
  163. package/src/runtime/view_widget_text.zig +11 -2
  164. package/src/runtime/view_widget_tree.zig +111 -3
  165. package/src/runtime/window_command_bridge_tests.zig +117 -0
  166. package/src/runtime/window_storage.zig +77 -2
  167. package/src/runtime/window_view_runtime.zig +34 -2
  168. package/src/runtime/window_views.zig +62 -1
  169. package/src/terminal_session_tests_root.zig +15 -0
  170. package/src/tooling/manifest.zig +75 -0
  171. package/src/tooling/raw_manifest.zig +2 -0
  172. package/src/tooling/templates.zig +244 -8
@@ -66,6 +66,10 @@ pub const Error = error{
66
66
  AudioPathTooLarge,
67
67
  AudioSourceNotFound,
68
68
  AudioDecodeFailed,
69
+ InvalidVideoOptions,
70
+ VideoPathTooLarge,
71
+ VideoSourceNotFound,
72
+ VideoDecodeFailed,
69
73
  InvalidGpuSurfacePixels,
70
74
  InvalidGpuSurfacePacket,
71
75
  InvalidGpuSurfaceImage,
@@ -153,6 +157,28 @@ pub const PlatformFeature = enum {
153
157
  /// keeps emitting; the null platform models the rule through its
154
158
  /// windows' modeled occlusion so the suites can pin it.
155
159
  audio_spectrum,
160
+ /// The `close_policy = .hide` window shape: the host can intercept
161
+ /// the user's close affordance, keep the window alive off the
162
+ /// glass, and re-show it later (`show_window_fn`, tray actions, the
163
+ /// macOS Dock reopen). macOS and Windows implement it; GTK reports
164
+ /// false — Linux has no status-item affordance in this toolkit, so
165
+ /// a hidden window would be unreachable, and window create refuses
166
+ /// the policy with a teaching error instead. The null platform
167
+ /// models full support.
168
+ window_hide_on_close,
169
+ /// Single-player video playback into a media-surface texture channel
170
+ /// (macOS: AVFoundation — one AVPlayer whose AVPlayerItemVideoOutput
171
+ /// frames feed the surface's producer; the null platform: a
172
+ /// deterministic fake). The core never sees pixels: apps send
173
+ /// transport commands and receive `.video` events (load
174
+ /// acknowledgment with dimensions and duration, coarse position
175
+ /// ticks, one completion at natural end, failures), while decoded
176
+ /// frames flow platform-side through the `VideoFrameSink` handed to
177
+ /// the load verbs. Windows (Media Foundation) and Linux (GStreamer)
178
+ /// do not implement the decoder yet: their hosts answer the load
179
+ /// verbs with a teaching and `error.UnsupportedService` — named
180
+ /// unsupported, not half-implemented — and report false here.
181
+ video_playback,
156
182
  };
157
183
 
158
184
  pub const WebViewSourceKind = enum {
@@ -376,6 +402,24 @@ pub fn isValidShortcutKey(key: []const u8) bool {
376
402
  "arrowright",
377
403
  "arrowup",
378
404
  "arrowdown",
405
+ "delete",
406
+ "home",
407
+ "end",
408
+ "pageup",
409
+ "pagedown",
410
+ "insert",
411
+ "f1",
412
+ "f2",
413
+ "f3",
414
+ "f4",
415
+ "f5",
416
+ "f6",
417
+ "f7",
418
+ "f8",
419
+ "f9",
420
+ "f10",
421
+ "f11",
422
+ "f12",
379
423
  };
380
424
  for (&specials) |special| {
381
425
  if (std.ascii.eqlIgnoreCase(key, special)) return true;
@@ -522,6 +566,24 @@ pub const WindowShowMode = enum {
522
566
  on_first_present,
523
567
  };
524
568
 
569
+ /// What the user's close affordance (the red traffic light, cmd+W, the
570
+ /// caption X) does to this window.
571
+ /// `.quit` is the default and today's behavior unchanged: the window
572
+ /// really closes, and the last close follows the host's exit semantics.
573
+ /// `.hide` is the menu-bar/tray-app shape: the close affordance hides
574
+ /// the window instead — it stays alive in the host's records (no
575
+ /// shutdown), `WindowState.hidden` flips true on the frame channel,
576
+ /// and `Effects.showWindow` / the macOS Dock reopen bring it back.
577
+ /// Hosts that cannot re-show a hidden window (GTK has no status item
578
+ /// to click) refuse `.hide` at create time with a teaching error —
579
+ /// never a silent no-op that strands the window.
580
+ /// Deliberate enum room for a future `.event` tier (model-decides
581
+ /// close, for unsaved-changes flows) — not implemented yet.
582
+ pub const WindowClosePolicy = enum {
583
+ quit,
584
+ hide,
585
+ };
586
+
525
587
  pub const WindowOptions = struct {
526
588
  id: WindowId = 1,
527
589
  label: []const u8 = "main",
@@ -539,6 +601,9 @@ pub const WindowOptions = struct {
539
601
  /// does not grow an already-smaller restored frame.
540
602
  min_width: f32 = 0,
541
603
  min_height: f32 = 0,
604
+ /// What the user's close affordance does — see `WindowClosePolicy`.
605
+ /// Fixed at create like the titlebar: it is host window state.
606
+ close_policy: WindowClosePolicy = .quit,
542
607
 
543
608
  pub fn resolvedTitle(self: WindowOptions, app_name: []const u8) []const u8 {
544
609
  return if (self.title.len > 0) self.title else app_name;
@@ -555,6 +620,16 @@ pub const WindowState = struct {
555
620
  focused: bool = true,
556
621
  maximized: bool = false,
557
622
  fullscreen: bool = false,
623
+ /// True while the window is alive but off the glass because its
624
+ /// `close_policy = .hide` intercepted a user close (the menu-bar-app
625
+ /// shape): the window keeps its views and native identity, `open`
626
+ /// stays true, and a show — `Effects.showWindow`, a tray action's
627
+ /// consequence, the macOS Dock reopen — flips it back. Distinct from
628
+ /// minimized (which keeps a Dock/taskbar affordance) and from
629
+ /// closed (`open = false`, the window is gone). Session-transient:
630
+ /// never persisted to the window-state store, so every launch
631
+ /// starts shown.
632
+ hidden: bool = false,
558
633
  };
559
634
 
560
635
  pub const WindowInfo = struct {
@@ -565,6 +640,8 @@ pub const WindowInfo = struct {
565
640
  scale_factor: f32 = 1,
566
641
  open: bool = true,
567
642
  focused: bool = false,
643
+ /// Alive but policy-hidden — see `WindowState.hidden`.
644
+ hidden: bool = false,
568
645
 
569
646
  pub fn state(self: WindowInfo) WindowState {
570
647
  return .{
@@ -575,6 +652,7 @@ pub const WindowInfo = struct {
575
652
  .scale_factor = self.scale_factor,
576
653
  .open = self.open,
577
654
  .focused = self.focused,
655
+ .hidden = self.hidden,
578
656
  };
579
657
  }
580
658
  };
@@ -593,6 +671,8 @@ pub const WindowCreateOptions = struct {
593
671
  /// `WindowOptions.min_width`/`min_height`); 0 = no floor.
594
672
  min_width: f32 = 0,
595
673
  min_height: f32 = 0,
674
+ /// See `WindowOptions.close_policy`.
675
+ close_policy: WindowClosePolicy = .quit,
596
676
  source: ?WebViewSource = null,
597
677
 
598
678
  pub fn windowOptions(self: WindowCreateOptions, id: WindowId, label: []const u8) WindowOptions {
@@ -608,6 +688,7 @@ pub const WindowCreateOptions = struct {
608
688
  .show = self.show,
609
689
  .min_width = self.min_width,
610
690
  .min_height = self.min_height,
691
+ .close_policy = self.close_policy,
611
692
  };
612
693
  }
613
694
  };
@@ -1094,6 +1175,14 @@ pub const AppInfo = struct {
1094
1175
  /// default menus: web items like Reload only exist when a webview
1095
1176
  /// can answer them.
1096
1177
  has_web_content: bool = false,
1178
+ /// Whether the manifest declares the "tray" capability (a status
1179
+ /// item). Close policy `.hide` leans on it where the OS has no
1180
+ /// built-in re-show affordance: hiding a window on windows removes
1181
+ /// its taskbar entry and windows has no dock-reopen path, so only a
1182
+ /// tray icon can bring the hidden window back. The Windows host
1183
+ /// folds this into its `window_hide_on_close` answer; macOS ignores
1184
+ /// it (the Dock reopen path always exists).
1185
+ declares_tray: bool = false,
1097
1186
  window_title: []const u8 = "",
1098
1187
  bundle_id: []const u8 = "dev.native_sdk.app",
1099
1188
  icon_path: []const u8 = "",
@@ -1338,6 +1427,75 @@ pub const AudioLoadResolution = enum(u8) {
1338
1427
  stream,
1339
1428
  };
1340
1429
 
1430
+ /// Longest video source string (local path or URL) `videoLoad`/
1431
+ /// `videoLoadUrl` accepts; longer strings are rejected with
1432
+ /// `error.VideoPathTooLarge` before the platform is asked.
1433
+ pub const max_video_path_bytes: usize = 1024;
1434
+
1435
+ /// How the platform's video player reports back — the audio vocabulary,
1436
+ /// verbatim. `loaded` answers a successful load with the stream's real
1437
+ /// pixel dimensions and the player's duration estimate; `position` ticks
1438
+ /// at the host's honest coarse cadence (about every 500ms) only while
1439
+ /// playing, carrying the stream's `buffering` flag; `completed` fires
1440
+ /// exactly once when a non-looping video reaches its natural end (a
1441
+ /// looping player wraps and keeps ticking — a video that never ends
1442
+ /// never completes); `failed` reports an asynchronous decode/device
1443
+ /// failure. Pause, stop, seek, volume, mute, and loop never echo events
1444
+ /// — the caller already knows. Pixels never ride events: decoded frames
1445
+ /// flow through the `VideoFrameSink` handed to the load verb.
1446
+ pub const VideoEventKind = enum(u8) {
1447
+ loaded,
1448
+ position,
1449
+ completed,
1450
+ failed,
1451
+ };
1452
+
1453
+ /// One report from the platform video player. Positions and durations
1454
+ /// are in milliseconds; `playing`/`buffering` carry the audio event's
1455
+ /// exact semantics (transport intent vs a stalled stream). `width` and
1456
+ /// `height` are the STREAM's decoded pixel dimensions, reported on
1457
+ /// `.loaded` (0 elsewhere) — the honest source geometry even when the
1458
+ /// host downscales frames to fit the texture channel's pixel budget.
1459
+ pub const VideoEvent = struct {
1460
+ kind: VideoEventKind,
1461
+ /// Which LOAD this event reports on: the engine mints a fresh
1462
+ /// token per `videoLoad`/`videoLoadUrl` and the host echoes it in
1463
+ /// every event that playback produces. The single player replaces
1464
+ /// in place, and an event emitted by the replaced playback can
1465
+ /// still be queued when the replacement lands — the token is how
1466
+ /// the engine swallows it instead of resetting (or misattributing
1467
+ /// events to) the playback that replaced it.
1468
+ token: u64 = 0,
1469
+ position_ms: u64 = 0,
1470
+ duration_ms: u64 = 0,
1471
+ playing: bool = false,
1472
+ buffering: bool = false,
1473
+ width: u64 = 0,
1474
+ height: u64 = 0,
1475
+ };
1476
+
1477
+ /// Where a platform video decoder delivers frames: a type-erased,
1478
+ /// copyable handle to one media-surface texture channel claim. The pair
1479
+ /// `context`/`generation` addresses process-lifetime slot memory fenced
1480
+ /// by a generation stamp (the media-surface thread contract), so the
1481
+ /// host may call `push_fn` from ANY thread — a decode callback, a frame
1482
+ /// timer — and a push after the claim was released lands in inert
1483
+ /// memory and reports `error.MediaSurfaceReleased` instead of touching
1484
+ /// freed state. `rgba8` is one tightly-packed straight-alpha RGBA8
1485
+ /// frame, copied before the call returns. A zeroed sink (`push_fn`
1486
+ /// null) is inert: hosts must tolerate it and simply decode nowhere.
1487
+ pub const VideoFrameSink = struct {
1488
+ context: ?*anyopaque = null,
1489
+ generation: u64 = 0,
1490
+ push_fn: ?*const fn (context: ?*anyopaque, generation: u64, width: usize, height: usize, rgba8: []const u8) anyerror!void = null,
1491
+
1492
+ /// Push one frame through the sink; inert sinks drop it silently.
1493
+ pub fn push(self: VideoFrameSink, width: usize, height: usize, rgba8: []const u8) anyerror!void {
1494
+ const push_fn = self.push_fn orelse return;
1495
+ return push_fn(self.context, self.generation, width, height, rgba8);
1496
+ }
1497
+ };
1498
+
1341
1499
  pub const FileDropEvent = struct {
1342
1500
  window_id: WindowId = 1,
1343
1501
  view_label: []const u8 = "",
@@ -1578,11 +1736,28 @@ pub const GpuSurfaceInputKind = enum {
1578
1736
  pinch_end,
1579
1737
  };
1580
1738
 
1739
+ /// Reserved bit in `GpuSurfaceInputEvent.pointer_id`: a host that can
1740
+ /// identify a TOUCH-sourced pointer event stamps it (a
1741
+ /// `GDK_SOURCE_TOUCHSCREEN` device on GTK; a mouse message whose
1742
+ /// `GetMessageExtraInfo` carries the touch `MI_WP_SIGNATURE` on
1743
+ /// Windows, where the OS synthesizes mouse-shaped moves for taps), and
1744
+ /// the runtime's hover-Msg containment then refuses to treat that
1745
+ /// pointer as hover-capable — the mechanical backstop for the "touch
1746
+ /// never synthesizes hover" contract even where the OS fakes a hover
1747
+ /// move. Hosts that cannot identify the source leave ids unstamped;
1748
+ /// unstamped ids keep today's behavior. The bit rides the EXISTING id
1749
+ /// field, so journals and the input codec are unchanged.
1750
+ pub const touch_pointer_id_bit: u64 = 1 << 63;
1751
+
1581
1752
  pub const GpuSurfaceInputEvent = struct {
1582
1753
  window_id: WindowId = 1,
1583
1754
  label: []const u8,
1584
1755
  kind: GpuSurfaceInputKind,
1585
1756
  timestamp_ns: u64 = 0,
1757
+ /// Host pointer identity, when the host distinguishes pointers
1758
+ /// (per-sequence touch ids, `WM_POINTER` ids); 0 on single-pointer
1759
+ /// hosts. Touch-sourced events additionally carry
1760
+ /// `touch_pointer_id_bit`.
1586
1761
  pointer_id: u64 = 0,
1587
1762
  x: f32 = 0,
1588
1763
  y: f32 = 0,
@@ -1663,10 +1838,41 @@ pub const PinchEvent = struct {
1663
1838
  y: f32 = 0,
1664
1839
  };
1665
1840
 
1841
+ /// A wheel/trackpad scroll over a gpu surface, for the app-level wheel
1842
+ /// channel (`on_wheel` — the pinch channel's sibling). Deltas are the
1843
+ /// host's scroll units in view points, sign as the platform reports it
1844
+ /// (natural scrolling on hosts that apply it); `x`/`y` locate the
1845
+ /// pointer in view-local canvas points.
1846
+ pub const WheelEvent = struct {
1847
+ window_id: WindowId = 1,
1848
+ label: []const u8 = "",
1849
+ delta_x: f32 = 0,
1850
+ delta_y: f32 = 0,
1851
+ x: f32 = 0,
1852
+ y: f32 = 0,
1853
+ modifiers: ShortcutModifiers = .{},
1854
+ };
1855
+
1666
1856
  /// Upper bound on native scroll drivers per gpu-surface view (one per
1667
1857
  /// scrollable canvas region).
1668
1858
  pub const max_gpu_surface_scroll_drivers: usize = 16;
1669
1859
 
1860
+ /// Upper bound on scroll OCCLUDERS per gpu-surface view (floating
1861
+ /// surfaces and modal catchers that hit-block regions beneath them).
1862
+ pub const max_gpu_surface_scroll_occluders: usize = 8;
1863
+
1864
+ /// A surface that hit-blocks scroll regions beneath it: anchored
1865
+ /// floating surfaces (popovers, dropdowns, tooltips) at their frames,
1866
+ /// and modal surfaces (dialog/drawer/sheet input catchers) as the whole
1867
+ /// view. The host must not route a wheel to a driver whose
1868
+ /// `occluder_mask` includes an occluder containing the point — the
1869
+ /// engine's hit test would give that point to the overlay's branch, so
1870
+ /// the native fast path has to decline it the same way (the wheel then
1871
+ /// rides the wire, where real hit-testing decides).
1872
+ pub const GpuSurfaceScrollOccluder = struct {
1873
+ frame: geometry.RectF,
1874
+ };
1875
+
1670
1876
  /// One native scroll driver's desired state, pushed by the runtime on
1671
1877
  /// every widget-layout install and every presented frame (self-healing
1672
1878
  /// against host-side relayouts). Coordinates are view-local canvas points
@@ -1678,20 +1884,50 @@ pub const GpuSurfaceScrollDriver = struct {
1678
1884
  /// The scroll region's layout frame, view-local.
1679
1885
  frame: geometry.RectF,
1680
1886
  /// Total scrollable content size for the region. The vertical max
1681
- /// scroll offset is `content_size.height - frame.height`.
1887
+ /// scroll offset is `content_size.height - frame.height`; the
1888
+ /// horizontal one is `content_size.width - frame.width` (a region
1889
+ /// that does not scroll horizontally reports `width ==
1890
+ /// frame.width`, so the horizontal max is 0 and the native
1891
+ /// scroller never travels sideways).
1682
1892
  content_size: geometry.SizeF,
1683
- /// The runtime's current scroll offset (canvas points, y-down).
1893
+ /// The runtime's current scroll offsets (canvas points, y-down,
1894
+ /// x-rightward).
1895
+ offset_x: f32 = 0,
1684
1896
  offset_y: f32 = 0,
1685
- /// True when the runtime changed the offset from a non-driver source
1686
- /// (keyboard scroll, programmatic scroll, rebuild clamp): the host
1687
- /// must write `offset_y` into the native scroller. False leaves the
1688
- /// native scroller alone — the driver owns the offset.
1689
- set_offset: bool = false,
1897
+ /// True when the runtime changed that axis's offset from a
1898
+ /// non-driver source (keyboard scroll, programmatic scroll, rebuild
1899
+ /// clamp): the host must write that offset into the native
1900
+ /// scroller. False leaves the axis alone — the driver owns it. Per
1901
+ /// axis, so a programmatic vertical write can never push a stale
1902
+ /// horizontal offset over native motion whose coalesced report is
1903
+ /// still in flight (and vice versa).
1904
+ set_offset_x: bool = false,
1905
+ set_offset_y: bool = false,
1690
1906
  /// Edge behavior for this region's native scroller: false (the
1691
1907
  /// default) pins scrolling at the content edges, true lets the OS
1692
- /// scroller bounce past them (vertical elasticity). Reconciled on
1693
- /// every push like the frame and content size.
1908
+ /// scroller bounce past them. Reconciled on every push like the
1909
+ /// frame and content size, and armed per axis through the grants
1910
+ /// below.
1694
1911
  rubber_band: bool = false,
1912
+ /// The nearest ANCESTOR driver's id (0 = none): the widget-tree
1913
+ /// containment chain, pushed so the host can restrict wheel-owner
1914
+ /// resolution to the hit region and its ancestors — geometric
1915
+ /// overlap alone would let an unrelated background region behind a
1916
+ /// floating surface steal an axis the engine's route would never
1917
+ /// give it.
1918
+ parent_id: u64 = 0,
1919
+ /// Which occluders (by bit index into the sync call's occluder
1920
+ /// array) hit-block THIS region: every pushed occluder that is not
1921
+ /// an ancestor of the region — a scroll region inside an open
1922
+ /// popover is not blocked by its own surface.
1923
+ occluder_mask: u32 = 0,
1924
+ /// Which axes the region GRANTS (`canvas.widgetScrollsAxis`): the
1925
+ /// host arms elasticity and scroller chrome only on granted axes.
1926
+ /// Distinct from having range right now — a granted axis with short
1927
+ /// content keeps its scroller parked but may still bounce, while an
1928
+ /// ungranted axis must never move, bounce, or grow a scroller.
1929
+ scrolls_x: bool = false,
1930
+ scrolls_y: bool = true,
1695
1931
  };
1696
1932
 
1697
1933
  /// A native scroll driver reported a new content offset (the user
@@ -1702,6 +1938,7 @@ pub const GpuSurfaceScrollDriverEvent = struct {
1702
1938
  window_id: WindowId = 1,
1703
1939
  label: []const u8,
1704
1940
  driver_id: u64,
1941
+ offset_x: f32 = 0,
1705
1942
  offset_y: f32 = 0,
1706
1943
  timestamp_ns: u64 = 0,
1707
1944
  };
@@ -1728,7 +1965,8 @@ pub const ContextMenuRequest = struct {
1728
1965
  view_label: []const u8 = "",
1729
1966
  point: geometry.PointF = .{},
1730
1967
  /// Opaque correlation token echoed back on the action event (the
1731
- /// runtime uses the target widget's id).
1968
+ /// runtime mints one per request, so a superseded menu's late
1969
+ /// dismissal can never resolve its successor's request).
1732
1970
  token: u64 = 0,
1733
1971
  items: []const ContextMenuItem = &.{},
1734
1972
  };
@@ -1783,8 +2021,11 @@ pub const GpuSurfaceImagePixels = struct {
1783
2021
  /// keyed by the canvas font id host-wide. The engine validates the bytes
1784
2022
  /// (a parseable TrueType face under the registry bounds) before this
1785
2023
  /// call, so hosts may treat a decode failure as a hard error rather than
1786
- /// a fallback. Ids are permanent for the process — the engine never
1787
- /// re-registers an id with different bytes.
2024
+ /// a fallback. Ids are permanent per RUNTIME (one runtime never
2025
+ /// re-registers an id with different bytes), but host font state is
2026
+ /// per-process and runtimes are not: a later runtime may re-register an
2027
+ /// id a still-live earlier runtime also holds, and the host resolves the
2028
+ /// most recent registration (last wins).
1788
2029
  pub const GpuSurfaceFontData = struct {
1789
2030
  id: u64,
1790
2031
  ttf: []const u8,
@@ -1946,6 +2187,15 @@ pub const Appearance = struct {
1946
2187
  high_contrast: bool = false,
1947
2188
  };
1948
2189
 
2190
+ /// A platform child view gained keyboard focus through native input.
2191
+ /// Canvas/GPU input reports its own focus edge with the input event;
2192
+ /// native webviews and controls need this explicit inverse edge because
2193
+ /// their pointer stream never crosses the runtime.
2194
+ pub const ViewFocusEvent = struct {
2195
+ window_id: WindowId = 1,
2196
+ label: []const u8,
2197
+ };
2198
+
1949
2199
  pub const Event = union(enum) {
1950
2200
  app_start,
1951
2201
  app_activated,
@@ -1956,6 +2206,7 @@ pub const Event = union(enum) {
1956
2206
  surface_resized: Surface,
1957
2207
  window_frame_changed: WindowState,
1958
2208
  window_focused: WindowId,
2209
+ view_focused: ViewFocusEvent,
1959
2210
  bridge_message: BridgeMessage,
1960
2211
  tray_action: TrayItemId,
1961
2212
  shortcut: ShortcutEvent,
@@ -1977,6 +2228,9 @@ pub const Event = union(enum) {
1977
2228
  /// Audio player reports: load acknowledgment, coarse position ticks
1978
2229
  /// while playing, one completion at natural end, async failures.
1979
2230
  audio: AudioEvent,
2231
+ /// Video player reports — the same shape, plus the stream's decoded
2232
+ /// dimensions on `.loaded`. Pixels never ride here.
2233
+ video: VideoEvent,
1980
2234
 
1981
2235
  pub fn name(self: Event) []const u8 {
1982
2236
  return switch (self) {
@@ -1989,6 +2243,7 @@ pub const Event = union(enum) {
1989
2243
  .surface_resized => "surface_resized",
1990
2244
  .window_frame_changed => "window_frame_changed",
1991
2245
  .window_focused => "window_focused",
2246
+ .view_focused => "view_focused",
1992
2247
  .bridge_message => "bridge_message",
1993
2248
  .tray_action => "tray_action",
1994
2249
  .shortcut => "shortcut",
@@ -2004,6 +2259,7 @@ pub const Event = union(enum) {
2004
2259
  .context_menu_action => "context_menu_action",
2005
2260
  .widget_accessibility_action => "widget_accessibility_action",
2006
2261
  .audio => "audio",
2262
+ .video => "video",
2007
2263
  };
2008
2264
  }
2009
2265
  };
@@ -2047,6 +2303,30 @@ pub const PlatformServices = struct {
2047
2303
  /// controls — chromeless windows have no system button to click.
2048
2304
  /// Platforms without the concept leave this null.
2049
2305
  minimize_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
2306
+ /// The real OS show verb: unhide + activate (macOS deminiaturize +
2307
+ /// makeKeyAndOrderFront + activate, Windows SW_RESTORE/SW_SHOW +
2308
+ /// foreground, GTK `gtk_window_present`) — the counterpart to a
2309
+ /// `close_policy = .hide` hide, and the tray "Open" consequence.
2310
+ /// Platforms without the concept leave this null.
2311
+ show_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
2312
+ /// The graceful app quit: terminate through the SAME shutdown path
2313
+ /// a last-window close takes — but the host QUEUES the emit, so
2314
+ /// `app_shutdown` dispatches on its NEXT loop turn, only after the
2315
+ /// dispatch that requested the quit has returned. Never emit
2316
+ /// synchronously from inside this call: the request arrives mid
2317
+ /// dispatch (the command whose update returned it is still on the
2318
+ /// recorder's staged-event stack), and a nested emit seals the
2319
+ /// session journal before the requesting command commits — the
2320
+ /// record is lost and replay diverges. Before the run loop starts
2321
+ /// (a quit from App.start's update, or from a boot command in the
2322
+ /// synchronous first canvas frame) the host parks the request and
2323
+ /// drains it at top level after the current callback returns.
2324
+ /// Either way `app.stop` runs exactly once, and the shutdown is
2325
+ /// journaled like any platform event. The null platform's
2326
+ /// `quit_pending`/`takeQueuedQuit` seam is the reference model of
2327
+ /// the queued shape. Platforms without the concept leave this
2328
+ /// null.
2329
+ quit_app_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2050
2330
  /// Hand the ACTIVE pointer-down to the platform as a window-drag
2051
2331
  /// gesture (the hidden-titlebar drag-region channel): the window
2052
2332
  /// moves once the pointer actually moves — a plain click moves
@@ -2154,6 +2434,49 @@ pub const PlatformServices = struct {
2154
2434
  audio_seek_fn: ?*const fn (context: ?*anyopaque, position_ms: u64) anyerror!void = null,
2155
2435
  /// Set the player volume, `0.0` (silent) through `1.0` (full).
2156
2436
  audio_set_volume_fn: ?*const fn (context: ?*anyopaque, volume: f32) anyerror!void = null,
2437
+ /// Load a local video file into THE app's single video player,
2438
+ /// leaving it PAUSED at position zero (transport is a separate
2439
+ /// verb, exactly like audio). Loading replaces whatever was loaded
2440
+ /// before. Success is asynchronous: a `.video`/`.loaded` event
2441
+ /// carries the stream's decoded dimensions and the player's
2442
+ /// duration estimate; an unreadable path fails synchronously
2443
+ /// (`error.VideoSourceNotFound` / `error.VideoDecodeFailed`).
2444
+ /// Decoded frames flow through `sink` from whatever thread the
2445
+ /// host's decode path runs on — the core never sees pixels. One
2446
+ /// player is the whole surface, like the audio channel it mirrors.
2447
+ video_load_fn: ?*const fn (context: ?*anyopaque, path: []const u8, token: u64, sink: VideoFrameSink) anyerror!void = null,
2448
+ /// Load an http(s) video source into the same single player,
2449
+ /// streaming progressively (playable before the download finishes;
2450
+ /// `buffering` flags on position ticks report stalls honestly).
2451
+ /// Same acknowledgment, sink, and replace semantics as
2452
+ /// `video_load_fn`.
2453
+ video_load_url_fn: ?*const fn (context: ?*anyopaque, url: []const u8, token: u64, sink: VideoFrameSink) anyerror!void = null,
2454
+ /// Start or resume the loaded player. While playing the platform
2455
+ /// emits `.video`/`.position` events at the audio tier's coarse
2456
+ /// honest cadence (about every 500ms — a readout, never the frame
2457
+ /// clock; frames pace themselves through the sink) and one
2458
+ /// `.video`/`.completed` when a non-looping video ends naturally.
2459
+ video_play_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2460
+ /// Pause in place; position holds, ticks and frame pushes stop, and
2461
+ /// the surface keeps its last adopted frame. No event echoes.
2462
+ video_pause_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2463
+ /// Stop and unload the player entirely; a new load is required
2464
+ /// before anything can play again.
2465
+ video_stop_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2466
+ /// Jump the loaded player to `position_ms` (clamped to the
2467
+ /// duration). Works while playing or paused; a paused seek still
2468
+ /// pushes the sought frame so scrubbing is visible.
2469
+ video_seek_fn: ?*const fn (context: ?*anyopaque, position_ms: u64) anyerror!void = null,
2470
+ /// Set the player volume, `0.0` (silent) through `1.0` (full) —
2471
+ /// independent of mute, which is a separate reversible switch.
2472
+ video_set_volume_fn: ?*const fn (context: ?*anyopaque, volume: f32) anyerror!void = null,
2473
+ /// Mute or unmute the player's audio track without touching the
2474
+ /// volume setting (the transport keeps playing either way).
2475
+ video_set_muted_fn: ?*const fn (context: ?*anyopaque, muted: bool) anyerror!void = null,
2476
+ /// Enable or disable looping: a looping player wraps from the
2477
+ /// natural end back to zero and keeps playing — no `.completed`
2478
+ /// event, because the playback never ends.
2479
+ video_set_loop_fn: ?*const fn (context: ?*anyopaque, loop: bool) anyerror!void = null,
2157
2480
  /// Nudge the platform event loop from ANY thread: the platform must
2158
2481
  /// deliver a `.wake` event on its loop thread as soon as possible.
2159
2482
  /// One of exactly two `PlatformServices` entries that may be called
@@ -2161,7 +2484,54 @@ pub const PlatformServices = struct {
2161
2484
  /// must be thread-safe (macOS: main-queue dispatch, GTK: `g_idle_add`,
2162
2485
  /// Win32: `PostMessage`, null platform: an atomic counter tests drain
2163
2486
  /// explicitly).
2487
+ ///
2488
+ /// CONTRACT — bounded, non-blocking, enqueue-only. The
2489
+ /// implementation must schedule the `.wake` delivery and return: it
2490
+ /// must never synchronously wait on the loop thread (a
2491
+ /// dispatch_sync-style marshal, a Win32 `SendMessage`) or on the
2492
+ /// posting thread. The first-party implementations are the model —
2493
+ /// macOS `dispatch_async` onto the main queue, GTK `g_idle_add`,
2494
+ /// Win32 `PostMessageW`, the null platform's atomic counter — the
2495
+ /// exact enqueue-only shape `request_frame_fn` documents for the
2496
+ /// media-surface producer wake, so the call stays bounded and never
2497
+ /// blocks on I/O. This contract is what the runtime's channel
2498
+ /// posting guarantee is conditioned on: `ChannelHandle.post` never
2499
+ /// blocks GIVEN a conforming wake, and because the runtime holds no
2500
+ /// channel lock across the call, a violating implementation hangs
2501
+ /// only its own posting thread — it can never entangle the
2502
+ /// runtime's lock graph. A violator still inside the call when the
2503
+ /// runtime tears down is ABANDONED after a bounded quiesce; see
2504
+ /// `note_channel_wake_abandoned_fn` for the consequence the
2505
+ /// platform must then honor.
2164
2506
  wake_fn: ?*const fn (context: ?*anyopaque) anyerror!void = null,
2507
+ /// Teardown consequence of an abandoned wake call. The runtime's
2508
+ /// effects teardown waits (bounded) for posts still inside
2509
+ /// `wake_fn`; a call that outlives the deadline — only possible
2510
+ /// when the wake violates its enqueue-only contract above — is
2511
+ /// abandoned, and it still holds `context` and may execute into the
2512
+ /// platform at ANY later time. The runtime reports that abandon
2513
+ /// here, synchronously, while the platform is still alive — and
2514
+ /// keeps its own half of the bargain: the `PlatformServices` VALUE
2515
+ /// the stale call reads on resume is a process-lived snapshot the
2516
+ /// runtime published at bind, never runtime-owned storage (see
2517
+ /// `Effects.bindServices`). A platform receiving this call must
2518
+ /// latch it, and its destruction path must consult the latch:
2519
+ /// destruction is SKIPPED and the platform deliberately leaked,
2520
+ /// process-lived, so the stale call can never execute into freed
2521
+ /// host state (the abandoned-worker idiom the effect workers
2522
+ /// already follow). The leak must cover EVERYTHING `context`
2523
+ /// transitively reaches — for the first-party desktop platforms
2524
+ /// that is the wrapper struct itself plus the native host behind
2525
+ /// it, which is why runners heap-allocate the wrapper
2526
+ /// (`createWithOptions`) and gate its free on the latch
2527
+ /// (`destroy`), never leaving it on a stack frame that unwinds at
2528
+ /// runner return. Every first-party platform wires this seam and
2529
+ /// gates both `deinit` and its storage on the latch; embedders
2530
+ /// providing their own `Platform` must do the same — or guarantee
2531
+ /// a conforming `wake_fn`, under which the teardown deadline is
2532
+ /// never met and this is never called. Loop-thread, teardown-only,
2533
+ /// unlike `wake_fn` itself.
2534
+ note_channel_wake_abandoned_fn: ?*const fn (context: ?*anyopaque) void = null,
2165
2535
  /// Ask the platform loop, from ANY thread, to deliver ONE
2166
2536
  /// `frame_requested` event on its loop thread soon — the same event a
2167
2537
  /// resize or an input-driven frame produces, so everything that rides
@@ -2204,16 +2574,43 @@ pub const PlatformServices = struct {
2204
2574
  /// without host-side text (GTK/Win32/null default), where the engine
2205
2575
  /// measures with the parsed face and inks it through the reference
2206
2576
  /// renderer.
2207
- register_gpu_surface_font_fn: ?*const fn (context: ?*anyopaque, font: GpuSurfaceFontData) anyerror!void = null,
2577
+ ///
2578
+ /// Returns the host's ownership token for THIS registration of the
2579
+ /// id. Host font state is per-process while ids are only permanent
2580
+ /// per-runtime, so two live runtimes can register the same id (last
2581
+ /// wins); the token names which registration a later unregister may
2582
+ /// remove — the runtime stores it beside the captured unregister
2583
+ /// owner and passes it back at teardown. Platforms that retain no
2584
+ /// per-id host state (a stateless accept) return 0: there was
2585
+ /// nothing installed, so there is nothing a token could own, and an
2586
+ /// unregister carrying 0 removes nothing.
2587
+ register_gpu_surface_font_fn: ?*const fn (context: ?*anyopaque, font: GpuSurfaceFontData) anyerror!u64 = null,
2588
+ /// Teardown twin of the registration seam above: return whatever
2589
+ /// per-id state the host retained for a registered face (descriptor
2590
+ /// tables, size/measurement caches) when the runtime that registered
2591
+ /// the id deinits. Fonts are per-runtime but host font state is
2592
+ /// per-process, so without this seam an embedder cycling runtimes
2593
+ /// with fresh ids grows host state for the process lifetime.
2594
+ /// `token` is the ownership token the matching register call
2595
+ /// returned: the host removes the id's state ONLY while the id's
2596
+ /// current registration still carries that token, so an older
2597
+ /// runtime's deinit can never tear down a newer runtime's live face
2598
+ /// under a shared id. A stale token (the id was re-registered since)
2599
+ /// is a no-op accept — the registration it owned is already gone,
2600
+ /// which is exactly the state its owner asked for. Unregistering an
2601
+ /// id the host never saw is likewise a no-op, not an error. Null on
2602
+ /// platforms whose register seam is itself null (GTK/Win32 default)
2603
+ /// — with no host font state there is nothing to return.
2604
+ unregister_gpu_surface_font_fn: ?*const fn (context: ?*anyopaque, id: u64, token: u64) anyerror!void = null,
2208
2605
  update_widget_accessibility_fn: ?*const fn (context: ?*anyopaque, snapshot: WidgetAccessibilitySnapshot) anyerror!void = null,
2209
2606
  /// Reconcile the native scroll drivers for a gpu-surface view against
2210
2607
  /// the full desired set: create missing drivers, update frames /
2211
- /// content extents / (when `set_offset`) offsets, remove drivers whose
2608
+ /// content extents / (per set-offset flag) offsets, remove drivers whose
2212
2609
  /// id is absent. Idempotent — the runtime calls this on every layout
2213
2610
  /// install and every presented frame. Null on platforms without
2214
2611
  /// native scroll drivers (GTK / Win32 / null default), which keeps
2215
2612
  /// scrolling on the engine's wheel physics.
2216
- set_gpu_surface_scroll_drivers_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId, label: []const u8, drivers: []const GpuSurfaceScrollDriver) anyerror!void = null,
2613
+ set_gpu_surface_scroll_drivers_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId, label: []const u8, drivers: []const GpuSurfaceScrollDriver, occluders: []const GpuSurfaceScrollOccluder) anyerror!void = null,
2217
2614
  /// Present a native context menu at the request's pointer location.
2218
2615
  /// Asynchronous: the selection (or dismissal) arrives later as a
2219
2616
  /// `context_menu_action` event echoing `request.token`. Null on
@@ -2326,6 +2723,16 @@ pub const PlatformServices = struct {
2326
2723
  return minimize_fn(self.context, window_id);
2327
2724
  }
2328
2725
 
2726
+ pub fn showWindow(self: PlatformServices, window_id: WindowId) anyerror!void {
2727
+ const show_fn = self.show_window_fn orelse return error.UnsupportedService;
2728
+ return show_fn(self.context, window_id);
2729
+ }
2730
+
2731
+ pub fn quitApp(self: PlatformServices) anyerror!void {
2732
+ const quit_fn = self.quit_app_fn orelse return error.UnsupportedService;
2733
+ return quit_fn(self.context);
2734
+ }
2735
+
2329
2736
  pub fn startWindowDrag(self: PlatformServices, window_id: WindowId) anyerror!void {
2330
2737
  const drag_fn = self.start_window_drag_fn orelse return error.UnsupportedService;
2331
2738
  return drag_fn(self.context, window_id);
@@ -2435,9 +2842,9 @@ pub const PlatformServices = struct {
2435
2842
  return close_fn(self.context, window_id, label);
2436
2843
  }
2437
2844
 
2438
- pub fn setGpuSurfaceScrollDrivers(self: PlatformServices, window_id: WindowId, label: []const u8, drivers: []const GpuSurfaceScrollDriver) anyerror!void {
2845
+ pub fn setGpuSurfaceScrollDrivers(self: PlatformServices, window_id: WindowId, label: []const u8, drivers: []const GpuSurfaceScrollDriver, occluders: []const GpuSurfaceScrollOccluder) anyerror!void {
2439
2846
  const set_fn = self.set_gpu_surface_scroll_drivers_fn orelse return error.UnsupportedService;
2440
- return set_fn(self.context, window_id, label, drivers);
2847
+ return set_fn(self.context, window_id, label, drivers, occluders);
2441
2848
  }
2442
2849
 
2443
2850
  pub fn showContextMenu(self: PlatformServices, request: ContextMenuRequest) anyerror!void {
@@ -2630,6 +3037,72 @@ pub const PlatformServices = struct {
2630
3037
  return volume_fn(self.context, volume);
2631
3038
  }
2632
3039
 
3040
+ /// Load a local video file into the app's single video player (see
3041
+ /// `video_load_fn`). Platforms without video playback answer
3042
+ /// `error.UnsupportedService`; bad arguments are rejected here
3043
+ /// before the platform is asked.
3044
+ pub fn videoLoad(self: PlatformServices, path: []const u8, token: u64, sink: VideoFrameSink) anyerror!void {
3045
+ if (path.len == 0) return error.InvalidVideoOptions;
3046
+ if (path.len > max_video_path_bytes) return error.VideoPathTooLarge;
3047
+ const load_fn = self.video_load_fn orelse return error.UnsupportedService;
3048
+ return load_fn(self.context, path, token, sink);
3049
+ }
3050
+
3051
+ /// Load an http(s) video source into the app's single video player,
3052
+ /// streaming progressively (see `video_load_url_fn`). Platforms
3053
+ /// without video playback answer `error.UnsupportedService`; bad
3054
+ /// arguments are rejected here before the platform is asked —
3055
+ /// including any non-http(s) scheme: hosts hand the URL to their
3056
+ /// media stack whole (AVPlayer opens file: URLs happily), so the
3057
+ /// seam is where the streaming-only contract holds for every
3058
+ /// caller, not just the engine's own gated loads.
3059
+ pub fn videoLoadUrl(self: PlatformServices, url: []const u8, token: u64, sink: VideoFrameSink) anyerror!void {
3060
+ if (url.len == 0) return error.InvalidVideoOptions;
3061
+ if (url.len > max_video_path_bytes) return error.VideoPathTooLarge;
3062
+ const uri = std.Uri.parse(url) catch return error.InvalidVideoOptions;
3063
+ const scheme_ok = std.ascii.eqlIgnoreCase(uri.scheme, "http") or
3064
+ std.ascii.eqlIgnoreCase(uri.scheme, "https");
3065
+ if (!scheme_ok) return error.InvalidVideoOptions;
3066
+ const load_fn = self.video_load_url_fn orelse return error.UnsupportedService;
3067
+ return load_fn(self.context, url, token, sink);
3068
+ }
3069
+
3070
+ pub fn videoPlay(self: PlatformServices) anyerror!void {
3071
+ const play_fn = self.video_play_fn orelse return error.UnsupportedService;
3072
+ return play_fn(self.context);
3073
+ }
3074
+
3075
+ pub fn videoPause(self: PlatformServices) anyerror!void {
3076
+ const pause_fn = self.video_pause_fn orelse return error.UnsupportedService;
3077
+ return pause_fn(self.context);
3078
+ }
3079
+
3080
+ pub fn videoStop(self: PlatformServices) anyerror!void {
3081
+ const stop_fn = self.video_stop_fn orelse return error.UnsupportedService;
3082
+ return stop_fn(self.context);
3083
+ }
3084
+
3085
+ pub fn videoSeek(self: PlatformServices, position_ms: u64) anyerror!void {
3086
+ const seek_fn = self.video_seek_fn orelse return error.UnsupportedService;
3087
+ return seek_fn(self.context, position_ms);
3088
+ }
3089
+
3090
+ pub fn videoSetVolume(self: PlatformServices, volume: f32) anyerror!void {
3091
+ if (!(volume >= 0.0 and volume <= 1.0)) return error.InvalidVideoOptions;
3092
+ const volume_fn = self.video_set_volume_fn orelse return error.UnsupportedService;
3093
+ return volume_fn(self.context, volume);
3094
+ }
3095
+
3096
+ pub fn videoSetMuted(self: PlatformServices, muted: bool) anyerror!void {
3097
+ const muted_fn = self.video_set_muted_fn orelse return error.UnsupportedService;
3098
+ return muted_fn(self.context, muted);
3099
+ }
3100
+
3101
+ pub fn videoSetLoop(self: PlatformServices, loop: bool) anyerror!void {
3102
+ const loop_fn = self.video_set_loop_fn orelse return error.UnsupportedService;
3103
+ return loop_fn(self.context, loop);
3104
+ }
3105
+
2633
3106
  /// Ask the platform loop to deliver a `.wake` event on its own thread.
2634
3107
  /// Safe to call from any thread; a missing implementation is an error
2635
3108
  /// so callers never assume a nudge happened when it did not.
@@ -2638,6 +3111,17 @@ pub const PlatformServices = struct {
2638
3111
  return wake_fn(self.context);
2639
3112
  }
2640
3113
 
3114
+ /// Report that an in-flight `wake_fn` call was abandoned at
3115
+ /// teardown (see `note_channel_wake_abandoned_fn` for the platform
3116
+ /// obligation this triggers). Loop-thread, teardown-only. A
3117
+ /// platform without the seam simply cannot be told — the caller's
3118
+ /// own warning still names the leak, and a conforming `wake_fn`
3119
+ /// never reaches this in the first place.
3120
+ pub fn noteChannelWakeAbandoned(self: PlatformServices) void {
3121
+ const note_fn = self.note_channel_wake_abandoned_fn orelse return;
3122
+ note_fn(self.context);
3123
+ }
3124
+
2641
3125
  /// Ask the platform loop to deliver one `frame_requested` event on
2642
3126
  /// its own thread. Safe to call from any thread; a missing
2643
3127
  /// implementation is an error so callers never assume a frame is
@@ -2695,13 +3179,25 @@ pub const PlatformServices = struct {
2695
3179
  return remove_fn(self.context, id);
2696
3180
  }
2697
3181
 
2698
- pub fn registerGpuSurfaceFont(self: PlatformServices, font: GpuSurfaceFontData) anyerror!void {
3182
+ /// Returns the host's ownership token for this registration (0 from
3183
+ /// hosts that retain no per-id state) — see
3184
+ /// `register_gpu_surface_font_fn`.
3185
+ pub fn registerGpuSurfaceFont(self: PlatformServices, font: GpuSurfaceFontData) anyerror!u64 {
2699
3186
  if (font.id == 0) return error.InvalidGpuSurfaceFont;
2700
3187
  if (font.ttf.len == 0 or font.ttf.len > max_gpu_surface_font_bytes) return error.InvalidGpuSurfaceFont;
2701
3188
  const register_fn = self.register_gpu_surface_font_fn orelse return error.UnsupportedService;
2702
3189
  return register_fn(self.context, font);
2703
3190
  }
2704
3191
 
3192
+ /// `token` must be the value the matching `registerGpuSurfaceFont`
3193
+ /// returned; a stale token is a no-op accept — see
3194
+ /// `unregister_gpu_surface_font_fn`.
3195
+ pub fn unregisterGpuSurfaceFont(self: PlatformServices, id: u64, token: u64) anyerror!void {
3196
+ if (id == 0) return error.InvalidGpuSurfaceFont;
3197
+ const unregister_fn = self.unregister_gpu_surface_font_fn orelse return error.UnsupportedService;
3198
+ return unregister_fn(self.context, id, token);
3199
+ }
3200
+
2705
3201
  pub fn updateWidgetAccessibility(self: PlatformServices, snapshot: WidgetAccessibilitySnapshot) anyerror!void {
2706
3202
  if (snapshot.view_label.len == 0 or snapshot.view_label.len > max_view_label_bytes) return error.InvalidViewOptions;
2707
3203
  if (snapshot.nodes.len > max_widget_accessibility_nodes) return error.InvalidViewOptions;
@@ -2780,6 +3276,16 @@ fn defaultSupportsFeature(services: PlatformServices, feature: PlatformFeature)
2780
3276
  // cannot see it; platforms that analyze answer through their own
2781
3277
  // `supports_fn` (like file_drops and gpu_surfaces above).
2782
3278
  .audio_spectrum => false,
3279
+ // Hide-on-close is host close-delegate behavior, not a service
3280
+ // verb: hosts that implement it answer through their own
3281
+ // `supports_fn`. The generic floor is honest refusal.
3282
+ .window_hide_on_close => false,
3283
+ // The load verb's presence alone is not proof of a decoder:
3284
+ // staged hosts register a teaching load that always refuses, so
3285
+ // they answer false through their own `supports_fn`. The
3286
+ // generic floor still probes the verb for embedders that wire a
3287
+ // real one.
3288
+ .video_playback => services.video_load_fn != null,
2783
3289
  };
2784
3290
  }
2785
3291