@native-sdk/cli 0.9.1 → 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.
Files changed (130) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +55 -0
  3. package/package.json +9 -9
  4. package/packages/core/package-lock.json +2 -2
  5. package/packages/core/package.json +1 -1
  6. package/packages/core/sdk/core.ts +3 -1
  7. package/skill-data/native-ui/SKILL.md +7 -7
  8. package/skill-data/ts-core/SKILL.md +1 -1
  9. package/src/app_runner/root.zig +93 -6
  10. package/src/app_runner/ts_core_main.zig +4 -4
  11. package/src/app_runner/window_placement.zig +63 -0
  12. package/src/embed/app_exports.zig +2 -1
  13. package/src/embed/conversions.zig +1 -0
  14. package/src/embed/host.zig +10 -3
  15. package/src/embed/root.zig +1 -0
  16. package/src/embed/tests.zig +13 -1
  17. package/src/embed/types.zig +2 -0
  18. package/src/embed/ui_host.zig +26 -2
  19. package/src/platform/android/NativeSdkActivity.java +49 -4
  20. package/src/platform/android/android_host.c +3 -3
  21. package/src/platform/android/native_sdk_app.h +1 -1
  22. package/src/platform/ios/apple_image_fit.h +38 -0
  23. package/src/platform/ios/files.zig +1 -0
  24. package/src/platform/ios/native_sdk_app.h +1 -1
  25. package/src/platform/ios/uikit_host.m +28 -5
  26. package/src/platform/linux/cef_host.cpp +10 -2
  27. package/src/platform/linux/gtk_host.c +43 -10
  28. package/src/platform/linux/gtk_host.h +3 -3
  29. package/src/platform/linux/root.zig +22 -7
  30. package/src/platform/macos/appkit_host.h +7 -4
  31. package/src/platform/macos/appkit_host.m +192 -40
  32. package/src/platform/macos/cef_host.mm +132 -34
  33. package/src/platform/macos/image_fit_test.m +44 -0
  34. package/src/platform/macos/root.zig +154 -9
  35. package/src/platform/null_platform.zig +17 -3
  36. package/src/platform/null_platform_tests.zig +58 -4
  37. package/src/platform/root.zig +2 -0
  38. package/src/platform/types.zig +69 -19
  39. package/src/platform/windows/root.zig +22 -7
  40. package/src/platform/windows/webview2_host.cpp +31 -6
  41. package/src/primitives/app_manifest/root.zig +3 -0
  42. package/src/primitives/app_manifest/tests.zig +24 -0
  43. package/src/primitives/app_manifest/types.zig +13 -0
  44. package/src/primitives/app_manifest/validation.zig +24 -0
  45. package/src/primitives/canvas/a11y_audit.zig +9 -7
  46. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  47. package/src/primitives/canvas/events.zig +50 -0
  48. package/src/primitives/canvas/layout_audit.zig +6 -6
  49. package/src/primitives/canvas/markdown.zig +4 -0
  50. package/src/primitives/canvas/markdown_tests.zig +1 -0
  51. package/src/primitives/canvas/png.zig +138 -0
  52. package/src/primitives/canvas/root.zig +13 -2
  53. package/src/primitives/canvas/text_span_tests.zig +5 -3
  54. package/src/primitives/canvas/text_spans.zig +2 -0
  55. package/src/primitives/canvas/text_tests.zig +20 -0
  56. package/src/primitives/canvas/ui.zig +55 -2
  57. package/src/primitives/canvas/ui_markup.zig +40 -13
  58. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  59. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  60. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  62. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  63. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  64. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  65. package/src/primitives/canvas/ui_schema.zig +17 -13
  66. package/src/primitives/canvas/ui_tests.zig +47 -0
  67. package/src/primitives/canvas/widget_access.zig +3 -3
  68. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  69. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  70. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  71. package/src/primitives/canvas/widget_layout.zig +333 -126
  72. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  73. package/src/primitives/canvas/widget_metrics.zig +7 -8
  74. package/src/primitives/canvas/widget_render.zig +76 -44
  75. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  76. package/src/primitives/canvas/widget_render_style.zig +58 -18
  77. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  78. package/src/primitives/canvas/widget_routing.zig +40 -34
  79. package/src/primitives/canvas/widget_runtime.zig +11 -2
  80. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  81. package/src/primitives/canvas/widget_semantics.zig +8 -3
  82. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  83. package/src/primitives/canvas/widget_tree.zig +99 -5
  84. package/src/primitives/canvas/widgets.zig +20 -7
  85. package/src/root.zig +3 -0
  86. package/src/runtime/api.zig +6 -0
  87. package/src/runtime/automation_widget_dispatch.zig +48 -6
  88. package/src/runtime/builtin_bridge.zig +5 -2
  89. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  90. package/src/runtime/canvas_image_tests.zig +146 -2
  91. package/src/runtime/canvas_images.zig +35 -16
  92. package/src/runtime/canvas_limits.zig +13 -3
  93. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  94. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  95. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  96. package/src/runtime/canvas_widget_events.zig +151 -26
  97. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  98. package/src/runtime/canvas_widget_runtime.zig +322 -102
  99. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  100. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  101. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  102. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  103. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  104. package/src/runtime/canvas_widget_state.zig +33 -7
  105. package/src/runtime/core.zig +16 -0
  106. package/src/runtime/effects.zig +14 -14
  107. package/src/runtime/effects_image_tests.zig +91 -0
  108. package/src/runtime/gpu_surface_events.zig +25 -2
  109. package/src/runtime/root.zig +2 -0
  110. package/src/runtime/session_replay.zig +13 -8
  111. package/src/runtime/session_tests.zig +111 -4
  112. package/src/runtime/shell_layout_tests.zig +12 -0
  113. package/src/runtime/ts_core_host_tests.zig +47 -0
  114. package/src/runtime/ui_app.zig +9 -3
  115. package/src/runtime/ui_app_tests.zig +119 -19
  116. package/src/runtime/ui_app_window_tests.zig +13 -1
  117. package/src/runtime/view.zig +3 -0
  118. package/src/runtime/view_widget_control.zig +18 -0
  119. package/src/runtime/view_widget_scroll.zig +112 -18
  120. package/src/runtime/view_widget_tree.zig +110 -13
  121. package/src/runtime/widget_bridge.zig +2 -0
  122. package/src/runtime/window_command_bridge_tests.zig +86 -0
  123. package/src/runtime/window_storage.zig +16 -1
  124. package/src/runtime/window_views.zig +1 -0
  125. package/src/tooling/ios.zig +3 -0
  126. package/src/tooling/manifest.zig +90 -2
  127. package/src/tooling/package.zig +67 -2
  128. package/src/tooling/raw_manifest.zig +10 -0
  129. package/src/tooling/templates.zig +128 -18
  130. package/src/tooling/web_engine.zig +1 -1
