@barefootjs/erb 0.30.4 → 0.30.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"erb-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/erb-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAMP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,EA+BhB,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAoClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAoBvD,qBAAa,UAAW,SAAQ,WAAY,YAAW,aAAa,CAAC,YAAY,CAAC;IAChF,IAAI,SAAQ;IACZ,SAAS,SAAS;IAClB,qBAAqB,UAAO;IAI5B,kBAAkB,EAAG,cAAc,CAAS;IAE5C;;;;;;OAMG;IACH,kBAAkB,EAAE,yBAAyB,CAAyB;IAEtE,OAAO,CAAC,aAAa,CAAa;IAClC;;;;oDAIgD;IAChD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAAsB;IACpC;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB,CAAI;IAC/B;;;;;OAKG;IACH,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CA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AE,MAAM,GAAG,MAAM,CAEvC;IAMD;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA8B5B,OAAO,CAAC,iCAAiC;IAkCzC;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAmBxC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,+BAA+B;IAuBvC;;;;;;;OAOG;IACH,OAAO,KAAK,OAAO,GAWlB;IAED;;;;OAIG;IACH,OAAO,KAAK,SAAS,GAQpB;IAED,sEAAsE;IACtE,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,uBAAuB;IA+E/B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAI9B;uEACmE;IACnE,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,2BAA2B;CAGpC;AAED,eAAO,MAAM,UAAU,YAAmB,CAAA"}
@@ -8,12 +8,13 @@
8
8
  * rather than reading adapter instance state directly.
9
9
  *
10
10
  * `isStringTypedOperand` is byte-identical to the Mojo/Xslate adapters'
11
- * copy. `emitIndexAccessRuby` is ERB-specific: Ruby's `[]` operator is
12
- * syntactically the same for Array and Hash access (unlike Perl's
13
- * `->[]`/`->{}` split), but this runtime's object values are JSON-shaped
14
- * Ruby Hashes with SYMBOL keys so a string-typed index still needs a
15
- * `.to_sym` conversion to become a valid Hash key, while a non-string
16
- * (numeric / loop-index) index passes straight through as an Array index.
11
+ * copy NOTE: this is a stale pre-#2212 fork with no `identifier` arm;
12
+ * Mojo has since migrated to the shared analyzer-backed version. Left
13
+ * as-is here (out of scope for #2491; a separate cleanup).
14
+ * `emitIndexAccessRuby` no longer uses it: it always routes through the
15
+ * runtime's polymorphic `bf.get` helper (#2491) rather than guessing at
16
+ * compile time whether an index is a string key or numeric index — see
17
+ * its own docstring below.
17
18
  */
18
19
  import type { ParsedExpr } from '@barefootjs/jsx';
19
20
  /**
@@ -25,10 +26,19 @@ import type { ParsedExpr } from '@barefootjs/jsx';
25
26
  */
26
27
  export declare function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string) => boolean): boolean;
27
28
  /**
28
- * Lower `arr[index]` to a Ruby `[]` access. A string-typed index reads a
29
- * JSON-shaped Hash by symbol key (`.to_sym`); any other index (the common
30
- * loop-index / arithmetic case, e.g. `selected()[index]`) reads an Array by
31
- * its (already-numeric) value.
29
+ * Lower `arr[index]` to the runtime's polymorphic `bf.get` accessor
30
+ * (`lib/barefoot_js.rb`) rather than guessing at compile time whether
31
+ * `index` is a string key or a numeric index (#2491). Row hashes
32
+ * deserialize with `symbolize_names: true`, so keys are Symbols while a
33
+ * dynamic key (e.g. a destructured `.map()` param used as a key,
34
+ * `tone[k]`) is a runtime String — `isStringTypedOperand` can't see
35
+ * that shape (the shared analyzer types it `{kind:'unknown'}`), so the
36
+ * previous `.to_sym`-or-not compile-time branch guessed wrong for that
37
+ * case and silently returned nil. `bf.get` tries the Hash key as-is,
38
+ * then as a Symbol, then as a String, and falls back to numeric Array
39
+ * indexing — a strict superset of the two hand-picked forms this used
40
+ * to emit, so the common loop-index case (`selected()[index]`) keeps
41
+ * working unchanged.
32
42
  */
