@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
@@ -1117,7 +1117,8 @@ pub const known_events = schema.event_names;
1117
1117
 
1118
1118
  pub const on_scroll_element_message = "on-scroll is only supported on scroll - the runtime emits scroll offsets for scroll containers, so the handler belongs on the scroll element itself";
1119
1119
  pub const on_reach_end_element_message = "on-reach-end is only supported on scroll - the runtime emits the approach-end signal for scroll containers, so the handler belongs on the scroll element itself";
1120
- pub const on_scroll_payload_message = "on-scroll takes a bare Msg tag whose payload is the post-scroll state (a canvas.ScrollState variant, like activity_scrolled: canvas.ScrollState, or a declared record of its offset/velocity/viewport_extent/content_extent fields for transpiled cores)";
1120
+ pub const on_scroll_payload_message = "on-scroll takes a bare Msg tag whose payload is the post-scroll state (a canvas.ScrollState variant, like activity_scrolled: canvas.ScrollState, or a declared record of its offset_x/offset_y/velocity_x/velocity_y/viewport_extent_x/viewport_extent_y/content_extent_x/content_extent_y fields for transpiled cores)";
1121
+ pub const on_scroll_legacy_payload_message = "on-scroll payloads are two-axis now: the one-axis {offset, velocity, viewport_extent, content_extent} record was replaced by per-axis fields - declare offset_x/offset_y, velocity_x/velocity_y, viewport_extent_x/viewport_extent_y, content_extent_x/content_extent_y (TS cores: offsetX/offsetY, velocityX/velocityY, viewportExtentX/viewportExtentY, contentExtentX/contentExtentY); a vertical list reads the _y fields where it read the old ones";
1121
1122
 
1122
1123
  pub const on_resize_element_message = "on-resize is only supported on split - the runtime emits fraction changes for split dividers, so the handler belongs on the split element itself";
1123
1124
  pub const on_resize_payload_message = "on-resize takes a bare Msg tag whose payload is the new first-pane fraction (an f32 variant, like sidebar_resized: f32; transpiled cores declare a one-number float arm)";
