@native-sdk/cli 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/build/app.zig +91 -2
  2. package/build.zig +756 -5
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +19 -1
  5. package/package.json +9 -9
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/rt/rt.zig +416 -9
  9. package/packages/core/sdk/core.ts +706 -5
  10. package/packages/core/sdk/events.ts +17 -8
  11. package/packages/core/src/checker.ts +305 -2
  12. package/packages/core/src/diagnostics.ts +12 -0
  13. package/packages/core/src/emitter.ts +3187 -264
  14. package/packages/core/src/typed_ast.ts +51 -4
  15. package/packages/core/src/types.ts +34 -1
  16. package/skill-data/native-ui/SKILL.md +42 -4
  17. package/skill-data/ts-core/SKILL.md +13 -3
  18. package/src/app_runner/root.zig +112 -10
  19. package/src/app_runner/ts_core_main.zig +4 -0
  20. package/src/automation/layout_fingerprint.zig +160 -0
  21. package/src/automation/protocol.zig +82 -33
  22. package/src/automation/root.zig +1 -0
  23. package/src/automation/server.zig +1 -1
  24. package/src/automation/snapshot.zig +68 -9
  25. package/src/automation/watcher.zig +1 -1
  26. package/src/embed/host.zig +5 -0
  27. package/src/embed/tests.zig +119 -1
  28. package/src/embed/ui_host.zig +13 -0
  29. package/src/platform/linux/gtk_host.c +639 -16
  30. package/src/platform/linux/gtk_host.h +25 -0
  31. package/src/platform/linux/root.zig +351 -7
  32. package/src/platform/macos/appkit_host.h +152 -8
  33. package/src/platform/macos/appkit_host.m +1816 -100
  34. package/src/platform/macos/cef_host.mm +372 -11
  35. package/src/platform/macos/root.zig +379 -11
  36. package/src/platform/null_platform.zig +696 -9
  37. package/src/platform/null_platform_tests.zig +35 -0
  38. package/src/platform/root.zig +42 -0
  39. package/src/platform/types.zig +524 -18
  40. package/src/platform/windows/root.zig +432 -9
  41. package/src/platform/windows/webview2_host.cpp +482 -45
  42. package/src/primitives/app_manifest/comptime_scene.zig +5 -0
  43. package/src/primitives/app_manifest/root.zig +1 -0
  44. package/src/primitives/app_manifest/types.zig +32 -0
  45. package/src/primitives/app_manifest/validation.zig +18 -0
  46. package/src/primitives/canvas/a11y_audit.zig +33 -11
  47. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  48. package/src/primitives/canvas/drawing.zig +25 -0
  49. package/src/primitives/canvas/equality.zig +8 -0
  50. package/src/primitives/canvas/events.zig +103 -16
  51. package/src/primitives/canvas/frame.zig +125 -1
  52. package/src/primitives/canvas/layout_audit.zig +22 -5
  53. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  54. package/src/primitives/canvas/render_tests.zig +13 -10
  55. package/src/primitives/canvas/root.zig +48 -0
  56. package/src/primitives/canvas/terminal_box.zig +471 -0
  57. package/src/primitives/canvas/terminal_grid.zig +978 -0
  58. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  59. package/src/primitives/canvas/test_support.zig +1 -0
  60. package/src/primitives/canvas/tests.zig +2 -0
  61. package/src/primitives/canvas/text_tests.zig +39 -4
  62. package/src/primitives/canvas/tokens.zig +115 -12
  63. package/src/primitives/canvas/ui.zig +535 -12
  64. package/src/primitives/canvas/ui_markup.zig +253 -36
  65. package/src/primitives/canvas/ui_markup_binary.zig +4 -1
  66. package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
  67. package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
  68. package/src/primitives/canvas/ui_markup_contract.zig +89 -6
  69. package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
  70. package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
  71. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  72. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  73. package/src/primitives/canvas/ui_markup_tests.zig +178 -9
  74. package/src/primitives/canvas/ui_markup_view.zig +220 -11
  75. package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
  76. package/src/primitives/canvas/ui_schema.zig +110 -17
  77. package/src/primitives/canvas/ui_schema_tests.zig +18 -10
  78. package/src/primitives/canvas/ui_tests.zig +141 -9
  79. package/src/primitives/canvas/widget_access.zig +28 -2
  80. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  81. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  82. package/src/primitives/canvas/widget_layout.zig +59 -11
  83. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  84. package/src/primitives/canvas/widget_render.zig +272 -18
  85. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  86. package/src/primitives/canvas/widget_routing.zig +59 -7
  87. package/src/primitives/canvas/widget_runtime.zig +23 -0
  88. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  89. package/src/primitives/canvas/widget_semantics.zig +119 -11
  90. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  91. package/src/primitives/canvas/widget_tree.zig +17 -0
  92. package/src/primitives/canvas/widgets.zig +132 -0
  93. package/src/root.zig +23 -0
  94. package/src/runtime/api.zig +76 -5
  95. package/src/runtime/automation_commands.zig +20 -1
  96. package/src/runtime/automation_snapshot.zig +25 -1
  97. package/src/runtime/automation_widget_dispatch.zig +73 -8
  98. package/src/runtime/bridge_payload.zig +8 -0
  99. package/src/runtime/bridge_responses.zig +5 -0
  100. package/src/runtime/builtin_bridge.zig +9 -4
  101. package/src/runtime/canvas_font_tests.zig +439 -2
  102. package/src/runtime/canvas_fonts.zig +61 -6
  103. package/src/runtime/canvas_frame.zig +62 -7
  104. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  105. package/src/runtime/canvas_frame_helpers.zig +190 -1
  106. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  107. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  108. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  109. package/src/runtime/canvas_image_tests.zig +195 -0
  110. package/src/runtime/canvas_images.zig +45 -12
  111. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  112. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  113. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  114. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  115. package/src/runtime/canvas_widget_display.zig +1 -1
  116. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  117. package/src/runtime/canvas_widget_events.zig +240 -24
  118. package/src/runtime/canvas_widget_runtime.zig +213 -29
  119. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  120. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  121. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  122. package/src/runtime/canvas_widget_state.zig +6 -0
  123. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  124. package/src/runtime/core.zig +131 -13
  125. package/src/runtime/effects.zig +8136 -180
  126. package/src/runtime/effects_channel_tests.zig +3519 -0
  127. package/src/runtime/effects_fetch_tests.zig +89 -1
  128. package/src/runtime/effects_file_tests.zig +41 -1
  129. package/src/runtime/effects_image_tests.zig +1304 -0
  130. package/src/runtime/effects_pty_tests.zig +1362 -0
  131. package/src/runtime/effects_tests.zig +167 -9
  132. package/src/runtime/effects_video_tests.zig +3609 -0
  133. package/src/runtime/flow.zig +42 -4
  134. package/src/runtime/gpu_surface_events.zig +473 -13
  135. package/src/runtime/media_surface.zig +116 -11
  136. package/src/runtime/media_surface_tests.zig +61 -0
  137. package/src/runtime/pty.zig +1252 -0
  138. package/src/runtime/pty_windows.zig +1780 -0
  139. package/src/runtime/root.zig +36 -0
  140. package/src/runtime/runtime_event_tests.zig +20 -1
  141. package/src/runtime/session_blobs.zig +689 -0
  142. package/src/runtime/session_journal.zig +432 -62
  143. package/src/runtime/session_record.zig +43 -2
  144. package/src/runtime/session_replay.zig +556 -20
  145. package/src/runtime/session_tests.zig +2087 -1
  146. package/src/runtime/shell_layout.zig +7 -0
  147. package/src/runtime/terminal_session.zig +1569 -0
  148. package/src/runtime/terminal_session_tests.zig +450 -0
  149. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  150. package/src/runtime/terminal_vt_stub.zig +13 -0
  151. package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
  152. package/src/runtime/testdata/fonts/OFL.txt +93 -0
  153. package/src/runtime/tests.zig +8 -0
  154. package/src/runtime/ts_core_host.zig +1320 -45
  155. package/src/runtime/ts_core_host_tests.zig +1100 -1
  156. package/src/runtime/ts_ui_app.zig +23 -5
  157. package/src/runtime/ui_app.zig +2444 -69
  158. package/src/runtime/ui_app_tests.zig +3171 -744
  159. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  160. package/src/runtime/ui_app_window_tests.zig +736 -0
  161. package/src/runtime/view.zig +190 -2
  162. package/src/runtime/view_widget_scroll.zig +218 -68
  163. package/src/runtime/view_widget_text.zig +11 -2
  164. package/src/runtime/view_widget_tree.zig +111 -3
  165. package/src/runtime/window_command_bridge_tests.zig +117 -0
  166. package/src/runtime/window_storage.zig +77 -2
  167. package/src/runtime/window_view_runtime.zig +34 -2
  168. package/src/runtime/window_views.zig +62 -1
  169. package/src/terminal_session_tests_root.zig +15 -0
  170. package/src/tooling/manifest.zig +75 -0
  171. package/src/tooling/raw_manifest.zig +2 -0
  172. package/src/tooling/templates.zig +244 -8
