@native-sdk/cli 0.7.2 → 0.8.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.
Files changed (61) hide show
  1. package/build/app.zig +265 -65
  2. package/build/ts_run.mjs +6 -8
  3. package/build.zig +292 -349
  4. package/package.json +13 -11
  5. package/packages/core/compile-surface/core.ts +559 -0
  6. package/packages/core/package-lock.json +375 -12
  7. package/packages/core/package.json +9 -6
  8. package/packages/core/scripts/compiler_typecheck.mjs +58 -0
  9. package/packages/core/scripts/gen_case_tables.mjs +130 -0
  10. package/packages/core/scripts/gen_declarations.mjs +97 -0
  11. package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
  12. package/packages/core/scripts/stage_external_core.mjs +148 -0
  13. package/packages/core/sdk/core.d.ts +363 -0
  14. package/packages/core/sdk/events.d.ts +65 -0
  15. package/packages/core/sdk/text.d.ts +51 -0
  16. package/packages/core/src/checker.ts +3 -3
  17. package/packages/core/src/cli.ts +40 -38
  18. package/packages/core/src/contract.ts +749 -0
  19. package/packages/core/src/devhost.ts +4 -3
  20. package/packages/core/src/diagnostics.ts +5 -7
  21. package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
  22. package/packages/core/src/infer.ts +1 -1
  23. package/packages/core/src/typed_ast.ts +16 -15
  24. package/packages/core/src/wyhash.ts +79 -0
  25. package/skill-data/native-ui/SKILL.md +3 -2
  26. package/skill-data/ts-core/SKILL.md +29 -29
  27. package/src/platform/macos/appkit_host.h +4 -4
  28. package/src/platform/macos/appkit_host.m +24 -4
  29. package/src/platform/macos/cef_host.mm +22 -6
  30. package/src/platform/macos/root.zig +2 -2
  31. package/src/primitives/canvas/markdown.zig +2010 -57
  32. package/src/primitives/canvas/markdown_hostile_tests.zig +40 -0
  33. package/src/primitives/canvas/markdown_tests.zig +778 -3
  34. package/src/primitives/canvas/ui_markup.zig +9 -1
  35. package/src/primitives/canvas/ui_markup_compiled.zig +29 -0
  36. package/src/primitives/canvas/ui_markup_contract.zig +11 -0
  37. package/src/primitives/canvas/ui_markup_view.zig +20 -0
  38. package/src/primitives/canvas/ui_markup_view_tests.zig +13 -1
  39. package/src/primitives/canvas/ui_schema.zig +3 -0
  40. package/src/primitives/canvas/ui_schema_tests.zig +4 -3
  41. package/src/primitives/canvas/widget_layout.zig +26 -3
  42. package/src/primitives/canvas/widget_metrics.zig +21 -3
  43. package/src/primitives/canvas/widget_render.zig +6 -1
  44. package/src/runtime/effects.zig +9 -0
  45. package/src/runtime/effects_fetch_tests.zig +21 -0
  46. package/src/runtime/ts_core_host.zig +38 -38
  47. package/src/runtime/ts_ui_app.zig +12 -12
  48. package/src/tooling/manifest.zig +32 -0
  49. package/src/tooling/raw_manifest.zig +4 -0
  50. package/src/tooling/templates.zig +25 -20
  51. package/src/tooling/ts_core.zig +55 -34
  52. package/src/tooling/verbs.zig +1 -1
  53. package/tools/corewire/core_abi.zig +169 -0
  54. package/tools/corewire/emit.zig +2418 -0
  55. package/tools/corewire/emit_facade.zig +3984 -0
  56. package/tools/corewire/emit_profile.zig +501 -0
  57. package/tools/corewire/main.zig +561 -0
  58. package/tools/corewire/shim_rt.zig +632 -0
  59. package/tools/corewire/sidecar.zig +2507 -0
  60. package/packages/core/rt/rt.zig +0 -1986
  61. package/packages/core/src/emitter.ts +0 -11898
@@ -1861,11 +1861,12 @@ pub const arena_scalar_equality_message = "arena-computed bindings cannot be com
1861
1861
  pub const binding_text_buffer_message = "this binding names a TextBuffer field - the buffer is the edit model, not the text; bind a pub fn returning its text (pub fn draft(model: *const Model) []const u8 { return model.draft_buffer.text(); })";
1862
1862
  pub const markdown_source_message = "markdown requires a source attribute with one {binding} naming the markdown text (a []const u8 field or fn - arena fns work)";
1863
1863
  pub const markdown_children_message = "markdown takes no children or text content - the source binding provides the markdown";
1864
- pub const markdown_attr_message = "unknown attribute for markdown - it takes source, on-link, on-details, details-expanded, and issue-link-base";
1864
+ pub const markdown_attr_message = "unknown attribute for markdown - it takes source, on-link, on-details, details-expanded, issue-link-base, and images";
1865
1865
  pub const markdown_issue_link_base_message = "issue-link-base takes a literal URL prefix or one {binding} producing it - '#123' refs become links to base ++ number (like ghissue:// or https://github.com/owner/repo/issues/)";