@@ -1224,6 +1225,22 @@ pub const overscroll_value_names = [_][]const u8{ "default", "none", "rubber_ban
1224
1225
 
1225
1226
  pub const overscroll_value_message = "unknown overscroll value - scroll takes default (follow the ScrollPhysics.overscroll token, off unless a theme flips it), none (pin at the content edges), or rubber_band (bounce past them)";
1226
1227
 
1228
+ pub const axis_element_message = "axis is only supported on scroll - it declares which axes the region scrolls (vertical, horizontal, or both); anywhere else it would be silently inert";
1229
+
1230
+ /// The `axis` attribute's closed value vocabulary: the member names of
1231
+ /// `canvas.ScrollAxes`, mirrored as data here (this layer stays
1232
+ /// std-only) with a lockstep test in ui_markup_view_tests.zig holding
1233
+ /// the mirror equal to the live enum.
1234
+ pub const axis_value_names = [_][]const u8{ "vertical", "horizontal", "both" };
1235
+
1236
+ pub const axis_value_message = "unknown axis value - scroll takes vertical (the default), horizontal, or both";
1237
+
1238
+ pub const axis_virtualized_message = "a horizontal axis grant is not supported on a virtualized scroll - windowed virtualization prices rows, not columns, so a virtual list always scrolls vertically (axis=\"vertical\" stays legal beside virtualized)";
1239
+
1240
+ pub const value_x_element_message = "value-x is only supported on scroll - it is the horizontal scroll offset (the sideways counterpart of value); anywhere else it would be silently inert";
1241
+
1242
+ pub const value_x_dependent_attr_message = "value-x needs axis=\"horizontal\" or axis=\"both\" on the same scroll - a vertical-only region never applies a horizontal offset, so without the axis grant it is silently inert";
1243
+
1227
1244
  pub const resize_duration_element_message = "resize-duration is only supported on split - it declares the split's layout tween (milliseconds; 0 snaps, the default): a rebuild that moves the bound value eases the rendered fraction there instead of snapping; anywhere else it would be silently inert";
1228
1245
 
1229
1246
  pub const resize_easing_element_message = "resize-easing is only supported on split - it names the easing curve of the split's layout tween (linear, standard, emphasized, spring); anywhere else it would be silently inert";
@@ -1255,6 +1272,20 @@ pub const media_surface_surface_message = "surface takes one {binding} to the u6
1255
1272
  pub const media_surface_surface_element_message = "surface is only supported on media-surface - it names the producer rendezvous of the media surface's texture channel; anywhere else it would be silently inert";
1256
1273
  pub const media_surface_missing_surface_message = "media-surface requires surface={binding} naming the u64 surface id its producer targets - without one the surface can never show anything (dead markup, same policy as icon without name)";
1257
1274
 
1275
+ pub const terminal_pty_message = "pty on terminal takes the model-owned pty effect key - one {binding} resolving to the u64 key the app's ptySpawn named (pty keys are model data, never markup literals; 0 leaves the terminal unbound and it renders the empty surface)";
1276
+ pub const terminal_pty_element_message = "pty is only supported on terminal - it binds the pty effect key whose session the terminal renders; anywhere else it would be silently inert";
1277
+ pub const terminal_missing_pty_message = "terminal requires pty={binding} naming the model-owned u64 pty effect key its session rides - without one the terminal can never attach a session (dead markup, same policy as media-surface without surface)";
1278
+ pub const terminal_children_message = "terminal is a leaf - it takes no children";
1279
+ pub const terminal_text_attr_message = "terminal's text channel is runtime-owned (the live screen rides it for assistive tech), so a text attribute would be overwritten every frame - name the terminal with label instead";
1280
+ pub const scrollback_element_message = "scrollback is only supported on terminal - it is the scrollback offset in rows above the live screen (echo on-terminal's scrollback back here, the scroll value reconcile shape); anywhere else it would be silently inert";
1281
+ pub const on_terminal_element_message = "on-terminal is only supported on terminal - the runtime emits terminal view state for terminal elements, so the handler belongs on the terminal element itself";
1282
+ pub const on_terminal_payload_message = "on-terminal takes a bare Msg tag whose payload is the post-change terminal view state (a canvas.TerminalState variant, like term_state: canvas.TerminalState, or a declared record of its scrollback/history/cols/rows fields for transpiled cores)";
1283
+
1284
+ pub const video_children_message = "video is a leaf - it takes no children";
1285
+ pub const video_attr_message = "unknown attribute for video - it takes src, controls, autoplay, loop, muted, width, height, grow, label, key, and global-key";
1286
+ pub const video_src_message = "src on video takes the playback source string - an app-assets path or an http(s) URL (a literal, or one {binding} resolving to a string)";
1287
+ pub const video_flag_element_message = "controls, autoplay, loop, and muted are only supported on video - they compose the house transport chrome and shape the fresh playback the element's src declares; anywhere else they would be silently inert";
1288
+
1258
1289
  /// The built-in vector icon vocabulary behind `<icon name="..."/>`.
1259
1290
  /// Registry section mirroring `canvas.icons.known_icon_names` (the
1260
1291
  /// comptime-parsed registry; this layer stays std-only); a test in
@@ -2719,10 +2750,63 @@ fn validateReactions(node: MarkupNode) ?MarkupErrorInfo {
2719
2750
  return null;
2720
2751
  }
2721
2752
 
2753
+ /// The video element's flag attributes (controls/autoplay/loop/muted).
2754
+ /// Pub and comptime-callable: the validator and BOTH engines share the
2755
+ /// set, so the video-only scoping teaching can never drift.
2756
+ pub fn videoFlagAttrName(name: []const u8) bool {
2757
+ return std.mem.eql(u8, name, "controls") or std.mem.eql(u8, name, "autoplay") or
2758
+ std.mem.eql(u8, name, "loop") or std.mem.eql(u8, name, "muted");
2759
+ }
2760
+
2761
+ /// `<video>` — the video playback composite: a LEAF (the playback
2762
+ /// surface plus runtime-owned transport chrome; widget layout gives it
2763
+ /// no child slots, so nested content would silently vanish — rejected
2764
+ /// like image and icon) with a closed attribute set. `src` is OPTIONAL:
2765
+ /// a src-less video is surface-only chrome over whatever playback the
2766
+ /// app loaded itself, so the dead-markup policy does not apply. Flags
2767
+ /// accept bare presence (the boolean-attribute convention), a literal
2768
+ /// true/false, or a {binding}.
2769
+ fn validateVideo(node: MarkupNode) ?MarkupErrorInfo {
2770
+ for (node.children) |child| {
2771
+ return errorAt(child, video_children_message);
2772
+ }
2773
+ for (node.attrs) |attribute| {
2774
+ if (std.mem.eql(u8, attribute.name, "src")) {
2775
+ if (attrExpressionError(attribute.value, video_src_message)) |message| {
2776
+ return attrError(node, attribute, message);
2777
+ }
2778
+ continue;
2779
+ }
2780
+ if (videoFlagAttrName(attribute.name)) {
2781
+ // Bare presence declares true; a valued flag is an
2782
+ // expression like any other flag attribute.
2783
+ if (attribute.value.len == 0) continue;
2784
+ if (attrExpressionError(attribute.value, invalid_expression_message)) |message| {
2785
+ return attrError(node, attribute, message);
2786
+ }
2787
+ continue;
2788
+ }
2789
+ const known = std.mem.eql(u8, attribute.name, "width") or
2790
+ std.mem.eql(u8, attribute.name, "height") or
2791
+ std.mem.eql(u8, attribute.name, "grow") or
2792
+ std.mem.eql(u8, attribute.name, "label") or
2793
+ std.mem.eql(u8, attribute.name, "key") or
2794
+ std.mem.eql(u8, attribute.name, "global-key");
2795
+ if (!known) {
2796
+ return attrError(node, attribute, video_attr_message);
2797
+ }
2798
+ if (attrExpressionError(attribute.value, invalid_expression_message)) |message| {
2799
+ return attrError(node, attribute, message);
2800
+ }
2801
+ if (attrCoverageError(node, attribute)) |info| return info;
2802
+ }
2803
+ return null;
2804
+ }
2805
+
2722
2806
  /// The rule hooks the composite registry entries name. A registry entry
2723
2807
  /// whose hook this table does not implement is a compile error (below),
2724
2808
  /// so attachment and implementation can never drift.
2725
- const rule_hook_names = [_][]const u8{ "markdown", "stepper", "step", "timeline", "timeline-item", "chart", "series", "context-menu", "input-group", "input-group-actions", "span", "reactions" };
2809
+ const rule_hook_names = [_][]const u8{ "markdown", "stepper", "step", "timeline", "timeline-item", "chart", "series", "context-menu", "input-group", "input-group-actions", "span", "reactions", "video" };
2726
2810
 
2727
2811
  comptime {
2728
2812
  for (schema.elements) |entry| {
@@ -2787,6 +2871,7 @@ fn validateRuleHook(hook: []const u8, document: MarkupDocument, node: MarkupNode
2787
2871
  // pass; one reaching the generic pass sits outside a bubble.
2788
2872
  return errorAt(node, reactions_parent_message);
2789
2873
  }
2874
+ if (std.mem.eql(u8, hook, "video")) return validateVideo(node);
2790
2875
  // The comptime check above proves every registry hook lands in one of
2791
2876
  // the branches; a name reaching here is not a registry hook at all.
2792
2877
  unreachable;
@@ -2939,6 +3024,23 @@ fn validateNode(document: MarkupDocument, node: MarkupNode, parent_element: ?[]c
2939
3024
  // teaching (the icon-without-name policy).
2940
3025
  if (node.attr("surface") == null) return errorAt(node, media_surface_missing_surface_message);
2941
3026
  }
3027
+ if (std.mem.eql(u8, node.name, "terminal")) {
3028
+ // A terminal without its pty binding can never attach a
3029
+ // session: the same dead-markup policy as media-surface.
3030
+ if (node.attr("pty") == null) return errorAt(node, terminal_missing_pty_message);
3031
+ // A leaf like icon and image: the widget gives a
3032
+ // terminal no child slots, so nested content would
3033
+ // silently vanish - rejected instead.
3034
+ if (node.children.len > 0) return errorAt(node.children[0], terminal_children_message);
3035
+ // The text channel is runtime-owned (the live screen
3036
+ // text rides it), so an authored text attribute would be
3037
+ // overwritten every frame — and worse, it would satisfy
3038
+ // the accessible-name lint with a name the runtime then
3039
+ // replaces. The name comes from label.
3040
+ if (node.attrEntry("text")) |attribute| {
3041
+ return attrError(node, attribute, terminal_text_attr_message);
3042
+ }
3043
+ }
2942
3044
  if (std.mem.eql(u8, node.name, "image")) {
2943
3045
  // An image leaf without its id binding can never draw:
2944
3046
  // the same dead-markup policy as media-surface.
@@ -2982,6 +3084,13 @@ fn validateNode(document: MarkupDocument, node: MarkupNode, parent_element: ?[]c
2982
3084
  if (!std.mem.eql(u8, node.name, "scroll")) {
2983
3085
  return attrError(node, attribute, on_scroll_element_message);
2984
3086
  }
3087
+ } else if (std.mem.eql(u8, attribute.name, "on-terminal")) {
3088
+ // The runtime emits terminal view state for
3089
+ // terminal elements only; anywhere else the
3090
+ // handler could never fire.
3091
+ if (!std.mem.eql(u8, node.name, "terminal")) {
3092
+ return attrError(node, attribute, on_terminal_element_message);
3093
+ }
2985
3094
  } else if (std.mem.eql(u8, attribute.name, "on-dismiss")) {
2986
3095
  // Only dismissible surfaces are ever dismissed by
2987
3096
  // the runtime; anywhere else the Msg could never
@@ -3099,6 +3208,25 @@ fn validateNode(document: MarkupDocument, node: MarkupNode, parent_element: ?[]c
3099
3208
  }
3100
3209
  continue;
3101
3210
  }
3211
+ if (std.mem.eql(u8, attribute.name, "pty")) {
3212
+ // The terminal's pty rendezvous, terminal scoped: pty
3213
+ // keys are model data the app's ptySpawn named, never
3214
+ // markup literals (the surface grammar exactly).
3215
+ if (!std.mem.eql(u8, node.name, "terminal")) {
3216
+ return attrError(node, attribute, terminal_pty_element_message);
3217
+ }
3218
+ const expression = parseAttrExpression(attribute.value);
3219
+ if (expression == null or expression.? != .binding) {
3220
+ return attrError(node, attribute, terminal_pty_message);
3221
+ }
3222
+ continue;
3223
+ }
3224
+ if (videoFlagAttrName(attribute.name)) {
3225
+ // The video element's flags, video-scoped (its rule
3226
+ // hook consumed them before this pass): anywhere
3227
+ // else they would be silently inert.
3228
+ return attrError(node, attribute, video_flag_element_message);
3229
+ }
3102
3230
  if (std.mem.eql(u8, attribute.name, "anchor")) {
3103
3231
  // Anchored floating placement, dropdown-menu-scoped:
3104
3232
  // a literal side so the compiled engine resolves it
@@ -3168,6 +3296,15 @@ fn validateNode(document: MarkupDocument, node: MarkupNode, parent_element: ?[]c
3168
3296
  }
3169
3297
  }
3170
3298
  }
3299
+ if (std.mem.eql(u8, attribute.name, "scrollback")) {
3300
+ // The scrollback offset exists only where an emulator
3301
+ // scrolls: anywhere but a terminal the option is
3302
+ // silently inert (same policy as overscroll off
3303
+ // scroll).
3304
+ if (!std.mem.eql(u8, node.name, "terminal")) {
3305
+ return attrError(node, attribute, scrollback_element_message);
3306
+ }
3307
+ }
3171
3308
  if (std.mem.eql(u8, attribute.name, "overscroll")) {
3172
3309
  // Edge behavior exists only where the runtime scrolls:
3173
3310
  // anywhere but a scroll container the option is
@@ -3185,6 +3322,62 @@ fn validateNode(document: MarkupDocument, node: MarkupNode, parent_element: ?[]c
3185
3322
  }
3186
3323
  }
3187
3324
  }
3325
+ if (std.mem.eql(u8, attribute.name, "axis")) {
3326
+ // Axes exist only where the runtime scrolls: anywhere
3327
+ // but a scroll container the option is silently inert
3328
+ // (same policy as overscroll off scroll).
3329
+ if (!std.mem.eql(u8, node.name, "scroll")) {
3330
+ return attrError(node, attribute, axis_element_message);
3331
+ }
3332
+ // The closed value vocabulary, checked on literals
3333
+ // here so the teaching error lands at validation
3334
+ // (bindings resolve at build, where the engines
3335
+ // enforce the same set).
3336
+ if (parseAttrExpression(attribute.value)) |expression| {
3337
+ if (expression == .literal and !nameInList(expression.literal, &axis_value_names)) {
3338
+ return attrError(node, attribute, axis_value_message);
3339
+ }
3340
+ // Windowed virtualization is vertical machinery:
3341
+ // a horizontal GRANT on a virtualized scroll
3342
+ // would be silently ignored, so exactly that
3343
+ // pairing is a teaching error. A literal vertical
3344
+ // axis stays legal beside virtualized, as does a
3345
+ // grant beside a literal virtualized="false";
3346
+ // binding-valued sides resolve at build.
3347
+ if (expression == .literal and !std.mem.eql(u8, expression.literal, "vertical")) {
3348
+ if (node.attr("virtualized")) |virtualized_raw| {
3349
+ const virtualized_off = if (parseAttrExpression(virtualized_raw)) |virtualized_expression|
3350
+ virtualized_expression != .literal or std.mem.eql(u8, virtualized_expression.literal, "false")
3351
+ else
3352
+ false;
3353
+ if (!virtualized_off) {
3354
+ return attrError(node, attribute, axis_virtualized_message);
3355
+ }
3356
+ }
3357
+ }
3358
+ }
3359
+ }
3360
+ if (std.mem.eql(u8, attribute.name, "value-x")) {
3361
+ // The horizontal offset exists only where the runtime
3362
+ // scrolls sideways: anywhere but a scroll container
3363
+ // it is silently inert.
3364
+ if (!std.mem.eql(u8, node.name, "scroll")) {
3365
+ return attrError(node, attribute, value_x_element_message);
3366
+ }
3367
+ // An offset on an axis the region never grants is
3368
+ // silently inert, so it is a teaching error (the
3369
+ // resize-easing-needs-duration policy). A
3370
+ // binding-valued axis cannot exist (axis takes the
3371
+ // closed literal set), so the literal check is total.
3372
+ const axis_raw = node.attr("axis") orelse {
3373
+ return attrError(node, attribute, value_x_dependent_attr_message);
3374
+ };
3375
+ if (parseAttrExpression(axis_raw)) |axis_expression| {
3376
+ if (axis_expression == .literal and std.mem.eql(u8, axis_expression.literal, "vertical")) {
3377
+ return attrError(node, attribute, value_x_dependent_attr_message);
3378
+ }
3379
+ }
3380
+ }
3188
3381
  if (std.mem.eql(u8, attribute.name, "quiet-hover")) {
3189
3382
  // The hover wash exists only on hit-tested elements:
3190
3383
  // anywhere else the knob is silently inert (same
@@ -283,6 +283,9 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
283
283
  // Series inside a chart are consumed by buildChart.
284
284
  comptime fail(node, markup.series_parent_message);
285
285
  }
286
+ if (comptime std.mem.eql(u8, node.name, "video")) {
287
+ return buildVideo(node, entries, ui, model, scope);
288
+ }
286
289
  if (comptime std.mem.eql(u8, node.name, "context-menu")) {
287
290
  // Direct context-menu children are consumed by their host
288
291
  // element below; one reaching here is misplaced.
@@ -420,6 +423,16 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
420
423
  fail(node, markup.image_children_message);
421
424
  }
422
425
  }
426
+ // Interpreter parity: the terminal leaf's static shape —
427
+ // pty required (dead markup without it), no children.
428
+ if (kind == .terminal) {
429
+ if (node.attr("pty") == null) {
430
+ fail(node, markup.terminal_missing_pty_message);
431
+ }
432
+ if (node.children.len > 0) {
433
+ fail(node, markup.terminal_children_message);
434
+ }
435
+ }
423
436
  // Interpreter parity: the a11y lint's error half — an
424
437
  // unnamed interactive control or a misused role ships a
425
438
  // view a screen reader user cannot operate, so it is a
@@ -1232,6 +1245,72 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
1232
1245
  return series;
1233
1246
  }