@@ -675,6 +675,42 @@ test "overscroll on scroll stamps the region's edge behavior" {
675
675
  try testing.expectEqual(canvas.ScrollOverscroll.none, canvas.widgetScrollPhysics(tree.root.children[1], physics).overscroll);
676
676
  }
677
677
 
678
+ test "axis and value-x stamp the region's scroll axes and horizontal offset" {
679
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
680
+ defer arena_state.deinit();
681
+ const arena = arena_state.allocator();
682
+ const model = Model{};
683
+
684
+ var view = try InboxMarkup.init(arena, "<column>\n <scroll axis=\"horizontal\" value-x=\"120\">\n <row><text>a</text></row>\n </scroll>\n <scroll axis=\"both\">\n <column><text>b</text></column>\n </scroll>\n <scroll>\n <column><text>c</text></column>\n </scroll>\n</column>");
685
+ var ui = InboxUi.init(arena);
686
+ const tree = try ui.finalize(try view.build(&ui, &model));
687
+ const shelf = tree.root.children[0];
688
+ try testing.expectEqual(canvas.WidgetKind.scroll_view, shelf.kind);
689
+ try testing.expectEqual(canvas.ScrollAxes.horizontal, shelf.scroll_axes);
690
+ try testing.expectEqual(@as(f32, 120), shelf.value_x);
691
+ try testing.expect(canvas.widgetScrollsAxis(shelf, .horizontal));
692
+ try testing.expect(!canvas.widgetScrollsAxis(shelf, .vertical));
693
+ const freeform = tree.root.children[1];
694
+ try testing.expectEqual(canvas.ScrollAxes.both, freeform.scroll_axes);
695
+ try testing.expect(canvas.widgetScrollsAxis(freeform, .horizontal));
696
+ try testing.expect(canvas.widgetScrollsAxis(freeform, .vertical));
697
+ // The undeclared region keeps the pre-axis default: vertical only.
698
+ const classic = tree.root.children[2];
699
+ try testing.expectEqual(canvas.ScrollAxes.vertical, classic.scroll_axes);
700
+ try testing.expect(!canvas.widgetScrollsAxis(classic, .horizontal));
701
+ try testing.expect(canvas.widgetScrollsAxis(classic, .vertical));
702
+ }
703
+
704
+ test "axis value vocabulary mirrors the live ScrollAxes enum" {
705
+ // The validator's std-only mirror of the enum's member names; a new
706
+ // member cannot ship without its markup spelling.
707
+ const fields = @typeInfo(canvas.ScrollAxes).@"enum".fields;
708
+ try testing.expectEqual(fields.len, canvas.ui_markup.axis_value_names.len);
709
+ inline for (fields, 0..) |field, index| {
710
+ try testing.expectEqualStrings(field.name, canvas.ui_markup.axis_value_names[index]);
711
+ }
712
+ }
713
+
678
714
  test "overscroll value vocabulary mirrors the live WidgetOverscroll enum" {
679
715
  // The validator's std-only mirror of the enum's member names; a new
680
716
  // member cannot ship without its markup spelling.
@@ -1050,6 +1086,51 @@ pub const picker_markup_source =
1050
1086
  \\</column>
1051
1087
  ;
1052
1088
 
1089
+ /// Shared source for the hover-pair parity tests (interpreter here,
1090
+ /// compiled engine in ui_markup_compiled_tests.zig): nested hover
1091
+ /// listeners on LAYOUT containers — legal everywhere like the press
1092
+ /// family, and the binding is what makes them hover-hittable.
1093
+ pub const hover_markup_source =
1094
+ \\<column gap="8">
1095
+ \\ <panel padding="8" on-hover-enter="add" on-hover-leave="toggle:{open_count}">
1096
+ \\ <row gap="4" on-hover-enter="add">
1097
+ \\ <text>Peek target</text>
1098
+ \\ </row>
1099
+ \\ </panel>
1100
+ \\</column>
1101
+ ;
1102
+
1103
+ test "markup binds the hover pair and makes listeners hover-hittable, never pressable" {
1104
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
1105
+ defer arena_state.deinit();
1106
+ const arena = arena_state.allocator();
1107
+ const model = Model{};
1108
+
1109
+ var view = try InboxMarkup.init(arena, hover_markup_source);
1110
+ var ui = InboxUi.init(arena);
1111
+ const tree = try ui.finalize(try view.build(&ui, &model));
1112
+
1113
+ const panel = tree.root.children[0];
1114
+ const row = panel.children[0];
1115
+ try testing.expect(panel.hover_msgs);
1116
+ try testing.expect(row.hover_msgs);
1117
+ // Hover listening never implies pressability OR interactive
1118
+ // hit-testing: no press action, no press claim, invisible to the
1119
+ // wash/press hit test — only the hover-containment policy sees it.
1120
+ try testing.expect(!row.semantics.actions.press);
1121
+ try testing.expect(!canvas.widgetClaimsPress(row));
1122
+ try testing.expect(!canvas.widgetIsHitTarget(row));
1123
+ try testing.expect(canvas.widgetIsHoverMsgHitTarget(row));
1124
+
1125
+ // Both edges resolve through the handler table; an element binding
1126
+ // only enter has no leave Msg, and plain children listen for nothing.
1127
+ try testing.expectEqual(Msg.add, tree.msgFor(panel.id, .hover_enter).?);
1128
+ try testing.expectEqual(@as(u32, 0), tree.msgFor(panel.id, .hover_leave).?.toggle);
1129
+ try testing.expectEqual(Msg.add, tree.msgFor(row.id, .hover_enter).?);
1130
+ try testing.expect(tree.msgFor(row.id, .hover_leave) == null);
1131
+ try testing.expect(!row.children[0].hover_msgs);
1132
+ }
1133
+
1053
1134
  test "markup anchors dropdown-menus and binds dismiss and hold handlers" {
1054
1135
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
1055
1136
  defer arena_state.deinit();
@@ -1322,10 +1403,10 @@ test "the registry's a11y name classes match the engine's control predicates" {
1322
1403
  try testing.expect(canvas.widgetKindClaimsPress(kind));
1323
1404
  }
1324
1405
  // Image-class elements are announced under the image role:
1325
- // avatar and the media surface (pictorial content whose missing
1326
- // label degrades but never blocks).
1406
+ // avatar, the media surface, and the image leaf (pictorial
1407
+ // content whose missing label degrades but never blocks).
1327
1408
  if (entry.a11y_name == .image) {
1328
- try testing.expect(kind == .avatar or kind == .media_surface);
1409
+ try testing.expect(kind == .avatar or kind == .media_surface or kind == .image);
1329
1410
  }
1330
1411
  }
1331
1412
  }
