@native-sdk/cli 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/build.zig +41 -0
  2. package/package.json +9 -9
  3. package/packages/core/package-lock.json +2 -2
  4. package/packages/core/package.json +1 -1
  5. package/packages/core/sdk/events.ts +39 -2
  6. package/packages/core/src/checker.ts +1 -1
  7. package/packages/core/src/emitter.ts +39 -3
  8. package/packages/core/src/infer.ts +53 -7
  9. package/skill-data/automation/SKILL.md +7 -4
  10. package/skill-data/core/references/app-model-runtime.md +3 -0
  11. package/skill-data/native-ui/SKILL.md +3 -2
  12. package/src/app_runner/root.zig +25 -0
  13. package/src/automation/protocol.zig +20 -1
  14. package/src/embed/host.zig +27 -0
  15. package/src/embed/tests.zig +69 -0
  16. package/src/embed/ui_host.zig +4 -0
  17. package/src/platform/macos/appkit_host.h +11 -0
  18. package/src/platform/macos/appkit_host.m +130 -0
  19. package/src/platform/macos/root.zig +34 -0
  20. package/src/platform/null_platform_tests.zig +39 -0
  21. package/src/platform/root.zig +3 -0
  22. package/src/platform/types.zig +118 -4
  23. package/src/primitives/canvas/chart.zig +7 -7
  24. package/src/primitives/canvas/chart_tests.zig +66 -0
  25. package/src/primitives/canvas/commands.zig +48 -0
  26. package/src/primitives/canvas/events.zig +161 -0
  27. package/src/primitives/canvas/font_ttf.zig +155 -8
  28. package/src/primitives/canvas/font_ttf_tests.zig +686 -0
  29. package/src/primitives/canvas/reference.zig +67 -8
  30. package/src/primitives/canvas/render_fingerprints.zig +8 -0
  31. package/src/primitives/canvas/root.zig +26 -0
  32. package/src/primitives/canvas/tokens.zig +170 -7
  33. package/src/primitives/canvas/ui.zig +62 -7
  34. package/src/primitives/canvas/ui_markup.zig +51 -4
  35. package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
  36. package/src/primitives/canvas/ui_markup_compiled.zig +49 -4
  37. package/src/primitives/canvas/ui_markup_compiled_tests.zig +160 -0
  38. package/src/primitives/canvas/ui_markup_contract.zig +9 -0
  39. package/src/primitives/canvas/ui_markup_contract_tests.zig +24 -0
  40. package/src/primitives/canvas/ui_markup_tests.zig +73 -0
  41. package/src/primitives/canvas/ui_markup_view.zig +63 -5
  42. package/src/primitives/canvas/ui_markup_view_tests.zig +151 -2
  43. package/src/primitives/canvas/ui_schema.zig +31 -1
  44. package/src/primitives/canvas/ui_schema_tests.zig +11 -11
  45. package/src/primitives/canvas/ui_tests.zig +31 -0
  46. package/src/primitives/canvas/vector.zig +258 -141
  47. package/src/primitives/canvas/widget_access.zig +1 -1
  48. package/src/primitives/canvas/widget_builtin_tests.zig +259 -0
  49. package/src/primitives/canvas/widget_layout.zig +13 -5
  50. package/src/primitives/canvas/widget_layout_tests.zig +82 -0
  51. package/src/primitives/canvas/widget_render.zig +78 -40
  52. package/src/primitives/canvas/widget_render_controls.zig +15 -4
  53. package/src/primitives/canvas/widget_semantics.zig +6 -1
  54. package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
  55. package/src/primitives/canvas/widget_text_input.zig +118 -10
  56. package/src/primitives/canvas/widget_tree.zig +14 -2
  57. package/src/primitives/canvas/widgets.zig +28 -0
  58. package/src/root.zig +5 -0
  59. package/src/runtime/api.zig +13 -0
  60. package/src/runtime/automation_commands.zig +33 -0
  61. package/src/runtime/automation_widget_dispatch.zig +159 -28
  62. package/src/runtime/canvas_font_tests.zig +272 -3
  63. package/src/runtime/canvas_fonts.zig +60 -20
  64. package/src/runtime/canvas_frame.zig +15 -0
  65. package/src/runtime/canvas_frame_helpers.zig +15 -0
  66. package/src/runtime/canvas_image_tests.zig +26 -0
  67. package/src/runtime/canvas_images.zig +33 -7
  68. package/src/runtime/canvas_limits.zig +44 -8
  69. package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
  70. package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
  71. package/src/runtime/canvas_widget_context_menu.zig +3 -2
  72. package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
  73. package/src/runtime/canvas_widget_events.zig +1295 -7
  74. package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
  75. package/src/runtime/canvas_widget_runtime.zig +24 -7
  76. package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
  77. package/src/runtime/canvas_widget_state.zig +88 -6
  78. package/src/runtime/canvas_widget_text_tests.zig +277 -0
  79. package/src/runtime/core.zig +112 -6
  80. package/src/runtime/flow.zig +51 -1
  81. package/src/runtime/gpu_surface_events.zig +51 -5
  82. package/src/runtime/media_surface.zig +726 -0
  83. package/src/runtime/media_surface_tests.zig +1476 -0
  84. package/src/runtime/root.zig +9 -0
  85. package/src/runtime/session_journal.zig +52 -13
  86. package/src/runtime/session_record.zig +166 -0
  87. package/src/runtime/session_tests.zig +575 -0
  88. package/src/runtime/tests.zig +1 -0
  89. package/src/runtime/ts_ui_app.zig +56 -0
  90. package/src/runtime/ui_app.zig +64 -1
  91. package/src/runtime/ui_app_tests.zig +794 -0
  92. package/src/runtime/view.zig +86 -0
  93. package/src/runtime/view_widget_text.zig +18 -1
  94. package/src/runtime/view_widget_tree.zig +339 -20
  95. package/src/runtime/widget_bridge.zig +26 -0
  96. package/src/runtime/window_storage.zig +61 -15
  97. package/src/runtime/window_view_runtime.zig +13 -0
  98. package/src/runtime/window_views.zig +6 -0