1234
1247
 
1248
+ // ---------------------------------------------------------- video
1249
+
1250
+ /// Comptime mirror of the interpreter's `buildVideo`: the leaf
1251
+ /// shape and the closed attribute set resolve at comptime with
1252
+ /// the interpreter's messages; the src string, flags, and
1253
+ /// sizing evaluate at runtime and lower through `Ui.video`.
1254
+ fn buildVideo(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype) Ui.Node {
1255
+ comptime {
1256
+ if (node.children.len > 0) fail(node.children[0], markup.video_children_message);
1257
+ for (node.attrs) |attribute| {
1258
+ if (std.mem.eql(u8, attribute.name, "kind")) continue;
1259
+ const known = std.mem.eql(u8, attribute.name, "src") or
1260
+ markup.videoFlagAttrName(attribute.name) or
1261
+ std.mem.eql(u8, attribute.name, "width") or
1262
+ std.mem.eql(u8, attribute.name, "height") or
1263
+ std.mem.eql(u8, attribute.name, "grow") or
1264
+ std.mem.eql(u8, attribute.name, "label") or
1265
+ std.mem.eql(u8, attribute.name, "key") or
1266
+ std.mem.eql(u8, attribute.name, "global-key");
1267
+ if (!known) fail(node, markup.video_attr_message);
1268
+ }
1269
+ }
1270
+ var options: Ui.VideoOptions = .{};
1271
+ if (comptime (node.attr("src") != null)) {
1272
+ options.src = stringAttr(node, entries, comptime node.attr("src").?, ui, model, scope, markup.video_src_message);
1273
+ }
1274
+ if (comptime (node.attr("controls") != null)) {
1275
+ options.controls = videoFlagValue(node, entries, comptime node.attr("controls").?, ui, model, scope);
1276
+ }
1277
+ if (comptime (node.attr("autoplay") != null)) {
1278
+ options.autoplay = videoFlagValue(node, entries, comptime node.attr("autoplay").?, ui, model, scope);
1279
+ }
1280
+ if (comptime (node.attr("loop") != null)) {
1281
+ options.loop = videoFlagValue(node, entries, comptime node.attr("loop").?, ui, model, scope);
1282
+ }
1283
+ if (comptime (node.attr("muted") != null)) {
1284
+ options.muted = videoFlagValue(node, entries, comptime node.attr("muted").?, ui, model, scope);
1285
+ }
1286
+ if (comptime (node.attr("width") != null)) {
1287
+ options.width = floatAttr(node, entries, comptime node.attr("width").?, ui, model, scope);
1288
+ }
1289
+ if (comptime (node.attr("height") != null)) {
1290
+ options.height = floatAttr(node, entries, comptime node.attr("height").?, ui, model, scope);
1291
+ }
1292
+ if (comptime (node.attr("grow") != null)) {
1293
+ options.grow = floatAttr(node, entries, comptime node.attr("grow").?, ui, model, scope);
1294
+ }
1295
+ if (comptime (node.attr("label") != null)) {
1296
+ options.label = stringAttr(node, entries, comptime node.attr("label").?, ui, model, scope, "label expects text");
1297
+ }
1298
+ if (comptime (node.attr("key") != null)) {
1299
+ options.key = attrKey(node, entries, comptime node.attr("key").?, ui, model, scope, "keys must be integers or strings");
1300
+ }
1301
+ if (comptime (node.attr("global-key") != null)) {
1302
+ options.global_key = attrKey(node, entries, comptime node.attr("global-key").?, ui, model, scope, "keys must be integers or strings");
1303
+ }
1304
+ return ui.video(options);
1305
+ }
1306
+
1307
+ /// One video flag's value (interpreter parity): bare presence
1308
+ /// declares true, a valued flag evaluates truthy.
1309
+ fn videoFlagValue(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype) bool {
1310
+ if (comptime (raw.len == 0)) return true;
1311
+ return evalExpr(node, entries, raw, ui, model, scope).truthy();
1312
+ }
1313
+
1235
1314
  /// Resolve a chart `x-labels` binding through the same sources
