@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
@@ -32,6 +32,8 @@ typedef enum {
32
32
  NATIVE_SDK_APPKIT_EVENT_GPU_SURFACE_SCROLL_DRIVER = 18,
33
33
  NATIVE_SDK_APPKIT_EVENT_CONTEXT_MENU_ACTION = 19,
34
34
  NATIVE_SDK_APPKIT_EVENT_AUDIO = 20,
35
+ NATIVE_SDK_APPKIT_EVENT_VIDEO = 21,
36
+ NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED = 22,
35
37
  } native_sdk_appkit_event_kind_t;
36
38
 
37
39
  /* Audio player reports (EVENT_AUDIO payloads). LOADED acknowledges a
@@ -53,6 +55,23 @@ typedef enum {
53
55
  NATIVE_SDK_APPKIT_AUDIO_EVENT_SPECTRUM = 4,
54
56
  } native_sdk_appkit_audio_event_kind_t;
55
57
 
58
+ /* Video player reports (EVENT_VIDEO payloads). LOADED acknowledges a
59
+ * successful native_sdk_appkit_video_load (or a ready URL stream) with
60
+ * the stream's true pixel dimensions and the decoded duration; POSITION
61
+ * ticks at a coarse honest cadence (~500ms) only while playing;
62
+ * COMPLETED fires exactly once at a non-looping video's natural end (a
63
+ * looping playback wraps and never completes); FAILED reports an
64
+ * asynchronous decode/device failure — or a network failure that killed
65
+ * a stream mid-flight. Pixels never ride events: decoded frames flow
66
+ * through the sink push handed to the load entries. Ordinals are
67
+ * mirrored by the Zig side (videoEventKindFromInt). */
68
+ typedef enum {
69
+ NATIVE_SDK_APPKIT_VIDEO_EVENT_LOADED = 0,
70
+ NATIVE_SDK_APPKIT_VIDEO_EVENT_POSITION = 1,
71
+ NATIVE_SDK_APPKIT_VIDEO_EVENT_COMPLETED = 2,
72
+ NATIVE_SDK_APPKIT_VIDEO_EVENT_FAILED = 3,
73
+ } native_sdk_appkit_video_event_kind_t;
74
+
56
75
  /* How many band magnitudes every SPECTRUM report carries: 32 buckets
57
76
  * with log-spaced center frequencies covering roughly 50 Hz..16 kHz.
58
77
  * Part of the event ABI — the Zig side binds the array by this count. */