@@ -1408,7 +1489,7 @@ test "the registry's takes-children predicate matches the interpreter's takes-ch
1408
1489
  /// lowered through `Ui.inputGroup`), so no plain element maps to the
1409
1490
  /// kind here — like chart, the bespoke builder is the channel.
1410
1491
  const markup_excluded_widget_kinds = [_]canvas.WidgetKind{
1411
- .image, .icon_button, .data_grid, .popover, .menu_surface, .segmented_control, .chart, .split_divider, .input_group,
1492
+ .icon_button, .data_grid, .popover, .menu_surface, .segmented_control, .chart, .split_divider, .input_group,
1412
1493
  };
1413
1494
 
1414
1495
  fn kindExpressible(kind: canvas.WidgetKind) bool {
@@ -2457,23 +2538,23 @@ test "avatar image misuse fails the build with the teaching messages" {
2457
2538
  .{
2458
2539
  // A literal id is not model data.
2459
2540
  .source = "<row>\n <avatar image=\"7\">CT</avatar>\n</row>",
2460
- .message = canvas.ui_markup.avatar_image_message,
2541
+ .message = canvas.ui_markup.image_binding_message,
2461
2542
  },
2462
2543
  .{
2463
2544
  // The binding must produce an integer ImageId (user_name is text).
2464
2545
  .source = "<row>\n <avatar image=\"{user_name}\">CT</avatar>\n</row>",
2465
- .message = canvas.ui_markup.avatar_image_message,
2546
+ .message = canvas.ui_markup.image_binding_message,
2466
2547
  },
2467
2548
  .{
2468
2549
  // A negative integer can never be a u64 ImageId: the
2469
2550
  // teaching failure, not an @intCast trap.
2470
2551
  .source = avatar_negative_markup_source,
2471
- .message = canvas.ui_markup.avatar_image_message,
2552
+ .message = canvas.ui_markup.image_binding_message,
2472
2553
  },
2473
2554
  .{
2474
2555
  // Scoped to avatar: the other image elements stay Zig views.
2475
2556
  .source = "<row>\n <badge image=\"{user_image}\">3</badge>\n</row>",
2476
- .message = canvas.ui_markup.avatar_image_element_message,
2557
+ .message = canvas.ui_markup.image_binding_element_message,
2477
2558
  },
2478
2559
  };
2479
2560
  for (cases) |case| {
@@ -2537,6 +2618,428 @@ test "the media-surface surface binding resolves the model id; negatives fail th
2537
2618
  try testing.expect(negative_view.diagnostic.line > 0);
2538
2619
  }
2539
2620
 
2621
+ // ------------------------------------------------ image leaf id binding
2622
+
2623
+ pub const ImageLeafMsg = union(enum) { refresh };
2624
+
2625
+ pub const ImageLeafModel = struct {
2626
+ /// Runtime-registered ImageId kept in the model (0 = no image, the
2627
+ /// leaf draws nothing) — the id lands here from `Cmd.imageLoad`'s
2628
+ /// loaded result (or `fx.registerImageBytes` on the Zig tier).
2629
+ cover: canvas.ImageId = 0,
2630
+ /// A signed id field: bindings evaluate as i64, so a negative must
2631
+ /// reach the image seam as a value, never trap in the u64 cast.
2632
+ stale_image: i64 = -2,
2633
+
2634
+ /// A pub fn producing an ImageId binds like a field.
2635
+ pub fn thumbnail(model: *const ImageLeafModel) canvas.ImageId {
2636
+ return model.cover + 1;
2637
+ }
2638
+ };
2639
+
2640
+ pub const image_markup_source =
2641
+ \\<row gap="8">
2642
+ \\ <image image="{cover}" width="120" height="80" label="Cover art" />
2643
+ \\ <image image="{thumbnail}" width="48" height="48" label="" />
2644
+ \\</row>
2645
+ ;
2646
+
2647
+ /// A negative model value into the image leaf's u64 id seam: both
2648
+ /// engines must fail the build with the image teaching, never trap.
2649
+ pub const image_negative_markup_source =
2650
+ \\<row>
2651
+ \\ <image image="{stale_image}" label="Cover art" />
2652
+ \\</row>
2653
+ ;
2654
+
2655
+ pub const ImageLeafUi = canvas.Ui(ImageLeafMsg);
2656
+
2657
+ /// The hand-written equivalent of the image markup: `ui.image` with
2658
+ /// `ElementOptions.image`, the parity baseline the compiled suite
2659
+ /// shares.
2660
+ pub fn handImageLeafView(ui: *ImageLeafUi, model: *const ImageLeafModel) ImageLeafUi.Node {
2661
+ return ui.row(.{ .gap = 8 }, .{
2662
+ ui.image(.{ .image = model.cover, .width = 120, .height = 80, .semantics = .{ .label = "Cover art" } }),
2663
+ ui.image(.{ .image = model.thumbnail(), .width = 48, .height = 48, .semantics = .{ .label = "" } }),
2664
+ });
2665
+ }
2666
+
2667
+ test "the image leaf binds a dynamic ImageId from model fields and fns" {
2668
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2669
+ defer arena_state.deinit();
2670
+ const arena = arena_state.allocator();
2671
+ const ImageMarkup = markup_view.MarkupView(ImageLeafModel, ImageLeafMsg);
2672
+ const model = ImageLeafModel{ .cover = 42 };
2673
+
2674
+ var view = try ImageMarkup.init(arena, image_markup_source);
2675
+ var markup_ui = ImageLeafUi.init(arena);
2676
+ const markup_tree = try markup_ui.finalize(try view.build(&markup_ui, &model));
2677
+
2678
+ var hand_ui = ImageLeafUi.init(arena);
2679
+ const hand_tree = try hand_ui.finalize(handImageLeafView(&hand_ui, &model));
2680
+
2681
+ var markup_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
2682
+ defer markup_ids.deinit(testing.allocator);
2683
+ var hand_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
2684
+ defer hand_ids.deinit(testing.allocator);
2685
+ try collectIds(markup_tree.root, &markup_ids, testing.allocator);
2686
+ try collectIds(hand_tree.root, &hand_ids, testing.allocator);
2687
+ try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
2688
+
2689
+ // The field binding and the fn binding both land in image_id.
2690
+ const cover = markup_tree.root.children[0];
2691
+ try testing.expectEqual(canvas.WidgetKind.image, cover.kind);
2692
+ try testing.expectEqual(@as(canvas.ImageId, 42), cover.image_id);
2693
+ try testing.expectEqualStrings("Cover art", cover.semantics.label);
2694
+ const thumbnail = markup_tree.root.children[1];
2695
+ try testing.expectEqual(@as(canvas.ImageId, 43), thumbnail.image_id);
2696
+
2697
+ // 0 is the "no image" sentinel: the leaf renders nothing (the
2698
+ // model simply has not loaded the image yet).
2699
+ const empty_model = ImageLeafModel{};
2700
+ var empty_ui = ImageLeafUi.init(arena);
2701
+ const empty_tree = try empty_ui.finalize(try view.build(&empty_ui, &empty_model));
2702
+ try testing.expectEqual(@as(canvas.ImageId, 0), empty_tree.root.children[0].image_id);
2703
+ }
2704
+
2705
+ test "image leaf misuse fails the build with the teaching messages" {
2706
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2707
+ defer arena_state.deinit();
2708
+ const arena = arena_state.allocator();
2709
+ const model = ImageLeafModel{};
2710
+ const ImageMarkup = markup_view.MarkupView(ImageLeafModel, ImageLeafMsg);
2711
+
2712
+ const cases = [_]struct { source: []const u8, message: []const u8 }{
2713
+ .{
2714
+ // A literal id is not model data.
2715
+ .source = "<row>\n <image image=\"7\" label=\"Art\" />\n</row>",
2716
+ .message = canvas.ui_markup.image_binding_message,
2717
+ },
2718
+ .{
2719
+ // A negative integer can never be a u64 ImageId: the
2720
+ // teaching failure, not an @intCast trap.
2721
+ .source = image_negative_markup_source,
2722
+ .message = canvas.ui_markup.image_binding_message,
2723
+ },
2724
+ .{
2725
+ // A leaf like icon: widget layout gives an image no child
2726
+ // slots, so a nested caption would silently vanish - the
2727
+ // build refuses it instead (the compiled engine rejects
2728
+ // the same construct as a compile error).
2729
+ .source = "<row>\n <image image=\"{cover}\" label=\"Art\"><text>Caption</text></image>\n</row>",
2730
+ .message = canvas.ui_markup.image_children_message,
2731
+ },
2732
+ .{
2733
+ // Markup that skipped validation (hot reload) can reach the
2734
+ // engine without the binding: the leaf could only ever
2735
+ // render nothing, so the build refuses it exactly like the
2736
+ // validator (the compiled engine rejects the same construct
2737
+ // as a compile error).
2738
+ .source = "<row>\n <image label=\"Art\" />\n</row>",
2739
+ .message = canvas.ui_markup.image_missing_image_message,
2740
+ },
2741
+ .{
2742
+ // The children check reads the ORIGINAL node: a context-menu
2743
+ // child is extracted as host metadata before the content
2744
+ // rules, but the validator rejects it on the raw node - the
2745
+ // build agrees instead of quietly accepting a menu-bearing
2746
+ // leaf the validator refuses (the compiled engine rejects
2747
+ // the same construct as a compile error).
2748
+ .source = "<row>\n <image image=\"{cover}\" label=\"Art\" on-press=\"refresh\"><context-menu><menu-item on-press=\"refresh\">Reload</menu-item></context-menu></image>\n</row>",
2749
+ .message = canvas.ui_markup.image_children_message,
2750
+ },
2751
+ };
2752
+ for (cases) |case| {
2753
+ var view = try ImageMarkup.init(arena, case.source);
2754
+ var ui = ImageLeafUi.init(arena);
2755
+ try testing.expectError(error.MarkupBuild, view.build(&ui, &model));
2756
+ try testing.expectEqualStrings(case.message, view.diagnostic.message);
2757
+ try testing.expect(view.diagnostic.line > 0);
2758
+ }
2759
+ }
2760
+
2761
+ // ---------------------------------------------- video playback element
2762
+
2763
+ pub const VideoElementMsg = union(enum) { refresh };
2764
+
2765
+ pub const VideoElementModel = struct {
2766
+ clip: []const u8 = "assets/clips/intro.mp4",
2767
+ count: usize = 3,
2768
+ };
2769
+
2770
+ pub const video_markup_source =
2771
+ \\<column>
2772
+ \\ <video src="{clip}" controls autoplay loop muted width="320" height="180" label="Trailer"/>
2773
+ \\</column>
2774
+ ;
2775
+
2776
+ pub const video_plain_markup_source =
2777
+ \\<column>
2778
+ \\ <video src="assets/clips/intro.mp4" width="320" height="180" label="Trailer"/>
2779
+ \\</column>
2780
+ ;
2781
+
2782
+ pub const VideoElementUi = canvas.Ui(VideoElementMsg);
2783
+
2784
+ /// The hand-written equivalent of the video markup: `ui.video` with the
2785
+ /// same options, the parity baseline the compiled suite shares.
2786
+ pub fn handVideoElementView(ui: *VideoElementUi, model: *const VideoElementModel) VideoElementUi.Node {
2787
+ return ui.column(.{}, .{
2788
+ ui.video(.{
2789
+ .src = model.clip,
2790
+ .controls = true,
2791
+ .autoplay = true,
2792
+ .loop = true,
2793
+ .muted = true,
2794
+ .width = 320,
2795
+ .height = 180,
2796
+ .label = "Trailer",
2797
+ }),
2798
+ });
2799
+ }
2800
+
2801
+ /// The first widget in the tree carrying the given video-control verb,
2802
+ /// or null: how tests find the house chrome's runtime-consumed controls.
2803
+ pub fn findVideoControl(widget: canvas.Widget, verb: canvas.VideoControlVerb) ?canvas.Widget {
2804
+ if (widget.video_control == verb) return widget;
2805
+ for (widget.children) |child| {
2806
+ if (findVideoControl(child, verb)) |found| return found;
2807
+ }
2808
+ return null;
2809
+ }
2810
+
2811
+ // -------------------------------------------------- terminal element
2812
+
2813
+ pub const TerminalElementMsg = union(enum) { term_state: canvas.TerminalState };
2814
+
2815
+ pub const TerminalElementModel = struct {
2816
+ shell: u64 = 7,
2817
+ offset: u32 = 4,
2818
+ };
2819
+
2820
+ pub const terminal_markup_source =
2821
+ \\<column>
2822
+ \\ <terminal pty="{shell}" scrollback="{offset}" grow="1" label="Build shell" on-terminal="term_state"/>
2823
+ \\</column>
2824
+ ;
2825
+
2826
+ pub const TerminalElementUi = canvas.Ui(TerminalElementMsg);
2827
+
2828
+ /// The hand-written equivalent of the terminal markup: `ui.terminal`
2829
+ /// with the same options, the parity baseline the compiled suite shares.
2830
+ pub fn handTerminalElementView(ui: *TerminalElementUi, model: *const TerminalElementModel) TerminalElementUi.Node {
2831
+ return ui.column(.{}, .{
2832
+ ui.terminal(.{
2833
+ .pty = model.shell,
2834
+ .scrollback = model.offset,
2835
+ .grow = 1,
2836
+ .semantics = .{ .label = "Build shell" },
2837
+ .on_terminal = TerminalElementUi.terminalMsg(.term_state),
2838
+ }),
2839
+ });
2840
+ }
2841
+
2842
+ /// The first widget of the given kind in the tree, or null.
2843
+ pub fn findWidgetKind(widget: canvas.Widget, kind: canvas.WidgetKind) ?canvas.Widget {
2844
+ if (widget.kind == kind) return widget;
2845
+ for (widget.children) |child| {
2846
+ if (findWidgetKind(child, kind)) |found| return found;
2847
+ }
2848
+ return null;
2849
+ }
2850
+
2851
+ test "the terminal element binds its pty key, scrollback echo, and view-state handler" {
2852
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2853
+ defer arena_state.deinit();
2854
+ const arena = arena_state.allocator();
2855
+
2856
+ const model = TerminalElementModel{};
2857
+ var view = try markup_view.MarkupView(TerminalElementModel, TerminalElementMsg).init(arena, terminal_markup_source);
2858
+ var ui = TerminalElementUi.init(arena);
2859
+ const tree = try ui.finalize(try view.build(&ui, &model));
2860
+
2861
+ const widget = findWidgetKind(tree.root, .terminal) orelse return error.TestExpectedTerminal;
2862
+ try testing.expectEqual(@as(u64, 7), widget.terminal.pty);
2863
+ try testing.expectEqual(@as(u32, 4), widget.terminal.scrollback);
2864
+ // No lookup installed (a bare builder): the widget renders unbound
2865
+ // and the author's label stays the accessible name.
2866
+ try testing.expect(widget.terminal.grid == null);
2867
+ try testing.expectEqualStrings("Build shell", widget.semantics.label);
2868
+
2869
+ // The view-state handler resolves through the tree and carries the
2870
+ // applied state.
2871
+ const msg = tree.msgForTerminal(widget.id, .{ .scrollback = 12, .history = 40, .cols = 80, .rows = 24 }) orelse return error.TestExpectedHandler;
2872
+ try testing.expectEqual(@as(u32, 12), msg.term_state.scrollback);
2873
+ try testing.expectEqual(@as(u32, 40), msg.term_state.history);
2874
+ try testing.expectEqual(@as(u16, 80), msg.term_state.cols);
2875
+ try testing.expectEqual(@as(u16, 24), msg.term_state.rows);
2876
+ }
2877
+
2878
+ test "the interpreter enforces the terminal leaf shape without the validator" {
2879
+ // Hot reload builds without a validation pass: the build itself must
2880
+ // refuse a pty-less terminal (dead markup) and terminal children (no
2881
+ // child slots), exactly like the image leaf.
2882
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2883
+ defer arena_state.deinit();
2884
+ const arena = arena_state.allocator();
2885
+ const model = TerminalElementModel{};
2886
+
2887
+ const missing_pty =
2888
+ \\<column>
2889
+ \\ <terminal label="Shell"/>
2890
+ \\</column>
2891
+ ;
2892
+ var missing_view = try markup_view.MarkupView(TerminalElementModel, TerminalElementMsg).init(arena, missing_pty);
2893
+ var missing_ui = TerminalElementUi.init(arena);
2894
+ try testing.expectError(error.MarkupBuild, missing_view.build(&missing_ui, &model));
2895
+ try testing.expectEqualStrings(canvas.ui_markup.terminal_missing_pty_message, missing_view.diagnostic.message);
2896
+
2897
+ const with_child =
2898
+ \\<column>
2899
+ \\ <terminal pty="{shell}" label="Shell"><button>Run</button></terminal>
2900
+ \\</column>
2901
+ ;
2902
+ var child_view = try markup_view.MarkupView(TerminalElementModel, TerminalElementMsg).init(arena, with_child);
2903
+ var child_ui = TerminalElementUi.init(arena);
2904
+ try testing.expectError(error.MarkupBuild, child_view.build(&child_ui, &model));
2905
+ try testing.expectEqualStrings(canvas.ui_markup.terminal_children_message, child_view.diagnostic.message);
2906
+
2907
+ const misplaced_scrollback =
2908
+ \\<column>
2909
+ \\ <panel scrollback="3"/>
2910
+ \\</column>
2911
+ ;
2912
+ var scoped_view = try markup_view.MarkupView(TerminalElementModel, TerminalElementMsg).init(arena, misplaced_scrollback);
2913
+ var scoped_ui = TerminalElementUi.init(arena);
2914
+ try testing.expectError(error.MarkupBuild, scoped_view.build(&scoped_ui, &model));
2915
+ try testing.expectEqualStrings(canvas.ui_markup.scrollback_element_message, scoped_view.diagnostic.message);
2916
+ }
2917
+
2918
+ test "on-terminal requires a bare tag: an authored payload is refused" {
2919
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2920
+ defer arena_state.deinit();
2921
+ const arena = arena_state.allocator();
2922
+
2923
+ // The runtime supplies the TerminalState, so `term_state:{offset}`
2924
+ // is dead data — refused with the payload teaching, not silently
2925
+ // discarded.
2926
+ const source =
2927
+ \\<column>
2928
+ \\ <terminal pty="{shell}" label="Shell" on-terminal="term_state:{offset}"/>
2929
+ \\</column>
2930
+ ;
2931
+ var view = try markup_view.MarkupView(TerminalElementModel, TerminalElementMsg).init(arena, source);
2932
+ var ui = TerminalElementUi.init(arena);
2933
+ const model = TerminalElementModel{};
2934
+ try testing.expectError(error.MarkupBuild, view.build(&ui, &model));
2935
+ try testing.expectEqualStrings(canvas.ui_markup.on_terminal_payload_message, view.diagnostic.message);
2936
+ }
2937
+
2938
+ test "the video element lowers to the playback surface with house chrome and records the declaration" {
2939
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2940
+ defer arena_state.deinit();
2941
+ const arena = arena_state.allocator();
2942
+ const VideoMarkup = markup_view.MarkupView(VideoElementModel, VideoElementMsg);
2943
+ const model = VideoElementModel{};
2944
+
2945
+ var view = try VideoMarkup.init(arena, video_markup_source);
2946
+ var markup_ui = VideoElementUi.init(arena);
2947
+ const markup_tree = try markup_ui.finalize(try view.build(&markup_ui, &model));
2948
+
2949
+ var hand_ui = VideoElementUi.init(arena);
2950
+ const hand_tree = try hand_ui.finalize(handVideoElementView(&hand_ui, &model));
2951
+
2952
+ var markup_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
2953
+ defer markup_ids.deinit(testing.allocator);
2954
+ var hand_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
2955
+ defer hand_ids.deinit(testing.allocator);
2956
+ try collectIds(markup_tree.root, &markup_ids, testing.allocator);
2957
+ try collectIds(hand_tree.root, &hand_ids, testing.allocator);
2958
+ try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
2959
+
2960
+ // With controls the element is a column: the playback surface bound
2961
+ // to the framework-owned playback id, then the transport row whose
2962
+ // controls carry the runtime-consumed verbs.
2963
+ const video_root = markup_tree.root.children[0];
2964
+ try testing.expectEqual(canvas.WidgetKind.column, video_root.kind);
2965
+ const surface = video_root.children[0];
2966
+ try testing.expectEqual(canvas.WidgetKind.media_surface, surface.kind);
2967
+ try testing.expectEqual(canvas.video_playback_surface_id, surface.image_id);
2968
+ try testing.expectEqualStrings("Trailer", surface.semantics.label);
2969
+ const toggle = findVideoControl(markup_tree.root, .toggle) orelse return error.TestUnexpectedResult;
2970
+ try testing.expectEqual(canvas.WidgetKind.button, toggle.kind);
2971
+ // The chrome renders the channel snapshot; outside an app loop the
2972
+ // default state is inactive, so the transport is disabled at the
2973
+ // play glyph.
2974
+ try testing.expect(toggle.state.disabled);
2975
+ try testing.expectEqualStrings("play", toggle.icon);
2976
+ const scrub = findVideoControl(markup_tree.root, .scrub) orelse return error.TestUnexpectedResult;
2977
+ try testing.expectEqual(canvas.WidgetKind.slider, scrub.kind);
2978
+ try testing.expect(scrub.state.disabled);
2979
+
2980
+ // The build recorded the declaration for the app loop's reconcile.
2981
+ const declaration = markup_ui.video_declaration orelse return error.TestUnexpectedResult;
2982
+ try testing.expectEqualStrings("assets/clips/intro.mp4", declaration.src);
2983
+ try testing.expect(declaration.controls);
2984
+ try testing.expect(declaration.autoplay);
2985
+ try testing.expect(declaration.loop);
2986
+ try testing.expect(declaration.muted);
2987
+
2988
+ // Without controls the element is the surface itself: no chrome
2989
+ // anywhere in the tree.
2990
+ var plain_view = try VideoMarkup.init(arena, video_plain_markup_source);
2991
+ var plain_ui = VideoElementUi.init(arena);
2992
+ const plain_tree = try plain_ui.finalize(try plain_view.build(&plain_ui, &model));
2993
+ const plain_surface = plain_tree.root.children[0];
2994
+ try testing.expectEqual(canvas.WidgetKind.media_surface, plain_surface.kind);
2995
+ try testing.expectEqual(canvas.video_playback_surface_id, plain_surface.image_id);
2996
+ try testing.expect(findVideoControl(plain_tree.root, .toggle) == null);
2997
+ try testing.expect(findVideoControl(plain_tree.root, .scrub) == null);
2998
+ try testing.expect(plain_ui.video_declaration != null);
2999
+ }
3000
+
3001
+ test "video misuse fails the build with the teaching messages" {
3002
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
3003
+ defer arena_state.deinit();
3004
+ const arena = arena_state.allocator();
3005
+ const model = VideoElementModel{};
3006
+ const VideoMarkup = markup_view.MarkupView(VideoElementModel, VideoElementMsg);
3007
+
3008
+ const cases = [_]struct { source: []const u8, message: []const u8 }{
3009
+ .{
3010
+ // A leaf like image and icon: nested content would silently
3011
+ // vanish (the compiled engine rejects the same construct as
3012
+ // a compile error).
3013
+ .source = "<row>\n <video src=\"a.mp4\"><text>Caption</text></video>\n</row>",
3014
+ .message = canvas.ui_markup.video_children_message,
3015
+ },
3016
+ .{
3017
+ // The closed attribute set teaches its vocabulary.
3018
+ .source = "<row>\n <video src=\"a.mp4\" gap=\"4\"/>\n</row>",
3019
+ .message = canvas.ui_markup.video_attr_message,
3020
+ },
3021
+ .{
3022
+ // A bound src must produce the source STRING (count is a
3023
+ // number).
3024
+ .source = "<row>\n <video src=\"{count}\"/>\n</row>",
3025
+ .message = canvas.ui_markup.video_src_message,
3026
+ },
3027
+ .{
3028
+ // The flags are video-scoped: anywhere else they would be
3029
+ // silently inert.
3030
+ .source = "<row>\n <panel controls=\"true\"/>\n</row>",
3031
+ .message = canvas.ui_markup.video_flag_element_message,
3032
+ },
3033
+ };
3034
+ for (cases) |case| {
3035
+ var view = try VideoMarkup.init(arena, case.source);
3036
+ var ui = VideoElementUi.init(arena);
3037
+ try testing.expectError(error.MarkupBuild, view.build(&ui, &model));
3038
+ try testing.expectEqualStrings(case.message, view.diagnostic.message);
3039
+ try testing.expect(view.diagnostic.line > 0);
3040
+ }
3041
+ }
3042
+
2540
3043
  // ------------------------------------- text alignment and grid columns
2541
3044
 
2542
3045
  pub const AlignMsg = union(enum) { refresh };
@@ -3907,7 +4410,8 @@ test "reactions misuse fails the build with the pinned teaching messages" {
3907
4410
 
3908
4411
  // The pill's literal run rides the tofu guard: a codepoint outside
3909
4412
  // the bundled face renders as a tofu box on the reference path, so
3910
- // the validator teaches vector icons or plain words instead.
4413
+ // the validator teaches the real paths — a registered covering
4414
+ // font behind a binding, a vector icon, or plain words.
3911
4415
  const emoji = "<column>\n <bubble><text>hi</text><reactions>\u{1F44D}</reactions></bubble>\n</column>";
3912
4416
  var parser = canvas.ui_markup.Parser.init(arena, emoji);
3913
4417
  const document = try parser.parse();
@@ -4008,10 +4512,14 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
4008
4512
  /// independently (the number tier): float fields widen exactly, integer
4009
4513
  /// fields round.
4010
4514
  pub const MirrorScrollState = struct {
4011
- offset: f64,
4012
- velocity: f64,
4013
- viewportExtent: i64,
4014
- contentExtent: i64,
4515
+ offsetX: f64,
4516
+ offsetY: f64,
4517
+ velocityX: f64,
4518
+ velocityY: f64,
4519
+ viewportExtentX: i64,
4520
+ viewportExtentY: i64,
4521
+ contentExtentX: i64,
4522
+ contentExtentY: i64,
4015
4523
  };
4016
4524
 
4017
4525
  pub const MirrorControlsModel = struct {
@@ -4030,18 +4538,27 @@ pub const MirrorControlsMsg = union(enum) {
4030
4538
 
4031
4539
  test "declaredScrollStateRecord accepts the emitted mirror shape and rejects near-misses" {
4032
4540
  try testing.expect(markup_view.declaredScrollStateRecord(MirrorScrollState));
4033
- // The canvas struct itself matches structurally too (four f32 fields).
4541
+ // The canvas struct itself matches structurally too (eight f32 fields).
4034
4542
  try testing.expect(markup_view.declaredScrollStateRecord(canvas.ScrollState));
4035
4543
  // A Zig-declared mirror in the canvas spelling stays accepted.
4036
- try testing.expect(markup_view.declaredScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, content_extent: f64 }));
4544
+ try testing.expect(markup_view.declaredScrollStateRecord(struct { offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, content_extent_y: f64 }));
4037
4545
  // Near-misses stay out: a missing field, a renamed field, a non-numeric
4038
4546
  // field, an extra field, a spelling mix.
4039
- try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64 }));
4040
- try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, content_size: f64 }));
4041
- try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset: []const u8, velocity: f64, viewport_extent: f64, content_extent: f64 }));
4042
- try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, content_extent: f64, extra: f64 }));
4043
- try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, contentExtent: f64 }));
4547
+ try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64 }));
4548
+ try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, content_size_y: f64 }));
4549
+ try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset_x: []const u8, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, content_extent_y: f64 }));
4550
+ try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, content_extent_y: f64, extra: f64 }));
4551
+ try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, contentExtentY: f64 }));
4044
4552
  try testing.expect(!markup_view.declaredScrollStateRecord(i64));