@@ -252,6 +252,144 @@ pub fn decodeRgba8(bytes: []const u8, output: []u8) Error!Decoded {
252
252
  return .{ .width = width, .height = height, .rgba8 = output[0 .. width * height * 4] };
253
253
  }
254
254
 
255
+ /// Decode the strict writer subset while fitting its RGBA8 pixels inside a
256
+ /// pixel-count budget. Stored-deflate bytes are addressed directly from the
257
+ /// encoded stream, so an oversized source is never materialized at native
258
+ /// size. Downscaling uses deterministic integer box averages in sRGB space;
259
+ /// the test/null codec values bounded repeatability over color-management
260
+ /// fidelity (real hosts use their platform codecs' native thumbnail paths).
261
+ pub fn decodeRgba8Fitted(bytes: []const u8, output: []u8, max_pixels: usize, max_fitted_dimension: usize) Error!Decoded {
262
+ if (max_pixels == 0 or max_fitted_dimension == 0) return error.PngPixelBufferTooSmall;
263
+ if (bytes.len < signature.len or !std.mem.eql(u8, bytes[0..signature.len], &signature)) return error.InvalidPng;
264
+
265
+ var offset: usize = signature.len;
266
+ var width: usize = 0;
267
+ var height: usize = 0;
268
+ var idat: ?[]const u8 = null;
269
+ var saw_iend = false;
270
+ while (offset < bytes.len) {
271
+ if (bytes.len - offset < chunk_overhead) return error.InvalidPng;
272
+ const data_len: usize = std.mem.readInt(u32, bytes[offset..][0..4], .big);
273
+ const chunk_type = bytes[offset + 4 .. offset + 8];
274
+ if (bytes.len - offset < chunk_overhead + data_len) return error.InvalidPng;
275
+ const data = bytes[offset + 8 .. offset + 8 + data_len];
276
+ const stored_crc = std.mem.readInt(u32, bytes[offset + 8 + data_len ..][0..4], .big);
277
+ var crc = std.hash.Crc32.init();
278
+ crc.update(chunk_type);
279
+ crc.update(data);
280
+ if (crc.final() != stored_crc) return error.InvalidPng;
281
+ offset += chunk_overhead + data_len;
282
+
283
+ if (std.mem.eql(u8, chunk_type, "IHDR")) {
284
+ if (width != 0 or data.len != 13) return error.InvalidPng;
285
+ width = std.mem.readInt(u32, data[0..4], .big);
286
+ height = std.mem.readInt(u32, data[4..8], .big);
287
+ try validateDimensions(width, height);
288
+ if (data[8] != 8 or data[9] != 6 or data[10] != 0 or data[11] != 0 or data[12] != 0) return error.UnsupportedPng;
289
+ } else if (std.mem.eql(u8, chunk_type, "IDAT")) {
290
+ if (width == 0 or idat != null) return error.UnsupportedPng;
291
+ idat = data;
292
+ } else if (std.mem.eql(u8, chunk_type, "IEND")) {
293
+ if (data.len != 0) return error.InvalidPng;
294
+ saw_iend = true;
295
+ break;
296
+ } else {
297
+ return error.UnsupportedPng;
298
+ }
299
+ }
300
+ if (!saw_iend) return error.InvalidPng;
301
+ const stream_data = idat orelse return error.InvalidPng;
302
+ if (stream_data.len < 6 or stream_data[0] != 0x78) return error.UnsupportedPng;
303
+ const expected_adler = std.mem.readInt(u32, stream_data[stream_data.len - 4 ..][0..4], .big);
304
+ const deflate = stream_data[2 .. stream_data.len - 4];
305
+ const raw_len = rawStreamLen(width, height);
306
+
307
+ // The strict writer emits canonical full-sized stored blocks. Validate
308
+ // that shape and the zlib checksum once, then rawByteAt below can map a
309
+ // raw offset to its encoded byte in O(1) without an allocation.
310
+ var compressed_offset: usize = 0;
311
+ var raw_offset: usize = 0;
312
+ var adler: std.hash.Adler32 = .{};
313
+ while (raw_offset < raw_len) {
314
+ if (deflate.len - compressed_offset < 5) return error.InvalidPng;
315
+ const header = deflate[compressed_offset];
316
+ if (header & 0xFE != 0) return error.UnsupportedPng;
317
+ const block_len: usize = std.mem.readInt(u16, deflate[compressed_offset + 1 ..][0..2], .little);
318
+ const block_nlen: usize = std.mem.readInt(u16, deflate[compressed_offset + 3 ..][0..2], .little);
319
+ const expected_len = @min(raw_len - raw_offset, max_stored_block_bytes);
320
+ if (block_len != expected_len or block_len ^ 0xFFFF != block_nlen) return error.UnsupportedPng;
321
+ if (deflate.len - compressed_offset < 5 + block_len) return error.InvalidPng;
322
+ const block = deflate[compressed_offset + 5 .. compressed_offset + 5 + block_len];
323
+ adler.update(block);
324
+ raw_offset += block_len;
325
+ compressed_offset += 5 + block_len;
326
+ const should_be_final = raw_offset == raw_len;
327
+ if ((header & 1 == 1) != should_be_final) return error.InvalidPng;
328
+ }
329
+ if (compressed_offset != deflate.len or adler.adler != expected_adler) return error.InvalidPng;
330
+
331
+ const source_pixels = std.math.mul(usize, width, height) catch return error.InvalidPngDimensions;
332
+ var fitted_width = width;
333
+ var fitted_height = height;
334
+ if (source_pixels > max_pixels or width > max_fitted_dimension or height > max_fitted_dimension) {
335
+ const area_scale = @sqrt(@as(f64, @floatFromInt(max_pixels)) / @as(f64, @floatFromInt(source_pixels)));
336
+ const axis_scale = @as(f64, @floatFromInt(max_fitted_dimension)) / @as(f64, @floatFromInt(@max(width, height)));
337
+ const scale = @min(1.0, @min(area_scale, axis_scale));
338
+ fitted_width = @max(1, @as(usize, @intFromFloat(@floor(@as(f64, @floatFromInt(width)) * scale))));
339
+ fitted_height = @max(1, @as(usize, @intFromFloat(@floor(@as(f64, @floatFromInt(height)) * scale))));
340
+ while (fitted_width * fitted_height > max_pixels) {
341
+ if (fitted_width > 1 and (fitted_height == 1 or fitted_width > fitted_height)) fitted_width -= 1 else fitted_height -= 1;
342
+ }
343
+ }
344
+ const fitted_byte_len = fitted_width * fitted_height * 4;
345
+ if (output.len < fitted_byte_len) return error.PngPixelBufferTooSmall;
346
+
347
+ const Reader = struct {
348
+ fn byteAt(data: []const u8, index: usize) u8 {
349
+ const block_index = index / max_stored_block_bytes;
350
+ const in_block = index % max_stored_block_bytes;
351
+ return data[block_index * (5 + max_stored_block_bytes) + 5 + in_block];
352
+ }
353
+ };
354
+ const source_row_len = rowByteLen(width);
355
+ var oy: usize = 0;
356
+ while (oy < fitted_height) : (oy += 1) {
357
+ const top: u64 = @as(u64, oy) * height;
358
+ const bottom: u64 = @as(u64, oy + 1) * height;
359
+ const sy0: usize = @intCast(top / fitted_height);
360
+ const sy1: usize = @intCast((bottom + fitted_height - 1) / fitted_height);
361
+ var ox: usize = 0;
362
+ while (ox < fitted_width) : (ox += 1) {
363
+ const left: u64 = @as(u64, ox) * width;
364
+ const right: u64 = @as(u64, ox + 1) * width;
365
+ const sx0: usize = @intCast(left / fitted_width);
366
+ const sx1: usize = @intCast((right + fitted_width - 1) / fitted_width);
367
+ var sums = [4]u64{ 0, 0, 0, 0 };
368
+ var weight_total: u64 = 0;
369
+ var sy = sy0;
370
+ while (sy < sy1) : (sy += 1) {
371
+ if (Reader.byteAt(deflate, sy * source_row_len) != 0) return error.UnsupportedPng;
372
+ const source_top: u64 = @as(u64, sy) * fitted_height;
373
+ const source_bottom: u64 = @as(u64, sy + 1) * fitted_height;
374
+ const weight_y = @min(bottom, source_bottom) - @max(top, source_top);
375
+ var sx = sx0;
376
+ while (sx < sx1) : (sx += 1) {
377
+ const source_left: u64 = @as(u64, sx) * fitted_width;
378
+ const source_right: u64 = @as(u64, sx + 1) * fitted_width;
379
+ const weight_x = @min(right, source_right) - @max(left, source_left);
380
+ const weight = weight_x * weight_y;
381
+ const source = sy * source_row_len + 1 + sx * 4;
382
+ inline for (0..4) |channel| sums[channel] += @as(u64, Reader.byteAt(deflate, source + channel)) * weight;
383
+ weight_total += weight;
384
+ }
385
+ }
386
+ const destination = (oy * fitted_width + ox) * 4;
387
+ inline for (0..4) |channel| output[destination + channel] = @intCast((sums[channel] + weight_total / 2) / weight_total);
388
+ }
389
+ }
390
+ return .{ .width = fitted_width, .height = fitted_height, .rgba8 = output[0..fitted_byte_len] };
391
+ }
392
+
255
393
  test "png writer emits signature and IHDR fields" {
256
394
  const width: usize = 3;
257
395
  const height: usize = 2;
@@ -740,7 +740,7 @@ pub const cursorForWidgetTarget = widget_runtime.cursorForWidgetTarget;
740
740
  /// the single source of truth the runtime, both markup engines, and the
741
741
  /// markup validator's element list all derive from). Kind-level only: the
742
742
  /// widget-level predicate is `widgetIsHitTarget`, which also admits any
743
- /// widget carrying a bound press/toggle handler.
743
+ /// widget carrying a bound press/toggle/drag handler.
744
744
  pub const widgetKindHitTarget = @import("widget_access.zig").widgetKindHitTarget;
745
745
  /// Widget-level keyboard focusability without geometry/ancestor-clip
746
746
  /// filtering. Runtime roving-focus groups use this to identify a logical
@@ -749,7 +749,7 @@ pub const widgetKindHitTarget = @import("widget_access.zig").widgetKindHitTarget
749
749
  /// rejects clipped targets.
750
750
  pub const widgetIsFocusable = @import("widget_access.zig").isFocusable;
751
751
  /// Widget-level hit-target-ness: kind-level `widgetKindHitTarget` plus
752
- /// any widget with a bound press/toggle handler (stamped into
752
+ /// any widget with a bound press/toggle/drag handler (stamped into
753
753
  /// `semantics.actions` by the builder and both markup engines).
754
754
  pub const widgetIsHitTarget = @import("widget_access.zig").isHitTarget;
755
755
  pub const widgetIsHoverMsgHitTarget = @import("widget_access.zig").isHoverMsgHitTarget;
@@ -780,6 +780,11 @@ pub const widgetWindowDragTargetIndexFromNode = @import("widget_routing.zig").wi
780
780
  /// stack-container list all derive from).
781
781
  pub const widgetKindStacksChildren = @import("widget_layout.zig").widgetKindStacksChildren;
782
782
  pub const widgetIsAnchored = @import("widget_tree.zig").widgetIsAnchored;
783
+ pub const widgetIsRootRelativeModal = @import("widget_tree.zig").widgetIsRootRelativeModal;
784
+ pub const widgetEscapesAncestorClips = @import("widget_tree.zig").widgetEscapesAncestorClips;
785
+ pub const WidgetPaintOrder = @import("widget_tree.zig").WidgetPaintOrder;
786
+ pub const widgetLayoutWindowSurfaceOrder = @import("widget_tree.zig").widgetLayoutWindowSurfaceOrder;
787
+ pub const widgetPaintOrderLess = @import("widget_tree.zig").widgetPaintOrderLess;
783
788
  /// The runtime-scrolled virtual list predicate (widget_tree.zig): a
784
789
  /// virtualized scroll_view with a DECLARED total item count, whose
785
790
  /// scroll offset the runtime owns (engine scrolling + native drivers)
@@ -798,6 +803,12 @@ pub const disclosureSettledOpen = @import("widget_tree.zig").disclosureSettledOp
798
803
  pub const disclosureContentBottom = @import("widget_tree.zig").disclosureContentBottom;
799
804
  pub const isWidgetConcealedByDisclosure = @import("widget_tree.zig").isWidgetConcealedByDisclosure;
800
805
  pub const anchoredWidgetFrame = @import("widget_layout.zig").anchoredWidgetFrame;
806
+ pub const relayoutAnchoredChildren = @import("widget_layout.zig").relayoutAnchoredChildren;
807
+ pub const relayoutAnchoredChildrenWithRootBounds = @import("widget_layout.zig").relayoutAnchoredChildrenWithRootBounds;
808
+ pub const relayoutAnchoredChildrenAtDepth = @import("widget_layout.zig").relayoutAnchoredChildrenAtDepth;
809
+ pub const anchoredNestingDepth = @import("widget_layout.zig").anchoredNestingDepth;
810
+ pub const maxAnchoredNestingDepth = @import("widget_layout.zig").maxAnchoredNestingDepth;
811
+ pub const widgetLayoutRootBounds = @import("widget_render.zig").widgetLayoutRootBounds;
801
812
  /// Window-control reservation trigger (widget_layout.zig): true when a
802
813
  /// laid-out tree left drag-header CONTENT under the OS window-control
803
814
  /// cluster, so runtimes know to stamp `DesignTokens.window_controls`
@@ -435,7 +435,7 @@ fn paragraphView(ui: *SpanUi) SpanUi.Node {
435
435
  .{ .text = "Read " },
436
436
  .{ .text = "the guide", .link = "https://example.com/guide" },
437
437
  .{ .text = " and " },
438
- .{ .text = "the spec", .link = "https://example.com/spec" },
438
+ .{ .text = "the spec", .link = "https://example.com/spec", .underline = true },
439
439
  };
440
440
  return ui.column(.{ .gap = 8 }, .{
441
441
  ui.paragraph(.{ .on_link = SpanUi.linkMsg(.open) }, &spans),
@@ -502,7 +502,7 @@ test "link children get span-derived frames and are hit-testable" {
502
502
  try testing.expectEqual(paragraph.id, paragraph_hit.id);
503
503
  }
504
504
 
505
- test "span paragraphs emit one text command per run plus link underlines" {
505
+ test "span underline decoration is independent from link behavior" {
506
506
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
507
507
  defer arena_state.deinit();
508
508
  var ui = SpanUi.init(arena_state.allocator());
@@ -532,7 +532,9 @@ test "span paragraphs emit one text command per run plus link underlines" {
532
532
  }
533
533
  // 4 spans on one wide line + the plain trailer text widget.
534
534
  try testing.expectEqual(@as(usize, 5), text_commands);
535
- try testing.expectEqual(@as(usize, 2), underlines);
535
+ // Both links keep accent ink and link interaction, but only the second
536
+ // span explicitly opts into an underline.
537
+ try testing.expectEqual(@as(usize, 1), underlines);
536
538
  try testing.expectEqual(@as(usize, 2), accent_texts);
537
539
  }
538
540
 
@@ -78,6 +78,8 @@ pub const TextSpan = struct {
78
78
  /// backgrounds never affect measurement or layout (#86, intra-line
79
79
  /// diff emphasis).
80
80
  background: ?TextSpanColor = null,
81
+ /// Visual underline decoration. Independent from `link`: clickable
82
+ /// spans remain undecorated unless this is true.
81
83
  underline: bool = false,
82
84
  strikethrough: bool = false,
83
85
  /// Relative size multiplier against the paragraph base size; 0 means
@@ -475,6 +475,26 @@ test "widget keyboard control intents map activation keys" {
475
475
  try std.testing.expect(radio.actions.press);
476
476
  try std.testing.expect(!radio.actions.toggle);
477
477
 
478
+ const grouped_radio_move = widgetKeyboardControlIntent(.{ .kind = .radio, .text = "Annual" }, .{
479
+ .phase = .key_down,
480
+ .key = "arrowright",
481
+ .focus_moved = true,
482
+ .radio_group_navigation = true,
483
+ .radio_group_selection = true,
484
+ }).?;
485
+ try std.testing.expectEqual(WidgetControlIntentKind.select, grouped_radio_move.kind);
486
+ try std.testing.expect(grouped_radio_move.actions.select);
487
+ try std.testing.expect(widgetKeyboardControlIntent(.{ .kind = .radio, .text = "Annual", .state = .{ .selected = true } }, .{
488
+ .phase = .key_down,
489
+ .key = "home",
490
+ .radio_group_navigation = true,
491
+ }) == null);
492
+ try std.testing.expect(widgetKeyboardControlIntent(.{ .kind = .radio, .text = "Bare" }, .{
493
+ .phase = .key_down,
494
+ .key = "arrowright",
495
+ .focus_moved = true,
496
+ }) == null);
497
+
478
498
  try std.testing.expect(widgetKeyboardControlIntent(.{ .kind = .button, .text = "Save" }, .{ .phase = .key_down, .key = "enter", .modifiers = .{ .super = true } }) == null);
479
499
  try std.testing.expect(widgetKeyboardControlIntent(.{ .kind = .button, .text = "Save", .state = .{ .disabled = true } }, .{ .phase = .key_down, .key = "enter" }) == null);
480
500
  try std.testing.expect(widgetKeyboardControlIntent(.{ .kind = .button, .text = "Save" }, .{ .phase = .key_up, .key = "enter" }) == null);
@@ -1409,8 +1409,22 @@ pub fn Ui(comptime Msg: type) type {
1409
1409
  /// widget resolves through the engine's semantic intent model
1410
1410
  /// (press, then toggle, then select) to the matching handler.
1411
1411
  pub fn msgForPointer(self: Tree, target_id: ObjectId, phase: canvas.WidgetPointerPhase) ?Msg {
1412
+ return self.msgForPointerSelection(target_id, phase, null);
1413
+ }
1414
+
1415
+ fn msgForPointerSelection(self: Tree, target_id: ObjectId, phase: canvas.WidgetPointerPhase, radio_selection_changed: ?bool) ?Msg {
1412
1416
  if (phase != .up) return null;
1413
1417
  const widget = self.findWidget(target_id) orelse return null;
1418
+ // A radio press is selection, regardless of which legacy
1419
+ // handlers are also bound. Resolve it through the same
1420
+ // canonical order as keyboard and a11y selection before
1421
+ // the generic press/toggle/select action walk can choose
1422
+ // an explicitly stamped on_toggle action first.
1423
+ if (widget.kind == .radio) {
1424
+ const intent = canvas.widgetSemanticControlIntent(widget, .select) orelse return null;
1425
+ _ = intent;
1426
+ return self.msgForRadioSelection(target_id, radio_selection_changed);
1427
+ }
1414
1428
  const semantic_actions = [_]canvas.WidgetSemanticAction{ .press, .toggle, .select };
1415
1429
  for (semantic_actions) |action| {
1416
1430
  const intent = canvas.widgetSemanticControlIntent(widget, action) orelse continue;
@@ -1430,7 +1444,18 @@ pub fn Ui(comptime Msg: type) type {
1430
1444
  if (phase == .up and click_count == 2) {
1431
1445
  if (self.msgFor(target_id, .double_press)) |msg| return msg;
1432
1446
  }
1433
- return self.msgForPointer(target_id, phase);
1447
+ return self.msgForPointerSelection(target_id, phase, null);
1448
+ }
1449
+
1450
+ /// Runtime pointer dispatch with the retained radio-selection
1451
+ /// outcome preserved. Direct tests and consumers can keep using
1452
+ /// `msgForPointerClick`; the runtime uses this form so reselecting
1453
+ /// an already-checked radio does not synthesize `on_change`.
1454
+ pub fn msgForPointerEvent(self: Tree, target_id: ObjectId, pointer: canvas.WidgetPointerEvent) ?Msg {
1455
+ if (pointer.phase == .up and pointer.click_count == 2) {
1456
+ if (self.msgFor(target_id, .double_press)) |msg| return msg;
1457
+ }
1458
+ return self.msgForPointerSelection(target_id, pointer.phase, pointer.radio_selection_changed);
1434
1459
  }
1435
1460
 
1436
1461
  /// Typed dispatch for keyboard events: engine control intents
@@ -1456,6 +1481,10 @@ pub fn Ui(comptime Msg: type) type {
1456
1481
  if (self.msgFor(target_id, .submit)) |msg| return msg;
1457
1482
  }
1458
1483
  if (canvas.widgetKeyboardControlIntent(widget, keyboard)) |intent| {
1484
+ if (widget.kind == .radio and intent.kind == .select) {
1485
+ if (self.msgForRadioSelection(target_id, keyboard.radio_selection_changed)) |msg| return msg;
1486
+ return null;
1487
+ }
1459
1488
  if (self.msgForIntent(target_id, intent)) |msg| return msg;
1460
1489
  }
1461
1490
  if (isSubmitKeyboard(widget, keyboard)) {
@@ -1498,7 +1527,18 @@ pub fn Ui(comptime Msg: type) type {
1498
1527
  return switch (intent.kind) {
1499
1528
  .press => self.msgFor(id, .press),
1500
1529
  .toggle => self.msgFor(id, .toggle),
1501
- .select => self.msgFor(id, .press),
1530
+ // Radio selection has one canonical handler order on
1531
+ // every input path: on_change, then the historical
1532
+ // on_toggle markup convention, then on_press for
1533
+ // backwards compatibility. Pointer, Space/Enter, and
1534
+ // radio-group focus arrivals all resolve here.
1535
+ .select => if (self.findWidget(id)) |widget|
1536
+ if (widget.kind == .radio)
1537
+ self.msgForRadioSelection(id, null)
1538
+ else
1539
+ self.msgFor(id, .press)
1540
+ else
1541
+ null,
1502
1542
  .set_value => blk: {
1503
1543
  if (intent.value) |value| {
1504
1544
  if (self.msgForValue(id, value)) |msg| break :blk msg;
@@ -1508,6 +1548,19 @@ pub fn Ui(comptime Msg: type) type {
1508
1548
  .scroll_by, .scroll_to_start, .scroll_to_end => null,
1509
1549
  };
1510
1550
  }
1551
+
1552
+ fn msgForRadioSelection(self: Tree, id: ObjectId, stamped_changed: ?bool) ?Msg {
1553
+ const widget = self.findWidget(id) orelse return null;
1554
+ if (widget.kind != .radio) return null;
1555
+ // Runtime input carries the exact retained mutation. A
1556
+ // direct Tree consumer has no retained mirror, so derive
1557
+ // the same ordinary case from the source snapshot.
1558
+ const changed = stamped_changed orelse !(widget.state.selected or widget.value >= 0.5);
1559
+ if (changed) {
1560
+ if (self.msgFor(id, .change)) |msg| return msg;
1561
+ }
1562
+ return self.msgFor(id, .toggle) orelse self.msgFor(id, .press);
1563
+ }
1511
1564
  };
1512
1565
 
1513
1566
  pub fn init(arena: std.mem.Allocator) Self {
@@ -1149,11 +1149,11 @@ pub const anchor_offset_value_message = "anchor-offset takes a literal number: t
1149
1149
  pub const anchor_dependent_attr_message = "anchor-alignment and anchor-offset only apply together with anchor - add anchor=\"below\" (or \"above\") to float this surface";
1150
1150
 
1151
1151
  /// Elements whose widget KIND the engine never hit-tests: layout and
1152
- /// decoration only. A bound `on-press`/`on-double-press`/`on-toggle`
1153
- /// makes any element a hit target (widget-level: the handler stamps the
1154
- /// press/toggle action, and presses on non-interactive content inside it
1155
- /// fall through to it), so those three are legal everywhere; the
1156
- /// remaining value/text handlers
1152
+ /// decoration only. A bound `on-press`/`on-double-press`/`on-toggle`/
1153
+ /// `on-hold`/`on-drag` makes any element a hit target (widget-level: the
1154
+ /// handler stamps a press/toggle/drag action, and presses on
1155
+ /// non-interactive content inside it fall through to it), so those are
1156
+ /// legal everywhere; the remaining value/text handlers
1157
1157
  /// (`on-change`/`on-submit`/`on-input`) have no behavior to bind to on
1158
1158
  /// these elements and stay validation errors. Registry-derived from the
1159
1159
  /// `hit_target` element predicate, which mirrors the engine's kind
@@ -1177,7 +1177,7 @@ pub const autofocus_element_message = "autofocus is only supported on focusable
1177
1177
 
1178
1178
  pub const submit_on_enter_element_message = "submit-on-enter is only supported on textarea - it makes plain Enter dispatch on-submit while Shift+Enter inserts a newline; single-line fields already submit on Enter, and other elements have no multiline Enter policy";
1179
1179
 
1180
- pub const non_hit_target_handler_message = "on-change/on-submit/on-input never fire here: this element has no control or text behavior - put them on a control (input, checkbox, slider) inside it (on-press/on-double-press/on-toggle are fine anywhere: a bound press handler makes any element pressable, and clicks on plain text or icons inside it fall through to it)";
1180
+ pub const non_hit_target_handler_message = "on-change/on-submit/on-input never fire here: this element has no control or text behavior - put them on a control (input, checkbox, slider) inside it (on-press/on-double-press/on-toggle/on-hold/on-drag are fine anywhere: they make any element interactive, and presses on plain text or icons inside it fall through to it)";
1181
1181
 
1182
1182
  /// Elements whose widget kind layers its children on top of each other
1183
1183
  /// (every child gets the full content box), so `gap` can never space
@@ -1419,7 +1419,7 @@ pub fn dismissEventElement(name: []const u8) bool {
1419
1419
  // operated blind; a role that cannot mean what it says lies to the
1420
1420
  // bridge), and a WARNING when the experience degrades but remains
1421
1421
  // navigable (an unnamed image, a label duplicating the text it shadows).
1422
- // Which elements are controls/editables/images is registry data
1422
+ // Which elements are controls/editables/radiogroups/images is registry data
1423
1423
  // (`schema.ElementInfo.a11y_name`); the judgment about name sources and
1424
1424
  // severities lives here. Both engines and the validator call the same
1425
1425
  // predicates, so the lint cannot drift between check time and build time.
@@ -1430,6 +1430,8 @@ pub const a11y_icon_only_message = "icon-only control: the icon name is a drawin
1430
1430
 
1431
1431
  pub const a11y_unlabeled_editable_message = "this text control has no accessible name - a screen reader user cannot tell what to type; add label=\"...\" (or placeholder=\"...\", which the accessibility bridges announce as the fallback name)";
1432
1432
 
1433
+ pub const a11y_unlabeled_radiogroup_message = "this radiogroup has no accessible name - a screen reader announces the choices without their shared question; add label=\"...\" naming the shared choice";
1434
+
1433
1435
  pub const a11y_unknown_role_message = "unknown role: role takes a canvas.WidgetRole name (button, link, tree, treeitem, list, listitem, tab, checkbox, ...)";
1434
1436
 
1435
1437
  pub const a11y_container_role_message = "this role promises child structure (rows, items, cells) that this element can never hold - put the role on the container element around it, or drop it";
@@ -1445,6 +1447,13 @@ pub const a11y_redundant_label_message = "this label duplicates the element's te
1445
1447
  /// the validator and both engines; comptime-callable.
1446
1448
  pub fn a11yNameError(node: MarkupNode) ?[]const u8 {
1447
1449
  const entry = schema.elementByName(node.name) orelse return null;
1450
+ // A literal role override can create a radiogroup on any container;
1451
+ // enforce the role's name contract in addition to the element-kind
1452
+ // registry. Dynamic roles resolve at runtime, where the tree audit
1453
+ // applies the same requirement to the effective semantic role.
1454
+ if (nodeHasLiteralRole(node, "radiogroup") and !attrNonBlank(node, "label")) {
1455
+ return a11y_unlabeled_radiogroup_message;
1456
+ }
1448
1457
  switch (entry.a11y_name) {
1449
1458
  .none, .image => return null,
1450
1459
  .control => {
@@ -1462,9 +1471,22 @@ pub fn a11yNameError(node: MarkupNode) ?[]const u8 {
1462
1471
  if (entry.takes_text and a11yNodeHasName(node)) return null;
1463
1472
  return a11y_unlabeled_editable_message;
1464
1473
  },
1474
+ .radiogroup => {
1475
+ if (attrNonBlank(node, "label")) return null;
1476
+ return a11y_unlabeled_radiogroup_message;
1477
+ },
1465
1478
  }
1466
1479
  }
1467
1480
 
1481
+ fn nodeHasLiteralRole(node: MarkupNode, role: []const u8) bool {
1482
+ const value = node.attr("role") orelse return false;
1483
+ const expression = parseAttrExpression(value) orelse return false;
1484
+ return switch (expression) {
1485
+ .literal => |literal| std.mem.eql(u8, literal, role),
1486
+ else => false,
1487
+ };
1488
+ }
1489
+
1468
1490
  /// The role-misuse ERROR for an element node: an unknown literal role, or
1469
1491
  /// a container role on an element that provably cannot hold the children
1470
1492
  /// the role promises. Dynamic role values (`role="{binding}"`) resolve at
@@ -1572,12 +1594,17 @@ fn inlineSeparatorNode(source: []const u8, start: usize, end: usize) MarkupNode
1572
1594
  }
1573
1595
 
1574
1596
  /// Whether an element can HOST a context-menu: right-click resolution
1575
- /// walks the hit route, so the host must be a hit target — or carry a
1576
- /// bound on-press/on-hold, which makes any element pressable. Shared by
1577
- /// the validator and both engines; comptime-callable.
1597
+ /// walks the hit route, so the host must be a hit target — or carry any
1598
+ /// handler that stamps a press/toggle/drag action and therefore makes an
1599
+ /// otherwise structural element a hit target. Shared by the validator
1600
+ /// and both engines; comptime-callable.
1578
1601
  pub fn contextMenuHostEligible(node: MarkupNode) bool {
1579
1602
  if (!nameInList(node.name, &known_non_hit_target_element_names)) return true;
1580
- return node.attr("on-press") != null or node.attr("on-hold") != null;
1603
+ return node.attr("on-press") != null or
1604
+ node.attr("on-double-press") != null or
1605
+ node.attr("on-toggle") != null or
1606
+ node.attr("on-hold") != null or
1607
+ node.attr("on-drag") != null;
1581
1608
  }
1582
1609
 
1583
1610
  fn a11yNodeHasName(node: MarkupNode) bool {
@@ -1645,7 +1672,7 @@ fn collectNodeA11yWarnings(node: MarkupNode, storage: []MarkupErrorInfo, len: *u
1645
1672
 
1646
1673
  /// The a11y ERRORS for a document, all of them: the same findings
1647
1674
  /// `validate` fails on one at a time (unnamed controls, icon-only
1648
- /// controls, unnamed text entry, and role misuse), collected per node so
1675
+ /// controls, unnamed text entry/radiogroups, and role misuse), collected per node so
1649
1676
  /// a checker can report every offender in one pass instead of one per
1650
1677
  /// re-run. Positions match `validate`'s emission exactly: the element
1651
1678
  /// for name errors, the role attribute for role errors.
@@ -1900,7 +1927,7 @@ pub const series_color_message = "series color takes a literal color token name
1900
1927
  pub const series_label_message = "series label expects text (a literal or one {binding}) - it names the series in the chart's semantics summary";
1901
1928
  pub const series_children_message = "series is a leaf - it takes no children; the values binding carries its data";
1902
1929
  pub const context_menu_parent_message = "context-menu must be a DIRECT child of the element whose right-click it answers - a conditional menu goes inside: wrap the menu-items in if/else, not the context-menu itself";
1903
- pub const context_menu_host_message = "context-menu attaches to the element that takes the right-click, and this element is never a hit target - put the menu on the pressable element (list-item, button, panel, ...) or bind on-press on this one";
1930
+ pub const context_menu_host_message = "context-menu attaches to the element that takes the right-click, and this element is never a hit target - put the menu on an interactive element (list-item, button, panel, ...) or bind on-press/on-double-press/on-toggle/on-hold/on-drag on this one";
1904
1931
  pub const context_menu_single_message = "an element takes at most one context-menu - one right-click, one menu; swap its items with if/else INSIDE the menu";
1905
1932
  pub const context_menu_attrs_message = "context-menu takes no attributes - presentation belongs to the platform (the OS menu where the host has one, the anchored fallback surface elsewhere)";
1906
1933
  pub const context_menu_children_message = "context-menu takes menu-item and separator children (if/else/for around them are fine) - the items present through the platform's menu, so other elements cannot render there";
@@ -391,17 +391,19 @@ const Decoder = struct {
391
391
  }
392
392
  };
393
393
 
394
- /// Decode an NSUI document. Refuses unknown versions and codes loudly
395
- /// (never a silent skip) and hostile depth/length input safely. The
396
- /// result is CANONICALIZED (typed values stamped), ready for either
397
- /// engine or further tooling; line/column positions are derived from the
398
- /// carried spans when present.
394
+ /// Decode an NSUI document. Schema v1 migrates structurally to v2: the
395
+ /// wire layout is unchanged, and every v1-valid checkbox/radio remains
396
+ /// valid after those elements gain optional text content. Other unknown
397
+ /// versions and codes refuse loudly (never a silent skip), and hostile
398
+ /// depth/length input stays bounded. The result is CANONICALIZED (typed
399
+ /// values stamped), ready for either engine or further tooling;
400
+ /// line/column positions are derived from the carried spans when present.
399
401
  pub fn decode(arena: std.mem.Allocator, bytes: []const u8, diagnostic: *CodecDiagnostic) DecodeError!markup.MarkupDocument {
400
402
  var decoder = Decoder{ .arena = arena, .bytes = bytes, .diagnostic = diagnostic };
401
403
  const header = try decoder.take(magic.len);
402
404
  if (!std.mem.eql(u8, header, magic)) return decoder.fail(bad_magic_message);
403
405
  const version = try decoder.int(u16);
404
- if (version != schema.schema_version) return decoder.fail(bad_version_message);
406
+ if (version != 1 and version != schema.schema_version) return decoder.fail(bad_version_message);
405
407
  const flags = try decoder.int(u16);
406
408
  decoder.spans = flags & flag_spans != 0;
407
409
  decoder.provenance = flags & flag_provenance != 0;
@@ -225,7 +225,7 @@ test "NSUI golden bytes for a minimal document" {
225
225
  const bytes = try nsui.encode(arena, document, .{ .spans = false, .provenance = false }, &diagnostic);
226
226
  const expected = [_]u8{
227
227
  'N', 'S', 'U', 'I', // magic
228
- 1, 0, // schema_version = 1
228
+ 2, 0, // schema_version = 2
229
229
  0, 0, // flags: no spans, no provenance
230
230
  0, 0, // template count = 0
231
231
  1, // root present
@@ -319,6 +319,16 @@ test "NSUI refuses what it does not know, loudly" {
319
319
  var diagnostic = nsui.CodecDiagnostic{};
320
320
  const bytes = try nsui.encode(arena, document, .{}, &diagnostic);
321
321
 
322
+ // V1 migrates structurally to v2. Its wire layout is unchanged, and
323
+ // every document valid under the old checkbox/radio content rules is
324
+ // also valid under the new optional-text rules.
325
+ {
326
+ const migrated = try arena.dupe(u8, bytes);
327
+ std.mem.writeInt(u16, migrated[4..6], 1, .little);
328
+ const decoded = try nsui.decode(arena, migrated, &diagnostic);
329
+ try testing.expectEqualStrings("row", decoded.root.?.name);
330
+ }
331
+
322
332
  // Unknown schema version.
323
333
  {
324
334
  const mutated = try arena.dupe(u8, bytes);
@@ -375,7 +385,7 @@ test "NSUI JSON dump derives from the decoded document" {
375
385
  defer out.deinit();
376
386
  try nsui.writeJson(decoded, hash, &out.writer);
377
387
  const json = out.written();
378
- try testing.expect(std.mem.indexOf(u8, json, "\"schemaVersion\":1") != null);
388
+ try testing.expect(std.mem.indexOf(u8, json, "\"schemaVersion\":2") != null);
379
389
  try testing.expect(std.mem.indexOf(u8, json, "\"node\":\"row\"") != null);
380
390
  try testing.expect(std.mem.indexOf(u8, json, "\"code\":1") != null);
381
391
  try testing.expect(std.mem.indexOf(u8, json, "\"name\":\"gap\"") != null);
@@ -402,8 +412,8 @@ test "NSUI refuses hostile nesting depth" {
402
412
  try testing.expectEqualStrings(nsui.depth_message, diagnostic.message);
403
413
  }
404
414
 
405
- test "the schema version constant is 1 and the registry backs the wire" {
406
- try testing.expectEqual(@as(u16, 1), schema.schema_version);
415
+ test "the schema version constant is 2 and the registry backs the wire" {
416
+ try testing.expectEqual(@as(u16, 2), schema.schema_version);
407
417
  // Every registry element/attr the encoder can meet has a nonzero code
408
418
  // (0 is the wire's "no entry" marker).
409
419
  for (schema.elements) |entry| try testing.expect(entry.code != 0);
@@ -514,7 +514,11 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
514
514
  }
515
515
  if (comptime (interpreter.elementTakesText(kind) and !composite_children)) {
516
516
  var built = ui.el(kind, options, .{});
517
- built.widget.text = interpolatedText(inner, entries, ui, model, scope);
517
+ // Interpreter parity: content wins when present; an empty
518
+ // element keeps its already-resolved text= attribute.
519
+ if (comptime inner.children.len > 0) {
520
+ built.widget.text = interpolatedText(inner, entries, ui, model, scope);
521
+ }
518
522
  // Avatars clip their runtime image to the avatar circle,
519
523
  // exactly like `Ui.avatar` and the interpreter (a no-op
520
524
  // while the id is 0 and the initials fallback renders).
@@ -99,6 +99,38 @@ const zero_card_padding_markup =
99
99
  ;
100
100
  const ZeroCardPaddingCompiled = canvas.CompiledMarkupView(fixture.Model, fixture.Msg, zero_card_padding_markup);
101
101
 
102
+ const selection_label_content_markup =
103
+ \\<column gap="8">
104
+ \\ <checkbox checked="true" on-toggle="add">Done</checkbox>
105
+ \\ <checkbox on-toggle="add" text="Later" />
106
+ \\ <radio-group label="Density">
107
+ \\ <radio checked="true" on-change="add">Default</radio>
108
+ \\ <radio on-change="add" text="Compact" />
109
+ \\ </radio-group>
110
+ \\</column>
111
+ ;
112
+ const SelectionLabelContentCompiled = canvas.CompiledMarkupView(fixture.Model, fixture.Msg, selection_label_content_markup);
113
+
114
+ test "checkbox and radio element content builds identically in both markup engines" {
115
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
116
+ defer arena_state.deinit();
117
+ const arena = arena_state.allocator();
118
+ const model = fixture.testModel();
119
+
120
+ var interpreter = try InboxInterpreter.init(arena, selection_label_content_markup);
121
+ var interpreter_ui = InboxUi.init(arena);
122
+ const interpreted = try interpreter_ui.finalize(try interpreter.build(&interpreter_ui, &model));
123
+ var compiled_ui = InboxUi.init(arena);
124
+ const compiled = try compiled_ui.finalize(SelectionLabelContentCompiled.build(&compiled_ui, &model));
125
+
126
+ try expectSameTree(fixture.Msg, interpreted, compiled);
127
+ try expectSameTexts(interpreted.root, compiled.root);
128
+ try testing.expect(fixture.findByText(compiled.root, .checkbox, "Done") != null);
129
+ try testing.expect(fixture.findByText(compiled.root, .checkbox, "Later") != null);
130
+ try testing.expect(fixture.findByText(compiled.root, .radio, "Default") != null);
131
+ try testing.expect(fixture.findByText(compiled.root, .radio, "Compact") != null);
132
+ }
133
+
102
134
  test "explicit zero card padding survives interpreted and compiled markup" {
103
135
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
104
136
  defer arena_state.deinit();
@@ -130,6 +162,26 @@ fn compileInbox(arena: std.mem.Allocator, model: *const fixture.Model) !InboxUi.
130
162
  }
131
163
 
132
164
  const ContextMenuCompiled = canvas.CompiledMarkupView(fixture.Model, fixture.Msg, fixture.context_menu_markup_source);
165
+ const DragContextMenuCompiled = canvas.CompiledMarkupView(fixture.Model, fixture.Msg, fixture.drag_context_menu_markup_source);
166
+
167
+ test "compiled drag-only context-menu host matches the interpreter" {
168
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
169
+ defer arena_state.deinit();
170
+ const arena = arena_state.allocator();
171
+ const model = fixture.testModel();
172
+
173
+ var interpreter_view = try InboxInterpreter.init(arena, fixture.drag_context_menu_markup_source);
174
+ var interpreter_ui = InboxUi.init(arena);
175
+ const interpreted = try interpreter_ui.finalize(try interpreter_view.build(&interpreter_ui, &model));
176
+ var compiled_ui = InboxUi.init(arena);
177
+ const compiled = try compiled_ui.finalize(DragContextMenuCompiled.build(&compiled_ui, &model));
178
+
179
+ try expectSameTree(fixture.Msg, interpreted, compiled);
180
+ try expectSameTexts(interpreted.root, compiled.root);
181
+ try testing.expect(compiled.root.semantics.actions.drag);
182
+ try testing.expect(canvas.widgetClaimsPress(compiled.root));
183
+ try testing.expectEqual(fixture.Msg.add, compiled.msgForContextMenu(compiled.root.id, 0).?);
184
+ }
133
185
 
134
186
  test "compiled context-menus build the interpreter's declared items and handler entries exactly" {
135
187
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);