@barefootjs/jinja 0.29.0 → 0.30.2

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
@@ -188669,6 +188670,7 @@ ${whenTrue}
188669
188670
  this.inLoop = true;
188670
188671
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188671
188672
  this.currentLoopKeyDepth = loop.depth;
188673
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188672
188674
  const childrenUnderLoop = this.renderChildren(loop.children);
188673
188675
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188674
188676
  this.inLoop = prevInLoop;
@@ -188692,9 +188694,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188692
188694
  filterCond = filterCond.replace(new RegExp(`\\b${loop.filterPredicate.param}\\b`, "g"), jinjaIdent(param));
188693
188695
  }
188694
188696
  lines.push(`{% if ${filterCond} %}`);
188697
+ lines.push(...preambleLines);
188695
188698
  lines.push(bodyChildren);
188696
188699
  lines.push(`{% endif %}`);
188697
188700
  } else {
188701
+ lines.push(...preambleLines);
188698
188702
  lines.push(bodyChildren);
188699
188703
  }
188700
188704
  lines.push(`{% endfor %}`);
@@ -188754,10 +188758,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188754
188758
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188755
188759
  continue;
188756
188760
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188757
- const prevInLoop = this.inLoop;
188758
- this.inLoop = false;
188759
188761
  const slotBody = this.renderChildren(p.value.children);
188760
- this.inLoop = prevInLoop;
188761
188762
  const captureName = `bf_prop_${this.childrenCaptureCounter++}`;
188762
188763
  namedSlotSetBlocks.push(`{% set ${captureName} %}${slotBody}{% endset %}`);
188763
188764
  currentEntries().push(`${jinjaHashKey(p.name)}: ${captureName}`);
@@ -188778,16 +188779,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188778
188779
  if (lowered)
188779
188780
  currentEntries().push(lowered);
188780
188781
  }
188781
- if (comp.slotId && !this.inLoop) {
188782
+ if (derivesScopeFromSlot(comp)) {
188782
188783
  currentEntries().push(`${jinjaHashKey("_bf_slot")}: '${comp.slotId}'`);
188783
188784
  }
188784
188785
  const tplName = this.toTemplateName(comp.name);
188785
188786
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188786
188787
  if (effectiveChildren.length > 0) {
188787
- const prevInLoop = this.inLoop;
188788
- this.inLoop = false;
188789
188788
  const childrenBody = this.renderChildren(effectiveChildren);
188790
- this.inLoop = prevInLoop;
188791
188789
  const captureName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188792
188790
  currentEntries().push(`${jinjaHashKey("children")}: ${captureName}`);
188793
188791
  const dict = this.combineComponentPropSegments(segments);
@@ -1 +1 @@
1
- {"version":3,"file":"jinja-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/jinja-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;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,yBAAyB,EAE1B,MAAM,iBAAiB,CAAA;AACxB,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OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,4BAA4B;CAGrC;AAED,eAAO,MAAM,YAAY,cAAqB,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
@@ -188669,6 +188670,7 @@ ${whenTrue}
188669
188670
  this.inLoop = true;
188670
188671
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188671
188672
  this.currentLoopKeyDepth = loop.depth;
188673
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188672
188674
  const childrenUnderLoop = this.renderChildren(loop.children);
188673
188675
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188674
188676
  this.inLoop = prevInLoop;
@@ -188692,9 +188694,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188692
188694
  filterCond = filterCond.replace(new RegExp(`\\b${loop.filterPredicate.param}\\b`, "g"), jinjaIdent(param));
188693
188695
  }
188694
188696
  lines.push(`{% if ${filterCond} %}`);
188697
+ lines.push(...preambleLines);
188695
188698
  lines.push(bodyChildren);
188696
188699
  lines.push(`{% endif %}`);
188697
188700
  } else {
188701
+ lines.push(...preambleLines);
188698
188702
  lines.push(bodyChildren);
188699
188703
  }
188700
188704
  lines.push(`{% endfor %}`);
@@ -188754,10 +188758,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188754
188758
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188755
188759
  continue;
188756
188760
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188757
- const prevInLoop = this.inLoop;
188758
- this.inLoop = false;
188759
188761
  const slotBody = this.renderChildren(p.value.children);
188760
- this.inLoop = prevInLoop;
188761
188762
  const captureName = `bf_prop_${this.childrenCaptureCounter++}`;
188762
188763
  namedSlotSetBlocks.push(`{% set ${captureName} %}${slotBody}{% endset %}`);
188763
188764
  currentEntries().push(`${jinjaHashKey(p.name)}: ${captureName}`);
@@ -188778,16 +188779,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188778
188779
  if (lowered)
188779
188780
  currentEntries().push(lowered);
188780
188781
  }
