@native-sdk/cli 0.9.1 → 0.9.3

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 (156) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +124 -1
  3. package/package.json +9 -9
  4. package/packages/core/package-lock.json +2 -2
  5. package/packages/core/package.json +1 -1
  6. package/packages/core/sdk/core.ts +3 -1
  7. package/packages/core/sdk/events.d.ts +7 -0
  8. package/packages/core/sdk/events.ts +26 -5
  9. package/packages/core/sdk/text.d.ts +4 -0
  10. package/packages/core/sdk/text.ts +51 -0
  11. package/packages/core/src/checker.ts +58 -1
  12. package/packages/core/src/contract.ts +5 -4
  13. package/packages/core/src/devhost_journal.mjs +2 -2
  14. package/packages/core/src/diagnostics.ts +2 -2
  15. package/packages/core/src/service_contract.ts +10 -0
  16. package/packages/core/src/typed_ast.ts +9 -7
  17. package/packages/core/src/types.ts +28 -8
  18. package/skill-data/automation/SKILL.md +4 -3
  19. package/skill-data/native-ui/SKILL.md +10 -8
  20. package/skill-data/ts-core/SKILL.md +8 -5
  21. package/src/app_runner/root.zig +301 -12
  22. package/src/app_runner/ts_core_main.zig +6 -4
  23. package/src/app_runner/window_placement.zig +63 -0
  24. package/src/automation/protocol.zig +5 -1
  25. package/src/automation/snapshot.zig +119 -0
  26. package/src/embed/app_exports.zig +2 -1
  27. package/src/embed/conversions.zig +1 -0
  28. package/src/embed/host.zig +10 -3
  29. package/src/embed/root.zig +1 -0
  30. package/src/embed/tests.zig +13 -1
  31. package/src/embed/types.zig +2 -0
  32. package/src/embed/ui_host.zig +26 -2
  33. package/src/platform/android/NativeSdkActivity.java +49 -4
  34. package/src/platform/android/android_host.c +3 -3
  35. package/src/platform/android/native_sdk_app.h +1 -1
  36. package/src/platform/ios/apple_image_fit.h +38 -0
  37. package/src/platform/ios/files.zig +1 -0
  38. package/src/platform/ios/native_sdk_app.h +1 -1
  39. package/src/platform/ios/uikit_host.m +28 -5
  40. package/src/platform/linux/cef_host.cpp +10 -2
  41. package/src/platform/linux/gtk_host.c +43 -10
  42. package/src/platform/linux/gtk_host.h +3 -3
  43. package/src/platform/linux/root.zig +22 -7
  44. package/src/platform/macos/appkit_host.h +7 -4
  45. package/src/platform/macos/appkit_host.m +271 -52
  46. package/src/platform/macos/cef_host.mm +132 -34
  47. package/src/platform/macos/image_fit_test.m +44 -0
  48. package/src/platform/macos/root.zig +222 -14
  49. package/src/platform/null_platform.zig +17 -3
  50. package/src/platform/null_platform_tests.zig +58 -4
  51. package/src/platform/root.zig +2 -0
  52. package/src/platform/types.zig +69 -19
  53. package/src/platform/windows/root.zig +22 -7
  54. package/src/platform/windows/webview2_host.cpp +31 -6
  55. package/src/primitives/app_manifest/root.zig +3 -0
  56. package/src/primitives/app_manifest/tests.zig +24 -0
  57. package/src/primitives/app_manifest/types.zig +13 -0
  58. package/src/primitives/app_manifest/validation.zig +24 -0
  59. package/src/primitives/canvas/a11y_audit.zig +9 -7
  60. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  61. package/src/primitives/canvas/events.zig +129 -1
  62. package/src/primitives/canvas/layout_audit.zig +6 -6
  63. package/src/primitives/canvas/markdown.zig +4 -0
  64. package/src/primitives/canvas/markdown_tests.zig +1 -0
  65. package/src/primitives/canvas/png.zig +138 -0
  66. package/src/primitives/canvas/root.zig +14 -2
  67. package/src/primitives/canvas/text_interaction.zig +23 -0
  68. package/src/primitives/canvas/text_span_tests.zig +5 -3
  69. package/src/primitives/canvas/text_spans.zig +2 -0
  70. package/src/primitives/canvas/text_tests.zig +65 -0
  71. package/src/primitives/canvas/ui.zig +66 -10
  72. package/src/primitives/canvas/ui_markup.zig +40 -13
  73. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  74. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  75. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  76. package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
  77. package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
  78. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  79. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  80. package/src/primitives/canvas/ui_markup_view_tests.zig +67 -6
  81. package/src/primitives/canvas/ui_schema.zig +17 -13
  82. package/src/primitives/canvas/ui_tests.zig +84 -0
  83. package/src/primitives/canvas/widget_access.zig +3 -3
  84. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  85. package/src/primitives/canvas/widget_builtin_tests.zig +593 -32
  86. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  87. package/src/primitives/canvas/widget_layout.zig +333 -126
  88. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  89. package/src/primitives/canvas/widget_metrics.zig +7 -8
  90. package/src/primitives/canvas/widget_render.zig +76 -44
  91. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  92. package/src/primitives/canvas/widget_render_style.zig +58 -18
  93. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  94. package/src/primitives/canvas/widget_routing.zig +40 -34
  95. package/src/primitives/canvas/widget_runtime.zig +11 -2
  96. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  97. package/src/primitives/canvas/widget_semantics.zig +8 -3
  98. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  99. package/src/primitives/canvas/widget_tree.zig +99 -5
  100. package/src/primitives/canvas/widgets.zig +20 -7
  101. package/src/root.zig +3 -0
  102. package/src/runtime/api.zig +6 -0
  103. package/src/runtime/automation_snapshot.zig +4 -0
  104. package/src/runtime/automation_widget_dispatch.zig +48 -6
  105. package/src/runtime/builtin_bridge.zig +5 -2
  106. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  107. package/src/runtime/canvas_image_tests.zig +146 -2
  108. package/src/runtime/canvas_images.zig +35 -16
  109. package/src/runtime/canvas_limits.zig +13 -3
  110. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  111. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  112. package/src/runtime/canvas_widget_control_tests.zig +33 -1
  113. package/src/runtime/canvas_widget_events.zig +151 -26
  114. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  115. package/src/runtime/canvas_widget_runtime.zig +322 -102
  116. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  117. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  118. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  119. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  120. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  121. package/src/runtime/canvas_widget_state.zig +33 -7
  122. package/src/runtime/canvas_widget_text_tests.zig +124 -0
  123. package/src/runtime/core.zig +16 -0
  124. package/src/runtime/effects.zig +14 -14
  125. package/src/runtime/effects_image_tests.zig +91 -0
  126. package/src/runtime/gpu_surface_events.zig +25 -2
  127. package/src/runtime/native_command_event_tests.zig +29 -0
  128. package/src/runtime/root.zig +2 -0
  129. package/src/runtime/session_journal.zig +21 -2
  130. package/src/runtime/session_replay.zig +13 -8
  131. package/src/runtime/session_tests.zig +111 -4
  132. package/src/runtime/shell_layout_tests.zig +12 -0
  133. package/src/runtime/ts_core_host_tests.zig +47 -0
  134. package/src/runtime/ts_ui_app.zig +164 -1
  135. package/src/runtime/ui_app.zig +100 -21
  136. package/src/runtime/ui_app_tests.zig +351 -32
  137. package/src/runtime/ui_app_window_tests.zig +13 -1
  138. package/src/runtime/view.zig +3 -0
  139. package/src/runtime/view_widget_control.zig +18 -0
  140. package/src/runtime/view_widget_scroll.zig +112 -18
  141. package/src/runtime/view_widget_text.zig +1 -1
  142. package/src/runtime/view_widget_tree.zig +110 -13
  143. package/src/runtime/widget_bridge.zig +2 -0
  144. package/src/runtime/window_command_bridge_tests.zig +86 -0
  145. package/src/runtime/window_storage.zig +16 -1
  146. package/src/runtime/window_views.zig +1 -0
  147. package/src/tooling/ios.zig +3 -0
  148. package/src/tooling/manifest.zig +90 -2
  149. package/src/tooling/package.zig +67 -2
  150. package/src/tooling/raw_manifest.zig +10 -0
  151. package/src/tooling/templates.zig +128 -18
  152. package/src/tooling/verbs.zig +1 -0
  153. package/src/tooling/web_engine.zig +1 -1
  154. package/tools/corewire/emit.zig +31 -12
  155. package/tools/corewire/emit_facade.zig +57 -2
  156. package/tools/corewire/shim_rt.zig +20 -0
