@native-sdk/cli 0.5.4 → 0.6.1

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 (149) hide show
  1. package/build/app.zig +50 -1
  2. package/build.zig +588 -32
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +3 -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 +280 -8
  9. package/packages/core/sdk/core.ts +481 -2
  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 +599 -3
  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 +39 -2
  17. package/skill-data/ts-core/SKILL.md +4 -2
  18. package/src/app_runner/root.zig +32 -10
  19. package/src/automation/layout_fingerprint.zig +160 -0
  20. package/src/automation/protocol.zig +82 -33
  21. package/src/automation/root.zig +1 -0
  22. package/src/automation/server.zig +1 -1
  23. package/src/automation/snapshot.zig +68 -9
  24. package/src/automation/watcher.zig +1 -1
  25. package/src/embed/host.zig +5 -0
  26. package/src/embed/ui_host.zig +13 -0
  27. package/src/platform/linux/gtk_host.c +527 -13
  28. package/src/platform/linux/gtk_host.h +25 -0
  29. package/src/platform/linux/root.zig +280 -7
  30. package/src/platform/macos/appkit_host.h +104 -6
  31. package/src/platform/macos/appkit_host.m +1368 -74
  32. package/src/platform/macos/cef_host.mm +110 -1
  33. package/src/platform/macos/root.zig +287 -7
  34. package/src/platform/null_platform.zig +398 -4
  35. package/src/platform/null_platform_tests.zig +35 -0
  36. package/src/platform/root.zig +9 -0
  37. package/src/platform/types.zig +386 -14
  38. package/src/platform/windows/root.zig +298 -9
  39. package/src/platform/windows/webview2_host.cpp +330 -5
  40. package/src/primitives/app_manifest/validation.zig +18 -0
  41. package/src/primitives/canvas/a11y_audit.zig +33 -11
  42. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  43. package/src/primitives/canvas/drawing.zig +25 -0
  44. package/src/primitives/canvas/equality.zig +8 -0
  45. package/src/primitives/canvas/events.zig +103 -16
  46. package/src/primitives/canvas/frame.zig +125 -1
  47. package/src/primitives/canvas/layout_audit.zig +22 -5
  48. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  49. package/src/primitives/canvas/render_tests.zig +13 -10
  50. package/src/primitives/canvas/root.zig +48 -0
  51. package/src/primitives/canvas/terminal_box.zig +471 -0
  52. package/src/primitives/canvas/terminal_grid.zig +978 -0
  53. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  54. package/src/primitives/canvas/test_support.zig +1 -0
  55. package/src/primitives/canvas/tests.zig +1 -0
  56. package/src/primitives/canvas/text_tests.zig +39 -4
  57. package/src/primitives/canvas/tokens.zig +115 -12
  58. package/src/primitives/canvas/ui.zig +524 -5
  59. package/src/primitives/canvas/ui_markup.zig +195 -2
  60. package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
  62. package/src/primitives/canvas/ui_markup_contract.zig +88 -5
  63. package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
  64. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  65. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  66. package/src/primitives/canvas/ui_markup_tests.zig +149 -0
  67. package/src/primitives/canvas/ui_markup_view.zig +191 -0
  68. package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
  69. package/src/primitives/canvas/ui_schema.zig +97 -17
  70. package/src/primitives/canvas/ui_schema_tests.zig +18 -11
  71. package/src/primitives/canvas/ui_tests.zig +141 -9
  72. package/src/primitives/canvas/widget_access.zig +28 -2
  73. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  74. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  75. package/src/primitives/canvas/widget_layout.zig +59 -11
  76. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  77. package/src/primitives/canvas/widget_render.zig +272 -18
  78. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  79. package/src/primitives/canvas/widget_routing.zig +59 -7
  80. package/src/primitives/canvas/widget_runtime.zig +23 -0
  81. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  82. package/src/primitives/canvas/widget_semantics.zig +119 -11
  83. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  84. package/src/primitives/canvas/widget_tree.zig +17 -0
  85. package/src/primitives/canvas/widgets.zig +132 -0
  86. package/src/root.zig +16 -0
  87. package/src/runtime/api.zig +76 -6
  88. package/src/runtime/automation_commands.zig +20 -1
  89. package/src/runtime/automation_snapshot.zig +25 -1
  90. package/src/runtime/automation_widget_dispatch.zig +73 -8
  91. package/src/runtime/bridge_payload.zig +1 -0
  92. package/src/runtime/canvas_frame.zig +62 -7
  93. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  94. package/src/runtime/canvas_frame_helpers.zig +190 -1
  95. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  96. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  97. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  98. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  99. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  100. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  101. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  102. package/src/runtime/canvas_widget_display.zig +1 -1
  103. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  104. package/src/runtime/canvas_widget_events.zig +268 -26
  105. package/src/runtime/canvas_widget_runtime.zig +213 -29
  106. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  107. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  108. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  109. package/src/runtime/canvas_widget_state.zig +6 -0
  110. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  111. package/src/runtime/core.zig +73 -2
  112. package/src/runtime/effects.zig +6389 -54
  113. package/src/runtime/effects_channel_tests.zig +3519 -0
  114. package/src/runtime/effects_pty_tests.zig +1362 -0
  115. package/src/runtime/effects_tests.zig +14 -9
  116. package/src/runtime/effects_video_tests.zig +3609 -0
  117. package/src/runtime/flow.zig +25 -4
  118. package/src/runtime/gpu_surface_events.zig +475 -15
  119. package/src/runtime/media_surface.zig +116 -11
  120. package/src/runtime/media_surface_tests.zig +61 -0
  121. package/src/runtime/pty.zig +1252 -0
  122. package/src/runtime/pty_windows.zig +1780 -0
  123. package/src/runtime/root.zig +25 -0
  124. package/src/runtime/runtime_event_tests.zig +20 -1
  125. package/src/runtime/session_journal.zig +367 -61
  126. package/src/runtime/session_record.zig +16 -0
  127. package/src/runtime/session_replay.zig +395 -11
  128. package/src/runtime/session_tests.zig +114 -19
  129. package/src/runtime/terminal_session.zig +1569 -0
  130. package/src/runtime/terminal_session_tests.zig +450 -0
  131. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  132. package/src/runtime/terminal_vt_stub.zig +13 -0
  133. package/src/runtime/tests.zig +6 -0
  134. package/src/runtime/ts_core_host.zig +980 -140
  135. package/src/runtime/ts_core_host_tests.zig +1059 -1
  136. package/src/runtime/ts_ui_app.zig +16 -5
  137. package/src/runtime/ui_app.zig +2338 -67
  138. package/src/runtime/ui_app_tests.zig +3171 -744
  139. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  140. package/src/runtime/ui_app_window_tests.zig +268 -0
  141. package/src/runtime/view.zig +190 -2
  142. package/src/runtime/view_widget_scroll.zig +218 -68
  143. package/src/runtime/view_widget_text.zig +11 -2
  144. package/src/runtime/view_widget_tree.zig +111 -3
  145. package/src/runtime/window_storage.zig +45 -2
  146. package/src/runtime/window_view_runtime.zig +34 -2
  147. package/src/runtime/window_views.zig +1 -0
  148. package/src/terminal_session_tests_root.zig +15 -0
  149. package/src/tooling/templates.zig +25 -7