188781
- if (comp.slotId && !this.inLoop) {
188782
+ if (derivesScopeFromSlot(comp)) {
188782
188783
  currentEntries().push(`${jinjaHashKey("_bf_slot")}: '${comp.slotId}'`);
188783
188784
  }
188784
188785
  const tplName = this.toTemplateName(comp.name);
188785
188786
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188786
188787
  if (effectiveChildren.length > 0) {
188787
- const prevInLoop = this.inLoop;
188788
- this.inLoop = false;
188789
188788
  const childrenBody = this.renderChildren(effectiveChildren);
188790
- this.inLoop = prevInLoop;
188791
188789
  const captureName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188792
188790
  currentEntries().push(`${jinjaHashKey("children")}: ${captureName}`);
188793
188791
  const dict = this.combineComponentPropSegments(segments);
@@ -1 +1 @@
1
- {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA8I7B,CAAA"}
1
+ {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAyI7B,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
@@ -188669,6 +188670,7 @@ ${whenTrue}
188669
188670
  this.inLoop = true;
188670
188671
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188671
188672
  this.currentLoopKeyDepth = loop.depth;
188673
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188672
188674
  const childrenUnderLoop = this.renderChildren(loop.children);
188673
188675
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188674
188676
  this.inLoop = prevInLoop;
@@ -188692,9 +188694,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188692
188694
  filterCond = filterCond.replace(new RegExp(`\\b${loop.filterPredicate.param}\\b`, "g"), jinjaIdent(param));
188693
188695
  }
188694
188696
  lines.push(`{% if ${filterCond} %}`);
188697
+ lines.push(...preambleLines);
188695
188698
  lines.push(bodyChildren);
188696
188699
  lines.push(`{% endif %}`);
188697
188700
  } else {
188701
+ lines.push(...preambleLines);
188698
188702
  lines.push(bodyChildren);
188699
188703
  }
188700
188704
  lines.push(`{% endfor %}`);
@@ -188754,10 +188758,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188754
188758
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188755
188759
  continue;
188756
188760
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188757
- const prevInLoop = this.inLoop;
188758
- this.inLoop = false;
188759
188761
  const slotBody = this.renderChildren(p.value.children);
188760
- this.inLoop = prevInLoop;
188761
188762
  const captureName = `bf_prop_${this.childrenCaptureCounter++}`;
188762
188763
  namedSlotSetBlocks.push(`{% set ${captureName} %}${slotBody}{% endset %}`);
188763
188764
  currentEntries().push(`${jinjaHashKey(p.name)}: ${captureName}`);
@@ -188778,16 +188779,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188778
188779
  if (lowered)
188779
188780
  currentEntries().push(lowered);
188780
188781
  }
188781
- if (comp.slotId && !this.inLoop) {
188782
+ if (derivesScopeFromSlot(comp)) {
188782
188783
  currentEntries().push(`${jinjaHashKey("_bf_slot")}: '${comp.slotId}'`);
188783
188784
  }
188784
188785
  const tplName = this.toTemplateName(comp.name);
188785
188786
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188786
188787
  if (effectiveChildren.length > 0) {
188787
- const prevInLoop = this.inLoop;
188788
- this.inLoop = false;
188789
188788
  const childrenBody = this.renderChildren(effectiveChildren);
188790
- this.inLoop = prevInLoop;
188791
188789
  const captureName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188792
188790
  currentEntries().push(`${jinjaHashKey("children")}: ${captureName}`);
188793
188791
  const dict = this.combineComponentPropSegments(segments);
@@ -189201,7 +189199,6 @@ var jinjaAdapter = new JinjaAdapter;
189201
189199
  // src/conformance-pins.ts
189202
189200
  var conformancePins = {
189203
189201
  "filter-typeof-predicate": [{ code: "BF021", severity: "error" }],
189204
- "map-preamble-branch-body": [{ code: "BF021", severity: "error" }],
189205
189202
  "map-array-builder-body": [{ code: "BF021", severity: "error" }],
189206
189203
  "map-array-builder-escaping": [{ code: "BF021", severity: "error" }],
189207
189204
  "fill-unsupported": [{ code: "BF101", severity: "error" }],
@@ -189229,7 +189226,10 @@ var conformancePins = {
189229
189226
  };
189230
189227
  // src/render-divergences.ts
189231
189228
  var renderDivergences = {
189232
- "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)"
189229
+ "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)",
189230
+ "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)",
189231
+ "loop-param-shadows-bool-prop": 'a .map() param sharing a boolean prop\'s name is routed through the bool lowering in attribute position (renders "true"/"false" instead of the row string) — `collectBooleanTypedProps` lacks the `collectLoopBoundNames` subtraction its sibling `collectStringValueNames` got in #2236 (https://github.com/piconic-ai/barefootjs/issues/2488)',
189232
+ "loop-param-shadows-spread-const": "a .map() param shadowing an object const is resolved by `emitSpread` against `localConstants` with no loop-shadow check, so every row spreads the OUTER const instead of the row value (https://github.com/piconic-ai/barefootjs/issues/2489)"
189233
189233
  };
189234
189234
  export {
189235
189235
  renderDivergences,
@@ -1 +1 @@
1
- {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBA0B/B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/jinja",
3
- "version": "0.29.0",
3
+ "version": "0.30.2",
4
4
  "description": "Jinja2 adapter for BarefootJS — compiles IR to .jinja templates and ships the Python BarefootJS rendering runtime; runs under any Python web framework (Flask, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,14 +53,14 @@
53
53
  "directory": "packages/adapter-jinja"
54
54
  },
55
55
  "dependencies": {
56
- "@barefootjs/shared": "0.29.0"
56
+ "@barefootjs/shared": "0.30.2"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@barefootjs/jsx": ">=0.2.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@barefootjs/adapter-tests": "0.1.0",
63
- "@barefootjs/jsx": "0.29.0",
63
+ "@barefootjs/jsx": "0.30.2",
64
64
  "typescript": "^5.0.0"
65
65
  }
66
66
  }
@@ -213,13 +213,13 @@ function C({ rows }: { rows?: number }) {
213
213
 
214
214
  test('leaves a defaulted attr unconditional (scope did not widen)', () => {
215
215
  const { template } = compileAndGenerate(`
216
- function C({ value = '' }: { value?: string }) {
217
- return <textarea value={value} />
216
+ function C({ placeholder = '' }: { placeholder?: string }) {
217
+ return <textarea placeholder={placeholder} />
218
218
  }
219
219
  `)
220
- // `value` has a destructure default → never None → unconditional, exactly
221
- // like Hono's value="".
222
- expect(template).toContain('value="{{ bf.string(value) }}"')
220
+ // `placeholder` has a destructure default → never None → unconditional, exactly
221
+ // like Hono's placeholder="".
222
+ expect(template).toContain('placeholder="{{ bf.string(placeholder) }}"')
223
223
  expect(template).not.toContain('is not none')
224
224
  })
225
225
  })
@@ -146,6 +146,7 @@ import {
146
146
  dangerousInnerHtmlDiagnostic,
147
147
  resolveStaticLoopSource,
148
148
  collectLoopBoundNames,
149
+ derivesScopeFromSlot,
149
150
  } from '@barefootjs/jsx'
150
151
  import { isAriaBooleanAttr, isBooleanResultExpr, isExplicitStringCall } from './boolean-result.ts'
151
152
  import type { ParsedExpr, LoweringMatcher } from '@barefootjs/jsx'
@@ -901,6 +902,15 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
901
902
  // Re-render children now that inLoop is set (so nested components use the
902
903
  // loop-child naming convention). renderedChildren above was computed with
903
904
  // the previous flag; recompute under the loop flag.
905
+
906
+ // Per-row locals for a `.map()` callback preamble (#2447), in source
907
+ // order so a later initializer sees an earlier local — same as the
908
+ // source block. Phase 1 refuses the loop outright when the preamble
909
+ // isn't fully declarable, so there is no partial-lowering case: either
910
+ // every statement is lowered here, or the build already failed.
911
+ const preambleLines = (loop.preamble?.declarations ?? []).map(
912
+ d => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`,
913
+ )
904
914
  const childrenUnderLoop = this.renderChildren(loop.children)
905
915
  this.currentLoopKeyDepth = prevLoopKeyDepth
906
916
  this.inLoop = prevInLoop
@@ -961,9 +971,11 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
961
971
  )
962
972
  }
963
973
  lines.push(`{% if ${filterCond} %}`)
974
+ lines.push(...preambleLines)
964
975
  lines.push(bodyChildren)
965
976
  lines.push(`{% endif %}`)
966
977
  } else {
978
+ lines.push(...preambleLines)
967
979
  lines.push(bodyChildren)
968
980
  }
969
981
 
@@ -1095,10 +1107,7 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
1095
1107
  // SSR (Hono renders neither; the client JS wires them at hydration).
1096
1108
  if ((p.name.match(/^on[A-Z]/) || p.name === 'ref') && p.value.kind === 'expression') continue
1097
1109
  if (p.value.kind === 'jsx-children' && p.name !== 'children') {
1098
- const prevInLoop = this.inLoop
1099
- this.inLoop = false
1100
1110
  const slotBody = this.renderChildren(p.value.children)
1101
- this.inLoop = prevInLoop
1102
1111
  // Purely counter-based — NOT derived from `p.name` or `comp.slotId`.
1103
1112
  // A JSX prop name can contain characters (`data-slot`) that aren't a
1104
1113
  // valid Jinja `{% set %}` target, and `comp.slotId` alone would
@@ -1141,11 +1150,11 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
1141
1150
  if (lowered) currentEntries().push(lowered)
1142
1151
  }
1143
1152
  // Pass slot ID so the child renderer can set correct scope ID for
1144
- // hydration. Skip for loop childrenthey use ComponentName_random.
1145
- // Appended to whatever the trailing entries segment is so a spread's
1146
- // own `_bf_slot`/`children` keys (if any) never win over these
1147
- // compiler-controlled entries.
1148
- if (comp.slotId && !this.inLoop) {
1153
+ // hydration. Skipped for a loop item root it uses ComponentName_random
1154
+ // instead (#2444). Appended to whatever the trailing entries segment is
1155
+ // so a spread's own `_bf_slot`/`children` keys (if any) never win over
1156
+ // these compiler-controlled entries.
1157
+ if (derivesScopeFromSlot(comp)) {
1149
1158
  currentEntries().push(`${jinjaHashKey('_bf_slot')}: '${comp.slotId}'`)
1150
1159
  }
1151
1160
  const tplName = this.toTemplateName(comp.name)
@@ -1166,10 +1175,7 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
1166
1175
  // backend before handing it to the child. See the file header,
1167
1176
  // divergence 4, for why a set-block (not a macro) is the uniform
1168
1177
  // mechanism here.
1169
- const prevInLoop = this.inLoop
1170
- this.inLoop = false
1171
1178
  const childrenBody = this.renderChildren(effectiveChildren)
1172
- this.inLoop = prevInLoop
1173
1179
  const captureName = `bf_children_${comp.slotId ?? 'c' + this.childrenCaptureCounter++}`
1174
1180
  currentEntries().push(`${jinjaHashKey('children')}: ${captureName}`)
1175
1181
  const dict = this.combineComponentPropSegments(segments)
@@ -15,11 +15,6 @@ export const conformancePins: ConformancePins = {
15
15
  // JS-runtime target runs it, a DSL adapter surfaces BF021 + `/* @client */`.
16
16
  // See spec/callback-fidelity.md.
17
17
  'filter-typeof-predicate': [{ code: 'BF021', severity: 'error' }],
18
- // A `.map()` body with a `const`/`let` preamble before its branches:
19
- // a JS runtime folds it, a DSL adapter can't carry the loop-local into a
20
- // conditional branch template, so it refuses with BF021 + `/* @client */`.
21
- // See spec/callback-fidelity.md.
22
- 'map-preamble-branch-body': [{ code: 'BF021', severity: 'error' }],
23
18
  'map-array-builder-body': [{ code: 'BF021', severity: 'error' }],
24
19
  'map-array-builder-escaping': [{ code: 'BF021', severity: 'error' }],
25
20
  // `.fill(value)` mutates the receiver in place — no template lowering
@@ -20,13 +20,24 @@ export const renderDivergences: RenderDivergences = {
20
20
  // instead of a fixed regex-shape catalogue) now correctly seeds `todos`
21
21
  // from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))`.
22
22
 
23
- // #2444: a child component nested inside a dynamic loop row whose root
24
- // is a plain element (`composite` loop plan + `nestedComponents`) is
25
- // rendered through the runtime's `render_child`, which mints its own
26
- // `Badge_<random>` scope id instead of deriving the parent-scope +
27
- // mount-slot id (`test_s0`) the Hono reference emits. Content is
28
- // correct; only `bf-s` diverges. Same class as the `grandchild-
29
- // composition` CSR skip.
30
- 'composite-row-child-component':
31
- '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)',
23
+ // Onboarding TSX-fidelity fixtures (PR #2461): `expectedHtml` is
24
+ // hand-authored to the CORRECT output because the emission bug lives in
25
+ // the shared compiler layer every adapter, including the Hono
26
+ // reference, currently emits the broken form (verified against this
27
+ // adapter's emitted template; see each fixture's docstring). Graduate
28
+ // by fixing the shared emission, regenerating `expectedHtml` from the
29
+ // fixed reference, and deleting these lines (and the matching hono
30
+ // `skipJsx` entries).
31
+ 'aliased-destructured-prop':
32
+ '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)',
33
+ 'composite-row-child-aliased-prop':
34
+ '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)',
35
+
36
+ // #2482 audit follow-ups: loop-scope holes in per-adapter name
37
+ // classification. Graduate by applying the loop-bound-name guards
38
+ // described in each issue and deleting the line.
39
+ 'loop-param-shadows-bool-prop':
40
+ 'a .map() param sharing a boolean prop\'s name is routed through the bool lowering in attribute position (renders "true"/"false" instead of the row string) — `collectBooleanTypedProps` lacks the `collectLoopBoundNames` subtraction its sibling `collectStringValueNames` got in #2236 (https://github.com/piconic-ai/barefootjs/issues/2488)',
41
+ 'loop-param-shadows-spread-const':
42
+ 'a .map() param shadowing an object const is resolved by `emitSpread` against `localConstants` with no loop-shadow check, so every row spreads the OUTER const instead of the row value (https://github.com/piconic-ai/barefootjs/issues/2489)',
32
43
  }