4553
+ // The RETIRED one-axis record is not a scroll-state record anymore -
4554
+ // it classifies as the legacy shape so on-scroll teaches the
4555
+ // per-axis migration by name (either spelling, never a mix).
4556
+ try testing.expect(!markup_view.declaredScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, content_extent: f64 }));
4557
+ try testing.expect(markup_view.declaredLegacyScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, content_extent: f64 }));
4558
+ try testing.expect(markup_view.declaredLegacyScrollStateRecord(struct { offset: f64, velocity: f64, viewportExtent: i64, contentExtent: i64 }));
4559
+ try testing.expect(!markup_view.declaredLegacyScrollStateRecord(MirrorScrollState));
4560
+ try testing.expect(!markup_view.declaredLegacyScrollStateRecord(canvas.ScrollState));
4561
+ try testing.expect(!markup_view.declaredLegacyScrollStateRecord(struct { offset: f64, velocity: f64, viewport_extent: f64, contentExtent: f64 }));
4045
4562
  }
4046
4563
 
4047
4564
  test "valueArmClass classifies exactly the value-carrying arm shapes" {
@@ -4070,17 +4587,25 @@ test "the interpreter binds on-scroll to a declared mirror record and translates
4070
4587
  const tree = try ui.finalize(try view.build(&ui, &model));
4071
4588
  const region = findByKind(tree.root, .scroll_view).?;
4072
4589
  const msg = tree.msgForScroll(region.id, .{
4073
- .offset = 41.5,
4074
- .velocity = -3.25,
4075
- .viewport_extent = 480.4,
4076
- .content_extent = 2000.6,
4590
+ .offset_x = 12.5,
4591
+ .offset_y = 41.5,
4592
+ .velocity_x = 1.5,
4593
+ .velocity_y = -3.25,
4594
+ .viewport_extent_x = 320.2,
4595
+ .viewport_extent_y = 480.4,
4596
+ .content_extent_x = 960.7,
4597
+ .content_extent_y = 2000.6,
4077
4598
  }).?;
4078
4599
  // Float fields widen exactly; integer-classed fields round to the
4079
4600
  // nearest whole number.
4080
- try testing.expectEqual(@as(f64, 41.5), msg.library_scrolled.offset);
4081
- try testing.expectEqual(@as(f64, -3.25), msg.library_scrolled.velocity);
4082
- try testing.expectEqual(@as(i64, 480), msg.library_scrolled.viewportExtent);
4083
- try testing.expectEqual(@as(i64, 2001), msg.library_scrolled.contentExtent);
4601
+ try testing.expectEqual(@as(f64, 12.5), msg.library_scrolled.offsetX);
4602
+ try testing.expectEqual(@as(f64, 41.5), msg.library_scrolled.offsetY);
4603
+ try testing.expectEqual(@as(f64, 1.5), msg.library_scrolled.velocityX);
4604
+ try testing.expectEqual(@as(f64, -3.25), msg.library_scrolled.velocityY);
4605
+ try testing.expectEqual(@as(i64, 320), msg.library_scrolled.viewportExtentX);
4606
+ try testing.expectEqual(@as(i64, 480), msg.library_scrolled.viewportExtentY);
4607
+ try testing.expectEqual(@as(i64, 961), msg.library_scrolled.contentExtentX);
4608
+ try testing.expectEqual(@as(i64, 2001), msg.library_scrolled.contentExtentY);
4084
4609
  }
4085
4610
 
4086
4611
  test "the interpreter binds slider on-change value arms and keeps the void static form" {