1866
1866
  pub const markdown_on_link_message = "on-link takes a bare Msg tag whose payload is the pressed link URL (a []const u8 variant, like open_url: []const u8)";
1867
1867
  pub const markdown_on_details_message = "on-details takes a bare Msg tag whose payload is the details block index (a usize variant, like toggle_details: usize)";
1868
1868
  pub const markdown_details_expanded_message = "details-expanded takes one {binding} naming a []const bool iterable (a model field, pub decl, or fn - the same sources for each accepts)";
1869
+ pub const markdown_images_message = "images takes one {binding} naming a []const canvas.markdown.ResolvedImage iterable (source, registered ImageId, width, and height); views never fetch image URLs implicitly";
1869
1870
  pub const code_source_message = "code requires a source attribute with one {binding} naming the source text (a []const u8 field or fn - arena fns work)";
1870
1871
  pub const code_children_message = "code takes no children or text content - the source binding provides the code";
1871
1872
  pub const code_attr_message = "unknown attribute for code - it takes source, language, editable, on-input, line-numbers, added-lines, removed-lines, wrap, width, height, min-width, grow, key, global-key, and label";
@@ -2208,6 +2209,13 @@ fn validateMarkdown(node: MarkupNode) ?MarkupErrorInfo {
2208
2209
  }
2209
2210
  continue;
2210
2211
  }
2212
+ if (std.mem.eql(u8, attribute.name, "images")) {
2213
+ const expression = parseAttrExpression(attribute.value);
2214
+ if (expression == null or expression.? != .binding) {
2215
+ return attrError(node, attribute, markdown_images_message);
2216
+ }
2217
+ continue;
2218
+ }
2211
2219
  if (std.mem.eql(u8, attribute.name, "issue-link-base")) {
2212
2220
  const expression = parseAttrExpression(attribute.value);
2213
2221
  if (expression == null or expression.? == .equals) {
@@ -738,6 +738,7 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
738
738
  if (std.mem.eql(u8, attribute.name, "on-details")) continue;
739
739
  if (std.mem.eql(u8, attribute.name, "details-expanded")) continue;
740
740
  if (std.mem.eql(u8, attribute.name, "issue-link-base")) continue;
741
+ if (std.mem.eql(u8, attribute.name, "images")) continue;
741
742
  fail(node, markup.markdown_attr_message);
742
743
  }
743
744
  }
@@ -763,6 +764,9 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
763
764
  if (comptime (node.attr("details-expanded") != null)) {
764
765
  options.details_expanded = detailsExpandedItems(node, entries, comptime node.attr("details-expanded").?, ui, model, scope);
765
766
  }
767
+ if (comptime (node.attr("images") != null)) {
768
+ options.images = markdownImageItems(node, entries, comptime node.attr("images").?, ui, model, scope);
769
+ }
766
770
  if (comptime (node.attr("issue-link-base") != null)) {
767
771
  const raw = comptime node.attr("issue-link-base").?;
768
772
  comptime {
@@ -945,6 +949,31 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
945
949
  return eachItems(info, ui, model);
946
950
  }
947
951
 
952
+ /// Comptime twin of the interpreter's registered-image iterable
953
+ /// binding. Scope slice arguments shadow model iterables.
954
+ fn markdownImageItems(comptime node: markup.MarkupNode, comptime entries: []const ScopeEntry, comptime raw: []const u8, ui: *Ui, model: *const ModelT, scope: anytype) []const canvas.markdown.ResolvedImage {
955
+ const path = comptime blk: {
956
+ const expression = markup.parseAttrExpression(raw) orelse fail(node, markup.markdown_images_message);
957
+ if (expression != .binding) fail(node, markup.markdown_images_message);
958
+ break :blk expression.binding;
959
+ };
960
+ const scope_index_opt = comptime scopeIndex(entries, path);
961
+ if (comptime (scope_index_opt != null)) {
962
+ const scope_index = comptime scope_index_opt.?;
963
+ comptime {
964
+ if (entries[scope_index].kind != .slice_arg or entries[scope_index].Item != canvas.markdown.ResolvedImage) {
965
+ fail(node, markup.markdown_images_message);
966
+ }
967
+ }
968
+ return scopePayload(entries, scope_index, scope);
969
+ }
970
+ const info = comptime (eachInfo(path) orelse fail(node, markup.markdown_images_message));
971
+ comptime {
972
+ if (info.Item != canvas.markdown.ResolvedImage) fail(node, markup.markdown_images_message);
973
+ }
974
+ return eachItems(info, ui, model);
975
+ }
976
+
948
977
  // ------------------------------------------------ stepper/timeline
949
978
 
950
979
  /// Comptime mirror of the interpreter's `buildStepper`: attrs and
@@ -1332,6 +1332,17 @@ const Checker = struct {
1332
1332
  }
1333
1333
  continue;
1334
1334
  }
