@barefootjs/xslate 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 as collectLoopBoundNames2
187317
+ collectLoopBoundNames as collectLoopBoundNames2,
187318
+ derivesScopeFromSlot
187318
187319
  } from "@barefootjs/jsx";
187319
187320
 
187320
187321
  // src/adapter/boolean-result.ts
@@ -188627,6 +188628,7 @@ ${whenTrue}
188627
188628
  this.inLoop = true;
188628
188629
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188629
188630
  this.currentLoopKeyDepth = loop.depth;
188631
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `: my $${d.name} = ${this.convertExpressionToKolon(d.raw, d.valueParsed)};`);
188630
188632
  const childrenUnderLoop = this.renderChildren(loop.children);
188631
188633
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188632
188634
  this.inLoop = prevInLoop;
@@ -188649,9 +188651,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188649
188651
  filterCond = filterCond.replace(new RegExp(`\\$${loop.filterPredicate.param}\\b`, "g"), `$${param}`);
188650
188652
  }
188651
188653
  lines.push(`: if (${filterCond}) {`);
188654
+ lines.push(...preambleLines);
188652
188655
  lines.push(bodyChildren);
188653
188656
  lines.push(`: }`);
188654
188657
  } else {
188658
+ lines.push(...preambleLines);
188655
188659
  lines.push(bodyChildren);
188656
188660
  }
188657
188661
  lines.push(`: }`);
@@ -188711,10 +188715,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188711
188715
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188712
188716
  continue;
188713
188717
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188714
- const prevInLoop = this.inLoop;
188715
- this.inLoop = false;
188716
188718
  const slotBody = this.renderChildren(p.value.children);
188717
- this.inLoop = prevInLoop;
188718
188719
  const macroName = `bf_prop_${this.childrenCaptureCounter++}`;
188719
188720
  namedSlotMacros.push(`<: macro ${macroName} -> () { :>${slotBody}<: } :>`);
188720
188721
  currentEntries().push(`${kolonHashKey(p.name)} => ${macroName}()`);
@@ -188735,16 +188736,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188735
188736
  if (lowered)
188736
188737
  currentEntries().push(lowered);
188737
188738
  }