33
43
  export declare function emitIndexAccessRuby(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string, isStringName: (n: string) => boolean): string;
34
44
  //# sourceMappingURL=operand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/operand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CASpG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,EAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GACnC,MAAM,CAKR"}
1
+ {"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/operand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CASpG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,EAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GACnC,MAAM,CAER"}
@@ -187741,20 +187741,8 @@ import {
187741
187741
  } from "@barefootjs/jsx";
187742
187742
 
187743
187743
  // src/adapter/expr/operand.ts
187744
- function isStringTypedOperand(expr, isStringName) {
187745
- if (expr.kind === "literal" && expr.literalType === "string")
187746
- return true;
187747
- if (expr.kind === "call" && expr.callee.kind === "identifier" && expr.args.length === 0) {
187748
- return isStringName(expr.callee.name);
187749
- }
187750
- if (expr.kind === "member" && expr.object.kind === "identifier" && expr.object.name === "props") {
187751
- return isStringName(expr.property);
187752
- }
187753
- return false;
187754
- }
187755
187744
  function emitIndexAccessRuby(object, index, emit, isStringName) {
187756
- const i = emit(index);
187757
- return isStringTypedOperand(index, isStringName) ? `${emit(object)}[(${i}).to_sym]` : `${emit(object)}[${i}]`;
187745
+ return `bf.get(${emit(object)}, ${emit(index)})`;
187758
187746
  }
187759
187747
 
187760
187748
  // src/adapter/expr/emitters.ts
@@ -189039,7 +189027,7 @@ ${children}`;
189039
189027
  if (ternaryHash !== null) {
189040
189028
  return `<%= bf.spread_attrs(${ternaryHash}) %>`;
189041
189029
  }
189042
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed)) {
189030
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed) && !this.loopBoundNames.has(trimmed)) {
189043
189031
  const localConst = this.localConstants.find((c) => c.name === trimmed && !c.isModule);
189044
189032
  if (localConst?.value !== undefined) {
189045
189033
  const initTrimmed = localConst.value.trim();
package/dist/build.js CHANGED
@@ -187741,20 +187741,8 @@ import {
187741
187741
  } from "@barefootjs/jsx";
187742
187742
 
187743
187743
  // src/adapter/expr/operand.ts
187744
- function isStringTypedOperand(expr, isStringName) {
187745
- if (expr.kind === "literal" && expr.literalType === "string")
187746
- return true;
187747
- if (expr.kind === "call" && expr.callee.kind === "identifier" && expr.args.length === 0) {
187748
- return isStringName(expr.callee.name);
187749
- }
187750
- if (expr.kind === "member" && expr.object.kind === "identifier" && expr.object.name === "props") {
187751
- return isStringName(expr.property);
187752
- }
187753
- return false;
187754
- }
187755
187744
  function emitIndexAccessRuby(object, index, emit, isStringName) {
187756
- const i = emit(index);
187757
- return isStringTypedOperand(index, isStringName) ? `${emit(object)}[(${i}).to_sym]` : `${emit(object)}[${i}]`;
187745
+ return `bf.get(${emit(object)}, ${emit(index)})`;
187758
187746
  }
187759
187747
 
187760
187748
  // src/adapter/expr/emitters.ts
@@ -189039,7 +189027,7 @@ ${children}`;
189039
189027
  if (ternaryHash !== null) {
189040
189028
  return `<%= bf.spread_attrs(${ternaryHash}) %>`;
189041
189029
  }
