@native-sdk/cli 0.5.4 → 0.6.1
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 +50 -1
- package/build.zig +588 -32
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +280 -8
- package/packages/core/sdk/core.ts +481 -2
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1368 -74
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +16 -0
- package/src/runtime/api.zig +76 -6
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +1 -0
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +268 -26
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -4
- package/src/runtime/gpu_surface_events.zig +475 -15
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +114 -19
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2338 -67
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +268 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
|
@@ -42,6 +42,7 @@ fn expectSameTree(comptime MsgT: type, expected: canvas.Ui(MsgT).Tree, actual: c
|
|
|
42
42
|
.input => |make| try testing.expectEqual(make, actual_handler.action.input),
|
|
43
43
|
.value => |make| try testing.expectEqual(make, actual_handler.action.value),
|
|
44
44
|
.scroll => |make| try testing.expectEqual(make, actual_handler.action.scroll),
|
|
45
|
+
.terminal => |make| try testing.expectEqual(make, actual_handler.action.terminal),
|
|
45
46
|
// Context-menu handler entries carry one ?Msg per declared
|
|
46
47
|
// item (separators are null slots); markup `<context-menu>`
|
|
47
48
|
// and the Zig builder both produce them.
|
|
@@ -391,11 +392,11 @@ test "compiled on-scroll binds the ScrollState constructor identically to the in
|
|
|
391
392
|
|
|
392
393
|
// Both engines dispatch the same typed scroll Msg for the container.
|
|
393
394
|
const feed = fixture.findByKind(compiled.root, .scroll_view).?;
|
|
394
|
-
const state = canvas.ScrollState{ .
|
|
395
|
-
try testing.expectEqual(@as(f32, 40), compiled.msgForScroll(feed.id, state).?.feed_scrolled.
|
|
395
|
+
const state = canvas.ScrollState{ .offset_y = 40, .viewport_extent_y = 80, .content_extent_y = 200 };
|
|
396
|
+
try testing.expectEqual(@as(f32, 40), compiled.msgForScroll(feed.id, state).?.feed_scrolled.offset_y);
|
|
396
397
|
try testing.expectEqual(
|
|
397
|
-
interpreted.msgForScroll(feed.id, state).?.feed_scrolled.
|
|
398
|
-
compiled.msgForScroll(feed.id, state).?.feed_scrolled.
|
|
398
|
+
interpreted.msgForScroll(feed.id, state).?.feed_scrolled.offset_y,
|
|
399
|
+
compiled.msgForScroll(feed.id, state).?.feed_scrolled.offset_y,
|
|
399
400
|
);
|
|
400
401
|
|
|
401
402
|
// And the same approach-end Msg (`on-reach-end`, the infinite-scroll
|
|
@@ -1306,6 +1307,97 @@ test "compiled image leaf binding refuses negative model values instead of trapp
|
|
|
1306
1307
|
try testing.expectError(error.OutOfMemory, image_ui.finalize(image_node));
|
|
1307
1308
|
}
|
|
1308
1309
|
|
|
1310
|
+
// -------------------------------------------------- terminal element
|
|
1311
|
+
|
|
1312
|
+
const TerminalElementUi = fixture.TerminalElementUi;
|
|
1313
|
+
const TerminalElementInterpreter = markup_view.MarkupView(fixture.TerminalElementModel, fixture.TerminalElementMsg);
|
|
1314
|
+
const TerminalElementCompiled = canvas.CompiledMarkupView(fixture.TerminalElementModel, fixture.TerminalElementMsg, fixture.terminal_markup_source);
|
|
1315
|
+
|
|
1316
|
+
test "compiled terminal element matches the interpreter and the hand-written ui.terminal tree" {
|
|
1317
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1318
|
+
defer arena_state.deinit();
|
|
1319
|
+
const arena = arena_state.allocator();
|
|
1320
|
+
|
|
1321
|
+
const model = fixture.TerminalElementModel{};
|
|
1322
|
+
|
|
1323
|
+
var view = try TerminalElementInterpreter.init(arena, fixture.terminal_markup_source);
|
|
1324
|
+
var interpreted_ui = TerminalElementUi.init(arena);
|
|
1325
|
+
const interpreted = try interpreted_ui.finalize(try view.build(&interpreted_ui, &model));
|
|
1326
|
+
|
|
1327
|
+
var compiled_ui = TerminalElementUi.init(arena);
|
|
1328
|
+
const compiled = try compiled_ui.finalize(TerminalElementCompiled.build(&compiled_ui, &model));
|
|
1329
|
+
|
|
1330
|
+
var hand_ui = TerminalElementUi.init(arena);
|
|
1331
|
+
const hand = try hand_ui.finalize(fixture.handTerminalElementView(&hand_ui, &model));
|
|
1332
|
+
|
|
1333
|
+
try expectSameTree(fixture.TerminalElementMsg, hand, interpreted);
|
|
1334
|
+
try expectSameTree(fixture.TerminalElementMsg, hand, compiled);
|
|
1335
|
+
|
|
1336
|
+
// All three lowerings bind the model-owned key and the echo.
|
|
1337
|
+
for ([_]TerminalElementUi.Tree{ hand, interpreted, compiled }) |tree| {
|
|
1338
|
+
const widget = fixture.findWidgetKind(tree.root, .terminal) orelse return error.TestExpectedTerminal;
|
|
1339
|
+
try testing.expectEqual(@as(u64, 7), widget.terminal.pty);
|
|
1340
|
+
try testing.expectEqual(@as(u32, 4), widget.terminal.scrollback);
|
|
1341
|
+
try testing.expect(widget.terminal.grid == null);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// --------------------------------------------- video playback element
|
|
1346
|
+
|
|
1347
|
+
const VideoElementUi = fixture.VideoElementUi;
|
|
1348
|
+
const VideoElementInterpreter = markup_view.MarkupView(fixture.VideoElementModel, fixture.VideoElementMsg);
|
|
1349
|
+
const VideoElementCompiled = canvas.CompiledMarkupView(fixture.VideoElementModel, fixture.VideoElementMsg, fixture.video_markup_source);
|
|
1350
|
+
const VideoElementPlainCompiled = canvas.CompiledMarkupView(fixture.VideoElementModel, fixture.VideoElementMsg, fixture.video_plain_markup_source);
|
|
1351
|
+
|
|
1352
|
+
test "compiled video element matches the interpreter and the hand-written ui.video tree" {
|
|
1353
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1354
|
+
defer arena_state.deinit();
|
|
1355
|
+
const arena = arena_state.allocator();
|
|
1356
|
+
|
|
1357
|
+
const model = fixture.VideoElementModel{};
|
|
1358
|
+
|
|
1359
|
+
var view = try VideoElementInterpreter.init(arena, fixture.video_markup_source);
|
|
1360
|
+
var interpreted_ui = VideoElementUi.init(arena);
|
|
1361
|
+
const interpreted = try interpreted_ui.finalize(try view.build(&interpreted_ui, &model));
|
|
1362
|
+
|
|
1363
|
+
var compiled_ui = VideoElementUi.init(arena);
|
|
1364
|
+
const compiled = try compiled_ui.finalize(VideoElementCompiled.build(&compiled_ui, &model));
|
|
1365
|
+
|
|
1366
|
+
var hand_ui = VideoElementUi.init(arena);
|
|
1367
|
+
const hand = try hand_ui.finalize(fixture.handVideoElementView(&hand_ui, &model));
|
|
1368
|
+
|
|
1369
|
+
try expectSameTree(fixture.VideoElementMsg, hand, interpreted);
|
|
1370
|
+
try expectSameTree(fixture.VideoElementMsg, hand, compiled);
|
|
1371
|
+
try expectSameTexts(interpreted.root, compiled.root);
|
|
1372
|
+
|
|
1373
|
+
// The compiled lowering binds the framework-owned playback surface
|
|
1374
|
+
// and stamps the chrome's runtime-consumed verbs, exactly like the
|
|
1375
|
+
// interpreter and the hand-written builder call.
|
|
1376
|
+
const surface = compiled.root.children[0].children[0];
|
|
1377
|
+
try testing.expectEqual(canvas.WidgetKind.media_surface, surface.kind);
|
|
1378
|
+
try testing.expectEqual(canvas.video_playback_surface_id, surface.image_id);
|
|
1379
|
+
const toggle = fixture.findVideoControl(compiled.root, .toggle) orelse return error.TestUnexpectedResult;
|
|
1380
|
+
try testing.expectEqual(canvas.WidgetKind.button, toggle.kind);
|
|
1381
|
+
const scrub = fixture.findVideoControl(compiled.root, .scrub) orelse return error.TestUnexpectedResult;
|
|
1382
|
+
try testing.expectEqual(canvas.WidgetKind.slider, scrub.kind);
|
|
1383
|
+
|
|
1384
|
+
// Both engines recorded the same declaration for the app loop's
|
|
1385
|
+
// reconcile.
|
|
1386
|
+
const compiled_declaration = compiled_ui.video_declaration orelse return error.TestUnexpectedResult;
|
|
1387
|
+
const interpreted_declaration = interpreted_ui.video_declaration orelse return error.TestUnexpectedResult;
|
|
1388
|
+
try testing.expectEqualStrings(interpreted_declaration.src, compiled_declaration.src);
|
|
1389
|
+
try testing.expectEqual(interpreted_declaration.autoplay, compiled_declaration.autoplay);
|
|
1390
|
+
try testing.expectEqual(interpreted_declaration.loop, compiled_declaration.loop);
|
|
1391
|
+
try testing.expectEqual(interpreted_declaration.muted, compiled_declaration.muted);
|
|
1392
|
+
|
|
1393
|
+
// The controls-less shape compiles to the bare surface: no chrome.
|
|
1394
|
+
var plain_ui = VideoElementUi.init(arena);
|
|
1395
|
+
const plain = try plain_ui.finalize(VideoElementPlainCompiled.build(&plain_ui, &model));
|
|
1396
|
+
try testing.expectEqual(canvas.WidgetKind.media_surface, plain.root.children[0].kind);
|
|
1397
|
+
try testing.expect(fixture.findVideoControl(plain.root, .toggle) == null);
|
|
1398
|
+
try testing.expect(fixture.findVideoControl(plain.root, .scrub) == null);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1309
1401
|
// ------------------------------------------------------ text wrap parity
|
|
1310
1402
|
|
|
1311
1403
|
const WrapUi = fixture.WrapUi;
|
|
@@ -1514,6 +1606,37 @@ test "compiled anchored picker (anchor, on-dismiss, on-hold) matches the interpr
|
|
|
1514
1606
|
try testing.expect(crumb.semantics.actions.press);
|
|
1515
1607
|
}
|
|
1516
1608
|
|
|
1609
|
+
// ------------------------------------------------------- hover-pair parity
|
|
1610
|
+
|
|
1611
|
+
const HoverCompiled = canvas.CompiledMarkupView(fixture.Model, fixture.Msg, fixture.hover_markup_source);
|
|
1612
|
+
|
|
1613
|
+
test "compiled hover pair (on-hover-enter, on-hover-leave) matches the interpreter" {
|
|
1614
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1615
|
+
defer arena_state.deinit();
|
|
1616
|
+
const arena = arena_state.allocator();
|
|
1617
|
+
|
|
1618
|
+
const model = fixture.Model{};
|
|
1619
|
+
|
|
1620
|
+
var view = try InboxInterpreter.init(arena, fixture.hover_markup_source);
|
|
1621
|
+
var interpreter_ui = InboxUi.init(arena);
|
|
1622
|
+
const interpreted = try interpreter_ui.finalize(try view.build(&interpreter_ui, &model));
|
|
1623
|
+
var compiled_ui = InboxUi.init(arena);
|
|
1624
|
+
const compiled = try compiled_ui.finalize(HoverCompiled.build(&compiled_ui, &model));
|
|
1625
|
+
try expectSameTree(fixture.Msg, interpreted, compiled);
|
|
1626
|
+
|
|
1627
|
+
// Both engines stamp the listener flag (hover-hittable, never
|
|
1628
|
+
// pressable) and bind both edges through the handler table.
|
|
1629
|
+
const panel = fixture.findByKind(compiled.root, .panel).?;
|
|
1630
|
+
const row = fixture.findByKind(compiled.root, .row).?;
|
|
1631
|
+
try testing.expect(panel.hover_msgs and row.hover_msgs);
|
|
1632
|
+
try testing.expect(!row.semantics.actions.press);
|
|
1633
|
+
try testing.expect(!canvas.widgetIsHitTarget(row));
|
|
1634
|
+
try testing.expect(canvas.widgetIsHoverMsgHitTarget(row));
|
|
1635
|
+
try testing.expectEqual(fixture.Msg.add, compiled.msgFor(panel.id, .hover_enter).?);
|
|
1636
|
+
try testing.expectEqual(@as(u32, 0), compiled.msgFor(panel.id, .hover_leave).?.toggle);
|
|
1637
|
+
try testing.expect(compiled.msgFor(row.id, .hover_leave) == null);
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1517
1640
|
// -------------------------------------------------- split panes and trees
|
|
1518
1641
|
|
|
1519
1642
|
const PaneCompiled = canvas.CompiledMarkupView(fixture.PaneModel, fixture.PaneMsg, fixture.pane_markup_source);
|
|
@@ -2086,11 +2209,13 @@ test "compiled on-scroll binds a declared scroll-state mirror identically to the
|
|
|
2086
2209
|
// Both engines translate the runtime state into the DECLARED record:
|
|
2087
2210
|
// float fields widen exactly, integer-classed fields round.
|
|
2088
2211
|
const region = fixture.findByKind(compiled.root, .scroll_view).?;
|
|
2089
|
-
const state = canvas.ScrollState{ .
|
|
2212
|
+
const state = canvas.ScrollState{ .offset_x = 12.5, .offset_y = 41.5, .velocity_y = -3.25, .viewport_extent_x = 320.2, .viewport_extent_y = 480.4, .content_extent_x = 960.7, .content_extent_y = 2000.6 };
|
|
2090
2213
|
const compiled_msg = compiled.msgForScroll(region.id, state).?;
|
|
2091
|
-
try testing.expectEqual(@as(f64, 41.5), compiled_msg.library_scrolled.
|
|
2092
|
-
try testing.expectEqual(@as(
|
|
2093
|
-
try testing.expectEqual(@as(i64,
|
|
2214
|
+
try testing.expectEqual(@as(f64, 41.5), compiled_msg.library_scrolled.offsetY);
|
|
2215
|
+
try testing.expectEqual(@as(f64, 12.5), compiled_msg.library_scrolled.offsetX);
|
|
2216
|
+
try testing.expectEqual(@as(i64, 480), compiled_msg.library_scrolled.viewportExtentY);
|
|
2217
|
+
try testing.expectEqual(@as(i64, 2001), compiled_msg.library_scrolled.contentExtentY);
|
|
2218
|
+
try testing.expectEqual(@as(i64, 961), compiled_msg.library_scrolled.contentExtentX);
|
|
2094
2219
|
try testing.expectEqual(
|
|
2095
2220
|
interpreted.msgForScroll(region.id, state).?,
|
|
2096
2221
|
compiled.msgForScroll(region.id, state).?,
|
|
@@ -46,8 +46,15 @@ pub const ValueKind = expr.ValueKind;
|
|
|
46
46
|
|
|
47
47
|
/// Bumped when the artifact layout or its checking semantics change; a
|
|
48
48
|
/// reader refuses versions it does not know (loudly, degrading to
|
|
49
|
-
/// structural checks — never a false pass).
|
|
50
|
-
|
|
49
|
+
/// structural checks — never a false pass). Version 2: the scroll-state
|
|
50
|
+
/// payload class became TWO-AXIS — a format-1 artifact classified the
|
|
51
|
+
/// retired four-field record as `.scroll_state`, which both engines now
|
|
52
|
+
/// reject, so accepting the stale artifact would be a false pass.
|
|
53
|
+
/// Version 3: the `terminal_state` payload class arrived and `on-terminal`
|
|
54
|
+
/// gained a bare-tag rule — a format-2 artifact classified a four-field
|
|
55
|
+
/// terminal message as `.unsupported` and would reject valid `<terminal>`
|
|
56
|
+
/// markup, so a stale artifact must force regeneration rather than pass.
|
|
57
|
+
pub const format_version: u32 = 3;
|
|
51
58
|
|
|
52
59
|
/// Where the app's build step writes the artifact, relative to the app
|
|
53
60
|
/// directory (a build product lives under zig-out, not in durable state).
|
|
@@ -129,8 +136,10 @@ pub const Iterable = struct {
|
|
|
129
136
|
/// Payload classes a markup dispatch can (or cannot) construct. The
|
|
130
137
|
/// special classes match the engines exactly: text_input/scroll_state
|
|
131
138
|
/// tags bind through on-input/on-scroll only, and `unsupported` payloads
|
|
132
|
-
/// cannot be built from markup at all.
|
|
133
|
-
|
|
139
|
+
/// cannot be built from markup at all. `legacy_scroll_state` is the
|
|
140
|
+
/// RETIRED one-axis scroll record, recognized only so `on-scroll` can
|
|
141
|
+
/// teach the two-axis migration by field name.
|
|
142
|
+
pub const PayloadClass = enum { none, string, integer, float, boolean, enum_tag, text_input, scroll_state, legacy_scroll_state, terminal_state, unsupported };
|
|
134
143
|
|
|
135
144
|
pub const MsgTag = struct {
|
|
136
145
|
name: []const u8,
|
|
@@ -170,6 +179,7 @@ pub const Contract = struct {
|
|
|
170
179
|
pub const Specials = struct {
|
|
171
180
|
TextInputEvent: type,
|
|
172
181
|
ScrollState: type,
|
|
182
|
+
TerminalState: type,
|
|
173
183
|
};
|
|
174
184
|
|
|
175
185
|
/// Reflect a concrete Model/Msg pair into a contract, at comptime. The
|
|
@@ -329,6 +339,15 @@ fn payloadClassOf(comptime T: type, comptime specials: Specials) PayloadClass {
|
|
|
329
339
|
// through on-scroll exactly like the canvas type — same resolution as
|
|
330
340
|
// both engines' scrollConstructor.
|
|
331
341
|
if (reflect.declaredScrollStateRecord(T)) return .scroll_state;
|
|
342
|
+
// The retired ONE-AXIS record classifies separately so on-scroll can
|
|
343
|
+
// teach the two-axis migration by field name instead of rejecting
|
|
344
|
+
// the payload generically.
|
|
345
|
+
if (reflect.declaredLegacyScrollStateRecord(T)) return .legacy_scroll_state;
|
|
346
|
+
if (T == specials.TerminalState) return .terminal_state;
|
|
347
|
+
// A declared mirror of the terminal-state record (transpiled cores)
|
|
348
|
+
// binds through on-terminal exactly like the canvas type — same
|
|
349
|
+
// resolution as both engines' terminalConstructor.
|
|
350
|
+
if (reflect.declaredTerminalStateRecord(T)) return .terminal_state;
|
|
332
351
|
return switch (@typeInfo(T)) {
|
|
333
352
|
.int => .integer,
|
|
334
353
|
.float => .float,
|
|
@@ -856,9 +875,23 @@ const Checker = struct {
|
|
|
856
875
|
}
|
|
857
876
|
if (std.mem.eql(u8, event, "scroll")) {
|
|
858
877
|
const found = tag orelse return self.failAttr(node, attribute, markup.on_scroll_payload_message);
|
|
878
|
+
// The retired one-axis record gets the migration teaching —
|
|
879
|
+
// it names the new per-axis fields — instead of the generic
|
|
880
|
+
// payload rejection.
|
|
881
|
+
if (found.payload == .legacy_scroll_state) return self.failAttr(node, attribute, markup.on_scroll_legacy_payload_message);
|
|
859
882
|
if (found.payload != .scroll_state) return self.failAttr(node, attribute, markup.on_scroll_payload_message);
|
|
860
883
|
return;
|
|
861
884
|
}
|
|
885
|
+
if (std.mem.eql(u8, event, "terminal")) {
|
|
886
|
+
// The runtime supplies the TerminalState payload, so the tag
|
|
887
|
+
// is BARE: an authored `:{binding}` would be silently
|
|
888
|
+
// discarded, which is the teaching error (dead data), not a
|
|
889
|
+
// pass.
|
|
890
|
+
if (expression.payload.len > 0) return self.failAttr(node, attribute, markup.on_terminal_payload_message);
|
|
891
|
+
const found = tag orelse return self.failAttr(node, attribute, markup.on_terminal_payload_message);
|
|
892
|
+
if (found.payload != .terminal_state) return self.failAttr(node, attribute, markup.on_terminal_payload_message);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
862
895
|
if (std.mem.eql(u8, event, "resize")) {
|
|
863
896
|
// f32 is the canvas-native arm; f64 the transpiled one-number
|
|
864
897
|
// float arm (engine parity — integer arms stay excluded, a
|
|
@@ -898,7 +931,7 @@ const Checker = struct {
|
|
|
898
931
|
.boolean => {},
|
|
899
932
|
// These payloads cannot be constructed from a markup binding
|
|
900
933
|
// (input/scroll payloads bind through their own events).
|
|
901
|
-
.text_input, .scroll_state, .unsupported => return self.failPayloadType(node, attribute, resolved, found),
|
|
934
|
+
.text_input, .scroll_state, .legacy_scroll_state, .terminal_state, .unsupported => return self.failPayloadType(node, attribute, resolved, found),
|
|
902
935
|
.none => unreachable,
|
|
903
936
|
}
|
|
904
937
|
}
|
|
@@ -1155,6 +1188,7 @@ const Checker = struct {
|
|
|
1155
1188
|
if (std.mem.eql(u8, node.name, "stepper")) return self.checkStepper(node);
|
|
1156
1189
|
if (std.mem.eql(u8, node.name, "timeline-item")) return self.checkTimelineItem(node);
|
|
1157
1190
|
if (std.mem.eql(u8, node.name, "chart")) return self.checkChart(node);
|
|
1191
|
+
if (std.mem.eql(u8, node.name, "video")) return self.checkVideo(node);
|
|
1158
1192
|
if (std.mem.eql(u8, node.name, "timeline")) {
|
|
1159
1193
|
for (node.attrs) |attribute| {
|
|
1160
1194
|
if (std.mem.eql(u8, attribute.name, "gap") or std.mem.eql(u8, attribute.name, "grow")) {
|
|
@@ -1205,6 +1239,18 @@ const Checker = struct {
|
|
|
1205
1239
|
try self.requireAttrKind(node, attribute, resolved.kind, &.{.integer}, markup.media_surface_surface_message);
|
|
1206
1240
|
continue;
|
|
1207
1241
|
}
|
|
1242
|
+
if (std.mem.eql(u8, attribute.name, "pty")) {
|
|
1243
|
+
// Terminal pty keys are model integers (engine parity —
|
|
1244
|
+
// the surface/image binding shape exactly): resolve the
|
|
1245
|
+
// binding so an undefined field is caught here and a
|
|
1246
|
+
// valid one is marked used (never a false dead-state
|
|
1247
|
+
// finding), and a non-integer is the teaching error.
|
|
1248
|
+
const expression = markup.parseAttrExpression(attribute.value) orelse continue;
|
|
1249
|
+
if (expression != .binding) continue;
|
|
1250
|
+
const resolved = try self.resolveBinding(node, expression.binding, true);
|
|
1251
|
+
try self.requireAttrKind(node, attribute, resolved.kind, &.{.integer}, markup.terminal_pty_message);
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1208
1254
|
if (std.mem.eql(u8, attribute.name, "icon") or
|
|
1209
1255
|
(std.mem.eql(u8, attribute.name, "name") and std.mem.eql(u8, node.name, "icon")))
|
|
1210
1256
|
{
|
|
@@ -1370,6 +1416,43 @@ const Checker = struct {
|
|
|
1370
1416
|
}
|
|
1371
1417
|
}
|
|
1372
1418
|
|
|
1419
|
+
/// `<video>`: a bound `src` must resolve to a string model field
|
|
1420
|
+
/// (the playback source is text — engine parity), the flags resolve
|
|
1421
|
+
/// truthy over any kind like every flag attribute (bare presence is
|
|
1422
|
+
/// true and resolves nothing), and sizing/identity resolve like the
|
|
1423
|
+
/// engines'.
|
|
1424
|
+
fn checkVideo(self: *Checker, node: markup.MarkupNode) CheckErr!void {
|
|
1425
|
+
for (node.attrs) |attribute| {
|
|
1426
|
+
if (std.mem.eql(u8, attribute.name, "src")) {
|
|
1427
|
+
const expression = markup.parseAttrExpression(attribute.value) orelse continue;
|
|
1428
|
+
if (expression != .binding) continue;
|
|
1429
|
+
const resolved = try self.resolveBinding(node, expression.binding, true);
|
|
1430
|
+
try self.requireAttrKind(node, attribute, resolved.kind, &.{.string}, markup.video_src_message);
|
|
1431
|
+
continue;
|
|
1432
|
+
}
|
|
1433
|
+
if (markup.videoFlagAttrName(attribute.name)) {
|
|
1434
|
+
if (attribute.value.len == 0) continue;
|
|
1435
|
+
_ = try self.attrKind(node, attribute, attribute.value);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
const number_attr = std.mem.eql(u8, attribute.name, "width") or
|
|
1439
|
+
std.mem.eql(u8, attribute.name, "height") or
|
|
1440
|
+
std.mem.eql(u8, attribute.name, "grow");
|
|
1441
|
+
if (number_attr) {
|
|
1442
|
+
try self.checkClassAttr(node, attribute, .number);
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
if (std.mem.eql(u8, attribute.name, "key") or std.mem.eql(u8, attribute.name, "global-key")) {
|
|
1446
|
+
try self.checkKeyAttr(node, attribute);
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
if (std.mem.eql(u8, attribute.name, "label")) {
|
|
1450
|
+
const kind = try self.attrKind(node, attribute, attribute.value);
|
|
1451
|
+
try self.requireAttrKind(node, attribute, kind, &.{.string}, label_attr_message);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1373
1456
|
fn checkSeries(self: *Checker, node: markup.MarkupNode) CheckErr!void {
|
|
1374
1457
|
for (node.attrs) |attribute| {
|
|
1375
1458
|
if (std.mem.eql(u8, attribute.name, "values")) {
|
|
@@ -49,6 +49,19 @@ const Profile = struct {
|
|
|
49
49
|
/// The transpiled-core mirror of `canvas.ScrollState` (field names pinned
|
|
50
50
|
/// by the reflect drift test below; classes per field).
|
|
51
51
|
const MirrorScroll = struct {
|
|
52
|
+
offset_x: f64,
|
|
53
|
+
offset_y: f64,
|
|
54
|
+
velocity_x: f64,
|
|
55
|
+
velocity_y: f64,
|
|
56
|
+
viewport_extent_x: f64,
|
|
57
|
+
viewport_extent_y: f64,
|
|
58
|
+
content_extent_x: f64,
|
|
59
|
+
content_extent_y: f64,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/// The RETIRED one-axis mirror: classifies as `legacy_scroll_state` so
|
|
63
|
+
/// the on-scroll checker teaches the per-axis migration by name.
|
|
64
|
+
const LegacyMirrorScroll = struct {
|
|
52
65
|
offset: f64,
|
|
53
66
|
velocity: f64,
|
|
54
67
|
viewport_extent: f64,
|
|
@@ -64,6 +77,7 @@ const Msg = union(enum) {
|
|
|
64
77
|
draft: canvas.TextInputEvent,
|
|
65
78
|
scrolled: canvas.ScrollState,
|
|
66
79
|
mirror_scrolled: MirrorScroll,
|
|
80
|
+
legacy_scrolled: LegacyMirrorScroll,
|
|
67
81
|
pane: f32,
|
|
68
82
|
pane_wide: f64,
|
|
69
83
|
tick,
|
|
@@ -101,6 +115,7 @@ const Model = struct {
|
|
|
101
115
|
const specials = contract.Specials{
|
|
102
116
|
.TextInputEvent = canvas.TextInputEvent,
|
|
103
117
|
.ScrollState = canvas.ScrollState,
|
|
118
|
+
.TerminalState = canvas.TerminalState,
|
|
104
119
|
};
|
|
105
120
|
|
|
106
121
|
const model_contract = contract.describe(Model, Msg, specials);
|
|
@@ -399,6 +414,17 @@ const fixtures = [_]Fixture{
|
|
|
399
414
|
,
|
|
400
415
|
.expect = markup.on_scroll_payload_message,
|
|
401
416
|
},
|
|
417
|
+
.{
|
|
418
|
+
// The RETIRED one-axis record gets the migration teaching that
|
|
419
|
+
// names the new per-axis fields, not the generic rejection.
|
|
420
|
+
.name = "an on-scroll tag carrying the retired one-axis record teaches the two-axis migration",
|
|
421
|
+
.source =
|
|
422
|
+
\\<scroll on-scroll="legacy_scrolled">
|
|
423
|
+
\\ <column><text>body</text></column>
|
|
424
|
+
\\</scroll>
|
|
425
|
+
,
|
|
426
|
+
.expect = markup.on_scroll_legacy_payload_message,
|
|
427
|
+
},
|
|
402
428
|
.{
|
|
403
429
|
// The transpiled one-number float arm carries the split fraction.
|
|
404
430
|
.name = "a split on-resize f64 arm accepts",
|
|
@@ -944,9 +970,15 @@ test "a contract round-trips through the ZON artifact" {
|
|
|
944
970
|
try testing.expectEqualStrings("wave", parsed.app_icons[0]);
|
|
945
971
|
try testing.expectEqualStrings("wave-pulse", parsed.app_icons[1]);
|
|
946
972
|
// Artifacts from before the app_icons field parse with the default
|
|
947
|
-
// (no registered icons) - the additive-with-default contract.
|
|
973
|
+
// (no registered icons) - the additive-with-default contract. The
|
|
974
|
+
// FORMAT VERSION is a separate gate: parsing tolerates missing
|
|
975
|
+
// fields, and the reader (tools/native-sdk markup check) refuses
|
|
976
|
+
// any format it does not know — format 1 classified the retired
|
|
977
|
+
// one-axis scroll record as a scroll_state payload, which would be
|
|
978
|
+
// a false pass today.
|
|
948
979
|
const legacy = try contract.parseArtifact(arena, ".{ .format = 1 }");
|
|
949
980
|
try testing.expectEqual(@as(usize, 0), legacy.app_icons.len);
|
|
981
|
+
try testing.expect(legacy.format != contract.format_version);
|
|
950
982
|
try testing.expectEqualStrings(model_contract.model_type, parsed.model_type);
|
|
951
983
|
try testing.expectEqual(model_contract.model.scalars.len, parsed.model.scalars.len);
|
|
952
984
|
try testing.expectEqual(model_contract.iterables.len, parsed.iterables.len);
|
|
@@ -1224,12 +1256,17 @@ test "the reflect field vocabulary never drifts from canvas.ScrollState" {
|
|
|
1224
1256
|
|
|
1225
1257
|
test "a declared scroll-state mirror classifies as a scroll_state payload" {
|
|
1226
1258
|
var saw_mirror = false;
|
|
1259
|
+
var saw_legacy = false;
|
|
1227
1260
|
var saw_wide_pane = false;
|
|
1228
1261
|
for (model_contract.msgs) |tag| {
|
|
1229
1262
|
if (std.mem.eql(u8, tag.name, "mirror_scrolled")) {
|
|
1230
1263
|
saw_mirror = true;
|
|
1231
1264
|
try testing.expectEqual(contract.PayloadClass.scroll_state, tag.payload);
|
|
1232
1265
|
}
|
|
1266
|
+
if (std.mem.eql(u8, tag.name, "legacy_scrolled")) {
|
|
1267
|
+
saw_legacy = true;
|
|
1268
|
+
try testing.expectEqual(contract.PayloadClass.legacy_scroll_state, tag.payload);
|
|
1269
|
+
}
|
|
1233
1270
|
if (std.mem.eql(u8, tag.name, "pane_wide")) {
|
|
1234
1271
|
saw_wide_pane = true;
|
|
1235
1272
|
try testing.expectEqual(contract.PayloadClass.float, tag.payload);
|
|
@@ -1237,6 +1274,7 @@ test "a declared scroll-state mirror classifies as a scroll_state payload" {
|
|
|
1237
1274
|
}
|
|
1238
1275
|
}
|
|
1239
1276
|
try testing.expect(saw_mirror);
|
|
1277
|
+
try testing.expect(saw_legacy);
|
|
1240
1278
|
try testing.expect(saw_wide_pane);
|
|
1241
1279
|
}
|
|
1242
1280
|
|
|
@@ -498,6 +498,7 @@ test "huge Model reflects into a model contract without raising the eval-branch
|
|
|
498
498
|
const huge_contract = comptime canvas.ui_markup.contract.describe(HugeModel, HugeMsg, .{
|
|
499
499
|
.TextInputEvent = canvas.TextInputEvent,
|
|
500
500
|
.ScrollState = canvas.ScrollState,
|
|
501
|
+
.TerminalState = canvas.TerminalState,
|
|
501
502
|
});
|
|
502
503
|
try std.testing.expect(huge_contract.model.scalars.len > 100);
|
|
503
504
|
try std.testing.expect(huge_contract.iterables.len > 30);
|
|
@@ -106,9 +106,9 @@ pub fn isZeroArgFn(comptime T: type, comptime DeclType: type) bool {
|
|
|
106
106
|
/// declared-shape predicate below stays std-only. A drift test in
|
|
107
107
|
/// `ui_markup_contract_tests.zig` holds this list equal to the real union.
|
|
108
108
|
pub const text_input_event_tags = [_][]const u8{
|
|
109
|
-
"insert_text",
|
|
110
|
-
"delete_word_forward", "clear",
|
|
111
|
-
"set_composition",
|
|
109
|
+
"insert_text", "delete_backward", "delete_forward", "delete_word_backward",
|
|
110
|
+
"delete_word_forward", "clear", "move_caret", "set_selection",
|
|
111
|
+
"set_composition", "commit_composition", "cancel_composition",
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
/// The caret-direction member vocabulary (`canvas.TextCaretDirection`).
|
|
@@ -156,12 +156,16 @@ pub fn declaredTextInputUnion(comptime T: type) bool {
|
|
|
156
156
|
return true;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
/// The canvas `ScrollState` field vocabulary
|
|
160
|
-
///
|
|
161
|
-
///
|
|
162
|
-
/// struct's fields (names and f32
|
|
159
|
+
/// The canvas `ScrollState` field vocabulary — the TWO-AXIS record,
|
|
160
|
+
/// eight per-axis fields — pinned here so the declared-shape predicate
|
|
161
|
+
/// below stays std-only. A drift test in `ui_markup_contract_tests.zig`
|
|
162
|
+
/// holds this list equal to the real struct's fields (names and f32
|
|
163
|
+
/// types alike).
|
|
163
164
|
pub const scroll_state_field_names = [_][]const u8{
|
|
164
|
-
"
|
|
165
|
+
"offset_x", "offset_y",
|
|
166
|
+
"velocity_x", "velocity_y",
|
|
167
|
+
"viewport_extent_x", "viewport_extent_y",
|
|
168
|
+
"content_extent_x", "content_extent_y",
|
|
165
169
|
};
|
|
166
170
|
|
|
167
171
|
/// The same vocabulary in the TS SDK's spelling (`@native-sdk/core/events`
|
|
@@ -169,35 +173,48 @@ pub const scroll_state_field_names = [_][]const u8{
|
|
|
169
173
|
/// field names the TS source wrote — your names are your names — so the
|
|
170
174
|
/// structural match accepts either spelling, never a mix.
|
|
171
175
|
pub const scroll_state_field_names_ts = [_][]const u8{
|
|
176
|
+
"offsetX", "offsetY",
|
|
177
|
+
"velocityX", "velocityY",
|
|
178
|
+
"viewportExtentX", "viewportExtentY",
|
|
179
|
+
"contentExtentX", "contentExtentY",
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/// The terminal-state vocabulary `canvas.TerminalState` carries — pinned
|
|
183
|
+
/// here so the declared-shape predicate below stays std-only. A drift
|
|
184
|
+
/// test in `ui_markup_contract_tests.zig` holds this list equal to the
|
|
185
|
+
/// real struct's fields. One spelling only: every field is a single
|
|
186
|
+
/// word, so the canvas and TS SDK spellings coincide.
|
|
187
|
+
pub const terminal_state_field_names = [_][]const u8{
|
|
188
|
+
"scrollback", "history", "cols", "rows",
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/// The RETIRED one-axis scroll-state vocabulary, kept only to recognize
|
|
192
|
+
/// a pre-two-axis mirror and teach the migration by name (see
|
|
193
|
+
/// `declaredLegacyScrollStateRecord`). Nothing dispatches through these
|
|
194
|
+
/// fields anymore.
|
|
195
|
+
pub const legacy_scroll_state_field_names = [_][]const u8{
|
|
196
|
+
"offset", "velocity", "viewport_extent", "content_extent",
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/// The retired vocabulary in the TS SDK's spelling.
|
|
200
|
+
pub const legacy_scroll_state_field_names_ts = [_][]const u8{
|
|
172
201
|
"offset", "velocity", "viewportExtent", "contentExtent",
|
|
173
202
|
};
|
|
174
203
|
|
|
175
|
-
|
|
176
|
-
/// being `canvas.ScrollState` by identity — the transpiled-core case,
|
|
177
|
-
/// where the emitted module declares its own mirror record (type identity
|
|
178
|
-
/// cannot cross the emission boundary). Matched structurally, the
|
|
179
|
-
/// `declaredTextInputUnion` contract applied to `on-scroll`: a struct of
|
|
180
|
-
/// exactly the four field names in either the canvas spelling
|
|
181
|
-
/// (`viewport_extent`, Zig-declared mirrors and `canvas.ScrollState`
|
|
182
|
-
/// itself) or the TS SDK spelling (`viewportExtent`, the emitted-core
|
|
183
|
-
/// mirror — transpiled fields keep their TS names), each numeric. Integer
|
|
184
|
-
/// or float per field (the transpiler's number model classes each slot);
|
|
185
|
-
/// the dispatch translation widens floats exactly and rounds
|
|
186
|
-
/// integer-classed fields to the nearest whole number.
|
|
187
|
-
pub fn declaredScrollStateRecord(comptime T: type) bool {
|
|
204
|
+
fn declaredRecordMatchesVocabulary(comptime T: type, comptime canvas_names: []const []const u8, comptime ts_names: []const []const u8) bool {
|
|
188
205
|
const info = switch (@typeInfo(T)) {
|
|
189
206
|
.@"struct" => |s| s,
|
|
190
207
|
else => return false,
|
|
191
208
|
};
|
|
192
|
-
if (info.fields.len !=
|
|
209
|
+
if (info.fields.len != canvas_names.len) return false;
|
|
193
210
|
const canvas_spelling = comptime blk: {
|
|
194
|
-
for (
|
|
211
|
+
for (canvas_names) |name| {
|
|
195
212
|
if (!@hasField(T, name)) break :blk false;
|
|
196
213
|
}
|
|
197
214
|
break :blk true;
|
|
198
215
|
};
|
|
199
216
|
const ts_spelling = comptime blk: {
|
|
200
|
-
for (
|
|
217
|
+
for (ts_names) |name| {
|
|
201
218
|
if (!@hasField(T, name)) break :blk false;
|
|
202
219
|
}
|
|
203
220
|
break :blk true;
|
|
@@ -209,6 +226,40 @@ pub fn declaredScrollStateRecord(comptime T: type) bool {
|
|
|
209
226
|
return true;
|
|
210
227
|
}
|
|
211
228
|
|
|
229
|
+
/// A Msg arm payload record DECLARING the scroll-state shape rather than
|
|
230
|
+
/// being `canvas.ScrollState` by identity — the transpiled-core case,
|
|
231
|
+
/// where the emitted module declares its own mirror record (type identity
|
|
232
|
+
/// cannot cross the emission boundary). Matched structurally, the
|
|
233
|
+
/// `declaredTextInputUnion` contract applied to `on-scroll`: a struct of
|
|
234
|
+
/// exactly the eight per-axis field names in either the canvas spelling
|
|
235
|
+
/// (`viewport_extent_y`, Zig-declared mirrors and `canvas.ScrollState`
|
|
236
|
+
/// itself) or the TS SDK spelling (`viewportExtentY`, the emitted-core
|
|
237
|
+
/// mirror — transpiled fields keep their TS names), each numeric. Integer
|
|
238
|
+
/// or float per field (the transpiler's number model classes each slot);
|
|
239
|
+
/// the dispatch translation widens floats exactly and rounds
|
|
240
|
+
/// integer-classed fields to the nearest whole number.
|
|
241
|
+
pub fn declaredScrollStateRecord(comptime T: type) bool {
|
|
242
|
+
return declaredRecordMatchesVocabulary(T, &scroll_state_field_names, &scroll_state_field_names_ts);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/// A Msg arm payload record DECLARING the terminal-state shape rather
|
|
246
|
+
/// than being `canvas.TerminalState` by identity — the transpiled-core
|
|
247
|
+
/// case, matched structurally like `declaredScrollStateRecord`: a struct
|
|
248
|
+
/// of exactly the four field names (scrollback/history/cols/rows — one
|
|
249
|
+
/// spelling, the words are single), each numeric.
|
|
250
|
+
pub fn declaredTerminalStateRecord(comptime T: type) bool {
|
|
251
|
+
return declaredRecordMatchesVocabulary(T, &terminal_state_field_names, &terminal_state_field_names);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/// A mirror of the RETIRED one-axis scroll state — `{offset, velocity,
|
|
255
|
+
/// viewport_extent, content_extent}` in either spelling. Recognized only
|
|
256
|
+
/// to fail with a teaching that names the new per-axis fields, so an app
|
|
257
|
+
/// carrying the pre-two-axis record shape hears exactly what to declare
|
|
258
|
+
/// instead of a generic payload rejection.
|
|
259
|
+
pub fn declaredLegacyScrollStateRecord(comptime T: type) bool {
|
|
260
|
+
return declaredRecordMatchesVocabulary(T, &legacy_scroll_state_field_names, &legacy_scroll_state_field_names_ts);
|
|
261
|
+
}
|
|
262
|
+
|
|
212
263
|
/// The machine classes a value-carrying Msg arm may declare for the
|
|
213
264
|
/// markup value events (slider `on-change`, split `on-resize`): `f32` is
|
|
214
265
|
/// the canvas-native payload Zig cores declare; `f64` is the one-number
|