@native-sdk/cli 0.7.0 → 0.7.2
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 +8 -0
- package/build.zig +114 -103
- package/native-sdk.d.ts +6 -3
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/text.ts +25 -14
- package/packages/core/src/checker.ts +39 -0
- package/packages/core/src/emitter.ts +125 -1
- package/skill-data/native-ui/SKILL.md +11 -7
- package/src/platform/macos/appkit_host.m +76 -4
- package/src/platform/macos/cef_host.mm +24 -2
- package/src/platform/macos/root.zig +13 -0
- package/src/platform/types.zig +4 -0
- package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
- package/src/platform/windows/gpu_surface_renderer.h +86 -0
- package/src/platform/windows/root.zig +298 -20
- package/src/platform/windows/webview2_host.cpp +343 -33
- package/src/primitives/canvas/code.zig +501 -33
- package/src/primitives/canvas/code_tests.zig +1029 -6
- package/src/primitives/canvas/events.zig +111 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/markdown_tests.zig +17 -18
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/text.zig +6 -0
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +160 -36
- package/src/primitives/canvas/ui_markup.zig +60 -9
- package/src/primitives/canvas/ui_markup_compiled.zig +41 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +12 -0
- package/src/primitives/canvas/ui_markup_contract.zig +17 -1
- package/src/primitives/canvas/ui_markup_view.zig +44 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +80 -6
- package/src/primitives/canvas/ui_schema.zig +18 -0
- package/src/primitives/canvas/ui_schema_tests.zig +10 -7
- package/src/primitives/canvas/ui_tests.zig +40 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +12 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +47 -6
- package/src/primitives/canvas/widget_render.zig +849 -78
- package/src/primitives/canvas/widget_render_controls.zig +83 -25
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_runtime.zig +2 -0
- package/src/primitives/canvas/widget_text_input.zig +167 -8
- package/src/primitives/canvas/widget_tree.zig +6 -5
- package/src/primitives/canvas/widgets.zig +78 -2
- package/src/runtime/canvas_budget_edge_tests.zig +3 -2
- package/src/runtime/canvas_frame.zig +60 -7
- package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
- package/src/runtime/canvas_frame_packet_tests.zig +83 -9
- package/src/runtime/canvas_frame_patch_tests.zig +16 -0
- package/src/runtime/canvas_images.zig +8 -2
- package/src/runtime/canvas_limits.zig +13 -6
- package/src/runtime/canvas_widget_clipboard_tests.zig +8 -5
- package/src/runtime/canvas_widget_context_menu.zig +7 -2
- package/src/runtime/canvas_widget_event_tests.zig +18 -14
- package/src/runtime/canvas_widget_events.zig +51 -20
- package/src/runtime/canvas_widget_runtime.zig +108 -4
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +59 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +100 -0
- package/src/runtime/canvas_widget_state.zig +27 -0
- package/src/runtime/canvas_widget_text_tests.zig +326 -0
- package/src/runtime/core.zig +15 -5
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +50 -19
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +60 -16
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_scroll.zig +48 -18
- package/src/runtime/view_widget_text.zig +59 -16
- package/src/runtime/window_view_runtime.zig +10 -0
- package/src/tooling/templates.zig +9 -6
|
@@ -807,6 +807,8 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
807
807
|
if (node.children.len != 0) return self.failNode(node.children[0], markup.code_children_message);
|
|
808
808
|
var options: Ui.CodeOptions = .{};
|
|
809
809
|
var source_text: ?[]const u8 = null;
|
|
810
|
+
var added_lines_storage: [canvas.code.max_diff_lines]usize = undefined;
|
|
811
|
+
var removed_lines_storage: [canvas.code.max_diff_lines]usize = undefined;
|
|
810
812
|
for (node.attrs) |attribute| {
|
|
811
813
|
if (std.mem.eql(u8, attribute.name, "kind")) continue;
|
|
812
814
|
if (std.mem.eql(u8, attribute.name, "source")) {
|
|
@@ -829,6 +831,46 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
829
831
|
options.line_numbers = try self.codeFlagAttr(scope, node, attribute);
|
|
830
832
|
continue;
|
|
831
833
|
}
|
|
834
|
+
if (std.mem.eql(u8, attribute.name, "added-lines")) {
|
|
835
|
+
const typed = markup.parseAttrExpression(attribute.value) orelse
|
|
836
|
+
return self.failNode(node, markup.code_diff_lines_message);
|
|
837
|
+
const spec = if (typed == .literal)
|
|
838
|
+
typed.literal
|
|
839
|
+
else switch (try self.evalAttrExpression(scope, node, attribute)) {
|
|
840
|
+
.string => |text| text,
|
|
841
|
+
else => return self.failNode(node, markup.code_diff_lines_message),
|
|
842
|
+
};
|
|
843
|
+
options.added_lines = canvas.code.parseLineNumberSpec(spec, &added_lines_storage) orelse
|
|
844
|
+
return self.failNode(node, markup.code_diff_lines_message);
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
if (std.mem.eql(u8, attribute.name, "removed-lines")) {
|
|
848
|
+
const typed = markup.parseAttrExpression(attribute.value) orelse
|
|
849
|
+
return self.failNode(node, markup.code_diff_lines_message);
|
|
850
|
+
const spec = if (typed == .literal)
|
|
851
|
+
typed.literal
|
|
852
|
+
else switch (try self.evalAttrExpression(scope, node, attribute)) {
|
|
853
|
+
.string => |text| text,
|
|
854
|
+
else => return self.failNode(node, markup.code_diff_lines_message),
|
|
855
|
+
};
|
|
856
|
+
options.removed_lines = canvas.code.parseLineNumberSpec(spec, &removed_lines_storage) orelse
|
|
857
|
+
return self.failNode(node, markup.code_diff_lines_message);
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
if (std.mem.eql(u8, attribute.name, "editable")) {
|
|
861
|
+
options.editable = try self.codeFlagAttr(scope, node, attribute);
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
if (std.mem.eql(u8, attribute.name, "on-input")) {
|
|
865
|
+
const typed = markup.attrTyped(attribute);
|
|
866
|
+
if (typed != .message) {
|
|
867
|
+
return self.failNode(node, "invalid message expression: on-* takes a Msg tag (\"add\") or tag with one binding payload (\"toggle:{item.id}\")");
|
|
868
|
+
}
|
|
869
|
+
options.on_input = inputConstructor(typed.message.tag) orelse {
|
|
870
|
+
return self.failNode(node, "on-input tag must carry a TextInputEvent payload");
|
|
871
|
+
};
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
832
874
|
if (std.mem.eql(u8, attribute.name, "wrap")) {
|
|
833
875
|
options.wrap = try self.codeFlagAttr(scope, node, attribute);
|
|
834
876
|
continue;
|
|
@@ -2036,6 +2078,8 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
2036
2078
|
const msg = try self.constructMessage(scope, node, expression);
|
|
2037
2079
|
if (std.mem.eql(u8, event, "press")) {
|
|
2038
2080
|
options.on_press = msg;
|
|
2081
|
+
} else if (std.mem.eql(u8, event, "double-press")) {
|
|
2082
|
+
options.on_double_press = msg;
|
|
2039
2083
|
} else if (std.mem.eql(u8, event, "toggle")) {
|
|
2040
2084
|
options.on_toggle = msg;
|
|
2041
2085
|
} else if (std.mem.eql(u8, event, "change")) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const geometry = @import("geometry");
|
|
2
3
|
const canvas = @import("root.zig");
|
|
4
|
+
const code_model = @import("code.zig");
|
|
3
5
|
const markup_view = @import("ui_markup_view.zig");
|
|
4
6
|
|
|
5
7
|
const testing = std.testing;
|
|
@@ -1082,7 +1084,7 @@ pub const picker_markup_source =
|
|
|
1082
1084
|
\\ <menu-item on-press="toggle:{open_count}">Alpha</menu-item>
|
|
1083
1085
|
\\ </dropdown-menu>
|
|
1084
1086
|
\\ </stack>
|
|
1085
|
-
\\ <button on-press="add" on-hold="add">Crumb</button>
|
|
1087
|
+
\\ <button on-press="add" on-double-press="toggle:{open_count}" on-hold="add">Crumb</button>
|
|
1086
1088
|
\\</column>
|
|
1087
1089
|
;
|
|
1088
1090
|
|
|
@@ -1131,7 +1133,7 @@ test "markup binds the hover pair and makes listeners hover-hittable, never pres
|
|
|
1131
1133
|
try testing.expect(!row.children[0].hover_msgs);
|
|
1132
1134
|
}
|
|
1133
1135
|
|
|
1134
|
-
test "markup anchors dropdown-menus and binds dismiss and
|
|
1136
|
+
test "markup anchors dropdown-menus and binds dismiss, hold, and double-press handlers" {
|
|
1135
1137
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1136
1138
|
defer arena_state.deinit();
|
|
1137
1139
|
const arena = arena_state.allocator();
|
|
@@ -1152,6 +1154,9 @@ test "markup anchors dropdown-menus and binds dismiss and hold handlers" {
|
|
|
1152
1154
|
|
|
1153
1155
|
const crumb = tree.root.children[1];
|
|
1154
1156
|
try testing.expect(tree.msgFor(crumb.id, .hold) != null);
|
|
1157
|
+
try testing.expectEqual(Msg.add, tree.msgForPointerClick(crumb.id, .up, 1).?);
|
|
1158
|
+
try testing.expectEqual(@as(u32, 0), tree.msgForPointerClick(crumb.id, .up, 2).?.toggle);
|
|
1159
|
+
try testing.expectEqual(Msg.add, tree.msgForPointerClick(crumb.id, .up, 3).?);
|
|
1155
1160
|
// A hold handler makes the element pressable, like on-press.
|
|
1156
1161
|
try testing.expect(crumb.semantics.actions.press);
|
|
1157
1162
|
|
|
@@ -1928,7 +1933,10 @@ test "markdown misuse is caught by the model-agnostic validator with positions"
|
|
|
1928
1933
|
|
|
1929
1934
|
// ------------------------------------------------------- code component
|
|
1930
1935
|
|
|
1931
|
-
pub const CodeMsg = union(enum) {
|
|
1936
|
+
pub const CodeMsg = union(enum) {
|
|
1937
|
+
noop,
|
|
1938
|
+
edit: canvas.TextInputEvent,
|
|
1939
|
+
};
|
|
1932
1940
|
|
|
1933
1941
|
pub const CodeModel = struct {
|
|
1934
1942
|
snippet: []const u8 =
|
|
@@ -1938,11 +1946,13 @@ pub const CodeModel = struct {
|
|
|
1938
1946
|
,
|
|
1939
1947
|
show_lines: bool = true,
|
|
1940
1948
|
wrap_code: bool = false,
|
|
1949
|
+
editable_code: bool = false,
|
|
1950
|
+
added_spec: []const u8 = "2",
|
|
1941
1951
|
count: usize = 3,
|
|
1942
1952
|
};
|
|
1943
1953
|
|
|
1944
1954
|
pub const code_markup_source =
|
|
1945
|
-
\\<code source="{snippet}" language="tsx" line-numbers="{show_lines}" wrap="{wrap_code}" width="240" label="Example code" />
|
|
1955
|
+
\\<code source="{snippet}" language="tsx" editable="{editable_code}" on-input="edit" line-numbers="{show_lines}" added-lines="{added_spec}" removed-lines="3" wrap="{wrap_code}" width="240" label="Example code" />
|
|
1946
1956
|
;
|
|
1947
1957
|
|
|
1948
1958
|
pub const CodeUi = canvas.Ui(CodeMsg);
|
|
@@ -1950,7 +1960,11 @@ pub const CodeUi = canvas.Ui(CodeMsg);
|
|
|
1950
1960
|
pub fn handCodeView(ui: *CodeUi, model: *const CodeModel) CodeUi.Node {
|
|
1951
1961
|
return ui.code(.{
|
|
1952
1962
|
.language = .html,
|
|
1963
|
+
.editable = model.editable_code,
|
|
1964
|
+
.on_input = CodeUi.inputMsg(.edit),
|
|
1953
1965
|
.line_numbers = model.show_lines,
|
|
1966
|
+
.added_lines = &.{2},
|
|
1967
|
+
.removed_lines = &.{3},
|
|
1954
1968
|
.wrap = model.wrap_code,
|
|
1955
1969
|
.width = 240,
|
|
1956
1970
|
.semantics = .{ .label = "Example code" },
|
|
@@ -1977,10 +1991,58 @@ test "code markup builds the reusable component with opt-in numbers and horizont
|
|
|
1977
1991
|
try collectIds(markup_tree.root, &markup_ids, testing.allocator);
|
|
1978
1992
|
try collectIds(hand_tree.root, &hand_ids, testing.allocator);
|
|
1979
1993
|
try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
|
|
1994
|
+
try testing.expectEqual(canvas.WidgetKind.column, markup_tree.root.kind);
|
|
1995
|
+
try testing.expectEqual(geometry.InsetsF{}, markup_tree.root.layout.padding);
|
|
1996
|
+
try testing.expect(markup_tree.root.style.background == null);
|
|
1997
|
+
try testing.expect(markup_tree.root.style.border == null);
|
|
1998
|
+
try testing.expect(markup_tree.root.style.radius == null);
|
|
1980
1999
|
try testing.expectEqual(canvas.ScrollAxes.horizontal, findByKind(markup_tree.root, .scroll_view).?.scroll_axes);
|
|
1981
2000
|
const source = findByText(markup_tree.root, .text, model.snippet).?;
|
|
1982
|
-
try testing.expectEqual(@as(u8, 1), source.
|
|
2001
|
+
try testing.expectEqual(@as(u8, 1), source.codeLineNumberDigits());
|
|
2002
|
+
try testing.expectEqual(@as(u128, 1) << 1, source.codeDiffLines().?.added);
|
|
2003
|
+
try testing.expectEqual(@as(u128, 1) << 2, source.codeDiffLines().?.removed);
|
|
1983
2004
|
try testing.expectEqualStrings("Example code", markup_tree.root.semantics.label);
|
|
2005
|
+
|
|
2006
|
+
var editable_model = model;
|
|
2007
|
+
editable_model.editable_code = true;
|
|
2008
|
+
var editable_ui = CodeUi.init(arena);
|
|
2009
|
+
const editable_tree = try editable_ui.finalize(try view.build(&editable_ui, &editable_model));
|
|
2010
|
+
try testing.expectEqual(canvas.WidgetKind.textarea, editable_tree.root.kind);
|
|
2011
|
+
try testing.expect(editable_tree.root.code_editor);
|
|
2012
|
+
try testing.expectEqual(@as(usize, 1), editable_tree.root.spans.len);
|
|
2013
|
+
try testing.expectEqual(code_model.Language.tsx, editable_tree.root.code_language);
|
|
2014
|
+
try testing.expect(editable_tree.root.text_no_wrap);
|
|
2015
|
+
try testing.expect(canvas.widgetScrollsAxis(editable_tree.root, .horizontal));
|
|
2016
|
+
try testing.expect(canvas.widgetScrollsAxis(editable_tree.root, .vertical));
|
|
2017
|
+
try testing.expectEqual(geometry.InsetsF{}, editable_tree.root.layout.padding);
|
|
2018
|
+
try testing.expect(editable_tree.root.style.background == null);
|
|
2019
|
+
try testing.expect(editable_tree.root.style.border == null);
|
|
2020
|
+
try testing.expect(editable_tree.root.style.radius == null);
|
|
2021
|
+
try testing.expect(editable_tree.root.semantics.actions.set_text);
|
|
2022
|
+
const edit = editable_tree.msgForTextEdit(editable_tree.root.id, .{ .insert_text = "x" }).?;
|
|
2023
|
+
try testing.expectEqualStrings("x", edit.edit.insert_text);
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
test "code markup accepts lexer aliases from the shared language registry" {
|
|
2027
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
2028
|
+
defer arena_state.deinit();
|
|
2029
|
+
const arena = arena_state.allocator();
|
|
2030
|
+
const model = CodeModel{};
|
|
2031
|
+
const CodeMarkup = markup_view.MarkupView(CodeModel, CodeMsg);
|
|
2032
|
+
const cases = [_][]const u8{
|
|
2033
|
+
"<code source=\"{snippet}\" language=\"mjs\" />",
|
|
2034
|
+
"<code source=\"{snippet}\" language=\"yaml\" />",
|
|
2035
|
+
"<code source=\"{snippet}\" language=\"yml\" />",
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
for (cases) |source| {
|
|
2039
|
+
var parser = canvas.ui_markup.Parser.init(arena, source);
|
|
2040
|
+
try testing.expectEqual(@as(?canvas.ui_markup.MarkupErrorInfo, null), canvas.ui_markup.validate(try parser.parse()));
|
|
2041
|
+
|
|
2042
|
+
var view = try CodeMarkup.init(arena, source);
|
|
2043
|
+
var ui = CodeUi.init(arena);
|
|
2044
|
+
_ = try ui.finalize(try view.build(&ui, &model));
|
|
2045
|
+
}
|
|
1984
2046
|
}
|
|
1985
2047
|
|
|
1986
2048
|
test "code markup misuse reports the component's closed contract" {
|
|
@@ -1994,6 +2056,9 @@ test "code markup misuse reports the component's closed contract" {
|
|
|
1994
2056
|
.{ .source = "<code source=\"literal\" />", .message = canvas.ui_markup.code_source_message },
|
|
1995
2057
|
.{ .source = "<code source=\"{count}\" />", .message = canvas.ui_markup.code_source_message, .model_agnostic = false },
|
|
1996
2058
|
.{ .source = "<code source=\"{snippet}\" language=\"brainwave\" />", .message = canvas.ui_markup.code_language_message },
|
|
2059
|
+
.{ .source = "<code source=\"{snippet}\" added-lines=\"0\" />", .message = canvas.ui_markup.code_diff_lines_message },
|
|
2060
|
+
.{ .source = "<code source=\"{snippet}\" removed-lines=\"4-2\" />", .message = canvas.ui_markup.code_diff_lines_message },
|
|
2061
|
+
.{ .source = "<code source=\"{snippet}\" removed-lines=\"{count}\" />", .message = canvas.ui_markup.code_diff_lines_message, .model_agnostic = false },
|
|
1997
2062
|
.{ .source = "<code source=\"{snippet}\" padding=\"8\" />", .message = canvas.ui_markup.code_attr_message },
|
|
1998
2063
|
.{ .source = "<code source=\"{snippet}\">text</code>", .message = canvas.ui_markup.code_children_message },
|
|
1999
2064
|
};
|
|
@@ -3240,6 +3305,7 @@ test "columns off grid and misshapen alignment values fail with teaching message
|
|
|
3240
3305
|
pub const Folder = struct {
|
|
3241
3306
|
id: u32,
|
|
3242
3307
|
name: []const u8,
|
|
3308
|
+
level: u16 = 1,
|
|
3243
3309
|
expanded: bool = false,
|
|
3244
3310
|
|
|
3245
3311
|
fn key(folder: *const Folder) canvas.UiKey {
|
|
@@ -3268,7 +3334,7 @@ pub const pane_markup_source =
|
|
|
3268
3334
|
\\<split value="{sidebar_fraction}" on-resize="sidebar_resized">
|
|
3269
3335
|
\\ <tree label="Folders">
|
|
3270
3336
|
\\ <for each="folders" key="id" as="f">
|
|
3271
|
-
\\ <panel role="treeitem" expanded="{f.expanded}" on-press="select_folder:{f.id}" on-toggle="toggle_folder:{f.id}" label="{f.name}">
|
|
3337
|
+
\\ <panel role="treeitem" tree-level="{f.level}" expanded="{f.expanded}" on-press="select_folder:{f.id}" on-change="select_folder:{f.id}" on-toggle="toggle_folder:{f.id}" label="{f.name}">
|
|
3272
3338
|
\\ <text>{f.name}</text>
|
|
3273
3339
|
\\ </panel>
|
|
3274
3340
|
\\ </for>
|
|
@@ -3291,7 +3357,9 @@ pub fn handPaneView(ui: *PaneUi, model: *const PaneModel) PaneUi.Node {
|
|
|
3291
3357
|
fn folderRow(ui: *PaneUi, folder: *const Folder) PaneUi.Node {
|
|
3292
3358
|
return ui.panel(.{
|
|
3293
3359
|
.expanded = folder.expanded,
|
|
3360
|
+
.tree_level = folder.level,
|
|
3294
3361
|
.on_press = PaneMsg{ .select_folder = folder.id },
|
|
3362
|
+
.on_change = PaneMsg{ .select_folder = folder.id },
|
|
3295
3363
|
.on_toggle = PaneMsg{ .toggle_folder = folder.id },
|
|
3296
3364
|
.semantics = .{ .role = .treeitem, .label = folder.name },
|
|
3297
3365
|
}, .{
|
|
@@ -3332,8 +3400,14 @@ test "markup split and tree build the hand-written view with the divider synthes
|
|
|
3332
3400
|
// and both the press (selection) and toggle (disclosure) handlers.
|
|
3333
3401
|
const row = findByKind(markup_tree.root, .panel).?;
|
|
3334
3402
|
try testing.expectEqual(canvas.WidgetRole.treeitem, row.semantics.role);
|
|
3403
|
+
try testing.expectEqual(@as(u16, 1), row.tree_level);
|
|
3335
3404
|
try testing.expectEqual(@as(?bool, true), row.state.expanded);
|
|
3336
3405
|
try testing.expectEqual(@as(u32, 1), markup_tree.msgForPointer(row.id, .up).?.select_folder);
|
|
3406
|
+
try testing.expectEqual(@as(u32, 1), markup_tree.msgForKeyboard(row.id, .{
|
|
3407
|
+
.phase = .key_down,
|
|
3408
|
+
.key = "arrowdown",
|
|
3409
|
+
.focus_moved = true,
|
|
3410
|
+
}).?.select_folder);
|
|
3337
3411
|
try testing.expectEqual(@as(u32, 1), markup_tree.msgFor(row.id, .toggle).?.toggle_folder);
|
|
3338
3412
|
|
|
3339
3413
|
// min-width lands as a floor only (no definite max).
|
|
@@ -563,6 +563,19 @@ pub const attrs = [_]AttrInfo{
|
|
|
563
563
|
// numbers are opt-in; wrapping reuses generic attr code 16.
|
|
564
564
|
.{ .code = 90, .name = "language", .class = .option, .group = .composite },
|
|
565
565
|
.{ .code = 91, .name = "line-numbers", .class = .flag, .group = .composite },
|
|
566
|
+
// Editable code is a composite-only opt-in: the default code surface
|
|
567
|
+
// remains selectable/read-only, while `editable` lowers it through
|
|
568
|
+
// the textarea behavior with code-specific bare rendering.
|
|
569
|
+
.{ .code = 92, .name = "editable", .class = .flag, .group = .composite },
|
|
570
|
+
// Flat loop-rendered tree rows can declare their one-based logical
|
|
571
|
+
// hierarchy without manufacturing nested layout containers. Zero (the
|
|
572
|
+
// default when absent) keeps structural widget nesting as the source.
|
|
573
|
+
.{ .code = 93, .name = "tree-level", .class = .whole, .group = .option, .field = "tree_level" },
|
|
574
|
+
// Code diff metadata follows Geist Code Block's added/removed line
|
|
575
|
+
// declarations. Values are one-based comma/range text specs so markup
|
|
576
|
+
// can state compact runs (`2-4, 7`) without putting +/- bytes in source.
|
|
577
|
+
.{ .code = 94, .name = "added-lines", .class = .text, .group = .composite },
|
|
578
|
+
.{ .code = 95, .name = "removed-lines", .class = .text, .group = .composite },
|
|
566
579
|
};
|
|
567
580
|
|
|
568
581
|
// ----------------------------------------------------------------- events
|
|
@@ -596,6 +609,11 @@ pub const events = [_]EventInfo{
|
|
|
596
609
|
// `scrollback` back (the on-scroll reconcile shape) and render
|
|
597
610
|
// honest status. Emulator internals never ride it.
|
|
598
611
|
.{ .code = 13, .name = "terminal", .payload = .terminal_state, .only_on_element = "terminal" },
|
|
612
|
+
// Double press is the second half of the desktop select-then-act
|
|
613
|
+
// gesture. The first release still dispatches `press`; a release
|
|
614
|
+
// whose runtime-derived click count reached two dispatches this
|
|
615
|
+
// channel in place of a second press.
|
|
616
|
+
.{ .code = 14, .name = "double-press" },
|
|
599
617
|
};
|
|
600
618
|
|
|
601
619
|
// ------------------------------------------------------- token vocabulary
|
|
@@ -22,8 +22,8 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
24
|
try testing.expectEqual(@as(usize, 70), schema.elements.len);
|
|
25
|
-
try testing.expectEqual(@as(usize,
|
|
26
|
-
try testing.expectEqual(@as(usize,
|
|
25
|
+
try testing.expectEqual(@as(usize, 95), schema.attrs.len);
|
|
26
|
+
try testing.expectEqual(@as(usize, 14), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64), the
|
|
28
28
|
// bubble-reactions composite (65), the media surface (66), the
|
|
29
29
|
// runtime-image leaf (67), the video playback composite (68), and
|
|
@@ -43,16 +43,19 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
43
43
|
// autoplay (83), loop (84), and muted (85), the scroll-axis
|
|
44
44
|
// attributes axis (86) and value-x (87), and the terminal
|
|
45
45
|
// attributes pty (88) and scrollback (89), and the code language
|
|
46
|
-
// (90)
|
|
46
|
+
// (90), line-numbers (91), and editable-code (92) declarations,
|
|
47
|
+
// the flat disclosure-tree hierarchy level tree-level (93), and the
|
|
48
|
+
// code-diff line sets added-lines (94) and removed-lines (95).
|
|
47
49
|
try testing.expectEqual(
|
|
48
|
-
@as(u64,
|
|
50
|
+
@as(u64, 0xf16fa9fd1d3e7f25),
|
|
49
51
|
tableFingerprint(schema.AttrInfo, &schema.attrs),
|
|
50
52
|
);
|
|
51
53
|
// The event table runs through the pointer-hover containment pair
|
|
52
|
-
// hover-enter (11) and hover-leave (12)
|
|
53
|
-
// echo terminal (13)
|
|
54
|
+
// hover-enter (11) and hover-leave (12), the terminal view-state
|
|
55
|
+
// echo terminal (13), and the desktop gesture channel
|
|
56
|
+
// double-press (14).
|
|
54
57
|
try testing.expectEqual(
|
|
55
|
-
@as(u64,
|
|
58
|
+
@as(u64, 0x0cdda4a2d5a85101),
|
|
56
59
|
tableFingerprint(schema.EventInfo, &schema.events),
|
|
57
60
|
);
|
|
58
61
|
}
|
|
@@ -123,6 +123,20 @@ test "ui builder emits an engine-compatible widget tree" {
|
|
|
123
123
|
try testing.expect(saw_button);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
test "ui builder distinguishes inherited tab padding from an equal author value" {
|
|
127
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
128
|
+
defer arena_state.deinit();
|
|
129
|
+
|
|
130
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
131
|
+
const inherited = ui.el(.tabs, .{}, .{});
|
|
132
|
+
try testing.expectEqual(@as(f32, 3), inherited.widget.layout.padding.top);
|
|
133
|
+
try testing.expect(inherited.widget.layout.padding_is_kind_default);
|
|
134
|
+
|
|
135
|
+
const explicit = ui.el(.tabs, .{ .padding = 3 }, .{});
|
|
136
|
+
try testing.expectEqual(@as(f32, 3), explicit.widget.layout.padding.top);
|
|
137
|
+
try testing.expect(!explicit.widget.layout.padding_is_kind_default);
|
|
138
|
+
}
|
|
139
|
+
|
|
126
140
|
test "structural ids are stable across rebuilds" {
|
|
127
141
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
128
142
|
defer arena_state.deinit();
|
|
@@ -321,6 +335,32 @@ test "keyboard events resolve activation and submit messages" {
|
|
|
321
335
|
try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(checkbox.id, letter));
|
|
322
336
|
}
|
|
323
337
|
|
|
338
|
+
test "tree keyboard navigation can select without dispatching pointer activation" {
|
|
339
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
340
|
+
defer arena_state.deinit();
|
|
341
|
+
|
|
342
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
343
|
+
const tree = try ui.finalize(ui.tree(.{}, .{
|
|
344
|
+
ui.listItem(.{
|
|
345
|
+
.on_press = .add,
|
|
346
|
+
.on_change = .load_more,
|
|
347
|
+
.semantics = .{ .role = .treeitem },
|
|
348
|
+
}, "main.zig"),
|
|
349
|
+
}));
|
|
350
|
+
const row = tree.root.children[0];
|
|
351
|
+
|
|
352
|
+
try testing.expectEqual(Msg.add, tree.msgForPointer(row.id, .up).?);
|
|
353
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(row.id, .{
|
|
354
|
+
.phase = .key_down,
|
|
355
|
+
.key = "arrowdown",
|
|
356
|
+
.focus_moved = true,
|
|
357
|
+
}).?);
|
|
358
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(row.id, .{
|
|
359
|
+
.phase = .key_down,
|
|
360
|
+
.key = "enter",
|
|
361
|
+
}).?);
|
|
362
|
+
}
|
|
363
|
+
|
|
324
364
|
test "textarea keyboard: enter edits a newline, submit rides the primary chord" {
|
|
325
365
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
326
366
|
defer arena_state.deinit();
|