@barefootjs/erb 0.35.2 → 0.35.3

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.
package/dist/vite.js CHANGED
@@ -3421,8 +3421,11 @@ function matchSearchParamsMethodCall(callee, args, localNames) {
3421
3421
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
3422
3422
  import ts19 from "typescript";
3423
3423
 
3424
- // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
3424
+ // ../jsx/src/ir-to-client-js/emit-reactive.ts
3425
3425
  import ts20 from "typescript";
3426
+
3427
+ // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
3428
+ import ts21 from "typescript";
3426
3429
  var NO_PREAMBLE = {
3427
3430
  lazySafe: true,
3428
3431
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -3471,9 +3474,6 @@ var INERT_BINDING_GLOBALS = new Set([
3471
3474
  "decodeURI"
3472
3475
  ]);
3473
3476
 
3474
- // ../jsx/src/ir-to-client-js/emit-reactive.ts
3475
- import ts21 from "typescript";
3476
-
3477
3477
  // ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
3478
3478
  var NON_BUBBLING_EVENTS = new Set([
3479
3479
  "blur",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/erb",
3
- "version": "0.35.2",
3
+ "version": "0.35.3",
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,7 +54,7 @@
54
54
  "directory": "packages/adapter-erb"
55
55
  },
56
56
  "dependencies": {
57
- "@barefootjs/shared": "0.35.2"
57
+ "@barefootjs/shared": "0.35.3"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@barefootjs/jsx": ">=0.2.0",
@@ -71,9 +71,9 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@barefootjs/adapter-tests": "0.1.0",
74
- "@barefootjs/jsx": "0.35.2",
75
- "@barefootjs/vite": "0.35.2",
76
- "@barefootjs/client": "0.35.2",
74
+ "@barefootjs/jsx": "0.35.3",
75
+ "@barefootjs/vite": "0.35.3",
76
+ "@barefootjs/client": "0.35.3",
77
77
  "typescript": "^5.0.0",
78
78
  "vite": "^6.0.0"
79
79
  }
@@ -669,3 +669,59 @@ describe('ErbAdapter - Ruby double-quote escaping order (#2698 review)', () => {
669
669
  expect(rubySymbolKey('a\\"b')).toBe('"a\\\\\\"b":')
670
670
  })
671
671
  })
672
+
673
+ // #2894 — investigated as the ERB sibling of #2883 (Mojolicious) and
674
+ // go-template's own fix in this same PR: `collectStringValueNames`'s
675
+ // string-typed-name witness has the identical missing-alias gap for a
676
+ // bare-props-form BODY-destructured, RENAMED prop (`const { fallbackKey:
677
+ // skipKey } = props`, the #2788 alias family) used as an index-access key.
678
+ // Unlike Mojolicious/go-template, this is NOT a live bug on ERB: since
679
+ // #2491, `emitIndexAccessRuby` (`adapter/expr/operand.ts`) ignores its
680
+ // `isStringName` parameter entirely and always lowers `obj[index]` to the
681
+ // runtime's polymorphic `bf.get(obj, index)` helper (Hash-key-or-Symbol-or-
682
+ // String-or-Array, tried in that order) rather than choosing a lowering at
683
+ // compile time — so the missing witness never reaches a decision point.
684
+ // This test pins that a renamed alias used as an index key resolves
685
+ // correctly end-to-end regardless, as evidence for that closed-out finding
686
+ // (no code change needed here; see the #2894 PR/issue for the full trail).
687
+ describe('ErbAdapter - #2894 index access by a renamed body-destructured prop already works via bf.get', () => {
688
+ test('renders the correct value: bf.get resolves the key regardless of collectStringValueNames', async () => {
689
+ const source = `
690
+ 'use client'
691
+ import { createSignal } from '@barefootjs/client'
692
+
693
+ export function IndexAccessRenamedProp(props: { fallbackKey: string }) {
694
+ const { fallbackKey: skipKey } = props
695
+ const [labels] = createSignal<Record<string, string>>({ a: 'Apple', b: 'Banana' })
696
+ return <div>{labels()[skipKey]}</div>
697
+ }
698
+ `
699
+ let html: string
700
+ try {
701
+ html = await renderErbComponent({
702
+ source,
703
+ adapter: new ErbAdapter(),
704
+ props: { fallbackKey: 'b' },
705
+ })
706
+ } catch (err) {
707
+ if (err instanceof ErbNotAvailableError) return // Ruby toolchain not installed on this host
708
+ throw err
709
+ }
710
+ expect(html).toContain('Banana')
711
+ })
712
+
713
+ test('the emitted template routes through bf.get, not a compile-time Hash/Array branch', () => {
714
+ const ir = compileToIR(`
715
+ 'use client'
716
+ import { createSignal } from '@barefootjs/client'
717
+
718
+ export function IndexAccessRenamedProp(props: { fallbackKey: string }) {
719
+ const { fallbackKey: skipKey } = props
720
+ const [labels] = createSignal<Record<string, string>>({ a: 'Apple', b: 'Banana' })
721
+ return <div>{labels()[skipKey]}</div>
722
+ }
723
+ `)
724
+ const { template } = new ErbAdapter().generate(ir)
725
+ expect(template).toContain('bf.get(v[:labels], v[:skipKey])')
726
+ })
727
+ })