1335
+ if (std.mem.eql(u8, attribute.name, "images")) {
1336
+ const expression = markup.parseAttrExpression(attribute.value) orelse continue;
1337
+ if (expression != .binding) continue;
1338
+ const item = try self.resolveIterable(node, expression.binding, markup.markdown_images_message);
1339
+ if (!std.mem.eql(u8, item.type_name, "ResolvedImage") and
1340
+ !std.mem.endsWith(u8, item.type_name, ".ResolvedImage"))
1341
+ {
1342
+ return self.failAttr(node, attribute, markup.markdown_images_message);
1343
+ }
1344
+ continue;
1345
+ }
1335
1346
  if (std.mem.eql(u8, attribute.name, "issue-link-base")) {
1336
1347
  const kind = try self.attrKind(node, attribute, attribute.value);
1337
1348
  try self.requireAttrKind(node, attribute, kind, &.{.string}, markup.markdown_issue_link_base_message);
@@ -782,6 +782,12 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
782
782
  options.details_expanded = try self.boolItems(ui, scope, node, typed.binding);
783
783
  continue;
784
784
  }
785
+ if (std.mem.eql(u8, attribute.name, "images")) {
786
+ const typed = markup.attrTyped(attribute);
787
+ if (typed != .binding) return self.failNode(node, markup.markdown_images_message);
788
+ options.images = try self.markdownImageItems(ui, scope, node, typed.binding);
789
+ continue;
790
+ }
785
791
  if (std.mem.eql(u8, attribute.name, "issue-link-base")) {
786
792
  const typed = markup.attrTyped(attribute);
787
793
  if (typed == .equals or typed == .invalid) {
@@ -1489,6 +1495,20 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
1489
1495
  return self.failText(node, markup.markdown_details_expanded_message);
1490
1496
  }
1491
1497
 
1498
+ /// Resolve Markdown's registered source-to-image mapping through the
1499
+ /// same bounded iterable reflection used by `for each`.
1500
+ fn markdownImageItems(self: *Self, ui: *Ui, scope: *Scope, node: markup.MarkupNode, path: []const u8) BuildError![]const canvas.markdown.ResolvedImage {
1501
+ @setEvalBranchQuota(scan_quota);
1502
+ inline for (item_types, 0..) |Item, type_index| {
1503
+ if (comptime (Item == canvas.markdown.ResolvedImage)) {
1504
+ if (try self.iterateItems(ui, Item, type_index, scope, path)) |items| {
1505
+ return items;
1506
+ }
1507
+ }
1508
+ }
1509
+ return self.failText(node, markup.markdown_images_message);
1510
+ }
1511
+
1492
1512
  // ------------------------------------------------------ templates
1493
1513
 
1494
1514
  /// A hard cap on template expansion nesting. Legit documents are
@@ -1711,6 +1711,10 @@ pub const doc_body_source =
1711
1711
  \\
1712
1712
  \\Tracked in #12, see https://status.example.com.
1713
1713
  \\
1714
+ \\| State |
1715
+ \\| --- |
1716
+ \\| ![Ready](https://status.example.com/ready.png) Ready |
1717
+ \\
1714
1718
  \\<details>
1715
1719
  \\<summary>Rollout</summary>
1716
1720
  \\
@@ -1724,6 +1728,12 @@ pub const DocModel = struct {
1724
1728
  details_expanded: [2]bool = .{ false, false },
1725
1729
  opened_count: usize = 0,
1726
1730
  issue_base: []const u8 = "ghissue://",
1731
+ images: [1]canvas.markdown.ResolvedImage = .{.{
1732
+ .source = "https://status.example.com/ready.png",
1733
+ .image = 71,
1734
+ .width = 10,
1735
+ .height = 10,
1736
+ }},
1727
1737
 
1728
1738
  /// Arena scalar as a markdown source: composed at view time.
1729
1739
  pub fn banner(model: *const DocModel, arena: std.mem.Allocator) []const u8 {
@@ -1733,7 +1743,7 @@ pub const DocModel = struct {
1733
1743
 
1734
1744
  pub const doc_markup_source =
1735
1745
  \\<column gap="8">
1736
- \\ <markdown source="{body}" on-link="open_url" on-details="toggle_details" details-expanded="{details_expanded}" issue-link-base="{issue_base}" />
1746
+ \\ <markdown source="{body}" on-link="open_url" on-details="toggle_details" details-expanded="{details_expanded}" issue-link-base="{issue_base}" images="{images}" />
1737
1747
  \\ <markdown source="{banner}" />
1738
1748
  \\</column>
1739
1749
  ;
@@ -1750,6 +1760,7 @@ pub fn handDocView(ui: *DocUi, model: *const DocModel) DocUi.Node {
1750
1760
  .on_details = DocMd.detailsMsg(.toggle_details),
1751
1761
  .details_expanded = &model.details_expanded,
1752
1762
  .issue_link_base = model.issue_base,
1763
+ .images = &model.images,
1753
1764
  }),
1754
1765
  DocMd.view(ui, model.banner(ui.arena), .{}),
1755
1766
  });
@@ -1807,6 +1818,7 @@ test "the markdown element builds the hand-written Md.view tree and dispatches l
1807
1818
  // URLs autolink (trailing punctuation trimmed).
1808
1819
  try testing.expectEqualStrings("ghissue://12", findSpanLink(markup_tree.root, "#12").?);
1809
1820
  try testing.expectEqualStrings("https://status.example.com", findSpanLink(markup_tree.root, "https://status.example.com").?);
1821
+ try testing.expectEqual(@as(canvas.ImageId, 71), findByKind(markup_tree.root, .image).?.image_id);
1810
1822
 
1811
1823
  // Details summary dispatches on-details with the block index; the body
1812
1824
  // is hidden while the caller-owned flag is false.
@@ -576,6 +576,9 @@ pub const attrs = [_]AttrInfo{
576
576
  // can state compact runs (`2-4, 7`) without putting +/- bytes in source.
577
577
  .{ .code = 94, .name = "added-lines", .class = .text, .group = .composite },
578
578
  .{ .code = 95, .name = "removed-lines", .class = .text, .group = .composite },
579
+ // Markdown's caller-owned source -> registered ImageId mapping. The
580
+ // markdown rule hook scopes and type-checks the iterable binding.
581
+ .{ .code = 96, .name = "images", .class = .binding_only, .group = .composite },
579
582
  };
580
583
 
581
584
  // ----------------------------------------------------------------- events
@@ -22,7 +22,7 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
22
22
  // the new fingerprint ONLY for additions; renames/renumbers are
23
23
  // schema-version-bump events, not silent edits.
24
24
  try testing.expectEqual(@as(usize, 70), schema.elements.len);
25
- try testing.expectEqual(@as(usize, 95), schema.attrs.len);
25
+ try testing.expectEqual(@as(usize, 96), schema.attrs.len);
26
26
  try testing.expectEqual(@as(usize, 14), schema.events.len);
27
27
  // The element table runs through the span composite (64), the
28
28
  // bubble-reactions composite (65), the media surface (66), the
@@ -45,9 +45,10 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
45
45
  // attributes pty (88) and scrollback (89), and the code language
46
46
  // (90), line-numbers (91), and editable-code (92) declarations,
47
47
  // the flat disclosure-tree hierarchy level tree-level (93), and the
48
- // code-diff line sets added-lines (94) and removed-lines (95).
48
+ // code-diff line sets added-lines (94) and removed-lines (95), and
49
+ // Markdown's registered-image iterable binding images (96).
49
50
  try testing.expectEqual(
50
- @as(u64, 0xf16fa9fd1d3e7f25),
51
+ @as(u64, 0xc0ab8db72d6e2110),
51
52
  tableFingerprint(schema.AttrInfo, &schema.attrs),
52
53
  );
53
54
  // The event table runs through the pointer-hover containment pair
@@ -150,8 +150,13 @@ pub fn layoutWidgetDepth(
150
150
  }
151
151
  },
152
152
  // Span paragraphs and span-carrying table cells share the link
153
- // hotspot child convention (no spans or no children is a no-op).
154
- .text, .data_cell => try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens),
153
+ // hotspot child convention. A span-less table cell may instead be
154
+ // a composed inline row (Markdown's resolved image + text shape).
155
+ .text => try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens),
156
+ .data_cell => if (widget.spans.len > 0)
157
+ try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens)
158
+ else
159
+ try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, widget.layout, tokens),
155
160
  .icon, .image, .avatar, .badge, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .tooltip, .menu_item, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .separator, .skeleton, .spinner, .chart, .split_divider, .media_surface, .terminal => {},