189042
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed)) {
189030
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed) && !this.loopBoundNames.has(trimmed)) {
189043
189031
  const localConst = this.localConstants.find((c) => c.name === trimmed && !c.isModule);
189044
189032
  if (localConst?.value !== undefined) {
189045
189033
  const initTrimmed = localConst.value.trim();
package/dist/index.js CHANGED
@@ -187741,20 +187741,8 @@ import {
187741
187741
  } from "@barefootjs/jsx";
187742
187742
 
187743
187743
  // src/adapter/expr/operand.ts
187744
- function isStringTypedOperand(expr, isStringName) {
187745
- if (expr.kind === "literal" && expr.literalType === "string")
187746
- return true;
187747
- if (expr.kind === "call" && expr.callee.kind === "identifier" && expr.args.length === 0) {
187748
- return isStringName(expr.callee.name);
187749
- }
187750
- if (expr.kind === "member" && expr.object.kind === "identifier" && expr.object.name === "props") {
187751
- return isStringName(expr.property);
187752
- }
187753
- return false;
187754
- }
187755
187744
  function emitIndexAccessRuby(object, index, emit, isStringName) {
187756
- const i = emit(index);
187757
- return isStringTypedOperand(index, isStringName) ? `${emit(object)}[(${i}).to_sym]` : `${emit(object)}[${i}]`;
187745
+ return `bf.get(${emit(object)}, ${emit(index)})`;
187758
187746
  }
187759
187747
 
187760
187748
  // src/adapter/expr/emitters.ts
@@ -189039,7 +189027,7 @@ ${children}`;
189039
189027
  if (ternaryHash !== null) {
189040
189028
  return `<%= bf.spread_attrs(${ternaryHash}) %>`;
189041
189029
  }
189042
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed)) {
189030
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed) && !this.loopBoundNames.has(trimmed)) {
189043
189031
  const localConst = this.localConstants.find((c) => c.name === trimmed && !c.isModule);
189044
189032
  if (localConst?.value !== undefined) {
189045
189033
  const initTrimmed = localConst.value.trim();
@@ -189289,9 +189277,7 @@ var conformancePins = {
189289
189277
  };
189290
189278
  // src/render-divergences.ts
189291
189279
  var renderDivergences = {
189292
- "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)",
189293
- "loop-param-shadows-spread-const": "a .map() param shadowing an object const is resolved by `emitSpread` against `localConstants` with no loop-shadow check (the live `loopBoundNames` map exists but is not consulted on this path), so every row spreads the OUTER const instead of the row value (https://github.com/piconic-ai/barefootjs/issues/2489)",
189294
- "loop-param-shadows-record-template-span": 'a dynamic-key element access on a loop row (`tone[k]`) renders empty: row hashes deserialize with SYMBOL keys while the dynamic key is a STRING, so `tone["a"]` is nil (https://github.com/piconic-ai/barefootjs/issues/2491)'
189280
+ "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/2524)"
189295
189281
  };
189296
189282
  export {
189297
189283
  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,iBAwB/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,iBAoB/B,CAAA"}
@@ -772,6 +772,57 @@ module BarefootJS
772
772
  string(recv).each_char.sum { |c| c.ord > 0xFFFF ? 2 : 1 }
773
773
  end
774
774
 
775
+ # Runtime-polymorphic element/key access for `arr[index]` /
776
+ # `hash[key]` (`emitIndexAccessRuby`, expr/operand.ts). Row hashes
777
+ # deserialize with `symbolize_names: true`, so a dynamic key whose
778
+ # runtime value is a String (e.g. a destructured `.map()` param used
779
+ # as a key, `tone[k]`) misses a Symbol-keyed Hash outright -- and the
780
+ # shared analyzer can't tell at compile time whether an index will
781
+ # turn out to be a string key or a numeric index (it types a
782
+ # destructured param `{kind:'unknown'}`), so no compile-time branch
783
+ # can pick the right access form (#2491). Mirrors `getFieldValue`'s
784
+ # (Go adapter, bf.go) case-tolerant lookup and Twig's `attribute()`:
785
+ # for a Hash, try the key as-is, then as a Symbol, then as a String;
786
+ # for an Array, index numerically; anything else has no lookup to
787
+ # perform.
788
+ def get(collection, key)
789
+ return nil if key.nil?
790
+
791
+ case collection
792
+ when Hash
793
+ return collection[key] if collection.key?(key)
794
+
795
+ sym = key.respond_to?(:to_sym) ? key.to_sym : nil
796
+ return collection[sym] if sym && collection.key?(sym)
797
+
798
+ str = key.to_s
799
+ return collection[str] if collection.key?(str)
800
+
801
+ nil
802
+ when Array
803
+ # Only an INTEGRAL index reads an element. `key.to_i` would be
804
+ # wrong on both ends: it coerces a non-numeric String to 0
805
+ # (`arr["nope"]` must be nil, not the first element) and it
806
+ # truncates a fractional number (JS `arr[1.2]` is a property
807
+ # lookup, i.e. undefined -- not index 1).
808
+ idx =
809
+ case key
810
+ when Integer then key
811
+ when Numeric then (key % 1).zero? ? key.to_i : nil
812
+ when String then (key =~ /\A-?\d+\z/ ? key.to_i : nil)
813
+ end
814
+ return nil if idx.nil?
815
+
816
+ # JS-semantics negative index is "not found" (`arr[-1] ===
817
+ # undefined`), NOT Ruby's native from-the-end wraparound -- guard
818
+ # it explicitly so this stays a superset of bracket access rather
819
+ # than a divergent one.
820
+ return nil if idx.negative?
821
+
822
+ collection[idx]
823
+ end
824
+ end
825
+
775
826
  # Mirrors Hono's own CSS-injection guard (`hono/jsx/utils.ts`'s
776
827
  # `hasUnsafeStyleValue` -- the ORACLE a dynamic `style={{...}}` value
777
828
  # must match, #2261): a hand-rolled structural scan for characters that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/erb",
3
- "version": "0.30.4",
3
+ "version": "0.30.6",
4
4
  "description": "ERB (Embedded Ruby) adapter for BarefootJS — compiles IR to .erb templates and ships the Ruby rendering backend; runs under any Rack app (Sinatra, Rails)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,14 +54,14 @@
54
54
  "directory": "packages/adapter-erb"
55
55
  },
56
56
  "dependencies": {
57
- "@barefootjs/shared": "0.30.4"
57
+ "@barefootjs/shared": "0.30.6"
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.30.4",
64
+ "@barefootjs/jsx": "0.30.6",
65
65
  "typescript": "^5.0.0"
66
66
  }
67
67
  }
