@barefootjs/jsx 0.35.3 → 0.35.4

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/src/debug.ts CHANGED
@@ -21,6 +21,7 @@ import type {
21
21
  MemoInfo,
22
22
  EffectInfo,
23
23
  SourceLocation,
24
+ OriginInfo,
24
25
  } from './types.ts'
25
26
  import { analyzeComponent, listComponentFunctions } from './analyzer.ts'
26
27
  import { jsxToIR } from './jsx-to-ir.ts'
@@ -66,6 +67,16 @@ export interface DomBinding {
66
67
  kind: 'dom'
67
68
  label: string // e.g., 'text node "s0"', 'click handler "s1"'
68
69
  slotId: string
70
+ /**
71
+ * Statically proven reactive sources this binding reads, by name: signal
72
+ * getters, memo names, and props (#2903). A prop dep is spelled the way the
73
+ * source reads it — a destructured prop by its name (`title`), a props-object
74
+ * member as `<propsObject>.<member>` (`props.value`) — and a prop read
75
+ * through a prop-derived local const (`class={classes}`) is reported as the
76
+ * underlying prop(s), never the const. Every entry resolves to a node in
77
+ * `ComponentGraph.signals` / `.memos` / `.props`. Event handlers instead list
78
+ * the setters / getters the handler body references.
79
+ */
69
80
  deps: string[]
70
81
  type: 'text' | 'event' | 'conditional' | 'loop' | 'attribute'
71
82
  /**
@@ -105,18 +116,38 @@ export interface DomBinding {
105
116
  jsxPreview?: string
106
117
  }
107
118
 
119
+ /**
120
+ * A component prop that at least one DOM binding reads reactively (#2903).
121
+ * Props are reactive sources on the same footing as signals and memos — the
122
+ * emitter wraps a prop-driven binding in `createEffect` exactly like a
123
+ * signal-driven one — so the graph lists them as nodes with consumers,
124
+ * rather than leaving the binding's `deps` empty and reporting
125
+ * `(no tracked deps)` for a read the IR itself marks `reactive: true`.
126
+ *
127
+ * Only props that some binding actually reads appear here (the list is
128
+ * derived from `DomBinding.deps`, not from the declared prop type), so a
129
+ * prop used solely inside an event handler is absent.
130
+ */
131
+ export interface PropNode {
132
+ kind: 'prop'
133
+ /** As spelled in `DomBinding.deps` — `title` or `props.value`. */
134
+ name: string
135
+ consumers: string[] // names of DOM nodes that read this prop
136
+ }
137
+
108
138
  export interface ComponentGraph {
109
139
  componentName: string
110
140
  sourceFile: string
111
141
  signals: SignalNode[]
112
142
  memos: MemoNode[]
113
143
  effects: EffectNode[]
144
+ props: PropNode[]
114
145
  domBindings: DomBinding[]
115
146
  }
116
147
 
117
148
  export interface UpdatePath {
118
149
  target: string
119
- kind: 'signal' | 'memo'
150
+ kind: 'signal' | 'memo' | 'prop'
120
151
  dependents: UpdatePathEntry[]
121
152
  }
122
153
 
@@ -199,7 +230,7 @@ export interface WhyUpdateResult {
199
230
 
200
231
  export interface WhyUpdateDep {
201
232
  name: string
202
- kind: 'signal' | 'memo'
233
+ kind: 'signal' | 'memo' | 'prop'
203
234
  dependsOn: string[]
204
235
  changedBy: WhyUpdateSource[]
205
236
  }
@@ -254,6 +285,7 @@ export function buildComponentGraph(source: string, filePath: string, componentN
254
285
  signals: [],
255
286
  memos: [],
256
287
  effects: [],
288
+ props: [],
257
289
  domBindings: [],
258
290
  }
259
291
  }
@@ -266,6 +298,7 @@ export function buildComponentGraph(source: string, filePath: string, componentN
266
298
  signals: [],
267
299
  memos: [],
268
300
  effects: [],
301
+ props: [],
269
302
  domBindings: [],
270
303
  }
271
304
  }