156
161
  }
157
162
 
@@ -824,10 +829,25 @@ fn wrappedVerticalExtentForWidth(widget: Widget, width: f32, tokens: DesignToken
824
829
  const padding = widget.layout.padding;
825
830
  const inner_width = @max(0, width - padding.left - padding.right);
826
831
  const content_height: f32 = switch (widget.kind) {
827
- .text, .data_cell => if (widget.spans.len > 0)
832
+ .text => if (widget.spans.len > 0)
828
833
  spanParagraphHeight(widget, inner_width, tokens)
829
834
  else
830
835
  return preferredMainExtent(widget, .vertical, tokens),
836
+ .data_cell => if (widget.spans.len > 0)
837
+ spanParagraphHeight(widget, inner_width, tokens)
838
+ else if (widget.children.len > 0) blk: {
839
+ var max_height: f32 = 0;
840
+ for (widget.children, 0..) |child, index| {
841
+ if (child.layout.anchor != null) continue;
842
+ max_height = @max(max_height, wrappedVerticalExtentForWidth(
843
+ child,
844
+ rowChildWidth(widget, inner_width, index, tokens),
845
+ tokens,
846
+ depth + 1,
847
+ ));
848
+ }
849
+ break :blk max_height;
850
+ } else return preferredMainExtent(widget, .vertical, tokens),
831
851
  .column, .list, .data_grid, .table, .menu_surface, .dropdown_menu => blk: {
832
852
  if (widget.layout.virtualized) return preferredMainExtent(widget, .vertical, tokens);
833
853
  var sum: f32 = 0;
@@ -1021,6 +1041,7 @@ fn layoutTextSpanLinkChildren(
1021
1041
  content.x += gutter;
1022
1042
  content.width -= gutter;
1023
1043
  }
1044
+ content = widget_metrics.widgetTextSpanAlignedContentFrame(widget, content, tokens);
1024
1045
 
1025
1046
  var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
1026
1047
  const layout = text_spans_model.layoutTextSpans(
@@ -1806,6 +1827,8 @@ fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize)
1806
1827
  // span paragraph; classic cells keep the single-line row metric.
1807
1828
  .data_cell => if (widget.spans.len > 0)
1808
1829
  paddedIntrinsicSize(widget, intrinsicTextWidgetSize(widget, tokens, widgetBodyTextSize(widget, tokens)))
1830
+ else if (widget.children.len > 0)
1831
+ intrinsicAxisChildrenSize(widget, tokens, .horizontal, depth)
1809
1832
  else
1810
1833
  intrinsicRowTextWidgetSize(widget, tokens),
1811
1834
  // Table rows sit taller than list rows: the comfortable row
@@ -138,15 +138,33 @@ pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32
138
138
  ) + 12;
139
139
  }
140
140
 
141
+ /// Vertically align a span paragraph inside a table cell's padded content.
142
+ /// Rows share the tallest cell's height; centering the laid-out text block
143
+ /// keeps a short text-only cell aligned with image-bearing or wrapped peers.
144
+ /// Other paragraph kinds keep their normal top-aligned document flow.
145
+ pub fn widgetTextSpanAlignedContentFrame(widget: Widget, content_in: geometry.RectF, tokens: DesignTokens) geometry.RectF {
146
+ if (widget.kind != .data_cell or widget.spans.len == 0 or content_in.height <= 0) return content_in;
147
+ var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
148
+ const layout = text_spans_model.layoutTextSpans(
149
+ widget.spans,
150
+ widgetTextSpanLayoutOptions(widget, tokens, content_in.width),
151
+ &runs,
152
+ );
153
+ var content = content_in;
154
+ content.y += @max(0, (content.height - layout.size.height) * 0.5);
155
+ return content;
156
+ }
157
+
141
158
  /// Span paragraph content after authored padding and the engine-owned code
142
- /// gutter. Layout, painting, hit mapping, and selection all use this exact
143
- /// frame so numbered source stays one coherent text model.
159
+ /// gutter, plus table-cell vertical alignment. Layout, painting, hit mapping,
160
+ /// and selection all use this exact frame so numbered source and cell links
161
+ /// stay one coherent text model.
144
162
  pub fn widgetTextSpanContentFrame(widget: Widget, tokens: DesignTokens) geometry.RectF {
145
163
  var content = widget.frame.inset(widget.layout.padding);
146
164
  const gutter = @min(content.width, widgetCodeLineNumberGutterWidth(widget, tokens));
147
165
  content.x += gutter;
148
166
  content.width -= gutter;
149
- return content;
167
+ return widgetTextSpanAlignedContentFrame(widget, content, tokens);
150
168
  }
151
169
 
152
170
  /// The ONE control height register — buttons, inputs, and select
@@ -351,7 +351,12 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
351
351
  // inside the flat wash chrome.
352
352
  try emitWidgetClippedChildren(builder, paint_widget, tokens, depth);
353
353
  },
