@barefootjs/jsx 0.39.1 → 0.39.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.
Files changed (41) hide show
  1. package/dist/adapters/parsed-expr-emitter.d.ts +2 -2
  2. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  3. package/dist/analyzer.d.ts.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1267 -1078
  7. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  8. package/dist/ir-to-client-js/safe-html.d.ts +1 -1
  9. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  10. package/dist/jsx-to-ir.d.ts.map +1 -1
  11. package/dist/literal-member-index.d.ts +6 -0
  12. package/dist/literal-member-index.d.ts.map +1 -0
  13. package/dist/scope/binding-scope.d.ts +11 -0
  14. package/dist/scope/binding-scope.d.ts.map +1 -1
  15. package/dist/signal-prop-name-collision.d.ts +20 -0
  16. package/dist/signal-prop-name-collision.d.ts.map +1 -0
  17. package/dist/ssr-defaults.d.ts.map +1 -1
  18. package/dist/ssr-seed-plan.d.ts +3 -2
  19. package/dist/ssr-seed-plan.d.ts.map +1 -1
  20. package/package.json +2 -2
  21. package/src/__tests__/binding-scope.test.ts +27 -0
  22. package/src/__tests__/client-template-escape-soundness.test.ts +17 -0
  23. package/src/__tests__/conditional-nested-loop-bindings.test.ts +41 -0
  24. package/src/__tests__/destructured-from-props-localconst-value.test.ts +3 -2
  25. package/src/__tests__/literal-member-index.test.ts +14 -0
  26. package/src/__tests__/signal-prop-name-collision.test.ts +171 -0
  27. package/src/__tests__/ssr-defaults.test.ts +6 -7
  28. package/src/__tests__/ssr-seed-plan.test.ts +23 -0
  29. package/src/__tests__/staged-ir/02-shadow-guards.test.ts +1 -1
  30. package/src/__tests__/staged-ir/08-relocate-unit.test.ts +6 -3
  31. package/src/adapters/parsed-expr-emitter.ts +3 -3
  32. package/src/analyzer.ts +10 -0
  33. package/src/index.ts +1 -0
  34. package/src/ir-to-client-js/collect-elements.ts +8 -9
  35. package/src/ir-to-client-js/safe-html.ts +19 -6
  36. package/src/jsx-to-ir.ts +14 -2
  37. package/src/literal-member-index.ts +12 -0
  38. package/src/scope/binding-scope.ts +31 -1
  39. package/src/signal-prop-name-collision.ts +164 -0
  40. package/src/ssr-defaults.ts +3 -5
  41. package/src/ssr-seed-plan.ts +14 -2
@@ -1 +1 @@
1
- {"version":3,"file":"collect-elements.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/collect-elements.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAwD,KAAK,MAAM,EAAmC,MAAM,aAAa,CAAA;AAC7I,OAAO,KAAK,EAAE,eAAe,EAA+H,iBAAiB,EAA0B,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvQ,OAAO,EAAkF,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAS/H,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAmG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA0C7E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAYzF;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,EAAE,w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liceContext {
149
149
  * 6. otherwise → `escapedText`
150
150
  *
151
151
  * Arm 5 tests BOTH `node.expr` (the original source text, stable across
152
- * builders) and the caller's resolved form (parens stripped): a
152
+ * builders) and the caller's resolved form (with parentheses handled structurally): a
153
153
  * destructured-and-renamed children (`const { children: kids } = props`)
154
154
  * reads `kids` in the source and `(_p.children)` after substitution, and
