@native-sdk/cli 0.9.0 → 0.9.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 +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -474,7 +474,7 @@ test "a dead handler on a non-hit-target element reports the attribute position"
|
|
|
474
474
|
try testing.expectEqual(@as(?markup.MarkupErrorInfo, null), markup.validate(try fixed_parser.parse()));
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
-
test "the a11y lint: unnamed controls,
|
|
477
|
+
test "the a11y lint: unnamed controls, radiogroups, and text entry are errors" {
|
|
478
478
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
479
479
|
defer arena_state.deinit();
|
|
480
480
|
const arena = arena_state.allocator();
|
|
@@ -490,6 +490,11 @@ test "the a11y lint: unnamed controls, icon-only controls, and unnamed text entr
|
|
|
490
490
|
// not a name (hearing the content does not say what to type).
|
|
491
491
|
.{ .source = "<row>\n <text-field on-input=\"draft\" />\n</row>", .message = markup.a11y_unlabeled_editable_message },
|
|
492
492
|
.{ .source = "<row>\n <input text=\"{query}\" on-input=\"draft\" />\n</row>", .message = markup.a11y_unlabeled_editable_message },
|
|
493
|
+
// A radio group's individually named choices do not name their
|
|
494
|
+
// shared question. The built-in element and a literal role
|
|
495
|
+
// override both require their own label.
|
|
496
|
+
.{ .source = "<radio-group>\n <radio label=\"Default\" />\n</radio-group>", .message = markup.a11y_unlabeled_radiogroup_message },
|
|
497
|
+
.{ .source = "<row role=\"radiogroup\">\n <radio label=\"Default\" />\n</row>", .message = markup.a11y_unlabeled_radiogroup_message },
|
|
493
498
|
// A blank label is not a name on a control (unlike an image,
|
|
494
499
|
// where the empty label is the decorative opt-out).
|
|
495
500
|
.{ .source = "<row>\n <checkbox label=\" \" on-toggle=\"select\" />\n</row>", .message = markup.a11y_unlabeled_control_message },
|
|
@@ -505,6 +510,7 @@ test "the a11y lint: unnamed controls, icon-only controls, and unnamed text entr
|
|
|
505
510
|
// select's face content.
|
|
506
511
|
const clean = [_][]const u8{
|
|
507
512
|
"<row>\n <checkbox on-toggle=\"select\">Done</checkbox>\n</row>",
|
|
513
|
+
"<radio-group label=\"Density\">\n <radio checked=\"true\">Default</radio>\n</radio-group>",
|
|
508
514
|
"<row>\n <checkbox text=\"Done\" on-toggle=\"select\" />\n</row>",
|
|
509
515
|
"<row>\n <checkbox label=\"Done\" on-toggle=\"select\" />\n</row>",
|
|
510
516
|
"<row>\n <button icon=\"trash\" label=\"Delete\" on-press=\"remove\"></button>\n</row>",
|
|
@@ -514,6 +520,8 @@ test "the a11y lint: unnamed controls, icon-only controls, and unnamed text entr
|
|
|
514
520
|
"<row>\n <textarea label=\"Body\" on-input=\"draft\" />\n</row>",
|
|
515
521
|
"<row>\n <select on-press=\"open\">Newest first</select>\n</row>",
|
|
516
522
|
"<row>\n <select text=\"{choice}\" on-press=\"open\"/>\n</row>",
|
|
523
|
+
"<radio-group label=\"Density\">\n <radio label=\"Default\" />\n</radio-group>",
|
|
524
|
+
"<row role=\"radiogroup\" label=\"{question}\">\n <radio label=\"Default\" />\n</row>",
|
|
517
525
|
};
|
|
518
526
|
for (clean) |source| {
|
|
519
527
|
var parser = markup.Parser.init(arena, source);
|
|
@@ -632,7 +640,7 @@ test "collectA11yErrors reports every a11y error in one pass with validate's pos
|
|
|
632
640
|
try testing.expectEqual(@as(usize, 0), markup.collectA11yErrors(try clean_parser.parse(), &storage).len);
|
|
633
641
|
}
|
|
634
642
|
|
|
635
|
-
test "press and
|
|
643
|
+
test "press toggle and drag handlers are legal on layout elements (press fall-through makes them interactive)" {
|
|
636
644
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
637
645
|
defer arena_state.deinit();
|
|
638
646
|
|
|
@@ -644,6 +652,7 @@ test "press and toggle handlers are legal on layout elements (press fall-through
|
|
|
644
652
|
"<column>\n <row on-press=\"select\" gap=\"8\">\n <text>press me</text>\n </row>\n</column>",
|
|
645
653
|
"<column on-press=\"add\">\n <text>x</text>\n</column>",
|
|
646
654
|
"<column>\n <stack on-toggle=\"flip\">\n <text>x</text>\n </stack>\n</column>",
|
|
655
|
+
"<column>\n <row on-drag=\"drag:{open_count}\" label=\"Draggable\">\n <text>x</text>\n </row>\n</column>",
|
|
647
656
|
"<row>\n <icon name=\"search\" on-press=\"go\" />\n</row>",
|
|
648
657
|
"<row>\n <badge on-press=\"open\">3</badge>\n</row>",
|
|
649
658
|
};
|
|
@@ -512,9 +512,15 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
514
|
if (elementTakesText(kind) and !composite_children) {
|
|
515
|
-
const text = try self.interpolatedText(ui, scope, inner);
|
|
516
515
|
var built = ui.el(kind, options, .{});
|
|
517
|
-
|
|
516
|
+
// Element content wins when present; an empty element
|
|
517
|
+
// keeps the already-resolved text= attribute in options.
|
|
518
|
+
// Checkbox/radio joined this path when they became text
|
|
519
|
+
// leaves, so replacing unconditionally would regress the
|
|
520
|
+
// binding-friendly attribute that already worked.
|
|
521
|
+
if (inner.children.len > 0) {
|
|
522
|
+
built.widget.text = try self.interpolatedText(ui, scope, inner);
|
|
523
|
+
}
|
|
518
524
|
// Avatars clip their runtime image to the avatar circle,
|
|
519
525
|
// exactly like `Ui.avatar` (a no-op while the id is 0 and
|
|
520
526
|
// the initials fallback renders).
|
|
@@ -28,6 +28,16 @@ pub const Msg = union(enum) {
|
|
|
28
28
|
toggle: u32,
|
|
29
29
|
set_filter: Filter,
|
|
30
30
|
draft: canvas.TextInputEvent,
|
|
31
|
+
drag: DragPayload,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
pub const DragPayload = struct {
|
|
35
|
+
sourceId: usize,
|
|
36
|
+
phase: u8,
|
|
37
|
+
x: f32,
|
|
38
|
+
y: f32,
|
|
39
|
+
viewWidth: f32,
|
|
40
|
+
viewHeight: f32,
|
|
31
41
|
};
|
|
32
42
|
|
|
33
43
|
pub const Model = struct {
|
|
@@ -1208,6 +1218,35 @@ pub const context_menu_markup_source =
|
|
|
1208
1218
|
\\</column>
|
|
1209
1219
|
;
|
|
1210
1220
|
|
|
1221
|
+
pub const drag_context_menu_markup_source =
|
|
1222
|
+
\\<row on-drag="drag:{open_count}" label="Draggable row">
|
|
1223
|
+
\\ <text>Drag me</text>
|
|
1224
|
+
\\ <context-menu>
|
|
1225
|
+
\\ <menu-item on-press="add">Duplicate</menu-item>
|
|
1226
|
+
\\ </context-menu>
|
|
1227
|
+
\\</row>
|
|
1228
|
+
;
|
|
1229
|
+
|
|
1230
|
+
test "a drag-only layout element can host a context menu" {
|
|
1231
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1232
|
+
defer arena_state.deinit();
|
|
1233
|
+
const arena = arena_state.allocator();
|
|
1234
|
+
const model = testModel();
|
|
1235
|
+
|
|
1236
|
+
var parser = canvas.ui_markup.Parser.init(arena, drag_context_menu_markup_source);
|
|
1237
|
+
try testing.expectEqual(@as(?canvas.ui_markup.MarkupErrorInfo, null), canvas.ui_markup.validate(try parser.parse()));
|
|
1238
|
+
|
|
1239
|
+
var view = try InboxMarkup.init(arena, drag_context_menu_markup_source);
|
|
1240
|
+
var ui = InboxUi.init(arena);
|
|
1241
|
+
const tree = try ui.finalize(try view.build(&ui, &model));
|
|
1242
|
+
try testing.expect(tree.root.semantics.actions.drag);
|
|
1243
|
+
try testing.expect(canvas.widgetIsHitTarget(tree.root));
|
|
1244
|
+
try testing.expect(canvas.widgetClaimsPress(tree.root));
|
|
1245
|
+
try testing.expectEqual(@as(usize, 1), tree.root.context_menu.len);
|
|
1246
|
+
try testing.expectEqualStrings("Duplicate", tree.root.context_menu[0].label);
|
|
1247
|
+
try testing.expectEqual(Msg.add, tree.msgForContextMenu(tree.root.id, 0).?);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1211
1250
|
test "markup context-menus lower to declared platform-menu items on their host" {
|
|
1212
1251
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1213
1252
|
defer arena_state.deinit();
|
|
@@ -1418,6 +1457,12 @@ test "the registry's a11y name classes match the engine's control predicates" {
|
|
|
1418
1457
|
if (entry.a11y_name == .image) {
|
|
1419
1458
|
try testing.expect(kind == .avatar or kind == .media_surface or kind == .image);
|
|
1420
1459
|
}
|
|
1460
|
+
// Radio-group is the one named container class: it is not a hit
|
|
1461
|
+
// target, but its label supplies the shared question announced
|
|
1462
|
+
// around the descendant radio choices.
|
|
1463
|
+
if (entry.a11y_name == .radiogroup) {
|
|
1464
|
+
try testing.expectEqual(canvas.WidgetKind.radio_group, kind);
|
|
1465
|
+
}
|
|
1421
1466
|
}
|
|
1422
1467
|
}
|
|
1423
1468
|
|
|
@@ -2171,8 +2216,8 @@ pub const catalog_markup_source =
|
|
|
2171
2216
|
\\ <input text="{query}" placeholder="Name" autofocus="true" on-input="query_edit" on-submit="submit_query" grow="1" />
|
|
2172
2217
|
\\ <combobox text="{query}" placeholder="Search fruit" on-input="query_edit" />
|
|
2173
2218
|
\\ </row>
|
|
2174
|
-
\\ <radio-group gap="4">
|
|
2175
|
-
\\ <radio checked="{bold}" on-
|
|
2219
|
+
\\ <radio-group gap="4" label="Formatting">
|
|
2220
|
+
\\ <radio checked="{bold}" on-change="toggle_bold" label="Bold" />
|
|
2176
2221
|
\\ </radio-group>
|
|
2177
2222
|
\\ <accordion text="Details" selected="{details_open}" on-toggle="toggle_details" padding="8">
|
|
2178
2223
|
\\ <text>More info</text>
|
|
@@ -2301,8 +2346,8 @@ pub fn handCatalogView(ui: *CatalogUi, model: *const CatalogModel) CatalogUi.Nod
|
|
|
2301
2346
|
ui.el(.input, .{ .text = model.query, .placeholder = "Name", .autofocus = true, .on_input = CatalogUi.inputMsg(.query_edit), .on_submit = .submit_query, .grow = 1 }, .{}),
|
|
2302
2347
|
ui.el(.combobox, .{ .text = model.query, .placeholder = "Search fruit", .on_input = CatalogUi.inputMsg(.query_edit) }, .{}),
|
|
2303
2348
|
}),
|
|
2304
|
-
ui.el(.radio_group, .{ .gap = 4 }, .{
|
|
2305
|
-
ui.el(.radio, .{ .checked = model.bold, .
|
|
2349
|
+
ui.el(.radio_group, .{ .gap = 4, .semantics = .{ .label = "Formatting" } }, .{
|
|
2350
|
+
ui.el(.radio, .{ .checked = model.bold, .on_change = .toggle_bold }, .{}),
|
|
2306
2351
|
}),
|
|
2307
2352
|
ui.el(.accordion, .{ .text = "Details", .selected = model.details_open, .on_toggle = .toggle_details, .padding = 8 }, .{
|
|
2308
2353
|
ui.text(.{}, "More info"),
|
|
@@ -50,7 +50,7 @@ const std = @import("std");
|
|
|
50
50
|
/// documents, journals, serialized contracts) carry it; readers reach
|
|
51
51
|
/// older artifacts through document→document migrations, never silent
|
|
52
52
|
/// reinterpretation.
|
|
53
|
-
pub const schema_version: u16 =
|
|
53
|
+
pub const schema_version: u16 = 2;
|
|
54
54
|
|
|
55
55
|
/// Value type-class of an attribute: what shape of value the engines
|
|
56
56
|
/// accept for it. `option` values name a Zig enum member (the enum itself
|
|
@@ -128,8 +128,8 @@ pub const EventInfo = struct {
|
|
|
128
128
|
/// ever receive this event.
|
|
129
129
|
dismissible_only: bool = false,
|
|
130
130
|
/// This handler binds control/text behavior a non-hit-target element
|
|
131
|
-
/// does not have, so it is a dead handler there (press/toggle
|
|
132
|
-
/// exempt:
|
|
131
|
+
/// does not have, so it is a dead handler there (press/toggle/drag
|
|
132
|
+
/// are exempt: their handlers make any element interactive).
|
|
133
133
|
dead_on_non_hit_target: bool = false,
|
|
134
134
|
};
|
|
135
135
|
|
|
@@ -145,12 +145,16 @@ pub const EventInfo = struct {
|
|
|
145
145
|
/// - `image`: pictorial content. An unnamed image degrades (announced as
|
|
146
146
|
/// an unnamed image) but does not block, so a missing alt-equivalent
|
|
147
147
|
/// label is a WARNING; an explicit `label=""` marks it decorative.
|
|
148
|
+
/// - `radiogroup`: a single-choice container whose label supplies the
|
|
149
|
+
/// shared question for its individually named choices. Only a nonblank
|
|
150
|
+
/// `label` names the group; a missing one is an ERROR.
|
|
148
151
|
/// - `none`: layout, decoration, and content whose name IS its text.
|
|
149
152
|
pub const A11yNameRule = enum {
|
|
150
153
|
none,
|
|
151
154
|
control,
|
|
152
155
|
editable,
|
|
153
156
|
image,
|
|
157
|
+
radiogroup,
|
|
154
158
|
};
|
|
155
159
|
|
|
156
160
|
pub const ElementInfo = struct {
|
|
@@ -221,7 +225,7 @@ pub const elements = [_]ElementInfo{
|
|
|
221
225
|
.{ .code = 11, .name = "breadcrumb", .widget_kind = "breadcrumb", .hit_target = false },
|
|
222
226
|
.{ .code = 12, .name = "button-group", .widget_kind = "button_group", .hit_target = false },
|
|
223
227
|
.{ .code = 13, .name = "pagination", .widget_kind = "pagination", .hit_target = false },
|
|
224
|
-
.{ .code = 14, .name = "radio-group", .widget_kind = "radio_group", .hit_target = false },
|
|
228
|
+
.{ .code = 14, .name = "radio-group", .widget_kind = "radio_group", .hit_target = false, .a11y_name = .radiogroup },
|
|
225
229
|
.{ .code = 15, .name = "tabs", .widget_kind = "tabs", .hit_target = false },
|
|
226
230
|
.{ .code = 16, .name = "toggle-group", .widget_kind = "toggle_group", .hit_target = false },
|
|
227
231
|
// Vertical containers.
|
|
@@ -257,8 +261,8 @@ pub const elements = [_]ElementInfo{
|
|
|
257
261
|
// paints whenever the view renders it.
|
|
258
262
|
.{ .code = 39, .name = "tooltip", .widget_kind = "tooltip", .takes_text = true, .hit_target = false, .anchorable = true },
|
|
259
263
|
// Value controls and text entry.
|
|
260
|
-
.{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .a11y_name = .control },
|
|
261
|
-
.{ .code = 41, .name = "radio", .widget_kind = "radio", .a11y_name = .control },
|
|
264
|
+
.{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .takes_text = true, .a11y_name = .control },
|
|
265
|
+
.{ .code = 41, .name = "radio", .widget_kind = "radio", .takes_text = true, .a11y_name = .control },
|
|
262
266
|
.{ .code = 42, .name = "slider", .widget_kind = "slider", .a11y_name = .control },
|
|
263
267
|
.{ .code = 43, .name = "progress", .widget_kind = "progress" },
|
|
264
268
|
.{ .code = 44, .name = "text-field", .widget_kind = "text_field", .a11y_name = .editable },
|
|
@@ -683,12 +687,12 @@ pub const icon_names = [_][]const u8{
|
|
|
683
687
|
/// std-only) with a lockstep test in ui_markup_view_tests.zig holding the
|
|
684
688
|
/// mirror equal to the live enum.
|
|
685
689
|
pub const role_names = [_][]const u8{
|
|
686
|
-
"none",
|
|
687
|
-
"button",
|
|
688
|
-
"menuitem",
|
|
689
|
-
"gridcell",
|
|
690
|
-
"slider", "progressbar", "chart",
|
|
691
|
-
"separator",
|
|
690
|
+
"none", "group", "text", "link", "image",
|
|
691
|
+
"button", "textbox", "tooltip", "dialog", "menu",
|
|
692
|
+
"menuitem", "list", "listitem", "row", "grid",
|
|
693
|
+
"gridcell", "tab", "checkbox", "radio", "radiogroup",
|
|
694
|
+
"switch_control", "slider", "progressbar", "chart", "tree",
|
|
695
|
+
"treeitem", "separator",
|
|
692
696
|
};
|
|
693
697
|
|
|
694
698
|
/// Roles that promise CHILD STRUCTURE to assistive tech (rows, items,
|
|
@@ -696,7 +700,7 @@ pub const role_names = [_][]const u8{
|
|
|
696
700
|
/// cannot hold element children (see `elementHoldsChildren`) is role
|
|
697
701
|
/// misuse the registry can see: the promise can never be kept.
|
|
698
702
|
pub const container_role_names = [_][]const u8{
|
|
699
|
-
"tree", "list", "menu", "grid", "row", "dialog",
|
|
703
|
+
"tree", "list", "menu", "grid", "row", "dialog", "radiogroup",
|
|
700
704
|
};
|
|
701
705
|
|
|
702
706
|
/// Whether markup can put element children inside this element: text
|
|
@@ -375,6 +375,53 @@ test "tree keyboard navigation can select without dispatching pointer activation
|
|
|
375
375
|
}).?);
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
test "radio selection dispatches change then toggle then press on every input path" {
|
|
379
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
380
|
+
defer arena_state.deinit();
|
|
381
|
+
|
|
382
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
383
|
+
const tree = try ui.finalize(ui.el(.radio_group, .{}, .{
|
|
384
|
+
ui.el(.radio, .{ .text = "All", .on_change = .add, .on_toggle = .load_more }, .{}),
|
|
385
|
+
ui.el(.radio, .{ .text = "Toggle fallback", .on_toggle = .load_more, .on_press = .add }, .{}),
|
|
386
|
+
ui.el(.radio, .{ .text = "Press fallback", .on_press = .add }, .{}),
|
|
387
|
+
ui.el(.radio, .{ .text = "Selected", .checked = true, .on_change = .add, .on_press = .load_more }, .{}),
|
|
388
|
+
}));
|
|
389
|
+
const change_radio = tree.root.children[0];
|
|
390
|
+
const toggle_radio = tree.root.children[1];
|
|
391
|
+
const press_radio = tree.root.children[2];
|
|
392
|
+
const selected_radio = tree.root.children[3];
|
|
393
|
+
|
|
394
|
+
try testing.expectEqual(Msg.add, tree.msgForPointer(change_radio.id, .up).?);
|
|
395
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{ .phase = .key_down, .key = "space" }).?);
|
|
396
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{ .phase = .key_down, .key = "enter" }).?);
|
|
397
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{
|
|
398
|
+
.phase = .key_down,
|
|
399
|
+
.key = "arrowright",
|
|
400
|
+
.focus_moved = true,
|
|
401
|
+
.radio_group_navigation = true,
|
|
402
|
+
.radio_group_selection = true,
|
|
403
|
+
}).?);
|
|
404
|
+
try testing.expectEqual(Msg.load_more, tree.msgForPointer(toggle_radio.id, .up).?);
|
|
405
|
+
try testing.expectEqual(Msg.add, tree.msgForPointer(press_radio.id, .up).?);
|
|
406
|
+
|
|
407
|
+
// `on_change` is an edge, not an activation alias. Direct tree
|
|
408
|
+
// consumers derive the result from source state; runtime events carry
|
|
409
|
+
// the retained mutation explicitly. Reselecting falls through to the
|
|
410
|
+
// historical activation handler when one exists.
|
|
411
|
+
try testing.expectEqual(Msg.load_more, tree.msgForPointer(selected_radio.id, .up).?);
|
|
412
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(selected_radio.id, .{ .phase = .key_down, .key = "space" }).?);
|
|
413
|
+
try testing.expectEqual(Msg.load_more, tree.msgForPointerEvent(change_radio.id, .{
|
|
414
|
+
.phase = .up,
|
|
415
|
+
.point = .{},
|
|
416
|
+
.radio_selection_changed = false,
|
|
417
|
+
}).?);
|
|
418
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(selected_radio.id, .{
|
|
419
|
+
.phase = .key_down,
|
|
420
|
+
.key = "space",
|
|
421
|
+
.radio_selection_changed = true,
|
|
422
|
+
}).?);
|
|
423
|
+
}
|
|
424
|
+
|
|
378
425
|
test "textarea keyboard: the default and chat-composer Enter policies stay distinct" {
|
|
379
426
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
380
427
|
defer arena_state.deinit();
|
|
@@ -174,15 +174,15 @@ pub fn widgetKindClaimsPress(kind: WidgetKind) bool {
|
|
|
174
174
|
|
|
175
175
|
/// Whether a press gesture stops at this widget instead of falling
|
|
176
176
|
/// through to the nearest claiming ancestor: an interactive kind
|
|
177
|
-
/// (`widgetKindClaimsPress`), or ANY widget with a bound press/toggle
|
|
178
|
-
/// handler (`on_press`/`on_toggle` stamp `semantics.actions`, and
|
|
177
|
+
/// (`widgetKindClaimsPress`), or ANY widget with a bound press/toggle/drag
|
|
178
|
+
/// handler (`on_press`/`on_toggle`/`on_drag` stamp `semantics.actions`, and
|
|
179
179
|
/// engine-owned `command` dispatch only exists on kinds already claiming).
|
|
180
180
|
/// Disabled widgets never claim — the hit test skips them too, so a press
|
|
181
181
|
/// on a disabled control keeps today's behavior of landing on whatever is
|
|
182
182
|
/// around it.
|
|
183
183
|
pub fn widgetClaimsPress(widget: Widget) bool {
|
|
184
184
|
if (widget.id == 0 or widget.state.disabled) return false;
|
|
185
|
-
if (widget.semantics.actions.press or widget.semantics.actions.toggle) return true;
|
|
185
|
+
if (widget.semantics.actions.press or widget.semantics.actions.toggle or widget.semantics.actions.drag) return true;
|
|
186
186
|
return widgetKindClaimsPress(widget.kind);
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -182,6 +182,44 @@ test "leaf trigger kinds lay out their anchored children" {
|
|
|
182
182
|
try std.testing.expect(layout.findById(4) != null);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
test "anchored relayout recomputes placement from a translated trigger frame" {
|
|
186
|
+
const menu_items = [_]Widget{.{ .id = 5, .kind = .menu_item, .frame = geometry.RectF.init(0, 0, 0, 24), .text = "One" }};
|
|
187
|
+
const dropdown = Widget{
|
|
188
|
+
.id = 4,
|
|
189
|
+
.kind = .dropdown_menu,
|
|
190
|
+
.frame = geometry.RectF.init(0, 0, 140, 50),
|
|
191
|
+
.layout = .{ .anchor = .{} },
|
|
192
|
+
.children = &menu_items,
|
|
193
|
+
};
|
|
194
|
+
const wrap_children = [_]Widget{
|
|
195
|
+
.{ .id = 3, .kind = .text, .text = "Files" },
|
|
196
|
+
dropdown,
|
|
197
|
+
};
|
|
198
|
+
const scroll_children = [_]Widget{
|
|
199
|
+
.{ .id = 2, .kind = .stack, .frame = geometry.RectF.init(0, 140, 160, 28), .children = &wrap_children },
|
|
200
|
+
.{ .id = 6, .kind = .panel, .frame = geometry.RectF.init(0, 320, 160, 20) },
|
|
201
|
+
};
|
|
202
|
+
const scroll = Widget{ .id = 1, .kind = .scroll_view, .children = &scroll_children };
|
|
203
|
+
var nodes: [6]WidgetLayoutNode = undefined;
|
|
204
|
+
const layout = try canvas.layoutWidgetTree(scroll, geometry.RectF.init(0, 0, 180, 100), &nodes);
|
|
205
|
+
|
|
206
|
+
// Model the post-layout scroll restore: content moved, while the old
|
|
207
|
+
// anchored frame merely rode the translation and retained its stale
|
|
208
|
+
// pre-scroll clamp.
|
|
209
|
+
for (nodes[1..layout.nodes.len]) |*node| {
|
|
210
|
+
node.frame.y -= 130;
|
|
211
|
+
node.widget.frame = node.frame;
|
|
212
|
+
}
|
|
213
|
+
try canvas.relayoutAnchoredChildren(nodes[0..layout.nodes.len], .{});
|
|
214
|
+
|
|
215
|
+
const relaid = canvas.WidgetLayoutTree{ .nodes = nodes[0..layout.nodes.len] };
|
|
216
|
+
const trigger = relaid.findById(2).?.frame;
|
|
217
|
+
const surface = relaid.findById(4).?.frame;
|
|
218
|
+
try std.testing.expectEqual(@as(f32, 10), trigger.y);
|
|
219
|
+
try std.testing.expectEqual(trigger.maxY() + 4, surface.y);
|
|
220
|
+
try std.testing.expectEqual(@as(f32, 50), surface.height);
|
|
221
|
+
}
|
|
222
|
+
|
|
185
223
|
/// The shared fixture for z-order/clip tests: a scroll pane whose content
|
|
186
224
|
/// holds the trigger + anchored dropdown, and a LATER sibling panel the
|
|
187
225
|
/// dropdown overlaps. In-tree paint order would put the panel above the
|
|
@@ -217,6 +255,74 @@ fn firstCommandIndexForWidget(list: canvas.DisplayList, widget_id: canvas.Object
|
|
|
217
255
|
return null;
|
|
218
256
|
}
|
|
219
257
|
|
|
258
|
+
test "window-level modals paint and route above later anchored overlays" {
|
|
259
|
+
const dialog = Widget{
|
|
260
|
+
.id = 2,
|
|
261
|
+
.kind = .dialog,
|
|
262
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
263
|
+
};
|
|
264
|
+
const dropdown = Widget{
|
|
265
|
+
.id = 3,
|
|
266
|
+
.kind = .dropdown_menu,
|
|
267
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
268
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(100, 100) } },
|
|
269
|
+
};
|
|
270
|
+
// The dropdown mounts later and overlaps the centered dialog exactly.
|
|
271
|
+
// Modal token order, not raw node order, owns the window-level stack.
|
|
272
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &.{ dialog, dropdown } };
|
|
273
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
274
|
+
const layout = try canvas.layoutWidgetTree(root, window, &nodes);
|
|
275
|
+
|
|
276
|
+
var commands: [64]canvas.CanvasCommand = undefined;
|
|
277
|
+
var builder = canvas.Builder.init(&commands);
|
|
278
|
+
try layout.emitDisplayList(&builder, .{});
|
|
279
|
+
const list = builder.displayList();
|
|
280
|
+
const dialog_index = firstCommandIndexForWidget(list, 2) orelse return error.TestUnexpectedResult;
|
|
281
|
+
const dropdown_index = firstCommandIndexForWidget(list, 3) orelse return error.TestUnexpectedResult;
|
|
282
|
+
try std.testing.expect(dialog_index > dropdown_index);
|
|
283
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 2), layout.hitTest(geometry.PointF.init(150, 150)).?.id);
|
|
284
|
+
|
|
285
|
+
// An explicit layer remains the author-controlled escape hatch.
|
|
286
|
+
const elevated_dropdown = Widget{
|
|
287
|
+
.id = 3,
|
|
288
|
+
.kind = .dropdown_menu,
|
|
289
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
290
|
+
.layer = 400,
|
|
291
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(100, 100) } },
|
|
292
|
+
};
|
|
293
|
+
const elevated_root = Widget{ .id = 1, .kind = .stack, .children = &.{ dialog, elevated_dropdown } };
|
|
294
|
+
var elevated_nodes: [4]WidgetLayoutNode = undefined;
|
|
295
|
+
const elevated = try canvas.layoutWidgetTree(elevated_root, window, &elevated_nodes);
|
|
296
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 3), elevated.hitTest(geometry.PointF.init(150, 150)).?.id);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
test "default anchored surfaces inside a modal stay above their modal" {
|
|
300
|
+
const dropdown = Widget{
|
|
301
|
+
.id = 3,
|
|
302
|
+
.kind = .dropdown_menu,
|
|
303
|
+
.frame = geometry.RectF.init(0, 0, 100, 50),
|
|
304
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(120, 120) } },
|
|
305
|
+
};
|
|
306
|
+
const dialog = Widget{
|
|
307
|
+
.id = 2,
|
|
308
|
+
.kind = .dialog,
|
|
309
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
310
|
+
.children = &.{dropdown},
|
|
311
|
+
};
|
|
312
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &.{dialog} };
|
|
313
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
314
|
+
const layout = try canvas.layoutWidgetTree(root, window, &nodes);
|
|
315
|
+
|
|
316
|
+
var commands: [64]canvas.CanvasCommand = undefined;
|
|
317
|
+
var builder = canvas.Builder.init(&commands);
|
|
318
|
+
try layout.emitDisplayList(&builder, .{});
|
|
319
|
+
const list = builder.displayList();
|
|
320
|
+
const dialog_index = firstCommandIndexForWidget(list, 2) orelse return error.TestUnexpectedResult;
|
|
321
|
+
const dropdown_index = firstCommandIndexForWidget(list, 3) orelse return error.TestUnexpectedResult;
|
|
322
|
+
try std.testing.expect(dropdown_index > dialog_index);
|
|
323
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 3), layout.hitTest(geometry.PointF.init(140, 140)).?.id);
|
|
324
|
+
}
|
|
325
|
+
|
|
220
326
|
test "anchored surfaces render in a late z-pass above later siblings and outside ancestor clips" {
|
|
221
327
|
var nodes: [8]WidgetLayoutNode = undefined;
|
|
222
328
|
const layout = try buildOverlapFixture(&nodes);
|