@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
@@ -22,7 +22,8 @@
22
22
  // sub arm|re-arm|cancel <key> subscription reconciliation by key
23
23
  // fire <key> -> <kind> @ <ms> a virtual timer fired (dispatched)
24
24
  //
25
- // Virtual-host semantics match the run-fidelity harness (node = native):
25
+ // Virtual-host semantics match the compiled core's (node = native; the
26
+ // SDK's ts-core e2e batteries pin the native side over real archives):
26
27
  // - Cmd.now dispatches its arm immediately at the current virtual time;
27
28
  // - Sub.timer reconciles by key after every commit (new key or changed
28
29
  // interval arms, missing key cancels), each fire dispatching the named
@@ -70,8 +71,8 @@ if (!entry) usage();
70
71
  // The resolver hook maps "@native-sdk/core" onto this package's own SDK
71
72
  // module (app trees carry no node_modules for bare resolution to find),
72
73
  // and the byte-text methods (s.toUpperCase(), s.split(sep), ...) install
73
- // on Uint8Array.prototype before the core loads — the same tables the
74
- // native rt helpers use, so node runs are byte-identical by construction.
74
+ // on Uint8Array.prototype before the core loads — locale-free simple
75
+ // case tables, the semantics the compiled core carries natively.
75
76
  installTextMethods();
76
77
  register(new URL("./devhost_resolver.mjs", import.meta.url));
77
78
 
@@ -394,13 +394,11 @@ export const rules = {
394
394
  fix: "Declare `Model` as an interface record (`export interface Model { ... }`) and `Msg` as a kind-tagged union (`export type Msg = { kind: \"...\" } | ...`).",
395
395
  why: "The generated wiring commits `Model` as the reference-stored record root and dispatches `Msg` by its declaration-order kind tags; any other shape under those names has no dispatch or commit path and would fail deep inside the emitted module instead of teaching here.",
396
396
  },
397
- // NS9xxx: internal emit-time verification. A checker gap becomes a loud
398
- // internal error naming the construct, never silent misbehavior.
399
- NS9001: {
400
- id: "NS9001",
401
- title: "construct not covered by the v1 emitter",
402
- fix: "Rewrite with the constructs in the subset table, or report this file so the mapping gains a rule.",
403
- why: "The emitter re-derives every subset rule during emission; anything it cannot prove a mapping for must stop the build.",
397
+ NS1063: {
398
+ id: "NS1063",
399
+ title: "the contract sidecar carries every crossing shape",
400
+ fix: "Spell the crossing in a schema-carried form: value-stored records (object-literal aliases) for message payloads, named records around optional or array payloads, and integer aliases whose values reach past 255.",
401
+ why: "The contract sidecar is the machine-readable twin of the core's surface, and a shape its schema cannot state would silently drop from every consumer — so the build stops here with the spelling that carries it instead.",
404
402
  },
405
403
  } as const satisfies Record<string, RuleCopy>;
406
404
 
@@ -1,64 +1,51 @@
1
- // Orchestration: resolve the core's import graph (teaching diagnostics for
2
- // every module-boundary mistake), check every module with the provider's
3
- // own checker (same semantics as the author-facing tsc by upstream design),
4
- // run the subset checker, run integer inference, then emit ONE Zig module
5
- // for the whole graph.
1
+ // The frontend orchestration: resolve the core's import graph (teaching
2
+ // diagnostics for every module-boundary mistake), check every module with
3
+ // the provider's own checker (same semantics as the author-facing tsc by
4
+ // upstream design), run the subset checker, run integer inference, then —
5
+ // when asked — emit the contract sidecar for the whole graph. The
6
+ // external core compiler does the compiling; this pass is the subset's
7
+ // teaching surface and the contract source.
6
8
 
7
9
  import { ts, TypedAst, createSubsetProgram, lineColumn } from "./typed_ast.ts";
8
10
  import { resolveModuleGraph } from "./modules.ts";
9
11
  import { TypeTable } from "./types.ts";
10
12
  import { IntInference } from "./infer.ts";
11
13
  import { SubsetChecker } from "./checker.ts";
12
- import { Emitter, EmitError, type KernelCapacities } from "./emitter.ts";
14
+ import { emitContractSidecar, ContractError } from "./contract.ts";
13
15
  import { makeDiagnostic, formatDiagnostic, type SubsetDiagnostic } from "./diagnostics.ts";
14
16
  import path from "node:path";
15
17
  import fs from "node:fs";
16
18
 