@@ -744,6 +744,89 @@ test "the media-surface surface attribute validates as one binding, required, me
744
744
  }
745
745
  }
746
746
 
747
+ test "the video element validates as a leaf with its closed attribute set" {
748
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
749
+ defer arena_state.deinit();
750
+ const arena = arena_state.allocator();
751
+
752
+ // The full declaration (bare flags read as presence-is-true), a
753
+ // bound src, and the src-less surface-only shape are all legal.
754
+ const valid = [_][]const u8{
755
+ "<row>\n <video src=\"assets/clips/a.mp4\" controls autoplay loop muted/>\n</row>",
756
+ "<row>\n <video src=\"{clip}\" controls=\"true\" width=\"320\" height=\"180\" label=\"Trailer\"/>\n</row>",
757
+ "<row>\n <video controls grow=\"1\" label=\"Preview\"/>\n</row>",
758
+ };
759
+ for (valid) |source| {
760
+ var parser = markup.Parser.init(arena, source);
761
+ try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try parser.parse()));
762
+ }
763
+
764
+ const cases = [_]struct { source: []const u8, message: []const u8 }{
765
+ // A leaf like image and icon: widget layout gives the playback
766
+ // surface no child slots, so nested content would silently
767
+ // vanish instead of rendering.
768
+ .{ .source = "<row>\n <video src=\"a.mp4\"><text>Caption</text></video>\n</row>", .message = markup.video_children_message },
769
+ // The closed attribute set teaches its vocabulary.
770
+ .{ .source = "<row>\n <video src=\"a.mp4\" gap=\"4\"/>\n</row>", .message = markup.video_attr_message },
771
+ // Events are not part of the set either: the chrome is
772
+ // runtime-consumed, so there is nothing to bind.
773
+ .{ .source = "<row>\n <video src=\"a.mp4\" on-press=\"open\"/>\n</row>", .message = markup.video_attr_message },
774
+ // The flags are video-scoped: anywhere else they would be
775
+ // silently inert.
776
+ .{ .source = "<row>\n <panel controls=\"true\"/>\n</row>", .message = markup.video_flag_element_message },
777
+ .{ .source = "<row>\n <badge muted=\"true\">3</badge>\n</row>", .message = markup.video_flag_element_message },
778
+ // A malformed flag value errors exactly as flags do.
779
+ .{ .source = "<row>\n <video controls=\"{\"/>\n</row>", .message = markup.invalid_expression_message },
780
+ };
781
+ for (cases) |case| {
782
+ var case_parser = markup.Parser.init(arena, case.source);
783
+ const info = markup.validate(try case_parser.parse()) orelse return error.TestUnexpectedResult;
784
+ try testing.expectEqualStrings(case.message, info.message);
785
+ try testing.expectEqual(@as(usize, 2), info.line);
786
+ }
787
+ }
788
+
789
+ test "the terminal element requires its pty binding and scopes its vocabulary" {
790
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
791
+ defer arena_state.deinit();
792
+ const arena = arena_state.allocator();
793
+
794
+ const valid = [_][]const u8{
795
+ "<column>\n <terminal pty=\"{shell}\" label=\"Shell\" grow=\"1\"/>\n</column>",
796
+ "<column>\n <terminal pty=\"{shell}\" scrollback=\"{offset}\" label=\"Shell\" on-terminal=\"term_state\" autofocus/>\n</column>",
797
+ };
798
+ for (valid) |source| {
799
+ var parser = markup.Parser.init(arena, source);
800
+ try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try parser.parse()));
801
+ }
802
+
803
+ const cases = [_]struct { source: []const u8, message: []const u8 }{
804
+ // A terminal without its pty binding can never attach a session:
805
+ // dead markup, the media-surface-without-surface policy.
806
+ .{ .source = "<column>\n <terminal label=\"Shell\"/>\n</column>", .message = markup.terminal_missing_pty_message },
807
+ // pty keys are model data, never markup literals.
808
+ .{ .source = "<column>\n <terminal pty=\"1\" label=\"Shell\"/>\n</column>", .message = markup.terminal_pty_message },
809
+ // A leaf like icon and image: no child slots.
810
+ .{ .source = "<column>\n <terminal pty=\"{shell}\" label=\"Shell\"><text>x</text></terminal>\n</column>", .message = markup.terminal_children_message },
811
+ // The scoped vocabulary teaches where it lives.
812
+ .{ .source = "<column>\n <panel pty=\"{shell}\"/>\n</column>", .message = markup.terminal_pty_element_message },
813
+ .{ .source = "<column>\n <panel scrollback=\"3\"/>\n</column>", .message = markup.scrollback_element_message },
814
+ .{ .source = "<column>\n <panel on-terminal=\"term_state\"/>\n</column>", .message = markup.on_terminal_element_message },
815
+ // The text channel is runtime-owned (the live screen rides it),
816
+ // so an authored text would be clobbered every frame.
817
+ .{ .source = "<column>\n <terminal pty=\"{shell}\" text=\"Build shell\"/>\n</column>", .message = markup.terminal_text_attr_message },
818
+ // A container role promises child structure a terminal leaf can
819
+ // never hold.
820
+ .{ .source = "<column>\n <terminal pty=\"{shell}\" label=\"Shell\" role=\"list\"/>\n</column>", .message = markup.a11y_container_role_message },
821
+ };
822
+ for (cases) |case| {
823
+ var case_parser = markup.Parser.init(arena, case.source);
824
+ const info = markup.validate(try case_parser.parse()) orelse return error.TestUnexpectedResult;
825
+ try testing.expectEqualStrings(case.message, info.message);
826
+ try testing.expectEqual(@as(usize, 2), info.line);
827
+ }
828
+ }
829
+
747
830
  test "wrap and issue-link-base validate as vocabulary with teaching errors" {
748
831
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
749
832
  defer arena_state.deinit();
@@ -841,6 +924,72 @@ test "overscroll validates as scroll-scoped with a closed value vocabulary" {
841
924
  }
842
925
  }