1236
1315
  /// `for each` accepts, requiring a string element type at
1237
1316
  /// comptime — the label twin of `chartValuesItems`.
@@ -1606,6 +1685,21 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
1606
1685
  applyImageAttr(node, attribute.value, entries, ui, model, scope, options);
1607
1686
  } else if (comptime std.mem.eql(u8, attribute.name, "surface")) {
1608
1687
  applySurfaceAttr(node, attribute.value, entries, ui, model, scope, options);
1688
+ } else if (comptime std.mem.eql(u8, attribute.name, "pty")) {
1689
+ applyPtyAttr(node, attribute.value, entries, ui, model, scope, options);
1690
+ } else if (comptime (std.mem.eql(u8, attribute.name, "scrollback") and !std.mem.eql(u8, node.name, "terminal"))) {
1691
+ // Terminal-scoped (validator parity for unvalidated
1692
+ // paths): anywhere else the option is inert data.
1693
+ comptime fail(node, markup.scrollback_element_message);
1694
+ } else if (comptime (std.mem.eql(u8, attribute.name, "text") and std.mem.eql(u8, node.name, "terminal"))) {
1695
+ // Runtime-owned text channel (interpreter and
1696
+ // validator parity).
1697
+ comptime fail(node, markup.terminal_text_attr_message);
1698
+ } else if (comptime markup.videoFlagAttrName(attribute.name)) {
1699
+ // The video element's flags, video-scoped (its own
1700
+ // build consumed them): anywhere else they would be
1701
+ // silently inert (interpreter and validator parity).
1702
+ comptime fail(node, markup.video_flag_element_message);
1609
1703
  } else if (comptime std.mem.eql(u8, attribute.name, "name")) {
1610
1704
  // Consumed by the icon branch in buildElement; a
1611
1705
  // compile error on any other element (interpreter and
@@ -1716,6 +1810,29 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
1716
1810
  };
