@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
@@ -1490,6 +1490,175 @@ test "horizontal scroll views draw the bottom-edge scrollbar and two-axis region
1490
1490
  try std.testing.expect(sheet_list.findCommandById(widgetPartId(1, 5)) != null);
1491
1491
  }
1492
1492
 
1493
+ test "modal surfaces resolve against root bounds through nested layout" {
1494
+ const modal_children = [_]Widget{
1495
+ .{ .id = 3, .kind = .dialog, .frame = geometry.RectF.init(7, 9, 240, 120) },
1496
+ .{ .id = 4, .kind = .drawer, .frame = geometry.RectF.init(11, 13, 180, 100) },
1497
+ .{ .id = 5, .kind = .sheet, .frame = geometry.RectF.init(17, 19, 160, 80) },
1498
+ };
1499
+ const nested = Widget{
1500
+ .id = 2,
1501
+ .kind = .stack,
1502
+ .frame = geometry.RectF.init(30, 40, 200, 150),
1503
+ .layout = .{ .padding = .{ .top = 12, .right = 12, .bottom = 12, .left = 12 } },
1504
+ .children = &modal_children,
1505
+ };
1506
+ const root = Widget{ .id = 1, .kind = .stack, .children = &.{nested} };
1507
+ const root_bounds = geometry.RectF.init(10, 20, 600, 400);
1508
+ var nodes: [5]WidgetLayoutNode = undefined;
1509
+ const layout = try layoutWidgetTree(root, root_bounds, &nodes);
1510
+
1511
+ // The nested container's frame, padding, and child offsets have no say
1512
+ // in modal placement: all three use the root bounds.
1513
+ try expectLayoutFrame(layout, 3, geometry.RectF.init(190, 160, 240, 120));
1514
+ try expectLayoutFrame(layout, 4, geometry.RectF.init(10, 320, 600, 100));
1515
+ try expectLayoutFrame(layout, 5, geometry.RectF.init(450, 20, 160, 400));
1516
+
1517
+ // The dialog's own scrim names the same root geometry its placement
1518
+ // used, even though the surface was declared inside the padded stack.
1519
+ var commands: [64]CanvasCommand = undefined;
1520
+ var builder = Builder.init(&commands);
1521
+ try layout.emitDisplayList(&builder, .{});
1522
+ switch (builder.displayList().findCommandById(widgetPartId(3, 14)).?.command) {
1523
+ .fill_rect => |fill| try expectRect(root_bounds, fill.rect),
1524
+ else => return error.TestUnexpectedResult,
1525
+ }
1526
+ }
1527
+
1528
+ test "root-relative modals consume neither flow extent nor grid cells" {
1529
+ const first = Widget{ .id = 2, .kind = .button, .frame = geometry.RectF.init(0, 0, 80, 20), .text = "First" };
1530
+ const dialog = Widget{ .id = 3, .kind = .dialog, .frame = geometry.RectF.init(0, 0, 200, 100) };
1531
+ const second = Widget{ .id = 4, .kind = .button, .frame = geometry.RectF.init(0, 0, 80, 20), .text = "Second" };
1532
+
1533
+ const column = Widget{
1534
+ .id = 1,
1535
+ .kind = .column,
1536
+ .layout = .{ .gap = 5 },
1537
+ .children = &.{ first, dialog, second },
1538
+ };
1539
+ const column_without_modal = Widget{
1540
+ .id = 1,
1541
+ .kind = .column,
1542
+ .layout = .{ .gap = 5 },
1543
+ .children = &.{ first, second },
1544
+ };
1545
+ try std.testing.expectEqualDeep(intrinsicWidgetSize(column_without_modal, .{}), intrinsicWidgetSize(column, .{}));
1546
+
1547
+ const bounds = geometry.RectF.init(0, 0, 400, 200);
1548
+ var column_nodes: [4]WidgetLayoutNode = undefined;
1549
+ const column_layout = try layoutWidgetTree(column, bounds, &column_nodes);
1550
+ try expectLayoutFrame(column_layout, 2, geometry.RectF.init(0, 0, 80, 20));
1551
+ try expectLayoutFrame(column_layout, 4, geometry.RectF.init(0, 25, 80, 20));
1552
+ try expectLayoutFrame(column_layout, 3, geometry.RectF.init(100, 50, 200, 100));
1553
+
1554
+ const grid = Widget{
1555
+ .id = 1,
1556
+ .kind = .grid,
1557
+ .layout = .{ .columns = 2 },
1558
+ .children = &.{ first, dialog, second },
1559
+ };
1560
+ var grid_nodes: [4]WidgetLayoutNode = undefined;
1561
+ const grid_layout = try layoutWidgetTree(grid, bounds, &grid_nodes);
1562
+ try expectLayoutFrame(grid_layout, 2, geometry.RectF.init(0, 0, 80, 20));
1563
+ try expectLayoutFrame(grid_layout, 4, geometry.RectF.init(200, 0, 80, 20));
1564
+ try expectLayoutFrame(grid_layout, 3, geometry.RectF.init(100, 50, 200, 100));
1565
+ }
1566
+
1567
+ test "a modal layout root retains viewport bounds for scrims and anchored children" {
1568
+ const menu = Widget{
1569
+ .id = 2,
1570
+ .kind = .dropdown_menu,
1571
+ .frame = geometry.RectF.init(0, 0, 120, 100),
1572
+ .layout = .{ .anchor = .{} },
1573
+ };
1574
+ const dialog = Widget{
1575
+ .id = 1,
1576
+ .kind = .dialog,
1577
+ .frame = geometry.RectF.init(0, 0, 240, 120),
1578
+ .children = &.{menu},
1579
+ };
1580
+ const viewport = geometry.RectF.init(10, 20, 600, 400);
1581
+ var nodes: [3]WidgetLayoutNode = undefined;
1582
+ const layout = try layoutWidgetTree(dialog, viewport, &nodes);
1583
+
1584
+ const dialog_frame = layout.findById(1).?.frame;
1585
+ try expectRect(geometry.RectF.init(190, 160, 240, 120), dialog_frame);
1586
+ try expectRect(viewport, canvas.widgetLayoutRootBounds(layout).?);
1587
+ // The menu clamps against the viewport, not the smaller dialog root.
1588
+ const menu_frame = layout.findById(2).?.frame;
1589
+ try std.testing.expectEqual(dialog_frame.maxY() + 4, menu_frame.y);
1590
+ try std.testing.expectEqual(@as(f32, 100), menu_frame.height);
1591
+
1592
+ var commands: [32]CanvasCommand = undefined;
1593
+ var builder = Builder.init(&commands);
1594
+ try layout.emitDisplayList(&builder, .{});
1595
+ switch (builder.displayList().findCommandById(widgetPartId(1, 14)).?.command) {
1596
+ .fill_rect => |fill| try expectRect(viewport, fill.rect),
1597
+ else => return error.TestUnexpectedResult,
1598
+ }
1599
+
1600
+ // A viewport may resize around the same center, leaving the dialog's
1601
+ // own frame unchanged. The separate root bounds still make that a full
1602
+ // scrim invalidation.
1603
+ var resized_nodes: [3]WidgetLayoutNode = undefined;
1604
+ const resized_viewport = geometry.RectF.init(-40, 20, 700, 400);
1605
+ const resized = try layoutWidgetTree(dialog, resized_viewport, &resized_nodes);
1606
+ try expectRect(dialog_frame, resized.findById(1).?.frame);
1607
+ var invalidations: [3]canvas.WidgetInvalidation = undefined;
1608
+ const changes = try layout.diff(resized, &invalidations);
1609
+ try std.testing.expectEqual(@as(usize, 1), changes.len);
1610
+ try std.testing.expect(changes[0].layout_dirty);
1611
+ try expectRect(geometry.RectF.unionWith(viewport, resized_viewport), changes[0].dirty_bounds.?);
1612
+ }
1613
+
1614
+ test "modal nested in a scroll viewport paints and routes at window level" {
1615
+ const panel_children = [_]Widget{.{
1616
+ .id = 4,
1617
+ .kind = .dialog,
1618
+ .frame = geometry.RectF.init(0, 0, 200, 100),
1619
+ }};
1620
+ const scroll_children = [_]Widget{.{
1621
+ .id = 3,
1622
+ .kind = .panel,
1623
+ .frame = geometry.RectF.init(0, 0, 120, 200),
1624
+ .children = &panel_children,
1625
+ }};
1626
+ const root_children = [_]Widget{.{
1627
+ .id = 2,
1628
+ .kind = .scroll_view,
1629
+ .frame = geometry.RectF.init(0, 0, 120, 80),
1630
+ .children = &scroll_children,
1631
+ }};
1632
+ const root = Widget{ .id = 1, .kind = .stack, .children = &root_children };
1633
+ var nodes: [4]WidgetLayoutNode = undefined;
1634
+ const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 400, 300), &nodes);
1635
+ try expectLayoutFrame(layout, 4, geometry.RectF.init(100, 100, 200, 100));
1636
+
1637
+ // This point is inside the dialog but below the scroll viewport. The
1638
+ // modal's window-level hit pass must still win.
1639
+ const hit = layout.hitTest(geometry.PointF.init(150, 120)) orelse return error.TestUnexpectedResult;
1640
+ try std.testing.expectEqual(@as(ObjectId, 4), hit.id);
1641
+
1642
+ // The modal chrome is emitted after the scroll viewport's clip closes.
1643
+ var commands: [64]CanvasCommand = undefined;
1644
+ var builder = Builder.init(&commands);
1645
+ try layout.emitDisplayList(&builder, .{});
1646
+ var clip_depth: usize = 0;
1647
+ var saw_dialog_chrome = false;
1648
+ for (builder.displayList().commands) |command| {
1649
+ switch (command) {
1650
+ .push_clip => clip_depth += 1,
1651
+ .pop_clip => clip_depth -= 1,
1652
+ else => {},
1653
+ }
1654
+ if (command.objectId() == widgetPartId(4, 1)) {
1655
+ saw_dialog_chrome = true;
1656
+ try std.testing.expectEqual(@as(usize, 0), clip_depth);
1657
+ }
1658
+ }
1659
+ try std.testing.expect(saw_dialog_chrome);
1660
+ }
1661
+
1493
1662
  test "a both-axes region whose content only overflows sideways reports horizontal scroll semantics" {
1494
1663
  // 500-wide content in a 200 x 100 both-axes viewport: no vertical
1495
1664
  // range, real horizontal range. The assistive node must read the
@@ -257,6 +257,12 @@ pub fn widgetControlInset(widget: Widget, tokens: DesignTokens, base: f32) f32 {
257
257
  return densityValue(tokens, widgetSizedTokenValue(widget, tokens, base));
258
258
  }
259
259
 
260
+ /// Alert chrome/content inset: one token-backed metric for rendering,
261
+ /// effective default layout padding, and intrinsic/wrapped measurement.
262
+ pub fn widgetAlertInset(widget: Widget, tokens: DesignTokens) f32 {
263
+ return widgetControlInset(widget, tokens, tokens.spacing.lg);
264
+ }
265
+
260
266
  /// Tab-trigger metrics split at the register boundary. House pill tabs
261
267
  /// keep using the shared label/control ladder exactly as before; the
262
268
  /// underline register owns the taller, label-hugging geometry measured
@@ -293,14 +299,7 @@ pub fn widgetSizedDensityValue(widget: Widget, tokens: DesignTokens, value: f32)
293
299
  }
