@native-sdk/cli 0.8.2 → 0.8.4

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 (92) hide show
  1. package/build/app.zig +50 -3
  2. package/build.zig +134 -360
  3. package/native-sdk.d.ts +4 -0
  4. package/package.json +9 -9
  5. package/packages/core/compile-surface/core.ts +90 -1
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/sdk/core.d.ts +65 -2
  9. package/packages/core/sdk/core.ts +189 -33
  10. package/packages/core/sdk/events.d.ts +14 -0
  11. package/packages/core/sdk/events.ts +18 -0
  12. package/packages/core/src/checker.ts +61 -1
  13. package/packages/core/src/devhost.ts +3 -3
  14. package/packages/core/src/diagnostics.ts +4 -4
  15. package/skill-data/core/SKILL.md +4 -2
  16. package/skill-data/core/references/project-anatomy.md +2 -1
  17. package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
  18. package/skill-data/native-ui/SKILL.md +8 -8
  19. package/skill-data/ts-core/SKILL.md +16 -13
  20. package/src/app_runner/app_assets.zig +138 -0
  21. package/src/app_runner/root.zig +2 -0
  22. package/src/app_runner/ts_core_main.zig +27 -3
  23. package/src/embed/host.zig +6 -0
  24. package/src/embed/ui_host.zig +2 -0
  25. package/src/platform/linux/root.zig +1 -0
  26. package/src/platform/macos/appkit_host.h +10 -0
  27. package/src/platform/macos/appkit_host.m +515 -93
  28. package/src/platform/macos/capture_info_plist.c +25 -0
  29. package/src/platform/macos/cef_host.mm +22 -0
  30. package/src/platform/macos/root.zig +68 -0
  31. package/src/platform/null_platform.zig +58 -0
  32. package/src/platform/root.zig +7 -0
  33. package/src/platform/types.zig +100 -0
  34. package/src/platform/windows/root.zig +56 -0
  35. package/src/platform/windows/webview2_host.cpp +171 -0
  36. package/src/primitives/app_manifest/types.zig +2 -0
  37. package/src/primitives/canvas/code_tests.zig +9 -9
  38. package/src/primitives/canvas/events.zig +12 -11
  39. package/src/primitives/canvas/frame.zig +44 -9
  40. package/src/primitives/canvas/icons/mic.svg +1 -0
  41. package/src/primitives/canvas/icons.zig +2 -0
  42. package/src/primitives/canvas/root.zig +8 -0
  43. package/src/primitives/canvas/text_span_tests.zig +39 -0
  44. package/src/primitives/canvas/ui.zig +23 -4
  45. package/src/primitives/canvas/ui_markup.zig +15 -0
  46. package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
  47. package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
  48. package/src/primitives/canvas/ui_markup_tests.zig +5 -0
  49. package/src/primitives/canvas/ui_markup_view.zig +9 -0
  50. package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
  51. package/src/primitives/canvas/ui_schema.zig +19 -10
  52. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  53. package/src/primitives/canvas/ui_tests.zig +18 -4
  54. package/src/primitives/canvas/widget_invalidation.zig +9 -2
  55. package/src/primitives/canvas/widget_render.zig +321 -115
  56. package/src/primitives/canvas/widget_runtime_tests.zig +173 -0
  57. package/src/primitives/canvas/widget_text_input.zig +10 -10
  58. package/src/primitives/canvas/widget_tree.zig +1 -1
  59. package/src/primitives/canvas/widgets.zig +41 -5
  60. package/src/root.zig +10 -0
  61. package/src/runtime/automation_widget_dispatch.zig +1 -0
  62. package/src/runtime/bridge_payload.zig +2 -0
  63. package/src/runtime/canvas_frame.zig +13 -2
  64. package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
  65. package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
  66. package/src/runtime/canvas_widget_event_tests.zig +1 -0
  67. package/src/runtime/canvas_widget_events.zig +69 -24
  68. package/src/runtime/canvas_widget_runtime.zig +101 -6
  69. package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
  70. package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
  71. package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
  72. package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
  73. package/src/runtime/canvas_widget_state.zig +10 -1
  74. package/src/runtime/canvas_widget_text_tests.zig +112 -3
  75. package/src/runtime/effects.zig +313 -2
  76. package/src/runtime/effects_audio_capture_tests.zig +251 -0
  77. package/src/runtime/root.zig +3 -0
  78. package/src/runtime/tests.zig +1 -0
  79. package/src/runtime/ts_core_host.zig +401 -32
  80. package/src/runtime/ts_core_host_tests.zig +407 -0
  81. package/src/runtime/ts_ui_app.zig +39 -1
  82. package/src/runtime/ui_app.zig +18 -3
  83. package/src/runtime/ui_app_tests.zig +48 -0
  84. package/src/runtime/view.zig +2 -0
  85. package/src/runtime/view_widget_scroll.zig +56 -5
  86. package/src/runtime/view_widget_text.zig +24 -5
  87. package/src/runtime/view_widget_tree.zig +1 -1
  88. package/src/tooling/manifest.zig +1034 -0
  89. package/src/tooling/package.zig +841 -10
  90. package/src/tooling/raw_manifest.zig +35 -0
  91. package/src/tooling/templates.zig +55 -0
  92. package/tools/corewire/emit_facade.zig +36 -0