843
926
 
927
+ test "axis and value-x validate as scroll-scoped with the axis grant dependency" {
928
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
929
+ defer arena_state.deinit();
930
+ const arena = arena_state.allocator();
931
+
932
+ // Valid: every vocabulary value on scroll, and value-x beside a
933
+ // horizontal-capable axis (literal or a binding resolved at build).
934
+ const valid_sources = [_][]const u8{
935
+ "<column>\n <scroll axis=\"vertical\">\n <column><text>a</text></column>\n </scroll>\n</column>",
936
+ "<column>\n <scroll axis=\"horizontal\">\n <row><text>a</text></row>\n </scroll>\n</column>",
937
+ "<column>\n <scroll axis=\"both\">\n <column><text>a</text></column>\n </scroll>\n</column>",
938
+ "<column>\n <scroll axis=\"horizontal\" value-x=\"120\">\n <row><text>a</text></row>\n </scroll>\n</column>",
939
+ "<column>\n <scroll axis=\"both\" value-x=\"{shelf_x}\">\n <column><text>a</text></column>\n </scroll>\n</column>",
940
+ // A literal VERTICAL axis is legal beside virtualization (it
941
+ // grants nothing virtualization ignores), and a horizontal
942
+ // grant is legal beside a literal virtualized="false".
943
+ "<column>\n <scroll axis=\"vertical\" virtualized=\"true\" virtual-item-extent=\"24\">\n <column><text>a</text></column>\n </scroll>\n</column>",
944
+ "<column>\n <scroll axis=\"horizontal\" virtualized=\"false\">\n <row><text>a</text></row>\n </scroll>\n</column>",
945
+ };
946
+ for (valid_sources) |source| {
947
+ var parser = markup.Parser.init(arena, source);
948
+ try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try parser.parse()));
949
+ }
950
+
951
+ const cases = [_]struct { source: []const u8, message: []const u8 }{
952
+ // Axes exist only where the runtime scrolls.
953
+ .{
954
+ .source = "<column>\n <row axis=\"horizontal\">\n <text>a</text>\n </row>\n</column>",
955
+ .message = markup.axis_element_message,
956
+ },
957
+ // Literal values outside the closed vocabulary teach the set.
958
+ .{
959
+ .source = "<column>\n <scroll axis=\"sideways\">\n <column><text>a</text></column>\n </scroll>\n</column>",
960
+ .message = markup.axis_value_message,
961
+ },
962
+ // Windowed virtualization is vertical machinery: a horizontal
963
+ // grant there would be silently ignored.
964
+ .{
965
+ .source = "<column>\n <scroll axis=\"horizontal\" virtualized=\"true\" virtual-item-extent=\"24\">\n <column><text>a</text></column>\n </scroll>\n</column>",
966
+ .message = markup.axis_virtualized_message,
967
+ },
968
+ // The horizontal offset exists only where the runtime scrolls
969
+ // sideways.
970
+ .{
971
+ .source = "<column>\n <row value-x=\"20\">\n <text>a</text>\n </row>\n</column>",
972
+ .message = markup.value_x_element_message,
973
+ },
974
+ // An offset on an axis the region never grants is silently
975
+ // inert: no axis at all, and the explicit vertical default.
976
+ .{
977
+ .source = "<column>\n <scroll value-x=\"20\">\n <column><text>a</text></column>\n </scroll>\n</column>",
978
+ .message = markup.value_x_dependent_attr_message,
979
+ },
980
+ .{
981
+ .source = "<column>\n <scroll axis=\"vertical\" value-x=\"20\">\n <column><text>a</text></column>\n </scroll>\n</column>",
982
+ .message = markup.value_x_dependent_attr_message,
983
+ },
984
+ };
985
+ for (cases) |case| {
986
+ var parser = markup.Parser.init(arena, case.source);
987
+ const info = markup.validate(try parser.parse()) orelse return error.TestUnexpectedResult;
988
+ try testing.expectEqualStrings(case.message, info.message);
989
+ try testing.expect(info.line > 0);
990
+ }
991
+ }
992
+
844
993
  test "tooltip-delay validates as tooltip-scoped beside anchor, and anchor accepts tooltip" {
845
994
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
846
995
  defer arena_state.deinit();
@@ -233,6 +233,9 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
233
233
  // Series inside a chart are consumed by buildChart.
234
234
  return self.failNode(node, markup.series_parent_message);
235
235
  }
