@native-sdk/cli 0.5.4 → 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 (149) hide show
  1. package/build/app.zig +50 -1
  2. package/build.zig +534 -3
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +3 -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 +280 -8
  9. package/packages/core/sdk/core.ts +481 -2
  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 +599 -3
  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 +39 -2
  17. package/skill-data/ts-core/SKILL.md +4 -2
  18. package/src/app_runner/root.zig +32 -10
  19. package/src/automation/layout_fingerprint.zig +160 -0
  20. package/src/automation/protocol.zig +82 -33
  21. package/src/automation/root.zig +1 -0
  22. package/src/automation/server.zig +1 -1
  23. package/src/automation/snapshot.zig +68 -9
  24. package/src/automation/watcher.zig +1 -1
  25. package/src/embed/host.zig +5 -0
  26. package/src/embed/ui_host.zig +13 -0
  27. package/src/platform/linux/gtk_host.c +527 -13
  28. package/src/platform/linux/gtk_host.h +25 -0
  29. package/src/platform/linux/root.zig +280 -7
  30. package/src/platform/macos/appkit_host.h +104 -6
  31. package/src/platform/macos/appkit_host.m +1283 -66
  32. package/src/platform/macos/cef_host.mm +110 -1
  33. package/src/platform/macos/root.zig +287 -7
  34. package/src/platform/null_platform.zig +398 -4
  35. package/src/platform/null_platform_tests.zig +35 -0
  36. package/src/platform/root.zig +9 -0
  37. package/src/platform/types.zig +386 -14
  38. package/src/platform/windows/root.zig +298 -9
  39. package/src/platform/windows/webview2_host.cpp +330 -5
  40. package/src/primitives/app_manifest/validation.zig +18 -0
  41. package/src/primitives/canvas/a11y_audit.zig +33 -11
  42. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  43. package/src/primitives/canvas/drawing.zig +25 -0
  44. package/src/primitives/canvas/equality.zig +8 -0
  45. package/src/primitives/canvas/events.zig +103 -16
  46. package/src/primitives/canvas/frame.zig +125 -1
  47. package/src/primitives/canvas/layout_audit.zig +22 -5
  48. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  49. package/src/primitives/canvas/render_tests.zig +13 -10
  50. package/src/primitives/canvas/root.zig +48 -0
  51. package/src/primitives/canvas/terminal_box.zig +471 -0
  52. package/src/primitives/canvas/terminal_grid.zig +978 -0
  53. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  54. package/src/primitives/canvas/test_support.zig +1 -0
  55. package/src/primitives/canvas/tests.zig +1 -0
  56. package/src/primitives/canvas/text_tests.zig +39 -4
  57. package/src/primitives/canvas/tokens.zig +115 -12
  58. package/src/primitives/canvas/ui.zig +524 -5
  59. package/src/primitives/canvas/ui_markup.zig +195 -2
  60. package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
  62. package/src/primitives/canvas/ui_markup_contract.zig +88 -5
  63. package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
  64. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  65. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  66. package/src/primitives/canvas/ui_markup_tests.zig +149 -0
  67. package/src/primitives/canvas/ui_markup_view.zig +191 -0
  68. package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
  69. package/src/primitives/canvas/ui_schema.zig +97 -17
  70. package/src/primitives/canvas/ui_schema_tests.zig +18 -11
  71. package/src/primitives/canvas/ui_tests.zig +141 -9
  72. package/src/primitives/canvas/widget_access.zig +28 -2
  73. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  74. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  75. package/src/primitives/canvas/widget_layout.zig +59 -11
  76. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  77. package/src/primitives/canvas/widget_render.zig +272 -18
  78. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  79. package/src/primitives/canvas/widget_routing.zig +59 -7
  80. package/src/primitives/canvas/widget_runtime.zig +23 -0
  81. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  82. package/src/primitives/canvas/widget_semantics.zig +119 -11
  83. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  84. package/src/primitives/canvas/widget_tree.zig +17 -0
  85. package/src/primitives/canvas/widgets.zig +132 -0
  86. package/src/root.zig +16 -0
  87. package/src/runtime/api.zig +70 -1
  88. package/src/runtime/automation_commands.zig +20 -1
  89. package/src/runtime/automation_snapshot.zig +25 -1
  90. package/src/runtime/automation_widget_dispatch.zig +73 -8
  91. package/src/runtime/bridge_payload.zig +1 -0
  92. package/src/runtime/canvas_frame.zig +62 -7
  93. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  94. package/src/runtime/canvas_frame_helpers.zig +190 -1
  95. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  96. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  97. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  98. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  99. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  100. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  101. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  102. package/src/runtime/canvas_widget_display.zig +1 -1
  103. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  104. package/src/runtime/canvas_widget_events.zig +240 -24
  105. package/src/runtime/canvas_widget_runtime.zig +213 -29
  106. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  107. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  108. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  109. package/src/runtime/canvas_widget_state.zig +6 -0
  110. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  111. package/src/runtime/core.zig +73 -2
  112. package/src/runtime/effects.zig +6389 -54
  113. package/src/runtime/effects_channel_tests.zig +3519 -0
  114. package/src/runtime/effects_pty_tests.zig +1362 -0
  115. package/src/runtime/effects_tests.zig +14 -9
  116. package/src/runtime/effects_video_tests.zig +3609 -0
  117. package/src/runtime/flow.zig +25 -4
  118. package/src/runtime/gpu_surface_events.zig +473 -13
  119. package/src/runtime/media_surface.zig +116 -11
  120. package/src/runtime/media_surface_tests.zig +61 -0
  121. package/src/runtime/pty.zig +1252 -0
  122. package/src/runtime/pty_windows.zig +1780 -0
  123. package/src/runtime/root.zig +25 -0
  124. package/src/runtime/runtime_event_tests.zig +20 -1
  125. package/src/runtime/session_journal.zig +367 -61
  126. package/src/runtime/session_record.zig +16 -0
  127. package/src/runtime/session_replay.zig +395 -11
  128. package/src/runtime/session_tests.zig +109 -15
  129. package/src/runtime/terminal_session.zig +1569 -0
  130. package/src/runtime/terminal_session_tests.zig +450 -0
  131. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  132. package/src/runtime/terminal_vt_stub.zig +13 -0
  133. package/src/runtime/tests.zig +6 -0
  134. package/src/runtime/ts_core_host.zig +980 -140
  135. package/src/runtime/ts_core_host_tests.zig +1059 -1
  136. package/src/runtime/ts_ui_app.zig +16 -5
  137. package/src/runtime/ui_app.zig +2333 -63
  138. package/src/runtime/ui_app_tests.zig +3171 -744
  139. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  140. package/src/runtime/ui_app_window_tests.zig +268 -0
  141. package/src/runtime/view.zig +190 -2
  142. package/src/runtime/view_widget_scroll.zig +218 -68
  143. package/src/runtime/view_widget_text.zig +11 -2
  144. package/src/runtime/view_widget_tree.zig +111 -3
  145. package/src/runtime/window_storage.zig +45 -2
  146. package/src/runtime/window_view_runtime.zig +34 -2
  147. package/src/runtime/window_views.zig +1 -0
  148. package/src/terminal_session_tests_root.zig +15 -0
  149. package/src/tooling/templates.zig +25 -7
