@native-sdk/cli 0.5.3 → 0.6.0
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 +91 -2
- package/build.zig +756 -5
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +19 -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 +416 -9
- package/packages/core/sdk/core.ts +706 -5
- 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 +3187 -264
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +42 -4
- package/skill-data/ts-core/SKILL.md +13 -3
- package/src/app_runner/root.zig +112 -10
- package/src/app_runner/ts_core_main.zig +4 -0
- 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/tests.zig +119 -1
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +639 -16
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +351 -7
- package/src/platform/macos/appkit_host.h +152 -8
- package/src/platform/macos/appkit_host.m +1816 -100
- package/src/platform/macos/cef_host.mm +372 -11
- package/src/platform/macos/root.zig +379 -11
- package/src/platform/null_platform.zig +696 -9
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +42 -0
- package/src/platform/types.zig +524 -18
- package/src/platform/windows/root.zig +432 -9
- package/src/platform/windows/webview2_host.cpp +482 -45
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- 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 +2 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +535 -12
- package/src/primitives/canvas/ui_markup.zig +253 -36
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
- package/src/primitives/canvas/ui_markup_contract.zig +89 -6
- package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- 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 +178 -9
- package/src/primitives/canvas/ui_markup_view.zig +220 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
- package/src/primitives/canvas/ui_schema.zig +110 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -10
- 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 +23 -0
- package/src/runtime/api.zig +76 -5
- 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 +8 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- 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_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- 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 +240 -24
- 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 +131 -13
- package/src/runtime/effects.zig +8136 -180
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +167 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +42 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- 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 +36 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +432 -62
- package/src/runtime/session_record.zig +43 -2
- package/src/runtime/session_replay.zig +556 -20
- package/src/runtime/session_tests.zig +2087 -1
- package/src/runtime/shell_layout.zig +7 -0
- 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/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +8 -0
- package/src/runtime/ts_core_host.zig +1320 -45
- package/src/runtime/ts_core_host_tests.zig +1100 -1
- package/src/runtime/ts_ui_app.zig +23 -5
- package/src/runtime/ui_app.zig +2444 -69
- 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 +736 -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_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +77 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +62 -1
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +244 -8
|
@@ -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")) {
|
|
@@ -1193,7 +1227,7 @@ const Checker = struct {
|
|
|
1193
1227
|
const expression = markup.parseAttrExpression(attribute.value) orelse continue;
|
|
1194
1228
|
if (expression != .binding) continue;
|
|
1195
1229
|
const resolved = try self.resolveBinding(node, expression.binding, true);
|
|
1196
|
-
try self.requireAttrKind(node, attribute, resolved.kind, &.{.integer}, markup.
|
|
1230
|
+
try self.requireAttrKind(node, attribute, resolved.kind, &.{.integer}, markup.image_binding_message);
|
|
1197
1231
|
continue;
|
|
1198
1232
|
}
|
|
1199
1233
|
if (std.mem.eql(u8, attribute.name, "surface")) {
|
|
@@ -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",
|
|
@@ -743,6 +769,32 @@ test "the media-surface surface binding checks as a model integer" {
|
|
|
743
769
|
try testing.expectEqualStrings(markup.media_surface_surface_message, message);
|
|
744
770
|
}
|
|
745
771
|
|
|
772
|
+
test "the image leaf's image binding checks as a model integer" {
|
|
773
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
774
|
+
defer arena_state.deinit();
|
|
775
|
+
const arena = arena_state.allocator();
|
|
776
|
+
|
|
777
|
+
// An integer-producing binding passes on avatar and the image leaf
|
|
778
|
+
// alike — the exact grammar `native check`'s model-aware pass
|
|
779
|
+
// applies to TS and Zig cores.
|
|
780
|
+
const good = try parseFixture(arena,
|
|
781
|
+
\\<column>
|
|
782
|
+
\\ <image image="{count}" label="Cover art" />
|
|
783
|
+
\\ <avatar image="{count}">CT</avatar>
|
|
784
|
+
\\</column>
|
|
785
|
+
);
|
|
786
|
+
try testing.expectEqual(null, try contractMessage(arena, good, null));
|
|
787
|
+
|
|
788
|
+
// A non-integer binding is refused with the image teaching.
|
|
789
|
+
const wrong = try parseFixture(arena,
|
|
790
|
+
\\<column>
|
|
791
|
+
\\ <image image="{name}" label="Cover art" />
|
|
792
|
+
\\</column>
|
|
793
|
+
);
|
|
794
|
+
const message = (try contractMessage(arena, wrong, null)).?;
|
|
795
|
+
try testing.expectEqualStrings(markup.image_binding_message, message);
|
|
796
|
+
}
|
|
797
|
+
|
|
746
798
|
test "app: icon references check against the contract's registered icon list" {
|
|
747
799
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
748
800
|
defer arena_state.deinit();
|
|
@@ -918,9 +970,15 @@ test "a contract round-trips through the ZON artifact" {
|
|
|
918
970
|
try testing.expectEqualStrings("wave", parsed.app_icons[0]);
|
|
919
971
|
try testing.expectEqualStrings("wave-pulse", parsed.app_icons[1]);
|
|
920
972
|
// Artifacts from before the app_icons field parse with the default
|
|
921
|
-
// (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.
|
|
922
979
|
const legacy = try contract.parseArtifact(arena, ".{ .format = 1 }");
|
|
923
980
|
try testing.expectEqual(@as(usize, 0), legacy.app_icons.len);
|
|
981
|
+
try testing.expect(legacy.format != contract.format_version);
|
|
924
982
|
try testing.expectEqualStrings(model_contract.model_type, parsed.model_type);
|
|
925
983
|
try testing.expectEqual(model_contract.model.scalars.len, parsed.model.scalars.len);
|
|
926
984
|
try testing.expectEqual(model_contract.iterables.len, parsed.iterables.len);
|
|
@@ -1198,12 +1256,17 @@ test "the reflect field vocabulary never drifts from canvas.ScrollState" {
|
|
|
1198
1256
|
|
|
1199
1257
|
test "a declared scroll-state mirror classifies as a scroll_state payload" {
|
|
1200
1258
|
var saw_mirror = false;
|
|
1259
|
+
var saw_legacy = false;
|
|
1201
1260
|
var saw_wide_pane = false;
|
|
1202
1261
|
for (model_contract.msgs) |tag| {
|
|
1203
1262
|
if (std.mem.eql(u8, tag.name, "mirror_scrolled")) {
|
|
1204
1263
|
saw_mirror = true;
|
|
1205
1264
|
try testing.expectEqual(contract.PayloadClass.scroll_state, tag.payload);
|
|
1206
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
|
+
}
|
|
1207
1270
|
if (std.mem.eql(u8, tag.name, "pane_wide")) {
|
|
1208
1271
|
saw_wide_pane = true;
|
|
1209
1272
|
try testing.expectEqual(contract.PayloadClass.float, tag.payload);
|
|
@@ -1211,6 +1274,7 @@ test "a declared scroll-state mirror classifies as a scroll_state payload" {
|
|
|
1211
1274
|
}
|
|
1212
1275
|
}
|
|
1213
1276
|
try testing.expect(saw_mirror);
|
|
1277
|
+
try testing.expect(saw_legacy);
|
|
1214
1278
|
try testing.expect(saw_wide_pane);
|
|
1215
1279
|
}
|
|
1216
1280
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
//! Compile-cost guard: a deliberately huge `.native` document — well past
|
|
2
|
+
//! 16KB of realistically nested markup — must build through the compiled
|
|
3
|
+
//! engine without the test (or any app) raising `@setEvalBranchQuota`.
|
|
4
|
+
//! Before the fix, `canonicalizeComptime` sized its quota by recursively
|
|
5
|
+
//! measuring the tree INSIDE the quota argument, which evaluates under the
|
|
6
|
+
//! caller's default 1000-backwards-branch budget — so any document past
|
|
7
|
+
//! ~10KB failed to compile with "evaluation exceeded 1000 backwards
|
|
8
|
+
//! branches" while the runtime interpreter handled it fine. The document
|
|
9
|
+
//! now carries `source_bytes` from parse/resolve time (O(1) to read);
|
|
10
|
+
//! this fixture is the regression tripwire for the single-file path, and
|
|
11
|
+
//! the import fixture below pins the resolver's size accounting (the
|
|
12
|
+
//! merged document's `source_bytes` must cover imported template trees,
|
|
13
|
+
//! not just the root file).
|
|
14
|
+
|
|
15
|
+
const std = @import("std");
|
|
16
|
+
const canvas = @import("root.zig");
|
|
17
|
+
const compiled_view = @import("ui_markup_compiled.zig");
|
|
18
|
+
|
|
19
|
+
const Item = struct {
|
|
20
|
+
id: u32,
|
|
21
|
+
name: []const u8,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Model = struct {
|
|
25
|
+
title: []const u8 = "ops console",
|
|
26
|
+
count: u32 = 3,
|
|
27
|
+
items: []const Item = &.{},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Msg = union(enum) {
|
|
31
|
+
refresh,
|
|
32
|
+
press: u32,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/// One realistic dashboard section, ~560 bytes of markup: a header row
|
|
36
|
+
/// with an interpolated title, a conditional status line, and a keyed-off
|
|
37
|
+
/// item list with per-item dispatch. Repeated enough times to put the
|
|
38
|
+
/// whole source safely past the old ~10KB comptime cliff.
|
|
39
|
+
fn sectionSource(comptime index: usize) []const u8 {
|
|
40
|
+
return std.fmt.comptimePrint(
|
|
41
|
+
\\ <panel padding="12">
|
|
42
|
+
\\ <row gap="8" cross="center">
|
|
43
|
+
\\ <badge radius="md">Section {d}</badge>
|
|
44
|
+
\\ <text grow="1">{{title}} - block {d} of the oversized regression document, padded with realistic prose so the source passes the old comptime measurement cliff.</text>
|
|
45
|
+
\\ <button size="sm" on-press="refresh">Reload</button>
|
|
46
|
+
\\ </row>
|
|
47
|
+
\\ <if test="{{count}}">
|
|
48
|
+
\\ <text>block {d} has {{count}} pending updates</text>
|
|
49
|
+
\\ </if>
|
|
50
|
+
\\ <for each="items" as="it">
|
|
51
|
+
\\ <row gap="6" cross="center">
|
|
52
|
+
\\ <text grow="1">{{it.name}}</text>
|
|
53
|
+
\\ <button size="sm" on-press="press:{{it.id}}">Open</button>
|
|
54
|
+
\\ </row>
|
|
55
|
+
\\ </for>
|
|
56
|
+
\\ </panel>
|
|
57
|
+
\\
|
|
58
|
+
, .{ index, index, index });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fn hugeSource(comptime sections: usize) []const u8 {
|
|
62
|
+
comptime {
|
|
63
|
+
// Quota for the fixture GENERATOR only (comptime string
|
|
64
|
+
// concatenation over ~20KB); the engine under test must get by on
|
|
65
|
+
// its own derived quotas.
|
|
66
|
+
@setEvalBranchQuota(1_000_000);
|
|
67
|
+
var source: []const u8 = "<column gap=\"8\">\n <text>{title}</text>\n";
|
|
68
|
+
for (0..sections) |index| {
|
|
69
|
+
source = source ++ sectionSource(index);
|
|
70
|
+
}
|
|
71
|
+
return source ++ "</column>\n";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const huge_source = hugeSource(36);
|
|
76
|
+
|
|
77
|
+
fn testItems() []const Item {
|
|
78
|
+
return &.{ .{ .id = 1, .name = "alpha" }, .{ .id = 2, .name = "beta" } };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
test "a 16KB+ document compiles through the compiled engine without raising the eval-branch quota" {
|
|
82
|
+
try std.testing.expect(huge_source.len >= 16_000);
|
|
83
|
+
|
|
84
|
+
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
|
|
85
|
+
defer arena_state.deinit();
|
|
86
|
+
const arena = arena_state.allocator();
|
|
87
|
+
|
|
88
|
+
var ui = canvas.Ui(Msg).init(arena);
|
|
89
|
+
const model: Model = .{ .items = testItems() };
|
|
90
|
+
const tree = try ui.finalize(compiled_view.CompiledMarkupView(Model, Msg, huge_source).build(&ui, &model));
|
|
91
|
+
|
|
92
|
+
// The whole document rendered: every section's badge, per-item
|
|
93
|
+
// dispatch from the last section's list, and the conditional branch.
|
|
94
|
+
var badges: usize = 0;
|
|
95
|
+
countKind(tree.root, .badge, &badges);
|
|
96
|
+
try std.testing.expectEqual(@as(usize, 36), badges);
|
|
97
|
+
var buttons: usize = 0;
|
|
98
|
+
countKind(tree.root, .button, &buttons);
|
|
99
|
+
try std.testing.expectEqual(@as(usize, 36 + 36 * 2), buttons);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// A component file carrying one huge template body. The root view is
|
|
103
|
+
/// tiny, so if import resolution failed to count imported sources into
|
|
104
|
+
/// the merged document's `source_bytes`, the canonicalize walk over the
|
|
105
|
+
/// spliced template tree would outrun its quota and this file would not
|
|
106
|
+
/// compile.
|
|
107
|
+
fn hugeTemplateSource(comptime rows: usize) []const u8 {
|
|
108
|
+
comptime {
|
|
109
|
+
@setEvalBranchQuota(1_000_000);
|
|
110
|
+
var source: []const u8 = "<template name=\"big-panel\" args=\"heading\">\n <column gap=\"4\">\n";
|
|
111
|
+
for (0..rows) |index| {
|
|
112
|
+
source = source ++ std.fmt.comptimePrint(
|
|
113
|
+
\\ <row gap="6" cross="center">
|
|
114
|
+
\\ <badge radius="md">{{heading}} {d}</badge>
|
|
115
|
+
\\ <text grow="1">imported row {d}, padded with enough literal prose that the imported file alone crosses the old comptime measurement cliff.</text>
|
|
116
|
+
\\ </row>
|
|
117
|
+
\\
|
|
118
|
+
, .{ index, index });
|
|
119
|
+
}
|
|
120
|
+
return source ++ " </column>\n</template>\n";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const huge_import_sources = [_]canvas.ui_markup.SourceFile{
|
|
125
|
+
.{ .path = "view.native", .source =
|
|
126
|
+
\\<import src="components/big.native"/>
|
|
127
|
+
\\<column gap="8">
|
|
128
|
+
\\ <use template="big-panel" heading="Imported" />
|
|
129
|
+
\\</column>
|
|
130
|
+
},
|
|
131
|
+
.{ .path = "components/big.native", .source = hugeTemplateSource(72) },
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
test "a large imported template compiles through the compiled engine's import resolution" {
|
|
135
|
+
try std.testing.expect(huge_import_sources[1].source.len >= 16_000);
|
|
136
|
+
|
|
137
|
+
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
|
|
138
|
+
defer arena_state.deinit();
|
|
139
|
+
const arena = arena_state.allocator();
|
|
140
|
+
|
|
141
|
+
const Compiled = canvas.CompiledMarkupImports(Model, Msg, "view.native", &huge_import_sources);
|
|
142
|
+
var ui = canvas.Ui(Msg).init(arena);
|
|
143
|
+
const model: Model = .{};
|
|
144
|
+
const tree = try ui.finalize(Compiled.build(&ui, &model));
|
|
145
|
+
|
|
146
|
+
var badges: usize = 0;
|
|
147
|
+
countKind(tree.root, .badge, &badges);
|
|
148
|
+
try std.testing.expectEqual(@as(usize, 72), badges);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
fn countKind(widget: canvas.Widget, kind: canvas.WidgetKind, total: *usize) void {
|
|
152
|
+
if (widget.kind == kind) total.* += 1;
|
|
153
|
+
for (widget.children) |child| countKind(child, kind, total);
|
|
154
|
+
}
|
|
@@ -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
|