@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
@@ -611,6 +611,62 @@ test "widget render state dirty bounds tracks changed runtime states" {
611
611
  );
612
612
  }
613
613
 
614
+ test "quiet logical menu focus paints and dirties the active row without an outline" {
615
+ const children = [_]Widget{
616
+ .{
617
+ .id = 2,
618
+ .kind = .menu_item,
619
+ .frame = geometry.RectF.init(10, 12, 120, 32),
620
+ .text = "Duplicate",
621
+ },
622
+ .{
623
+ .id = 3,
624
+ .kind = .menu_item,
625
+ .frame = geometry.RectF.init(10, 52, 120, 32),
626
+ .text = "Rename",
627
+ },
628
+ };
629
+ var nodes: [3]WidgetLayoutNode = undefined;
630
+ const layout = try layoutWidgetTree(.{ .kind = .stack, .children = &children }, geometry.RectF.init(0, 0, 160, 100), &nodes);
631
+
632
+ // A pointer-opened menu keeps focus-visible quiet, but ArrowDown
633
+ // still establishes a logical active row. That row needs the menu
634
+ // wash so the movement is perceptible, without acquiring the focus
635
+ // outline reserved for keyboard traversal between controls.
636
+ var commands: [16]CanvasCommand = undefined;
637
+ var builder = Builder.init(&commands);
638
+ try layout.emitDisplayListWithState(&builder, .{}, .{ .focused_id = 2 });
639
+ var duplicate_wash = false;
640
+ var rename_wash = false;
641
+ var duplicate_outline = false;
642
+ for (builder.displayList().commands) |command| switch (command) {
643
+ .fill_rounded_rect => |fill| {
644
+ if (fill.id == widgetPartId(2, 1)) duplicate_wash = true;
645
+ if (fill.id == widgetPartId(3, 1)) rename_wash = true;
646
+ },
647
+ .stroke_rect => |stroke| {
648
+ if (stroke.id == widgetPartId(2, 2)) duplicate_outline = true;
649
+ },
650
+ else => {},
651
+ };
652
+ try std.testing.expect(duplicate_wash);
653
+ try std.testing.expect(!rename_wash);
654
+ try std.testing.expect(!duplicate_outline);
655
+
656
+ // Moving to the next row changes pixels on both the old and new
657
+ // rows; retained rendering must invalidate the complete union.
658
+ const duplicate_frame = layout.findById(2).?.frame;
659
+ const rename_frame = layout.findById(3).?.frame;
660
+ const dirty = layout.renderStateDirtyBounds(
661
+ .{ .focused_id = 2 },
662
+ .{ .focused_id = 3 },
663
+ ).?;
664
+ try std.testing.expect(dirty.x <= @min(duplicate_frame.x, rename_frame.x));
665
+ try std.testing.expect(dirty.y <= @min(duplicate_frame.y, rename_frame.y));
666
+ try std.testing.expect(dirty.maxX() >= @max(duplicate_frame.maxX(), rename_frame.maxX()));
667
+ try std.testing.expect(dirty.maxY() >= @max(duplicate_frame.maxY(), rename_frame.maxY()));
668
+ }
669
+
614
670
  test "widget render state dirty bounds tracks terminal logical focus" {
615
671
  const rows = [_]canvas.TerminalRow{.{ .cells = &.{} }};
616
672
  var grid = canvas.TerminalGrid{
@@ -2756,6 +2812,123 @@ test "widget layout emission applies presentation motion to a keyed draggable" {
2756
2812
  try std.testing.expect(saw_motion_inverse);
2757
2813
  }
2758
2814
 
2815
+ test "drag landing layout motion escapes its scroll lane clip" {
2816
+ const cards = [_]Widget{.{
2817
+ .id = 3,
2818
+ .kind = .row,
2819
+ .frame = geometry.RectF.init(12, 16, 120, 36),
2820
+ .style = .{ .background = Color.rgb8(240, 240, 240), .radius = 6 },
2821
+ }};
2822
+ const columns = [_]Widget{.{
2823
+ .id = 2,
2824
+ .kind = .scroll_view,
2825
+ .frame = geometry.RectF.init(10, 10, 140, 80),
2826
+ .children = &cards,
2827
+ }};
2828
+ var nodes: [3]WidgetLayoutNode = undefined;
2829
+ const layout = try layoutWidgetTree(.{ .id = 1, .kind = .panel, .children = &columns }, geometry.RectF.init(0, 0, 320, 140), &nodes);
2830
+ const layout_motions = [_]WidgetLayoutMotion{.{
2831
+ .id = 3,
2832
+ .offset = geometry.OffsetF.init(180, 0),
2833
+ .escape_ancestor_clips = true,
2834
+ }};
2835
+
2836
+ var commands: [16]CanvasCommand = undefined;
2837
+ var builder = Builder.init(&commands);
2838
+ try layout.emitDisplayListWithState(&builder, .{}, .{ .layout_motions = &layout_motions });
2839
+
2840
+ var clip_depth: usize = 0;
2841
+ var saw_landing_motion = false;
2842
+ for (builder.displayList().commands) |command| switch (command) {
2843
+ .push_clip => clip_depth += 1,
2844
+ .pop_clip => clip_depth -= 1,
2845
+ .transform => |transform| {
2846
+ if (!affinesEqual(transform, Affine.translate(180, 0))) continue;
2847
+ saw_landing_motion = true;
2848
+ try std.testing.expectEqual(@as(usize, 0), clip_depth);
2849
+ },
2850
+ else => {},
2851
+ };
2852
+ try std.testing.expect(saw_landing_motion);
2853
+ }
2854
+
2855
+ test "rich text remains visible in floating drag and landing passes" {
2856
+ const source = "Lifted rich text";
2857
+ const spans = [_]canvas.TextSpan{.{ .text = source }};
2858
+ const root_frame = geometry.RectF.init(0, 0, 320, 140);
2859
+ const scroll_frame = geometry.RectF.init(10, 10, 140, 60);
2860
+ const card_frame = geometry.RectF.init(12, 80, 120, 36);
2861
+ const text_frame = geometry.RectF.init(18, 86, 108, 24);
2862
+ const nodes = [_]WidgetLayoutNode{
2863
+ .{
2864
+ .widget = .{ .id = 1, .kind = .panel, .frame = root_frame },
2865
+ .frame = root_frame,
2866
+ .depth = 0,
2867
+ },
2868
+ .{
2869
+ .widget = .{ .id = 2, .kind = .scroll_view, .frame = scroll_frame },
2870
+ .frame = scroll_frame,
2871
+ .depth = 1,
2872
+ .parent_index = 0,
2873
+ },
2874
+ .{
2875
+ .widget = .{
2876
+ .id = 3,
2877
+ .kind = .row,
2878
+ .frame = card_frame,
2879
+ .style = .{ .background = Color.rgb8(240, 240, 240), .radius = 6 },
2880
+ },
2881
+ .frame = card_frame,
2882
+ .depth = 2,
2883
+ .parent_index = 1,
2884
+ },
2885
+ .{
2886
+ .widget = .{
2887
+ .id = 4,
2888
+ .kind = .text,
2889
+ .frame = text_frame,
2890
+ .text = source,
2891
+ .spans = &spans,
2892
+ },
2893
+ .frame = text_frame,
2894
+ .depth = 3,
2895
+ .parent_index = 2,
2896
+ },
2897
+ };
2898
+ const layout = WidgetLayoutTree{ .nodes = &nodes };
2899
+
2900
+ var preview_commands: [64]CanvasCommand = undefined;
2901
+ var preview_builder = Builder.init(&preview_commands);
2902
+ try layout.emitDisplayListWithState(&preview_builder, .{}, .{
2903
+ .drag_preview_id = 3,
2904
+ .drag_preview_origin = geometry.PointF.init(card_frame.x, card_frame.y),
2905
+ .drag_preview_offset = geometry.OffsetF.init(0, -60),
2906
+ });
2907
+
2908
+ var preview_has_text = false;
2909
+ for (preview_builder.displayList().commands) |command| switch (command) {
2910
+ .draw_text => |draw| preview_has_text = preview_has_text or std.mem.eql(u8, source, draw.text),
2911
+ else => {},
2912
+ };
2913
+ try std.testing.expect(preview_has_text);
2914
+
2915
+ const layout_motions = [_]WidgetLayoutMotion{.{
2916
+ .id = 3,
2917
+ .offset = geometry.OffsetF.init(0, -60),
2918
+ .escape_ancestor_clips = true,
2919
+ }};
2920
+ var landing_commands: [64]CanvasCommand = undefined;
2921
+ var landing_builder = Builder.init(&landing_commands);
2922
+ try layout.emitDisplayListWithState(&landing_builder, .{}, .{ .layout_motions = &layout_motions });
2923
+
2924
+ var landing_has_text = false;
2925
+ for (landing_builder.displayList().commands) |command| switch (command) {
2926
+ .draw_text => |draw| landing_has_text = landing_has_text or std.mem.eql(u8, source, draw.text),
2927
+ else => {},
2928
+ };
2929
+ try std.testing.expect(landing_has_text);
2930
+ }
2931
+
2759
2932
  test "input-group wears the focus ring for its focused descendant" {
2760
2933
  const tokens = DesignTokens{};
2761
2934
  const group_children = [_]Widget{
@@ -191,14 +191,14 @@ fn widgetTextInputLineHeight(text_size: f32) f32 {
191
191
  }
192
192
 
193
193
  fn widgetTextInputWrap(widget: Widget, line_height: f32) TextWrap {
194
- if (widget.code_editor) return if (widget.text_no_wrap) .none else .word;
194
+ if (widget.runtime_flags.code_editor) return if (widget.text_no_wrap) .none else .word;
195
195
  if (widget.kind == .textarea) return .word;
196
196
  if (widget.kind == .text_field and widget.frame.height >= line_height * 2.25) return .word;
197
197
  return .none;
198
198
  }
199
199
 
200
200
  fn widgetTextInputVerticalInset(widget: Widget, tokens: DesignTokens, text_size: f32, options: TextLayoutOptions) f32 {
201
- if (widget.code_editor) return 0;
201
+ if (widget.runtime_flags.code_editor) return 0;
202
202
  if (options.wrap != .none) return widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.sm);
203
203
  return @max(0, (widget.frame.height - widgetTextInputLineHeight(text_size)) * 0.5);
204
204
  }
@@ -220,7 +220,7 @@ const text_input_caret_reserve: f32 = 1;
220
220
  /// unscrolled field always has.
221
221
  fn widgetTextInputHorizontalScrollOffset(widget: Widget, tokens: DesignTokens, text_size: f32, text_inset: f32, options: TextLayoutOptions) f32 {
222
222
  if (options.wrap != .none) return 0;
223
- const offset = if (widget.code_editor) widget.value_x else widget.value;
223
+ const offset = if (widget.runtime_flags.code_editor) widget.value_x else widget.value;
224
224
  return std.math.clamp(offset, 0, widgetTextInputMaxHorizontalScrollOffset(widget, tokens, text_size, text_inset, options));
225
225
  }
226
226
 
@@ -232,7 +232,7 @@ fn widgetTextInputMaxHorizontalScrollOffset(widget: Widget, tokens: DesignTokens
232
232
  // paints — so a value holding a line break scrolls by the same
233
233
  // single-line extent it draws.
234
234
  const font_id = widgetTextInputFontId(widget, tokens);
235
- const text_width = if (widget.code_editor)
235
+ const text_width = if (widget.runtime_flags.code_editor)
236
236
  if (codeContentWidthCacheCurrent(widget, font_id, text_size))
237
237
  widget.code_content_width
238
238
  else
@@ -243,7 +243,7 @@ fn widgetTextInputMaxHorizontalScrollOffset(widget: Widget, tokens: DesignTokens
243
243
  }
244
244
 
245
245
  pub fn widgetTextInputOrigin(widget: Widget, tokens: DesignTokens, text_size: f32, inset: f32, options: TextLayoutOptions) geometry.PointF {
246
- if (widget.code_editor) {
246
+ if (widget.runtime_flags.code_editor) {
247
247
  return geometry.PointF.init(
248
248
  widget.frame.x + inset - widgetTextInputHorizontalScrollOffset(widget, tokens, text_size, inset, options),
249
249
  widget.frame.y + text_size - widgetTextInputScrollOffset(widget, tokens, text_size, inset, options),
@@ -365,7 +365,7 @@ pub fn textInputCaretVisibleScrollOffsetForWidget(widget: Widget, tokens: Design
365
365
  // selection rects measure with — the PRESENTED bytes (byte offsets
366
366
  // are interchangeable: the presentation substitutes 1:1).
367
367
  const caret_offset = snapTextOffset(widget.text, selection.focus);
368
- const caret_line_start = if (widget.code_editor)
368
+ const caret_line_start = if (widget.runtime_flags.code_editor)
369
369
  (std.mem.lastIndexOfScalar(u8, widget.text[0..caret_offset], '\n') orelse 0) +
370
370
  @as(usize, @intFromBool(std.mem.lastIndexOfScalar(u8, widget.text[0..caret_offset], '\n') != null))
371
371
  else
@@ -464,7 +464,7 @@ pub fn widgetTextInputDrawText(
464
464
  }
465
465
 
466
466
  pub fn widgetTextInputInset(widget: Widget, tokens: DesignTokens) f32 {
467
- if (widget.code_editor) return widget_metrics.widgetCodeLineNumberGutterWidth(widget, tokens);
467
+ if (widget.runtime_flags.code_editor) return widget_metrics.widgetCodeLineNumberGutterWidth(widget, tokens);
468
468
  const text_size = widgetTextInputSize(widget, tokens);
469
469
  return switch (widget.kind) {
470
470
  .search_field, .combobox => widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.md) + @max(widget_metrics.widgetSizedDensityValue(widget, tokens, 8), text_size - 2) + widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.sm),
@@ -473,7 +473,7 @@ pub fn widgetTextInputInset(widget: Widget, tokens: DesignTokens) f32 {
473
473
  }
474
474
 
475
475
  fn widgetTextInputFontId(widget: Widget, tokens: DesignTokens) FontId {
476
- return if (widget.code_editor) tokens.typography.mono_font_id else tokens.typography.font_id;
476
+ return if (widget.runtime_flags.code_editor) tokens.typography.mono_font_id else tokens.typography.font_id;
477
477
  }
478
478
 
479
479
  fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32) bool {
@@ -489,7 +489,7 @@ fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32)
489
489
  /// Runtime reconciliation carries this cache across unchanged app rebuilds;
490
490
  /// edits invalidate it before caret scrolling recomputes the new document.
491
491
  pub fn cacheTextInputContentWidthForWidget(widget: *Widget, tokens: DesignTokens) void {
492
- if (widget.kind != .textarea or !widget.code_editor or !widget.text_no_wrap) return;
492
+ if (widget.kind != .textarea or !widget.runtime_flags.code_editor or !widget.text_no_wrap) return;
493
493
  if (widget.hasCodeDiff()) return;
494
494
  const text_size = widgetTextInputSize(widget.*, tokens);
495
495
  const font_id = widgetTextInputFontId(widget.*, tokens);
@@ -578,7 +578,7 @@ fn widgetTextInputTrailingInset(widget: Widget, text_size: f32, inset: f32) f32
578
578
  // field padding. Its source viewport runs all the way to the trailing
579
579
  // edge; mirroring the gutter here invents horizontal overflow for lines
580
580
  // that visibly fit beside the numbers.
581
- if (widget.code_editor) return 0;
581
+ if (widget.runtime_flags.code_editor) return 0;
582
582
  if (widget.kind == .combobox) return inset + @max(8, text_size - 4);
583
583
  // A search field holding text reserves the trailing slot for the
584
584
  // built-in clear affordance so the text never runs under the x.
@@ -128,7 +128,7 @@ pub fn widgetScrollsAxis(widget: Widget, axis: token_model.ScrollAxis) bool {
128
128
  return switch (axis) {
129
129
  .vertical => widget.kind != .scroll_view or widget.scroll_axes.scrollsVertically() or widget.layout.virtualized,
130
130
  .horizontal => (widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized) or
131
- (widget.kind == .textarea and widget.code_editor and widget.text_no_wrap),
131
+ (widget.kind == .textarea and widget.runtime_flags.code_editor and widget.text_no_wrap),
132
132
  };
133
133
  }
134
134
 
@@ -264,6 +264,18 @@ pub const WidgetState = struct {
264
264
  invalid: bool = false,
265
265
  };
266
266
 
267
+ /// Engine-owned widget markers share one byte so adding runtime policy does
268
+ /// not expand every retained `Widget`. Builder-facing behavior remains on
269
+ /// ordinary named fields; these bits are stamped only by engine code.
270
+ pub const WidgetRuntimeFlags = packed struct(u8) {
271
+ /// `Ui.code` stamped this textarea as the editor surface.
272
+ code_editor: bool = false,
273
+ /// The runtime installed an OS-native scroll driver; engine-drawn
274
+ /// scrollbar and kinetic physics stand down for this scroll view.
275
+ native_scroll: bool = false,
276
+ _reserved: u6 = 0,
277
+ };
278
+
267
279
  /// Two 128-line masks for code-only diff presentation. `Widget` packs them
268
280
  /// into fields dormant on decorated code so ordinary widgets do not grow.
269
281
  pub const CodeDiffLines = struct {
@@ -279,6 +291,10 @@ pub const WidgetLayoutMotion = struct {
279
291
  id: ObjectId,
280
292
  from_offset: geometry.OffsetF = .{},
281
293
  offset: geometry.OffsetF = .{},
294
+ /// A drag landing begins at the pointer after the live preview has
295
+ /// disappeared. Hoist that one moving subtree above ancestor clips until
296
+ /// it settles; ordinary neighbor reflow stays clipped to its scroll lane.
297
+ escape_ancestor_clips: bool = false,
282
298
  start_ns: u64 = 0,
283
299
  duration_ms: u32 = 180,
284
300
  easing: Easing = .emphasized,
@@ -344,6 +360,14 @@ pub const WidgetRenderState = struct {
344
360
  }
345
361
  return .{};
346
362
  }
363
+
364
+ pub fn layoutMotionEscapesAncestorClips(self: WidgetRenderState, id: ObjectId) bool {
365
+ if (id == 0 or self.rendering_drag_preview) return false;
366
+ for (self.layout_motions) |motion| {
367
+ if (motion.id == id) return motion.escape_ancestor_clips;
368
+ }
369
+ return false;
370
+ }
347
371
  };
348
372
 
349
373
  pub const WidgetMainAlignment = enum {
@@ -935,7 +959,14 @@ pub const Widget = struct {
935
959
  /// selection, and accessibility paths all apply; this bit only swaps
936
960
  /// the textarea's visual/geometry policy to bare monospace highlighted
937
961
  /// code (no control fill, border, radius, focus ring, or inset).
938
- code_editor: bool = false,
962
+ runtime_flags: WidgetRuntimeFlags = .{},
963
+ /// Textarea Enter policy (`ElementOptions.submit_on_enter` / markup
964
+ /// `submit-on-enter`): plain Enter submits instead of editing, while
965
+ /// Shift+Enter remains a newline. False keeps the ordinary multiline
966
+ /// contract. Ignored by non-textarea kinds. The engine-only booleans in
967
+ /// `runtime_flags` share a byte so adding this policy does not grow every
968
+ /// retained widget.
969
+ submit_on_enter: bool = false,
939
970
  /// Syntax grammar for an editable `Ui.code` surface. Editable code
940
971
  /// retains one plain source span and tokenizes only visible logical
941
972
  /// lines during paint, so large documents do not consume the view's
@@ -1021,10 +1052,6 @@ pub const Widget = struct {
1021
1052
  semantics: WidgetSemantics = .{},
1022
1053
  /// App-declared native context menu for this widget (empty = none).
1023
1054
  context_menu: []const WidgetContextMenuItem = &.{},
1024
- /// True when the runtime installed a native scroll driver for this
1025
- /// `.scroll_view`: the engine's drawn scrollbar and kinetic physics
1026
- /// stand down — the OS scroller owns feel and the overlay scroller.
1027
- native_scroll: bool = false,
1028
1055
  /// Per-region edge behavior for scroll containers (`overscroll:` in
1029
1056
  /// the builder, `overscroll=` in markup): `.default` follows the
1030
1057
  /// `ScrollPhysics.overscroll` token (off unless a theme flips it),
@@ -1606,3 +1633,12 @@ fn mergeLayoutDefaults(explicit: WidgetLayoutStyle, defaults: WidgetLayoutStyle)
1606
1633
  if (explicit.min_size.width == 0 and explicit.min_size.height == 0) merged.min_size = defaults.min_size;
1607
1634
  return merged;
1608
1635
  }
1636
+
1637
+ test "Widget keeps the retained hot-path footprint after textarea policy flags" {
1638
+ // One layout tree holds thousands of Widgets by value. On the 64-bit
1639
+ // targets that run the renderer, 776 bytes is the reviewed footprint;
1640
+ // packing engine-only markers keeps the new textarea policy within it.
1641
+ if (@sizeOf(usize) == 8) {
1642
+ try std.testing.expectEqual(@as(usize, 776), @sizeOf(Widget));
1643
+ }
1644
+ }
package/src/root.zig CHANGED
@@ -74,6 +74,9 @@ pub const EffectTimerOutcome = runtime.EffectTimerOutcome;
74
74
  pub const max_effect_timers = runtime.max_effect_timers;
75
75
  pub const EffectAudio = runtime.EffectAudio;
76
76
  pub const EffectAudioEventKind = runtime.EffectAudioEventKind;
77
+ pub const EffectAudioCaptureEvent = runtime.EffectAudioCaptureEvent;
78
+ pub const EffectAudioCaptureEventKind = runtime.EffectAudioCaptureEventKind;
79
+ pub const decodeAudioCaptureChannelEvent = runtime.decodeAudioCaptureChannelEvent;
77
80
  pub const EffectAudioSource = runtime.EffectAudioSource;
78
81
  pub const audioCachePath = runtime.audioCachePath;
79
82
  pub const max_effect_audio_path_bytes = runtime.max_effect_audio_path_bytes;
@@ -133,6 +136,13 @@ pub const WebViewSourceKind = platform.WebViewSourceKind;
133
136
  pub const WebViewAssetSource = platform.WebViewAssetSource;
134
137
  pub const WebEngine = platform.WebEngine;
135
138
  pub const PlatformFeature = platform.PlatformFeature;
139
+ pub const AudioCaptureSource = platform.AudioCaptureSource;
140
+ pub const AudioCaptureFormat = platform.AudioCaptureFormat;
141
+ pub const AudioCaptureEvent = platform.AudioCaptureEvent;
142
+ pub const AudioCaptureEventKind = platform.AudioCaptureEventKind;
143
+ pub const AudioCaptureSink = platform.AudioCaptureSink;
144
+ pub const AudioCapturePushResult = platform.AudioCapturePushResult;
145
+ pub const max_audio_capture_pcm_bytes = platform.max_audio_capture_pcm_bytes;
136
146
  pub const ViewKind = platform.ViewKind;
137
147
  pub const ViewOptions = platform.ViewOptions;
138
148
  pub const ViewPatch = platform.ViewPatch;
@@ -508,6 +508,7 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
508
508
  self.views[view_index].recordGpuSurfaceInputTimestamp(automationInputTimestampNs());
509
509
  try CanvasWidgetEventMethods().invalidateForCanvasWidgetRenderStateChange(self, view_index, previous_state, self.views[view_index].canvasWidgetRenderState());
510
510
  }
511
+ _ = try self.views[view_index].ensureCanvasWidgetFocusedTextCaret();
511
512
  }
512
513
 
513
514
  pub fn dispatchAutomationWidgetKey(self: *Runtime, app: runtime_api.App(Runtime), view_index: usize, id: canvas.ObjectId, key: []const u8) anyerror!void {
@@ -125,6 +125,8 @@ pub fn platformFeatureFromString(value: []const u8) ?platform.PlatformFeature {
125
125
  if (std.mem.eql(u8, value, "audioPlayback")) return .audio_playback;
126
126
  if (std.mem.eql(u8, value, "audioStreaming")) return .audio_streaming;
127
127
  if (std.mem.eql(u8, value, "audioSpectrum")) return .audio_spectrum;
128
+ if (std.mem.eql(u8, value, "microphoneCapture")) return .microphone_capture;
129
+ if (std.mem.eql(u8, value, "systemAudioCapture")) return .system_audio_capture;
128
130
  if (std.mem.eql(u8, value, "windowHideOnClose")) return .window_hide_on_close;
129
131
  if (std.mem.eql(u8, value, "videoPlayback")) return .video_playback;
130
132
  return null;
@@ -220,6 +220,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
220
220
 
221
221
  var frame_options = options;
222
222
  if (frame_options.surface_size.isEmpty()) frame_options.surface_size = self.views[index].frame.size();
223
+ frame_options.backdrop_blur_sample_extent_multiplier = backdropBlurSampleExtentMultiplier(self.options.platform.name);
223
224
  return self.views[index].canvasDisplayList().framePlan(previous, frame_options, storage);
224
225
  }
225
226
 
@@ -874,6 +875,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
874
875
  launch_timing.lapOnce("first_plan_begin");
875
876
  defer launch_timing.lapOnce("first_plan_done");
876
877
  var frame_options = options;
878
+ frame_options.backdrop_blur_sample_extent_multiplier = backdropBlurSampleExtentMultiplier(self.options.platform.name);
877
879
  if (frame_options.surface_size.isEmpty()) {
878
880
  frame_options.surface_size = if (self.views[index].gpu_size.isEmpty()) self.views[index].frame.size() else self.views[index].gpu_size;
879
881
  }
@@ -1134,6 +1136,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
1134
1136
  render_plan.commands,
1135
1137
  dirty_bounds,
1136
1138
  dirty_rects[0..dirty_rect_count],
1139
+ frame_options.backdrop_blur_sample_extent_multiplier,
1137
1140
  )) {
1138
1141
  // A blur's apron must be reconstructed from the scene as
1139
1142
  // it existed before that command. Retained pixels beyond
@@ -1316,14 +1319,22 @@ fn incrementalCanvasDamageIntersectsBackdropBlur(
1316
1319
  commands: []const canvas.RenderCommand,
1317
1320
  dirty_bounds: ?geometry.RectF,
1318
1321
  dirty_rects: []const geometry.RectF,
1322
+ sample_extent_multiplier: f32,
1319
1323
  ) bool {
1320
- if (dirty_rects.len == 0) return canvas.incrementalDamageIntersectsBackdropBlur(commands, dirty_bounds);
1324
+ if (dirty_rects.len == 0) return canvas.incrementalDamageIntersectsBackdropBlurWithSampleExtent(commands, dirty_bounds, sample_extent_multiplier);
1321
1325
  for (dirty_rects) |dirty_rect| {
1322
- if (canvas.incrementalDamageIntersectsBackdropBlur(commands, dirty_rect)) return true;
1326
+ if (canvas.incrementalDamageIntersectsBackdropBlurWithSampleExtent(commands, dirty_rect, sample_extent_multiplier)) return true;
1323
1327
  }
1324
1328
  return false;
1325
1329
  }
1326
1330
 
1331
+ /// AppKit approximates its Gaussian with three consecutive box filters, so
1332
+ /// one output pixel can depend on the sum of three box radii. Other renderers
1333
+ /// retain the shared one-radius footprint.
1334
+ fn backdropBlurSampleExtentMultiplier(platform_name: []const u8) f32 {
1335
+ return if (std.mem.eql(u8, platform_name, "macos")) 3 else 1;
1336
+ }
1337
+
1327
1338
  /// Rework a planned frame's incremental damage for the present's
1328
1339
  /// EFFECTIVE scale. Two obligations when the scales differ:
1329
1340
  /// - A COARSER presentation scale carries a larger device pixel than
@@ -438,10 +438,13 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
438
438
  }
439
439
  };
440
440
 
441
- const surface = geometry.SizeF.init(100, 40);
441
+ const surface = geometry.SizeF.init(120, 40);
442
442
  const harness = try TestHarness().create(std.testing.allocator, .{});
443
443
  defer harness.destroy(std.testing.allocator);
444
444
  harness.null_platform.gpu_surfaces = true;
445
+ // Exercise the AppKit-specific three-box sampling footprint while the
446
+ // null host keeps the test deterministic and headless.
447
+ harness.runtime.options.platform.name = "macos";
445
448
  harness.runtime.options.pixel_present_retained_baseline = true;
446
449
  var app_state: TestApp = .{};
447
450
  try harness.start(app_state.app());
@@ -452,14 +455,14 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
452
455
  .kind = .gpu_surface,
453
456
  .frame = geometry.RectF.init(0, 0, surface.width, surface.height),
454
457
  });
455
- var pixels: [100 * 40 * 4]u8 = undefined;
456
- var scratch: [100 * 40 * 4]u8 = undefined;
458
+ var pixels: [120 * 40 * 4]u8 = undefined;
459
+ var scratch: [120 * 40 * 4]u8 = undefined;
457
460
  const clear = canvas.Color.rgb8(0, 0, 0);
458
461
 
459
462
  const initial = [_]canvas.CanvasCommand{
460
463
  .{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(4, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
461
464
  .{ .fill_rect = .{ .id = 2, .rect = geometry.RectF.init(44, 15, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
462
- .{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(90, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
465
+ .{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(110, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
463
466
  .{ .push_clip = .{ .id = 3, .rect = geometry.RectF.init(50, 10, 20, 20) } },
464
467
  .{ .blur = .{ .id = 4, .rect = geometry.RectF.init(50, 10, 20, 20), .radius = 8 } },
465
468
  .pop_clip,
@@ -471,12 +474,13 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
471
474
  }, canvasFrameScratchStorage(&harness.runtime), &pixels, &scratch, clear);
472
475
  try std.testing.expect(first.full_repaint);
473
476
 
474
- // Two damage islands well outside the blur's radius keep the retained
475
- // path even though their bounding union crosses the blur apron.
477
+ // Two damage islands well outside the three-pass blur's conservative
478
+ // sampling extent keep the retained path even though their bounding
479
+ // union crosses the blur apron.
476
480
  const far_changed = [_]canvas.CanvasCommand{
477
481
  .{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(4, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 255, 0) } } },
478
482
  initial[1],
479
- .{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(90, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 255, 0) } } },
483
+ .{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(110, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 255, 0) } } },
480
484
  initial[3],
481
485
  initial[4],
482
486
  initial[5],
@@ -490,20 +494,41 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
490
494
  try std.testing.expect(incremental.dirty_bounds != null);
491
495
  try std.testing.expectEqual(@as(usize, 2), incremental.dirtyRects().len);
492
496
 
497
+ // AppKit's radius-8 Gaussian uses three boxes whose combined support
498
+ // reaches beyond the declared radius. Moving this rect to twenty points
499
+ // past the blur output must therefore replay the whole list; the old
500
+ // radius-only apron left the affected blur pixels stale.
501
+ const gaussian_apron_changed = [_]canvas.CanvasCommand{
502
+ far_changed[0],
503
+ far_changed[1],
504
+ .{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(90, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 0, 255) } } },
505
+ initial[3],
506
+ initial[4],
507
+ initial[5],
508
+ };
509
+ _ = try harness.runtime.setCanvasDisplayList(1, "canvas", .{ .commands = &gaussian_apron_changed });
510
+ const gaussian_promoted = try harness.runtime.presentNextCanvasFramePixels(1, "canvas", .{
511
+ .frame_index = 3,
512
+ .surface_size = surface,
513
+ }, canvasFrameScratchStorage(&harness.runtime), &pixels, &scratch, clear);
514
+ try std.testing.expect(gaussian_promoted.full_repaint);
515
+ try std.testing.expectEqual(@as(usize, 0), gaussian_promoted.changes.len);
516
+ try std.testing.expectEqualDeep(geometry.RectF.init(0, 0, surface.width, surface.height), gaussian_promoted.dirty_bounds.?);
517
+
493
518
  // This changed rect stops two points before the blur output, but it
494
519
  // lies inside the radius-8 sampling apron. A scissored replay would
495
520
  // sample the prior composited frame outside its dirty boundary.
496
521
  const apron_changed = [_]canvas.CanvasCommand{
497
- far_changed[0],
522
+ gaussian_apron_changed[0],
498
523
  .{ .fill_rect = .{ .id = 2, .rect = geometry.RectF.init(44, 15, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 0, 255) } } },
499
- far_changed[2],
524
+ gaussian_apron_changed[2],
500
525
  initial[3],
501
526
  initial[4],
502
527
  initial[5],
503
528
  };
504
529
  _ = try harness.runtime.setCanvasDisplayList(1, "canvas", .{ .commands = &apron_changed });
505
530
  const promoted = try harness.runtime.presentNextCanvasFramePixels(1, "canvas", .{
506
- .frame_index = 3,
531
+ .frame_index = 4,
507
532
  .surface_size = surface,
508
533
  }, canvasFrameScratchStorage(&harness.runtime), &pixels, &scratch, clear);
509
534
  try std.testing.expect(promoted.full_repaint);