@native-sdk/cli 0.4.4 → 0.5.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 +371 -5
- package/build/ts_run.mjs +102 -0
- package/build.zig +255 -1
- package/build.zig.zon +1 -0
- package/package.json +19 -10
- package/packages/core/package-lock.json +44 -0
- package/packages/core/package.json +38 -0
- package/packages/core/rt/rt.zig +1579 -0
- package/packages/core/sdk/bytes_text_methods.d.ts +88 -0
- package/packages/core/sdk/core.ts +694 -0
- package/packages/core/sdk/events.ts +137 -0
- package/packages/core/sdk/text.ts +519 -0
- package/packages/core/src/checker.ts +1869 -0
- package/packages/core/src/cli.ts +68 -0
- package/packages/core/src/devhost.ts +291 -0
- package/packages/core/src/devhost_resolver.mjs +22 -0
- package/packages/core/src/diagnostics.ts +417 -0
- package/packages/core/src/emitter.ts +8815 -0
- package/packages/core/src/infer.ts +1515 -0
- package/packages/core/src/modules.ts +173 -0
- package/packages/core/src/ownership.ts +740 -0
- package/packages/core/src/text_polyfill.ts +337 -0
- package/packages/core/src/text_tables.ts +408 -0
- package/packages/core/src/transpile.ts +146 -0
- package/packages/core/src/typed_ast.ts +546 -0
- package/packages/core/src/types.ts +815 -0
- package/skill-data/native-ui/SKILL.md +14 -0
- package/skill-data/ts-core/SKILL.md +493 -0
- package/skill-data/zig/SKILL.md +10 -0
- package/src/app_runner/root.zig +24 -0
- package/src/app_runner/ts_core_main.zig +231 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/app_manifest/comptime_scene.zig +341 -0
- package/src/primitives/app_manifest/root.zig +5 -0
- package/src/primitives/canvas/commands.zig +14 -7
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/lazy_tls.zig +73 -0
- package/src/primitives/canvas/render_generic_resources.zig +22 -15
- package/src/primitives/canvas/root.zig +11 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +40 -32
- package/src/primitives/canvas/text_layout_cache.zig +29 -22
- package/src/primitives/canvas/text_measure_cache.zig +56 -41
- package/src/primitives/canvas/text_spans.zig +39 -26
- package/src/primitives/canvas/tokens.zig +69 -0
- package/src/primitives/canvas/ui.zig +125 -0
- package/src/primitives/canvas/ui_markup.zig +22 -3
- package/src/primitives/canvas/ui_markup_compiled.zig +97 -7
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +275 -0
- package/src/primitives/canvas/ui_markup_contract.zig +68 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +257 -2
- package/src/primitives/canvas/ui_markup_reflect.zig +214 -0
- package/src/primitives/canvas/ui_markup_view.zig +105 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +336 -0
- package/src/primitives/canvas/ui_schema.zig +8 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +309 -5
- package/src/primitives/canvas/widget_invalidation.zig +14 -7
- package/src/primitives/canvas/widget_layout.zig +138 -2
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_render.zig +25 -15
- package/src/primitives/canvas/widget_render_controls.zig +15 -9
- package/src/primitives/canvas/widget_runtime_tests.zig +44 -0
- package/src/root.zig +7 -0
- package/src/runtime/canvas_frame.zig +57 -36
- package/src/runtime/canvas_images.zig +9 -3
- package/src/runtime/canvas_widget_control_tests.zig +5 -6
- package/src/runtime/canvas_widget_runtime.zig +7 -4
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +1525 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_host_tests.zig +594 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/root.zig +18 -0
- package/src/runtime/session_replay.zig +7 -1
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +1505 -0
- package/src/runtime/ts_core_host_tests.zig +1408 -0
- package/src/runtime/ts_ui_app.zig +469 -0
- package/src/runtime/ui_app.zig +189 -38
- package/src/runtime/ui_app_tests.zig +221 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view_canvas.zig +24 -17
- package/src/runtime/view_widget_tree.zig +2 -2
- package/src/tooling/codesign.zig +212 -105
- package/src/tooling/doctor.zig +78 -0
- package/src/tooling/manifest.zig +47 -0
- package/src/tooling/package.zig +435 -20
- package/src/tooling/raw_manifest.zig +15 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +777 -34
- package/src/tooling/ts_core.zig +1099 -0
- package/src/tooling/verbs.zig +105 -2
|
@@ -1245,7 +1245,12 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1245
1245
|
|
|
1246
1246
|
/// Resolve a series `values` binding through the same sources
|
|
1247
1247
|
/// `for each` accepts (scope slice args shadow model iterables),
|
|
1248
|
-
/// requiring an f32 element type at comptime.
|
|
1248
|
+
/// requiring an f32 or f64 element type at comptime. f64
|
|
1249
|
+
/// iterables narrow into a build-arena f32 copy per sample (the
|
|
1250
|
+
/// interpreter's `f32Items` rule): transpiled TS cores carry
|
|
1251
|
+
/// every number array as f64 — the subset's one float class —
|
|
1252
|
+
/// and refusing them would leave markup charts unreachable from
|
|
1253
|
+
/// a TS model.
|
|
1249
1254
|
fn chartValuesItems(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype) []const f32 {
|
|
1250
1255
|
const path = comptime blk: {
|
|
1251
1256
|
const expression = markup.parseAttrExpression(raw) orelse fail(node, markup.series_values_message);
|
|
@@ -1256,17 +1261,31 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1256
1261
|
if (comptime (scope_index_opt != null)) {
|
|
1257
1262
|
const scope_index = comptime scope_index_opt.?;
|
|
1258
1263
|
comptime {
|
|
1259
|
-
if (entries[scope_index].kind != .slice_arg or
|
|
1264
|
+
if (entries[scope_index].kind != .slice_arg or
|
|
1265
|
+
(entries[scope_index].Item != f32 and entries[scope_index].Item != f64))
|
|
1266
|
+
{
|
|
1260
1267
|
fail(node, markup.series_values_message);
|
|
1261
1268
|
}
|
|
1262
1269
|
}
|
|
1263
|
-
return scopePayload(entries, scope_index, scope);
|
|
1270
|
+
return narrowedSeriesValues(entries[scope_index].Item, scopePayload(entries, scope_index, scope), ui);
|
|
1264
1271
|
}
|
|
1265
1272
|
const info = comptime (eachInfo(path) orelse fail(node, markup.series_values_message));
|
|
1266
1273
|
comptime {
|
|
1267
|
-
if (info.Item != f32) fail(node, markup.series_values_message);
|
|
1274
|
+
if (info.Item != f32 and info.Item != f64) fail(node, markup.series_values_message);
|
|
1268
1275
|
}
|
|
1269
|
-
return eachItems(info, ui, model);
|
|
1276
|
+
return narrowedSeriesValues(info.Item, eachItems(info, ui, model), ui);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/// f32 series values pass through; f64 values copy down into the
|
|
1280
|
+
/// build arena (charts plot f32).
|
|
1281
|
+
fn narrowedSeriesValues(comptime Item: type, items: []const Item, ui: *Ui) []const f32 {
|
|
1282
|
+
if (comptime (Item == f32)) return items;
|
|
1283
|
+
const narrowed = ui.arena.alloc(f32, items.len) catch {
|
|
1284
|
+
ui.failed = true;
|
|
1285
|
+
return &.{};
|
|
1286
|
+
};
|
|
1287
|
+
for (narrowed, items) |*slot, value| slot.* = @floatCast(value);
|
|
1288
|
+
return narrowed;
|
|
1270
1289
|
}
|
|
1271
1290
|
|
|
1272
1291
|
/// Comptime icon-value classification with the invalid arm turned
|
|
@@ -1612,6 +1631,15 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1612
1631
|
break :blk std.fmt.parseFloat(f32, attribute.value) catch
|
|
1613
1632
|
fail(node, markup.anchor_offset_value_message);
|
|
1614
1633
|
};
|
|
1634
|
+
} else if (comptime std.mem.eql(u8, attribute.name, "quiet-hover")) {
|
|
1635
|
+
// The quiet-surface knob (`WidgetStyle.quiet_hover`)
|
|
1636
|
+
// for image-forward content tiles: hover wash off,
|
|
1637
|
+
// press/selection fills, focus ring, cursor intent,
|
|
1638
|
+
// and hit testing untouched. Hit-target elements only
|
|
1639
|
+
// (interpreter and validator parity); applied to
|
|
1640
|
+
// `options.style`, so no flat option field backs it.
|
|
1641
|
+
comptime if (!markup.hitTargetElement(node.name)) fail(node, markup.quiet_hover_element_message);
|
|
1642
|
+
options.style.quiet_hover = evalExpr(node, entries, attribute.value, ui, model, scope).truthy();
|
|
1615
1643
|
} else if (comptime (colorStyleField(attribute.name) != null)) {
|
|
1616
1644
|
// Style token refs resolve entirely at comptime: a typo
|
|
1617
1645
|
// in a token name is a compile error.
|
|
@@ -1787,6 +1815,17 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1787
1815
|
options.on_resize = comptime (resizeConstructor(expression.tag) orelse fail(node, markup.on_resize_payload_message));
|
|
1788
1816
|
return;
|
|
1789
1817
|
}
|
|
1818
|
+
// The value-payload change event: a slider's `on-change` with a
|
|
1819
|
+
// bare tag naming a value-carrying arm dispatches the APPLIED
|
|
1820
|
+
// value through the `on_value` constructor (the `on-resize`
|
|
1821
|
+
// fraction mechanism) instead of a static Msg. Void arms keep
|
|
1822
|
+
// the static form below (interpreter parity).
|
|
1823
|
+
if (comptime (std.mem.eql(u8, event, "change") and std.mem.eql(u8, node.name, "slider") and expression.payload.len == 0)) {
|
|
1824
|
+
if (comptime valueConstructor(expression.tag)) |make| {
|
|
1825
|
+
options.on_value = make;
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1790
1829
|
const msg = constructMessage(node, expression, entries, ui, model, scope);
|
|
1791
1830
|
if (comptime std.mem.eql(u8, event, "press")) {
|
|
1792
1831
|
options.on_press = msg;
|
|
@@ -1827,6 +1866,12 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1827
1866
|
if (field.type == canvas.TextInputEvent and std.mem.eql(u8, field.name, tag)) {
|
|
1828
1867
|
return Ui.inputMsg(@field(std.meta.Tag(MsgT), field.name));
|
|
1829
1868
|
}
|
|
1869
|
+
// A declared mirror of the event union (transpiled
|
|
1870
|
+
// cores, where type identity cannot cross the emission
|
|
1871
|
+
// boundary): translated at dispatch, same handler shape.
|
|
1872
|
+
if (interpreter.declaredTextInputUnion(field.type) and std.mem.eql(u8, field.name, tag)) {
|
|
1873
|
+
return Ui.translatedInputMsg(@field(std.meta.Tag(MsgT), field.name), field.type);
|
|
1874
|
+
}
|
|
1830
1875
|
}
|
|
1831
1876
|
return null;
|
|
1832
1877
|
}
|
|
@@ -1839,6 +1884,13 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1839
1884
|
if (field.type == canvas.ScrollState and std.mem.eql(u8, field.name, tag)) {
|
|
1840
1885
|
return Ui.scrollMsg(@field(std.meta.Tag(MsgT), field.name));
|
|
1841
1886
|
}
|
|
1887
|
+
// A declared mirror of the scroll-state record
|
|
1888
|
+
// (transpiled cores, where type identity cannot cross
|
|
1889
|
+
// the emission boundary): translated at dispatch, same
|
|
1890
|
+
// handler shape.
|
|
1891
|
+
if (interpreter.declaredScrollStateRecord(field.type) and std.mem.eql(u8, field.name, tag)) {
|
|
1892
|
+
return Ui.translatedScrollMsg(@field(std.meta.Tag(MsgT), field.name), field.type);
|
|
1893
|
+
}
|
|
1842
1894
|
}
|
|
1843
1895
|
return null;
|
|
1844
1896
|
}
|
|
@@ -1851,6 +1903,32 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
1851
1903
|
if (field.type == f32 and std.mem.eql(u8, field.name, tag)) {
|
|
1852
1904
|
return Ui.valueMsg(@field(std.meta.Tag(MsgT), field.name));
|
|
1853
1905
|
}
|
|
1906
|
+
// A declared one-number float arm (transpiled cores):
|
|
1907
|
+
// the fraction widens exactly at dispatch. Integer
|
|
1908
|
+
// arms stay excluded — a 0..1 fraction rounded into
|
|
1909
|
+
// an integer would be silently useless data.
|
|
1910
|
+
if (field.type == f64 and std.mem.eql(u8, field.name, tag)) {
|
|
1911
|
+
return Ui.translatedValueMsg(@field(std.meta.Tag(MsgT), field.name), field.type);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
return null;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
/// The slider `on-change` value form: an arm carrying the applied
|
|
1919
|
+
/// 0..1 fraction as `f32` (the canvas-native shape) or the
|
|
1920
|
+
/// transpiled one-number float arm (`f64`, widened exactly).
|
|
1921
|
+
/// Interpreter parity.
|
|
1922
|
+
fn valueConstructor(comptime tag: []const u8) ?Ui.ValueMsgFn {
|
|
1923
|
+
comptime {
|
|
1924
|
+
@setEvalBranchQuota(10_000);
|
|
1925
|
+
for (@typeInfo(MsgT).@"union".fields) |field| {
|
|
1926
|
+
const class = interpreter.valueArmClass(field.type) orelse continue;
|
|
1927
|
+
if (!std.mem.eql(u8, field.name, tag)) continue;
|
|
1928
|
+
return switch (class) {
|
|
1929
|
+
.identity => Ui.valueMsg(@field(std.meta.Tag(MsgT), field.name)),
|
|
1930
|
+
.float => Ui.translatedValueMsg(@field(std.meta.Tag(MsgT), field.name), field.type),
|
|
1931
|
+
};
|
|
1854
1932
|
}
|
|
1855
1933
|
return null;
|
|
1856
1934
|
}
|
|
@@ -2159,16 +2237,20 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2159
2237
|
/// and (when `allow_arena`) arena-taking scalar methods — or null
|
|
2160
2238
|
/// when the path names nothing `valueOf` can represent (which is
|
|
2161
2239
|
/// exactly when the interpreter fails).
|
|
2162
|
-
fn OnType(comptime
|
|
2240
|
+
fn OnType(comptime OuterT: type, comptime path: []const u8, comptime allow_arena: bool) ?type {
|
|
2163
2241
|
comptime {
|
|
2164
2242
|
@setEvalBranchQuota(10_000);
|
|
2243
|
+
// Single-item const pointers are transparent
|
|
2244
|
+
// (`reflect.Pointee`): a `*const Row` loop item or shared
|
|
2245
|
+
// model node resolves like the struct it points at.
|
|
2246
|
+
const T = interpreter.Pointee(OuterT);
|
|
2165
2247
|
if (@typeInfo(T) != .@"struct") return null;
|
|
2166
2248
|
const head = interpreter.pathHead(path);
|
|
2167
2249
|
const tail_opt = interpreter.pathTail(path);
|
|
2168
2250
|
for (@typeInfo(T).@"struct".fields) |field| {
|
|
2169
2251
|
if (!std.mem.eql(u8, field.name, head)) continue;
|
|
2170
2252
|
if (tail_opt) |tail| {
|
|
2171
|
-
if (@typeInfo(field.type) != .@"struct") return null;
|
|
2253
|
+
if (@typeInfo(interpreter.Pointee(field.type)) != .@"struct") return null;
|
|
2172
2254
|
return OnType(field.type, tail, allow_arena);
|
|
2173
2255
|
}
|
|
2174
2256
|
if (!supportedValue(field.type)) return null;
|
|
@@ -2202,6 +2284,14 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
2202
2284
|
/// to member access, method leaves to a direct call (arena-taking
|
|
2203
2285
|
/// leaves receive the build arena).
|
|
2204
2286
|
fn valueOn(comptime T: type, comptime path: []const u8, ptr: *const T, arena: std.mem.Allocator) (OnType(T, path, true).?) {
|
|
2287
|
+
// Mirror OnType's `reflect.Pointee` transparency: a resolved
|
|
2288
|
+
// path through a single-item const pointer dereferences it and
|
|
2289
|
+
// continues on the struct it shares (OnType already proved the
|
|
2290
|
+
// pointer shape, so only const single-item pointers reach this
|
|
2291
|
+
// branch).
|
|
2292
|
+
if (comptime (@typeInfo(T) == .pointer and @typeInfo(T).pointer.size == .one)) {
|
|
2293
|
+
return valueOn(@typeInfo(T).pointer.child, path, ptr.*, arena);
|
|
2294
|
+
}
|
|
2205
2295
|
const head = comptime interpreter.pathHead(path);
|
|
2206
2296
|
if (comptime (interpreter.pathTail(path) != null)) {
|
|
2207
2297
|
const tail = comptime interpreter.pathTail(path).?;
|
|
@@ -1502,6 +1502,35 @@ test "compiled charts match the interpreter and the hand-written Ui.chart tree"
|
|
|
1502
1502
|
try testing.expectEqual(canvas.WidgetKind.chart, compiled_chart.kind);
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
|
+
const ChartF64Interpreter = markup_view.MarkupView(fixture.ChartF64Model, fixture.ChartMsg);
|
|
1506
|
+
const ChartF64Compiled = canvas.CompiledMarkupView(fixture.ChartF64Model, fixture.ChartMsg, fixture.chart_f64_markup_source);
|
|
1507
|
+
|
|
1508
|
+
test "compiled charts bind f64 series (the transpiled-core float class) identically to the interpreter" {
|
|
1509
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1510
|
+
defer arena_state.deinit();
|
|
1511
|
+
const arena = arena_state.allocator();
|
|
1512
|
+
|
|
1513
|
+
const model = fixture.ChartF64Model{};
|
|
1514
|
+
|
|
1515
|
+
var view = try ChartF64Interpreter.init(arena, fixture.chart_f64_markup_source);
|
|
1516
|
+
var interpreted_ui = ChartUi.init(arena);
|
|
1517
|
+
const interpreted = try interpreted_ui.finalize(try view.build(&interpreted_ui, &model));
|
|
1518
|
+
var compiled_ui = ChartUi.init(arena);
|
|
1519
|
+
const compiled = try compiled_ui.finalize(ChartF64Compiled.build(&compiled_ui, &model));
|
|
1520
|
+
|
|
1521
|
+
try expectSameTree(fixture.ChartMsg, interpreted, compiled);
|
|
1522
|
+
const interpreted_chart = firstChartWidget(interpreted.root).?;
|
|
1523
|
+
const compiled_chart = firstChartWidget(compiled.root).?;
|
|
1524
|
+
try expectSameChartData(interpreted_chart.chart, compiled_chart.chart);
|
|
1525
|
+
|
|
1526
|
+
// The narrowing itself: f64 model samples land as exact f32 casts,
|
|
1527
|
+
// NaN gaps preserved, in BOTH engines (field and arena-fn sources).
|
|
1528
|
+
try testing.expectEqual(@as(f32, 0.25), compiled_chart.chart.series[0].values[0]);
|
|
1529
|
+
try testing.expect(std.math.isNan(compiled_chart.chart.series[0].values[1]));
|
|
1530
|
+
try testing.expectEqual(@as(f32, 0.125), compiled_chart.chart.series[1].values[0]);
|
|
1531
|
+
try testing.expectEqual(@as(f32, 0.5), compiled_chart.chart.series[1].values[3]);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1505
1534
|
// ---------------------------------------------- input-group fixture parity
|
|
1506
1535
|
|
|
1507
1536
|
const ComposerUi = fixture.ComposerUi;
|
|
@@ -1667,3 +1696,249 @@ test "compiled reactions lower onto the bubble's chrome-text channel exactly lik
|
|
|
1667
1696
|
try testing.expectEqual(canvas.TextAlign.start, sent.text_alignment);
|
|
1668
1697
|
try testing.expectEqual(@as(usize, 0), compiled.root.children[2].text.len);
|
|
1669
1698
|
}
|
|
1699
|
+
|
|
1700
|
+
// ------------------------------------------- committed-model (pointer) shape
|
|
1701
|
+
|
|
1702
|
+
const Track = struct {
|
|
1703
|
+
id: i64,
|
|
1704
|
+
title: []const u8,
|
|
1705
|
+
plays: f64,
|
|
1706
|
+
starred: bool,
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
const LibraryMeta = struct {
|
|
1710
|
+
name: []const u8,
|
|
1711
|
+
track_total: i64,
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1714
|
+
const LibraryMsg = union(enum) {
|
|
1715
|
+
open_track: i64,
|
|
1716
|
+
star_track: i64,
|
|
1717
|
+
refresh,
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
/// The committed-model shape transpiled cores emit: record arrays are
|
|
1721
|
+
/// slices of shared `*const` nodes and nested records are `*const`
|
|
1722
|
+
/// fields. `reflect.Pointee` makes both bind exactly like their by-value
|
|
1723
|
+
/// counterparts.
|
|
1724
|
+
const LibraryModel = struct {
|
|
1725
|
+
meta: *const LibraryMeta,
|
|
1726
|
+
tracks: []const *const Track,
|
|
1727
|
+
selected: ?i64 = null,
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
const library_markup =
|
|
1731
|
+
\\<column gap="4">
|
|
1732
|
+
\\ <text>{meta.name} holds {meta.track_total}</text>
|
|
1733
|
+
\\ <if test="{selected}">
|
|
1734
|
+
\\ <text>picked</text>
|
|
1735
|
+
\\ </if>
|
|
1736
|
+
\\ <for each="tracks" as="t" key="id">
|
|
1737
|
+
\\ <row key="{t.id}" gap="2" cross="center">
|
|
1738
|
+
\\ <text grow="1">{t.title} ({t.plays})</text>
|
|
1739
|
+
\\ <if test="{t.starred}">
|
|
1740
|
+
\\ <badge>starred</badge>
|
|
1741
|
+
\\ </if>
|
|
1742
|
+
\\ <button size="sm" on-press="open_track:{t.id}">Open</button>
|
|
1743
|
+
\\ </row>
|
|
1744
|
+
\\ </for>
|
|
1745
|
+
\\ <else>
|
|
1746
|
+
\\ <text>empty library</text>
|
|
1747
|
+
\\ </else>
|
|
1748
|
+
\\</column>
|
|
1749
|
+
;
|
|
1750
|
+
|
|
1751
|
+
const LibraryUi = canvas.Ui(LibraryMsg);
|
|
1752
|
+
const LibraryInterpreter = markup_view.MarkupView(LibraryModel, LibraryMsg);
|
|
1753
|
+
const LibraryCompiled = canvas.CompiledMarkupView(LibraryModel, LibraryMsg, library_markup);
|
|
1754
|
+
|
|
1755
|
+
fn interpretLibrary(arena: std.mem.Allocator, model: *const LibraryModel) !LibraryUi.Tree {
|
|
1756
|
+
var view = try LibraryInterpreter.init(arena, library_markup);
|
|
1757
|
+
var ui = LibraryUi.init(arena);
|
|
1758
|
+
return ui.finalize(try view.build(&ui, model));
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
fn compileLibrary(arena: std.mem.Allocator, model: *const LibraryModel) !LibraryUi.Tree {
|
|
1762
|
+
var ui = LibraryUi.init(arena);
|
|
1763
|
+
return ui.finalize(LibraryCompiled.build(&ui, model));
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
test "compiled pointer-item lists and pointer-record paths match the interpreter" {
|
|
1767
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1768
|
+
defer arena_state.deinit();
|
|
1769
|
+
const arena = arena_state.allocator();
|
|
1770
|
+
|
|
1771
|
+
const meta = LibraryMeta{ .name = "field notes", .track_total = 2 };
|
|
1772
|
+
const first = Track{ .id = 7, .title = "one", .plays = 3.5, .starred = false };
|
|
1773
|
+
const second = Track{ .id = 9, .title = "two", .plays = 12, .starred = true };
|
|
1774
|
+
const tracks = [_]*const Track{ &first, &second };
|
|
1775
|
+
var model = LibraryModel{ .meta = &meta, .tracks = &tracks };
|
|
1776
|
+
|
|
1777
|
+
const interpreted = try interpretLibrary(arena, &model);
|
|
1778
|
+
const compiled = try compileLibrary(arena, &model);
|
|
1779
|
+
try expectSameTree(LibraryMsg, interpreted, compiled);
|
|
1780
|
+
try expectSameTexts(interpreted.root, compiled.root);
|
|
1781
|
+
|
|
1782
|
+
// Dotted paths through the `*const` record field interpolate its
|
|
1783
|
+
// fields; pointer items bind their struct's fields, floats included.
|
|
1784
|
+
try testing.expect(findText(compiled.root, "field notes holds 2") != null);
|
|
1785
|
+
try testing.expect(findText(compiled.root, "one (3.5)") != null);
|
|
1786
|
+
try testing.expect(findText(compiled.root, "two (12)") != null);
|
|
1787
|
+
try testing.expect(findText(compiled.root, "starred") != null);
|
|
1788
|
+
try testing.expect(findText(compiled.root, "picked") == null);
|
|
1789
|
+
try testing.expect(findText(compiled.root, "empty library") == null);
|
|
1790
|
+
|
|
1791
|
+
// Message payloads built from pointer items dispatch identically.
|
|
1792
|
+
const open_button = fixture.findByKind(compiled.root, .button).?;
|
|
1793
|
+
try testing.expectEqual(
|
|
1794
|
+
interpreted.msgForPointer(open_button.id, .up).?,
|
|
1795
|
+
compiled.msgForPointer(open_button.id, .up).?,
|
|
1796
|
+
);
|
|
1797
|
+
try testing.expectEqual(@as(i64, 7), compiled.msgForPointer(open_button.id, .up).?.open_track);
|
|
1798
|
+
|
|
1799
|
+
// The optional scalar flips the gate at runtime, like every optional.
|
|
1800
|
+
model.selected = 9;
|
|
1801
|
+
const picked = try compileLibrary(arena, &model);
|
|
1802
|
+
try testing.expect(findText(picked.root, "picked") != null);
|
|
1803
|
+
|
|
1804
|
+
// An empty pointer list renders the for-else branch.
|
|
1805
|
+
model.tracks = &.{};
|
|
1806
|
+
const emptied_interpreted = try interpretLibrary(arena, &model);
|
|
1807
|
+
const emptied_compiled = try compileLibrary(arena, &model);
|
|
1808
|
+
try expectSameTree(LibraryMsg, emptied_interpreted, emptied_compiled);
|
|
1809
|
+
try testing.expect(findText(emptied_compiled.root, "empty library") != null);
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
test "the compiled engine binds on-input to a declared mirror union in parity with the interpreter" {
|
|
1813
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1814
|
+
defer arena_state.deinit();
|
|
1815
|
+
const arena = arena_state.allocator();
|
|
1816
|
+
|
|
1817
|
+
const source =
|
|
1818
|
+
\\<column>
|
|
1819
|
+
\\ <text-field text="{draft}" label="Draft" on-input="edit" on-submit="submit" />
|
|
1820
|
+
\\</column>
|
|
1821
|
+
;
|
|
1822
|
+
const model = fixture.MirrorModel{ .draft = "hi" };
|
|
1823
|
+
|
|
1824
|
+
const Compiled = canvas.CompiledMarkupView(fixture.MirrorModel, fixture.MirrorMsg, source);
|
|
1825
|
+
var compiled_ui = canvas.Ui(fixture.MirrorMsg).init(arena);
|
|
1826
|
+
const compiled = try compiled_ui.finalize(Compiled.build(&compiled_ui, &model));
|
|
1827
|
+
|
|
1828
|
+
var view = try markup_view.MarkupView(fixture.MirrorModel, fixture.MirrorMsg).init(arena, source);
|
|
1829
|
+
var interpreter_ui = canvas.Ui(fixture.MirrorMsg).init(arena);
|
|
1830
|
+
const interpreted = try interpreter_ui.finalize(try view.build(&interpreter_ui, &model));
|
|
1831
|
+
|
|
1832
|
+
const field = fixture.findByKind(compiled.root, .text_field).?;
|
|
1833
|
+
try testing.expectEqual(fixture.findByKind(interpreted.root, .text_field).?.id, field.id);
|
|
1834
|
+
|
|
1835
|
+
// Both engines translate the runtime event into the DECLARED union.
|
|
1836
|
+
const compiled_insert = compiled.msgForTextEdit(field.id, .{ .insert_text = "abc" }).?;
|
|
1837
|
+
const interpreted_insert = interpreted.msgForTextEdit(field.id, .{ .insert_text = "abc" }).?;
|
|
1838
|
+
try testing.expectEqualStrings("abc", compiled_insert.edit.insert_text);
|
|
1839
|
+
try testing.expectEqualStrings("abc", interpreted_insert.edit.insert_text);
|
|
1840
|
+
const compiled_move = compiled.msgForTextEdit(field.id, .{ .move_caret = .{ .direction = .end, .extend = false } }).?;
|
|
1841
|
+
try testing.expectEqual(fixture.MirrorCaretDirection.end, compiled_move.edit.move_caret.direction);
|
|
1842
|
+
try testing.expectEqual(
|
|
1843
|
+
interpreted.msgForTextEdit(field.id, .delete_backward).?,
|
|
1844
|
+
compiled.msgForTextEdit(field.id, .delete_backward).?,
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
// ---------------------------- declared scroll-state + value arms (parity)
|
|
1849
|
+
|
|
1850
|
+
test "compiled on-scroll binds a declared scroll-state mirror identically to the interpreter" {
|
|
1851
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1852
|
+
defer arena_state.deinit();
|
|
1853
|
+
const arena = arena_state.allocator();
|
|
1854
|
+
|
|
1855
|
+
const source =
|
|
1856
|
+
\\<scroll value="{scroll_top}" on-scroll="library_scrolled">
|
|
1857
|
+
\\ <text>rows</text>
|
|
1858
|
+
\\</scroll>
|
|
1859
|
+
;
|
|
1860
|
+
const model = fixture.MirrorControlsModel{};
|
|
1861
|
+
|
|
1862
|
+
const Compiled = canvas.CompiledMarkupView(fixture.MirrorControlsModel, fixture.MirrorControlsMsg, source);
|
|
1863
|
+
var compiled_ui = canvas.Ui(fixture.MirrorControlsMsg).init(arena);
|
|
1864
|
+
const compiled = try compiled_ui.finalize(Compiled.build(&compiled_ui, &model));
|
|
1865
|
+
|
|
1866
|
+
var view = try markup_view.MarkupView(fixture.MirrorControlsModel, fixture.MirrorControlsMsg).init(arena, source);
|
|
1867
|
+
var interpreter_ui = canvas.Ui(fixture.MirrorControlsMsg).init(arena);
|
|
1868
|
+
const interpreted = try interpreter_ui.finalize(try view.build(&interpreter_ui, &model));
|
|
1869
|
+
try expectSameTree(fixture.MirrorControlsMsg, interpreted, compiled);
|
|
1870
|
+
|
|
1871
|
+
// Both engines translate the runtime state into the DECLARED record:
|
|
1872
|
+
// float fields widen exactly, integer-classed fields round.
|
|
1873
|
+
const region = fixture.findByKind(compiled.root, .scroll_view).?;
|
|
1874
|
+
const state = canvas.ScrollState{ .offset = 41.5, .velocity = -3.25, .viewport_extent = 480.4, .content_extent = 2000.6 };
|
|
1875
|
+
const compiled_msg = compiled.msgForScroll(region.id, state).?;
|
|
1876
|
+
try testing.expectEqual(@as(f64, 41.5), compiled_msg.library_scrolled.offset);
|
|
1877
|
+
try testing.expectEqual(@as(i64, 480), compiled_msg.library_scrolled.viewportExtent);
|
|
1878
|
+
try testing.expectEqual(@as(i64, 2001), compiled_msg.library_scrolled.contentExtent);
|
|
1879
|
+
try testing.expectEqual(
|
|
1880
|
+
interpreted.msgForScroll(region.id, state).?,
|
|
1881
|
+
compiled.msgForScroll(region.id, state).?,
|
|
1882
|
+
);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
test "compiled slider on-change value arms match the interpreter" {
|
|
1886
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1887
|
+
defer arena_state.deinit();
|
|
1888
|
+
const arena = arena_state.allocator();
|
|
1889
|
+
|
|
1890
|
+
const source =
|
|
1891
|
+
\\<column>
|
|
1892
|
+
\\ <slider value="{seek_fraction}" label="Seek" on-change="scrubbed" />
|
|
1893
|
+
\\ <slider value="{volume}" label="Volume" on-change="set_volume" />
|
|
1894
|
+
\\ <slider value="{volume}" label="Nudge" on-change="nudged" />
|
|
1895
|
+
\\</column>
|
|
1896
|
+
;
|
|
1897
|
+
const model = fixture.MirrorControlsModel{};
|
|
1898
|
+
|
|
1899
|
+
const Compiled = canvas.CompiledMarkupView(fixture.MirrorControlsModel, fixture.MirrorControlsMsg, source);
|
|
1900
|
+
var compiled_ui = canvas.Ui(fixture.MirrorControlsMsg).init(arena);
|
|
1901
|
+
const compiled = try compiled_ui.finalize(Compiled.build(&compiled_ui, &model));
|
|
1902
|
+
|
|
1903
|
+
var view = try markup_view.MarkupView(fixture.MirrorControlsModel, fixture.MirrorControlsMsg).init(arena, source);
|
|
1904
|
+
var interpreter_ui = canvas.Ui(fixture.MirrorControlsMsg).init(arena);
|
|
1905
|
+
const interpreted = try interpreter_ui.finalize(try view.build(&interpreter_ui, &model));
|
|
1906
|
+
try expectSameTree(fixture.MirrorControlsMsg, interpreted, compiled);
|
|
1907
|
+
|
|
1908
|
+
const seek = fixture.findByKind(compiled.root, .slider).?;
|
|
1909
|
+
// The transpiled f64 arm carries the applied fraction widened exactly,
|
|
1910
|
+
// through both engines' handler tables.
|
|
1911
|
+
try testing.expectEqual(@as(f64, 0.25), compiled.msgForChange(seek.id, 0.25).?.scrubbed);
|
|
1912
|
+
try testing.expectEqual(
|
|
1913
|
+
interpreted.msgForChange(seek.id, 0.25).?,
|
|
1914
|
+
compiled.msgForChange(seek.id, 0.25).?,
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
test "compiled split on-resize binds a declared float arm identically to the interpreter" {
|
|
1919
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1920
|
+
defer arena_state.deinit();
|
|
1921
|
+
const arena = arena_state.allocator();
|
|
1922
|
+
|
|
1923
|
+
const source =
|
|
1924
|
+
\\<split value="{seek_fraction}" on-resize="scrubbed">
|
|
1925
|
+
\\ <column><text>left</text></column>
|
|
1926
|
+
\\ <column><text>right</text></column>
|
|
1927
|
+
\\</split>
|
|
1928
|
+
;
|
|
1929
|
+
const model = fixture.MirrorControlsModel{};
|
|
1930
|
+
|
|
1931
|
+
const Compiled = canvas.CompiledMarkupView(fixture.MirrorControlsModel, fixture.MirrorControlsMsg, source);
|
|
1932
|
+
var compiled_ui = canvas.Ui(fixture.MirrorControlsMsg).init(arena);
|
|
1933
|
+
const compiled = try compiled_ui.finalize(Compiled.build(&compiled_ui, &model));
|
|
1934
|
+
|
|
1935
|
+
var view = try markup_view.MarkupView(fixture.MirrorControlsModel, fixture.MirrorControlsMsg).init(arena, source);
|
|
1936
|
+
var interpreter_ui = canvas.Ui(fixture.MirrorControlsMsg).init(arena);
|
|
1937
|
+
const interpreted = try interpreter_ui.finalize(try view.build(&interpreter_ui, &model));
|
|
1938
|
+
try expectSameTree(fixture.MirrorControlsMsg, interpreted, compiled);
|
|
1939
|
+
|
|
1940
|
+
try testing.expectEqual(
|
|
1941
|
+
interpreted.msgForResize(interpreted.root.id, 0.25).?,
|
|
1942
|
+
compiled.msgForResize(compiled.root.id, 0.25).?,
|
|
1943
|
+
);
|
|
1944
|
+
}
|
|
@@ -191,6 +191,10 @@ pub fn describe(comptime Model: type, comptime Msg: type, comptime specials: Spe
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
fn describeGroup(comptime T: type) Group {
|
|
194
|
+
return describeGroupSeen(T, &.{});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
fn describeGroupSeen(comptime T: type, comptime seen: []const type) Group {
|
|
194
198
|
comptime {
|
|
195
199
|
var scalars: []const Scalar = &.{};
|
|
196
200
|
var groups: []const NamedGroup = &.{};
|
|
@@ -203,11 +207,17 @@ fn describeGroup(comptime T: type) Group {
|
|
|
203
207
|
}};
|
|
204
208
|
continue;
|
|
205
209
|
}
|
|
206
|
-
|
|
210
|
+
// `reflect.Pointee` transparency: a `*const Row` field
|
|
211
|
+
// traverses like the struct it shares. Pointer models can
|
|
212
|
+
// cycle (unlike by-value structs), so already-described
|
|
213
|
+
// types stop the walk — the engines resolve such paths
|
|
214
|
+
// segment by segment and never recurse into the type graph.
|
|
215
|
+
const Nested = reflect.Pointee(field.type);
|
|
216
|
+
if (@typeInfo(Nested) == .@"struct" and !typeListed(Nested, seen ++ &[_]type{T})) {
|
|
207
217
|
groups = groups ++ &[_]NamedGroup{.{
|
|
208
218
|
.name = field.name,
|
|
209
|
-
.type_name = @typeName(
|
|
210
|
-
.group =
|
|
219
|
+
.type_name = @typeName(Nested),
|
|
220
|
+
.group = describeGroupSeen(Nested, seen ++ &[_]type{T}),
|
|
211
221
|
}};
|
|
212
222
|
}
|
|
213
223
|
}
|
|
@@ -238,14 +248,24 @@ fn describeGroup(comptime T: type) Group {
|
|
|
238
248
|
}
|
|
239
249
|
}
|
|
240
250
|
|
|
251
|
+
fn typeListed(comptime T: type, comptime seen: []const type) bool {
|
|
252
|
+
for (seen) |S| {
|
|
253
|
+
if (S == T) return true;
|
|
254
|
+
}
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
|
|
241
258
|
fn describeItem(comptime Item: type) Iterable {
|
|
242
259
|
comptime {
|
|
260
|
+
// `reflect.Pointee` transparency: `[]const *const Row` iterates
|
|
261
|
+
// items that bind like Row itself.
|
|
262
|
+
const Bare = reflect.Pointee(Item);
|
|
243
263
|
return .{
|
|
244
264
|
.name = "",
|
|
245
|
-
.item_type = @typeName(
|
|
265
|
+
.item_type = @typeName(Bare),
|
|
246
266
|
.item_kind = if (reflect.supportedScalar(Item)) reflect.scalarKindOf(Item) else null,
|
|
247
267
|
.item_scalar = reflect.supportedScalar(Item),
|
|
248
|
-
.item = if (@typeInfo(
|
|
268
|
+
.item = if (@typeInfo(Bare) == .@"struct") describeGroup(Bare) else .{},
|
|
249
269
|
};
|
|
250
270
|
}
|
|
251
271
|
}
|
|
@@ -299,7 +319,16 @@ fn describeMsgs(comptime Msg: type, comptime specials: Specials) []const MsgTag
|
|
|
299
319
|
fn payloadClassOf(comptime T: type, comptime specials: Specials) PayloadClass {
|
|
300
320
|
if (T == void) return .none;
|
|
301
321
|
if (T == specials.TextInputEvent) return .text_input;
|
|
322
|
+
// A declared mirror of the text-input event union (transpiled cores,
|
|
323
|
+
// where type identity cannot cross the emission boundary) binds
|
|
324
|
+
// through on-input exactly like the canvas type — same resolution as
|
|
325
|
+
// both engines' inputConstructor.
|
|
326
|
+
if (reflect.declaredTextInputUnion(T)) return .text_input;
|
|
302
327
|
if (T == specials.ScrollState) return .scroll_state;
|
|
328
|
+
// A declared mirror of the scroll-state record (transpiled cores) binds
|
|
329
|
+
// through on-scroll exactly like the canvas type — same resolution as
|
|
330
|
+
// both engines' scrollConstructor.
|
|
331
|
+
if (reflect.declaredScrollStateRecord(T)) return .scroll_state;
|
|
303
332
|
return switch (@typeInfo(T)) {
|
|
304
333
|
.int => .integer,
|
|
305
334
|
.float => .float,
|
|
@@ -831,12 +860,29 @@ const Checker = struct {
|
|
|
831
860
|
return;
|
|
832
861
|
}
|
|
833
862
|
if (std.mem.eql(u8, event, "resize")) {
|
|
863
|
+
// f32 is the canvas-native arm; f64 the transpiled one-number
|
|
864
|
+
// float arm (engine parity — integer arms stay excluded, a
|
|
865
|
+
// fraction rounded into an integer would be useless data).
|
|
834
866
|
const found = tag orelse return self.failAttr(node, attribute, markup.on_resize_payload_message);
|
|
835
|
-
|
|
867
|
+
const resize_ok = found.payload == .float and
|
|
868
|
+
(std.mem.eql(u8, found.payload_type, "f32") or std.mem.eql(u8, found.payload_type, "f64"));
|
|
869
|
+
if (!resize_ok) {
|
|
836
870
|
return self.failAttr(node, attribute, markup.on_resize_payload_message);
|
|
837
871
|
}
|
|
838
872
|
return;
|
|
839
873
|
}
|
|
874
|
+
// The value-payload change event (engine parity): a slider's
|
|
875
|
+
// on-change with a bare tag naming a value-carrying arm — f32 (the
|
|
876
|
+
// canvas-native shape) or the transpiled one-number float arm
|
|
877
|
+
// (f64) — dispatches the applied 0..1 fraction. Void arms fall
|
|
878
|
+
// through to the static form below.
|
|
879
|
+
if (std.mem.eql(u8, event, "change") and std.mem.eql(u8, node.name, "slider") and expression.payload.len == 0) {
|
|
880
|
+
if (tag) |found| {
|
|
881
|
+
const value_arm = found.payload == .float and
|
|
882
|
+
(std.mem.eql(u8, found.payload_type, "f32") or std.mem.eql(u8, found.payload_type, "f64"));
|
|
883
|
+
if (value_arm) return;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
840
886
|
const found = tag orelse return self.failNamed(node, unknown_tag_message, expression.tag, .{ .msgs = self.contract });
|
|
841
887
|
if (found.payload == .none) {
|
|
842
888
|
if (expression.payload.len > 0) return self.failAttr(node, attribute, no_payload_message);
|
|
@@ -1258,7 +1304,7 @@ const Checker = struct {
|
|
|
1258
1304
|
|
|
1259
1305
|
/// `<chart>` and its `<series>` children: options resolve like the
|
|
1260
1306
|
/// engines' (numbers, whole numbers, truthy flags, text), and every
|
|
1261
|
-
/// series `values` binding must name an f32 iterable — a wrong item
|
|
1307
|
+
/// series `values` binding must name an f32 or f64 iterable — a wrong item
|
|
1262
1308
|
/// type fails with the model type named, so the fix is visible from
|
|
1263
1309
|
/// the finding.
|
|
1264
1310
|
fn checkChart(self: *Checker, node: markup.MarkupNode) CheckErr!void {
|
|
@@ -1321,7 +1367,9 @@ const Checker = struct {
|
|
|
1321
1367
|
const expression = markup.parseAttrExpression(attribute.value) orelse continue;
|
|
1322
1368
|
if (expression != .binding) continue;
|
|
1323
1369
|
const item = try self.resolveIterable(node, expression.binding, markup.series_values_message);
|
|
1324
|
-
|
|
1370
|
+
// f32 is the canvas-native series element; f64 the
|
|
1371
|
+
// transpiled-core one (both engines narrow it per sample).
|
|
1372
|
+
if (!std.mem.eql(u8, item.type_name, "f32") and !std.mem.eql(u8, item.type_name, "f64")) {
|
|
1325
1373
|
const message = std.fmt.allocPrint(self.arena, "{s} (\"{s}\" iterates {s})", .{
|
|
1326
1374
|
markup.series_values_message, expression.binding, item.type_name,
|
|
1327
1375
|
}) catch return error.OutOfMemory;
|
|
@@ -1520,11 +1568,16 @@ fn editDistance(a: []const u8, b: []const u8) ?usize {
|
|
|
1520
1568
|
|
|
1521
1569
|
// -------------------------------------------------------------- artifact
|
|
1522
1570
|
|
|
1523
|
-
/// Hash the app's
|
|
1524
|
-
/// path-sorted, path and contents both mixed in.
|
|
1525
|
-
///
|
|
1526
|
-
///
|
|
1527
|
-
///
|
|
1571
|
+
/// Hash the app's core sources: every `.zig` and `.ts` file under
|
|
1572
|
+
/// `root_path`, path-sorted, path and contents both mixed in. TypeScript
|
|
1573
|
+
/// cores are hashed too because on that track the Model/Msg truth lives
|
|
1574
|
+
/// in `src/core.ts` — a core edit changes no `.zig` file, and a contract
|
|
1575
|
+
/// that stays "fresh" through it reports phantom unknown-tag and
|
|
1576
|
+
/// unknown-field errors against the user's new state. The emit step
|
|
1577
|
+
/// stamps this into the artifact; `native check` recomputes it and
|
|
1578
|
+
/// DEGRADES to structural checking on any mismatch — a stale contract
|
|
1579
|
+
/// can hide new fields or resurrect deleted ones, so it must never pass
|
|
1580
|
+
/// silently.
|
|
1528
1581
|
pub fn hashSourceDir(allocator: std.mem.Allocator, io: std.Io, root_path: []const u8) !u64 {
|
|
1529
1582
|
return hashSourceDirAt(allocator, io, std.Io.Dir.cwd(), root_path);
|
|
1530
1583
|
}
|
|
@@ -1540,7 +1593,8 @@ pub fn hashSourceDirAt(allocator: std.mem.Allocator, io: std.Io, base: std.Io.Di
|
|
|
1540
1593
|
var walker = try root.walk(allocator);
|
|
1541
1594
|
defer walker.deinit();
|
|
1542
1595
|
while (try walker.next(io)) |entry| {
|
|
1543
|
-
if (entry.kind
|
|
1596
|
+
if (entry.kind != .file) continue;
|
|
1597
|
+
if (std.mem.endsWith(u8, entry.path, ".zig") or std.mem.endsWith(u8, entry.path, ".ts")) {
|
|
1544
1598
|
try paths.append(allocator, try allocator.dupe(u8, entry.path));
|
|
1545
1599
|
}
|
|
1546
1600
|
}
|