@@ -16,6 +16,7 @@
16
16
  #include "include/cef_client.h"
17
17
  #include "include/cef_command_line.h"
18
18
  #include "include/cef_application_mac.h"
19
+ #include "include/cef_focus_handler.h"
19
20
  #include "include/cef_load_handler.h"
20
21
  #include "include/cef_process_message.h"
21
22
  #include "include/cef_values.h"
@@ -102,7 +103,7 @@ private:
102
103
  IMPLEMENT_REFCOUNTING(NativeSdkCefBridgeV8Handler);
103
104
  };
104
105
 
105
- class NativeSdkCefClient final : public CefClient, public CefLifeSpanHandler, public CefLoadHandler, public CefRequestHandler {
106
+ class NativeSdkCefClient final : public CefClient, public CefLifeSpanHandler, public CefLoadHandler, public CefRequestHandler, public CefFocusHandler {
106
107
  public:
107
108
  explicit NativeSdkCefClient(NativeSdkChromiumHost *host, uint64_t window_id) : host_(host), window_id_(window_id) {}
108
109
  NativeSdkCefClient(NativeSdkChromiumHost *host, uint64_t window_id, std::string webview_key, uint64_t webview_generation, bool bridge_enabled) : host_(host), window_id_(window_id), webview_key_(webview_key), webview_generation_(webview_generation), bridge_enabled_(bridge_enabled) {}
@@ -119,8 +120,13 @@ public:
119
120
  return this;
120
121
  }
121
122
 
123
+ CefRefPtr<CefFocusHandler> GetFocusHandler() override {
124
+ return this;
125
+ }
126
+
122
127
  void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
123
128
  void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
129
+ void OnGotFocus(CefRefPtr<CefBrowser> browser) override;
124
130
  void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) override;
125
131
  bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, bool user_gesture, bool is_redirect) override;
126
132
  bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefProcessId source_process, CefRefPtr<CefProcessMessage> message) override;
