@barefootjs/rust 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -187314,7 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames
187317
+ collectLoopBoundNames,
187318
+ derivesScopeFromSlot
187318
187319
  } from "@barefootjs/jsx";
187319
187320
 
187320
187321
  // src/adapter/boolean-result.ts
@@ -188663,6 +188664,7 @@ ${whenTrue}
188663
188664
  this.inLoop = true;
188664
188665
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188665
188666
  this.currentLoopKeyDepth = loop.depth;
188667
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188666
188668
  const childrenUnderLoop = this.renderChildren(loop.children);
188667
188669
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188668
188670
  this.inLoop = prevInLoop;
@@ -188686,9 +188688,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188686
188688
  filterCond = filterCond.replace(new RegExp(`\\b${loop.filterPredicate.param}\\b`, "g"), minijinjaIdent(param));
188687
188689
  }
188688
188690
  lines.push(`{% if ${filterCond} %}`);
188691
+ lines.push(...preambleLines);
188689
188692
  lines.push(bodyChildren);
188690
188693
  lines.push(`{% endif %}`);
188691
188694
  } else {
188695
+ lines.push(...preambleLines);
188692
188696
  lines.push(bodyChildren);
188693
188697
  }
188694
188698
  lines.push(`{% endfor %}`);
@@ -188748,10 +188752,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188748
188752
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188749
188753
  continue;
188750
188754
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188751
- const prevInLoop = this.inLoop;
188752
- this.inLoop = false;
188753
188755
  const slotBody = this.renderChildren(p.value.children);
188754
- this.inLoop = prevInLoop;
188755
188756
  const captureName = `bf_prop_${this.childrenCaptureCounter++}`;
188756
188757
  namedSlotSetBlocks.push(`{% set ${captureName} %}${slotBody}{% endset %}`);
188757
188758
  currentEntries().push(`${minijinjaHashKey(p.name)}: ${captureName}`);
@@ -188772,16 +188773,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188772
188773
  if (lowered)
188773
188774
  currentEntries().push(lowered);
188774
188775
  }
188775
- if (comp.slotId && !this.inLoop) {
188776
+ if (derivesScopeFromSlot(comp)) {
188776
188777
  currentEntries().push(`${minijinjaHashKey("_bf_slot")}: '${comp.slotId}'`);
188777
188778
  }
188778
188779
  const tplName = this.toTemplateName(comp.name);
188779
188780
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188780
188781
  if (effectiveChildren.length > 0) {
188781
- const prevInLoop = this.inLoop;
188782
- this.inLoop = false;
188783
188782
  const childrenBody = this.renderChildren(effectiveChildren);
188784
- this.inLoop = prevInLoop;
188785
188783
  const captureName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188786
188784
  currentEntries().push(`${minijinjaHashKey("children")}: ${captureName}`);
188787
188785
  const dict = this.combineComponentPropSegments(segments);
@@ -1 +1 @@
1
- {"version":3,"file":"minijinja-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/minijinja-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiHG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAKP,yBAA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oB;IAW5B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,4BAA4B;CAGrC;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
package/dist/build.js CHANGED
@@ -187314,7 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames
187317
+ collectLoopBoundNames,
187318
+ derivesScopeFromSlot
187318
187319
  } from "@barefootjs/jsx";
187319
187320
 
187320
187321
  // src/adapter/boolean-result.ts
@@ -188663,6 +188664,7 @@ ${whenTrue}
188663
188664
  this.inLoop = true;
188664
188665
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188665
188666
  this.currentLoopKeyDepth = loop.depth;
188667
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188666
188668
  const childrenUnderLoop = this.renderChildren(loop.children);
188667
188669
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188668
188670
  this.inLoop = prevInLoop;
@@ -188686,9 +188688,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188686
188688
  filterCond = filterCond.replace(new RegExp(`\\b${loop.filterPredicate.param}\\b`, "g"), minijinjaIdent(param));
188687
188689
  }
188688
188690
  lines.push(`{% if ${filterCond} %}`);
188691
+ lines.push(...preambleLines);
188689
188692
  lines.push(bodyChildren);
188690
188693
  lines.push(`{% endif %}`);
188691
188694
  } else {
188695
+ lines.push(...preambleLines);
188692
188696
  lines.push(bodyChildren);
188693
188697
  }