@@ -716,6 +716,84 @@ test "resize-duration and resize-easing on split stamp the layout-tween declarat
716
716
  try testing.expectEqual(canvas.Easing.standard, plain.resize_easing);
717
717
  }
718
718
 
719
+ test "anchor and tooltip-delay on tooltip stamp the hover-intent declaration" {
720
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
721
+ defer arena_state.deinit();
722
+ const arena = arena_state.allocator();
723
+ const model = Model{};
724
+
725
+ // An anchored tooltip declaring its own delay, an anchored tooltip
726
+ // on the token default, and a bare static tooltip that keeps the
727
+ // classic paints-when-rendered leaf — so existing documents lower
728
+ // byte-identically.
729
+ var view = try InboxMarkup.init(arena, "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"250\">Bold the selection</tooltip>\n </stack>\n <stack>\n <text>Link</text>\n <tooltip anchor=\"below\">Insert a link</tooltip>\n </stack>\n <tooltip>Copied!</tooltip>\n</column>");
730
+ var ui = InboxUi.init(arena);
731
+ const tree = try ui.finalize(try view.build(&ui, &model));
732
+
733
+ const declared = findByText(tree.root, .tooltip, "Bold the selection").?;
734
+ try testing.expectEqual(@as(i32, 250), declared.tooltip_delay_ms);
735
+ try testing.expectEqual(canvas.WidgetAnchorPlacement.above, declared.layout.anchor.?.placement);
736
+
737
+ const defaulted = findByText(tree.root, .tooltip, "Insert a link").?;
738
+ try testing.expectEqual(@as(i32, -1), defaulted.tooltip_delay_ms);
739
+ try testing.expectEqual(canvas.WidgetAnchorPlacement.below, defaulted.layout.anchor.?.placement);
740
+
741
+ const static = findByText(tree.root, .tooltip, "Copied!").?;
742
+ try testing.expectEqual(@as(i32, -1), static.tooltip_delay_ms);
743
+ try testing.expectEqual(@as(?canvas.WidgetAnchor, null), static.layout.anchor);
744
+ }
745
+
746
+ test "tooltip-delay past i32 max fails the build instead of trapping" {
747
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
748
+ defer arena_state.deinit();
749
+ const arena = arena_state.allocator();
750
+ const model = Model{};
751
+
752
+ // One past maxInt(i32): the option field's own type is the bound,
753
+ // so the cast that used to trap is now the grid-lines teaching
754
+ // error. The value parses fine as a 64-bit literal — the failure
755
+ // must come from the attribute seam, not the expression parser.
756
+ var overflow_view = try InboxMarkup.init(arena, "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"2147483648\">Bold the selection</tooltip>\n </stack>\n</column>");
757
+ var overflow_ui = InboxUi.init(arena);
758
+ try testing.expectError(error.MarkupBuild, overflow_view.build(&overflow_ui, &model));
759
+ try testing.expectEqualStrings("expected a non-negative whole number", overflow_view.diagnostic.message);
760
+
761
+ // Boundary values pass: 0 (the instant-show escape hatch) and the
762
+ // type's exact max.
763
+ var boundary_view = try InboxMarkup.init(arena, "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"0\">Bold the selection</tooltip>\n </stack>\n <stack>\n <text>Link</text>\n <tooltip anchor=\"below\" tooltip-delay=\"2147483647\">Insert a link</tooltip>\n </stack>\n</column>");
764
+ var boundary_ui = InboxUi.init(arena);
765
+ const tree = try boundary_ui.finalize(try boundary_view.build(&boundary_ui, &model));
766
+ try testing.expectEqual(@as(i32, 0), findByText(tree.root, .tooltip, "Bold the selection").?.tooltip_delay_ms);
767
+ try testing.expectEqual(@as(i32, std.math.maxInt(i32)), findByText(tree.root, .tooltip, "Insert a link").?.tooltip_delay_ms);
768
+ }
769
+
770
+ test "tooltip-delay model binding past i32 max fails the build instead of trapping" {
771
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
772
+ defer arena_state.deinit();
773
+ const arena = arena_state.allocator();
774
+
775
+ // Bindings deliver i64 model values straight into the same cast
776
+ // seam the literal path uses, so an out-of-range model value must
777
+ // produce the same teaching error — per-build, since only the
778
+ // value (not the document) is wrong.
779
+ const DelayModel = struct { delay: i64 = 0 };
780
+ const DelayMarkup = markup_view.MarkupView(DelayModel, Msg);
781
+ const source = "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"{delay}\">Bold the selection</tooltip>\n </stack>\n</column>";
782
+
783
+ var overflow_view = try DelayMarkup.init(arena, source);
784
+ var overflow_ui = InboxUi.init(arena);
785
+ const overflow_model = DelayModel{ .delay = @as(i64, std.math.maxInt(i32)) + 1 };
786
+ try testing.expectError(error.MarkupBuild, overflow_view.build(&overflow_ui, &overflow_model));
787
+ try testing.expectEqualStrings("expected a non-negative whole number", overflow_view.diagnostic.message);
788
+
789
+ // The same document lowers when the model holds an in-range value.
790
+ var ok_view = try DelayMarkup.init(arena, source);
791
+ var ok_ui = InboxUi.init(arena);
792
+ const ok_model = DelayModel{ .delay = 250 };
793
+ const tree = try ok_ui.finalize(try ok_view.build(&ok_ui, &ok_model));
794
+ try testing.expectEqual(@as(i32, 250), findByText(tree.root, .tooltip, "Bold the selection").?.tooltip_delay_ms);
795
+ }
796
+
719
797
  test "resize-easing value vocabulary mirrors the live Easing enum" {
720
798
  // The validator's std-only mirror of the enum's member names; a new
721
799
  // member cannot ship without its markup spelling.
@@ -1243,9 +1321,11 @@ test "the registry's a11y name classes match the engine's control predicates" {
1243
1321
  try testing.expect(canvas.widgetKindHitTarget(kind));
1244
1322
  try testing.expect(canvas.widgetKindClaimsPress(kind));
1245
1323
  }
1246
- // Image-class elements are announced under the image role.
1324
+ // Image-class elements are announced under the image role:
1325
+ // avatar and the media surface (pictorial content whose missing
1326
+ // label degrades but never blocks).
1247
1327
  if (entry.a11y_name == .image) {
1248
- try testing.expectEqual(canvas.WidgetKind.avatar, kind);
1328
+ try testing.expect(kind == .avatar or kind == .media_surface);
1249
1329
  }
1250
1330
  }