@@ -1536,7 +1536,12 @@ export class ErbAdapter extends BaseAdapter implements IRNodeEmitter<ErbRenderCt
1536
1536
  // text and route through the same conditional-spread lowering. Only
1537
1537
  // function-scope (`!isModule`) consts whose value is NOT itself a
1538
1538
  // bare identifier (loop guard) are considered.
1539
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed)) {
1539
+ //
1540
+ // `loopBoundNames` guard (#2489): an enclosing `.map()` callback's own
1541
+ // param can shadow this outer const's name (`.map((attrs) => <p
1542
+ // {...attrs} />)`) — without the guard this forwarded the OUTER
1543
+ // const's value at every iteration instead of the per-item value.
1544
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(trimmed) && !this.loopBoundNames.has(trimmed)) {
1540
1545
  const localConst = this.localConstants.find(
1541
1546
  c => c.name === trimmed && !c.isModule,
1542
1547
  )
@@ -8,12 +8,13 @@
8
8
  * rather than reading adapter instance state directly.
9
9
  *
10
10
  * `isStringTypedOperand` is byte-identical to the Mojo/Xslate adapters'
11
- * copy. `emitIndexAccessRuby` is ERB-specific: Ruby's `[]` operator is
12
- * syntactically the same for Array and Hash access (unlike Perl's
13
- * `->[]`/`->{}` split), but this runtime's object values are JSON-shaped
14
- * Ruby Hashes with SYMBOL keys so a string-typed index still needs a
15
- * `.to_sym` conversion to become a valid Hash key, while a non-string
16
- * (numeric / loop-index) index passes straight through as an Array index.
11
+ * copy NOTE: this is a stale pre-#2212 fork with no `identifier` arm;
12
+ * Mojo has since migrated to the shared analyzer-backed version. Left
13
+ * as-is here (out of scope for #2491; a separate cleanup).
14
+ * `emitIndexAccessRuby` no longer uses it: it always routes through the
15
+ * runtime's polymorphic `bf.get` helper (#2491) rather than guessing at
16
+ * compile time whether an index is a string key or numeric index — see
17
+ * its own docstring below.
17
18
  */
18
19
 
19
20
  import type { ParsedExpr } from '@barefootjs/jsx'
@@ -37,10 +38,19 @@ export function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string)
37
38
  }