17
- export interface TranspileOptions {
18
- /// Frame arena capacity in bytes: the transient budget of one dispatch.
19
- /// Emitted as a comptime parameter of the core's rt kernel instantiation
20
- /// (rt default when omitted).
21
- readonly frameCap?: number;
22
- /// Model heap capacity in bytes PER SPACE (the two-space committed-model
23
- /// heap): the live model graph plus not-yet-compacted garbage must fit.
24
- readonly heapCap?: number;
19
+ export interface FrontendOptions {
20
+ /// When set, also emit the contract sidecar (core.contract.json,
21
+ /// schema format 1) from the checked program — the entry spelling the
22
+ /// document states (never a filesystem-absolute leak).
23
+ readonly contractEntry?: string;
25
24
  }
26
25
 
27
- export interface TranspileResult {
26
+ export interface FrontendResult {
28
27
  readonly ok: boolean;
29
- readonly zig: string | null;
28
+ /// The contract sidecar JSON, when options.contractEntry asked for it
29
+ /// (null otherwise, and on any failed check).
30
+ readonly contract: string | null;
30
31
  readonly diagnostics: SubsetDiagnostic[];
31
32
  /// Non-fatal teaching notices (NS1028 today): surfaced as warnings,
32
- /// never failing the transpile.
33
+ /// never failing the check.
33
34
  readonly warnings: SubsetDiagnostic[];
34
35
  /// Provider (tsc-semantics) diagnostics, already formatted.
35
36
  readonly typeErrors: string[];
36
37
  /// Every file the core is built from, absolute, entry first — the
37
- /// build-graph staleness set (a change to any of them re-emits).
38
+ /// build-graph staleness set (a change to any of them re-checks).
38
39
  readonly inputs: string[];
39
40
  }
40
41
 
41
- function validateCapacities(options: TranspileOptions): KernelCapacities {
42
- for (const [name, v] of [
43
- ["frameCap", options.frameCap],
44
- ["heapCap", options.heapCap],
45
- ] as const) {
46
- if (v !== undefined && (!Number.isSafeInteger(v) || v <= 0)) {
47
- throw new Error(`${name} must be a positive integer byte count, got ${v}`);
48
- }
49
- }
50
- return { frameCap: options.frameCap, heapCap: options.heapCap };
51
- }
52
-
53
- export function transpileFile(entry: string, options: TranspileOptions = {}): TranspileResult {
54
- const capacities = validateCapacities(options);
55
-
42
+ export function checkFile(entry: string, options: FrontendOptions = {}): FrontendResult {
56
43
  // Module-boundary mistakes (NS1034-NS1037) teach BEFORE the type-checked
57
44
  // program is built: a missing file or an escaped src/ boundary would
58
45
  // otherwise surface as a raw resolution error.
59
46
  const graph = resolveModuleGraph(entry);
60
47
  if (graph.diagnostics.length > 0) {
61
- return { ok: false, zig: null, diagnostics: graph.diagnostics, warnings: [], typeErrors: [], inputs: [...graph.files] };
48
+ return { ok: false, contract: null, diagnostics: graph.diagnostics, warnings: [], typeErrors: [], inputs: [...graph.files] };
62
49
  }
63
50
 
64
51
  const program = createSubsetProgram(entry);
@@ -68,12 +55,12 @@ export function transpileFile(entry: string, options: TranspileOptions = {}): Tr
68
55
  for (const p of graph.files) {
69
56
  const file = byPath.get(path.resolve(p));
70
57
  if (!file) {
71
- return { ok: false, zig: null, diagnostics: [], warnings: [], typeErrors: [`cannot read ${p}`], inputs: [...graph.files] };
58
+ return { ok: false, contract: null, diagnostics: [], warnings: [], typeErrors: [`cannot read ${p}`], inputs: [...graph.files] };
72
59
  }
73
60
  files.push(file);
74
61
  }
75
62
  if (files.length === 0) {
76
- return { ok: false, zig: null, diagnostics: [], warnings: [], typeErrors: [`cannot read ${entry}`], inputs: [] };
63
+ return { ok: false, contract: null, diagnostics: [], warnings: [], typeErrors: [`cannot read ${entry}`], inputs: [] };
77
64
  }
78
65
 
79
66
  const typeErrors: string[] = [];
@@ -87,14 +74,14 @@ export function transpileFile(entry: string, options: TranspileOptions = {}): Tr
87
74
  }
88
75
  }
89
76
  if (typeErrors.length > 0) {
90
- return { ok: false, zig: null, diagnostics: [], warnings: [], typeErrors: [...new Set(typeErrors)], inputs: [...graph.files] };
77
+ return { ok: false, contract: null, diagnostics: [], warnings: [], typeErrors: [...new Set(typeErrors)], inputs: [...graph.files] };
91
78
  }
92
79
 
93
80
  const table = new TypeTable(tast, files);
94
81
  const checker = new SubsetChecker(tast, table, files);
95
82
  const checkResult = checker.check();
96
83
  if (checkResult.diagnostics.length > 0) {
97
- return { ok: false, zig: null, diagnostics: checkResult.diagnostics, warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
84
+ return { ok: false, contract: null, diagnostics: checkResult.diagnostics, warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
98
85
  }
99
86
 
100
87
  const infer = new IntInference(tast, table, files);
@@ -112,32 +99,33 @@ export function transpileFile(entry: string, options: TranspileOptions = {}): Tr
112
99
  column,
113
100
  );
114
101
  });
115
- return { ok: false, zig: null, diagnostics, warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
102
+ return { ok: false, contract: null, diagnostics, warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
116
103
  }
117
- const emitter = new Emitter(tast, table, infer, checkResult, files, path.basename(entry), capacities);
118
104
  try {
119
- const zig = emitter.emitModule();
120
- return { ok: true, zig, diagnostics: [], warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
105
+ // The contract sidecar emits from the SAME checked analysis, so a
106
+ // contract-bearing run keeps every check-time teaching.
107
+ const contract =
108
+ options.contractEntry !== undefined
109
+ ? emitContractSidecar({ tast, table, infer, checkResult, files, entry: options.contractEntry })
110
+ : null;
111
+ return { ok: true, contract, diagnostics: [], warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
121
112
  } catch (e) {
122
- if (e instanceof EmitError) {
113
+ if (e instanceof ContractError) {
123
114
  const file = e.node.getSourceFile();
124
115
  const { line, column } = lineColumn(file, e.node.getStart());
125
- // Layer-3 re-derivations of taught rules keep their own rule copy;
126
- // everything else is the internal NS9001 stop.
127
- const site = e.ruleId === "NS9001" ? `Internal: no v1 mapping for ${e.message}.` : `${e.message[0].toUpperCase()}${e.message.slice(1)}.`;
128
- const d = makeDiagnostic(e.ruleId, site, file.fileName, line, column);
129
- return { ok: false, zig: null, diagnostics: [d], warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
116
+ const d = makeDiagnostic("NS1063", `${e.message[0].toUpperCase()}${e.message.slice(1)}.`, file.fileName, line, column);
117
+ return { ok: false, contract: null, diagnostics: [d], warnings: checkResult.warnings, typeErrors: [], inputs: [...graph.files] };
130
118
  }
131
119
  throw e;
132
120
  }
133
121
  }
134
122
 
135
- export function transpileSource(source: string, name = "core.ts", options: TranspileOptions = {}): TranspileResult {
123
+ export function checkSource(source: string, name = "core.ts", options: FrontendOptions = {}): FrontendResult {
136
124
  // Test seam: materialize an in-memory file through a temp path-less host.
137
125
  const tmp = path.join(process.env.TMPDIR ?? "/tmp", `native-core-${process.pid}-${Math.random().toString(36).slice(2)}.ts`);
138
126
  fs.writeFileSync(tmp, source);
139
127
  try {
140
- return transpileFile(tmp, options);
128
+ return checkFile(tmp, options);
141
129
  } finally {
142
130
  fs.unlinkSync(tmp);
143
131
  }
@@ -1323,7 +1323,7 @@ export class IntInference {
1323
1323
  // comparisons against proven/demanded integer sides. Comparison-origin
1324
1324
  // demand never claims a host-boundary slot, nor any slot a host-boundary
1325
1325
  // slot feeds: the comparison itself does not require an integer (the
1326
- // emitter widens the integer side into f64 instead), and an i64-claimed
1326
+ // integer side widens into f64 instead), and an i64-claimed
1327
1327
  // exported signature would truncate host f64 values that node compares
1328
1328
  // exactly — claiming only part of such a chain would manufacture an
1329
1329
  // NS1016 conflict out of thin air. Genuine demand chains (index,
@@ -1,11 +1,16 @@
1
1
  // The TypedAst seam — the ONLY file that imports the type-checker provider.
2
2
  //
3
- // The transpiler needs resolved types (union discrimination, literal types,
3
+ // The frontend needs resolved types (union discrimination, literal types,
4
4
  // readonly-ness, symbol resolution, contextual types) but must not couple to
5
- // a particular checker API: today the provider is the `@typescript/typescript6`
6
- // compat package (same checker semantics as the author-facing TS7 tsc by
7
- // upstream design); when the stable Go-native programmatic API ships, only
8
- // this adapter changes.
5
+ // a particular checker API: today the provider is the `@typescript/old`
6
+ // alias (the 6.x compiler line). It powers the TEACHINGS; the
7
+ // author-facing typecheck VERDICT comes from the pinned external core
8
+ // compiler itself, which `native check` runs as its final pass
9
+ // (scripts/compiler_typecheck.mjs) — check and build judge with one
10
+ // compiler. The Go-native 7.x line ships no in-process API (its
11
+ // programmatic surface is an out-of-process protocol, still marked
12
+ // unstable); when a stable in-process-equivalent API exists, only this
13
+ // adapter changes.
9
14
  //
10
15
  // Surface discipline:
11
16
  // - Syntax (node kinds, tree walking) passes through as `ts` — syntax trees
@@ -13,16 +18,12 @@
13
18
  // - Every TYPE question goes through the named queries on `TypedAst` below.
14
19
  // Checker/emitter code never touches `program.getTypeChecker()` directly.
15
20
 
16
- // The IMPORT deliberately bypasses the `@typescript/typescript6` wrapper
17
- // (which stays the declared dependency — it is the provider named above,
18
- // and its own dependency IS this alias): the wrapper's lib/typescript.js
19
- // re-exports "@typescript/old" resolved from the WRAPPER's location, so a
20
- // consumer tree already carrying a conflicting hoisted @typescript/old
21
- // would win node's nearest-wins walk there while our exactly pinned copy
22
- // sat nested and unused. Importing the alias directly resolves it from
23
- // THIS file — inside our package, where our own nested/hoisted exact pin
24
- // is always the nearest — and the CLI's resolution gate additionally
25
- // verifies the resolved version against the pin.
21
+ // The IMPORT resolves the alias from THIS file — inside our package,
22
+ // where our own nested/hoisted exact pin is always the nearest in node's
23
+ // walk — so a consumer tree carrying a conflicting hoisted
24
+ // @typescript/old can never shadow the pinned compiler; the CLI's
25
+ // resolution gate additionally verifies the resolved version against the
26
+ // pin.
26
27
  import tsImpl from "@typescript/old";
27
28
  import path from "node:path";
28
29
  import { fileURLToPath } from "node:url";
@@ -0,0 +1,79 @@
1
+ // Wyhash (the final version, as Zig's std.hash.Wyhash implements it),
2
+ // one-shot form. The contract sidecar's synthesized identity fields hash
3
+ // the reflected surface with this function so the frontend-emitted
4
+ // document and the extraction-path document agree byte for byte on
5
+ // identical surfaces (tools/corewire/extract.zig hashes the same bytes
6
+ // with std.hash.Wyhash). BigInt-based: the transpiler is a build-time
7
+ // tool and the inputs are small.
8
+
9
+ const M64 = (1n << 64n) - 1n;
10
+
11
+ const SECRET = [0xa0761d6478bd642fn, 0xe7037ed1a0b428dbn, 0x8ebc6af09c88c6e3n, 0x589965cc75374cc3n] as const;
12
+
13
+ function mix(aIn: bigint, bIn: bigint): bigint {
14
+ const x = (aIn & M64) * (bIn & M64);
15
+ return (x & M64) ^ ((x >> 64n) & M64);
16
+ }
17
+
18
+ /// Little-endian read of `n` bytes at `offset`.
19
+ function read(data: Uint8Array, offset: number, n: number): bigint {
20
+ let v = 0n;
21
+ for (let i = n - 1; i >= 0; i--) v = (v << 8n) | BigInt(data[offset + i]);
22
+ return v;
23
+ }
24
+
25
+ export function wyhash(seed: bigint, input: Uint8Array): bigint {
26
+ const len = input.length;
27
+ const state = new Array<bigint>(3);
28
+ state[0] = (seed ^ mix(seed ^ SECRET[0], SECRET[1])) & M64;
29
+ state[1] = state[0];
30
+ state[2] = state[0];
31
+ let a = 0n;
32
+ let b = 0n;
33
+
34
+ if (len <= 16) {
35
+ if (len >= 4) {
36
+ const end = len - 4;
37
+ const quarter = (len >> 3) << 2;
38
+ a = ((read(input, 0, 4) << 32n) | read(input, quarter, 4)) & M64;
39
+ b = ((read(input, end, 4) << 32n) | read(input, end - quarter, 4)) & M64;
40
+ } else if (len > 0) {
41
+ a = (BigInt(input[0]) << 16n) | (BigInt(input[len >> 1]) << 8n) | BigInt(input[len - 1]);
42
+ b = 0n;
43
+ }
44
+ } else {
45
+ let i = 0;
46
+ if (len >= 48) {
47
+ while (i + 48 < len) {
48
+ for (let j = 0; j < 3; j++) {
49
+ const x = read(input, i + 8 * (2 * j), 8);
50
+ const y = read(input, i + 8 * (2 * j + 1), 8);
51
+ state[j] = mix(x ^ SECRET[j + 1], y ^ state[j]);
52
+ }
53
+ i += 48;
54
+ }
55
+ state[0] = state[0] ^ state[1] ^ state[2];
56
+ }
57
+ // The tail: 16-byte lanes relative to the last block start, then the
58
+ // final 16 bytes of the WHOLE input.
59
+ let k = i;
60
+ while (k + 16 < len) {
61
+ state[0] = mix(read(input, k, 8) ^ SECRET[1], read(input, k + 8, 8) ^ state[0]);
62
+ k += 16;
63
+ }
64
+ a = read(input, len - 16, 8);
65
+ b = read(input, len - 8, 8);
66
+ }
67
+
68
+ a = a ^ SECRET[1];
69
+ b = b ^ state[0];
70
+ const x = (a & M64) * (b & M64);
71
+ a = x & M64;
72
+ b = (x >> 64n) & M64;
73
+ return mix(a ^ SECRET[0] ^ BigInt(len), b ^ SECRET[1]);
74
+ }
75
+
76
+ /// The sidecar's identity spelling: 16 lowercase hex digits.
77
+ export function wyhashHex(seed: bigint, input: Uint8Array): string {
78
+ return wyhash(seed, input).toString(16).padStart(16, "0");
79
+ }
@@ -991,15 +991,16 @@ Bare source-bound highlighted content shared with Markdown fences:
991
991
  A leaf element that renders a markdown string (the GFM subset below) as ordinary widgets, wiring `native_sdk.markdown` for you — both engines implement it identically:
992
992
 
993
993
  ```html
994
- <markdown source="{issue_body}" on-link="open_url" on-details="toggle_details" details-expanded="{details_expanded}" />
994
+ <markdown source="{issue_body}" images="{markdownImages}" on-link="open_url" on-details="toggle_details" details-expanded="{details_expanded}" />
995
995
  ```
996
996
 
997
997
  - `source` (required): one `{binding}` producing the markdown text — a `[]const u8` field, zero-arg fn, or arena-taking fn (compose the document into the build arena at view time).
998
+ - `images` (optional): one `{binding}` producing `[]const canvas.markdown.ResolvedImage`. Give `canvas.markdown.collectImageSources` caller-owned `[]canvas.markdown.CollectedImageSource` storage, consume each canonical source through `value()` while that storage is alive, load it through `fx.loadImage`, and retain the source, successful id, and decoded dimensions in the model. Return mappings from a model or arena-taking fn. The view never performs I/O; missing mappings keep the safe alt-text fallback.
998
999
  - `on-link` (optional): a BARE Msg tag — no `:{payload}` — whose payload is the pressed link URL; declare `open_url: []const u8` in `Msg`.
999
1000
  - `on-details` (optional): a bare Msg tag whose payload is the `<details>` block's document-order index; declare `toggle_details: usize`.
1000
1001
  - `details-expanded` (optional): one `{binding}` naming a `[]const bool` iterable (a model field, pub decl, or fn — the same sources `for each` accepts); flags are read in details-block document order. Keep a bounded `details_expanded: [8]bool` in the model and toggle it in `update`.
1001
1002
  - `issue-link-base` (optional): a literal URL prefix or one `{binding}` producing it; `#123` references at word boundaries become links to base ++ number (`issue-link-base="ghissue://"` links `#123` to `ghissue://123` — an app scheme your `on-link` handler intercepts, or a web base like `https://github.com/owner/repo/issues/`). Off by default: resolving a ref needs repo context.
1002
- - No children, no text content, no other attributes (teaching errors point at misuse). Without the details wiring, `<details>` blocks render collapsed and inert; without `on-link`, links render styled but inert.
1003
+ - No children and no text content (teaching errors point at misuse). Without the details wiring, `<details>` blocks render collapsed and inert; without `on-link`, links render styled but inert.
1003
1004
 
1004
1005
  ## Pipeline composites: stepper, timeline, nav
1005
1006