@@ -235,6 +254,10 @@ typedef struct {
235
254
  double y;
236
255
  int open;
237
256
  int focused;
257
+ /* WINDOW_FRAME: nonzero while the window is alive but hidden by
258
+ * its close_policy (.hide intercepted a user close). open stays 1
259
+ * for the window's whole hidden stretch. */
260
+ int hidden;
238
261
  const char *label;
239
262
  size_t label_len;
240
263
  const char *shortcut_id;
@@ -275,9 +298,11 @@ typedef struct {
275
298
  int high_contrast;
276
299
  uint64_t timer_id;
277
300
  /* GPU_SURFACE_SCROLL_DRIVER / CONTEXT_MENU_ACTION payloads: widget_id
278
- * carries the driver id / menu token; scroll_driver_offset_y the new
279
- * content offset (canvas points, y-down, overscroll passes through);
280
- * menu_item_id the selected context-menu item (0 = dismissed). */
301
+ * carries the driver id / menu token; scroll_driver_offset_x/_y the
302
+ * new content offsets (canvas points, x-rightward, y-down,
303
+ * overscroll passes through); menu_item_id the selected
304
+ * context-menu item (0 = dismissed). */
305
+ double scroll_driver_offset_x;
281
306
  double scroll_driver_offset_y;
282
307
  uint32_t menu_item_id;
283
308
  /* GPU_SURFACE_FRAME payloads: host-stamped durations of the most
@@ -309,6 +334,26 @@ typedef struct {
309
334
  * the -60 dBFS analysis floor at 0 to full scale at 255). Zeros on
310
335
  * every other event kind. */
311
336
  uint8_t audio_bands[NATIVE_SDK_APPKIT_AUDIO_SPECTRUM_BANDS];
337
+ /* EVENT_VIDEO payloads: the report kind
338
+ * (native_sdk_appkit_video_event_kind_t) plus the player's
339
+ * position/duration readout in milliseconds at emit time.
340
+ * video_playing/video_buffering carry the audio event's exact
341
+ * semantics (transport intent vs a stalled stream). */
342
+ int video_kind;
343
+ /* The engine-minted load token this playback echoes in every event
344
+ * (see the Zig seam's VideoEvent.token): how a replaced playback's
345
+ * queued straggler is told apart from the replacement's stream. */
346
+ uint64_t video_token;
347
+ uint64_t video_position_ms;
348
+ uint64_t video_duration_ms;
349
+ int video_playing;
350
+ int video_buffering;
351
+ /* LOADED payloads: the STREAM's decoded pixel dimensions — the
352
+ * honest source geometry, even when the host downscales frames to
353
+ * fit the sink's per-frame pixel budget. Zeros on every other
354
+ * event kind. */
355
+ uint64_t video_width;
356
+ uint64_t video_height;
312
357
  } native_sdk_appkit_event_t;
313
358
 
314
359
  typedef void (*native_sdk_appkit_event_callback_t)(void *context, const native_sdk_appkit_event_t *event);
@@ -342,7 +387,20 @@ void native_sdk_appkit_set_dock_icon_rgba(native_sdk_appkit_host_t *host, const
342
387
  // keeping the pre-masking behavior (icon shown unshaped) as the floor.
343
388
  void native_sdk_appkit_set_dock_icon_file(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
344
389
  void native_sdk_appkit_run(native_sdk_appkit_host_t *host, native_sdk_appkit_event_callback_t callback, void *context);
390
+ // The host-side shutdown request: a failed event emit asks the host to
391
+ // deliver SHUTDOWN and stop. While the run loop is live the delivery is
392
+ // queued to the next turn; before [NSApp run] it happens inline (the
393
+ // failed-START precedent — runWithCallback's didShutdown check honors
394
+ // it before the loop would start).
345
395
  void native_sdk_appkit_stop(native_sdk_appkit_host_t *host);
396
+ // The quit VERB's landing point (fx.quitApp): always deferred, never
397
+ // inline — the verb arrives mid dispatch, and the shutdown must emit
398
+ // only after the requesting dispatch has committed to the session
399
+ // recorder. While the run loop is live the deferral is a main-queue
400
+ // hop; before [NSApp run] the request parks as a pending flag that
401
+ // runWithCallback drains at top level after the pre-run dispatch that
402
+ // carried it returns.
403
+ void native_sdk_appkit_request_stop(native_sdk_appkit_host_t *host);
346
404
  void native_sdk_appkit_load_webview(native_sdk_appkit_host_t *host, const char *source, size_t source_len, int source_kind, const char *asset_root, size_t asset_root_len, const char *asset_entry, size_t asset_entry_len, const char *asset_origin, size_t asset_origin_len, int spa_fallback);
347
405
  void native_sdk_appkit_load_window_webview(native_sdk_appkit_host_t *host, uint64_t window_id, const char *source, size_t source_len, int source_kind, const char *asset_root, size_t asset_root_len, const char *asset_entry, size_t asset_entry_len, const char *asset_origin, size_t asset_origin_len, int spa_fallback);
348
406
  void native_sdk_appkit_set_bridge_callback(native_sdk_appkit_host_t *host, native_sdk_appkit_bridge_callback_t callback, void *context);
@@ -364,6 +422,17 @@ int native_sdk_appkit_close_window(native_sdk_appkit_host_t *host, uint64_t wind
364
422
  // window controls on chromeless windows. Returns 0 when the window id
365
423
  // is unknown.
366
424
  int native_sdk_appkit_minimize_window(native_sdk_appkit_host_t *host, uint64_t window_id);
425
+ // The show verb: bring the window back to the glass and activate the
426
+ // app (deminiaturize + makeKeyAndOrderFront) — the counterpart to a
427
+ // close_policy .hide hide, and the tray-menu "Open" consequence.
428
+ // Returns 0 when the window id is unknown.
429
+ int native_sdk_appkit_show_window(native_sdk_appkit_host_t *host, uint64_t window_id);
430
+ // What the user's close affordance does to this window: 0 = quit (the
431
+ // default: really close; last close follows app exit semantics),
432
+ // 1 = hide (order out and keep running — the menu-bar-app shape).
433
+ // Applied right after create, like the content min-size floor.
434
+ // Returns 0 when the window id is unknown.
435
+ int native_sdk_appkit_set_window_close_policy(native_sdk_appkit_host_t *host, uint64_t window_id, int close_policy);
367
436
  // Window-drag region channel: called during dispatch of the pointer-down
368
437
  // that starts the gesture. Single click hands the event to
369
438
  // -[NSWindow performWindowDragWithEvent:] (moves only on actual
@@ -459,6 +528,41 @@ int native_sdk_appkit_audio_pause(native_sdk_appkit_host_t *host);
459
528
  int native_sdk_appkit_audio_stop(native_sdk_appkit_host_t *host);
460
529
  int native_sdk_appkit_audio_seek(native_sdk_appkit_host_t *host, uint64_t position_ms);
461
530
  int native_sdk_appkit_audio_set_volume(native_sdk_appkit_host_t *host, double volume);
531
+
532
+ /* Where the video player delivers decoded frames: one tightly packed,
533
+ * row-major, straight-alpha RGBA8 frame per call (len = width * height
534
+ * * 4), copied before return. Returns 0 when the frame was accepted, 1
535
+ * when the receiving claim has been released (the host must stop
536
+ * pushing — its frame timer has nothing left to feed), anything else a
537
+ * dropped frame (latest-wins; the host keeps decoding). Always invoked
538
+ * on the main run loop. */
539
+ typedef int (*native_sdk_appkit_video_sink_push_t)(void *context, size_t width, size_t height, const uint8_t *pixels, size_t len);
540
+
541
+ /* The app's single video player (AVPlayer + AVPlayerItemVideoOutput).
542
+ * Load replaces whatever was loaded before, paused at position zero;
543
+ * returns 0 on success, 1 when the file is missing/unreadable, 2 when
544
+ * it cannot be decoded. A successful load is followed by one
545
+ * EVENT_VIDEO/LOADED on the run loop carrying the stream's dimensions
546
+ * and the decoded duration; decoded frames flow through push_fn.
547
+ * Play/pause/stop/seek/set_volume/set_muted/set_loop return 1 when
548
+ * applied, 0 when there is no loaded player to apply to (stop, pause,
549
+ * and the setters treat that as a harmless no-op on the Zig side).
550
+ * All entries are loop-thread only. */
551
+ 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);
552
+ /* URL sources on the same single player: progressive AVPlayer streaming
553
+ * (playable as soon as enough bytes arrive, never download-then-play;
554
+ * no cache layer). Returns 2 when the URL cannot even be parsed, 0 for
555
+ * a started stream. Async failures (unreachable host, mid-stream
556
+ * network loss, undecodable payload) arrive as one EVENT_VIDEO/FAILED
557
+ * on the run loop. Loop-thread only. */
558
+ 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);
559
+ int native_sdk_appkit_video_play(native_sdk_appkit_host_t *host);
560
+ int native_sdk_appkit_video_pause(native_sdk_appkit_host_t *host);
561
+ int native_sdk_appkit_video_stop(native_sdk_appkit_host_t *host);
562
+ int native_sdk_appkit_video_seek(native_sdk_appkit_host_t *host, uint64_t position_ms);
563
+ int native_sdk_appkit_video_set_volume(native_sdk_appkit_host_t *host, double volume);
564
+ int native_sdk_appkit_video_set_muted(native_sdk_appkit_host_t *host, int muted);
565
+ int native_sdk_appkit_video_set_loop(native_sdk_appkit_host_t *host, int loop);
462
566
  /* Thread-safe: nudges the main run loop to emit a WAKE event. May be
463
567
  * called from any thread (worker threads streaming effect results). */
464
568
  void native_sdk_appkit_wake(native_sdk_appkit_host_t *host);
@@ -486,8 +590,26 @@ int native_sdk_appkit_measure_text_advances(uint64_t font_id, double size, const
486
590
 
487
591
  // Register engine-validated TrueType bytes under a canvas font id so
488
592
  // measurement and packet text drawing resolve the id to this exact face.
489
- // Returns 1 on success, 0 when CoreText rejects the data.
490
- int native_sdk_appkit_register_font(uint64_t font_id, const uint8_t *bytes, size_t bytes_len);
593
+ // Returns 1 on success, 0 when CoreText rejects the data. On success
594
+ // `*out_token` is the registration's ownership token — the handle the
595
+ // caller must present to native_sdk_appkit_unregister_font, so teardown
596
+ // removes exactly this registration (font ids are per-runtime while
597
+ // host font state is per-process: a later runtime may re-register the
598
+ // id, and its live face must survive the older owner's teardown). Hosts
599
+ // that retain no font state (the Chromium engine's stateless accept)
600
+ // write 0: nothing installed, nothing a token could own.
601
+ int native_sdk_appkit_register_font(uint64_t font_id, const uint8_t *bytes, size_t bytes_len, uint64_t *out_token);
602
+ // Drop the per-id state a registration installed (the descriptor and its
603
+ // caches) — the teardown twin Runtime.deinit calls, because font ids are
604
+ // per-runtime while this host's font state is per-process. `token` must
605
+ // be the value the matching register call reported: state is removed
606
+ // only while the id's current registration still carries it, so an
607
+ // older runtime's deinit never tears down a newer runtime's live face
608
+ // under a shared id. A stale token — like an id with no installed
609
+ // descriptor — is a no-op accept: the registration the token owned is
610
+ // already gone, which is the state the caller asked for. Returns 1 on
611
+ // accept, 0 only for the invalid id 0.
612
+ int native_sdk_appkit_unregister_font(uint64_t font_id, uint64_t token);
491
613
  /* Decode encoded image bytes (PNG, JPEG, ... — whatever ImageIO supports)
492
614
  * through CGImageSource into tightly packed, row-major, straight-alpha
493
615
  * (non-premultiplied) RGBA8 written into `pixels`. Returns 1 on success
@@ -557,19 +679,41 @@ typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t item_i
557
679
  * set_gpu_surface_scroll_drivers_fn). Frame coordinates are view-local
558
680
  * canvas points (top-left origin, y-down); the host flips to AppKit
559
681
  * coordinates itself. */
682
+ /* A surface that hit-blocks scroll regions beneath it (view-local
683
+ * canvas points, top-left origin): wheel routing declines a driver
684
+ * whose occluder mask includes an occluder containing the point. */
685
+ typedef struct {
686
+ double x;
687
+ double y;
688
+ double width;
689
+ double height;
690
+ } native_sdk_appkit_scroll_occluder_t;
691
+
560
692
  typedef struct {
561
693
  uint64_t driver_id;
694
+ /* The nearest ancestor driver's id (0 = none): wheel-owner
695
+ * resolution is restricted to the hit region and its ancestors. */
696
+ uint64_t parent_driver_id;
697
+ /* Bit i set = occluder i (of the sync call's occluder array) blocks
698
+ * this region at points it contains. */
699
+ uint32_t occluder_mask;
562
700
  double x;
563
701
  double y;
564
702
  double width;
565
703
  double height;
566
704
  double content_width;
567
705
  double content_height;
706
+ double offset_x;
568
707
  double offset_y;
569
- int set_offset;
708
+ int set_offset_x;
709
+ int set_offset_y;
570
710
  /* Edge behavior: 0 pins scrolling at the content edges, nonzero lets
571
- * the scroller bounce past them (vertical elasticity). */
711
+ * the scroller bounce past them (armed per axis via the grants). */
572
712
  int rubber_band;
713
+ /* Which axes the region grants: elasticity and scroller chrome arm
714
+ * only on granted axes; an ungranted axis never moves or bounces. */
715
+ int scrolls_x;
716
+ int scrolls_y;
573
717
  } native_sdk_appkit_scroll_driver_t;
574
718
 
575
719
  /* One native context-menu entry. */
@@ -586,7 +730,7 @@ typedef struct {
586
730
  * extents / (when set_offset) offsets, remove drivers absent from the
587
731
  * list. Idempotent; called every layout install and every presented
588
732
  * frame. Returns 1 on success, 0 when the view does not exist. */
589
- int native_sdk_appkit_set_gpu_surface_scroll_drivers(native_sdk_appkit_host_t *host, uint64_t window_id, const char *label, size_t label_len, const native_sdk_appkit_scroll_driver_t *drivers, size_t count);
733
+ int native_sdk_appkit_set_gpu_surface_scroll_drivers(native_sdk_appkit_host_t *host, uint64_t window_id, const char *label, size_t label_len, const native_sdk_appkit_scroll_driver_t *drivers, size_t count, const native_sdk_appkit_scroll_occluder_t *occluders, size_t occluder_count);
590
734
 
591
735
  /* Present a native context menu (NSMenu popUpMenuPositioningItem) at the
592
736
  * view-local point on the next main-loop turn. The selection (or