155
155
  * either alone misses one of the two shapes (#2786).
@@ -1 +1 @@
1
- {"version":3,"file":"safe-html.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/safe-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,eAAe,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA;AAO3E;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAE7C;AAQD,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAE1D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAExE;AAOD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAErD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAEnG;AAED;;;;;;GAM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E,MAAM,GAAG,QAAQ,GAAG,gBAAgB,CAAC,EAC9D,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,kBAAkB,GACrB,QAAQ,CAUV"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-to-ir.d.ts","sourceRoot":"","sources":["../src/jsx-to-ir.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,KAAK,MAAM,EAgCZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,eAAe,EAA0E,MAAM,uBAAuB,CAAA;AAunCpI,wBAAgB,OAAO,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAchE"}
1
+ {"version":3,"file":"jsx-to-ir.d.ts","sourceRoot":"","sources":["../src/jsx-to-ir.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,KAAK,MAAM,EAgCZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,eAAe,EAA4F,MAAM,uBAAuB,CAAA;AAunCtJ,wBAAgB,OAAO,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAchE"}
@@ -0,0 +1,6 @@
1
+ import type { ParsedExpr } from './expression-parser.ts';
2
+ /** Recover an index operand from a computed member's property key.
3
+ * Only canonical array indices become numbers: keys such as "01" must
4
+ * remain strings. Both `obj[0]` and `obj['0']` use the same JS key. */
5
+ export declare function literalMemberIndex(property: string): ParsedExpr;
6
+ //# sourceMappingURL=literal-member-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal-member-index.d.ts","sourceRoot":"","sources":["../src/literal-member-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAM/D"}
@@ -37,6 +37,7 @@
37
37
  export type ScopeBindingSource = 'item' | 'index' | 'destructure' | 'preamble' | 'param';
38
38
  export interface ScopeBinding {
39
39
  readonly source: ScopeBindingSource;
40
+ readonly stringValue?: boolean;
40
41
  }
41
42
  export interface ScopeFrame {
42
43
  readonly kind: 'loop-row' | 'callback';
@@ -50,6 +51,7 @@ export interface ScopeFrame {
50
51
  */
51
52
  export interface LoopBindingSource {
52
53
  readonly param: string;
54
+ readonly itemType?: LoopValueType | null;
53
55
  readonly index?: string | null;
54
56
  readonly paramBindings?: readonly {
55
57
  readonly name: string;
@@ -58,6 +60,10 @@ export interface LoopBindingSource {
58
60
  readonly declaredNames: readonly string[];
59
61
  } | null;
60
62
  }
63
+ interface LoopValueType {
64
+ readonly primitive?: string;
65
+ readonly unionTypes?: readonly LoopValueType[];
66
+ }
61
67
  /**
62
68
  * A stack of `ScopeFrame`s, innermost frame at index 0 of the internal
63
69
  * array (i.e. `frames[0]` is what `enterLoopRow`/`enterCallback` most
@@ -114,6 +120,10 @@ export declare class BindingScope {
114
120
  enterCallback(params: readonly string[]): BindingScope;
115
121
  /** Innermost-first membership check across every frame in the stack. */
116
122
  isBound(name: string): boolean;
123
+ /** Resolve string typing at this position, respecting the nearest binding. */
124
+ isStringValueName(name: string, outer: (name: string) => boolean, componentProperty?: boolean): boolean;
125
+ /** Names this frame shadows in an enclosing callback/row frame. */
126
+ shadowedNames(): readonly string[];
117
127
  /**
118
128
  * Resolves `name` against the frame stack innermost-first. `depth 0`
119
129
  * means the innermost (most recently entered) frame; `null` when `name`
@@ -176,4 +186,5 @@ export declare class BindingScope {
176
186
  */
177
187
  asShadowPredicate(): (name: string) => boolean;
178
188
  }
189
+ export {};
179
190
  //# sourceMappingURL=binding-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding-scope.d.ts","sourceRoot":"","sources":["../../src/scope/binding-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GA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;;;;OAgCG;IACH,eAAe,IAAI,WAAW,CAAC,MAAM,CAAC,CAYrC;IAED;;;OAGG;IACH,iBAAiB,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAE7C;CACF"}
@@ -0,0 +1,20 @@
1
+ import ts from 'typescript';
2
+ import type { AnalyzerContext } from './analyzer-context.ts';
3
+ /** Preserve a build-supplied Program's virtual files and resolution options
4
+ * when one root's source changes. Other SourceFiles remain untouched. */
5
+ export declare function programWithSeparatedSource(program: ts.Program, filePath: string, source: string): ts.Program;
6
+ /**
7
+ * A bare prop and a literal-seeded getter are different JS bindings, but
8
+ * scalar template backends flatten both to one variable. Give the local
9
+ * getter a hygienic name before building IR, so every backend (including
10
+ * the client emitter) receives one consistent binding identity.
11
+ *
12
+ * Source edits are AST/symbol-based and preserve untouched source bytes.
13
+ * Property keys, strings, and shadowing callback bindings never rename;
14
+ * shorthand values expand without changing their public keys. The rare
15
+ * collision-only path reuses the analyzer's checker when available. Its
16
+ * fallback binds the already-parsed SourceFile without parsing or loading
17
+ * dependencies: only lexical symbol identity is needed, not types.
18
+ */
19
+ export declare function separateLiteralSignalPropBindings(ctx: AnalyzerContext, isNonReference: (id: ts.Identifier) => boolean): string | null;
20
+ //# sourceMappingURL=signal-prop-name-collision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-prop-name-collision.d.ts","sourceRoot":"","sources":["../src/signal-prop-name-collision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAa5D;yEACyE;AACzE,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,OAAO,CAgD5G;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,KAAK,OAAO,GAC7C,MAAM,GAAG,IAAI,CAsEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-defaults.d.ts","sourceRoot":"","sources":["../src/ssr-defaults.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAA;IACd;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB;AAkBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,CAuQ/F"}
1
+ {"version":3,"file":"ssr-defaults.d.ts","sourceRoot":"","sources":["../src/ssr-defaults.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAA;IACd;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB;AAkBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,CAqQ/F"}
@@ -10,7 +10,8 @@
10
10
  *
11
11
  * Ordering / acyclicity guarantee: `steps` lists the component's signals
12
12
  * first, then its memos, each group in declaration order (matching
13
- * `IRMetadata.signals` / `IRMetadata.memos`). A binding's name only enters
13
+ * `IRMetadata.signals` / `IRMetadata.memos`), then canonical getter aliases.
14
+ * A binding's name only enters
14
15
  * the scope set AFTER its own step is decided, so a `derived` step's `frees`
15
16
  * can only name `baseScope` entries or EARLIER steps — self- and
16
17
  * forward-references are rejected by construction, and a consumer emitting
@@ -33,7 +34,7 @@ import { type EnvSignalReader } from './adapters/env-signal.ts';
33
34
  import { type ParsedExpr } from './expression-parser.ts';
34
35
  import type { IRMetadata } from './types.ts';
35
36
  /**
36
- * One binding in component declaration order (signals first, then memos —
37
+ * One binding in dependency order (signals, memos, then getter aliases —
37
38
  * matching `IRMetadata` order and the adapters' iteration).
38
39
  *
39
40
  * - `env-reader`: an env signal whose `envReader` key resolves in the shared
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-seed-plan.d.ts","sourceRoot":"","sources":["../src/ssr-seed-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;;;;;;;;;;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,GAAG,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAC/G;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAA;CAAE,CAAA;AAE/D,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB;AAiGD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAqFpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/jsx",
3
- "version": "0.39.1",
3
+ "version": "0.39.2",
4
4
  "description": "JSX compiler for BarefootJS - transforms JSX to server HTML + client JS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "directory": "packages/jsx"
50
50
  },
51
51
  "dependencies": {
52
- "@barefootjs/shared": "0.39.1"
52
+ "@barefootjs/shared": "0.39.2"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@barefootjs/client": ">=0.2.0",
@@ -198,3 +198,30 @@ describe('BindingScope', () => {
198
198
  })
199
199
  })
200
200
  })
201
+
202
+ describe('scoped string value types', () => {
203
+ test('nested string rows retain outer types; numeric shadows and indexes do not inherit them', () => {
204
+ const outer = BindingScope.EMPTY.enterLoopRow({ param: 'item', itemType: { primitive: 'string' } })
205
+ const inner = outer.enterLoopRow({ param: 'choice', index: 'i', itemType: { primitive: 'string' } })
206
+ expect(inner.isStringValueName('item', () => false)).toBe(true)
207
+ expect(inner.isStringValueName('choice', () => false)).toBe(true)
208
+ expect(inner.isStringValueName('choice', () => false, true)).toBe(false)
209
+ expect(inner.isStringValueName('i', () => true)).toBe(false)
210
+ const shadow = inner.enterLoopRow({ param: 'item', itemType: { primitive: 'number' } })
211
+ expect(shadow.isStringValueName('item', () => true)).toBe(false)
212
+ expect(shadow.shadowedNames()).toEqual(['item'])
213
+ expect(inner.shadowedNames()).toEqual([])
214
+ expect(outer.isStringValueName('item', () => false)).toBe(true)
215
+ expect(inner.isStringValueName('title', () => true)).toBe(true)
216
+ })
217
+ test('a union of string literals is string-valued; mixed unions are not', () => {
218
+ const stringRow = BindingScope.EMPTY.enterLoopRow({ param: 'row', itemType: {
219
+ unionTypes: [{ primitive: 'string' }, { primitive: 'string' }],
220
+ } })
221
+ expect(stringRow.isStringValueName('row', () => false)).toBe(true)
222
+ const mixedRow = stringRow.enterLoopRow({ param: 'row', itemType: {
223
+ unionTypes: [{ primitive: 'string' }, { primitive: 'number' }],
224
+ } })
225
+ expect(mixedRow.isStringValueName('row', () => true)).toBe(false)
226
+ })
227
+ })
@@ -170,6 +170,23 @@ export function Box(props: { children?: any }) {
170
170
  }`,
171
171
  pin: (js) => expect(js).toContain('${markupOrEmpty((_p.children))}'),
172
172
  },
173
+ {
174
+ id: 'children-nullish-empty-fallback',
175
+ source: `
176
+ export function Box(props: { children?: unknown }) {
177
+ const { children: kids } = props
178
+ return <div>{(kids) ?? ''}</div>
179
+ }`,
180
+ pin: (js) => expect(js).toContain('markupOrEmpty('),
181
+ },
182
+ {
183
+ id: 'children-nullish-text-fallback',
184
+ source: `
185
+ export function Box(props: { children?: unknown }) {
186
+ return <div>{props.children ?? '<b>text</b>'}</div>
187
+ }`,
188
+ pin: (js) => expect(js).toContain('escapeText('),
189
+ },
173
190
  {
174
191
  // The author-facing escape hatch, by name.
175
192
  id: 'dangerously-set-inner-html',
@@ -0,0 +1,41 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import { compileJSX } from '../compiler'
3
+ import { TestAdapter } from '../adapters/test-adapter'
4
+
5
+ // The branch collector must retain each inner row's own binding scope,
6
+ // independently of whether either source array is reactive.
7
+ describe('nested conditional-branch loop binding collection (#3274)', () => {
8
+ for (const signalOuter of [false, true]) {
9
+ for (const signalInner of [false, true]) {
10
+ test(`outer signal=${signalOuter}, inner signal=${signalInner}`, () => {
11
+ const source = `
12
+ 'use client'
13
+ import { createSignal } from '@barefootjs/client'
14
+ const GROUPS = ['a', 'b']
15
+ const CHOICES = ['1', '2']
16
+ export function BranchChoices() {
17
+ const [open] = createSignal(true)
18
+ const [picked] = createSignal('a1')
19
+ const [groups] = createSignal(GROUPS)
20
+ const [choices] = createSignal(CHOICES)
21
+ return <section>{open() ? <div>
22
+ {${signalOuter ? 'groups()' : 'GROUPS'}.map(group => <div key={group}>
23
+ {${signalInner ? 'choices()' : 'CHOICES'}.map(choice =>
24
+ <button key={choice} aria-checked={picked() === group + choice ? 'true' : 'false'}>
25
+ {picked() === group + choice ? 'on' : 'off'}
26
+ </button>)}
27
+ </div>)}
28
+ </div> : null}</section>
29
+ }
30
+ `
31
+ const result = compileJSX(source, 'BranchChoices.tsx', { adapter: new TestAdapter() })
32
+ expect(result.errors.filter(e => e.severity === 'error')).toEqual([])
33
+ const js = result.files.find(f => f.type === 'clientJs')!.content
34
+ expect(js).toContain('mapArray(() =>')
35
+ expect(js).toContain("setAttribute('aria-checked'")
36
+ expect(js).toContain("insert(__innerEl1_0, 's1', () => picked() === group() + choice()")
37
+ expect(js).toContain('group() + choice()')
38
+ })
39
+ }
40
+ }
41
+ })
@@ -77,8 +77,9 @@ describe('destructured-from-props-object → localConstants value rewrite', () =
77
77
  const clientJs = result.files.find((f) => f.type === 'clientJs')
78
78
  const content = clientJs?.content ?? ''
79
79
 
80
- // `count` is the signal getter — must stay as `count()`, not `_p.count()`
81
- expect(content).toMatch(/const\s+doubled\s*=\s*count\(\)\s*\*\s*2/)
80
+ // The signal remains a local getter (now hygienically distinct from
81
+ // the bare prop), never a read/call of the caller's `_p.count`.
82
+ expect(content).toMatch(/const\s+doubled\s*=\s*bfSignal_count\(\)\s*\*\s*2/)
82
83
  expect(content).not.toMatch(/const\s+doubled\s*=\s*_p\.count\(\)/)
83
84
  })
84
85
 
@@ -0,0 +1,14 @@
1
+ import { expect, test } from 'bun:test'
2
+ import { literalMemberIndex } from '../literal-member-index.ts'
3
+
4
+ test('canonical array indices share the numeric index path', () => {
5
+ for (const property of ['0', '1', '4294967294']) {
6
+ expect(literalMemberIndex(property)).toEqual({ kind: 'literal', value: Number(property), literalType: 'number' })
7
+ }
8
+ })
9
+
10
+ test('non-index keys retain their exact spelling', () => {
11
+ for (const property of ['data-x', '01', '', '-1', '1.5', '1e2', '4294967295', "it's", 'a\\b']) {
12
+ expect(literalMemberIndex(property)).toEqual({ kind: 'literal', value: property, literalType: 'string' })
13
+ }
14
+ })
@@ -0,0 +1,171 @@
1
+ import { expect, test } from 'bun:test'
2
+ import ts from 'typescript'
3
+ import { analyzeComponent } from '../analyzer.ts'
4
+ import { compileJSX } from '../compiler.ts'
5
+ import { programWithSeparatedSource } from '../signal-prop-name-collision.ts'
6
+ import { TestAdapter } from '../adapters/test-adapter.ts'
7
+ import { fixture } from '../../../adapter-tests/fixtures/signal-literal-prop-name-collision.ts'
8
+
9
+ test('literal-seeded signal and bare prop have independent binding names', () => {
10
+ const ctx = analyzeComponent(fixture.source, 'test.tsx')
11
+ expect(ctx.signals[0].getter).not.toBe('rows')
12
+ expect(ctx.propsParams[0].name).toBe('rows')
13
+ expect(ctx.sourceFile.text).toContain('props.rows.map')
14
+ expect(ctx.sourceFile.text).toContain(`${ctx.signals[0].getter}().map`)
15
+ })
16
+
17
+ test('rename follows binding identity, preserves keys, and avoids source names', () => {
18
+ const source = `
19
+ 'use client'
20
+ import { createSignal } from '@barefootjs/client'
21
+ export function App(props: { count: number }) {
22
+ const bfSignal_count = 8
23
+ const BfSignal_count_1 = 9
24
+ const [count, setCount] = createSignal(7)
25
+ const alias = count
26
+ const object = { count }
27
+ const shadow = (count: number) => ({ count, label: 'count', value: count })
28
+ return <button onClick={() => setCount(count() + 1)}>{props.count}{count()}{alias()}{object.count()}{shadow(2).count}</button>
29
+ }
30
+ `
31
+ const ctx = analyzeComponent(source, 'test.tsx')
32
+ const name = ctx.signals[0].getter
33
+ expect(name).not.toBe('count')
34
+ expect(name).not.toBe('bfSignal_count')
35
+ expect(name.toLowerCase()).not.toBe('bfsignal_count_1')
36
+ expect(ctx.sourceFile.text).toContain(`const alias = ${name}`)
37
+ expect(ctx.sourceFile.text).toContain(`{ count: ${name} }`)
38
+ expect(ctx.sourceFile.text).toContain("(count: number) => ({ count, label: 'count', value: count })")
39
+ expect(ctx.sourceFile.text).toContain('object.count()')
40
+ expect(ctx.sourceFile.text).toContain(`setCount(${name}() + 1)`)
41
+ const result = compileJSX(source, 'test.tsx', { adapter: new TestAdapter() })
42
+ expect(result.errors.filter(e => e.severity === 'error')).toEqual([])
43
+ expect(result.files.find(f => f.type === 'clientJs')?.content).toContain(name)
44
+ })
45
+
46
+ test('same-prop derived seeds and ordinary bindings stay unchanged', () => {
47
+ const ctx = analyzeComponent(`
48
+ 'use client'
49
+ import { createSignal } from '@barefootjs/client'
50
+ export function App(props: { count: number }) {
51
+ const [count] = createSignal(props.count ?? 7)
52
+ const [other] = createSignal(2)
53
+ return <p>{count()}{other()}</p>
54
+ }
55
+ `, 'test.tsx')
56
+ expect(ctx.signals.map(s => s.getter)).toEqual(['count', 'other'])
57
+ })
58
+
59
+ test('signed literal seeds are separated without a type-based program', () => {
60
+ const ctx = analyzeComponent(`
61
+ 'use client'
62
+ import { createSignal } from '@barefootjs/client'
63
+ export function App(props: { count: number }) {
64
+ const [count] = createSignal(-7)
65
+ return <p>{props.count}{count()}</p>
66
+ }
67
+ `, 'test.tsx')
68
+ expect(ctx.signals[0].getter).not.toBe('count')
69
+ expect(ctx.signals[0].initialValue).toBe('-7')
70
+ })
71
+
72
+ test('re-analysis preserves a supplied Program and its virtual imports', () => {
73
+ const source = `
74
+ 'use client'
75
+ import { createSignal } from '@barefootjs/client'
76
+ import { n } from './virtual'
77
+ export function App(props: { count: number }) {
78
+ const [count] = createSignal(7)
79
+ const extra = n
80
+ return <p>{props.count}{count()}{extra}</p>
81
+ }
82
+ `
83
+ const files = new Map([
84
+ ['/virtual/app.tsx', source],
85
+ ['/virtual/virtual.ts', 'export const n = 42'],
86
+ ])
87
+ const options: ts.CompilerOptions = {
88
+ noLib: true, module: ts.ModuleKind.ESNext,
89
+ moduleResolution: ts.ModuleResolutionKind.Bundler, jsx: ts.JsxEmit.Preserve,
90
+ }
91
+ const program = ts.createProgram([...files.keys()], options, {
92
+ ...ts.createCompilerHost(options),
93
+ getCurrentDirectory: () => '/virtual',
94
+ directoryExists: name => name === '/virtual',
95
+ fileExists: name => files.has(name),
96
+ readFile: name => files.get(name),
97
+ getSourceFile: (name, version) => files.has(name)
98
+ ? ts.createSourceFile(name, files.get(name)!, version, true, ts.ScriptKind.TSX) : undefined,
99
+ })
100
+ const ctx = analyzeComponent(source, '/virtual/app.tsx', undefined, program)
101
+ expect(ctx.signals[0].getter).not.toBe('count')
102
+ expect(ctx.checker).not.toBeNull()
103
+ let extra: ts.VariableDeclaration | undefined
104
+ function visit(node: ts.Node): void {
105
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === 'extra') extra = node
106
+ ts.forEachChild(node, visit)
107
+ }
108
+ visit(ctx.sourceFile)
109
+ expect(ctx.checker!.typeToString(ctx.checker!.getTypeAtLocation(extra!.initializer!))).toBe('42')
110
+ expect(program.getSourceFile('/virtual/app.tsx')!.text).toBe(source)
111
+ })
112
+
113
+ test('multi-component production compilation separates each component independently', () => {
114
+ const source = `
115
+ 'use client'
116
+ import { createSignal } from '@barefootjs/client'
117
+ export function First(props: { count: number }) {
118
+ const [count] = createSignal(7)
119
+ return <p>{props.count}{count()}</p>
120
+ }
121
+ export function Second(props: { count: number }) {
122
+ const [count] = createSignal(9)
123
+ return <p>{props.count}{count()}</p>
124
+ }
125
+ `
126
+ const result = compileJSX(source, 'test.tsx', { adapter: new TestAdapter() })
127
+ expect(result.errors.filter(e => e.severity === 'error')).toEqual([])
128
+ const clientJs = result.files.find(f => f.type === 'clientJs')!.content
129
+ expect(clientJs).toContain('initFirst')
130
+ expect(clientJs).toContain('initSecond')
131
+ expect(clientJs.match(/\[bfSignal_count\]/g)).toHaveLength(2)
132
+ })
133
+
134
+ test.each([false, true])('custom module and type resolutions survive reanalysis (automatic: %s)', automatic => {
135
+ const source = `${automatic ? '' : '/// <reference types="custom-globals" />'}
136
+ 'use client'
137
+ import { n } from 'custom-values'
138
+ export function App(props: { count: number }) {
139
+ const [count] = createSignal(7)
140
+ const extra = n
141
+ return <p>{props.count}{count()}{extra}</p>
142
+ }
143
+ `
144
+ const files = new Map([
145
+ ['/virtual/app.tsx', source],
146
+ ['/virtual/value.ts', 'export const n = 42'],
147
+ ['/virtual/globals.d.ts', 'declare function createSignal(v: number): [() => number]'],
148
+ ])
149
+ const options: ts.CompilerOptions = { noLib: true, module: ts.ModuleKind.ESNext, jsx: ts.JsxEmit.Preserve, types: automatic ? ['custom-globals'] : [] }
150
+ const program = ts.createProgram(['/virtual/app.tsx'], options, {
151
+ ...ts.createCompilerHost(options),
152
+ getCurrentDirectory: () => '/virtual',
153
+ directoryExists: name => name === '/virtual',
154
+ fileExists: name => files.has(name),
155
+ readFile: name => files.get(name),
156
+ getSourceFile: (name, version) => files.has(name)
157
+ ? ts.createSourceFile(name, files.get(name)!, version, true, ts.ScriptKind.TSX) : undefined,
158
+ resolveModuleNames: names => names.map(name => name === 'custom-values'
159
+ ? { resolvedFileName: '/virtual/value.ts', extension: ts.Extension.Ts } : undefined),
160
+ resolveTypeReferenceDirectives: names => names.map(() => ({ resolvedFileName: '/virtual/globals.d.ts', primary: true })),
161
+ })
162
+ const ctx = analyzeComponent(source, '/virtual/app.tsx', undefined, program)
163
+ expect(ctx.signals[0].getter).not.toBe('count')
164
+ const rebuilt = programWithSeparatedSource(program, '/virtual/app.tsx', ctx.sourceFile.text)
165
+ const originalDiagnostics = program.getSemanticDiagnostics().map(d => d.code)
166
+ expect(rebuilt.getSemanticDiagnostics().map(d => d.code)).toEqual(originalDiagnostics)
167
+ const module = rebuilt.getSourceFile('/virtual/value.ts')!
168
+ const declaration = (module.statements[0] as ts.VariableStatement).declarationList.declarations[0]
169
+ expect(rebuilt.getTypeChecker().typeToString(rebuilt.getTypeChecker().getTypeAtLocation(declaration.name))).toBe('42')
170
+ expect(rebuilt.getSourceFile('/virtual/globals.d.ts')).toBeDefined()
171
+ })
@@ -173,15 +173,13 @@ describe('extractSsrDefaults', () => {
173
173
  expect(defaults?.n).toEqual({ value: 0 })
174
174
  })
175
175
 
176
- test('NON-self-derived collision (#2669, shape C — out of scope, must be unchanged): signal value still wins, no `propName`', () => {
176
+ test('literal-seeded collision has distinct raw-prop and internal-signal defaults', () => {
177
177
  // Same-named `label` getter and `label` prop, but the signal's OWN
178
178
  // initializer does NOT derive from `props.label` (it's a plain
179
179
  // string literal) — the JSX body separately reads `label()` AND
180
- // `props.label`. That's a template-variable-ALIASING defect (both
181
- // expressions lower to the same template variable, so no seeding
182
- // choice can be right for both readers) — a different bug, tracked
183
- // separately, and this fix must leave it byte-identical: the entry
184
- // stays the plain evaluated-signal-value shape with no `propName`.
180
+ // `props.label`. Analysis separates the local binding before IR is
181
+ // built, so the prop keeps its caller-facing seed while the signal
182
+ // remains an internal entry without `propName`.
185
183
  const metadata = metadataFor(`
186
184
  'use client'
187
185
  import { createSignal } from '@barefootjs/client'
@@ -192,7 +190,8 @@ describe('extractSsrDefaults', () => {
192
190
  `)
193
191
 
194
192
  const defaults = extractSsrDefaults(metadata)
195
- expect(defaults?.label).toEqual({ value: 'sig' })
193
+ expect(defaults?.label).toEqual({ propName: 'label', value: null })
194
+ expect(defaults?.[metadata.signals[0].getter]).toEqual({ value: 'sig' })
196
195
  })
197
196
 
198
197
  test('self-derived signal collision THROUGH a component-scope const (#2685 review): entry stays a PROP entry', () => {
@@ -23,6 +23,29 @@ function step(plan: SsrSeedPlan, name: string): SsrSeedStep {
23
23
  }
24
24
 
25
25
  describe('computeSsrSeedPlan', () => {
26
+ test('getter aliases seed after their prop-derived memo, including alias hops', () => {
27
+ const plan = planFor(`
28
+ 'use client'
29
+ import { createSignal, createMemo } from '@barefootjs/client'
30
+ function App(props: { count: number }) {
31
+ const [n] = createSignal(1.5)
32
+ const total = createMemo(() => n() + props.count)
33
+ const totalAlias = total
34
+ const secondAlias = totalAlias
35
+ return <p>{totalAlias()}{secondAlias()}</p>
36
+ }
37
+ `)
38
+ expect(plan.steps.map(s => s.name)).toEqual(['n', 'total', 'totalAlias', 'secondAlias'])
39
+ for (const name of ['totalAlias', 'secondAlias']) {
40
+ const alias = step(plan, name)
41
+ expect(alias.kind).toBe('derived')
42
+ if (alias.kind === 'derived') {
43
+ expect(alias.parsed).toEqual({ kind: 'call', callee: { kind: 'identifier', name: 'total' }, args: [] })
44
+ expect(alias.frees).toContain('total')
45
+ }
46
+ }
47
+ })
48
+
26
49
  test('env signal (aliased) → env-reader step; derived memo over it', () => {
27
50
  const plan = planFor(`
28
51
  'use client'
@@ -33,7 +33,7 @@ describe('Shadow guards: bare names that shadow props are NOT rewritten to _p.X'
33
33
 
34
34
  expect(errors).toEqual([])
35
35
  // The local must use the signal getter, not _p.count.
36
- expect(initBody).toMatch(/doubled\s*=\s*count\(\)\s*\*\s*2/)
36
+ expect(initBody).toMatch(/doubled\s*=\s*bfSignal_count\(\)\s*\*\s*2/)
37
37
  expect(initBody).not.toMatch(/_p\.count\(\)/)
38
38
  })
39
39
 
@@ -219,9 +219,12 @@ describe('buildRelocateEnv: builds env from analyzer/IR state', () => {
219
219
  }
220
220
  `, 'Foo.tsx')
221
221
  const env = buildRelocateEnv(ctx)
222
- // `count` is the signal getter, NOT the prop. Critical for #1132.
223
- expect(env.bindings.get('count')).toBe('signal-getter')
224
- expect(env.propsForLift.has('count')).toBe(false)
222
+ // The local getter is distinct from the bare prop. It must still
223
+ // classify as a getter, never as a prop eligible for lifting.
224
+ const getter = ctx.signals[0].getter
225
+ expect(env.bindings.get(getter)).toBe('signal-getter')
226
+ expect(env.propsForLift.has(getter)).toBe(false)
227
+ expect(env.bindings.get('count')).toBe('prop')
225
228
  })
226
229
 
227
230
  test('pure prop alias stays classified as prop (eligible for lift)', async () => {
@@ -244,14 +244,14 @@ export interface ParsedExprEmitter {
244
244
  * Consumed by `===`/`!==` lowering on backends whose `==` is numeric
245
245
  * (Perl `eq`/`ne`) and by `isStringConcatBinary` below.
246
246
  */
247
- export function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string) => boolean): boolean {
247
+ export function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string, componentProperty?: boolean) => boolean): boolean {
248
248
  if (expr.kind === 'literal' && expr.literalType === 'string') return true
249
249
  if (expr.kind === 'template-literal') return true
250
250
  if (expr.kind === 'call' && expr.callee.kind === 'identifier' && expr.args.length === 0) {
251
251
  return isStringName(expr.callee.name)
252
252
  }
253
253
  if (expr.kind === 'member' && expr.object.kind === 'identifier' && expr.object.name === 'props') {
254
- return isStringName(expr.property)
254
+ return isStringName(expr.property, true)
255
255
  }
256
256
  // A bare identifier (#2212): a destructured prop param or a same-file
257
257
  // local const, string-typed per the caller's `isStringName` set — each
@@ -282,7 +282,7 @@ export function isStringConcatBinary(
282
282
  op: string,
283
283
  left: ParsedExpr,
284
284
  right: ParsedExpr,
285
- isStringName: (n: string) => boolean,
285
+ isStringName: (n: string, componentProperty?: boolean) => boolean,
286
286
  ): boolean {
287
287
  return op === '+' && (isStringTypedOperand(left, isStringName) || isStringTypedOperand(right, isStringName))
288
288
  }
package/src/analyzer.ts CHANGED
@@ -32,6 +32,7 @@ import { CATALOGUED_RICH_TYPE_NAMES } from './date-lowering.ts'
32
32
  import path from 'node:path'
33
33
  import fs from 'node:fs'
34
34
  import { signalSecondBinding } from './signal-initializer.ts'
35
+ import { separateLiteralSignalPropBindings, programWithSeparatedSource } from './signal-prop-name-collision.ts'
35
36
 
36
37
  // =============================================================================
37
38
  // TypeScript Program Creation
@@ -375,6 +376,15 @@ export function analyzeComponent(
375
376
  if (parsed.kind !== 'unsupported') signal.parsed = parsed
376
377
  }
377
378
 
379
+ const separatedSource = separateLiteralSignalPropBindings(ctx, isNonReferenceIdentifierPosition)
380
+ if (separatedSource !== null) {
381
+ // The checker supplied by the caller names the old AST. Re-analyze the
382
+ // structurally renamed source, preserving the shared-program contract
383
+ // (BF050), just as the reactive-factory prepass does above.
384
+ const separatedProgram = program && programWithSeparatedSource(program, filePath, separatedSource)
385
+ return analyzeComponent(separatedSource, filePath, targetComponentName, separatedProgram, acceptsCallbackBody, hadSharedProgram)
386
+ }
387
+
378
388
  // #2040: fold a complete, value-producing block-bodied memo into a single
379
389
  // expression so it flows through the same `parsed` path as an expression-bodied
380
390
  // memo, instead of relying on per-idiom block recognizers (#1897 / #1945 /
package/src/index.ts CHANGED
@@ -238,6 +238,7 @@ export { isValueReferenceIdentifier, collectValueReferencedNames } from './value
238
238
  // Expression Parser
239
239
  export { parseExpression, tsNodeToParsedExpr, asCallbackMethodCall, CALLBACK_METHODS, sortComparatorFromArrow, serializeParsedExpr, freeVarsInBody, freeIdentifiers, materializeGetterCalls, isSupported, isSupportedValue, exprToString, stringifyParsedExpr, identifierPath, parseBlockBody, parseBlockBodyTolerant, foldBlockToExpr, predicateTernaryToLogical, containsHigherOrder, extractArrowBodyExpression, parseStyleObjectEntries, hasUnsafeStyleValue, parseProviderObjectLiteral, isFunctionShapedExpression, type ProviderObjectMember, type FoldBlockOptions } from './expression-parser.ts'
240
240
  export type { StyleObjectEntry } from './expression-parser.ts'
241
+ export { literalMemberIndex } from './literal-member-index.ts'
241
242
  export { PARSED_EXPR_KINDS, ARRAY_METHOD_NAMES, SORT_KEY_TYPES, SORT_KEY_TARGETS, SORT_KEY_DIRECTIONS } from './expression-parser.ts'
242
243
  export type { ParsedExpr, ObjectLiteralProperty, ParsedStatement, SortComparator, SortKey, FlatDepth, SupportLevel, SupportResult, TemplatePart } from './expression-parser.ts'
243
244
  export { buildLoopChainExpr } from './loop-chain.ts'