236
+ if (std.mem.eql(u8, node.name, "video")) {
237
+ return self.buildVideo(ui, scope, node);
238
+ }
236
239
  if (std.mem.eql(u8, node.name, "context-menu")) {
237
240
  // Direct context-menu children are consumed by their host
238
241
  // element below; one reaching here is misplaced.
@@ -415,6 +418,20 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
415
418
  return self.failNode(node, markup.image_children_message);
416
419
  }
417
420
  }
421
+ // The terminal leaf's static shape, the image policy exactly:
422
+ // without its pty binding it can never attach a session, and
423
+ // its widget has no child slots — both refused at build so
424
+ // markup that skipped validation (hot reload) fails instead
425
+ // of silently rendering an unbound surface or dropping the
426
+ // child.
427
+ if (kind == .terminal) {
428
+ if (node.attr("pty") == null) {
429
+ return self.failNode(node, markup.terminal_missing_pty_message);
430
+ }
431
+ if (node.children.len > 0) {
432
+ return self.failNode(node, markup.terminal_children_message);
433
+ }
434
+ }
418
435
  // The a11y lint's error half: an unnamed interactive control
419
436
  // or a misused role ships a view a screen reader user cannot
420
437
  // operate, so it fails the build like any other markup
@@ -1136,6 +1153,74 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1136
1153
  return ui.chart(options, series);
