@barefootjs/jsx 0.39.2 → 0.39.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.
Files changed (41) hide show
  1. package/dist/adapters/line-statement-text.d.ts +17 -0
  2. package/dist/adapters/line-statement-text.d.ts.map +1 -0
  3. package/dist/analyzer.d.ts +1 -0
  4. package/dist/analyzer.d.ts.map +1 -1
  5. package/dist/augment-inherited-props.d.ts +20 -0
  6. package/dist/augment-inherited-props.d.ts.map +1 -1
  7. package/dist/html-types.d.ts +15 -0
  8. package/dist/html-types.d.ts.map +1 -1
  9. package/dist/index.d.ts +5 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +260 -91
  12. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  13. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  14. package/dist/nullable-signal-attr.d.ts +73 -0
  15. package/dist/nullable-signal-attr.d.ts.map +1 -0
  16. package/dist/scope/root-prop-alias.d.ts +43 -0
  17. package/dist/scope/root-prop-alias.d.ts.map +1 -0
  18. package/package.json +2 -2
  19. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +3 -3
  20. package/src/__tests__/attribute-fallback-wrap.test.ts +24 -0
  21. package/src/__tests__/compiler-stress-1244.test.ts +10 -13
  22. package/src/__tests__/conditional-fallback-wrap.test.ts +20 -0
  23. package/src/__tests__/html-event-handler-names.test.ts +107 -0
  24. package/src/__tests__/line-statement-text.test.ts +25 -0
  25. package/src/__tests__/lookup-literal-const.test.ts +46 -0
  26. package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +66 -19
  27. package/src/__tests__/nullable-signal-attr.test.ts +124 -0
  28. package/src/__tests__/profile-binding-ids.test.ts +102 -0
  29. package/src/__tests__/root-prop-alias.test.ts +62 -0
  30. package/src/adapters/line-statement-text.ts +24 -0
  31. package/src/analyzer.ts +50 -26
  32. package/src/augment-inherited-props.ts +49 -0
  33. package/src/html-types.ts +15 -0
  34. package/src/index.ts +13 -2
  35. package/src/ir-to-client-js/collect-elements.ts +7 -1
  36. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +2 -2
  37. package/src/ir-to-client-js/stringify/declaration-emit.ts +5 -5
  38. package/src/ir-to-client-js/utils.ts +88 -117
  39. package/src/jsx-to-ir.ts +7 -0
  40. package/src/nullable-signal-attr.ts +156 -0
  41. package/src/scope/root-prop-alias.ts +81 -0
@@ -7,9 +7,11 @@
7
7
  */
8
8
 
9
9
  import { describe, test, expect } from 'bun:test'
10
+ import ts from 'typescript'
10
11
  import { compileJSX } from '../compiler'
11
12
  import { TestAdapter } from '../adapters/test-adapter'
12
13
  import { buildIdIndex } from '../profiler'
14
+ import { analyzeComponent } from '../analyzer'
13
15
  import { buildComponentAnalysis } from '../debug'
14
16
 
15
17
  const adapter = new TestAdapter()
@@ -121,3 +123,103 @@ describe('binding-effect ids', () => {
121
123
  expect(node.loc.line).toBeGreaterThan(0)
122
124
  })
123
125
  })