@@ -295,73 +328,96 @@ export function buildGraphFromIR(ir: ComponentIR): ComponentGraph {
295
328
  const memoNames = new Set(meta.memos.map(m => m.name))
296
329
  const signalSetters = new Map(meta.signals.filter(s => s.setter).map(s => [s.setter!, s.getter]))
297
330
 
298
- // Does an attribute expression read a component prop? Mirrors the emitter's
331
+ // Which component props does a binding expression read? Mirrors the emitter's
299
332
  // `needsEffectWrapper` prop gate (`reactivity.ts`):
300
333
  // - any individual destructured prop name (`{ className }` → `class={className}`),
301
334
  // - or a `<propsObject>.x` member access (`class={props.className}`),
302
335
  // both excluding `children` (server-rendered, never wrapped). Detection is
303
336
  // structural, not a raw-string regex: destructured names use the IR's
304
- // lexer-resolved `freeIdentifiers` (falling back to the lexer-aware
337
+ // lexer-resolved free-identifier sets (falling back to the lexer-aware
305
338
  // `tokenContainsIdent`), and the props-object case parses the expression and
306
- // walks for a real `props.member` access — so a `props.` inside a string
339
+ // walks for real `props.member` accesses — so a `props.` inside a string
307
340
  // literal / comment can't false-match, and bare `props` (`id={props}`) or
308
341
  // `props.children` are correctly NOT treated as reactive (matching the
309
342
  // emitter, which only wraps `<propsObject>.<non-children>`).
310
343
  //
311
- // Prop-driven attribute bindings are wrapped in a `createEffect` by the
312
- // emitter (and so emit a `#binding:<slot>` profiler id), but the debug-side
313
- // collector only tracked signal/memo deps before — so those ids resolved to
314
- // `(unresolved)` in `bf debug profile` (#1844 follow-up). Detecting prop reads
315
- // here closes that emit↔analyzer gap.
344
+ // Prop-driven bindings are wrapped in a `createEffect` by the emitter (and so
345
+ // emit a `#binding:<slot>` profiler id), but the debug-side collector only
346
+ // tracked signal/memo deps before — so those ids resolved to `(unresolved)`
347
+ // in `bf debug profile` (#1844 follow-up), and `bf debug graph` printed
348
+ // `(no tracked deps)` for a `props.value` read the IR itself marks
349
+ // `reactive: true` (#2903). The collector therefore returns the prop NAMES
350
+ // (not a boolean), so a prop read lands in `DomBinding.deps` on the same
351
+ // footing as a signal or memo read.
316
352
  const destructuredPropNames = new Set(meta.propsParams.map(p => p.name).filter(n => n !== 'children'))
317
353
  const propsObjectName = meta.propsObjectName
354
+ const propMemberDep = (member: string): string => `${propsObjectName}.${member}`
318
355
 
319
356
  // A binding often reads a prop *indirectly* through a local const:
320
357
  // `const classes = `…${variant}…${size}…${className}``, then
321
358
  // `<button class={classes}>` / `<Slot className={classes}>`. The emitter
322
359
  // inlines `classes`, sees the prop reads, and wraps the binding in a
323
360
  // `createEffect` (emitting `#binding:<slot>`) — but the expression's only free
324
- // identifier is the local `classes`, so the direct prop check above misses it
361
+ // identifier is the local `classes`, so the direct prop check would miss it
325
362
  // and the id resolves to `(unresolved)` (the Slot-composed-button case, #1863).
326
- // Precompute every local const whose value transitively derives from a prop,
327
- // so reading such a const counts as reading a prop. Module-level consts can't
328
- // reach component props, so they fall out naturally.
363
+ // Precompute, for every local const, the props its value transitively reads,
364
+ // so reading such a const reports the UNDERLYING props (`variant, className`),
365
+ // not the const's own name — a const is not a reactive source, the props it
366
+ // captures are. Module-level consts can't reach component props, so they fall
367
+ // out naturally (empty list).
329
368
  const constByName = new Map(meta.localConstants.map(c => [c.name, c]))
330
- const propDerivedConsts = new Set<string>()
369
+ const constPropDeps = new Map<string, readonly string[]>()
331
370
  {
332
371
  const onStack = new Set<string>()
333
- const derivesFromProp = (name: string): boolean => {
334
- if (propDerivedConsts.has(name)) return true
372
+ const propDepsOfConst = (name: string): readonly string[] => {
373
+ const cached = constPropDeps.get(name)
374
+ if (cached) return cached
335
375
  const c = constByName.get(name)
336
- if (!c?.freeIdentifiers || onStack.has(name)) return false
376
+ if (!c?.freeIdentifiers || onStack.has(name)) return []
337
377
  onStack.add(name)
338
- let derived = false
378
+ const out = new Set<string>()
339
379
  for (const free of c.freeIdentifiers) {
340
- if (destructuredPropNames.has(free) || free === propsObjectName || derivesFromProp(free)) {
341
- derived = true
342
- break
343
- }
380
+ if (destructuredPropNames.has(free)) out.add(free)
381
+ for (const dep of propDepsOfConst(free)) out.add(dep)
382
+ }
383
+ if (propsObjectName && c.value !== undefined && c.freeIdentifiers.has(propsObjectName)) {
384
+ for (const member of collectPropMembers(c.value, propsObjectName)) out.add(propMemberDep(member))
344
385
  }
345
386
  onStack.delete(name)
346
- if (derived) propDerivedConsts.add(name)
347
- return derived
348
- }
349
- for (const c of meta.localConstants) derivesFromProp(c.name)
350
- }
351
-
352
- const exprReadsProp = (expr: string, freeIds?: ReadonlySet<string>): boolean => {
387
+ const deps = [...out]
388
+ constPropDeps.set(name, deps)
389
+ return deps
390
+ }
391
+ for (const c of meta.localConstants) propDepsOfConst(c.name)
392
+ }
393
+
394
+ // `isShadowed` (#2903): inside a `.map()` row a loop binding of the same name
395
+ // hides the outer prop — `({ item }) => rows.map(item => <li>{item}</li>)`
396
+ // reads the row item, not the prop — so a shadowed name is never a prop dep.
397
+ // This is the SHADOW-GUARD consumer class of `BindingScope` (`isBound`), not
398
+ // the reactivity classifier (`valueBoundNames`).
399
+ const propDepsOf = (expr: string, freeIds?: ReadonlySet<string>, isShadowed?: (name: string) => boolean): string[] => {
400
+ const out = new Set<string>()
401
+ const reads = (name: string): boolean =>
402
+ !isShadowed?.(name) && (freeIds ? freeIds.has(name) : tokenContainsIdent(expr, name))
353
403
  for (const name of destructuredPropNames) {
354
- if (freeIds ? freeIds.has(name) : tokenContainsIdent(expr, name)) return true
404
+ if (reads(name)) out.add(name)
405
+ }
406
+ for (const [name, deps] of constPropDeps) {
407
+ if (deps.length > 0 && reads(name)) for (const dep of deps) out.add(dep)
355
408
  }
356
- for (const name of propDerivedConsts) {
357
- if (freeIds ? freeIds.has(name) : tokenContainsIdent(expr, name)) return true
409
+ // Same shadow guard as the two branches above: a `.map(props => …)` row
410
+ // whose callback param is literally named `props` reads the row item, so
411
+ // its `props.x` accesses are not outer-prop deps (Pullfrog review on #2904).
412
+ if (propsObjectName && !isShadowed?.(propsObjectName)) {
413
+ for (const member of collectPropMembers(expr, propsObjectName)) out.add(propMemberDep(member))
358
414
  }
359
- return propsObjectName ? exprReadsPropMember(expr, propsObjectName) : false
415
+ return [...out]
360
416
  }
361
417
 
362
418
  // Collect DOM bindings from IR tree
363
419
  const domBindings: DomBinding[] = []
364
- collectDomBindings(ir.root, domBindings, signalGetters, memoNames, undefined, BindingScope.EMPTY, exprReadsProp)
420
+ collectDomBindings(ir.root, domBindings, signalGetters, memoNames, undefined, BindingScope.EMPTY, propDepsOf)
365
421
 
366
422
  // Build consumer lists for signals
367
423
  const signalConsumers = new Map<string, string[]>()
@@ -413,6 +469,23 @@ export function buildGraphFromIR(ir: ComponentIR): ComponentGraph {
413
469
  }
414
470
  }
415
471
 
472
+ // Props are nodes too (#2903): every binding dep that is neither a signal
473
+ // nor a memo is a prop read (that is the only other thing `propDepsOf`
474
+ // contributes), keyed in first-seen order so the graph is stable.
475
+ const propConsumers = new Map<string, string[]>()
476
+ for (const dom of domBindings) {
477
+ if (dom.type === 'event') continue
478
+ for (const dep of dom.deps) {
479
+ if (signalGetters.has(dep) || memoNames.has(dep)) continue
480
+ let consumers = propConsumers.get(dep)
481
+ if (!consumers) {
482
+ consumers = []
483
+ propConsumers.set(dep, consumers)
484
+ }
485
+ consumers.push(`dom:${dom.label}`)
486
+ }
487
+ }
488
+
416
489
  const signals: SignalNode[] = meta.signals.map(s => ({
417
490
  kind: 'signal',
418
491
  name: s.getter,
@@ -439,12 +512,19 @@ export function buildGraphFromIR(ir: ComponentIR): ComponentGraph {
439
512
  loc: { file: e.loc.file, line: e.loc.start.line },
440
513
  }))
441
514
 
515
+ const props: PropNode[] = [...propConsumers].map(([name, consumers]) => ({
516
+ kind: 'prop',
517
+ name,
518
+ consumers,
519
+ }))
520
+
442
521
  return {
443
522
  componentName: meta.componentName,
444
523
  sourceFile: findSourceFile(meta) ?? '',
445
524
  signals,
446
525
  memos,
447
526
  effects,
527
+ props,
448
528
  domBindings,
449
529
  }
450
530
  }
@@ -1029,22 +1109,22 @@ export function formatLoopSummary(summary: LoopSummary): string {
1029
1109
  // =============================================================================
1030
1110
 
1031
1111
  /**
1032
- * Trace the update propagation path from a signal or memo.
1112
+ * Trace the update propagation path from a signal, memo, or prop (#2903 —
1113
+ * a prop is named as spelled in the graph: `title` / `props.value`).
1033
1114
  * Shows all downstream effects, memos, and DOM bindings.
1034
1115
  */
1035
1116
  export function traceUpdatePath(graph: ComponentGraph, targetName: string): UpdatePath | null {
1036
- // Find the target in signals or memos
1037
1117
  const signal = graph.signals.find(s => s.name === targetName)
1118
+ if (signal) return { target: targetName, kind: 'signal', dependents: traceConsumers(signal.consumers, graph) }
1038
1119
  const memo = graph.memos.find(m => m.name === targetName)
1120
+ if (memo) return { target: targetName, kind: 'memo', dependents: traceConsumers(memo.consumers, graph) }
1121
+ const prop = graph.props.find(p => p.name === targetName)
1122
+ if (prop) return { target: targetName, kind: 'prop', dependents: traceConsumers(prop.consumers, graph) }
1123
+ return null
1124
+ }
1039
1125
 
1040
- if (!signal && !memo) return null
1041
-
1042
- const kind = signal ? 'signal' : 'memo'
1043
- const consumers = signal ? signal.consumers : memo!.consumers
1044
-
1045
- const dependents = consumers.map(consumer => buildUpdateEntry(consumer, graph, new Set()))
1046
-
1047
- return { target: targetName, kind: kind as 'signal' | 'memo', dependents }
1126
+ function traceConsumers(consumers: string[], graph: ComponentGraph): UpdatePathEntry[] {
1127
+ return consumers.map(consumer => buildUpdateEntry(consumer, graph, new Set()))
1048
1128
  }
1049
1129
 
1050
1130
  function buildUpdateEntry(consumer: string, graph: ComponentGraph, visited: Set<string>): UpdatePathEntry {
@@ -1145,6 +1225,14 @@ export function buildWhyUpdate(
1145
1225
  if (memo) {
1146
1226
  deps.push({ name, kind: 'memo', dependsOn: memo.deps, changedBy: [] })
1147
1227
  for (const dep of memo.deps) traceDep(dep)
1228
+ return
1229
+ }
1230
+
1231
+ // A prop is driven by the parent, so it has no in-component setter to
1232
+ // trace — but it IS a real reactive source (#2903), so report it rather
1233
+ // than silently dropping the dep.
1234
+ if (graph.props.some(p => p.name === name)) {
1235
+ deps.push({ name, kind: 'prop', dependsOn: [], changedBy: [] })
1148
1236
  }
1149
1237
  }
1150
1238
 
@@ -1179,6 +1267,9 @@ export function formatWhyUpdate(result: WhyUpdateResult): string {
1179
1267
  if (dep.kind === 'memo') {
1180
1268
  lines.push(`${dep.name} depends on:`)
1181
1269
  for (const d of dep.dependsOn) lines.push(` ${d}`)
1270
+ } else if (dep.kind === 'prop') {
1271
+ lines.push(`${dep.name} changes from:`)
1272
+ lines.push(' (prop — the parent component passes a new value)')
1182
1273
  } else {
1183
1274
  lines.push(`${dep.name} changes from:`)
1184
1275
  if (dep.changedBy.length === 0) {
@@ -1232,6 +1323,16 @@ export function formatComponentGraph(graph: ComponentGraph): string {
1232
1323
  }
1233
1324
  }
1234
1325
 
1326
+ // Props read reactively by a DOM binding (#2903) — listed like signals /
1327
+ // memos so the `<- props.value` / `props.value -> dom:…` edges below have a
1328
+ // node to point at.
1329
+ if (graph.props.length > 0) {
1330
+ lines.push(` props:`)
1331
+ for (const p of graph.props) {
1332
+ lines.push(` ${p.name}`)
1333
+ }
1334
+ }
1335
+
1235
1336
  // DOM bindings. Fallback-wrapped expressions (#937 Solid-style
1236
1337
  // wrap-by-default) are marked with a leading `~` so users can spot
1237
1338
  // expressions whose reactivity couldn't be statically proven — these
@@ -1272,7 +1373,7 @@ export function formatComponentGraph(graph: ComponentGraph): string {
1272
1373
  }
1273
1374
 
1274
1375
  // Dependency graph
1275
- if (graph.signals.length > 0 || graph.memos.length > 0) {
1376
+ if (graph.signals.length > 0 || graph.memos.length > 0 || graph.props.length > 0) {
1276
1377
  lines.push(` dependency graph:`)
1277
1378
  for (const s of graph.signals) {
1278
1379
  for (const consumer of s.consumers) {
@@ -1284,6 +1385,11 @@ export function formatComponentGraph(graph: ComponentGraph): string {
1284
1385
  lines.push(` ${m.name} -> ${consumer}`)
1285
1386
  }
1286
1387
  }
1388
+ for (const p of graph.props) {
1389
+ for (const consumer of p.consumers) {
1390
+ lines.push(` ${p.name} -> ${consumer}`)
1391
+ }
1392
+ }
1287
1393
  }
1288
1394
 
1289
1395
  return lines.join('\n')
@@ -1341,6 +1447,10 @@ export function graphToJSON(graph: ComponentGraph): object {
1341
1447
  body: e.body,
1342
1448
  loc: e.loc,
1343
1449
  })),
1450
+ props: graph.props.map(p => ({
1451
+ name: p.name,
1452
+ consumers: p.consumers,
1453
+ })),
1344
1454
  domBindings: graph.domBindings.map(d => ({
1345
1455
  label: d.label,
1346
1456
  slotId: d.slotId,
@@ -1689,13 +1799,18 @@ function collectDomBindings(
1689
1799
  // `BindingScope.valueBoundNames`'s docstring) — reads `valueBoundNames()`,
1690
1800
  // not `boundNames()`.
1691
1801
  scope: BindingScope = BindingScope.EMPTY,
1692
- // Predicate: does an attribute expression read a component prop? Mirrors the
1693
- // emitter's `needsEffectWrapper` prop detection so a prop-driven attribute
1802
+ // Which component props does a binding expression read? Mirrors the
1803
+ // emitter's `needsEffectWrapper` prop detection so a prop-driven binding
1694
1804
  // (wrapped in `createEffect` at codegen, hence emitting `#binding:<slot>`) is
1695
- // tracked here too — otherwise its profiler id resolves to `(unresolved)`.
1696
- readsProp: (expr: string, freeIds?: ReadonlySet<string>) => boolean = () => false,
1805
+ // tracked here too — otherwise its profiler id resolves to `(unresolved)` and
1806
+ // the graph prints `(no tracked deps)` for it (#2903). Returns the prop
1807
+ // names, which join `deps` alongside signal / memo reads.
1808
+ propDepsOf: (expr: string, freeIds?: ReadonlySet<string>, isShadowed?: (name: string) => boolean) => string[] = () => [],
1697
1809
  ): void {
1698
1810
  const boundNames = scope.valueBoundNames()
1811
+ // Shadow guard for prop deps (see `propDepsOf`'s `isShadowed` in
1812
+ // `buildGraphFromIR`): a loop-row binding hides an outer prop of the same name.
1813
+ const isShadowed = scope.asShadowPredicate()
1699
1814
  // Does a loop-child binding read a loop param (or index)? Use the analyzer's
1700
1815
  // lexer-resolved metadata, NOT a raw-string regex — so a param name that only
1701
1816
  // appears inside a string literal (index `i` vs `'i'`) is not mistaken for a
@@ -1712,6 +1827,13 @@ function collectDomBindings(
1712
1827
  boundNames.size > 0 && (n.origin?.freeRefs?.some(r => boundNames.has(r.name)) ?? false)
1713
1828
  const attrReadsLoopParam = (free: ReadonlySet<string> | undefined): boolean =>
1714
1829
  boundNames.size > 0 && free !== undefined && setSomeIn(boundNames, free)
1830
+ // Text / conditional nodes carry no `freeIdentifiers`; their analyzer-resolved
1831
+ // `origin.freeRefs` is the equivalent lexer-aware identifier set (a
1832
+ // `reactive-brand` ref's name is a full access path, which simply never
1833
+ // matches a prop name). Absent origin ⇒ `undefined` ⇒ `propDepsOf` falls back
1834
+ // to `tokenContainsIdent`.
1835
+ const freeIdsOf = (origin: OriginInfo | undefined): ReadonlySet<string> | undefined =>
1836
+ origin?.freeRefs ? new Set(origin.freeRefs.map(r => r.name)) : undefined
1715
1837
  switch (node.type) {
1716
1838
  case 'element': {
1717
1839
  // Dynamic attribute bindings (style, class, aria-*, data-*, etc.)
@@ -1728,19 +1850,21 @@ function collectDomBindings(
1728
1850
  if (attr.name === 'key' && boundNames.size > 0) continue
1729
1851
  const expr = attrValueToString(attr.value)
1730
1852
  if (!expr) continue
1731
- const deps = extractReactiveDeps(expr, signalGetters, memoNames)
1732
- const isReactive = deps.length > 0 || attrReadsLoopParam(attr.freeIdentifiers)
1853
+ const signalDeps = extractReactiveDeps(expr, signalGetters, memoNames)
1854
+ const isReactive = signalDeps.length > 0 || attrReadsLoopParam(attr.freeIdentifiers)
1733
1855
  // A prop-driven attribute (`id={props.id}`, `class={`…${props.x}`}`) is
1734
1856
  // wrapped in a `createEffect` by the emitter even with no signal/memo
1735
- // dep — match that gate so its `#binding:<slot>` id resolves.
1736
- const hasPropsRef = readsProp(expr, attr.freeIdentifiers)
1857
+ // dep — match that gate so its `#binding:<slot>` id resolves, and list
1858
+ // the props read as deps (#2903).
1859
+ const propDeps = propDepsOf(expr, attr.freeIdentifiers, isShadowed)
1860
+ const hasPropsRef = propDeps.length > 0
1737
1861
  const wrapReason = inferWrapReasonForAttrLike(isReactive, hasPropsRef, attr)
1738
1862
  if (wrapReason) {
1739
1863
  bindings.push({
1740
1864
  kind: 'dom',
1741
1865
  label: attr.name,
1742
1866
  slotId: node.slotId ?? '?',
1743
- deps,
1867
+ deps: [...signalDeps, ...propDeps],
1744
1868
  type: 'attribute',
1745
1869
  classification: isReactive || hasPropsRef ? 'reactive' : 'fallback',
1746
1870
  expression: expr,
@@ -1768,7 +1892,7 @@ function collectDomBindings(
1768
1892
  }
1769
1893
  // Recurse — pass element tag as parent context for text bindings
1770
1894
  for (const child of node.children) {
1771
- collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, readsProp)
1895
+ collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, propDepsOf)
1772
1896
  }
1773
1897
  break
1774
1898
  }
@@ -1778,7 +1902,10 @@ function collectDomBindings(
1778
1902
  const decision = decideWrapFromAstFlags(node)
1779
1903
  const loopReactive = exprReadsLoopParam(node)
1780
1904
  if ((decision.wrap || loopReactive) && node.slotId) {
1781
- const deps = extractReactiveDeps(node.expr, signalGetters, memoNames)
1905
+ const deps = [
1906
+ ...extractReactiveDeps(node.expr, signalGetters, memoNames),
1907
+ ...propDepsOf(node.expr, freeIdsOf(node.origin), isShadowed),
1908
+ ]
1782
1909
  const preview = parentTag
1783
1910
  ? `<${parentTag}>{${truncateExpr(node.expr)}}</${parentTag}>`
1784
1911
  : `{${truncateExpr(node.expr)}}`
@@ -1808,7 +1935,10 @@ function collectDomBindings(
1808
1935
  const loopReactive =
1809
1936
  boundNames.size > 0 && (node.origin?.freeRefs?.some(r => boundNames.has(r.name)) ?? false)
1810
1937
  if ((decision.wrap || loopReactive) && node.slotId) {
1811
- const deps = extractReactiveDeps(node.condition, signalGetters, memoNames)
1938
+ const deps = [
1939
+ ...extractReactiveDeps(node.condition, signalGetters, memoNames),
1940
+ ...propDepsOf(node.condition, freeIdsOf(node.origin), isShadowed),
1941
+ ]
1812
1942
  bindings.push({
1813
1943
  kind: 'dom',
1814
1944
  label: `conditional "${node.slotId}"`,
@@ -1825,8 +1955,8 @@ function collectDomBindings(
1825
1955
  jsxPreview: `{${truncateExpr(node.condition)} ? ... : ...}`,
1826
1956
  })
1827
1957
  }
1828
- collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope, readsProp)
1829
- collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope, readsProp)
1958
+ collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf)
1959
+ collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf)
1830
1960
  break
1831
1961
  }
1832
1962
  case 'loop': {
@@ -1877,7 +2007,7 @@ function collectDomBindings(
1877
2007
  // `paramBindings`/`preamble`), so no bespoke Set bookkeeping is needed.
1878
2008
  const childScope = scope.enterLoopRow(node)
1879
2009
  for (const child of node.children) {
1880
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, readsProp)
2010
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, propDepsOf)
1881
2011
  }
1882
2012
  break
1883
2013
  }
@@ -1888,22 +2018,23 @@ function collectDomBindings(
1888
2018
  if (prop.value.kind !== 'expression' && prop.value.kind !== 'template' && prop.value.kind !== 'spread') continue
1889
2019
  const propValue = attrValueToString(prop.value) ?? ''
1890
2020
  if (!propValue) continue
1891
- const deps = extractReactiveDeps(propValue, signalGetters, memoNames)
2021
+ const signalDeps = extractReactiveDeps(propValue, signalGetters, memoNames)
1892
2022
  // Mirror the element-attr gate: a child prop is wrapped (and emits
1893
2023
  // `#binding:<slot>`) when it reads a prop directly or via a prop-derived
1894
2024
  // local const (`<Slot className={classes}>`). The previous
1895
2025
  // `includes('props.')` check missed both destructured props and the
1896
2026
  // local-const indirection, leaving the forwarded binding `(unresolved)`
1897
2027
  // (#1863).
1898
- const hasPropsRef = readsProp(propValue, prop.freeIdentifiers)
1899
- const isReactive = deps.length > 0 || hasPropsRef
1900
- const wrapReason = inferWrapReasonForAttrLike(deps.length > 0, hasPropsRef, prop)
2028
+ const propDeps = propDepsOf(propValue, prop.freeIdentifiers, isShadowed)
2029
+ const hasPropsRef = propDeps.length > 0
2030
+ const isReactive = signalDeps.length > 0 || hasPropsRef
2031
+ const wrapReason = inferWrapReasonForAttrLike(signalDeps.length > 0, hasPropsRef, prop)
1901
2032
  if (wrapReason) {
1902
2033
  bindings.push({
1903
2034
  kind: 'dom',
1904
2035
  label: `${node.name}.${prop.name}`,
1905
2036
  slotId: node.slotId ?? '?',
1906
- deps,
2037
+ deps: [...signalDeps, ...propDeps],
1907
2038
  type: 'attribute',
1908
2039
  classification: isReactive ? 'reactive' : 'fallback',
1909
2040
  expression: propValue,
@@ -1916,21 +2047,21 @@ function collectDomBindings(
1916
2047
  }
1917
2048
  }
1918
2049
  for (const child of node.children) {
1919
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp)
2050
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf)
1920
2051
  }
1921
2052
  break
1922
2053
  }
1923
2054
  case 'fragment':
1924
2055
  case 'provider': {
1925
2056
  for (const child of node.children) {
1926
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp)
2057
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf)
1927
2058
  }
1928
2059
  break
1929
2060
  }
1930
2061
  case 'if-statement': {
1931
- collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, readsProp)
2062
+ collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf)
1932
2063
  if (node.alternate) {
1933
- collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, readsProp)
2064
+ collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf)
1934
2065
  }
1935
2066
  break
1936
2067
  }
@@ -1943,37 +2074,36 @@ function truncateExpr(expr: string, max: number = 40): string {
1943
2074
  }
1944
2075
 
1945
2076
  /**
1946
- * True when `expr` contains a genuine `<propsObject>.<member>` property access
1947
- * with `member !== 'children'` — the emitter's prop gate for the props object
1948
- * (`needsEffectWrapper`, `reactivity.ts`). Parses the expression rather than
1949
- * regex-matching the raw string, so a `props.` inside a string literal/comment
1950
- * doesn't false-match, and bare `props` / `props.children` are excluded. Parse
1951
- * failures (e.g. an attribute expression carrying JSX) fall back to `false` —
1952
- * conservative: we never invent a binding the emitter wouldn't wrap.
2077
+ * Member names of every genuine `<propsObject>.<member>` property access in
2078
+ * `expr` with `member !== 'children'` — the emitter's prop gate for the props
2079
+ * object (`needsEffectWrapper`, `reactivity.ts`). Parses the expression rather
2080
+ * than regex-matching the raw string, so a `props.` inside a string literal /
2081
+ * comment doesn't false-match, and bare `props` / `props.children` are
2082
+ * excluded. Parse failures (e.g. an attribute expression carrying JSX) yield
2083
+ * `[]` — conservative: we never invent a binding the emitter wouldn't wrap.
2084
+ * Deduplicated, in first-seen order.
1953
2085
  */
1954
- function exprReadsPropMember(expr: string, propsObjectName: string): boolean {
2086
+ function collectPropMembers(expr: string, propsObjectName: string): string[] {
1955
2087
  let sf: ts.SourceFile
1956
2088
  try {
1957
2089
  sf = ts.createSourceFile('__attr.tsx', `(${expr})`, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX)
1958
2090
  } catch {
1959
- return false
2091
+ return []
1960
2092
  }
1961
- let found = false
2093
+ const members = new Set<string>()
1962
2094
  const visit = (n: ts.Node): void => {
1963
- if (found) return
1964
2095
  if (
1965
2096
  ts.isPropertyAccessExpression(n) &&
1966
2097
  ts.isIdentifier(n.expression) &&
1967
2098
  n.expression.text === propsObjectName &&
1968
2099
  n.name.text !== 'children'
1969
2100
  ) {
1970
- found = true
1971
- return
2101
+ members.add(n.name.text)
1972
2102
  }
1973
2103
  ts.forEachChild(n, visit)
1974
2104
  }
1975
2105
  visit(sf)
1976
- return found
2106
+ return [...members]
1977
2107
  }
1978
2108
 
1979
2109
  /** Convert an `AttrValue` to a flat string for reactive dep extraction. */