354
- .data_cell => try emitDataCellContent(builder, paint_widget, tokens),
354
+ .data_cell => {
355
+ try emitDataCellContent(builder, paint_widget, tokens);
356
+ if (paint_widget.spans.len == 0 and paint_widget.children.len > 0) {
357
+ try emitWidgetClippedChildren(builder, paint_widget, tokens, depth);
358
+ }
359
+ },
355
360
  .status_bar => try emitStatusBarWidget(builder, paint_widget, tokens),
356
361
  .segmented_control => try widget_render_controls.emitSegmentedControlWidget(builder, paint_widget, tokens),
357
362
  .checkbox => try widget_render_controls.emitCheckboxWidget(builder, paint_widget, tokens),
@@ -12860,6 +12860,15 @@ pub fn Effects(comptime Msg: type) type {
12860
12860
  try body.writer.writeAll(slot.fetchPayload());
12861
12861
  try body.end();
12862
12862
  try request.connection.?.flush();
12863
+ } else if (slot.method.requestHasBody()) {
12864
+ // POST, PUT and PATCH carry a body by definition, so
12865
+ // `sendBodiless` asserts against them. A payload-free
12866
+ // request of one of those methods is still valid HTTP;
12867
+ // send an explicit zero-length body instead.
12868
+ request.transfer_encoding = .{ .content_length = 0 };
12869
+ var body = try request.sendBodyUnflushed(&.{});
12870
+ try body.end();
12871
+ try request.connection.?.flush();
12863
12872
  } else {
12864
12873
  try request.sendBodiless();
12865
12874
  }
@@ -923,6 +923,27 @@ test "real fetch round-trips a POST payload through the echo route" {
923
923
  try std.testing.expectEqualStrings("the payload rides in the fetch buffer", h.app_state.model.body());
924
924
  }
925
925
 