@@ -35,7 +35,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
35
35
  for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
36
36
  if (node.widget.kind != .scroll_view or canvasWidgetModelDrivenVirtual(node.widget)) continue;
37
37
  // Native drivers own momentum + rubber-band recovery.
38
- if (node.widget.native_scroll) continue;
38
+ if (node.widget.runtime_flags.native_scroll) continue;
39
39
  const viewport = node.frame.inset(node.widget.layout.padding).normalized();
40
40
  if (viewport.isEmpty()) continue;
41
41
  const physics = canvas.widgetScrollPhysics(node.widget, self.widget_tokens.scroll);
@@ -215,7 +215,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
215
215
  // an engine overscroll here would have no kinetic step to
216
216
  // pull it back.
217
217
  const physics = canvas.widgetScrollPhysics(scroll_node.widget, self.widget_tokens.scroll);
218
- const rubberband = allow_rubberband and !scroll_node.widget.native_scroll;
218
+ const rubberband = allow_rubberband and !scroll_node.widget.runtime_flags.native_scroll;
219
219
  const next = switch (source) {
220
220
  .wheel => if (rubberband)
221
221
  current.applyWheel(delta, physics)
@@ -380,6 +380,57 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
380
380
  return self.canvasWidgetDirtyBounds(scroll_index, scroll_node.frame);
381
381
  }
382
382
 
