@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.
- package/build/app.zig +91 -2
- package/build.zig +756 -5
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +19 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +416 -9
- package/packages/core/sdk/core.ts +706 -5
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +3187 -264
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +42 -4
- package/skill-data/ts-core/SKILL.md +13 -3
- package/src/app_runner/root.zig +112 -10
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/tests.zig +119 -1
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +639 -16
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +351 -7
- package/src/platform/macos/appkit_host.h +152 -8
- package/src/platform/macos/appkit_host.m +1816 -100
- package/src/platform/macos/cef_host.mm +372 -11
- package/src/platform/macos/root.zig +379 -11
- package/src/platform/null_platform.zig +696 -9
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +42 -0
- package/src/platform/types.zig +524 -18
- package/src/platform/windows/root.zig +432 -9
- package/src/platform/windows/webview2_host.cpp +482 -45
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +535 -12
- package/src/primitives/canvas/ui_markup.zig +253 -36
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
- package/src/primitives/canvas/ui_markup_contract.zig +89 -6
- package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +178 -9
- package/src/primitives/canvas/ui_markup_view.zig +220 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
- package/src/primitives/canvas/ui_schema.zig +110 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -10
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +23 -0
- package/src/runtime/api.zig +76 -5
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +8 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +240 -24
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +131 -13
- package/src/runtime/effects.zig +8136 -180
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +167 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +42 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +36 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +432 -62
- package/src/runtime/session_record.zig +43 -2
- package/src/runtime/session_replay.zig +556 -20
- package/src/runtime/session_tests.zig +2087 -1
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +8 -0
- package/src/runtime/ts_core_host.zig +1320 -45
- package/src/runtime/ts_core_host_tests.zig +1100 -1
- package/src/runtime/ts_ui_app.zig +23 -5
- package/src/runtime/ui_app.zig +2444 -69
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +736 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +77 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +62 -1
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +244 -8
|
@@ -673,22 +673,42 @@ test "gap on stacking containers is rejected with the teaching error" {
|
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
|
|
676
|
-
test "the
|
|
676
|
+
test "the image attribute validates as one binding on avatar and image" {
|
|
677
677
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
678
678
|
defer arena_state.deinit();
|
|
679
679
|
const arena = arena_state.allocator();
|
|
680
680
|
|
|
681
|
-
// One {binding} on avatar is the whole grammar.
|
|
682
|
-
|
|
683
|
-
|
|
681
|
+
// One {binding} on avatar or the image leaf is the whole grammar.
|
|
682
|
+
const valid = [_][]const u8{
|
|
683
|
+
"<row>\n <avatar image=\"{user_image}\">CT</avatar>\n</row>",
|
|
684
|
+
"<row>\n <image image=\"{cover}\" width=\"120\" height=\"80\" label=\"Cover art\" />\n</row>",
|
|
685
|
+
};
|
|
686
|
+
for (valid) |source| {
|
|
687
|
+
var parser = markup.Parser.init(arena, source);
|
|
688
|
+
try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try parser.parse()));
|
|
689
|
+
}
|
|
684
690
|
|
|
685
691
|
const cases = [_]struct { source: []const u8, message: []const u8 }{
|
|
686
692
|
// Runtime image ids are model data, never markup literals.
|
|
687
|
-
.{ .source = "<row>\n <avatar image=\"7\">CT</avatar>\n</row>", .message = markup.
|
|
688
|
-
.{ .source = "<row>\n <avatar image=\"{a == b}\">CT</avatar>\n</row>", .message = markup.
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
693
|
+
.{ .source = "<row>\n <avatar image=\"7\">CT</avatar>\n</row>", .message = markup.image_binding_message },
|
|
694
|
+
.{ .source = "<row>\n <avatar image=\"{a == b}\">CT</avatar>\n</row>", .message = markup.image_binding_message },
|
|
695
|
+
.{ .source = "<row>\n <image image=\"7\" label=\"Art\" />\n</row>", .message = markup.image_binding_message },
|
|
696
|
+
// Scoped to the two ImageId-drawing widgets: anywhere else the
|
|
697
|
+
// attribute would be silently inert.
|
|
698
|
+
.{ .source = "<row>\n <badge image=\"{user_image}\">3</badge>\n</row>", .message = markup.image_binding_element_message },
|
|
699
|
+
.{ .source = "<column>\n <panel image=\"{user_image}\" />\n</column>", .message = markup.image_binding_element_message },
|
|
700
|
+
// ...and required on the leaf: an unbound image is statically
|
|
701
|
+
// dead markup (avatar keeps its initials fallback instead).
|
|
702
|
+
.{ .source = "<row>\n <image label=\"Art\" />\n</row>", .message = markup.image_missing_image_message },
|
|
703
|
+
// The leaf takes no children (icon's policy): widget layout
|
|
704
|
+
// gives an image no child slots, so a nested caption would
|
|
705
|
+
// silently vanish instead of rendering.
|
|
706
|
+
.{ .source = "<row>\n <image image=\"{cover}\" label=\"Art\"><text>Caption</text></image>\n</row>", .message = markup.image_children_message },
|
|
707
|
+
// ...and the rejection reads the RAW node: an extracted
|
|
708
|
+
// context-menu (host metadata on a pressable host) still counts
|
|
709
|
+
// as a child - the leaf takes no children at all, and both
|
|
710
|
+
// engines check the original node the same way.
|
|
711
|
+
.{ .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>", .message = markup.image_children_message },
|
|
692
712
|
};
|
|
693
713
|
for (cases) |case| {
|
|
694
714
|
var case_parser = markup.Parser.init(arena, case.source);
|
|
@@ -724,6 +744,89 @@ test "the media-surface surface attribute validates as one binding, required, me
|
|
|
724
744
|
}
|
|
725
745
|
}
|
|
726
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
|
+
|
|
727
830
|
test "wrap and issue-link-base validate as vocabulary with teaching errors" {
|
|
728
831
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
729
832
|
defer arena_state.deinit();
|
|
@@ -821,6 +924,72 @@ test "overscroll validates as scroll-scoped with a closed value vocabulary" {
|
|
|
821
924
|
}
|
|
822
925
|
}
|
|
823
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
|
+
|
|
824
993
|
test "tooltip-delay validates as tooltip-scoped beside anchor, and anchor accepts tooltip" {
|
|
825
994
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
826
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.
|
|
@@ -398,6 +401,37 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
398
401
|
}
|
|
399
402
|
if (pane_count != 2) return self.failNode(node, markup.split_children_message);
|
|
400
403
|
}
|
|
404
|
+
// The image leaf's static shape, mirroring the validator and
|
|
405
|
+
// the compiled engine's compile error. Without its id binding
|
|
406
|
+
// the leaf can never draw - statically dead markup, refused
|
|
407
|
+
// here too so markup that skipped validation (hot reload)
|
|
408
|
+
// fails the build instead of silently rendering nothing. And
|
|
409
|
+
// it takes no children at all (icon's leaf policy): checked
|
|
410
|
+
// on the ORIGINAL node, so an extracted context-menu still
|
|
411
|
+
// counts as a child exactly like the validator's raw-node
|
|
412
|
+
// check.
|
|
413
|
+
if (kind == .image) {
|
|
414
|
+
if (node.attr("image") == null) {
|
|
415
|
+
return self.failNode(node, markup.image_missing_image_message);
|
|
416
|
+
}
|
|
417
|
+
if (node.children.len > 0) {
|
|
418
|
+
return self.failNode(node, markup.image_children_message);
|
|
419
|
+
}
|
|
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
|
+
}
|
|
401
435
|
// The a11y lint's error half: an unnamed interactive control
|
|
402
436
|
// or a misused role ships a view a screen reader user cannot
|
|
403
437
|
// operate, so it fails the build like any other markup
|
|
@@ -1119,6 +1153,74 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1119
1153
|
return ui.chart(options, series);
|
|
1120
1154
|
}
|
|
1121
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
|
+
|
|
1122
1224
|
fn buildSeries(self: *Self, ui: *Ui, scope: *Scope, node: markup.MarkupNode) BuildError!canvas.ChartSeries {
|
|
1123
1225
|
if (node.children.len != 0) {
|
|
1124
1226
|
return self.failVoid(node.children[0], markup.series_children_message);
|
|
@@ -1503,6 +1605,29 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1503
1605
|
try self.applySurfaceAttr(scope, node, options, attribute);
|
|
1504
1606
|
continue;
|
|
1505
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
|
+
}
|
|
1506
1631
|
if (std.mem.eql(u8, attribute.name, "name")) {
|
|
1507
1632
|
// Consumed by the icon branch in buildElement.
|
|
1508
1633
|
if (!std.mem.eql(u8, node.name, "icon")) {
|
|
@@ -1567,28 +1692,29 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1567
1692
|
};
|
|
1568
1693
|
}
|
|
1569
1694
|
|
|
1570
|
-
/// `image="{binding}"` on avatar: one binding
|
|
1571
|
-
/// `canvas.ImageId` the app registered at
|
|
1572
|
-
/// (`fx.
|
|
1573
|
-
///
|
|
1574
|
-
///
|
|
1575
|
-
///
|
|
1695
|
+
/// `image="{binding}"` on avatar and image: one binding
|
|
1696
|
+
/// producing a `u64` `canvas.ImageId` the app registered at
|
|
1697
|
+
/// runtime (`Cmd.imageLoad`, `fx.loadImage`,
|
|
1698
|
+
/// `fx.registerImageBytes`) — the id is model data, never a
|
|
1699
|
+
/// markup literal, and 0 draws nothing (an avatar keeps its
|
|
1700
|
+
/// initials fallback). The remaining image-bearing widget
|
|
1701
|
+
/// (icon-button) stays a Zig view.
|
|
1576
1702
|
fn applyImageAttr(self: *Self, scope: *Scope, node: markup.MarkupNode, options: *Ui.ElementOptions, attribute: markup.MarkupAttr) BuildError!void {
|
|
1577
|
-
if (!std.mem.eql(u8, node.name, "avatar")) {
|
|
1578
|
-
return self.failVoid(node, markup.
|
|
1703
|
+
if (!std.mem.eql(u8, node.name, "avatar") and !std.mem.eql(u8, node.name, "image")) {
|
|
1704
|
+
return self.failVoid(node, markup.image_binding_element_message);
|
|
1579
1705
|
}
|
|
1580
1706
|
const typed = markup.attrTyped(attribute);
|
|
1581
|
-
if (typed != .binding) return self.failVoid(node, markup.
|
|
1707
|
+
if (typed != .binding) return self.failVoid(node, markup.image_binding_message);
|
|
1582
1708
|
const value = try self.evalBinding(scope, node, typed.binding, true);
|
|
1583
1709
|
// Range-checked before the u64 cast: expression values are
|
|
1584
1710
|
// i64, so a signed model field (`image: i64 = -1`) can
|
|
1585
1711
|
// deliver a negative — the teaching failure, never a trap.
|
|
1586
1712
|
options.image = switch (value) {
|
|
1587
1713
|
.integer => |int| if (int < 0)
|
|
1588
|
-
return self.failVoid(node, markup.
|
|
1714
|
+
return self.failVoid(node, markup.image_binding_message)
|
|
1589
1715
|
else
|
|
1590
1716
|
@intCast(int),
|
|
1591
|
-
else => return self.failVoid(node, markup.
|
|
1717
|
+
else => return self.failVoid(node, markup.image_binding_message),
|
|
1592
1718
|
};
|
|
1593
1719
|
}
|
|
1594
1720
|
|
|
@@ -1616,6 +1742,30 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1616
1742
|
};
|
|
1617
1743
|
}
|
|
1618
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
|
+
|
|
1619
1769
|
/// `icon="save"` on button, toggle-button, list-item, or
|
|
1620
1770
|
/// menu-item: the same icon value grammar as `<icon name>` — a
|
|
1621
1771
|
/// built-in literal can never rot silently, app:<name> and one
|
|
@@ -1766,10 +1916,28 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1766
1916
|
return self.failVoid(node, markup.on_scroll_element_message);
|
|
1767
1917
|
}
|
|
1768
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
|
+
}
|
|
1769
1925
|
return self.failVoid(node, markup.on_scroll_payload_message);
|
|
1770
1926
|
};
|
|
1771
1927
|
return;
|
|
1772
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
|
+
}
|
|
1773
1941
|
if (std.mem.eql(u8, event, "resize")) {
|
|
1774
1942
|
if (!std.mem.eql(u8, node.name, "split")) {
|
|
1775
1943
|
return self.failVoid(node, markup.on_resize_element_message);
|
|
@@ -1812,6 +1980,13 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1812
1980
|
// Press family: like on-press, a bound hold makes any
|
|
1813
1981
|
// element pressable.
|
|
1814
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;
|
|
1815
1990
|
} else if (std.mem.eql(u8, event, "reach-end")) {
|
|
1816
1991
|
// The approach-end signal (infinite-scroll fetch) is
|
|
1817
1992
|
// emitted for scroll containers only.
|
|
@@ -1919,6 +2094,38 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1919
2094
|
return null;
|
|
1920
2095
|
}
|
|
1921
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
|
+
|
|
1922
2129
|
fn resizeConstructor(tag: []const u8) ?Ui.ValueMsgFn {
|
|
1923
2130
|
@setEvalBranchQuota(scan_quota);
|
|
1924
2131
|
inline for (@typeInfo(MsgT).@"union".fields) |field| {
|
|
@@ -2266,6 +2473,8 @@ pub const typeScanQuota = reflect.typeScanQuota;
|
|
|
2266
2473
|
pub const Pointee = reflect.Pointee;
|
|
2267
2474
|
pub const declaredTextInputUnion = reflect.declaredTextInputUnion;
|
|
2268
2475
|
pub const declaredScrollStateRecord = reflect.declaredScrollStateRecord;
|
|
2476
|
+
pub const declaredTerminalStateRecord = reflect.declaredTerminalStateRecord;
|
|
2477
|
+
pub const declaredLegacyScrollStateRecord = reflect.declaredLegacyScrollStateRecord;
|
|
2269
2478
|
pub const valueArmClass = reflect.valueArmClass;
|
|
2270
2479
|
pub const sliceElement = reflect.sliceElement;
|
|
2271
2480
|
pub const isItemFn = reflect.isItemFn;
|