1717
1811
  }
1718
1812
 
1813
+ /// `pty="{binding}"` on terminal resolves to the model-owned u64
1814
+ /// pty effect key whose session the terminal renders —
1815
+ /// terminal-only, binding-only, integer-valued, all checked at
1816
+ /// comptime with the interpreter's messages (the media-surface
1817
+ /// `surface` grammar exactly). The key rides `options.pty` into
1818
+ /// `Widget.terminal.pty`.
1819
+ fn applyPtyAttr(comptime node: markup.MarkupNode, comptime raw: []const u8, comptime entries: []const ScopeEntry, ui: *Ui, model: *const ModelT, scope: anytype, options: *Ui.ElementOptions) void {
1820
+ comptime {
1821
+ if (!std.mem.eql(u8, node.name, "terminal")) fail(node, markup.terminal_pty_element_message);
1822
+ const expression = markup.parseAttrExpression(raw) orelse fail(node, markup.terminal_pty_message);
1823
+ if (expression != .binding) fail(node, markup.terminal_pty_message);
1824
+ }
1825
+ const path = comptime markup.parseAttrExpression(raw).?.binding;
1826
+ comptime requireVariant(pathVariant(node, entries, path, true), &.{.integer}, node, markup.terminal_pty_message);
1827
+ // Range-checked before the u64 cast (the interpreter fails
1828
+ // the same way): a signed model field can deliver a negative
1829
+ // — fail the build, never trap.
1830
+ options.pty = switch (bindingValue(node, entries, path, ui, model, scope, true)) {
1831
+ .integer => |int| if (int < 0) runtimeFail(u64, ui) else @intCast(int),
1832
+ else => runtimeFail(u64, ui),
1833
+ };
1834
+ }
1835
+
1719
1836
  fn colorStyleField(comptime attr_name: []const u8) ?[]const u8 {
1720
1837
  comptime {
1721
1838
  @setEvalBranchQuota(10_000);
@@ -1860,7 +1977,21 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
1860
1977
  comptime {
1861
1978
  if (!std.mem.eql(u8, node.name, "scroll")) fail(node, markup.on_scroll_element_message);
1862
1979
  }
1863
- options.on_scroll = comptime (scrollConstructor(expression.tag) orelse fail(node, markup.on_scroll_payload_message));
1980
+ options.on_scroll = comptime (scrollConstructor(expression.tag) orelse
1981
+ // The retired one-axis record gets the migration
1982
+ // teaching (it names the new per-axis fields) instead
1983
+ // of the generic payload rejection.
1984
+ fail(node, if (legacyScrollTag(expression.tag)) markup.on_scroll_legacy_payload_message else markup.on_scroll_payload_message));
1985
+ return;
1986
+ }
1987
+ if (comptime std.mem.eql(u8, event, "terminal")) {
1988
+ comptime {
1989
+ if (!std.mem.eql(u8, node.name, "terminal")) fail(node, markup.on_terminal_element_message);
1990
+ // Bare tag only: the runtime supplies the payload, so
1991
+ // an authored one would be silently discarded.
1992
+ if (expression.payload.len > 0) fail(node, markup.on_terminal_payload_message);
1993
+ }
1994
+ options.on_terminal = comptime (terminalConstructor(expression.tag) orelse fail(node, markup.on_terminal_payload_message));
1864
1995
  return;
1865
1996
  }
1866
1997
  if (comptime std.mem.eql(u8, event, "resize")) {
@@ -1901,6 +2032,13 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
1901
2032
  // Press family: like on-press, a bound hold makes any
1902
2033
  // element pressable.
1903
2034
  options.on_hold = msg;
2035
+ } else if (comptime std.mem.eql(u8, event, "hover-enter")) {
2036
+ // Hover family: binding either edge makes any element
2037
+ // hover-hittable (never pressable), so both are legal
2038
+ // everywhere like the press family (interpreter parity).
2039
+ options.on_hover_enter = msg;
2040
+ } else if (comptime std.mem.eql(u8, event, "hover-leave")) {
2041
+ options.on_hover_leave = msg;
1904
2042
  } else if (comptime std.mem.eql(u8, event, "reach-end")) {
1905
2043
  // The approach-end signal (infinite-scroll fetch) is
1906
2044
  // emitted for scroll containers only (interpreter and
@@ -1951,6 +2089,39 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
1951
2089
  }
1952
2090
  }