@@ -55,13 +55,14 @@ pub fn hitTestWidgetLayout(layout: anytype, point: geometry.PointF, tokens: Desi
55
55
  }
56
56
 
57
57
  pub fn hitTestWidgetLayoutWithPolicy(layout: anytype, point: geometry.PointF, tokens: DesignTokens, comptime policy: HitTestPolicy) ?WidgetHit {
58
- // Anchored floating surfaces paint in the late z-pass — topmost — so
59
- // they hit-test FIRST, in reverse tree order (a nested anchored
60
- // submenu has a higher node index than the surface it hangs from).
61
- var index = layout.nodes.len;
62
- while (index > 0) {
63
- index -= 1;
64
- if (!widget_tree.widgetIsAnchored(layout.nodes[index].widget)) continue;
58
+ // Window-level surfaces paint in the late z-pass — topmost — so they
59
+ // hit-test FIRST, in reverse window-surface paint order.
60
+ const surface_count = widget_tree.widgetLayoutWindowSurfaceCount(layout);
61
+ var tested: usize = 0;
62
+ var previous: ?widget_tree.WidgetPaintOrder = null;
63
+ while (tested < surface_count) : (tested += 1) {
64
+ const index = widget_tree.previousWidgetLayoutWindowSurface(layout, tokens, previous) orelse break;
65
+ previous = widget_tree.widgetLayoutWindowSurfaceOrder(layout, index, tokens);
65
66
  if (isWidgetHiddenInAncestors(layout, index)) continue;
66
67
  if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) continue;
67
68
  if (hitTestWidgetLayoutNode(layout, index, point, tokens, policy)) |hit| return hit;
@@ -75,9 +76,9 @@ fn hitTestWidgetLayoutChildren(layout: anytype, parent_index: ?usize, point: geo
75
76
  var previous: ?widget_tree.WidgetPaintOrder = null;
76
77
  while (tested < child_count) : (tested += 1) {
77
78
  const child_index = widget_tree.previousWidgetLayoutPaintChild(layout, parent_index, tokens, previous) orelse return null;
78
- // Anchored floating children live in the hoisted pre-pass above,
79
- // never at their tree position.
80
- if (!widget_tree.widgetIsAnchored(layout.nodes[child_index].widget)) {
79
+ // Window-level surfaces live in the hoisted pre-pass above, never
80
+ // at their tree position.
81
+ if (!widget_tree.widgetEscapesAncestorClips(layout.nodes[child_index].widget)) {
81
82
  if (hitTestWidgetLayoutNode(layout, child_index, point, tokens, policy)) |hit| return hit;
82
83
  }
83
84
  previous = .{ .layer = widget_tree.widgetPaintLayer(layout.nodes[child_index].widget, tokens), .index = child_index };
@@ -131,7 +132,7 @@ fn widgetHitFromNode(node: WidgetLayoutNode, index: usize) WidgetHit {
131
132
  /// claims presses (`widgetClaimsPress`). Plain text, icons, decorations,
132
133
  /// and layout containers let the press fall through; interactive kinds,
133
134
  /// editable text, scroll containers, overlay surfaces, and any widget
134
- /// with a bound press/toggle handler stop the walk. Returns null when
135
+ /// with a bound press/toggle/drag handler stop the walk. Returns null when
135
136
  /// nothing on the path claims — the press dispatches to no one, exactly
136
137
  /// like a click on dead space.
137
138
  pub fn widgetPressTargetIndexFromNode(layout: anytype, node_index: usize) ?usize {
@@ -234,9 +235,9 @@ pub fn widgetWindowDragTargetIndexFromNode(layout: anytype, node_index: usize) ?
234
235
  fn isPointVisibleInWidgetAncestors(layout: anytype, node_index: usize, point: geometry.PointF) bool {
235
236
  var current: usize = node_index;
236
237
  while (true) {
237
- // An anchored floating widget escapes its ancestors' clip regions
238
- // (window-clipped, not parent-clipped), so the walk stops here.
239
- if (widget_tree.widgetIsAnchored(layout.nodes[current].widget)) return true;
238
+ // A window-level surface escapes its ancestors' clip regions, so
239
+ // the walk stops here.
240
+ if (widget_tree.widgetEscapesAncestorClips(layout.nodes[current].widget)) return true;
240
241
  const parent_index = layout.nodes[current].parent_index orelse return true;
241
242
  if (parent_index >= layout.nodes.len) return true;
242
243
  const parent = layout.nodes[parent_index];
@@ -251,10 +252,9 @@ fn isWidgetFrameVisibleInWidgetAncestors(layout: anytype, node_index: usize) boo
251
252
  if (frame.isEmpty()) return false;
252
253
  var current: usize = node_index;
253
254
  while (true) {
254
- // Anchored floating widgets escape ancestor clips — focus targets
255
- // inside an open overlay stay live outside the scroll ancestor's
256
- // bounds.
257
- if (widget_tree.widgetIsAnchored(layout.nodes[current].widget)) return true;
255
+ // Window-level surfaces escape ancestor clips, keeping their focus
256
+ // targets live outside the authored container's bounds.
257
+ if (widget_tree.widgetEscapesAncestorClips(layout.nodes[current].widget)) return true;
258
258
  const parent_index = layout.nodes[current].parent_index orelse return true;
259
259
  if (parent_index >= layout.nodes.len) return true;
260
260
  const parent = layout.nodes[parent_index];
@@ -413,6 +413,26 @@ pub fn focusWidgetTargetById(layout: anytype, id: ObjectId, scroll_semantics_fn:
413
413
  return focusTargetFromLayoutNode(layout, index, scroll_semantics_fn);
414
414
  }
415
415
 
416
+ /// Resolve every ordinary focus gate except ancestor geometry. Runtime
417
+ /// reveal paths use this to name a clipped target before scrolling it, while
418
+ /// keeping the exact same hidden, disclosure, disabled, and scroll-semantic
419
+ /// eligibility as `focusWidgetTargetById`.
420
+ pub fn logicalFocusWidgetTargetAtIndex(layout: anytype, index: usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
421
+ if (index >= layout.nodes.len) return null;
422
+ if (isWidgetHiddenInAncestors(layout, index)) return null;
423
+ if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) return null;
424
+ const node = layout.nodes[index];
425
+ if (node.widget.id == 0) return null;
426
+ if (!widget_access.isFocusable(node.widget) and (node.widget.state.disabled or !scroll_semantics_fn(layout, index).scrollable)) return null;
427
+ return .{
428
+ .id = node.widget.id,
429
+ .kind = node.widget.kind,
430
+ .bounds = node.frame,
431
+ .index = index,
432
+ .state = node.widget.state,
433
+ };
434
+ }
435
+
416
436
  fn focusForward(layout: anytype, current_index: ?usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
417
437
  var index: usize = if (current_index) |value| value + 1 else 0;
418
438
  while (index < layout.nodes.len) : (index += 1) {
@@ -466,23 +486,9 @@ fn focusSpatial(layout: anytype, current_index: usize, direction: WidgetFocusDir
466
486
  }
467
487
 
468
488
  fn focusTargetFromLayoutNode(layout: anytype, index: usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
469
- if (index >= layout.nodes.len) return null;
470
- if (isWidgetHiddenInAncestors(layout, index)) return null;
471
- // Concealed disclosure content never joins the focus order: a
472
- // closed section's controls are unreachable by tab or arrows, and
473
- // mid-reveal content stays unreachable until the reveal settles.
474
- if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) return null;
489
+ const target = logicalFocusWidgetTargetAtIndex(layout, index, scroll_semantics_fn) orelse return null;
475
490
  if (!isWidgetFrameVisibleInWidgetAncestors(layout, index)) return null;
476
- const node = layout.nodes[index];
477
- if (node.widget.id == 0) return null;
478
- if (!widget_access.isFocusable(node.widget) and (node.widget.state.disabled or !scroll_semantics_fn(layout, index).scrollable)) return null;
479
- return .{
480
- .id = node.widget.id,
481
- .kind = node.widget.kind,
482
- .bounds = node.frame,
483
- .index = index,
484
- .state = node.widget.state,
485
- };
491
+ return target;
486
492
  }
487
493
 
488
494
  fn spatialFocusCandidate(
@@ -60,6 +60,10 @@ pub const textGeometryForWidget = widget_text_input.textGeometryForWidget;
60
60
 
61
61
  pub const WidgetLayoutTree = struct {
62
62
  nodes: []const WidgetLayoutNode = &.{},
63
+ /// Viewport bounds that produced the layout. Kept on the tree instead
64
+ /// of every node so root-authored modals retain their window-space
65
+ /// contract without widening the hot node array.
66
+ root_bounds: ?geometry.RectF = null,
63
67
 
64
68
  pub fn nodeCount(self: WidgetLayoutTree) usize {
65
69
  return self.nodes.len;
@@ -158,6 +162,10 @@ pub const WidgetLayoutTree = struct {
158
162
  return widget_routing.focusWidgetTargetById(self, id, widgetScrollSemantics);
159
163
  }
160
164
 
165
+ pub fn logicalFocusTargetAtIndex(self: WidgetLayoutTree, index: usize) ?WidgetFocusTarget {
166
+ return widget_routing.logicalFocusWidgetTargetAtIndex(self, index, widgetScrollSemantics);
167
+ }
168
+
161
169
  pub fn collectSemantics(self: WidgetLayoutTree, output: []WidgetSemanticsNode) Error![]const WidgetSemanticsNode {
162
170
  return collectWidgetSemantics(self, output);
163
171
  }
@@ -201,9 +209,10 @@ pub fn layoutWidgetTree(widget: Widget, bounds: geometry.RectF, output: []Widget
201
209
  }
202
210
 
203
211
  pub fn layoutWidgetTreeWithTokens(widget: Widget, bounds: geometry.RectF, tokens: DesignTokens, output: []WidgetLayoutNode) Error!WidgetLayoutTree {
212
+ const root_bounds = bounds.normalized();
204
213
  var len: usize = 0;
205
- _ = try widget_layout.layoutWidgetDepth(widget, bounds.normalized(), null, 0, output, &len, tokens);
206
- return .{ .nodes = output[0..len] };
214
+ _ = try widget_layout.layoutWidgetDepth(widget, root_bounds, null, 0, output, &len, tokens);
215
+ return .{ .nodes = output[0..len], .root_bounds = root_bounds };
207
216
  }
208
217
 
209
218
  pub fn intrinsicWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
@@ -1750,11 +1750,13 @@ test "widget emitter applies button variants" {
1750
1750
  try emitWidgetTree(&builder, .{ .id = 23, .kind = .button, .frame = geometry.RectF.init(0, 120, 120, 32), .text = "Ghost", .variant = .ghost }, tokens);
1751
1751
  try emitWidgetTree(&builder, .{ .id = 24, .kind = .button, .frame = geometry.RectF.init(0, 160, 120, 32), .text = "Delete", .variant = .destructive }, tokens);
1752
1752
 
1753
- // Every variant is FLAT (no shadow command): 5 x (fill + border +
1754
- // label). Destructive is the quiet red chip — the destructive hue
1755
- // as a 10% wash under destructive-red text, borderless.
1753
+ // Every variant is FLAT (no shadow command): primary, secondary, and
1754
+ // outline each emit fill + border + label; borderless ghost and
1755
+ // destructive each emit only fill + label. Destructive is the quiet
1756
+ // red chip — the destructive hue as a 10% wash under destructive-red
1757
+ // text. No dead zero-width stroke commands enter the list.
1756
1758
  const display_list = builder.displayList();
1757
- try std.testing.expectEqual(@as(usize, 15), display_list.commandCount());
1759
+ try std.testing.expectEqual(@as(usize, 13), display_list.commandCount());
1758
1760
  switch (display_list.commands[0]) {
1759
1761
  .fill_rounded_rect => |fill| try expectFillColor(tokens.colors.accent, fill.fill),
1760
1762
  else => return error.TestUnexpectedResult,
@@ -1775,19 +1777,13 @@ test "widget emitter applies button variants" {
1775
1777
  .fill_rounded_rect => |fill| try expectFillColor(transparentColor(), fill.fill),
1776
1778
  else => return error.TestUnexpectedResult,
1777
1779
  }
1778
- switch (display_list.commands[10]) {
1779
- .stroke_rect => |stroke| try std.testing.expectEqual(@as(f32, 0), stroke.stroke.width),
1780
- else => return error.TestUnexpectedResult,
1781
- }
1782
- switch (display_list.commands[12]) {
1780
+ try std.testing.expect(display_list.findCommandById(widgetPartId(23, 2)) == null);
1781
+ switch (display_list.commands[11]) {
1783
1782
  .fill_rounded_rect => |fill| try expectFillColor(colorWithAlpha(tokens.colors.destructive, 0.10), fill.fill),
1784
1783
  else => return error.TestUnexpectedResult,
1785
1784
  }
1786
- switch (display_list.commands[13]) {
1787
- .stroke_rect => |stroke| try std.testing.expectEqual(@as(f32, 0), stroke.stroke.width),
1788
- else => return error.TestUnexpectedResult,
1789
- }
1790
- switch (display_list.commands[14]) {
1785
+ try std.testing.expect(display_list.findCommandById(widgetPartId(24, 2)) == null);
1786
+ switch (display_list.commands[12]) {
1791
1787
  .draw_text => |text| try std.testing.expectEqualDeep(tokens.colors.destructive, text.color),
1792
1788
  else => return error.TestUnexpectedResult,
1793
1789
  }
@@ -114,7 +114,8 @@ fn nearestSemanticParent(stack: []const ?usize) ?usize {
114
114
  pub fn semanticRole(widget: Widget) WidgetRole {
115
115
  if (widget.semantics.role != .none) return widget.semantics.role;
116
116
  return switch (widget.kind) {
117
- .stack, .row, .column, .grid, .scroll_view, .breadcrumb, .button_group, .pagination, .radio_group, .tabs, .toggle_group, .accordion, .bubble, .resizable, .alert, .card, .panel => .group,
117
+ .stack, .row, .column, .grid, .scroll_view, .breadcrumb, .button_group, .pagination, .tabs, .toggle_group, .accordion, .bubble, .resizable, .alert, .card, .panel => .group,
118
+ .radio_group => .radiogroup,
118
119
  .data_grid, .table => .grid,
119
120
  .data_row => .row,
120
121
  .dialog, .drawer, .sheet, .popover => .dialog,
@@ -519,6 +520,10 @@ fn widgetScrollContentExtent(layout: anytype, scroll_index: usize, viewport: geo
519
520
  var index = scroll_index + 1;
520
521
  while (index < layout.nodes.len and layout.nodes[index].depth > scroll_depth) {
521
522
  const node = layout.nodes[index];
523
+ if (widget_tree.widgetIsRootRelativeModal(node.widget)) {
524
+ index = skipSubtree(layout, index);
525
+ continue;
526
+ }
522
527
  // A subtree anchored DIRECTLY to the scroll region stays
523
528
  // stationary under scrolling (its anchor base never moves), so
524
529
  // `frame + offset` is not a content-space position for it —
@@ -551,7 +556,7 @@ fn widgetScrollContentExtent(layout: anytype, scroll_index: usize, viewport: geo
551
556
  /// The horizontal content reach for a horizontal scroll view's
552
557
  /// semantics — the sideways mirror of `widgetScrollContentExtent`, with
553
558
  /// the honest-range exclusions the engine's clamp/driver walker applies
554
- /// (`canvasWidgetLayoutScrollContentExtentX`): anchored floating
559
+ /// (`canvasWidgetLayoutScrollContentExtentX`): window-level floating
555
560
  /// subtrees are out of flow, a nested clip scope bounds its own
556
561
  /// children, and disclosure content counts only while settled open.
557
562
  fn widgetScrollContentExtentX(layout: anytype, scroll_index: usize, viewport: geometry.RectF) f32 {
@@ -562,7 +567,7 @@ fn widgetScrollContentExtentX(layout: anytype, scroll_index: usize, viewport: ge
562
567
  var index = scroll_index + 1;
563
568
  while (index < layout.nodes.len and layout.nodes[index].depth > scroll_depth) {
564
569
  const node = layout.nodes[index];
565
- if (node.widget.layout.anchor != null) {
570
+ if (widget_tree.widgetEscapesAncestorClips(node.widget)) {
566
571
  index = skipSubtree(layout, index);
567
572
  continue;
568
573
  }
@@ -2083,10 +2083,14 @@ test "text editing affordance colors resolve tokens and per-widget overrides" {
2083
2083
  try std.testing.expectEqual(Color.rgb8(4, 5, 6).r, styled_wash.r);
2084
2084
  try std.testing.expectApproxEqAbs(@as(f32, 0.3), styled_wash.a, 0.001);
2085
2085
 
2086
- // A disabled field's ink mutes with its text.
2086
+ // A disabled field keeps its resolved text identity at the shared
2087
+ // disabled-wash strength instead of swapping to a flat gray.
2087
2088
  var disabled = field;
2088
2089
  disabled.state.disabled = true;
2089
- try std.testing.expectEqualDeep(tokens.colors.text_muted, textEditingInkColor(disabled, tokens));
2090
+ try std.testing.expectEqualDeep(
2091
+ Color.rgba(tokens.colors.text.r, tokens.colors.text.g, tokens.colors.text.b, tokens.states.disabled_alpha),
2092
+ textEditingInkColor(disabled, tokens),
2093
+ );
2090
2094
  }
2091
2095
 
2092
2096
  test "widget text fields render wrapped selection geometry" {
@@ -17,12 +17,70 @@ pub const WidgetPaintOrder = struct {
17
17
  pub fn widgetPaintLayer(widget: Widget, tokens: DesignTokens) i32 {
18
18
  if (widget.layer) |layer| return layer;
19
19
  return switch (widget.kind) {
20
+ .dialog, .drawer, .sheet => tokens.layer.modal,
20
21
  .popover, .menu_surface, .dropdown_menu => tokens.layer.overlay,
21
22
  .tooltip => tokens.layer.floating,
22
23
  else => tokens.layer.base,
23
24
  };
24
25
  }
25
26
 
27
+ /// Window-surface ordering keeps anchored siblings in their established
28
+ /// mount-order stack while lifting root-relative modals into the modal token
29
+ /// stratum. An explicit widget layer always wins. Anchored tooltip/menu
30
+ /// coexistence deliberately shares the overlay stratum here: their late-pass
31
+ /// contract is last-mounted-on-top even though their ordinary in-tree token
32
+ /// defaults differ.
33
+ pub fn widgetWindowSurfaceLayer(widget: Widget, tokens: DesignTokens) i32 {
34
+ if (widget.layer) |layer| return layer;
35
+ if (widgetIsRootRelativeModal(widget)) return tokens.layer.modal;
36
+ if (widgetIsAnchored(widget)) return tokens.layer.overlay;
37
+ return widgetPaintLayer(widget, tokens);
38
+ }
39
+
40
+ /// Effective layer of a hoisted window surface in a laid tree. A surface
41
+ /// without an explicit layer cannot fall beneath the window surface that
42
+ /// contains it: a default dropdown/tooltip opened inside a modal therefore
43
+ /// stays in the modal stratum, while an explicitly authored layer remains an
44
+ /// intentional escape hatch.
45
+ pub fn widgetLayoutWindowSurfaceLayer(layout: anytype, node_index: usize, tokens: DesignTokens) i32 {
46
+ const node = layout.nodes[node_index];
47
+ if (node.widget.layer) |layer| return layer;
48
+
49
+ var layer = widgetWindowSurfaceLayer(node.widget, tokens);
50
+ var current = node.parent_index;
51
+ while (current) |index| {
52
+ if (index >= layout.nodes.len) break;
53
+ const ancestor = layout.nodes[index];
54
+ if (widgetEscapesAncestorClips(ancestor.widget)) {
55
+ layer = @max(layer, widgetWindowSurfaceLayer(ancestor.widget, tokens));
56
+ }
57
+ current = ancestor.parent_index;
58
+ }
59
+ return layer;
60
+ }
61
+
62
+ pub fn widgetLayoutWindowSurfaceOrder(layout: anytype, node_index: usize, tokens: DesignTokens) WidgetPaintOrder {
63
+ return .{
64
+ .layer = widgetLayoutWindowSurfaceLayer(layout, node_index, tokens),
65
+ .index = node_index,
66
+ };
67
+ }
68
+
69
+ /// Modal surfaces are placed in layout-root coordinates and never ride an
70
+ /// ancestor scroll region's content translation.
71
+ pub fn widgetIsRootRelativeModal(widget: Widget) bool {
72
+ return switch (widget.kind) {
73
+ .dialog, .drawer, .sheet => true,
74
+ else => false,
75
+ };
76
+ }
77
+
78
+ /// Surfaces whose layout, paint, routing, and visibility are resolved at
79
+ /// the window level rather than through their authored ancestor clips.
80
+ pub fn widgetEscapesAncestorClips(widget: Widget) bool {
81
+ return widgetIsAnchored(widget) or widgetIsRootRelativeModal(widget);
82
+ }
83
+
26
84
  pub fn nextWidgetPaintChild(children: []const Widget, tokens: DesignTokens, previous: ?WidgetPaintOrder) ?usize {
27
85
  var best: ?WidgetPaintOrder = null;
28
86
  for (children, 0..) |child, index| {
@@ -63,6 +121,36 @@ pub fn previousWidgetLayoutPaintChild(layout: anytype, parent_index: ?usize, tok
63
121
  return if (best) |order| order.index else null;
64
122
  }
65
123
 
124
+ pub inline fn widgetLayoutWindowSurfaceCount(layout: anytype) usize {
125
+ var count: usize = 0;
126
+ for (layout.nodes) |node| {
127
+ if (widgetEscapesAncestorClips(node.widget)) count += 1;
128
+ }
129
+ return count;
130
+ }
131
+
132
+ pub fn nextWidgetLayoutWindowSurface(layout: anytype, tokens: DesignTokens, previous: ?WidgetPaintOrder) ?usize {
133
+ var best: ?WidgetPaintOrder = null;
134
+ for (layout.nodes, 0..) |node, index| {
135
+ if (!widgetEscapesAncestorClips(node.widget)) continue;
136
+ const order = widgetLayoutWindowSurfaceOrder(layout, index, tokens);
137
+ if (!widgetPaintOrderAfter(order, previous)) continue;
138
+ if (best == null or widgetPaintOrderLess(order, best.?)) best = order;
139
+ }
140
+ return if (best) |order| order.index else null;
141
+ }
142
+
143
+ pub fn previousWidgetLayoutWindowSurface(layout: anytype, tokens: DesignTokens, previous: ?WidgetPaintOrder) ?usize {
144
+ var best: ?WidgetPaintOrder = null;
145
+ for (layout.nodes, 0..) |node, index| {
146
+ if (!widgetEscapesAncestorClips(node.widget)) continue;
147
+ const order = widgetLayoutWindowSurfaceOrder(layout, index, tokens);
148
+ if (!widgetPaintOrderBefore(order, previous)) continue;
149
+ if (best == null or widgetPaintOrderLess(best.?, order)) best = order;
150
+ }
151
+ return if (best) |order| order.index else null;
152
+ }
153
+
66
154
  fn widgetPaintOrderAfter(order: WidgetPaintOrder, previous: ?WidgetPaintOrder) bool {
67
155
  const value = previous orelse return true;
68
156
  return order.layer > value.layer or (order.layer == value.layer and order.index > value.index);
@@ -73,7 +161,7 @@ fn widgetPaintOrderBefore(order: WidgetPaintOrder, previous: ?WidgetPaintOrder)
73
161
  return order.layer < value.layer or (order.layer == value.layer and order.index < value.index);
74
162
  }
75
163
 
76
- fn widgetPaintOrderLess(a: WidgetPaintOrder, b: WidgetPaintOrder) bool {
164
+ pub fn widgetPaintOrderLess(a: WidgetPaintOrder, b: WidgetPaintOrder) bool {
77
165
  return a.layer < b.layer or (a.layer == b.layer and a.index < b.index);
78
166
  }
79
167
 
@@ -186,16 +274,22 @@ pub fn widgetKindDisclosureAnimated(kind: widget_model.WidgetKind) bool {
186
274
  const disclosure_settle_slack: f32 = 0.5;
187
275
 
188
276
  /// The bottom edge the disclosure widget's content REACHES: the deepest
189
- /// maxY among its in-flow children's subtrees. Anchored children float
190
- /// outside the flow (window-positioned) and never count.
277
+ /// maxY among its in-flow children's subtrees. Window-level surfaces float
278
+ /// outside the flow and never count.
191
279
  pub fn disclosureContentBottom(layout: anytype, node_index: usize) f32 {
192
280
  const node = layout.nodes[node_index];
193
281
  var bottom = -std.math.inf(f32);
194
282
  var index = node_index + 1;
195
- while (index < layout.nodes.len and layout.nodes[index].depth > node.depth) : (index += 1) {
283
+ while (index < layout.nodes.len and layout.nodes[index].depth > node.depth) {
196
284
  const child = layout.nodes[index];
197
- if (widgetIsAnchored(child.widget)) continue;
285
+ if (widgetEscapesAncestorClips(child.widget)) {
286
+ const subtree_depth = child.depth;
287
+ index += 1;
288
+ while (index < layout.nodes.len and layout.nodes[index].depth > subtree_depth) : (index += 1) {}
289
+ continue;
290
+ }
198
291
  bottom = @max(bottom, child.frame.normalized().maxY());
292
+ index += 1;
199
293
  }
200
294
  return bottom;
201
295
  }
@@ -577,6 +577,8 @@ pub const WidgetRole = enum {
577
577
  tab,
578
578
  checkbox,
579
579
  radio,
580
+ /// A single-choice group containing descendant radio controls.
581
+ radiogroup,
580
582
  switch_control,
581
583
  slider,
582
584
  progressbar,
@@ -743,7 +745,7 @@ pub fn builtinComponentDescriptor(kind: BuiltinComponentKind) BuiltinComponentDe
743
745
  .input => builtinComponent(.input, .input, .textbox, false),
744
746
  .pagination => builtinComponent(.pagination, .pagination, .group, true),
745
747
  .progress => builtinComponent(.progress, .progress, .progressbar, false),
746
- .radio_group => builtinComponent(.radio_group, .radio_group, .group, true),
748
+ .radio_group => builtinComponent(.radio_group, .radio_group, .radiogroup, true),
747
749
  .resizable => builtinComponent(.resizable, .resizable, .group, true),
748
750
  .select => builtinComponent(.select, .select, .button, true),
749
751
  .separator => builtinComponent(.separator, .separator, .none, false),
@@ -1040,9 +1042,8 @@ pub const Widget = struct {
1040
1042
  layer: ?i32 = null,
1041
1043
  /// Modal surfaces (dialog/drawer/sheet) paint a token-driven scrim
1042
1044
  /// (dim + backdrop blur) across the whole tree behind them. False
1043
- /// opts a surface out — for embedding one as an inline PREVIEW
1044
- /// (a component catalog card, a docs specimen) where it is not
1045
- /// actually modal. Ignored on every other kind.
1045
+ /// opts out of the scrim for a non-modal specimen; placement remains
1046
+ /// root-relative. Ignored on every other kind.
1046
1047
  scrim: bool = true,
1047
1048
  state: WidgetState = .{},
1048
1049
  layout: WidgetLayoutStyle = .{},
@@ -1210,8 +1211,8 @@ pub const BuiltinComponentOptions = struct {
1210
1211
  text_composition: ?TextRange = null,
1211
1212
  value: f32 = 0,
1212
1213
  layer: ?i32 = null,
1213
- /// See `Widget.scrim`: false embeds a modal surface as an inline
1214
- /// preview without the behind-it dim + blur.
1214
+ /// See `Widget.scrim`: false keeps root-relative placement but omits
1215
+ /// the behind-it dim + blur.
1215
1216
  scrim: bool = true,
1216
1217
  state: WidgetState = .{},
1217
1218
  layout: WidgetLayoutStyle = .{},
@@ -1509,6 +1510,18 @@ fn builtinComponentSemantics(descriptor: BuiltinComponentDescriptor, semantics:
1509
1510
  /// concentric with the container's at every position.
1510
1511
  pub const tabs_list_inset: f32 = 3;
1511
1512
 
1513
+ /// Additive control-size step shared by token-backed chrome metrics and
1514
+ /// token-independent kind defaults. The default alert inset uses the
1515
+ /// house 16px base / 2px step here; runtime token packs feed their own
1516
+ /// base and step through `widget_metrics.widgetSizedTokenValue`.
1517
+ pub fn widgetSizeSteppedValue(size: WidgetSize, value: f32, step: f32) f32 {
1518
+ return switch (size) {
1519
+ .sm => @max(0, value - step),
1520
+ .default, .icon, .heading, .display => value,
1521
+ .lg => value + step,
1522
+ };
1523
+ }
1524
+
1512
1525
  /// Ergonomic per-kind layout defaults for the composite surfaces whose
1513
1526
  /// house reference carries built-in content spacing, shared by EVERY
1514
1527
  /// authoring path — `builtinComponentWidget` and (via the ui builder,
@@ -1525,7 +1538,7 @@ pub fn widgetKindDefaultLayout(kind: WidgetKind, size: WidgetSize) ?WidgetLayout
1525
1538
  .clip_content = true,
1526
1539
  },
1527
1540
  .alert => .{
1528
- .padding = geometry.InsetsF.all(16),
1541
+ .padding = geometry.InsetsF.all(widgetSizeSteppedValue(size, 16, 2)),
1529
1542
  .gap = 12,
1530
1543
  .clip_content = true,
1531
1544
  },
package/src/root.zig CHANGED
@@ -133,6 +133,7 @@ pub const EffectImageOutcome = runtime.EffectImageOutcome;
133
133
  pub const imageCachePath = runtime.imageCachePath;
134
134
  pub const max_effect_image_path_bytes = runtime.max_effect_image_path_bytes;
135
135
  pub const max_effect_image_bytes = runtime.max_effect_image_bytes;
136
+ pub const max_effect_image_source_bytes = runtime.max_effect_image_source_bytes;
136
137
  pub const effect_image_blob_hash_len = runtime.effect_image_blob_hash_len;
137
138
  pub const EffectChannelEvent = runtime.EffectChannelEvent;
138
139
  pub const EffectChannelEventKind = runtime.EffectChannelEventKind;
@@ -168,6 +169,7 @@ pub const setFreestandingMonotonicNanoseconds = runtime.setFreestandingMonotonic
168
169
  pub const RegisteredImage = runtime.RegisteredImage;
169
170
  pub const max_registered_canvas_images = runtime.max_registered_canvas_images;
170
171
  pub const max_registered_canvas_image_pixel_bytes = runtime.max_registered_canvas_image_pixel_bytes;
172
+ pub const max_registered_canvas_image_pixel_bytes_ceiling = runtime.max_registered_canvas_image_pixel_bytes_ceiling;
171
173
  pub const MediaSurfaceProducer = runtime.MediaSurfaceProducer;
172
174
  pub const max_media_surface_channels = runtime.max_media_surface_channels;
173
175
  pub const max_media_surface_pixel_bytes = runtime.max_media_surface_pixel_bytes;
@@ -214,6 +216,7 @@ pub const WindowCreateOptions = platform.WindowCreateOptions;
214
216
  pub const WindowInfo = platform.WindowInfo;
215
217
  pub const WindowState = platform.WindowState;
216
218
  pub const WindowRestorePolicy = platform.WindowRestorePolicy;
219
+ pub const WindowInitialPlacement = platform.WindowInitialPlacement;
217
220
  pub const WindowTitlebarStyle = platform.WindowTitlebarStyle;
218
221
  pub const WindowChrome = platform.WindowChrome;
219
222
  pub const FormFactor = platform.FormFactor;
@@ -8,6 +8,7 @@ const extensions = @import("../extensions/root.zig");
8
8
  const app_manifest = @import("app_manifest");
9
9
  const platform = @import("../platform/root.zig");
10
10
  const runtime_effects = @import("effects.zig");
11
+ const canvas_limits = @import("canvas_limits.zig");
11
12
  const runtime_session_record = @import("session_record.zig");
12
13
  const runtime_view = @import("view.zig");
13
14
  const security = @import("../security/root.zig");
@@ -480,6 +481,11 @@ pub const Options = struct {
480
481
  /// mutating `options.allocator` on a live runtime retargets
481
482
  /// nothing — pick the owning allocator here, before init.
482
483
  allocator: std.mem.Allocator = std.heap.page_allocator,
484
+ /// Runtime-frozen registered-image pixel budget. The standard app
485
+ /// runner reads this from app.zon's `.images.max_image_pixel_bytes`;
486
+ /// custom runners may set it directly. Storage remains lazy per used
487
+ /// slot, so raising the budget reserves nothing by itself.
488
+ max_image_pixel_bytes: usize = canvas_limits.max_registered_canvas_image_pixel_bytes,
483
489
  trace_sink: ?trace.Sink = null,
484
490
  log_path: ?[]const u8 = null,
485
491
  extensions: ?extensions.ModuleRegistry = null,
@@ -30,6 +30,8 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
30
30
  .windows = self.automation_windows[0..1],
31
31
  .views = &.{},
32
32
  .widgets = &.{},
33
+ .commands = self.options.commands,
34
+ .menus = self.options.menus,
33
35
  .diagnostics = automationDiagnostics(self),
34
36
  .frame_profile = automationFrameProfile(self),
35
37
  .trays = automationTrays(self),
@@ -64,6 +66,8 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
64
66
  .windows = self.automation_windows[0..count],
65
67
  .views = self.automation_views[0..view_count],
66
68
  .widgets = self.automation_widgets[0..widget_count],
69
+ .commands = self.options.commands,
70
+ .menus = self.options.menus,
67
71
  .diagnostics = automationDiagnostics(self),
68
72
  .frame_profile = automationFrameProfile(self),
69
73
  .trays = automationTrays(self),
@@ -476,8 +476,16 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
476
476
 
477
477
  pub fn focusAutomationCanvasWidget(self: *Runtime, view_index: usize, id: canvas.ObjectId) anyerror!void {
478
478
  if (view_index >= self.view_count) return error.ViewNotFound;
479
- const target = self.views[view_index].widgetLayoutTree().focusTargetById(id) orelse return error.InvalidCommand;
479
+ // Programmatic focus names logical targets before applying the
480
+ // pointer path's geometry clip. The shared keyboard/autofocus
481
+ // reveal seam scrolls every runtime-owned ancestor. Preflight
482
+ // the reveal before platform focus, then focus the view before
483
+ // committing any retained scroll mutation: a rejected platform
484
+ // focus leaves the canvas byte-for-byte where it was.
485
+ if (!CanvasWidgetEventMethods().canRevealCanvasWidgetFocusTarget(self, view_index, id)) return error.InvalidCommand;
480
486
  try self.focusView(self.views[view_index].window_id, self.views[view_index].label);
487
+ const reveal = try CanvasWidgetEventMethods().revealCanvasWidgetFocusTarget(self, view_index, id) orelse return error.InvalidCommand;
488
+ const target = reveal.target;
481
489
  // Programmatic focus (autofocus, automation `focus`) follows
482
490
  // the pointer contract, not the keyboard one: buttons and
483
491
  // rows take focus QUIETLY (no ring), editable text kinds show
@@ -486,8 +494,9 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
486
494
  // window-level default focus landing on a button dressed an
487
495
  // idle control in the focus ring.
488
496
  const focus_visible_id: canvas.ObjectId = if (canvas_widget_runtime.canvasWidgetShowsPointerFocusRing(target.kind)) target.id else 0;
489
- if (self.views[view_index].canvas_widget_focused_id != target.id or self.views[view_index].canvas_widget_focus_visible_id != focus_visible_id) {
490
- const previous_state = self.views[view_index].canvasWidgetRenderState();
497
+ const previous_state = self.views[view_index].canvasWidgetRenderState();
498
+ const focus_changed = self.views[view_index].canvas_widget_focused_id != target.id or self.views[view_index].canvas_widget_focus_visible_id != focus_visible_id;
499
+ if (focus_changed) {
491
500
  self.views[view_index].canvas_widget_focused_id = target.id;
492
501
  self.views[view_index].canvas_widget_focus_visible_id = focus_visible_id;
493
502
  // Pointer-contract provenance: a programmatic ring
@@ -501,14 +510,47 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
501
510
  // widget whose focus-shown tooltip is up with the ring
502
511
  // intact is not a move, and leaves it alone.
503
512
  try CanvasWidgetEventMethods().updateCanvasTooltipIntentForProgrammaticFocusMove(self, view_index);
504
- // A focus change repaints; record the automation input so
505
- // the completing frame publishes (same contract as select
513
+ }
514
+
515
+ // The established programmatic-selection contract is a collapsed
516
+ // caret at text.len when no source/retained selection exists.
517
+ // Preserve an existing selection, then reveal its focus endpoint
518
+ // inside the editor after the outer ancestor reveal has made the
519
+ // editability/visibility gate truthful.
520
+ const caret_initialized = try self.views[view_index].ensureCanvasWidgetFocusedTextCaret();
521
+ var inner_scroll_changed = false;
522
+ if (self.views[view_index].canEditCanvasWidgetText(target.id)) {
523
+ if (self.views[view_index].canvasWidgetNodeIndexById(target.id)) |node_index| {
524
+ const before = self.views[view_index].widget_layout_nodes[node_index].widget;
525
+ self.views[view_index].scrollCanvasTextInputCaretIntoView(node_index);
526
+ const after = self.views[view_index].widget_layout_nodes[node_index].widget;
527
+ inner_scroll_changed = before.value != after.value or before.value_x != after.value_x;
528
+ }
529
+ }
530
+ if (inner_scroll_changed) {
531
+ try self.views[view_index].refreshCanvasWidgetSemantics();
532
+ if (!caret_initialized) self.views[view_index].widget_revision += 1;
533
+ }
534
+
535
+ if (focus_changed or caret_initialized or inner_scroll_changed or reveal.scroll_dirty != null) {
536
+ // A focus/reveal change repaints; record the automation input
537
+ // so the completing frame publishes (same contract as select
506
538
  // and text edits). Callers that dispatch a follow-up input
507
539
  // event simply overwrite this with their own timestamp.
508
540
  self.views[view_index].recordGpuSurfaceInputTimestamp(automationInputTimestampNs());
541
+ }
542
+ if (focus_changed) {
509
543
  try CanvasWidgetEventMethods().invalidateForCanvasWidgetRenderStateChange(self, view_index, previous_state, self.views[view_index].canvasWidgetRenderState());
544
+ } else if (caret_initialized or inner_scroll_changed) {
545
+ if (self.views[view_index].canvasWidgetNodeIndexById(target.id)) |node_index| {
546
+ if (self.views[view_index].canvasWidgetDirtyBounds(node_index, self.views[view_index].widget_layout_nodes[node_index].frame)) |dirty| {
547
+ try CanvasWidgetEventMethods().invalidateForCanvasWidgetDirty(self, view_index, dirty);
548
+ }
549
+ }
550
+ }
551
+ if (reveal.scroll_dirty != null) {
552
+ _ = try CanvasWidgetDisplayMethods().refreshCanvasWidgetDisplayListIfOwned(self, view_index);
510
553
  }
511
- _ = try self.views[view_index].ensureCanvasWidgetFocusedTextCaret();
512
554
  }
513
555
 
514
556
  pub fn dispatchAutomationWidgetKey(self: *Runtime, app: runtime_api.App(Runtime), view_index: usize, id: canvas.ObjectId, key: []const u8) anyerror!void {
@@ -244,8 +244,10 @@ pub fn RuntimeBuiltinBridge(comptime Runtime: type) type {
244
244
  const title = jsonStringField(payload, "title", &storage) orelse "";
245
245
  const width = jsonNumberField(payload, "width") orelse 720;
246
246
  const height = jsonNumberField(payload, "height") orelse 480;
247
- const x = jsonNumberField(payload, "x") orelse 0;
248
- const y = jsonNumberField(payload, "y") orelse 0;
247
+ const requested_x = jsonNumberField(payload, "x");
248
+ const requested_y = jsonNumberField(payload, "y");
249
+ const x = requested_x orelse 0;
250
+ const y = requested_y orelse 0;
249
251
  const source = if (jsonStringField(payload, "url", &storage)) |url| platform.WebViewSource.url(url) else null;
250
252
  const titlebar = if (jsonStringField(payload, "titlebar", &storage)) |value|
251
253
  windowTitlebarStyleFromString(value) orelse return error.InvalidWindowOptions
@@ -256,6 +258,7 @@ pub fn RuntimeBuiltinBridge(comptime Runtime: type) type {
256
258
  .title = title,
257
259
  .default_frame = geometry.RectF.init(x, y, width, height),
258
260
  .restore_state = jsonBoolField(payload, "restoreState") orelse true,
261
+ .initial_placement = if (requested_x != null or requested_y != null) .explicit else .default,
259
262
  .titlebar = titlebar,
260
263
  .transparent = jsonBoolField(payload, "transparent") orelse false,
261
264
  .always_on_top = jsonBoolField(payload, "alwaysOnTop") orelse false,