1137
1154
  }
1138
1155
 
1156
+ // ---------------------------------------------------------- video
1157
+
1158
+ /// `<video src="assets/clips/intro.mp4" controls autoplay/>`:
1159
+ /// the video playback composite, lowered through `Ui.video` so
1160
+ /// markup videos get the same playback surface, house chrome,
1161
+ /// and declaration recording as Zig-built ones. A leaf with a
1162
+ /// closed attribute set; flags accept bare presence (the
1163
+ /// boolean-attribute convention), literals, and bindings.
1164
+ fn buildVideo(self: *Self, ui: *Ui, scope: *Scope, node: markup.MarkupNode) BuildError!Ui.Node {
1165
+ if (node.children.len > 0) {
1166
+ return self.failNode(node.children[0], markup.video_children_message);
1167
+ }
1168
+ var options: Ui.VideoOptions = .{};
1169
+ for (node.attrs) |attribute| {
1170
+ if (std.mem.eql(u8, attribute.name, "kind")) continue;
1171
+ if (std.mem.eql(u8, attribute.name, "src")) {
1172
+ options.src = try self.stringAttr(scope, node, attribute, markup.video_src_message);
1173
+ continue;
1174
+ }
1175
+ if (markup.videoFlagAttrName(attribute.name)) {
1176
+ const value = try self.videoFlagAttr(scope, node, attribute);
1177
+ if (std.mem.eql(u8, attribute.name, "controls")) {
1178
+ options.controls = value;
1179
+ } else if (std.mem.eql(u8, attribute.name, "autoplay")) {
1180
+ options.autoplay = value;
1181
+ } else if (std.mem.eql(u8, attribute.name, "loop")) {
1182
+ options.loop = value;
1183
+ } else {
1184
+ options.muted = value;
1185
+ }
1186
+ continue;
1187
+ }
1188
+ if (std.mem.eql(u8, attribute.name, "width")) {
1189
+ options.width = try self.floatAttr(scope, node, attribute);
1190
+ continue;
1191
+ }
1192
+ if (std.mem.eql(u8, attribute.name, "height")) {
1193
+ options.height = try self.floatAttr(scope, node, attribute);
1194
+ continue;
1195
+ }
1196
+ if (std.mem.eql(u8, attribute.name, "grow")) {
1197
+ options.grow = try self.floatAttr(scope, node, attribute);
1198
+ continue;
1199
+ }
1200
+ if (std.mem.eql(u8, attribute.name, "label")) {
1201
+ options.label = try self.stringAttr(scope, node, attribute, "label expects text");
1202
+ continue;
1203
+ }
1204
+ if (std.mem.eql(u8, attribute.name, "key")) {
1205
+ options.key = try self.attrKey(scope, node, attribute);
1206
+ continue;
1207
+ }
1208
+ if (std.mem.eql(u8, attribute.name, "global-key")) {
1209
+ options.global_key = try self.attrKey(scope, node, attribute);
1210
+ continue;
1211
+ }
1212
+ return self.failNode(node, markup.video_attr_message);
1213
+ }
1214
+ return ui.video(options);
1215
+ }
1216
+
1217
+ /// One video flag's value: bare presence declares true, a
1218
+ /// valued flag evaluates truthy like every other flag attr.
1219
+ fn videoFlagAttr(self: *Self, scope: *Scope, node: markup.MarkupNode, attribute: markup.MarkupAttr) BuildError!bool {
1220
+ if (attribute.value.len == 0) return true;
1221
+ return (try self.evalAttrExpression(scope, node, attribute)).truthy();
1222
+ }
1223
+
1139
1224
  fn buildSeries(self: *Self, ui: *Ui, scope: *Scope, node: markup.MarkupNode) BuildError!canvas.ChartSeries {
1140
1225
  if (node.children.len != 0) {
1141
1226
  return self.failVoid(node.children[0], markup.series_children_message);
@@ -1520,6 +1605,29 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1520
1605
  try self.applySurfaceAttr(scope, node, options, attribute);
1521
1606
  continue;
1522
1607
  }
1608
+ if (std.mem.eql(u8, attribute.name, "pty")) {
1609
+ try self.applyPtyAttr(scope, node, options, attribute);
1610
+ continue;
1611
+ }
1612
+ if (std.mem.eql(u8, attribute.name, "scrollback") and !std.mem.eql(u8, node.name, "terminal")) {
1613
+ // Terminal-scoped (the validator's rule, enforced
1614
+ // here too for unvalidated paths): anywhere else the
1615
+ // option would be silently inert data.
1616
+ return self.failVoid(node, markup.scrollback_element_message);
1617
+ }
1618
+ if (std.mem.eql(u8, attribute.name, "text") and std.mem.eql(u8, node.name, "terminal")) {
1619
+ // The terminal's text channel is runtime-owned (the
1620
+ // live screen); an authored value would clobber it
1621
+ // and rename the control every frame.
1622
+ return self.failVoid(node, markup.terminal_text_attr_message);
1623
+ }
1624
+ if (markup.videoFlagAttrName(attribute.name)) {
1625
+ // The video element's flags, video-scoped (its own
1626
+ // build consumed them): anywhere else they would be
1627
+ // silently inert. Mirrors the validator and the
1628
+ // compiled engine.
1629
+ return self.failVoid(node, markup.video_flag_element_message);
1630
+ }
1523
1631
  if (std.mem.eql(u8, attribute.name, "name")) {
1524
1632
  // Consumed by the icon branch in buildElement.
1525
1633
  if (!std.mem.eql(u8, node.name, "icon")) {
@@ -1634,6 +1742,30 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1634
1742
  };
1635
1743
  }
1636
1744
 
1745
+ /// `pty="{binding}"` on terminal: the model-owned u64 pty effect
1746
+ /// key whose session the terminal renders — terminal-only,
1747
+ /// binding-only, integer-valued (the media-surface `surface`
1748
+ /// grammar exactly). The key rides `options.pty` into
1749
+ /// `Widget.terminal.pty`.
1750
+ fn applyPtyAttr(self: *Self, scope: *Scope, node: markup.MarkupNode, options: *Ui.ElementOptions, attribute: markup.MarkupAttr) BuildError!void {
1751
+ if (!std.mem.eql(u8, node.name, "terminal")) {
1752
+ return self.failVoid(node, markup.terminal_pty_element_message);
1753
+ }
1754
+ const typed = markup.attrTyped(attribute);
1755
+ if (typed != .binding) return self.failVoid(node, markup.terminal_pty_message);
1756
+ const value = try self.evalBinding(scope, node, typed.binding, true);
1757
+ // Range-checked before the u64 cast: expression values are
1758
+ // i64, so a signed model field can deliver a negative — the
1759
+ // teaching failure, never a trap.
1760
+ options.pty = switch (value) {
1761
+ .integer => |int| if (int < 0)
1762
+ return self.failVoid(node, markup.terminal_pty_message)
1763
+ else
1764
+ @intCast(int),
1765
+ else => return self.failVoid(node, markup.terminal_pty_message),
1766
+ };
1767
+ }
1768
+
1637
1769
  /// `icon="save"` on button, toggle-button, list-item, or
1638
1770
  /// menu-item: the same icon value grammar as `<icon name>` — a
1639
1771
  /// built-in literal can never rot silently, app:<name> and one
@@ -1784,10 +1916,28 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1784
1916
  return self.failVoid(node, markup.on_scroll_element_message);
1785
1917
  }