188694
188698
  lines.push(`{% endfor %}`);
@@ -188748,10 +188752,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188748
188752
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188749
188753
  continue;
188750
188754
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188751
- const prevInLoop = this.inLoop;
188752
- this.inLoop = false;
188753
188755
  const slotBody = this.renderChildren(p.value.children);
188754
- this.inLoop = prevInLoop;
188755
188756
  const captureName = `bf_prop_${this.childrenCaptureCounter++}`;
188756
188757
  namedSlotSetBlocks.push(`{% set ${captureName} %}${slotBody}{% endset %}`);
188757
188758
  currentEntries().push(`${minijinjaHashKey(p.name)}: ${captureName}`);
@@ -188772,16 +188773,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188772
188773
  if (lowered)
188773
188774
  currentEntries().push(lowered);
188774
188775
  }
188775
- if (comp.slotId && !this.inLoop) {
188776
+ if (derivesScopeFromSlot(comp)) {
188776
188777
  currentEntries().push(`${minijinjaHashKey("_bf_slot")}: '${comp.slotId}'`);
188777
188778
  }
188778
188779
  const tplName = this.toTemplateName(comp.name);
188779
188780
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188780
188781
  if (effectiveChildren.length > 0) {
188781
- const prevInLoop = this.inLoop;
188782
- this.inLoop = false;
188783
188782
  const childrenBody = this.renderChildren(effectiveChildren);
188784
- this.inLoop = prevInLoop;
188785
188783
  const captureName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188786
188784
  currentEntries().push(`${minijinjaHashKey("children")}: ${captureName}`);
188787
188785
  const dict = this.combineComponentPropSegments(segments);
@@ -1 +1 @@
1
- {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA6I7B,CAAA"}
1
+ {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAwI7B,CAAA"}
package/dist/index.js CHANGED
@@ -187314,7 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames
187317
+ collectLoopBoundNames,
187318
+ derivesScopeFromSlot
187318
187319
  } from "@barefootjs/jsx";
187319
187320
 
187320
187321
  // src/adapter/boolean-result.ts
@@ -188663,6 +188664,7 @@ ${whenTrue}
188663
188664
  this.inLoop = true;
188664
188665
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188665
188666
  this.currentLoopKeyDepth = loop.depth;
188667
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188666
188668
  const childrenUnderLoop = this.renderChildren(loop.children);
188667
188669
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188668
188670
  this.inLoop = prevInLoop;
@@ -188686,9 +188688,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188686
188688
  filterCond = filterCond.replace(new RegExp(`\\b${loop.filterPredicate.param}\\b`, "g"), minijinjaIdent(param));
188687
188689
  }
188688
188690
  lines.push(`{% if ${filterCond} %}`);
188691
+ lines.push(...preambleLines);
188689
188692
  lines.push(bodyChildren);
188690
188693
  lines.push(`{% endif %}`);
188691
188694
  } else {
188695
+ lines.push(...preambleLines);
188692
188696
  lines.push(bodyChildren);
188693
188697
  }
188694
188698
  lines.push(`{% endfor %}`);
@@ -188748,10 +188752,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188748
188752
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188749
188753
  continue;
188750
188754
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188751
- const prevInLoop = this.inLoop;
188752
- this.inLoop = false;
188753
188755
  const slotBody = this.renderChildren(p.value.children);
188754
- this.inLoop = prevInLoop;
188755
188756
  const captureName = `bf_prop_${this.childrenCaptureCounter++}`;
188756
188757
  namedSlotSetBlocks.push(`{% set ${captureName} %}${slotBody}{% endset %}`);
188757
188758
  currentEntries().push(`${minijinjaHashKey(p.name)}: ${captureName}`);
@@ -188772,16 +188773,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188772
188773
  if (lowered)
188773
188774
  currentEntries().push(lowered);
188774
188775
  }