188738
- if (comp.slotId && !this.inLoop) {
188739
+ if (derivesScopeFromSlot(comp)) {
188739
188740
  currentEntries().push(`_bf_slot => '${comp.slotId}'`);
188740
188741
  }
188741
188742
  const tplName = this.toTemplateName(comp.name);
188742
188743
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188743
188744
  if (effectiveChildren.length > 0) {
188744
- const prevInLoop = this.inLoop;
188745
- this.inLoop = false;
188746
188745
  const childrenBody = this.renderChildren(effectiveChildren);
188747
- this.inLoop = prevInLoop;
188748
188746
  const macroName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188749
188747
  currentEntries().push(`children => ${macroName}()`);
188750
188748
  const dict = this.combineComponentPropSegments(segments);
@@ -1 +1 @@
1
- {"version":3,"file":"xslate-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/xslate-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;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,EAG1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,EA+BhB,MAAM,iBA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OAAO,CAAC,qBAAqB;IAuB7B,OAAO,CAAC,kCAAkC;IAwB1C;;;;OAIG;IACH,OAAO,CAAC,iCAAiC;IAmBzC;;;;;OAKG;IACH,OAAO,CAAC,+BAA+B;IAuBvC;;;;;;;OAOG;IACH,OAAO,KAAK,OAAO,GAUlB;IAED;;;;;OAKG;IACH,OAAO,KAAK,SAAS,GAQpB;IAED,sEAAsE;IACtE,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,wBAAwB;IAyEhC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAI/B;oEACgE;IAChE,OAAO,CAAC,kBAAkB;IAI1B;;;;;OAKG;IACH;;;;;OAKG;IACH;;;;;OAKG;IACH;;;;OAIG;IACH,8BAA8B,CAC5B,IAAI,EAAE,MAAM,GACX;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAgBlD;IAED,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO3C;IAED;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,yBAAyB;IASjC,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,4BAA4B;CAGrC;AAED,eAAO,MAAM,aAAa,eAAsB,CAAA"}
1
+ {"version":3,"file":"xslate-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/xslate-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;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,EAG1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EAC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AM,CAEvC;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAMD;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAuB7B,OAAO,CAAC,kCAAkC;IAwB1C;;;;OAIG;IACH,OAAO,CAAC,iCAAiC;IAmBzC;;;;;OAKG;IACH,OAAO,CAAC,+BAA+B;IAuBvC;;;;;;;OAOG;IACH,OAAO,KAAK,OAAO,GAUlB;IAED;;;;;OAKG;IACH,OAAO,KAAK,SAAS,GAQpB;IAED,sEAAsE;IACtE,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,wBAAwB;IAyEhC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAI/B;oEACgE;IAChE,OAAO,CAAC,kBAAkB;IAI1B;;;;;OAKG;IACH;;;;;OAKG;IACH;;;;;OAKG;IACH;;;;OAIG;IACH,8BAA8B,CAC5B,IAAI,EAAE,MAAM,GACX;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAgBlD;IAED,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO3C;IAED;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,yBAAyB;IASjC,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,4BAA4B;CAGrC;AAED,eAAO,MAAM,aAAa,eAAsB,CAAA"}
package/dist/build.js CHANGED
@@ -187314,7 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames as collectLoopBoundNames2
187317
+ collectLoopBoundNames as collectLoopBoundNames2,
187318
+ derivesScopeFromSlot
187318
187319
  } from "@barefootjs/jsx";
187319
187320
 
187320
187321
  // src/adapter/boolean-result.ts
@@ -188627,6 +188628,7 @@ ${whenTrue}
188627
188628
  this.inLoop = true;
188628
188629
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188629
188630
  this.currentLoopKeyDepth = loop.depth;
188631
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `: my $${d.name} = ${this.convertExpressionToKolon(d.raw, d.valueParsed)};`);
188630
188632
  const childrenUnderLoop = this.renderChildren(loop.children);
188631
188633
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188632
188634
  this.inLoop = prevInLoop;
@@ -188649,9 +188651,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188649
188651
  filterCond = filterCond.replace(new RegExp(`\\$${loop.filterPredicate.param}\\b`, "g"), `$${param}`);
188650
188652
  }
188651
188653
  lines.push(`: if (${filterCond}) {`);
188654
+ lines.push(...preambleLines);
188652
188655
  lines.push(bodyChildren);
188653
188656
  lines.push(`: }`);
188654
188657
  } else {
188658
+ lines.push(...preambleLines);
188655
188659
  lines.push(bodyChildren);
188656
188660
  }
188657
188661
  lines.push(`: }`);
@@ -188711,10 +188715,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188711
188715
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188712
188716
  continue;
188713
188717
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188714
- const prevInLoop = this.inLoop;
188715
- this.inLoop = false;
188716
188718
  const slotBody = this.renderChildren(p.value.children);
188717
- this.inLoop = prevInLoop;
188718
188719
  const macroName = `bf_prop_${this.childrenCaptureCounter++}`;
188719
188720
  namedSlotMacros.push(`<: macro ${macroName} -> () { :>${slotBody}<: } :>`);
188720
188721
  currentEntries().push(`${kolonHashKey(p.name)} => ${macroName}()`);
@@ -188735,16 +188736,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188735
188736
  if (lowered)
188736
188737
  currentEntries().push(lowered);
188737
188738
  }