294
300
 
295
301
  pub fn widgetSizedTokenValue(widget: Widget, tokens: DesignTokens, value: f32) f32 {
296
- const step = tokens.metrics.size_inset_step;
297
- return switch (widget.size) {
298
- .sm => @max(0, value - step),
299
- // heading/display step type, not chrome: control metrics stay at
300
- // the default step.
301
- .default, .icon, .heading, .display => value,
302
- .lg => value + step,
303
- };
302
+ return widget_model.widgetSizeSteppedValue(widget.size, value, tokens.metrics.size_inset_step);
304
303
  }
305
304
 
306
305
  pub fn widgetSizeScale(widget: Widget) f32 {
@@ -105,6 +105,7 @@ const badgeBackgroundColor = widget_render_style.badgeBackgroundColor;
105
105
  const badgeBorderColor = widget_render_style.badgeBorderColor;
106
106
  const badgeTextColor = widget_render_style.badgeTextColor;
107
107
  const badgeStrokeWidth = widget_render_style.badgeStrokeWidth;
108
+ const listItemFillColor = widget_render_style.listItemFillColor;
108
109
  pub const buttonStrokeWidth = widget_render_style.buttonStrokeWidth;
109
110
  pub const transparentColor = widget_render_style.transparentColor;
110
111
  pub const checkboxWidgetBoxRect = widget_render_controls.checkboxWidgetBoxRect;
@@ -165,7 +166,7 @@ pub fn emitWidgetLayoutWithState(builder: *Builder, layout: anytype, tokens: Des
165
166
  scrim_viewport = widgetLayoutRootBounds(layout);
166
167
  try emitWidgetLayoutChildren(builder, layout, null, tokens, state);
167
168
  try emitWidgetLayoutClipEscapingMotions(builder, layout, tokens, state);
168
- try emitWidgetLayoutAnchored(builder, layout, tokens, state);
169
+ try emitWidgetLayoutWindowSurfaces(builder, layout, tokens, state);
169
170
  try emitWidgetLayoutChartHoverDetails(builder, layout, tokens, state);
170
171
  try emitWidgetLayoutDragPreview(builder, layout, tokens, state);
171
172
  }
@@ -177,7 +178,7 @@ pub fn emitWidgetLayoutWithState(builder: *Builder, layout: anytype, tokens: Des
177
178
  /// ordinary tree walk and retain their scroll clipping.
178
179
  fn emitWidgetLayoutClipEscapingMotions(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
179
180
  for (layout.nodes, 0..) |node, index| {
180
- if (widget_tree.widgetIsAnchored(node.widget)) continue;
181
+ if (widget_tree.widgetEscapesAncestorClips(node.widget)) continue;
181
182
  if (!state.layoutMotionEscapesAncestorClips(node.widget.id)) continue;
182
183
  if (widget_tree.isWidgetHiddenInAncestors(layout, index)) continue;
183
184
  if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) continue;
@@ -245,9 +246,14 @@ fn widgetLayoutDragPreviewTranslation(
245
246
  );
246
247
  }
247
248
 
248
- /// The union of the layout's root-node frames: the whole laid-out
249
- /// surface, which is what a modal scrim covers.
249
+ /// The union of the layout's root bounds: the whole viewport that produced
250
+ /// the roots, which is what a modal scrim covers. Layout-produced roots
251
+ /// retain those bounds separately from their resolved frame so a root
252
+ /// dialog can be centered without shrinking its own scrim to the dialog.
250
253
  pub fn widgetLayoutRootBounds(layout: anytype) ?geometry.RectF {
254
+ if (@hasField(@TypeOf(layout), "root_bounds")) {
255
+ if (layout.root_bounds) |root_bounds| return root_bounds.normalized();
256
+ }
251
257
  var bounds: ?geometry.RectF = null;
252
258
  for (layout.nodes) |node| {
253
259
  if (node.parent_index != null) continue;
@@ -257,9 +263,9 @@ pub fn widgetLayoutRootBounds(layout: anytype) ?geometry.RectF {
257
263
  return bounds;
258
264
  }
259
265
 
260
- /// Accumulated transform active while `node_index` emits. Anchored surfaces
261
- /// are hoisted into the late top-level pass, so their original ancestors do
262
- /// not contribute transforms there.
266
+ /// Accumulated transform active while `node_index` emits. Window-level
267
+ /// surfaces are hoisted into the late top-level pass, so their original
268
+ /// ancestors do not contribute transforms there.
263
269
  fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine {
264
270
  if (node_index >= layout.nodes.len) return null;
265
271
  var indices: [widget_layout.max_widget_depth]usize = undefined;
@@ -269,7 +275,7 @@ fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine
269
275
  if (index >= layout.nodes.len or len >= indices.len) return null;
270
276
  indices[len] = index;
271
277
  len += 1;
272
- if (widget_tree.widgetIsAnchored(layout.nodes[index].widget)) break;
278
+ if (widget_tree.widgetEscapesAncestorClips(layout.nodes[index].widget)) break;
273
279
  current = layout.nodes[index].parent_index;
274
280
  }
275
281
 
@@ -304,7 +310,7 @@ fn widgetLayoutNodePresentationTransform(
304
310
  if (index >= layout.nodes.len or len >= indices.len) return null;
305
311
  indices[len] = index;
306
312
  len += 1;
307
- if (widget_tree.widgetIsAnchored(layout.nodes[index].widget)) break;
313
+ if (widget_tree.widgetEscapesAncestorClips(layout.nodes[index].widget)) break;
308
314
  current = layout.nodes[index].parent_index;
309
315
  }
310
316
 
@@ -324,11 +330,11 @@ fn widgetLayoutNodePresentationTransform(
324
330
  /// The transform stack a node inherits at its ordinary paint position. A
325
331
  /// drag preview is hoisted to the window-level late pass to escape clipping,
326
332
  /// so it must explicitly restore this stack before painting the source.
327
- /// Anchored nodes were already hoisted and therefore inherit no original
328
- /// ancestors there.
333
+ /// Window-level nodes were already hoisted and therefore inherit no
334
+ /// original ancestors there.
329
335
  fn widgetLayoutNodeAncestorEmissionTransform(layout: anytype, node_index: usize) ?Affine {
330
336
  if (node_index >= layout.nodes.len) return null;
331
- if (widget_tree.widgetIsAnchored(layout.nodes[node_index].widget)) return Affine.identity();
337
+ if (widget_tree.widgetEscapesAncestorClips(layout.nodes[node_index].widget)) return Affine.identity();
332
338
  const parent_index = layout.nodes[node_index].parent_index orelse return Affine.identity();
333
339
  return widgetLayoutNodeEmissionTransform(layout, parent_index);
334
340
  }
@@ -363,7 +369,7 @@ fn widgetLayoutNodeVisibleBounds(
363
369
  state.drag_preview_id.? == current_widget.id;
364
370
  // Every late window-level pass escapes clips ABOVE its lifted root,
365
371
  // but nested clips inside that subtree still constrain descendants.
366
- if (widget_tree.widgetIsAnchored(current_widget) or
372
+ if (widget_tree.widgetEscapesAncestorClips(current_widget) or
367
373
  is_drag_preview_root or
368
374
  has_layout_motion and state.layoutMotionEscapesAncestorClips(current_widget.id))
369
375
  {
@@ -388,15 +394,19 @@ fn widgetLayoutNodeVisibleBounds(
388
394
  return if (clipped.isEmpty()) null else clipped;
389
395
  }
390
396
 
391
- /// The late z-pass for anchored floating surfaces: they are skipped by
392
- /// the in-tree walk above and emitted here LAST, at the top level, so no
393
- /// ancestor scroll/clip region crops them (window-clipped, not
394
- /// parent-clipped) and they paint above everything in the tree. Node
395
- /// order is tree order, so a nested anchored surface (submenu) paints
396
- /// above the surface it hangs from. Ancestor hiding still applies.
397
- fn emitWidgetLayoutAnchored(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
398
- for (layout.nodes, 0..) |node, index| {
399
- if (!widget_tree.widgetIsAnchored(node.widget)) continue;
397
+ /// The late z-pass for window-level surfaces: anchored overlays and
398
+ /// root-relative modals are skipped by the in-tree walk and emitted here
399
+ /// LAST, so ancestor scroll/clip regions cannot crop them. Window-surface
400
+ /// layers order the lifted roots; equal layers retain tree order, so nested
401
+ /// floating surfaces preserve their structural z-order.
402
+ /// Ancestor hiding still applies.
403
+ fn emitWidgetLayoutWindowSurfaces(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
404
+ const surface_count = widget_tree.widgetLayoutWindowSurfaceCount(layout);
405
+ var emitted: usize = 0;
406
+ var previous: ?widget_tree.WidgetPaintOrder = null;
407
+ while (emitted < surface_count) : (emitted += 1) {
408
+ const index = widget_tree.nextWidgetLayoutWindowSurface(layout, tokens, previous) orelse return;
409
+ previous = widget_tree.widgetLayoutWindowSurfaceOrder(layout, index, tokens);
400
410
  if (widget_tree.isWidgetHiddenInAncestors(layout, index)) continue;
401
411
  // A floating surface anchored inside a concealed disclosure
402
412
  // subtree stays down with its anchor — concealed content is
@@ -438,7 +448,7 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
438
448
  try emitWidgetBackdropBlur(builder, paint_widget, tokens);
439
449
  switch (paint_widget.kind) {
440
450
  .stack, .row, .column => {
441
- try emitLayoutContainerBackground(builder, paint_widget);
451
+ try emitLayoutContainerBackground(builder, paint_widget, tokens);
442
452
  try emitWidgetClippedChildren(builder, paint_widget, tokens, depth);
443
453
  },
444
454
  .grid, .list, .breadcrumb, .pagination, .radio_group, .toggle_group, .split, .tree => try emitWidgetClippedChildren(builder, paint_widget, tokens, depth),
@@ -693,9 +703,9 @@ fn emitWidgetLayoutChildren(
693
703
  var previous: ?WidgetPaintOrder = null;
694
704
  while (emitted < child_count) : (emitted += 1) {
695
705
  const child_index = nextWidgetLayoutPaintChild(layout, parent_index, tokens, previous) orelse return;
696
- // Anchored floating children paint in the late z-pass
697
- // (`emitWidgetLayoutAnchored`), never in tree position.
698
- if (!widget_tree.widgetIsAnchored(layout.nodes[child_index].widget) and
706
+ // Window-level surfaces paint in the late z-pass
707
+ // (`emitWidgetLayoutWindowSurfaces`), never in tree position.
708
+ if (!widget_tree.widgetEscapesAncestorClips(layout.nodes[child_index].widget) and
699
709
  !state.layoutMotionEscapesAncestorClips(layout.nodes[child_index].widget.id))
700
710
  {
701
711
  const segment = if (group_index) |index|
@@ -778,7 +788,7 @@ fn emitWidgetLayoutNodeContent(
778
788
  const paint_widget = widgetWithFrame(widget, pixelSnapGeometryRect(tokens, widget.frame));
779
789
  try emitWidgetBackdropBlur(builder, paint_widget, tokens);
780
790
  switch (paint_widget.kind) {
781
- .stack, .row, .column => try emitLayoutContainerBackground(builder, paint_widget),
791
+ .stack, .row, .column => try emitLayoutContainerBackground(builder, paint_widget, tokens),
782
792
  .breadcrumb, .button_group, .pagination, .radio_group, .toggle_group, .split, .tree => {},
783
793
  .data_row => try emitDataRowWidgetWash(builder, paint_widget, tokens),
784
794
  .tabs => try widget_render_surfaces.emitTabsListWidgetChrome(builder, paint_widget, tokens),
@@ -930,12 +940,31 @@ fn emitWidgetLayoutNodeContent(
930
940
  try emitWidgetLayoutClippedChildren(builder, layout, node_index, tokens, state, paint_widget);
931
941
  }
932
942
 
933
- /// Flow and stacking containers have no implicit surface treatment, but
934
- /// an author background is real chrome: it fills the laid-out frame
935
- /// before any children, with the same optional radius accepted by the
936
- /// builder and markup grammar.
937
- fn emitLayoutContainerBackground(builder: *Builder, widget: Widget) Error!void {
938
- const background = widget.style.background orelse return;
943
+ /// Flow and stacking containers have no implicit surface treatment. An
944
+ /// actionable container, however, wears the same neutral hover/pressed
945
+ /// ladder as a list row over its full hit frame; an authored background is
946
+ /// its rest fill. Non-actionable containers paint only that authored fill.
947
+ fn emitLayoutContainerBackground(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
948
+ const actions = widget.semantics.actions;
949
+ const actionable = widget.id != 0 and !widget.state.disabled and
950
+ (actions.press or actions.toggle or actions.drag);
951
+ if (!actionable) {
952
+ const background = widget.style.background orelse return;
953
+ if (background.a <= 0) return;
954
+ try builder.fillRoundedRect(.{
955
+ .id = widgetPartId(widget.id, 1),
956
+ .rect = widget.frame,
957
+ .radius = Radius.all(nonNegative(widget.style.radius orelse 0)),
958
+ .fill = colorFill(background),
959
+ });
960
+ return;
961
+ }
962
+ // The common rest-state actionable container with no authored fill
963
+ // emits nothing. Avoid the token ladder on every structural row in a
964
+ // full rebuild; only live feedback or authored chrome needs it.
965
+ if (widget.style.background == null and !widget.state.selected and !widget.state.pressed and !widget_render_style.washHovered(widget)) return;
966
+ const background = listItemFillColor(widget, tokens, widget.state);
967
+ if (background.a <= 0) return;
939
968
  try builder.fillRoundedRect(.{
940
969
  .id = widgetPartId(widget.id, 1),
941
970
  .rect = widget.frame,
@@ -1582,7 +1611,7 @@ fn emitVisibleTextSpansWidget(
1582
1611
  if (run.text.len == 0) continue;
1583
1612
  const span = widget.spans[run.span_index];
1584
1613
  const is_link = span.link.len > 0;
1585
- const underline_ordinal: ?usize = if (span.underline or is_link) blk: {
1614
+ const underline_ordinal: ?usize = if (span.underline) blk: {
1586
1615
  const value = decoration_base +| decoration_ordinal;
1587
1616
  decoration_ordinal += 1;
1588
1617
  break :blk value;
@@ -3005,15 +3034,18 @@ fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Erro
3005
3034
  .radius = radius,
3006
3035
  .fill = colorFill(badgeBackgroundColor(widget, tokens, visual)),
3007
3036
  });
3008
- try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
3009
- .id = widgetPartId(widget.id, 2),
3010
- .rect = widget.frame,
3011
- .radius = radius,
3012
- .stroke = .{
3013
- .fill = widgetBorderFill(widget, badgeBorderColor(widget, tokens, visual)),
3014
- .width = badgeStrokeWidth(widget, tokens, visual),
3015
- },
3016
- }));
3037
+ const stroke_width = badgeStrokeWidth(widget, tokens, visual);
3038
+ if (stroke_width > 0) {
3039
+ try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
3040
+ .id = widgetPartId(widget.id, 2),
3041
+ .rect = widget.frame,
3042
+ .radius = radius,
3043
+ .stroke = .{
3044
+ .fill = colorFill(badgeBorderColor(widget, tokens, visual)),
3045
+ .width = stroke_width,
3046
+ },
3047
+ }));
3048
+ }
3017
3049
  const content_color = badgeTextColor(widget, tokens, visual);
3018
3050
  // Inline vector icon: icon-only badges center it (the stepper's
3019
3051
  // completed check, status chips); icon + text draws it before the
@@ -3200,7 +3232,7 @@ fn emitSkeletonWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) E
3200
3232
  /// edge to edge (the table register's row hover), square-cornered so
3201
3233
  /// adjacent rows tile. Rows at rest draw nothing.
3202
3234
  fn emitDataRowWidgetWash(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
3203
- const fill = widget_render_style.listItemFillColor(widget, tokens, widget.state);
3235
+ const fill = listItemFillColor(widget, tokens, widget.state);
3204
3236
  if (fill.a <= 0) return;
3205
3237
  try builder.fillRect(.{
3206
3238
  .id = widgetPartId(widget.id, 1),