188775
- if (comp.slotId && !this.inLoop) {
188776
+ if (derivesScopeFromSlot(comp)) {
188776
188777
  currentEntries().push(`${minijinjaHashKey("_bf_slot")}: '${comp.slotId}'`);
188777
188778
  }
188778
188779
  const tplName = this.toTemplateName(comp.name);
188779
188780
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188780
188781
  if (effectiveChildren.length > 0) {
188781
- const prevInLoop = this.inLoop;
188782
- this.inLoop = false;
188783
188782
  const childrenBody = this.renderChildren(effectiveChildren);
188784
- this.inLoop = prevInLoop;
188785
188783
  const captureName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188786
188784
  currentEntries().push(`${minijinjaHashKey("children")}: ${captureName}`);
188787
188785
  const dict = this.combineComponentPropSegments(segments);
@@ -189195,7 +189193,6 @@ var minijinjaAdapter = new MinijinjaAdapter;
189195
189193
  // src/conformance-pins.ts
189196
189194
  var conformancePins = {
189197
189195
  "filter-typeof-predicate": [{ code: "BF021", severity: "error" }],
189198
- "map-preamble-branch-body": [{ code: "BF021", severity: "error" }],
189199
189196
  "map-array-builder-body": [{ code: "BF021", severity: "error" }],
189200
189197
  "map-array-builder-escaping": [{ code: "BF021", severity: "error" }],
189201
189198
  "fill-unsupported": [{ code: "BF101", severity: "error" }],
@@ -189223,7 +189220,8 @@ var conformancePins = {
189223
189220
  };
189224
189221
  // src/render-divergences.ts
189225
189222
  var renderDivergences = {
189226
- "composite-row-child-component": "a child component nested inside a dynamic loop row gets a random `Name_<id>` scope id from `render_child` instead of the parent-derived `<parent>_s0` the reference emits (https://github.com/piconic-ai/barefootjs/issues/2444)"
189223
+ "aliased-destructured-prop": "aliased destructured prop `{ n: count }` loses its rename template vars, ssr-defaults, and the props bridge all key off the local name, so the prop is always undefined (https://github.com/piconic-ai/barefootjs/issues/2460)",
189224
+ "composite-row-child-aliased-prop": "same #2460 defect as `aliased-destructured-prop`, inside a keyed `.map()` loop row: the nested child's renamed prop (`{ n: count }`) is always undefined, so both rows render an empty count (https://github.com/piconic-ai/barefootjs/issues/2460)"
189227
189225
  };
189228
189226
  export {
189229
189227
  renderDivergences,
@@ -1 +1 @@
1
- {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAe/B,CAAA"}
1
+ {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAkB/B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/rust",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "minijinja (Rust) adapter for BarefootJS — compiles IR to .j2 templates and ships a Rust rendering runtime (packages/adapter-rust/runtime/); runs under any Rust web framework (axum, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,14 +54,14 @@
54
54
  "directory": "packages/adapter-rust"
55
55
  },
56
56
  "dependencies": {
57
- "@barefootjs/shared": "0.29.0"
57
+ "@barefootjs/shared": "0.30.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@barefootjs/jsx": ">=0.2.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@barefootjs/adapter-tests": "0.1.0",
64
- "@barefootjs/jsx": "0.29.0",
64
+ "@barefootjs/jsx": "0.30.0",
65
65
  "typescript": "^5.0.0"
66
66
  }
67
67
  }
@@ -215,13 +215,13 @@ function C({ rows }: { rows?: number }) {
215
215
 
216
216
  test('leaves a defaulted attr unconditional (scope did not widen)', () => {
217
217
  const { template } = compileAndGenerate(`
218
- function C({ value = '' }: { value?: string }) {
219
- return <textarea value={value} />
218
+ function C({ placeholder = '' }: { placeholder?: string }) {
219
+ return <textarea placeholder={placeholder} />
220
220
  }
221
221
  `)
222
- // `value` has a destructure default → never None → unconditional, exactly
223
- // like Hono's value="".
224
- expect(template).toContain('value="{{ bf.string(value) }}"')
222
+ // `placeholder` has a destructure default → never None → unconditional, exactly
223
+ // like Hono's placeholder="".
224
+ expect(template).toContain('placeholder="{{ bf.string(placeholder) }}"')
225
225
  expect(template).not.toContain('is not none')
226
226
  })
227
227
  })
@@ -171,6 +171,7 @@ import {
171
171
  dangerousInnerHtmlDiagnostic,
172
172
  resolveStaticLoopSource,
173
173
  collectLoopBoundNames,
174
+ derivesScopeFromSlot,
174
175
  } from '@barefootjs/jsx'
175
176
  import { isAriaBooleanAttr, isBooleanResultExpr, isExplicitStringCall } from './boolean-result.ts'
176
177
  import type { ParsedExpr, LoweringMatcher, LoopBindingPathSegment } from '@barefootjs/jsx'
@@ -942,6 +943,15 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
942
943
  // Re-render children now that inLoop is set (so nested components use the
943
944
  // loop-child naming convention). renderedChildren above was computed with
944
945
  // the previous flag; recompute under the loop flag.
946
+
947
+ // Per-row locals for a `.map()` callback preamble (#2447), in source
948
+ // order so a later initializer sees an earlier local — same as the
949
+ // source block. Phase 1 refuses the loop outright when the preamble
950
+ // isn't fully declarable, so there is no partial-lowering case: either
951
+ // every statement is lowered here, or the build already failed.
952
+ const preambleLines = (loop.preamble?.declarations ?? []).map(
953
+ d => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`,
954
+ )
945
955
  const childrenUnderLoop = this.renderChildren(loop.children)
946
956
  this.currentLoopKeyDepth = prevLoopKeyDepth
947
957
  this.inLoop = prevInLoop
@@ -1008,9 +1018,11 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1008
1018
  )
1009
1019
  }
1010
1020
  lines.push(`{% if ${filterCond} %}`)
1021
+ lines.push(...preambleLines)
1011
1022
  lines.push(bodyChildren)
1012
1023
  lines.push(`{% endif %}`)
1013
1024
  } else {
1025
+ lines.push(...preambleLines)
1014
1026
  lines.push(bodyChildren)
1015
1027
  }
1016
1028
 
@@ -1144,10 +1156,7 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1144
1156
  // SSR (Hono renders neither; the client JS wires them at hydration).
1145
1157
  if ((p.name.match(/^on[A-Z]/) || p.name === 'ref') && p.value.kind === 'expression') continue
1146
1158
  if (p.value.kind === 'jsx-children' && p.name !== 'children') {
1147
- const prevInLoop = this.inLoop
1148
- this.inLoop = false
1149
1159
  const slotBody = this.renderChildren(p.value.children)
1150
- this.inLoop = prevInLoop
1151
1160
  // Purely counter-based — NOT derived from `p.name` or `comp.slotId`.
1152
1161
  // A JSX prop name can contain characters (`data-slot`) that aren't a
1153
1162
  // valid minijinja `{% set %}` target, and `comp.slotId` alone would
@@ -1190,11 +1199,11 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1190
1199
  if (lowered) currentEntries().push(lowered)
1191
1200
  }
1192
1201
  // Pass slot ID so the child renderer can set correct scope ID for
1193
- // hydration. Skip for loop childrenthey use ComponentName_random.
1194
- // Appended to whatever the trailing entries segment is so a spread's
1195
- // own `_bf_slot`/`children` keys (if any) never win over these
1196
- // compiler-controlled entries.
1197
- if (comp.slotId && !this.inLoop) {
1202
+ // hydration. Skipped for a loop item root it uses ComponentName_random
1203
+ // instead (#2444). Appended to whatever the trailing entries segment is
1204
+ // so a spread's own `_bf_slot`/`children` keys (if any) never win over
1205
+ // these compiler-controlled entries.
1206
+ if (derivesScopeFromSlot(comp)) {
1198
1207
  currentEntries().push(`${minijinjaHashKey('_bf_slot')}: '${comp.slotId}'`)
1199
1208
  }
1200
1209
  const tplName = this.toTemplateName(comp.name)
@@ -1215,10 +1224,7 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1215
1224
  // backend before handing it to the child. See the file header,
1216
1225
  // divergence 4, for why a set-block (not a macro) is the uniform
1217
1226
  // mechanism here.
1218
- const prevInLoop = this.inLoop
1219
- this.inLoop = false
1220
1227
  const childrenBody = this.renderChildren(effectiveChildren)
1221
- this.inLoop = prevInLoop
1222
1228
  const captureName = `bf_children_${comp.slotId ?? 'c' + this.childrenCaptureCounter++}`
1223
1229
  currentEntries().push(`${minijinjaHashKey('children')}: ${captureName}`)
1224
1230
  const dict = this.combineComponentPropSegments(segments)
@@ -16,11 +16,6 @@ export const conformancePins: ConformancePins = {
16
16
  // JS-runtime target runs it, a DSL adapter surfaces BF021 + `/* @client */`.
17
17
  // See spec/callback-fidelity.md.
18
18
  'filter-typeof-predicate': [{ code: 'BF021', severity: 'error' }],
19
- // A `.map()` body with a `const`/`let` preamble before its branches:
20
- // a JS runtime folds it, a DSL adapter can't carry the loop-local into a
21
- // conditional branch template, so it refuses with BF021 + `/* @client */`.
22
- // See spec/callback-fidelity.md.
23
- 'map-preamble-branch-body': [{ code: 'BF021', severity: 'error' }],
24
19
  'map-array-builder-body': [{ code: 'BF021', severity: 'error' }],
25
20
  'map-array-builder-escaping': [{ code: 'BF021', severity: 'error' }],
26
21
  // `.fill(value)` mutates the receiver in place — no template lowering
@@ -22,13 +22,16 @@ export const renderDivergences: RenderDivergences = {
22
22
  // instead of a fixed regex-shape catalogue) now correctly seeds `todos`
23
23
  // from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))`.
24
24
 
25
- // #2444: a child component nested inside a dynamic loop row whose root
26
- // is a plain element (`composite` loop plan + `nestedComponents`) is
27
- // rendered through the runtime's `render_child`, which mints its own
28
- // `Badge_<random>` scope id instead of deriving the parent-scope +
29
- // mount-slot id (`test_s0`) the Hono reference emits. Content is
30
- // correct; only `bf-s` diverges. Same class as the `grandchild-
31
- // composition` CSR skip.
32
- 'composite-row-child-component':
33
- 'a child component nested inside a dynamic loop row gets a random `Name_<id>` scope id from `render_child` instead of the parent-derived `<parent>_s0` the reference emits (https://github.com/piconic-ai/barefootjs/issues/2444)',
25
+ // Onboarding TSX-fidelity fixtures (PR #2461): `expectedHtml` is
26
+ // hand-authored to the CORRECT output because the emission bug lives in
27
+ // the shared compiler layer every adapter, including the Hono
28
+ // reference, currently emits the broken form (verified against this
29
+ // adapter's emitted template; see each fixture's docstring). Graduate
30
+ // by fixing the shared emission, regenerating `expectedHtml` from the
31
+ // fixed reference, and deleting these lines (and the matching hono
32
+ // `skipJsx` entries).
33
+ 'aliased-destructured-prop':
34
+ 'aliased destructured prop `{ n: count }` loses its rename — template vars, ssr-defaults, and the props bridge all key off the local name, so the prop is always undefined (https://github.com/piconic-ai/barefootjs/issues/2460)',
35
+ 'composite-row-child-aliased-prop':
36
+ 'same #2460 defect as `aliased-destructured-prop`, inside a keyed `.map()` loop row: the nested child\'s renamed prop (`{ n: count }`) is always undefined, so both rows render an empty count (https://github.com/piconic-ai/barefootjs/issues/2460)',
34
37
  }