188738
- if (comp.slotId && !this.inLoop) {
188739
+ if (derivesScopeFromSlot(comp)) {
188739
188740
  currentEntries().push(`_bf_slot => '${comp.slotId}'`);
188740
188741
  }
188741
188742
  const tplName = this.toTemplateName(comp.name);
188742
188743
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188743
188744
  if (effectiveChildren.length > 0) {
188744
- const prevInLoop = this.inLoop;
188745
- this.inLoop = false;
188746
188745
  const childrenBody = this.renderChildren(effectiveChildren);
188747
- this.inLoop = prevInLoop;
188748
188746
  const macroName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188749
188747
  currentEntries().push(`children => ${macroName}()`);
188750
188748
  const dict = this.combineComponentPropSegments(segments);
@@ -1 +1 @@
1
- {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA8J7B,CAAA"}
1
+ {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAyJ7B,CAAA"}
package/dist/index.js CHANGED
@@ -187314,7 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames as collectLoopBoundNames2
187317
+ collectLoopBoundNames as collectLoopBoundNames2,
187318
+ derivesScopeFromSlot
187318
187319
  } from "@barefootjs/jsx";
187319
187320
 
187320
187321
  // src/adapter/boolean-result.ts
@@ -188627,6 +188628,7 @@ ${whenTrue}
188627
188628
  this.inLoop = true;
188628
188629
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188629
188630
  this.currentLoopKeyDepth = loop.depth;
188631
+ const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `: my $${d.name} = ${this.convertExpressionToKolon(d.raw, d.valueParsed)};`);
188630
188632
  const childrenUnderLoop = this.renderChildren(loop.children);
188631
188633
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188632
188634
  this.inLoop = prevInLoop;
@@ -188649,9 +188651,11 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188649
188651
  filterCond = filterCond.replace(new RegExp(`\\$${loop.filterPredicate.param}\\b`, "g"), `$${param}`);
188650
188652
  }
188651
188653
  lines.push(`: if (${filterCond}) {`);
188654
+ lines.push(...preambleLines);
188652
188655
  lines.push(bodyChildren);
188653
188656
  lines.push(`: }`);
188654
188657
  } else {
188658
+ lines.push(...preambleLines);
188655
188659
  lines.push(bodyChildren);
188656
188660
  }
188657
188661
  lines.push(`: }`);
@@ -188711,10 +188715,7 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188711
188715
  if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
188712
188716
  continue;
188713
188717
  if (p.value.kind === "jsx-children" && p.name !== "children") {
188714
- const prevInLoop = this.inLoop;
188715
- this.inLoop = false;
188716
188718
  const slotBody = this.renderChildren(p.value.children);
188717
- this.inLoop = prevInLoop;
188718
188719
  const macroName = `bf_prop_${this.childrenCaptureCounter++}`;
188719
188720
  namedSlotMacros.push(`<: macro ${macroName} -> () { :>${slotBody}<: } :>`);
188720
188721
  currentEntries().push(`${kolonHashKey(p.name)} => ${macroName}()`);
@@ -188735,16 +188736,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
188735
188736
  if (lowered)
188736
188737
  currentEntries().push(lowered);
188737
188738
  }