926
+ test "real fetch sends a payload-free POST as an explicit zero-length body" {
927
+ var h = try Harness.create();
928
+ defer h.destroy();
929
+ const fixture = try Fixture.start(std.testing.allocator);
930
+ defer fixture.stop();
931
+
932
+ var url_buffer: [128]u8 = undefined;
933
+ test_url = fixture.url(&url_buffer, "/echo");
934
+ test_method = .POST;
935
+ test_headers = &.{};
936
+ test_payload = null;
937
+ test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
938
+ try h.app_state.dispatch(&h.harness.runtime, 1, .start);
939
+ try waitForResponse(&h);
940
+
941
+ try std.testing.expectEqual(effects_mod.EffectFetchOutcome.ok, h.app_state.model.outcome.?);
942
+ try std.testing.expectEqual(@as(u16, 200), h.app_state.model.status);
943
+ try std.testing.expectEqual(@as(usize, 0), h.app_state.model.body_len);
944
+ try std.testing.expect(fixture.headContains("content-length: 0"));
945
+ }
946
+
926
947
  test "real fetch preserves binary bodies byte for byte" {
927
948
  var h = try Harness.create();
928
949
  defer h.destroy();
@@ -1,17 +1,18 @@
1
- //! The native host consumer for transpiled app cores: bridges the
2
- //! versioned command/subscription wire format a transpiled core emits
3
- //! (`packages/core/rt/rt.zig`, `cmd_format_version` 3) onto the
4
- //! real effect engine (`effects.zig`). The transpiler's output is a
5
- //! pure Model/Msg/update core whose effects are INERT BYTES — this
6
- //! module is the one place those bytes become engine calls, so the
7
- //! entire existing effects machinery (executors, keyed slots, the
8
- //! completion queue, the session journal, replay) carries transpiled
9
- //! cores without a parallel engine.
1
+ //! The native host consumer for compiled TypeScript app cores: bridges
2
+ //! the versioned command/subscription wire format a compiled core
3
+ //! emits (`cmd_format_version` 3) onto the real effect engine
4
+ //! (`effects.zig`). The TypeScript tier's core module is a pure
5
+ //! Model/Msg/update core whose effects are INERT BYTES — this module is
6
+ //! the one place those bytes become engine calls, so the entire
7
+ //! existing effects machinery (executors, keyed slots, the completion
8
+ //! queue, the session journal, replay) carries TypeScript cores without
9
+ //! a parallel engine.
10
10
  //!
11
- //! `TsCoreHost(core)` is comptime-generic over the emitted core module
12
- //! and expects the emitted ABI:
11
+ //! `TsCoreHost(core)` is comptime-generic over the core module (the
12
+ //! corewire-generated mirror over a compiled archive, or any
13
+ //! hand-written module of the same shape) and expects:
13
14
  //!
14
- //! core.rt the core's rt kernel: `frameAlloc`,
15
+ //! core.rt the core's runtime: `frameAlloc`,
15
16
  //! `frameReset`, `resetAll`
16
17
  //! core.Model the committed model struct
17
18
  //! core.Msg the app Msg `union(enum)` (wire tags are the
@@ -22,14 +23,13 @@
22
23
  //! core.commitModelRoot the frame-end commit walker
23
24
  //! core.subscriptions optional: `fn (*const Model) []const u8`
24
25
  //!
25
- //! Like the rt kernel it drives, a host instance is container-level
26
- //! state — the v1 contract is ONE LIVE APP PER CORE MODULE: two apps
27
- //! over the same emitted core in one process would share a committed
28
- //! root and one set of bridge tables. Two DIFFERENT core modules
29
- //! coexist fine (each staged core carries its own rt.zig module
30
- //! instance, so kernels never alias; distinct core types get distinct
31
- //! hosts) — the e2e suite drives two live cores side by side to pin
32
- //! exactly that.
26
+ //! Like the runtime it drives, a host instance is container-level
27
+ //! state — the contract is ONE LIVE APP PER CORE MODULE: two apps
28
+ //! over the same core in one process would share a committed root and
29
+ //! one set of bridge tables. A compiled archive additionally owns the
30
+ //! process's fixed-prefix C ABI symbol set, so a process carries ONE
31
+ //! compiled core (each e2e battery is its own binary for exactly that
32
+ //! reason).
33
33
  //!
34
34
  //! THE DISPATCH CYCLE — every Msg runs update → commit → command walk →
35
35
  //! subscription reconcile → frame reset, in that order, because the
@@ -182,7 +182,7 @@
182
182
  //! are matched by member name, exactly the
183
183
  //! data/closed/rejected set) — until the one `closed`
184
184
  //! (or a refused open's `rejected`) terminal retires
185
- //! it. POSTING is not a TS-tier verb: transpiled cores
185
+ //! it. POSTING is not a TS-tier verb: TypeScript cores
186
186
  //! are single-threaded, so the thread-safe posting
187
187
  //! handle is native-side API (`Effects.channelHandle`)
188
188
  //! for embedders and platform-services extensions —
@@ -349,7 +349,7 @@
349
349
  //! frame-resident and copy whatever the model keeps into the heap.
350
350
  //!
351
351
  //! Malformed wire bytes are teaching panics, not error codes: the only
352
- //! producer is the transpiler's own rt builders, so a bad record is a
352
+ //! producer is the compiled core's own runtime builders, so a bad record is a
353
353
  //! build-pipeline bug the app author must see immediately.
354
354
 
355
355
  const std = @import("std");
@@ -410,8 +410,8 @@ pub fn videoKeyForTag(event_tag: u8) u64 {
410
410
  /// families' one engine key space without ever colliding on a key.
411
411
  pub const pty_key_base: u64 = 0x5453_5054_0000_0000;
412
412
 
413
- /// The spawn wire record's "no line routing" tag sentinel (mirrors
414
- /// rt.zig's `spawn_no_line_tag`).
413
+ /// The spawn wire record's "no line routing" tag sentinel (the wire
414
+ /// format's shared constant).
415
415
  pub const spawn_no_line_tag: u8 = 0xFF;
416
416
 
417
417
  /// Longest wire key (request or timer) the format can carry: the key
@@ -713,7 +713,7 @@ pub fn TsCoreHost(comptime core: type) type {
713
713
  /// boot model. The command bytes are re-derived by re-running
714
714
  /// the PURE `initialModel` (they were frame-resident and did not
715
715
  /// survive `boot`'s frame reset; the duplicate model value is
716
- /// frame-transient garbage) — purity is the transpiled subset's
716
+ /// frame-transient garbage) — purity is the app-core subset's
717
717
  /// own guarantee, so the bytes are identical by construction.
718
718
  pub fn performBoot(fx: *Fx) void {
719
719
  if (comptime init_returns_cmd) {
@@ -789,7 +789,7 @@ pub fn TsCoreHost(comptime core: type) type {
789
789
  /// One full dispatch cycle for `msg`. The `TsUiApp` adapter
790
790
  /// wires this to `UiApp.Options.update_fx` (refreshing the
791
791
  /// app-held root from `model()` afterwards) so host events and
792
- /// drained effect results run the transpiled core through the
792
+ /// drained effect results run the TypeScript core through the
793
793
  /// same path Zig cores use. A Msg flagged by its own result
794
794
  /// callback as a dropped entry's terminal is swallowed here —
795
795
  /// the silent drop the keyed-effect discipline promises.
@@ -937,7 +937,7 @@ pub fn TsCoreHost(comptime core: type) type {
937
937
  const url = takeLongBytes(cmd, &at);
938
938
  const header_count: usize = takeByte(cmd, &at);
939
939
  if (header_count > runtime_effects.max_effect_fetch_headers) {
940
- @panic("ts core host: a fetch wire record carries more headers than the engine accepts - the transpiler's own bound should have stopped this build");
940
+ @panic("ts core host: a fetch wire record carries more headers than the engine accepts - the frontend's own bound should have stopped this build");
941
941
  }
942
942
  var headers: [runtime_effects.max_effect_fetch_headers]std.http.Header = undefined;
943
943
  for (0..header_count) |i| {
@@ -1006,7 +1006,7 @@ pub fn TsCoreHost(comptime core: type) type {
1006
1006
  }
1007
1007
  const argc: usize = takeByte(cmd, &at);
1008
1008
  if (argc == 0 or argc > runtime_effects.max_effect_argv) {
1009
- @panic("ts core host: a spawn wire record carries more argv elements than the engine accepts - the transpiler's own bound should have stopped this build");
1009
+ @panic("ts core host: a spawn wire record carries more argv elements than the engine accepts - the frontend's own bound should have stopped this build");
1010
1010
  }
1011
1011
  var argv: [runtime_effects.max_effect_argv][]const u8 = undefined;
1012
1012
  for (0..argc) |i| argv[i] = takeLongBytes(cmd, &at);
@@ -1185,7 +1185,7 @@ pub fn TsCoreHost(comptime core: type) type {
1185
1185
  const term = takeShortBytes(cmd, &at);
1186
1186
  const argc: usize = takeByte(cmd, &at);
1187
1187
  if (argc == 0 or argc > runtime_effects.max_effect_argv) {
1188
- @panic("ts core host: a pty_spawn wire record carries more argv elements than the engine accepts - the transpiler's own bound should have stopped this build");
1188
+ @panic("ts core host: a pty_spawn wire record carries more argv elements than the engine accepts - the frontend's own bound should have stopped this build");
1189
1189
  }
1190
1190
  var argv: [runtime_effects.max_effect_argv][]const u8 = undefined;
1191
1191
  for (0..argc) |i| argv[i] = takeLongBytes(cmd, &at);
@@ -2110,7 +2110,7 @@ pub fn TsCoreHost(comptime core: type) type {
2110
2110
  // ------------------------------------------ subscription timers
2111
2111
 
2112
2112
  /// Reconcile the declarative subscription set against the fixed
2113
- /// timer table — the same algorithm as the transpiler package's
2113
+ /// timer table — the same algorithm as the @native-sdk/core package's
2114
2114
  /// run-fidelity drivers, engine-backed: match by key, arm new
2115
2115
  /// keys into the first free slot, re-arm on interval change,
2116
2116
  /// re-route on tag change, cancel the missing. Slot order
@@ -2270,7 +2270,7 @@ pub fn TsCoreHost(comptime core: type) type {
2270
2270
  /// (fetch's `{ status, body }` and a collect spawn's
2271
2271
  /// `{ code, output }`): the arm must be a struct of exactly one
2272
2272
  /// number field and one bytes field, matched BY TYPE (the
2273
- /// transpiler validates the shape, so field names stay the
2273
+ /// frontend validates the shape, so field names stay the
2274
2274
  /// app's). The bytes copy into the core's frame arena like
2275
2275
  /// every routed payload; the number widens into its field the
2276
2276
  /// way the subset's number model classes it (i64, u64, or f64).
@@ -2351,14 +2351,14 @@ pub fn TsCoreHost(comptime core: type) type {
2351
2351
  }
2352
2352
 
2353
2353
  /// The arm's `state` member for an engine event kind, matched
2354
- /// by member NAME (the transpiler pins the member set, so the
2354
+ /// by member NAME (the frontend pins the member set, so the
2355
2355
  /// app's declaration order never matters to the wire).
2356
2356
  fn audioStateValue(comptime E: type, kind: runtime_effects.EffectAudioEventKind) E {
2357
2357
  const name = @tagName(kind);
2358
2358
  inline for (@typeInfo(E).@"enum".fields) |f| {
2359
2359
  if (std.mem.eql(u8, f.name, name)) return @enumFromInt(f.value);
2360
2360
  }
2361
- @panic("ts core host: an audio event kind has no member in the event arm's state union - the transpiler's own shape check should have stopped this build");
2361
+ @panic("ts core host: an audio event kind has no member in the event arm's state union - the frontend's own shape check should have stopped this build");
2362
2362
  }
2363
2363
 
2364
2364
  /// Build the six-field audio event arm at index `tag` from an
@@ -2431,7 +2431,7 @@ pub fn TsCoreHost(comptime core: type) type {
2431
2431
  inline for (@typeInfo(E).@"enum".fields) |f| {
2432
2432
  if (std.mem.eql(u8, f.name, name)) return @enumFromInt(f.value);
2433
2433
  }
2434
- @panic("ts core host: a video event kind has no member in the event arm's state union - the transpiler's own shape check should have stopped this build");
2434
+ @panic("ts core host: a video event kind has no member in the event arm's state union - the frontend's own shape check should have stopped this build");
2435
2435
  }
2436
2436
 
2437
2437
  /// Build the seven-field video event arm at index `tag` from an
@@ -2496,7 +2496,7 @@ pub fn TsCoreHost(comptime core: type) type {
2496
2496
  inline for (@typeInfo(E).@"enum".fields) |f| {
2497
2497
  if (std.mem.eql(u8, f.name, name)) return @enumFromInt(f.value);
2498
2498
  }
2499
- @panic("ts core host: an image outcome has no member in the result arm's state union - the transpiler's own shape check should have stopped this build");
2499
+ @panic("ts core host: an image outcome has no member in the result arm's state union - the frontend's own shape check should have stopped this build");
2500
2500
  }
2501
2501
 
2502
2502
  /// Build the five-field image result arm at index `tag` from an
@@ -2561,7 +2561,7 @@ pub fn TsCoreHost(comptime core: type) type {
2561
2561
  inline for (@typeInfo(E).@"enum".fields) |f| {
2562
2562
  if (std.mem.eql(u8, f.name, name)) return @enumFromInt(f.value);
2563
2563
  }
2564
- @panic("ts core host: a channel event kind has no member in the event arm's state union - the transpiler's own shape check should have stopped this build");
2564
+ @panic("ts core host: a channel event kind has no member in the event arm's state union - the frontend's own shape check should have stopped this build");
2565
2565
  }
2566
2566
 
2567
2567
  /// Build the five-field channel event arm at index `tag` from
@@ -2646,7 +2646,7 @@ pub fn TsCoreHost(comptime core: type) type {
2646
2646
  inline for (@typeInfo(E).@"enum".fields) |f| {
2647
2647
  if (std.mem.eql(u8, f.name, name)) return @enumFromInt(f.value);
2648
2648
  }
2649
- @panic("ts core host: a pty event kind has no member in the event arm's state union - the transpiler's own shape check should have stopped this build");
2649
+ @panic("ts core host: a pty event kind has no member in the event arm's state union - the frontend's own shape check should have stopped this build");
2650
2650
  }
2651
2651
 
2652
2652
  /// The arm's `reason` member for an engine exit reason, matched
@@ -2656,7 +2656,7 @@ pub fn TsCoreHost(comptime core: type) type {
2656
2656
  inline for (@typeInfo(E).@"enum".fields) |f| {
2657
2657
  if (std.mem.eql(u8, f.name, name)) return @enumFromInt(f.value);
2658
2658
  }
2659
- @panic("ts core host: a pty exit reason has no member in the event arm's reason union - the transpiler's own shape check should have stopped this build");
2659
+ @panic("ts core host: a pty exit reason has no member in the event arm's reason union - the frontend's own shape check should have stopped this build");
2660
2660
  }
2661
2661
 
2662
2662
  /// Build the six-field pty event arm at index `tag` from an