@@ -595,6 +601,7 @@ static const char *NativeSdkCefBridgeScript() {
595
601
  - (void)emitWindowFrameForWindowId:(uint64_t)windowId open:(BOOL)open;
596
602
  - (void)emitFrame;
597
603
  - (void)emitShutdown;
604
+ - (void)emitViewFocusedForWindowId:(uint64_t)windowId label:(NSString *)label;
598
605
  - (void)loadSource:(NSString *)source kind:(NSInteger)kind assetRoot:(NSString *)assetRoot entry:(NSString *)entry origin:(NSString *)origin spaFallback:(BOOL)spaFallback;
599
606
  - (void)loadSource:(NSString *)source kind:(NSInteger)kind assetRoot:(NSString *)assetRoot entry:(NSString *)entry origin:(NSString *)origin spaFallback:(BOOL)spaFallback windowId:(uint64_t)windowId;
600
607
  - (void)setAllowedNavigationOrigins:(NSArray<NSString *> *)origins externalURLs:(NSArray<NSString *> *)externalURLs externalAction:(NSInteger)externalAction;
@@ -1190,6 +1197,18 @@ static const char *NativeSdkCefBridgeScript() {
1190
1197
  if (self.callback) self.callback(self.context, &event);
1191
1198
  }
1192
1199
 
1200
+ - (void)emitViewFocusedForWindowId:(uint64_t)windowId label:(NSString *)label {
1201
+ NSWindow *window = self.windows[@(windowId)] ?: (windowId == 1 ? self.window : nil);
1202
+ if (!window || label.length == 0) return;
1203
+ const char *labelBytes = label.UTF8String ?: "";
1204
+ [self emitEvent:(native_sdk_appkit_event_t){
1205
+ .kind = NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED,
1206
+ .window_id = windowId,
1207
+ .view_label = labelBytes,
1208
+ .view_label_len = strlen(labelBytes),
1209
+ }];
1210
+ }
1211
+
1193
1212
  - (void)startApplicationActivationObservers {
1194
1213
  if (self.observesApplicationActivation) return;
1195
1214
  NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
@@ -1899,6 +1918,21 @@ static NSString *NativeSdkShortcutKeyForEvent(NSEvent *event) {
1899
1918
  case NSDeleteFunctionKey: return @"delete";
1900
1919
  case NSHomeFunctionKey: return @"home";
1901
1920
  case NSEndFunctionKey: return @"end";
1921
+ case NSPageUpFunctionKey: return @"pageup";
1922
+ case NSPageDownFunctionKey: return @"pagedown";
1923
+ case NSInsertFunctionKey: return @"insert";
1924
+ case NSF1FunctionKey: return @"f1";
1925
+ case NSF2FunctionKey: return @"f2";
1926
+ case NSF3FunctionKey: return @"f3";
1927
+ case NSF4FunctionKey: return @"f4";
1928
+ case NSF5FunctionKey: return @"f5";
1929
+ case NSF6FunctionKey: return @"f6";
1930
+ case NSF7FunctionKey: return @"f7";
1931
+ case NSF8FunctionKey: return @"f8";
1932
+ case NSF9FunctionKey: return @"f9";
1933
+ case NSF10FunctionKey: return @"f10";
1934
+ case NSF11FunctionKey: return @"f11";
1935
+ case NSF12FunctionKey: return @"f12";
1902
1936
  case 0x1b: return @"escape";
1903
1937
  case '\r': return @"enter";
1904
1938
  case '\t': return @"tab";
@@ -1989,6 +2023,18 @@ void NativeSdkCefClient::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
1989
2023
  [host_ cleanupClosedWebViewWithKey:key ?: @"" generation:webview_generation_];
1990
2024
  }
1991
2025
 
2026
+ void NativeSdkCefClient::OnGotFocus(CefRefPtr<CefBrowser> browser) {
2027
+ (void)browser;
2028
+ if (!host_) return;
2029
+ if (!webview_key_.empty()) {
2030
+ NSString *key = [[NSString alloc] initWithBytes:webview_key_.data() length:webview_key_.size() encoding:NSUTF8StringEncoding];
2031
+ if (![host_ webViewGeneration:webview_generation_ matchesKey:key ?: @""]) return;
2032
+ }
2033
+ const std::string label = WebViewLabel();
2034
+ NSString *labelString = [[NSString alloc] initWithBytes:label.data() length:label.size() encoding:NSUTF8StringEncoding];
2035
+ [host_ emitViewFocusedForWindowId:window_id_ label:labelString ?: @""];
2036
+ }
2037
+
1992
2038
  void NativeSdkCefClient::OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) {
1993
2039
  (void)browser;
1994
2040
  (void)errorText;
@@ -2548,6 +2594,69 @@ int native_sdk_appkit_audio_set_volume(native_sdk_appkit_host_t *host, double vo
2548
2594
  return 0;
2549
2595
  }
2550
2596
 
2597
+ /* Video playback lives in the system-engine AppKit host (AVFoundation).
2598
+ * The Chromium host reports the feature unsupported and the Zig side
2599
+ * refuses before calling, so these exist only to satisfy the shared C
2600
+ * ABI — each answers with its honest failure code. */
2601
+ int native_sdk_appkit_video_load(native_sdk_appkit_host_t *host, const char *path, size_t path_len, uint64_t token, native_sdk_appkit_video_sink_push_t push_fn, void *push_context) {
2602
+ (void)host;
2603
+ (void)path;
2604
+ (void)path_len;
2605
+ (void)token;
2606
+ (void)push_fn;
2607
+ (void)push_context;
2608
+ return 2;
2609
+ }
2610
+
2611
+ int native_sdk_appkit_video_load_url(native_sdk_appkit_host_t *host, const char *url, size_t url_len, uint64_t token, native_sdk_appkit_video_sink_push_t push_fn, void *push_context) {
2612
+ (void)host;
2613
+ (void)url;
2614
+ (void)url_len;
2615
+ (void)token;
2616
+ (void)push_fn;
2617
+ (void)push_context;
2618
+ return 2;
2619
+ }
2620
+
2621
+ int native_sdk_appkit_video_play(native_sdk_appkit_host_t *host) {
2622
+ (void)host;
2623
+ return 0;
2624
+ }
2625
+
2626
+ int native_sdk_appkit_video_pause(native_sdk_appkit_host_t *host) {
2627
+ (void)host;
2628
+ return 0;
2629
+ }
2630
+
2631
+ int native_sdk_appkit_video_stop(native_sdk_appkit_host_t *host) {
2632
+ (void)host;
2633
+ return 0;
2634
+ }
2635
+
2636
+ int native_sdk_appkit_video_seek(native_sdk_appkit_host_t *host, uint64_t position_ms) {
2637
+ (void)host;
2638
+ (void)position_ms;
2639
+ return 0;
2640
+ }
2641
+
2642
+ int native_sdk_appkit_video_set_volume(native_sdk_appkit_host_t *host, double volume) {
2643
+ (void)host;
2644
+ (void)volume;
2645
+ return 0;
2646
+ }
2647
+
2648
+ int native_sdk_appkit_video_set_muted(native_sdk_appkit_host_t *host, int muted) {
2649
+ (void)host;
2650
+ (void)muted;
2651
+ return 0;
2652
+ }
2653
+
2654
+ int native_sdk_appkit_video_set_loop(native_sdk_appkit_host_t *host, int loop) {
2655
+ (void)host;
2656
+ (void)loop;
2657
+ return 0;
2658
+ }
2659
+
2551
2660
  void native_sdk_appkit_request_frame(native_sdk_appkit_host_t *host) {
2552
2661
  // The AppKit host pauses FRAME events when idle, so a cross-thread
2553
2662
  // frame request is how the automation arrival watcher wakes it. The
@@ -39,6 +39,8 @@ const AppKitEventKind = enum(c_int) {
39
39
  gpu_surface_scroll_driver = 18,
40
40
  context_menu_action = 19,
41
41
  audio = 20,
42
+ video = 21,
43
+ view_focused = 22,
42
44
  };
43
45
 
44
46
  const AppKitEvent = extern struct {
@@ -93,6 +95,7 @@ const AppKitEvent = extern struct {
93
95
  reduce_motion: c_int,
94
96
  high_contrast: c_int,
95
97
  timer_id: u64,
98
+ scroll_driver_offset_x: f64,
96
99
  scroll_driver_offset_y: f64,
97
100
  menu_item_id: u32,
98
101
  /// Host-stamped packet decode/draw durations riding the frame
@@ -117,10 +120,34 @@ const AppKitEvent = extern struct {
117
120
  /// documented scale (log-spaced 50 Hz..16 kHz buckets, linear-in-dB
118
121
  /// from -60 dBFS at 0 to full scale at 255). Zeros elsewhere.
119
122
  audio_bands: [platform_mod.audio_spectrum_band_count]u8,
123
+ /// Video player report payload (`kind == .video`): the
124
+ /// `VideoEventKind` ordinal plus the player's position/duration
125
+ /// readout at emit time. `video_buffering` is stream-only, distinct
126
+ /// from `video_playing` (the transport intent) — the audio pair's
127
+ /// exact semantics.
128
+ video_kind: c_int,
129
+ /// The engine-minted load token this event's playback echoes (see
130
+ /// `platform.VideoEvent.token`).
131
+ video_token: u64,
132
+ video_position_ms: u64,
133
+ video_duration_ms: u64,
134
+ video_playing: c_int,
135
+ video_buffering: c_int,
136
+ /// `.loaded` payload: the STREAM's decoded pixel dimensions — the
137
+ /// honest source geometry even when the host fits frames to the
138
+ /// sink's pixel budget. Zeros on every other kind.
139
+ video_width: u64,
140
+ video_height: u64,
120
141
  };
121
142
 
122
143
  const AppKitCallback = *const fn (context: ?*anyopaque, event: *const AppKitEvent) callconv(.c) void;
123
144
  const AppKitBridgeCallback = *const fn (context: ?*anyopaque, window_id: u64, webview_label: [*]const u8, webview_label_len: usize, message: [*]const u8, message_len: usize, origin: [*]const u8, origin_len: usize) callconv(.c) void;
145
+ /// Where the AppKit host's video frame pump delivers decoded frames
146
+ /// (`native_sdk_appkit_video_sink_push_t`): one tightly packed
147
+ /// straight-alpha RGBA8 frame per call, answered 0 accepted, 1 the
148
+ /// receiving claim was released (the host stops its frame timer),
149
+ /// anything else one dropped frame.
150
+ const AppKitVideoSinkPush = *const fn (context: ?*anyopaque, width: usize, height: usize, pixels: [*c]const u8, len: usize) callconv(.c) c_int;
124
151
 
125
152
  const shortcut_modifier_primary: u32 = 1 << 0;
126
153
  const shortcut_modifier_command: u32 = 1 << 1;
@@ -166,7 +193,7 @@ extern fn native_sdk_appkit_adopt_view_surface(host: *AppKitHost, window_id: u64
166
193
  extern fn native_sdk_appkit_release_view_surface(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize) c_int;
167
194
  extern fn native_sdk_appkit_request_gpu_surface_frame(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize) c_int;
168
195
  extern fn native_sdk_appkit_note_gpu_surface_input(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize) c_int;
169
- extern fn native_sdk_appkit_set_gpu_surface_scroll_drivers(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize, drivers: [*]const AppKitScrollDriver, count: usize) c_int;
196
+ extern fn native_sdk_appkit_set_gpu_surface_scroll_drivers(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize, drivers: [*]const AppKitScrollDriver, count: usize, occluders: [*]const AppKitScrollOccluder, occluder_count: usize) c_int;
170
197
  extern fn native_sdk_appkit_show_context_menu(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize, x: f64, y: f64, token: u64, items: [*]const AppKitContextMenuItem, count: usize) c_int;
171
198
  extern fn native_sdk_appkit_start_timer(host: *AppKitHost, timer_id: u64, interval_ns: u64, repeats: c_int) void;
172
199
  extern fn native_sdk_appkit_cancel_timer(host: *AppKitHost, timer_id: u64) void;
@@ -177,6 +204,15 @@ extern fn native_sdk_appkit_audio_pause(host: *AppKitHost) c_int;
177
204
  extern fn native_sdk_appkit_audio_stop(host: *AppKitHost) c_int;
178
205
  extern fn native_sdk_appkit_audio_seek(host: *AppKitHost, position_ms: u64) c_int;
179
206
  extern fn native_sdk_appkit_audio_set_volume(host: *AppKitHost, volume: f64) c_int;
207
+ extern fn native_sdk_appkit_video_load(host: *AppKitHost, path: [*]const u8, path_len: usize, token: u64, push_fn: AppKitVideoSinkPush, push_context: ?*anyopaque) c_int;
208
+ extern fn native_sdk_appkit_video_load_url(host: *AppKitHost, url: [*]const u8, url_len: usize, token: u64, push_fn: AppKitVideoSinkPush, push_context: ?*anyopaque) c_int;
209
+ extern fn native_sdk_appkit_video_play(host: *AppKitHost) c_int;
210
+ extern fn native_sdk_appkit_video_pause(host: *AppKitHost) c_int;
211
+ extern fn native_sdk_appkit_video_stop(host: *AppKitHost) c_int;
212
+ extern fn native_sdk_appkit_video_seek(host: *AppKitHost, position_ms: u64) c_int;
213
+ extern fn native_sdk_appkit_video_set_volume(host: *AppKitHost, volume: f64) c_int;
214
+ extern fn native_sdk_appkit_video_set_muted(host: *AppKitHost, muted: c_int) c_int;
215
+ extern fn native_sdk_appkit_video_set_loop(host: *AppKitHost, loop: c_int) c_int;
180
216
  extern fn native_sdk_appkit_wake(host: *AppKitHost) void;
181
217
  extern fn native_sdk_appkit_present_gpu_surface_pixels(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize, width: usize, height: usize, scale: f64, has_dirty_rect: c_int, dirty_x: f64, dirty_y: f64, dirty_width: f64, dirty_height: f64, rgba8: [*]const u8, rgba8_len: usize) c_int;
182
218
  extern fn native_sdk_appkit_present_gpu_surface_packet(host: *AppKitHost, window_id: u64, label: [*]const u8, label_len: usize, surface_width: f64, surface_height: f64, scale: f64, clear_r: u8, clear_g: u8, clear_b: u8, clear_a: u8, requires_render: c_int, command_count: usize, unsupported_command_count: usize, representable: c_int, json: [*]const u8, json_len: usize) c_int;
@@ -209,17 +245,30 @@ extern fn native_sdk_appkit_set_credential(host: *AppKitHost, service: [*]const
209
245
  extern fn native_sdk_appkit_get_credential(host: *AppKitHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize, buffer: [*]u8, buffer_len: usize) usize;
210
246
  extern fn native_sdk_appkit_delete_credential(host: *AppKitHost, service: [*]const u8, service_len: usize, account: [*]const u8, account_len: usize) c_int;
211
247
 
248
+ const AppKitScrollOccluder = extern struct {
249
+ x: f64,
250
+ y: f64,
251
+ width: f64,
252
+ height: f64,
253
+ };
254
+
212
255
  const AppKitScrollDriver = extern struct {
213
256
  driver_id: u64,
257
+ parent_driver_id: u64,
258
+ occluder_mask: u32,
214
259
  x: f64,
215
260
  y: f64,
216
261
  width: f64,
217
262
  height: f64,
218
263
  content_width: f64,
219
264
  content_height: f64,
265
+ offset_x: f64,
220
266
  offset_y: f64,
221
- set_offset: c_int,
267
+ set_offset_x: c_int,
268
+ set_offset_y: c_int,
222
269
  rubber_band: c_int,
270
+ scrolls_x: c_int,
271
+ scrolls_y: c_int,
223
272
  };
224
273
 
225
274
  const AppKitContextMenuItem = extern struct {
@@ -516,6 +565,25 @@ pub const MacPlatform = struct {
516
565
  app_info: platform_mod.AppInfo,
517
566
  surface_value: platform_mod.Surface,
518
567
  state: RunState = .{},
568
+ /// Latched when the runtime's effects teardown abandons an
569
+ /// in-flight channel `wake_fn` call (see
570
+ /// `PlatformServices.note_channel_wake_abandoned_fn`): the stale
571
+ /// call still holds this platform as its context and may execute
572
+ /// into it at any later time, so `deinit` must skip destruction
573
+ /// and leak the host, process-lived — and the wrapper struct the
574
+ /// context actually points at (the wake thunk casts to
575
+ /// `*MacPlatform` before reaching the host) must outlive the call
576
+ /// too, which is why runners allocate it through
577
+ /// `createWithOptions` and retire it through `destroy`, the
578
+ /// latch-gated free.
579
+ channel_wake_abandoned: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
580
+ /// The CURRENT video frame sink — the host's C push trampoline
581
+ /// cannot carry a Zig error-union fn pointer, so the sink lives
582
+ /// here and `nativeSdkVideoSinkPush` forwards through it. Single
583
+ /// player, single slot: loads replace it on the main thread, and
584
+ /// every push happens on the main thread (the host's frame pump is
585
+ /// a run-loop timer), so a plain field is race-free.
586
+ video_sink: platform_mod.VideoFrameSink = .{},
519
587
 
520
588
  pub fn init(title: []const u8, size: geometry.SizeF) Error!MacPlatform {
521
589
  return initWithEngine(title, size, .system);
@@ -568,7 +636,44 @@ pub const MacPlatform = struct {
568
636
  };
569
637
  }
570
638
 
639
+ /// Heap-allocate the wrapper (process allocator) and initialize it
640
+ /// in place. Runners must use this over a stack `initWithOptions`
641
+ /// value: `platform().services.context` is this wrapper's ADDRESS,
642
+ /// worker threads dereference it inside the channel wake path, and
643
+ /// a wake call teardown abandons may do so at any later time —
644
+ /// after a runner's stack frame would have unwound. Pair with
645
+ /// `destroy`, the latch-gated free.
646
+ pub fn createWithOptions(size: geometry.SizeF, web_engine: platform_mod.WebEngine, app_info: platform_mod.AppInfo) Error!*MacPlatform {
647
+ const self = std.heap.page_allocator.create(MacPlatform) catch return error.CreateFailed;
648
+ errdefer std.heap.page_allocator.destroy(self);
649
+ self.* = try initWithOptions(size, web_engine, app_info);
650
+ return self;
651
+ }
652
+
653
+ /// `deinit` plus the wrapper's own storage, gated by the same
654
+ /// latch: an abandoned channel wake call dereferences this wrapper
655
+ /// (its context) BEFORE it reaches the native host, so on abandon
656
+ /// both are leaked, process-lived — deinit-gating extended to
657
+ /// lifetime-gating, the honest completion of the abandoned-worker
658
+ /// idiom. No cross-thread race on the gate: the latch is set
659
+ /// synchronously on the loop thread during effects teardown, which
660
+ /// runs before the runner's deferred destroy.
661
+ pub fn destroy(self: *MacPlatform) void {
662
+ self.deinit();
663
+ if (self.channel_wake_abandoned.load(.seq_cst)) return;
664
+ std.heap.page_allocator.destroy(self);
665
+ }
666
+
571
667
  pub fn deinit(self: *MacPlatform) void {
668
+ // An abandoned channel wake call may still enter this host at
669
+ // any later time (see `channel_wake_abandoned`): destroying it
670
+ // would turn that stale call into a use-after-free, so the
671
+ // host is deliberately leaked, process-lived — the
672
+ // abandoned-worker idiom, applied to the platform itself.
673
+ if (self.channel_wake_abandoned.load(.seq_cst)) {
674
+ std.debug.print("macos platform teardown: an abandoned channel wake call may still enter this host; skipping destruction and leaking it (and the wrapper it enters through), process-lived, so the stale call stays safe\n", .{});
675
+ return;
676
+ }
572
677
  native_sdk_appkit_destroy(self.host);
573
678
  }
574
679
 
@@ -641,7 +746,17 @@ pub const MacPlatform = struct {
641
746
  .audio_stop_fn = audioStop,
642
747
  .audio_seek_fn = audioSeek,
643
748
  .audio_set_volume_fn = audioSetVolume,
749
+ .video_load_fn = videoLoad,
750
+ .video_load_url_fn = videoLoadUrl,
751
+ .video_play_fn = videoPlay,
752
+ .video_pause_fn = videoPause,
753
+ .video_stop_fn = videoStop,
754
+ .video_seek_fn = videoSeek,
755
+ .video_set_volume_fn = videoSetVolume,
756
+ .video_set_muted_fn = videoSetMuted,
757
+ .video_set_loop_fn = videoSetLoop,
644
758
  .wake_fn = wake,
759
+ .note_channel_wake_abandoned_fn = noteChannelWakeAbandoned,
645
760
  .request_frame_fn = requestFrame,
646
761
  .request_gpu_surface_frame_fn = requestGpuSurfaceFrame,
647
762
  .note_gpu_surface_input_fn = noteGpuSurfaceInput,
@@ -703,6 +818,12 @@ pub const MacPlatform = struct {
703
818
  .audio_streaming,
704
819
  .audio_spectrum,
705
820
  => self.web_engine == .system,
821
+ // AVFoundation video ships in the AppKit host only (one
822
+ // AVPlayer whose AVPlayerItemVideoOutput frames feed the
823
+ // media-surface sink); the CEF host stubs the C ABI and
824
+ // reports honestly unsupported rather than half-implementing
825
+ // a second player.
826
+ .video_playback => self.web_engine == .system,
706
827
  };
707
828
  }
708
829
 
@@ -790,6 +911,10 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
790
911
  .hidden = event.hidden != 0,
791
912
  } });
792
913
  },
914
+ .view_focused => state.emit(.{ .view_focused = .{
915
+ .window_id = event.window_id,
916
+ .label = event.view_label[0..event.view_label_len],
917
+ } }),
793
918
  .shortcut => state.emit(.{ .shortcut = .{
794
919
  .id = event.shortcut_id[0..event.shortcut_id_len],
795
920
  .key = event.shortcut_key[0..event.shortcut_key_len],
@@ -850,6 +975,7 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
850
975
  .window_id = event.window_id,
851
976
  .label = event.view_label[0..event.view_label_len],
852
977
  .driver_id = event.widget_id,
978
+ .offset_x = @floatCast(event.scroll_driver_offset_x),
853
979
  .offset_y = @floatCast(event.scroll_driver_offset_y),
854
980
  .timestamp_ns = event.timestamp_ns,
855
981
  } }),
@@ -867,6 +993,16 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
867
993
  .buffering = event.audio_buffering != 0,
868
994
  .bands = event.audio_bands,
869
995
  } }),
996
+ .video => state.emit(.{ .video = .{
997
+ .kind = videoEventKindFromInt(event.video_kind),
998
+ .token = event.video_token,
999
+ .position_ms = event.video_position_ms,
1000
+ .duration_ms = event.video_duration_ms,
1001
+ .playing = event.video_playing != 0,
1002
+ .buffering = event.video_buffering != 0,
1003
+ .width = event.video_width,
1004
+ .height = event.video_height,
1005
+ } }),
870
1006
  .widget_accessibility_action => if (widgetAccessibilityActionFromInt(event.widget_action)) |action| {
871
1007
  state.emit(.{ .widget_accessibility_action = .{
872
1008
  .window_id = event.window_id,
@@ -910,6 +1046,18 @@ fn audioEventKindFromInt(value: c_int) platform_mod.AudioEventKind {
910
1046
  };
911
1047
  }
912
1048
 
1049
+ /// Ordinals match `native_sdk_appkit_video_event_kind_t` in
1050
+ /// appkit_host.h; anything unknown degrades to `.failed` so a host/SDK
1051
+ /// skew is loud in the app instead of undefined behavior here.
1052
+ fn videoEventKindFromInt(value: c_int) platform_mod.VideoEventKind {
1053
+ return switch (value) {
1054
+ 0 => .loaded,
1055
+ 1 => .position,
1056
+ 2 => .completed,
1057
+ else => .failed,
1058
+ };
1059
+ }
1060
+
913
1061
  fn gpuSurfaceInputEventFromAppKitEvent(event: *const AppKitEvent) platform_mod.GpuSurfaceInputEvent {
914
1062
  return .{
915
1063
  .window_id = event.window_id,
@@ -1365,13 +1513,105 @@ fn audioSetVolume(context: ?*anyopaque, volume: f32) anyerror!void {
1365
1513
  _ = native_sdk_appkit_audio_set_volume(self.host, volume);
1366
1514
  }
1367
1515
 
1368
- /// Thread-safe: dispatches onto the main queue, which emits `.wake` on
1369
- /// the AppKit run loop. One of the two services worker threads may call.
1516
+ /// The C-callable bridge for `VideoFrameSink.push`: the sink's `push_fn`
1517
+ /// is a Zig-calling-convention error-union fn the host cannot invoke, so
1518
+ /// the host is handed this trampoline (context = the `MacPlatform`) and
1519
+ /// it forwards through the platform's current sink. Answers 0 accepted,
1520
+ /// 1 when the claim reports `error.MediaSurfaceReleased` (the host stops
1521
+ /// its frame timer — a released claim just means stop pushing), 2 for
1522
+ /// any other refusal (one dropped frame; latest-wins).
1523
+ fn nativeSdkVideoSinkPush(context: ?*anyopaque, width: usize, height: usize, pixels: [*c]const u8, len: usize) callconv(.c) c_int {
1524
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1525
+ self.video_sink.push(width, height, pixels[0..len]) catch |err| {
1526
+ return if (err == error.MediaSurfaceReleased) 1 else 2;
1527
+ };
1528
+ return 0;
1529
+ }
1530
+
1531
+ /// Map the video host's synchronous load result: 0 loaded, 1 the file is
1532
+ /// missing/unreadable, anything else a decode failure. The asynchronous
1533
+ /// `.loaded` acknowledgment (with the stream's dimensions and duration)
1534
+ /// follows as a `.video` event on the run loop; decoded frames flow
1535
+ /// through the sink stored on the platform (see `nativeSdkVideoSinkPush`).
1536
+ fn videoLoad(context: ?*anyopaque, path: []const u8, token: u64, sink: platform_mod.VideoFrameSink) anyerror!void {
1537
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1538
+ if (self.web_engine != .system) return error.UnsupportedService;
1539
+ self.video_sink = sink;
1540
+ return switch (native_sdk_appkit_video_load(self.host, path.ptr, path.len, token, nativeSdkVideoSinkPush, self)) {
1541
+ 0 => {},
1542
+ 1 => error.VideoSourceNotFound,
1543
+ else => error.VideoDecodeFailed,
1544
+ };
1545
+ }
1546
+
1547
+ /// Map the streaming host's synchronous result: 0 a progressive stream
1548
+ /// started (the `.loaded` acknowledgment follows when the item is
1549
+ /// ready), anything else the URL itself was unusable. Network failures
1550
+ /// after this point are asynchronous and arrive as `.video`/`.failed`
1551
+ /// events.
1552
+ fn videoLoadUrl(context: ?*anyopaque, url: []const u8, token: u64, sink: platform_mod.VideoFrameSink) anyerror!void {
1553
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1554
+ if (self.web_engine != .system) return error.UnsupportedService;
1555
+ self.video_sink = sink;
1556
+ return switch (native_sdk_appkit_video_load_url(self.host, url.ptr, url.len, token, nativeSdkVideoSinkPush, self)) {
1557
+ 0 => {},
1558
+ else => error.InvalidVideoOptions,
1559
+ };
1560
+ }
1561
+
1562
+ fn videoPlay(context: ?*anyopaque) anyerror!void {
1563
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1564
+ if (native_sdk_appkit_video_play(self.host) == 0) return error.InvalidVideoOptions;
1565
+ }
1566
+
1567
+ fn videoPause(context: ?*anyopaque) anyerror!void {
1568
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1569
+ _ = native_sdk_appkit_video_pause(self.host);
1570
+ }
1571
+
1572
+ fn videoStop(context: ?*anyopaque) anyerror!void {
1573
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1574
+ _ = native_sdk_appkit_video_stop(self.host);
1575
+ self.video_sink = .{};
1576
+ }
1577
+
1578
+ fn videoSeek(context: ?*anyopaque, position_ms: u64) anyerror!void {
1579
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1580
+ if (native_sdk_appkit_video_seek(self.host, position_ms) == 0) return error.InvalidVideoOptions;
1581
+ }
1582
+
1583
+ fn videoSetVolume(context: ?*anyopaque, volume: f32) anyerror!void {
1584
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1585
+ _ = native_sdk_appkit_video_set_volume(self.host, volume);
1586
+ }
1587
+
1588
+ fn videoSetMuted(context: ?*anyopaque, muted: bool) anyerror!void {
1589
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1590
+ _ = native_sdk_appkit_video_set_muted(self.host, if (muted) 1 else 0);
1591
+ }
1592
+
1593
+ fn videoSetLoop(context: ?*anyopaque, loop: bool) anyerror!void {
1594
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1595
+ _ = native_sdk_appkit_video_set_loop(self.host, if (loop) 1 else 0);
1596
+ }
1597
+
1598
+ /// Thread-safe: dispatches onto the main queue (`dispatch_async` — the
1599
+ /// enqueue-only shape the wake contract requires), which emits `.wake`
1600
+ /// on the AppKit run loop. One of the two services worker threads may
1601
+ /// call.
1370
1602
  fn wake(context: ?*anyopaque) anyerror!void {
1371
1603
  const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1372
1604
  native_sdk_appkit_wake(self.host);
1373
1605
  }
1374
1606
 
1607
+ /// Teardown abandoned an in-flight channel wake call: latch the flag
1608
+ /// `deinit` consults so this host is leaked rather than destroyed (see
1609
+ /// `MacPlatform.channel_wake_abandoned`).
1610
+ fn noteChannelWakeAbandoned(context: ?*anyopaque) void {
1611
+ const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1612
+ self.channel_wake_abandoned.store(true, .seq_cst);
1613
+ }
1614
+
1375
1615
  /// Thread-safe like `wake`: dispatches onto the main queue, which emits
1376
1616
  /// one coalesced `frame` event on the AppKit run loop. The automation
1377
1617
  /// arrival watcher calls this when a command lands so an idle app runs
@@ -1394,7 +1634,7 @@ fn noteGpuSurfaceInput(context: ?*anyopaque, window_id: platform_mod.WindowId, l
1394
1634
  _ = native_sdk_appkit_note_gpu_surface_input(self.host, window_id, label.ptr, label.len);
1395
1635
  }
1396
1636
 
1397
- fn setGpuSurfaceScrollDrivers(context: ?*anyopaque, window_id: platform_mod.WindowId, label: []const u8, drivers: []const platform_mod.GpuSurfaceScrollDriver) anyerror!void {
1637
+ fn setGpuSurfaceScrollDrivers(context: ?*anyopaque, window_id: platform_mod.WindowId, label: []const u8, drivers: []const platform_mod.GpuSurfaceScrollDriver, occluders: []const platform_mod.GpuSurfaceScrollOccluder) anyerror!void {
1398
1638
  const self: *MacPlatform = @ptrCast(@alignCast(context.?));
1399
1639
  if (self.web_engine != .system) return error.UnsupportedService;
1400
1640
  var specs: [platform_mod.max_gpu_surface_scroll_drivers]AppKitScrollDriver = undefined;
@@ -1402,18 +1642,34 @@ fn setGpuSurfaceScrollDrivers(context: ?*anyopaque, window_id: platform_mod.Wind
1402
1642
  for (drivers[0..count], 0..) |driver, index| {
1403
1643
  specs[index] = .{
1404
1644
  .driver_id = driver.id,
1645
+ .parent_driver_id = driver.parent_id,
1646
+ .occluder_mask = driver.occluder_mask,
1405
1647
  .x = driver.frame.x,
1406
1648
  .y = driver.frame.y,
1407
1649
  .width = driver.frame.width,
1408
1650
  .height = driver.frame.height,
1409
1651
  .content_width = driver.content_size.width,
1410
1652
  .content_height = driver.content_size.height,
1653
+ .offset_x = driver.offset_x,
1411
1654
  .offset_y = driver.offset_y,
1412
- .set_offset = if (driver.set_offset) 1 else 0,
1655
+ .set_offset_x = if (driver.set_offset_x) 1 else 0,
1656
+ .set_offset_y = if (driver.set_offset_y) 1 else 0,
1413
1657
  .rubber_band = if (driver.rubber_band) 1 else 0,
1658
+ .scrolls_x = if (driver.scrolls_x) 1 else 0,
1659
+ .scrolls_y = if (driver.scrolls_y) 1 else 0,
1414
1660
  };
1415
1661
  }
1416
- if (native_sdk_appkit_set_gpu_surface_scroll_drivers(self.host, window_id, label.ptr, label.len, &specs, count) == 0) return error.ViewNotFound;
1662
+ var occluder_specs: [platform_mod.max_gpu_surface_scroll_occluders]AppKitScrollOccluder = undefined;
1663
+ const occluder_count = @min(occluders.len, occluder_specs.len);
1664
+ for (occluders[0..occluder_count], 0..) |occluder, index| {
1665
+ occluder_specs[index] = .{
1666
+ .x = occluder.frame.x,
1667
+ .y = occluder.frame.y,
1668
+ .width = occluder.frame.width,
1669
+ .height = occluder.frame.height,
1670
+ };
1671
+ }
1672
+ if (native_sdk_appkit_set_gpu_surface_scroll_drivers(self.host, window_id, label.ptr, label.len, &specs, count, &occluder_specs, occluder_count) == 0) return error.ViewNotFound;
1417
1673
  }
1418
1674
 
1419
1675
  fn showContextMenu(context: ?*anyopaque, request: platform_mod.ContextMenuRequest) anyerror!void {
@@ -2157,6 +2413,30 @@ test "mac platform module exports type" {
2157
2413
  _ = MacPlatform;
2158
2414
  }
2159
2415
 
2416
+ test "mac webview presses report the focused child label" {
2417
+ // WKWebView owns the page's pointer stream, so the AppKit host
2418
+ // observes the down before dispatch and emits the explicit inverse
2419
+ // edge that blurs a sibling canvas view.
2420
+ const host_source = @embedFile("appkit_host.m");
2421
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown | NSEventMaskOtherMouseDown") != null);
2422
+ try std.testing.expect(std.mem.indexOf(u8, host_source, ".kind = NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED") != null);
2423
+ try std.testing.expect(std.mem.indexOf(u8, host_source, ".view_label = label") != null);
2424
+ }
2425
+
2426
+ test "mac Chromium webview focus reports the focused child label" {
2427
+ // CEF's focus handler is the engine-level ownership edge: it covers
2428
+ // pointer, keyboard, and programmatic focus without predicting from
2429
+ // a press. A generation guard keeps a closing/replaced child from
2430
+ // publishing its old label after runtime storage has moved on.
2431
+ const host_source = @embedFile("cef_host.mm");
2432
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "public CefFocusHandler") != null);
2433
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "CefRefPtr<CefFocusHandler> GetFocusHandler() override") != null);
2434
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "void NativeSdkCefClient::OnGotFocus") != null);
2435
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "webViewGeneration:webview_generation_ matchesKey:") != null);
2436
+ try std.testing.expect(std.mem.indexOf(u8, host_source, ".kind = NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED") != null);
2437
+ try std.testing.expect(std.mem.indexOf(u8, host_source, "emitViewFocusedForWindowId:window_id_ label:") != null);
2438
+ }
2439
+
2160
2440
  test "mac dock icon fallback renders the embedded toolkit default" {
2161
2441
  // The exact pipeline `defaultDockIconRenderMain` hands the host:
2162
2442
  // decode the embedded default and render the packaging canvas. This