383
+ /// Minimally scroll every runtime-owned ancestor viewport needed
384
+ /// to make `id` fully visible. Roving tree/list navigation resolves
385
+ /// the logical successor before geometry focusability, then calls
386
+ /// this seam before committing focus so an offscreen row becomes a
387
+ /// normal routable focus target in the same key event.
388
+ pub fn scrollCanvasWidgetIntoView(self: *RuntimeView, id: canvas.ObjectId) anyerror!?geometry.RectF {
389
+ const target_index = self.canvasWidgetNodeIndexById(id) orelse return null;
390
+ var dirty: ?geometry.RectF = null;
391
+ var current = self.widget_layout_nodes[target_index].parent_index;
392
+ while (current) |ancestor_index| {
393
+ if (ancestor_index >= self.widget_layout_node_count) break;
394
+ const ancestor = self.widget_layout_nodes[ancestor_index];
395
+
396
+ // Anchored surfaces escape ancestor clips rather than
397
+ // scrolling with their source branch.
398
+ if (canvas.widgetIsAnchored(ancestor.widget)) break;
399
+
400
+ if (canvasWidgetScrollableKind(ancestor.widget.kind) and ancestor.widget.kind != .textarea) {
401
+ const viewport = ancestor.frame.inset(ancestor.widget.layout.padding).normalized();
402
+ if (!viewport.isEmpty()) {
403
+ if (canvas.widgetScrollsAxis(ancestor.widget, .vertical)) {
404
+ const target = self.widget_layout_nodes[target_index].frame.normalized();
405
+ const delta_y: f32 = if (target.y < viewport.y)
406
+ target.y - viewport.y
407
+ else if (target.maxY() > viewport.maxY())
408
+ target.maxY() - viewport.maxY()
409
+ else
410
+ 0;
411
+ if (delta_y != 0) {
412
+ dirty = unionOptionalRects(dirty, try self.applyCanvasWidgetScrollAxis(ancestor_index, .vertical, delta_y, .discrete, false));
413
+ }
414
+ }
415
+ if (canvas.widgetScrollsAxis(ancestor.widget, .horizontal)) {
416
+ const target = self.widget_layout_nodes[target_index].frame.normalized();
417
+ const delta_x: f32 = if (target.x < viewport.x)
418
+ target.x - viewport.x
419
+ else if (target.maxX() > viewport.maxX())
420
+ target.maxX() - viewport.maxX()
421
+ else
422
+ 0;
423
+ if (delta_x != 0) {
424
+ dirty = unionOptionalRects(dirty, try self.applyCanvasWidgetScrollAxis(ancestor_index, .horizontal, delta_x, .discrete, false));
425
+ }
426
+ }
427
+ }
428
+ }
429
+ current = self.widget_layout_nodes[ancestor_index].parent_index;
430
+ }
431
+ return dirty;
432
+ }
433
+
383
434
  pub fn stepCanvasWidgetKineticScroll(self: *RuntimeView, dt_ms: f32) anyerror!?geometry.RectF {
384
435
  var dirty: ?geometry.RectF = null;
385
436
  var changed = false;
@@ -387,7 +438,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
387
438
  for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |scroll_node, scroll_index| {
388
439
  if (scroll_node.widget.kind != .scroll_view or canvasWidgetModelDrivenVirtual(scroll_node.widget)) continue;
389
440
  // Native drivers own momentum + rubber-band recovery.
390
- if (scroll_node.widget.native_scroll) continue;
441
+ if (scroll_node.widget.runtime_flags.native_scroll) continue;
391
442
 
392
443
  const viewport = scroll_node.frame.inset(scroll_node.widget.layout.padding).normalized();
393
444
  if (viewport.isEmpty()) {
@@ -473,7 +524,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
473
524
  if (scroll_index < self.widget_layout_node_count) {
474
525
  const widget = self.widget_layout_nodes[scroll_index].widget;
475
526
  if (widget.kind == .textarea) {
476
- return if (widget.code_editor)
527
+ return if (widget.runtime_flags.code_editor)
477
528
  @max(viewport.width, canvas.textInputContentWidthForWidget(widget, self.widget_tokens))
478
529
  else
479
530
  viewport.width;
@@ -524,7 +575,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
524
575
  }
525
576
  if (widget.kind != .textarea) return;
526
577
 
527
- if (widget.code_editor and widget.text_no_wrap) {
578
+ if (widget.runtime_flags.code_editor and widget.text_no_wrap) {
528
579
  const next_x = canvas.textInputCaretVisibleScrollOffsetForWidget(widget, self.widget_tokens, widget.value_x);
529
580
  if (next_x != widget.value_x) {
530
581
  widget.value_x = next_x;
@@ -179,14 +179,16 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
179
179
  return null;
180
180
  }
181
181
 
182
- // Multi-line editing contract: Enter (plain or shift) inserts
183
- // a newline; submit rides the primary-modifier chord instead.
184
- // Shared with the app dispatch path so the model's `on_input`
185
- // hears exactly the edit the retained text applied.
182
+ // Multi-line editing contract: Enter normally inserts a
183
+ // newline, while a submit-on-enter textarea leaves plain
184
+ // Enter for its submit handler and keeps Shift+Enter as the
185
+ // newline gesture. Shared with the app dispatch path so the
186
+ // model's `on_input` hears exactly the edit retained text
187
+ // applied.
186
188
  if (canvas.widgetCodeTabTextEditEvent(widget, keyboard)) |tab_edit| {
187
189
  return tab_edit;
188
190
  }
189
- if (canvas.widgetKeyboardNewlineTextEditEvent(widget.kind, keyboard)) |newline_edit| {
191
+ if (canvas.widgetKeyboardNewlineTextEditEvent(widget, keyboard)) |newline_edit| {
190
192
  return newline_edit;
191
193
  }
192
194
 
@@ -959,6 +961,23 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
959
961
  return canvasWidgetEditableTextKind(widget.kind) and !widget.state.disabled;
960
962
  }
961
963
 
964
+ /// A controlled source replacement intentionally discards stale
965
+ /// selection state, but logical focus survives that rebuild. Give
966
+ /// the focused editor a fresh insertion point so an app clearing a
967
+ /// submitted composer never leaves a focused-but-caretless field.
968
+ /// Explicit source selections are left untouched.
969
+ pub fn ensureCanvasWidgetFocusedTextCaret(self: *RuntimeView) anyerror!bool {
970
+ const focused_id = self.canvas_widget_focused_id;
971
+ if (focused_id == 0 or !self.canEditCanvasWidgetText(focused_id)) return false;
972
+ const index = self.canvasWidgetNodeIndexById(focused_id) orelse return false;
973
+ const widget = &self.widget_layout_nodes[index].widget;
974
+ if (widget.text_selection != null) return false;
975
+ widget.text_selection = canvas.TextSelection.collapsed(widget.text.len);
976
+ try self.refreshCanvasWidgetSemantics();
977
+ self.widget_revision += 1;
978
+ return true;
979
+ }
980
+
962
981
  pub fn applyCanvasWidgetTextPointer(
963
982
  self: *RuntimeView,
964
983
  target_id: canvas.ObjectId,
@@ -911,7 +911,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
911
911
  /// Keyboard entry point into an anchored menu surface: the marked
912
912
  /// (`selected`) row when the menu has one, otherwise the first
913
913
  /// focusable row for an ArrowDown entry or the last for ArrowUp —
914
- /// the open-select keymap.
914
+ /// the open-menu keymap shared by picker and menu-button triggers.
915
915
  pub fn canvasWidgetMenuSurfaceEntryId(self: *const RuntimeView, surface_index: usize, from_end: bool) ?canvas.ObjectId {
916
916
  var first: ?canvas.ObjectId = null;
917
917
  var last: ?canvas.ObjectId = null;