1953
2091
 
2092
+ fn terminalConstructor(comptime tag: []const u8) ?Ui.TerminalMsgFn {
2093
+ comptime {
2094
+ @setEvalBranchQuota(10_000);
2095
+ for (@typeInfo(MsgT).@"union".fields) |field| {
2096
+ if (field.type == canvas.TerminalState and std.mem.eql(u8, field.name, tag)) {
2097
+ return Ui.terminalMsg(@field(std.meta.Tag(MsgT), field.name));
2098
+ }
2099
+ // A declared mirror of the terminal-state record
2100
+ // (transpiled cores): translated at dispatch, same
2101
+ // handler shape.
2102
+ if (interpreter.declaredTerminalStateRecord(field.type) and std.mem.eql(u8, field.name, tag)) {
2103
+ return Ui.translatedTerminalMsg(@field(std.meta.Tag(MsgT), field.name), field.type);
2104
+ }
2105
+ }
2106
+ return null;
2107
+ }
2108
+ }
2109
+
2110
+ /// Whether `tag` names an arm carrying the RETIRED one-axis
2111
+ /// scroll record — recognized only so the on-scroll rejection
2112
+ /// can teach the two-axis migration by field name.
2113
+ fn legacyScrollTag(comptime tag: []const u8) bool {
2114
+ comptime {
2115
+ @setEvalBranchQuota(10_000);
2116
+ for (@typeInfo(MsgT).@"union".fields) |field| {
2117
+ if (interpreter.declaredLegacyScrollStateRecord(field.type) and std.mem.eql(u8, field.name, tag)) {
2118
+ return true;
2119
+ }
2120
+ }
2121
+ return false;
2122
+ }
2123
+ }
2124
+
1954
2125
  fn resizeConstructor(comptime tag: []const u8) ?Ui.ValueMsgFn {
1955
2126
  comptime {
1956
2127
  @setEvalBranchQuota(10_000);