188738
- if (comp.slotId && !this.inLoop) {
188739
+ if (derivesScopeFromSlot(comp)) {
188739
188740
  currentEntries().push(`_bf_slot => '${comp.slotId}'`);
188740
188741
  }
188741
188742
  const tplName = this.toTemplateName(comp.name);
188742
188743
  const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
188743
188744
  if (effectiveChildren.length > 0) {
188744
- const prevInLoop = this.inLoop;
188745
- this.inLoop = false;
188746
188745
  const childrenBody = this.renderChildren(effectiveChildren);
188747
- this.inLoop = prevInLoop;
188748
188746
  const macroName = `bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`;
188749
188747
  currentEntries().push(`children => ${macroName}()`);
188750
188748
  const dict = this.combineComponentPropSegments(segments);
@@ -189141,7 +189139,6 @@ var xslateAdapter = new XslateAdapter;
189141
189139
  // src/conformance-pins.ts
189142
189140
  var conformancePins = {
189143
189141
  "filter-typeof-predicate": [{ code: "BF021", severity: "error" }],
189144
- "map-preamble-branch-body": [{ code: "BF021", severity: "error" }],
189145
189142
  "map-array-builder-body": [{ code: "BF021", severity: "error" }],
189146
189143
  "map-array-builder-escaping": [{ code: "BF021", severity: "error" }],
189147
189144
  "fill-unsupported": [{ code: "BF101", severity: "error" }],
@@ -189169,7 +189166,10 @@ var conformancePins = {
189169
189166
  };
189170
189167
  // src/render-divergences.ts
189171
189168
  var renderDivergences = {
189172
- "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)"
189169
+ "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)",
189170
+ "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)",
189171
+ "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)',
189172
+ "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)"
189173
189173
  };
189174
189174
  export {
189175
189175
  xslateAdapter,
@@ -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"}
@@ -1,5 +1,5 @@
1
1
  package BarefootJS::Backend::Xslate;
2
- our $VERSION = "0.28.1";
2
+ our $VERSION = "0.30.0";
3
3
  use strict;
4
4
  use warnings;
5
5
  use utf8;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/xslate",
3
- "version": "0.29.0",
3
+ "version": "0.30.2",
4
4
  "description": "Text::Xslate (Kolon) adapter for BarefootJS — compiles IR to .tx templates and ships the Xslate rendering backend; runs under any PSGI/Plack app",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -55,14 +55,14 @@
55
55
  "directory": "packages/adapter-xslate"
56
56
  },
57
57
  "dependencies": {
58
- "@barefootjs/shared": "0.29.0"
58
+ "@barefootjs/shared": "0.30.2"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@barefootjs/jsx": ">=0.2.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@barefootjs/adapter-tests": "0.1.0",
65
- "@barefootjs/jsx": "0.29.0",
65
+ "@barefootjs/jsx": "0.30.2",
66
66
  "typescript": "^5.0.0"
67
67
  }
68
68
  }
@@ -206,13 +206,13 @@ function C({ rows }: { rows?: number }) {
206
206
 
207
207
  test('leaves a defaulted attr unconditional (scope did not widen)', () => {
208
208
  const { template } = compileAndGenerate(`
209
- function C({ value = '' }: { value?: string }) {
210
- return <textarea value={value} />
209
+ function C({ placeholder = '' }: { placeholder?: string }) {
210
+ return <textarea placeholder={placeholder} />
211
211
  }
212
212
  `)
213
- // `value` has a destructure default → never undef → unconditional, exactly
214
- // like Hono's value="".
215
- expect(template).toContain('value="<: $value :>"')
216
- expect(template).not.toContain('defined $value')
213
+ // `placeholder` has a destructure default → never undef → unconditional, exactly
214
+ // like Hono's placeholder="".
215
+ expect(template).toContain('placeholder="<: $placeholder :>"')
216
+ expect(template).not.toContain('defined $placeholder')
217
217
  })
218
218
  })
@@ -79,6 +79,7 @@ import {
79
79
  dangerousInnerHtmlDiagnostic,
80
80
  resolveStaticLoopSource,
81
81
  collectLoopBoundNames,
82
+ derivesScopeFromSlot,
82
83
  } from '@barefootjs/jsx'
83
84
  import { isAriaBooleanAttr, isBooleanResultExpr } from './boolean-result.ts'
84
85
  import ts from 'typescript'
@@ -879,6 +880,15 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
879
880
  // Re-render children now that inLoop is set (so nested components use the
880
881
  // loop-child naming convention). renderedChildren above was computed with
881
882
  // the previous flag; recompute under the loop flag.
883
+
884
+ // Per-row locals for a `.map()` callback preamble (#2447), in source
885
+ // order so a later initializer sees an earlier local — same as the
886
+ // source block. Phase 1 refuses the loop outright when the preamble
887
+ // isn't fully declarable, so there is no partial-lowering case: either
888
+ // every statement is lowered here, or the build already failed.
889
+ const preambleLines = (loop.preamble?.declarations ?? []).map(
890
+ d => `: my $${d.name} = ${this.convertExpressionToKolon(d.raw, d.valueParsed)};`,
891
+ )
882
892
  const childrenUnderLoop = this.renderChildren(loop.children)
883
893
  this.currentLoopKeyDepth = prevLoopKeyDepth
884
894
  this.inLoop = prevInLoop
@@ -933,9 +943,11 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
933
943
  )