38
39
 
39
40
  /**
40
- * Lower `arr[index]` to a Ruby `[]` access. A string-typed index reads a
41
- * JSON-shaped Hash by symbol key (`.to_sym`); any other index (the common
42
- * loop-index / arithmetic case, e.g. `selected()[index]`) reads an Array by
43
- * its (already-numeric) value.
41
+ * Lower `arr[index]` to the runtime's polymorphic `bf.get` accessor
42
+ * (`lib/barefoot_js.rb`) rather than guessing at compile time whether
43
+ * `index` is a string key or a numeric index (#2491). Row hashes
44
+ * deserialize with `symbolize_names: true`, so keys are Symbols while a
45
+ * dynamic key (e.g. a destructured `.map()` param used as a key,
46
+ * `tone[k]`) is a runtime String — `isStringTypedOperand` can't see
47
+ * that shape (the shared analyzer types it `{kind:'unknown'}`), so the
48
+ * previous `.to_sym`-or-not compile-time branch guessed wrong for that
49
+ * case and silently returned nil. `bf.get` tries the Hash key as-is,
50
+ * then as a Symbol, then as a String, and falls back to numeric Array
51
+ * indexing — a strict superset of the two hand-picked forms this used
52
+ * to emit, so the common loop-index case (`selected()[index]`) keeps
53
+ * working unchanged.
44
54
  */
45
55
  export function emitIndexAccessRuby(
46
56
  object: ParsedExpr,
@@ -48,8 +58,5 @@ export function emitIndexAccessRuby(
48
58
  emit: (e: ParsedExpr) => string,
49
59
  isStringName: (n: string) => boolean,
50
60
  ): string {
51
- const i = emit(index)
52
- return isStringTypedOperand(index, isStringName)
53
- ? `${emit(object)}[(${i}).to_sym]`
54
- : `${emit(object)}[${i}]`
61
+ return `bf.get(${emit(object)}, ${emit(index)})`
55
62
  }
@@ -20,22 +20,18 @@ 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
- // Onboarding TSX-fidelity fixtures (PR #2461): `expectedHtml` is
24
- // hand-authored to the CORRECT output because the emission bug lives in
23
+ // Onboarding TSX-fidelity fixtures (PR #2461): `expectedHtml` was
24
+ // hand-authored to the CORRECT output while the emission bug lived in
25
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).
26
+ // reference, used to emit the broken form. That shared-layer defect
27
+ // (#2460) is now FIXED (b4f5075): `expectedHtml` is generated from the
28
+ // Hono reference like any other fixture. The remaining gap is
29
+ // per-template-adapter this adapter still keys its template vars /
30
+ // ssr-defaults / props bridge off the local binding instead of
31
+ // `sourceName ?? name` — tracked by #2524 (the 7 silent template
32
+ // adapters). Graduate by applying the same `sourceName ?? name` fix to
33
+ // this adapter's emission path and deleting this line (and the
34
+ // matching hono `skipJsx` entries, already gone).
31
35
  '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
-
34
- // #2482 audit follow-ups: loop-scope holes in per-adapter name
35
- // classification. Graduate by applying the loop-bound-name guards
36
- // described in each issue and deleting the line.
37
- 'loop-param-shadows-spread-const':
38
- 'a .map() param shadowing an object const is resolved by `emitSpread` against `localConstants` with no loop-shadow check (the live `loopBoundNames` map exists but is not consulted on this path), so every row spreads the OUTER const instead of the row value (https://github.com/piconic-ai/barefootjs/issues/2489)',
39
- 'loop-param-shadows-record-template-span':
40
- 'a dynamic-key element access on a loop row (`tone[k]`) renders empty: row hashes deserialize with SYMBOL keys while the dynamic key is a STRING, so `tone["a"]` is nil (https://github.com/piconic-ai/barefootjs/issues/2491)',
36
+ '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/2524)',
41
37
  }