126
+
127
+ describe('a zero-arg createSignal() emits valid client JS (#3217)', () => {
128
+ const zeroArgSource = `
129
+ 'use client'
130
+ import { createSignal } from '@barefootjs/client'
131
+ export function Empty() {
132
+ const [v, setV] = createSignal<string>()
133
+ return <button onClick={() => setV('x')}>{v() ?? '-'}</button>
134
+ }
135
+ `
136
+
137
+ function emit(profile: boolean): string {
138
+ return compileJSX(zeroArgSource, 'Empty.tsx', { adapter, profile })
139
+ .files.find(f => f.type === 'clientJs')!.content
140
+ }
141
+
142
+ function parseErrors(js: string): string[] {
143
+ const diagnostics = ts.transpileModule(js, {
144
+ reportDiagnostics: true,
145
+ compilerOptions: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.Latest },
146
+ }).diagnostics ?? []
147
+ return diagnostics
148
+ .filter(d => d.category === ts.DiagnosticCategory.Error)
149
+ .map(d => ts.flattenDiagnosticMessageText(d.messageText, '\n'))
150
+ }
151
+
152
+ test('profile on: the signal id follows an explicit `undefined`, not a bare comma', () => {
153
+ const on = emit(true)
154
+ expect(on).toContain('createSignal(undefined, "Empty#signal:v")')
155
+ expect(on).not.toContain('createSignal(,')
156
+ expect(parseErrors(on)).toEqual([])
157
+ })
158
+
159
+ test('profile off: the call and the template both carry an explicit `undefined`', () => {
160
+ // The CSR template substitutes `v()` with the signal's initial value.
161
+ // An empty one used to inline as `()`, so the module failed to parse
162
+ // even without profiling.
163
+ const off = emit(false)
164
+ expect(off).toContain('createSignal(undefined)')
165
+ expect(off).toContain("escapeTextOrMarkup((undefined) ?? '-')")
166
+ expect(parseErrors(off)).toEqual([])
167
+ })
168
+ })
169
+
170
+ describe('the analyzer records `undefined` for a zero-arg createSignal() (#3215)', () => {
171
+ // One decision at the source: every emitter (SSR getter, CSR template,
172
+ // client-JS call) splices `initialValue` into an expression, so an empty
173
+ // string there is an empty operand in each of them.
174
+ const shapes: Array<[string, string]> = [
175
+ ['array destructure', 'const [v, setV] = createSignal<string>()'],
176
+ ['tuple ref + index access', 'const s = createSignal<string>(); const v = s[0]; const setV = s[1]'],
177
+ ['direct index access', 'const v = createSignal<string>()[0]; const setV = createSignal<string>()[1]'],
178
+ ]
179
+ for (const [label, decl] of shapes) {
180
+ test(label, () => {
181
+ const source = `
182
+ 'use client'
183
+ import { createSignal } from '@barefootjs/client'
184
+ export function Empty() {
185
+ ${decl}
186
+ return <button onClick={() => setV('x')}>{v() ?? '-'}</button>
187
+ }
188
+ `
189
+ const signals = analyzeComponent(source, 'Empty.tsx').signals
190
+ expect(signals.length).toBeGreaterThan(0)
191
+ for (const signal of signals) {
192
+ expect(signal.initialValue).toBe('undefined')
193
+ // The zero-arg overload's `T | undefined`, so a typed backend seeds
194
+ // nil rather than the type's zero value.
195
+ expect(signal.type.raw).toBe('string | undefined')
196
+ }
197
+ })
198
+ }
199
+
200
+ test('a type argument that already admits undefined is not widened again', () => {
201
+ const source = `
202
+ 'use client'
203
+ import { createSignal } from '@barefootjs/client'
204
+ export function Empty() {
205
+ const [v] = createSignal<'a' | 'b' | undefined>()
206
+ return <p>{v() ?? '-'}</p>
207
+ }
208
+ `
209
+ const [signal] = analyzeComponent(source, 'Empty.tsx').signals
210
+ expect(signal.type.raw).toBe("'a' | 'b' | undefined")
211
+ })
212
+
213
+ test('an explicit initial value keeps the type argument as written', () => {
214
+ const source = `
215
+ 'use client'
216
+ import { createSignal } from '@barefootjs/client'
217
+ export function Empty() {
218
+ const [v] = createSignal<string>('x')
219
+ return <p>{v()}</p>
220
+ }
221
+ `
222
+ const [signal] = analyzeComponent(source, 'Empty.tsx').signals
223
+ expect(signal.type.raw).toBe('string')
224
+ })
225
+ })
@@ -0,0 +1,62 @@
1
+ import { describe, test, expect } from 'bun:test'
2
+ import { BindingScope } from '../scope/binding-scope'
3
+ import { rootPropAliasNames, rootPropAliasesForLoop, rootPropReadName } from '../scope/root-prop-alias'
4
+ import type { ComponentIR } from '../types'
5
+
6
+ function irWith(opts: { localConstants?: string[]; loopParam?: string } = {}): ComponentIR {
7
+ const root = opts.loopParam
8
+ ? { type: 'loop', param: opts.loopParam, children: [] }
9
+ : { type: 'element', children: [] }
10
+ return {
11
+ root,
12
+ metadata: {
13
+ localConstants: (opts.localConstants ?? []).map(name => ({ name })),
14
+ localFunctions: [],
15
+ signals: [],
16
+ memos: [],
17
+ },
18
+ } as unknown as ComponentIR
19
+ }
20
+
21
+ describe('root-prop aliases (#3314)', () => {
22
+ const props = new Set(['value', 'index', 'values'])
23
+ const aliases = rootPropAliasNames(irWith(), props)
24
+ const outer = BindingScope.EMPTY
25
+ const row = outer.enterLoopRow({ param: 'value', index: 'index' })
26
+ const inner = row.enterLoopRow({ param: 'value' })
27
+
28
+ test('a loop row aliases exactly the props it newly shadows', () => {
29
+ expect(rootPropAliasesForLoop(outer, row, aliases)).toEqual([
30
+ { name: 'value', alias: '__bf_root_value' },
31
+ { name: 'index', alias: '__bf_root_index' },
32
+ ])
33
+ })
34
+
35
+ test('a nested loop re-binding an already shadowed name adds no alias', () => {
36
+ expect(rootPropAliasesForLoop(row, inner, aliases)).toEqual([])
37
+ })
38
+
39
+ test('a binding that is not a prop needs no alias', () => {
40
+ expect(rootPropAliasesForLoop(outer, outer.enterLoopRow({ param: 'item' }), aliases)).toEqual([])
41
+ })
42
+
43
+ test('props.X reads the alias only while X is shadowed', () => {
44
+ expect(rootPropReadName('value', outer, aliases)).toBe('value')
45
+ expect(rootPropReadName('value', row, aliases)).toBe('__bf_root_value')
46
+ expect(rootPropReadName('value', inner, aliases)).toBe('__bf_root_value')
47
+ expect(rootPropReadName('values', row, aliases)).toBe('values')
48
+ })
49
+
50
+ test('an alias never takes a name the component already uses', () => {
51
+ expect(rootPropAliasNames(irWith(), ['value', '__bf_root_value']).get('value')).toBe('__bf_root_value_')
52
+ expect(rootPropAliasNames(irWith({ localConstants: ['__bf_root_value'] }), ['value']).get('value')).toBe(
53
+ '__bf_root_value_',
54
+ )
55
+ expect(rootPropAliasNames(irWith({ loopParam: '__bf_root_value' }), ['value']).get('value')).toBe(
56
+ '__bf_root_value_',
57
+ )
58
+ // `value` (bumped past the prop) and `value_` would otherwise share `__bf_root_value_`.
59
+ const both = rootPropAliasNames(irWith(), ['value', '__bf_root_value', 'value_'])
60
+ expect(new Set(both.values()).size).toBe(3)
61
+ })
62
+ })
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Static text in a template engine with LINE statements — Mojolicious
3
+ * (`% if (…) {`) and Xslate Kolon (`: if (…) {`) — must never begin a
4
+ * template line with the statement sigil: the engine reads such a line as
5
+ * code, so `{c ? 'on' : 'off'} :y` (whose text lands on its own line right
6
+ * after the conditional's closing `: }`) fails to parse, or vanishes when the
7
+ * line happens to parse (#3311).
8
+ *
9
+ * Every sigil that is the first non-blank character of the text or of a line
10
+ * inside it is emitted through `literal` instead — an output expression for
11
+ * the sigil character itself (`<%= '%' %>`, `<: ':' :>`). The text cannot know
12
+ * whether it starts a template line (that depends on what precedes it), so a
13
+ * line-leading sigil is always rewritten; the expression renders the same
14
+ * character either way.
15
+ */
16
+ export function escapeLineStatementSigil(text: string, sigil: string, literal: string): string {
17
+ return text
18
+ .split('\n')
19
+ .map(line => {
20
+ const indent = line.length - line.trimStart().length
21
+ return line.startsWith(sigil, indent) ? line.slice(0, indent) + literal + line.slice(indent + sigil.length) : line
22
+ })
23
+ .join('\n')
24
+ }
package/src/analyzer.ts CHANGED
@@ -1484,19 +1484,10 @@ function collectSignal(node: ts.VariableDeclaration, ctx: AnalyzerContext): void
1484
1484
  : null
1485
1485
  if (getterElided && !setter) return
1486
1486
  const getter = getterElided ? `__bfGet_${setter}` : (elements[0] as ts.BindingElement & { name: ts.Identifier }).name.text
1487
- const initialValue = callExpr.arguments[0] ? ctx.getJS(callExpr.arguments[0]) : ''
1487
+ const initialValue = signalInitialValueText(callExpr, ctx)
1488
1488
  const typedInitialValue = callExpr.arguments[0] ? callExpr.arguments[0].getText(ctx.sourceFile) : undefined
1489
1489
 
1490
- // Try to infer type from initial value or type argument
1491
- let type: TypeInfo = { kind: 'unknown', raw: 'unknown' }
1492
-
1493
- // Check for type argument: createSignal<number>(0)
1494
- if (callExpr.typeArguments && callExpr.typeArguments.length > 0) {
1495
- type = typeNodeToTypeInfo(callExpr.typeArguments[0], ctx.sourceFile) ?? type
1496
- } else {
1497
- // Infer from initial value
1498
- type = inferTypeFromValue(initialValue)
1499
- }
1490
+ const type = signalTypeInfo(callExpr, initialValue, ctx)
1500
1491
 
1501
1492
  const envReader = resolveEnvSignalKey(callExpr, ctx) ?? undefined
1502
1493
  // The factory as written (identifier, alias, or `ns.factory`), so emit re-emits
@@ -1730,6 +1721,44 @@ function isSignalIndexAccess(
1730
1721
  return null
1731
1722
  }
1732
1723
 
1724
+ /**
1725
+ * A `createSignal` call's initial value as JS text. A call with no argument
1726
+ * starts the signal as `undefined` (what the runtime does with a missing
1727
+ * argument), so it is recorded as `'undefined'` rather than `''` — every
1728
+ * consumer that splices the initial value into an expression (the SSR
1729
+ * getter, the CSR template, the client-JS call) would otherwise emit an
1730
+ * empty operand (#3215). `createQuery`'s factory path records the same.
1731
+ */
1732
+ function signalInitialValueText(callExpr: ts.CallExpression, ctx: AnalyzerContext): string {
1733
+ return callExpr.arguments[0] ? ctx.getJS(callExpr.arguments[0]) : 'undefined'
1734
+ }
1735
+
1736
+ /**
1737
+ * A `createSignal` call's value type: its type argument, else inferred from
1738
+ * the initial value. A zero-arg call with a type argument is `T | undefined`
1739
+ * (the zero-arg overload's return type), not `T` — a typed backend would
1740
+ * otherwise seed the type's zero value (`0`, `""`) where the signal holds
1741
+ * `undefined` (#3215).
1742
+ */
1743
+ function signalTypeInfo(callExpr: ts.CallExpression, initialValue: string, ctx: AnalyzerContext): TypeInfo {
1744
+ const typeArg = callExpr.typeArguments?.[0]
1745
+ if (!typeArg) return inferTypeFromValue(initialValue)
1746
+ const type = typeNodeToTypeInfo(typeArg, ctx.sourceFile) ?? { kind: 'unknown', raw: 'unknown' }
1747
+ return callExpr.arguments[0] ? type : withUndefined(type)
1748
+ }
1749
+
1750
+ /** `T | undefined`, flattening a union `T` and leaving one that already admits `undefined` as is. */
1751
+ function withUndefined(type: TypeInfo): TypeInfo {
1752
+ const members = type.kind === 'union' && type.unionTypes ? type.unionTypes : [type]
1753
+ if (members.some(t => t.kind === 'primitive' && t.primitive === 'undefined')) return type
1754
+ if (type.kind === 'unknown') return type
1755
+ return {
1756
+ kind: 'union',
1757
+ raw: `${type.raw} | undefined`,
1758
+ unionTypes: [...members, { kind: 'primitive', raw: 'undefined', primitive: 'undefined' }],
1759
+ }
1760
+ }
1761
+
1733
1762
  function collectSignalTupleRef(
1734
1763
  node: ts.VariableDeclaration,
1735
1764
  ctx: AnalyzerContext
@@ -1737,17 +1766,12 @@ function collectSignalTupleRef(
1737
1766
  const name = (node.name as ts.Identifier).text
1738
1767
  const callExpr = node.initializer as ts.CallExpression
1739
1768
 
1740
- const initialValue = callExpr.arguments[0] ? ctx.getJS(callExpr.arguments[0]) : ''
1769
+ const initialValue = signalInitialValueText(callExpr, ctx)
1741
1770
  const typedInitialValue = callExpr.arguments[0]
1742
1771
  ? callExpr.arguments[0].getText(ctx.sourceFile)
1743
1772
  : undefined
1744
1773
 
1745
- let type: TypeInfo = { kind: 'unknown', raw: 'unknown' }
1746
- if (callExpr.typeArguments && callExpr.typeArguments.length > 0) {
1747
- type = typeNodeToTypeInfo(callExpr.typeArguments[0], ctx.sourceFile) ?? type
1748
- } else {
1749
- type = inferTypeFromValue(initialValue)
1750
- }
1774
+ const type = signalTypeInfo(callExpr, initialValue, ctx)
1751
1775
 
1752
1776
  ctx.signalTupleRefs.set(name, {
1753
1777
  initialValue,
@@ -1773,17 +1797,12 @@ function collectSignalFromIndexAccess(
1773
1797
  // Pattern A — each declaration is a standalone signal. Pair [0] -> getter
1774
1798
  // or [1] -> setter; the missing half stays null.
1775
1799
  const callExpr = match.callExpr
1776
- const initialValue = callExpr.arguments[0] ? ctx.getJS(callExpr.arguments[0]) : ''
1800
+ const initialValue = signalInitialValueText(callExpr, ctx)
1777
1801
  const typedInitialValue = callExpr.arguments[0]
1778
1802
  ? callExpr.arguments[0].getText(ctx.sourceFile)
1779
1803
  : undefined
1780
1804
 
1781
- let type: TypeInfo = { kind: 'unknown', raw: 'unknown' }
1782
- if (callExpr.typeArguments && callExpr.typeArguments.length > 0) {
1783
- type = typeNodeToTypeInfo(callExpr.typeArguments[0], ctx.sourceFile) ?? type
1784
- } else {
1785
- type = inferTypeFromValue(initialValue)
1786
- }
1805
+ const type = signalTypeInfo(callExpr, initialValue, ctx)
1787
1806
 
1788
1807
  const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath)
1789
1808
  const initialFreeIdentifiers = callExpr.arguments[0]
@@ -2386,7 +2405,12 @@ function collectLocalDeclarations(root: ts.Node): Set<string> {
2386
2405
  // Reactive primitives are DOM-free. The context/portal entries here are
2387
2406
  // type-level shims — their implementations live in @barefootjs/client/runtime
2388
2407
  // and are emitted by the compiler for 'use client' components.
2389
- const CLIENT_EXPORTS = new Set([
2408
+ //
2409
+ // The compiler re-points a recognised import at `@barefootjs/client/runtime`
2410
+ // in client JS, and at the Hono SSR shim on the server, so every name here
2411
+ // must exist on both. `client-exports-contract.test.ts` (adapter-hono) pins
2412
+ // this set against both, and against the root entry's own exports (#3217).
2413
+ export const CLIENT_EXPORTS: ReadonlySet<string> = new Set([
2390
2414
  'createSignal', 'createEffect', 'createDisposableEffect', 'createMemo',
2391
2415
  'createRoot', 'onCleanup', 'onMount', 'untrack', 'batch', 'splitProps',
2392
2416
  'forwardProps', 'unwrap', '__slot',
@@ -514,6 +514,55 @@ export function lookupStaticRecordLiteral(
514
514
  return null
515
515
  }
516
516
 
517
+ /**
518
+ * Resolve a bare identifier bound to a literal-initialized `const` — module
519
+ * or component-function scope — to that literal, or `null` for any other
520
+ * shape so callers fall back to their generic lowering. The one decision
521
+ * every template-string adapter used to copy as its own `_resolveLiteralConst`
522
+ * (#3312): those copies matched numbers and strings by regex and missed
523
+ * booleans, so `const on = true` read as a ternary test lowered to an unbound
524
+ * template variable (the falsy branch, or a render-time error). Each adapter
525
+ * renders the returned literal — boolean, number, string or `null` — in its
526
+ * own syntax.
527
+ *
528
+ * Reads the analyzer's structured `parsed` literal when present (a negated
529
+ * number arrives as unary `-`), falling back to the value text for the same
530
+ * three shapes. `isShadowed` is REQUIRED, as in `lookupStaticRecordLiteral`:
531
+ * a name the enclosing loop binds is the row's own value (#2221).
532
+ */
533
+ export function lookupLiteralConst(
534
+ name: string,
535
+ constants: IRMetadata['localConstants'] | undefined,
536
+ isShadowed: (name: string) => boolean,
537
+ ): { kind: 'string' | 'number' | 'boolean' | 'null'; text: string } | null {
538
+ if (isShadowed(name)) return null
539
+ const c = (constants ?? []).find(lc => lc.name === name)
540
+ if (c?.value === undefined) return null
541
+ const p = c.parsed
542
+ if (p?.kind === 'literal') {
543
+ if (p.literalType === 'string' && typeof p.value === 'string') return { kind: 'string', text: p.value }
544
+ if (p.literalType === 'boolean' && typeof p.value === 'boolean') return { kind: 'boolean', text: String(p.value) }
545
+ if (p.literalType === 'null') return { kind: 'null', text: 'null' }
546
+ if (p.literalType === 'number' && typeof p.value === 'number' && Number.isFinite(p.value)) {
547
+ return { kind: 'number', text: String(p.value) }
548
+ }
549
+ }
550
+ if (
551
+ p?.kind === 'unary' && p.op === '-' &&
552
+ p.argument.kind === 'literal' && p.argument.literalType === 'number' &&
553
+ typeof p.argument.value === 'number' && Number.isFinite(p.argument.value)
554
+ ) {
555
+ return { kind: 'number', text: String(-p.argument.value) }
556
+ }
557
+ if (p) return null
558
+ const v = c.value.trim()
559
+ if (/^-?\d+(\.\d+)?$/.test(v)) return { kind: 'number', text: v }
560
+ if (v === 'true' || v === 'false') return { kind: 'boolean', text: v }
561
+ if (v === 'null') return { kind: 'null', text: 'null' }
562
+ const strLit = /^'([^'\\]*)'$/.exec(v) ?? /^"([^"\\]*)"$/.exec(v)
563
+ return strLit ? { kind: 'string', text: strLit[1] } : null
564
+ }
565
+
517
566
  /**
518
567
  * Statically evaluate `[<string literals>].join(<sep?>)` (e.g. a module-scope
519
568
  * `const stateClasses = ['…', …].join(' ')`) to its joined string, so SSR
package/src/html-types.ts CHANGED
@@ -51,7 +51,11 @@ export interface BaseEventAttributes {
51
51
  onAnimationStart?: (event: AnimationEvent) => void
52
52
  onAnimationEnd?: (event: AnimationEvent) => void
53
53
  onAnimationIteration?: (event: AnimationEvent) => void
54
+ onAnimationCancel?: (event: AnimationEvent) => void
55
+ onTransitionStart?: (event: TransitionEvent) => void
56
+ onTransitionRun?: (event: TransitionEvent) => void
54
57
  onTransitionEnd?: (event: TransitionEvent) => void
58
+ onTransitionCancel?: (event: TransitionEvent) => void
55
59
  onCopy?: (event: ClipboardEvent) => void
56
60
  onCut?: (event: ClipboardEvent) => void
57
61
  onPaste?: (event: ClipboardEvent) => void
@@ -134,6 +138,17 @@ export interface HTMLBaseAttributes extends BaseEventAttributes {
134
138
  onPointerMove?: (event: PointerEvent) => void
135
139
  onPointerEnter?: (event: PointerEvent) => void
136
140
  onPointerLeave?: (event: PointerEvent) => void
141
+ onPointerCancel?: (event: PointerEvent) => void
142
+ onPointerOver?: (event: PointerEvent) => void
143
+ onPointerOut?: (event: PointerEvent) => void
144
+ onGotPointerCapture?: (event: PointerEvent) => void
145
+ onLostPointerCapture?: (event: PointerEvent) => void
146
+ onMouseOver?: MouseEventHandler<HTMLElement>
147
+ onMouseOut?: MouseEventHandler<HTMLElement>
148
+ onAuxClick?: MouseEventHandler<HTMLElement>
149
+ onFocusIn?: FocusEventHandler<HTMLElement>
150
+ onFocusOut?: FocusEventHandler<HTMLElement>
151
+ onBeforeInput?: InputEventHandler<HTMLElement>
137
152
  onContextMenu?: MouseEventHandler<HTMLElement>
138
153
  onDoubleClick?: MouseEventHandler<HTMLElement>
139
154
 
package/src/index.ts CHANGED
@@ -90,7 +90,7 @@ export type {
90
90
  export { isElidedFactoryGetter } from './types.ts'
91
91
 
92
92
  // Analyzer
93
- export { analyzeComponent, listComponentFunctions, listComponentFunctions as listExportedComponents, scanComponentFile, createProgramForFile, createAnchoredProgram, needsTypeBasedDetection, resolveRelativeImportToFile, REACTIVE_PRIMITIVES, BROWSER_ONLY_CLIENT_APIS, type AnalyzerContext, type ComponentFileScan } from './analyzer.ts'
93
+ export { analyzeComponent, listComponentFunctions, listComponentFunctions as listExportedComponents, scanComponentFile, createProgramForFile, createAnchoredProgram, needsTypeBasedDetection, resolveRelativeImportToFile, REACTIVE_PRIMITIVES, CLIENT_EXPORTS, BROWSER_ONLY_CLIENT_APIS, type AnalyzerContext, type ComponentFileScan } from './analyzer.ts'
94
94
  export { createProgramForCorpus, type SharedProgramOptions } from './shared-program.ts'
95
95
 
96
96
  // JSX to IR transformer
@@ -122,6 +122,15 @@ export type { ParsedExprEmitter, LoweringEmitter, HigherOrderMethod, ArrayMethod
122
122
  export { collectLoopBoundNames } from './adapters/loop-bound-names.ts'
123
123
  export { derivesScopeFromSlot } from './adapters/child-scope.ts'
124
124
  export { evaluateStaticLiteral, isFullyStaticLiteral, resolveStaticLoopSource } from './static-literal.ts'
125
+ export {
126
+ attrValueMayBeNullish,
127
+ collectNullableSignalGetters,
128
+ collectNullishAttrContext,
129
+ isNullableSignal,
130
+ isNullishLiteral,
131
+ nullableSignalAttrGetter,
132
+ type NullishAttrContext,
133
+ } from './nullable-signal-attr.ts'
125
134
  export { importsSearchParams, searchParamsLocalNames, envSignalLocalNames, envSignalReaderFor, ENV_SIGNAL_READERS, queryHrefLocalNames, matchSearchParamsMethodCall } from './adapters/env-signal.ts'
126
135
  export type { EnvSignalReader } from './adapters/env-signal.ts'
127
136
  export { matchQueryHrefCall, queryHrefArgs, type QueryHrefCall, type QueryHrefTriple } from './query-href-lowering.ts'
@@ -152,6 +161,7 @@ export { emitIRNode } from './adapters/ir-node-emitter.ts'
152
161
  export type { IRNodeEmitter, EmitIRNode } from './adapters/ir-node-emitter.ts'
153
162
  export { emitAttrValue } from './adapters/attr-value-emitter.ts'
154
163
  export type { AttrValueEmitter } from './adapters/attr-value-emitter.ts'
164
+ export { escapeLineStatementSigil } from './adapters/line-statement-text.ts'
155
165
  export {
156
166
  isDangerousInnerHtmlAttr,
157
167
  resolveDangerousInnerHtml,
@@ -248,6 +258,7 @@ export { isLowerableLoopDestructure, isLowerableObjectRestDestructure } from './
248
258
  // Binding scope (#2482) — shared loop-bound-name resolution service
249
259
  export { BindingScope } from './scope/binding-scope.ts'
250
260
  export type { ScopeBindingSource, ScopeBinding, ScopeFrame, LoopBindingSource } from './scope/binding-scope.ts'
261
+ export { rootPropAliasNames, rootPropAliasesForLoop, rootPropReadName } from './scope/root-prop-alias.ts'
251
262
 
252
263
  // Debug analysis
253
264
  export {
@@ -362,7 +373,7 @@ export { BOOLEAN_ATTRS, isBooleanAttr } from './html-constants.ts'
362
373
  export { USE_CLIENT_DIRECTIVE, CLIENT_EXPRESSION_DIRECTIVE } from './directives.ts'
363
374
 
364
375
  // Shared props-object-pattern helpers for the Go / Mojo template adapters
365
- export { augmentInheritedPropAccesses, parseRecordIndexAccess, evalStringArrayJoin, collectModuleStringConsts, lookupStaticRecordLiteral, collectContextConsumers } from './augment-inherited-props.ts'
376
+ export { augmentInheritedPropAccesses, parseRecordIndexAccess, evalStringArrayJoin, collectModuleStringConsts, lookupStaticRecordLiteral, lookupLiteralConst, collectContextConsumers } from './augment-inherited-props.ts'
366
377
  export type { RecordIndexAccess, RecordIndexEntry, ContextConsumer } from './augment-inherited-props.ts'
367
378
 
368
379
  // HTML element attribute types
@@ -1292,6 +1292,12 @@ function collectBranchReactiveAttrs(node: IRNode, ctx: ClientJsContext): Conditi
1292
1292
  * Collect reactive text expressions from a conditional branch IR subtree.
1293
1293
  * Walks the branch tree to find expression nodes that need createEffect updates.
1294
1294
  * Does NOT recurse into nested conditionals (they get their own insert() call).
1295
+ *
1296
+ * Uses the same wrap decision as top-level text (`decideWrapFromAstFlags`,
1297
+ * #937): a call the analyzer can't prove non-reactive (`{v().text}`, `v`
1298
+ * reading an untyped or class-held store) wraps too. Gating on
1299
+ * `n.reactive` alone left such text frozen at its first value inside a
1300
+ * branch while the same expression outside it updated (#3266).
1295
1301
  */
1296
1302
  function collectBranchTextEffects(node: IRNode): ConditionalBranchTextEffect[] {
1297
1303
  const effects: ConditionalBranchTextEffect[] = []
@@ -1302,7 +1308,7 @@ function collectBranchTextEffects(node: IRNode): ConditionalBranchTextEffect[] {
1302
1308
  // element / fragment / component / provider / async use default descent.
1303
1309
  ...stopAt<null>('conditional', 'ifStatement', 'loop'),
1304
1310
  expression: ({ node: n }) => {
1305
- if (n.reactive && n.slotId && !n.clientOnly) {
1311
+ if (decideWrapFromAstFlags(n).wrap && n.slotId && !n.clientOnly) {
1306
1312
  effects.push({ slotId: n.slotId, expression: n.expr })
1307
1313
  }
1308
1314
  },
@@ -62,7 +62,7 @@ function collectTextOnlySlotIds(nodes: readonly IRNode[], into: Set<string>): vo
62
62
  /** @internal — prefer `buildLoopPlan`. */
63
63
  export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?: string): ComponentLoopPlan {
64
64
  const { name } = elem.childComponent!
65
- const propsExpr = buildComponentPropsExpr(elem.childComponent!, elem.param, undefined, elem.index)
65
+ const propsExpr = buildComponentPropsExpr(elem.childComponent!, elem.param, elem.paramBindings, elem.index)
66
66
  const keyExpr = wrapLoopParamAsAccessor(elem.key || '__idx', elem.param, elem.paramBindings, elem.index)
67
67
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings)
68
68
 
@@ -103,7 +103,7 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
103
103
  return {
104
104
  componentName: comp.name,
105
105
  selector: buildCompSelector(comp),
106
- propsExpr: buildComponentPropsExpr(comp, elem.param, undefined, elem.index),
106
+ propsExpr: buildComponentPropsExpr(comp, elem.param, elem.paramBindings, elem.index),
107
107
  // #3064: marker-scoped where possible — see `buildChildrenTextEffect`.
108
108
  childrenTextEffect: childrenRefsLoop
109
109
  ? buildChildrenTextEffect(comp.children!, rawChildrenExpr!, wrap)
@@ -88,7 +88,7 @@ function emitSignal(lines: string[], plan: SignalEmitPlan): void {
88
88
  lines.push(` const [${bindings}] = ${plan.initializerOverride}`)
89
89
  return
90
90
  }
91
- const id = bfIdArg(plan.bfId)
91
+ const args = `${plan.initialValueExpr}${bfIdArg(plan.bfId)}`
92
92
  if (plan.branchCondition) {
93
93
  // #1414 cell #8: signal declared inside an early-return `if`-block.
94
94
  // Hoist as `let` so closures and event handlers hoisted to outer
@@ -99,12 +99,12 @@ function emitSignal(lines: string[], plan: SignalEmitPlan): void {
99
99
  if (plan.setter) {
100
100
  lines.push(plan.getterElided ? ` let ${plan.setter}` : ` let ${plan.getter}, ${plan.setter}`)
101
101
  lines.push(` if (${plan.branchCondition}) {`)
102
- lines.push(` ;[${getterSlot}, ${plan.setter}] = createSignal(${plan.initialValueExpr}${id})`)
102
+ lines.push(` ;[${getterSlot}, ${plan.setter}] = createSignal(${args})`)
103
103
  lines.push(` }`)
104
104
  } else {
105
105
  lines.push(` let ${plan.getter}`)
106
106
  lines.push(` if (${plan.branchCondition}) {`)
107
- lines.push(` ;[${plan.getter}] = createSignal(${plan.initialValueExpr}${id})`)
107
+ lines.push(` ;[${plan.getter}] = createSignal(${args})`)
108
108
  lines.push(` }`)
109
109
  }
110
110
  // Controlled effects don't apply to branch-conditioned signals — a
@@ -113,9 +113,9 @@ function emitSignal(lines: string[], plan: SignalEmitPlan): void {
113
113
  return
114
114
  }
115
115
  if (plan.setter) {
116
- lines.push(` const [${getterSlot}, ${plan.setter}] = createSignal(${plan.initialValueExpr}${id})`)
116
+ lines.push(` const [${getterSlot}, ${plan.setter}] = createSignal(${args})`)
117
117
  } else {
118
- lines.push(` const [${plan.getter}] = createSignal(${plan.initialValueExpr}${id})`)
118
+ lines.push(` const [${plan.getter}] = createSignal(${args})`)
119
119
  }
120
120
  if (plan.controlledEffect) {
121
121
  emitControlledEffect(lines, plan.controlledEffect)