934
944
  }
935
945
  lines.push(`: if (${filterCond}) {`)
946
+ lines.push(...preambleLines)
936
947
  lines.push(bodyChildren)
937
948
  lines.push(`: }`)
938
949
  } else {
950
+ lines.push(...preambleLines)
939
951
  lines.push(bodyChildren)
940
952
  }
941
953
 
@@ -1066,10 +1078,7 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
1066
1078
  // SSR (Hono renders neither; the client JS wires them at hydration).
1067
1079
  if ((p.name.match(/^on[A-Z]/) || p.name === 'ref') && p.value.kind === 'expression') continue
1068
1080
  if (p.value.kind === 'jsx-children' && p.name !== 'children') {
1069
- const prevInLoop = this.inLoop
1070
- this.inLoop = false
1071
1081
  const slotBody = this.renderChildren(p.value.children)
1072
- this.inLoop = prevInLoop
1073
1082
  // Purely counter-based — NOT derived from `p.name` or `comp.slotId`.
1074
1083
  // A JSX prop name can contain characters (`data-slot`) that aren't a
1075
1084
  // valid Kolon macro identifier, and `comp.slotId` alone would
@@ -1111,11 +1120,11 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
1111
1120
  if (lowered) currentEntries().push(lowered)
1112
1121
  }
1113
1122
  // Pass slot ID so the child renderer can set correct scope ID for
1114
- // hydration. Skip for loop childrenthey use ComponentName_random.
1115
- // Appended to whatever the trailing entries segment is so a spread's
1116
- // own `_bf_slot`/`children` keys (if any) never win over these
1117
- // compiler-controlled entries.
1118
- if (comp.slotId && !this.inLoop) {
1123
+ // hydration. Skipped for a loop item root it uses ComponentName_random
1124
+ // instead (#2444). Appended to whatever the trailing entries segment is
1125
+ // so a spread's own `_bf_slot`/`children` keys (if any) never win over
1126
+ // these compiler-controlled entries.
1127
+ if (derivesScopeFromSlot(comp)) {
1119
1128
  currentEntries().push(`_bf_slot => '${comp.slotId}'`)
1120
1129
  }
1121
1130
  const tplName = this.toTemplateName(comp.name)
@@ -1133,10 +1142,7 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
1133
1142
  // children HTML; the macro call result is passed as the `children` entry
1134
1143
  // of the render_child hashref. `render_child` materializes a CODE-ref
1135
1144
  // children value through the backend before handing it to the child.
1136
- const prevInLoop = this.inLoop
1137
- this.inLoop = false
1138
1145
  const childrenBody = this.renderChildren(effectiveChildren)
1139
- this.inLoop = prevInLoop
1140
1146
  const macroName = `bf_children_${comp.slotId ?? 'c' + this.childrenCaptureCounter++}`
1141
1147
  currentEntries().push(`children => ${macroName}()`)
1142
1148
  const dict = this.combineComponentPropSegments(segments)
@@ -13,11 +13,6 @@ export const conformancePins: ConformancePins = {
13
13
  // JS-runtime target runs it, a DSL adapter surfaces BF021 + `/* @client */`.
14
14
  // See spec/callback-fidelity.md.
15
15
  'filter-typeof-predicate': [{ code: 'BF021', severity: 'error' }],
16
- // A `.map()` body with a `const`/`let` preamble before its branches:
17
- // a JS runtime folds it, a DSL adapter can't carry the loop-local into a
18
- // conditional branch template, so it refuses with BF021 + `/* @client */`.
19
- // See spec/callback-fidelity.md.
20
- 'map-preamble-branch-body': [{ code: 'BF021', severity: 'error' }],
21
16
  'map-array-builder-body': [{ code: 'BF021', severity: 'error' }],
22
17
  'map-array-builder-escaping': [{ code: 'BF021', severity: 'error' }],
23
18
  // `.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
  }