1786
1918
  options.on_scroll = scrollConstructor(expression.tag) orelse {
1919
+ // The retired one-axis record gets the migration
1920
+ // teaching (it names the new per-axis fields) instead
1921
+ // of the generic payload rejection.
1922
+ if (legacyScrollTag(expression.tag)) {
1923
+ return self.failVoid(node, markup.on_scroll_legacy_payload_message);
1924
+ }
1787
1925
  return self.failVoid(node, markup.on_scroll_payload_message);
1788
1926
  };
1789
1927
  return;
1790
1928
  }
1929
+ if (std.mem.eql(u8, event, "terminal")) {
1930
+ if (!std.mem.eql(u8, node.name, "terminal")) {
1931
+ return self.failVoid(node, markup.on_terminal_element_message);
1932
+ }
1933
+ // Bare tag only: the runtime supplies the TerminalState,
1934
+ // so an authored payload would be silently discarded.
1935
+ if (expression.payload.len > 0) return self.failVoid(node, markup.on_terminal_payload_message);
1936
+ options.on_terminal = terminalConstructor(expression.tag) orelse {
1937
+ return self.failVoid(node, markup.on_terminal_payload_message);
1938
+ };
1939
+ return;
1940
+ }
1791
1941
  if (std.mem.eql(u8, event, "resize")) {
1792
1942
  if (!std.mem.eql(u8, node.name, "split")) {
1793
1943
  return self.failVoid(node, markup.on_resize_element_message);
@@ -1830,6 +1980,13 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1830
1980
  // Press family: like on-press, a bound hold makes any
1831
1981
  // element pressable.
1832
1982
  options.on_hold = msg;
1983
+ } else if (std.mem.eql(u8, event, "hover-enter")) {
1984
+ // Hover family: binding either edge makes any element
1985
+ // hover-hittable (never pressable), so both are legal
1986
+ // everywhere like the press family.
1987
+ options.on_hover_enter = msg;
1988
+ } else if (std.mem.eql(u8, event, "hover-leave")) {
1989
+ options.on_hover_leave = msg;
1833
1990
  } else if (std.mem.eql(u8, event, "reach-end")) {
1834
1991
  // The approach-end signal (infinite-scroll fetch) is
1835
1992
  // emitted for scroll containers only.
@@ -1937,6 +2094,38 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1937
2094
  return null;
1938
2095
  }
1939
2096
 
2097
+ fn terminalConstructor(tag: []const u8) ?Ui.TerminalMsgFn {
2098
+ @setEvalBranchQuota(scan_quota);
2099
+ inline for (@typeInfo(MsgT).@"union".fields) |field| {
2100
+ if (field.type == canvas.TerminalState) {
2101
+ if (std.mem.eql(u8, field.name, tag)) {
2102
+ return Ui.terminalMsg(@field(std.meta.Tag(MsgT), field.name));
2103
+ }
2104
+ } else if (comptime reflect.declaredTerminalStateRecord(field.type)) {
2105
+ // A declared mirror of the terminal-state record
2106
+ // (transpiled cores): translated at dispatch, same
2107
+ // handler shape.
2108
+ if (std.mem.eql(u8, field.name, tag)) {
2109
+ return Ui.translatedTerminalMsg(@field(std.meta.Tag(MsgT), field.name), field.type);
2110
+ }
2111
+ }
2112
+ }
2113
+ return null;
2114
+ }
2115
+
2116
+ /// Whether `tag` names an arm carrying the RETIRED one-axis
2117
+ /// scroll record — recognized only so the on-scroll rejection
2118
+ /// can teach the two-axis migration by field name.
2119
+ fn legacyScrollTag(tag: []const u8) bool {
2120
+ @setEvalBranchQuota(scan_quota);
2121
+ inline for (@typeInfo(MsgT).@"union".fields) |field| {
2122
+ if (comptime reflect.declaredLegacyScrollStateRecord(field.type)) {
2123
+ if (std.mem.eql(u8, field.name, tag)) return true;
2124
+ }
2125
+ }
2126
+ return false;
2127
+ }
2128
+
1940
2129
  fn resizeConstructor(tag: []const u8) ?Ui.ValueMsgFn {
1941
2130
  @setEvalBranchQuota(scan_quota);
1942
2131
  inline for (@typeInfo(MsgT).@"union".fields) |field| {
@@ -2284,6 +2473,8 @@ pub const typeScanQuota = reflect.typeScanQuota;
2284
2473
  pub const Pointee = reflect.Pointee;
2285
2474
  pub const declaredTextInputUnion = reflect.declaredTextInputUnion;
2286
2475
  pub const declaredScrollStateRecord = reflect.declaredScrollStateRecord;
2476
+ pub const declaredTerminalStateRecord = reflect.declaredTerminalStateRecord;
2477
+ pub const declaredLegacyScrollStateRecord = reflect.declaredLegacyScrollStateRecord;
2287
2478
  pub const valueArmClass = reflect.valueArmClass;
2288
2479
  pub const sliceElement = reflect.sliceElement;
2289
2480
  pub const isItemFn = reflect.isItemFn;