1251
1331
  }
@@ -2289,6 +2369,9 @@ pub const AvatarModel = struct {
2289
2369
  /// `fx.registerImageBytes`.
2290
2370
  user_image: canvas.ImageId = 0,
2291
2371
  user_name: []const u8 = "Casey Torres",
2372
+ /// A signed id field: bindings evaluate as i64, so a negative must
2373
+ /// reach the image seam as a value, never trap in the u64 cast.
2374
+ stale_image: i64 = -1,
2292
2375
 
2293
2376
  /// A pub fn producing an ImageId binds like a field.
2294
2377
  pub fn teammateImage(model: *const AvatarModel) canvas.ImageId {
@@ -2303,6 +2386,14 @@ pub const avatar_markup_source =
2303
2386
  \\</row>
2304
2387
  ;
2305
2388
 
2389
+ /// A negative model value into avatar's u64 image seam: both engines
2390
+ /// must fail the build with the avatar teaching, never trap.
2391
+ pub const avatar_negative_markup_source =
2392
+ \\<row>
2393
+ \\ <avatar image="{stale_image}">CT</avatar>
2394
+ \\</row>
2395
+ ;
2396
+
2306
2397
  pub const AvatarUi = canvas.Ui(AvatarMsg);
2307
2398
 
2308
2399
  /// The hand-written equivalent of the avatar markup: `ui.avatar` with
@@ -2373,6 +2464,12 @@ test "avatar image misuse fails the build with the teaching messages" {
2373
2464
  .source = "<row>\n <avatar image=\"{user_name}\">CT</avatar>\n</row>",
2374
2465
  .message = canvas.ui_markup.avatar_image_message,
2375
2466
  },
2467
+ .{
2468
+ // A negative integer can never be a u64 ImageId: the
2469
+ // teaching failure, not an @intCast trap.
2470
+ .source = avatar_negative_markup_source,
2471
+ .message = canvas.ui_markup.avatar_image_message,
2472
+ },
2376
2473
  .{
2377
2474
  // Scoped to avatar: the other image elements stay Zig views.
2378
2475
  .source = "<row>\n <badge image=\"{user_image}\">3</badge>\n</row>",
@@ -2388,6 +2485,58 @@ test "avatar image misuse fails the build with the teaching messages" {
2388
2485
  }
2389
2486
  }
2390
2487
 
2488
+ // -------------------------------------------- media-surface id binding
2489
+
2490
+ pub const SurfaceMsg = union(enum) { refresh };
2491
+
2492
+ pub const SurfaceModel = struct {
2493
+ preview: u64 = 5,
2494
+ /// A signed id field: bindings evaluate as i64, so a negative must
2495
+ /// reach the surface seam as a value, never trap in the u64 cast.
2496
+ stale_surface: i64 = -3,
2497
+ };
2498
+
2499
+ pub const surface_markup_source =
2500
+ \\<column>
2501
+ \\ <media-surface surface="{preview}" label="Preview" />
2502
+ \\</column>
2503
+ ;
2504
+
2505
+ /// A negative model value into media-surface's u64 surface seam: both
2506
+ /// engines must fail the build with the surface teaching, never trap.
2507
+ pub const surface_negative_markup_source =
2508
+ \\<column>
2509
+ \\ <media-surface surface="{stale_surface}" label="Preview" />
2510
+ \\</column>
2511
+ ;
2512
+
2513
+ pub const SurfaceUi = canvas.Ui(SurfaceMsg);
2514
+
2515
+ test "the media-surface surface binding resolves the model id; negatives fail the build" {
2516
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2517
+ defer arena_state.deinit();
2518
+ const arena = arena_state.allocator();
2519
+ const SurfaceMarkup = markup_view.MarkupView(SurfaceModel, SurfaceMsg);
2520
+ const model = SurfaceModel{};
2521
+
2522
+ // The u64 model id rides options.image into the widget's image_id
2523
+ // (the media surface's surface-id channel).
2524
+ var view = try SurfaceMarkup.init(arena, surface_markup_source);
2525
+ var ui = SurfaceUi.init(arena);
2526
+ const tree = try ui.finalize(try view.build(&ui, &model));
2527
+ const surface = tree.root.children[0];
2528
+ try testing.expectEqual(canvas.WidgetKind.media_surface, surface.kind);
2529
+ try testing.expectEqual(@as(canvas.ImageId, 5), surface.image_id);
2530
+
2531
+ // A negative integer can never be a u64 surface id: the teaching
2532
+ // failure, not an @intCast trap.
2533
+ var negative_view = try SurfaceMarkup.init(arena, surface_negative_markup_source);
2534
+ var negative_ui = SurfaceUi.init(arena);
2535
+ try testing.expectError(error.MarkupBuild, negative_view.build(&negative_ui, &model));
2536
+ try testing.expectEqualStrings(canvas.ui_markup.media_surface_surface_message, negative_view.diagnostic.message);
2537
+ try testing.expect(negative_view.diagnostic.line > 0);
2538
+ }
2539
+
2391
2540
  // ------------------------------------- text alignment and grid columns
2392
2541
 
2393
2542
  pub const AlignMsg = union(enum) { refresh };
@@ -249,7 +249,13 @@ pub const elements = [_]ElementInfo{
249
249
  .{ .code = 36, .name = "switch", .widget_kind = "switch_control", .takes_text = true, .a11y_name = .control },
250
250
  .{ .code = 37, .name = "table-cell", .widget_kind = "data_cell", .takes_text = true },
251
251
  .{ .code = 38, .name = "toggle-button", .widget_kind = "toggle_button", .takes_text = true, .icon_attr = true, .a11y_name = .control },
252
- .{ .code = 39, .name = "tooltip", .widget_kind = "tooltip", .takes_text = true, .hit_target = false },
252
+ // Tooltip is anchorable: `anchor="above|below"` floats it against
253
+ // its PARENT's frame (the trigger, or the stack wrapping trigger +
254
+ // tooltip), and the RUNTIME owns its visibility — hidden until the
255
+ // hover-intent delay on the trigger fires (see `tooltip-delay`).
256
+ // Without `anchor` it stays the classic static text leaf that
257
+ // paints whenever the view renders it.
258
+ .{ .code = 39, .name = "tooltip", .widget_kind = "tooltip", .takes_text = true, .hit_target = false, .anchorable = true },
253
259
  // Value controls and text entry.
254
260
  .{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .a11y_name = .control },
255
261
  .{ .code = 41, .name = "radio", .widget_kind = "radio", .a11y_name = .control },
@@ -306,6 +312,14 @@ pub const elements = [_]ElementInfo{
306
312
  // end, the reference's trailing dock), so the element mints ONE
307
313
  // code and no attribute codes at all.
308
314
  .{ .code = 65, .name = "reactions", .rule_hook = "reactions" },
315
+ // The media surface: a leaf compositing a texture PRODUCED OUTSIDE
316
+ // the widget tree (video decoder, camera preview, an external
317
+ // renderer like mpv) into the layout like any widget. Its `surface`
318
+ // attribute binds the model-owned u64 surface id a producer targets
319
+ // (`Runtime.acquireMediaSurfaceProducer`) — the runtime-image-id
320
+ // binding shape, never a markup literal. Display-only like image
321
+ // and chart (presses fall through); pictorial for the a11y lint.
322
+ .{ .code = 66, .name = "media-surface", .widget_kind = "media_surface", .hit_target = false, .a11y_name = .image },
309
323
  };
310
324
 
311
325
  // ------------------------------------------------------------- attributes
@@ -450,6 +464,22 @@ pub const attrs = [_]AttrInfo{
450
464
  // silently inert). No `field`: the engines apply it to
451
465
  // `ElementOptions.style`, not a flat option field.
452
466
  .{ .code = 79, .name = "quiet-hover", .class = .flag, .group = .option },
467
+ // Hover-intent show delay for ANCHORED tooltips (tooltip only, and
468
+ // only beside `anchor`; the validator scopes both), in whole
469
+ // milliseconds. The runtime shows an anchored tooltip after its
470
+ // trigger has been hovered this long on the recorded frame clock —
471
+ // 0 shows the instant the trigger is hovered. Negative is
472
+ // unreachable from markup; absent keeps the token default
473
+ // (`ControlMetricTokens.tooltip_show_delay_ms`).
474
+ .{ .code = 80, .name = "tooltip-delay", .class = .whole, .group = .option, .field = "tooltip_delay" },
475
+ // The media-surface producer rendezvous (media-surface only; the
476
+ // validator scopes it): one {binding} to the model-owned u64 surface
477
+ // id a producer targets (`Runtime.acquireMediaSurfaceProducer`) —
478
+ // ids are model data in the runtime-image-id spirit, never markup
479
+ // literals; 0 is the unbound sentinel (the surface draws nothing,
480
+ // like an image leaf with id 0), and usable ids stay below the
481
+ // reserved namespace bit (bit 63), which acquire refuses.
482
+ .{ .code = 81, .name = "surface", .class = .binding_only, .group = .element },
453
483
  };
454
484
 
455
485
  // ----------------------------------------------------------------- events
@@ -21,25 +21,25 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
21
21
  // (append or slot them anywhere — order carries no meaning) and pin
22
22
  // the new fingerprint ONLY for additions; renames/renumbers are
23
23
  // schema-version-bump events, not silent edits.
24
- try testing.expectEqual(@as(usize, 65), schema.elements.len);
25
- try testing.expectEqual(@as(usize, 79), schema.attrs.len);
24
+ try testing.expectEqual(@as(usize, 66), schema.elements.len);
25
+ try testing.expectEqual(@as(usize, 81), schema.attrs.len);
26
26
  try testing.expectEqual(@as(usize, 10), schema.events.len);
27
- // The element table runs through the span composite (64) and the
28
- // bubble-reactions composite (65); the reaction pill's dock rides
29
- // the existing text-alignment attribute, so element additions can
30
- // leave the attr table untouched.
27
+ // The element table runs through the span composite (64), the
28
+ // bubble-reactions composite (65), and the media surface (66).
31
29
  try testing.expectEqual(
32
- @as(u64, 0x961be186c9929e4c),
30
+ @as(u64, 0x65ed870d5b6e279e),
33
31
  tableFingerprint(schema.ElementInfo, &schema.elements),
34
32
  );
35
33
  // The attr table runs through the split layout-tween attributes
36
34
  // resize-duration (71) and resize-easing (72), the chart axis/hover
37
35
  // attributes x-labels (73), y-labels (74), and hover-details (75),
38
36
  // the later span additions scale (76) and underline (77), the
39
- // split enter-from attribute resize-origin (78), and the
40
- // quiet-surface hover knob quiet-hover (79).
37
+ // split enter-from attribute resize-origin (78), the quiet-surface
38
+ // hover knob quiet-hover (79), the anchored-tooltip hover-intent
39
+ // delay tooltip-delay (80), and the media-surface producer
40
+ // rendezvous surface (81).
41
41
  try testing.expectEqual(
42
- @as(u64, 0x3b439a78a91600b6),
42
+ @as(u64, 0x046479d29c4f0c5e),
43
43
  tableFingerprint(schema.AttrInfo, &schema.attrs),
44
44
  );
45
45
  try testing.expectEqual(
@@ -90,7 +90,7 @@ test "registry event scoping names registry elements" {
90
90
  test "derived name lists mirror the registry" {
91
91
  // The derivations are the vocabulary every consumer reads; hold them
92
92
  // to the registry's own predicates.
93
- try testing.expectEqual(@as(usize, 53), schema.element_names.len);
93
+ try testing.expectEqual(@as(usize, 54), schema.element_names.len);
94
94
  for (schema.element_names) |name| {
95
95
  try testing.expect(schema.elementByName(name).?.rule_hook == null);
96
96
  }
@@ -354,6 +354,36 @@ test "textarea keyboard: enter edits a newline, submit rides the primary chord"
354
354
  try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(textarea.id, alt_enter));
355
355
  }
356
356
 
357
+ test "single-line keyboard fallback derivation sanitizes line breaks like the runtime seam" {
358
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
359
+ defer arena_state.deinit();
360
+
361
+ var ui = InboxUi.init(arena_state.allocator());
362
+ const tree = try ui.finalize(ui.column(.{ .gap = 8 }, .{
363
+ ui.el(.text_field, .{ .on_input = InboxUi.inputMsg(.draft) }, .{}),
364
+ ui.el(.textarea, .{ .on_input = InboxUi.inputMsg(.draft) }, .{}),
365
+ }));
366
+ const field = findByKind(tree.root, .text_field).?;
367
+ const textarea = findByKind(tree.root, .textarea).?;
368
+
369
+ // An un-stamped text_input event (a direct Tree consumer — nothing
370
+ // crossed the runtime) derives its insert locally, and the local
371
+ // derivation applies the SAME single-line sanitize rule the runtime
372
+ // seam stamps with: line breaks strip, so a model mirror can never
373
+ // hear bytes the retained editor would refuse.
374
+ const multi_line = canvas.WidgetKeyboardEvent{ .phase = .text_input, .text = "a\nb\r\nc" };
375
+ try testing.expectEqualStrings("abc", tree.msgForKeyboard(field.id, multi_line).?.draft.insert_text);
376
+ try testing.expectEqualStrings("a\nb\r\nc", tree.msgForKeyboard(textarea.id, multi_line).?.draft.insert_text);
377
+
378
+ // An insert that is ONLY breaks suppresses outright.
379
+ const bare_breaks = canvas.WidgetKeyboardEvent{ .phase = .text_input, .text = "\r\n" };
380
+ try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(field.id, bare_breaks));
381
+
382
+ // A STAMPED edit (the runtime already sanitized it) passes through.
383
+ const stamped = canvas.WidgetKeyboardEvent{ .phase = .key_down, .edit = .{ .insert_text = "clean" } };
384
+ try testing.expectEqualStrings("clean", tree.msgForKeyboard(field.id, stamped).?.draft.insert_text);
385
+ }
386
+
357
387
  test "typed handlers imply accessibility actions" {
358
388
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
359
389
  defer arena_state.deinit();
@@ -1402,6 +1432,7 @@ test "widget kind codes are pinned: assigned at birth, declaration-order-indepen
1402
1432
  .{ .kind = .split_divider, .code = 58 },
1403
1433
  .{ .kind = .tree, .code = 59 },
1404
1434
  .{ .kind = .input_group, .code = 60 },
1435
+ .{ .kind = .media_surface, .code = 61 },
1405
1436
  };
1406
1437
  try testing.expectEqual(std.enums.values(canvas.WidgetKind).len, expected.len);
1407
1438
  for (expected) |entry| {