@barefootjs/jsx 0.39.6 → 0.39.8

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 (192) hide show
  1. package/dist/adapters/attr-plan.d.ts +8 -1
  2. package/dist/adapters/attr-plan.d.ts.map +1 -1
  3. package/dist/adapters/callback-method.d.ts +44 -0
  4. package/dist/adapters/callback-method.d.ts.map +1 -1
  5. package/dist/adapters/component-props.d.ts +80 -13
  6. package/dist/adapters/component-props.d.ts.map +1 -1
  7. package/dist/adapters/computed-const.d.ts +52 -0
  8. package/dist/adapters/computed-const.d.ts.map +1 -0
  9. package/dist/adapters/dangerous-inner-html.d.ts +10 -0
  10. package/dist/adapters/dangerous-inner-html.d.ts.map +1 -1
  11. package/dist/adapters/dsl-template-adapter.d.ts +151 -0
  12. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -0
  13. package/dist/adapters/element-shell.d.ts +44 -0
  14. package/dist/adapters/element-shell.d.ts.map +1 -0
  15. package/dist/adapters/interface.d.ts +2 -0
  16. package/dist/adapters/interface.d.ts.map +1 -1
  17. package/dist/adapters/jsx-adapter.d.ts +4 -0
  18. package/dist/adapters/jsx-adapter.d.ts.map +1 -1
  19. package/dist/adapters/literal-value.d.ts +2 -2
  20. package/dist/adapters/literal-value.d.ts.map +1 -1
  21. package/dist/adapters/parsed-expr-emitter.d.ts +27 -0
  22. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  23. package/dist/adapters/style-object.d.ts +33 -0
  24. package/dist/adapters/style-object.d.ts.map +1 -0
  25. package/dist/analyzer.d.ts.map +1 -1
  26. package/dist/augment-inherited-props.d.ts +7 -0
  27. package/dist/augment-inherited-props.d.ts.map +1 -1
  28. package/dist/children-nullish.d.ts +22 -0
  29. package/dist/children-nullish.d.ts.map +1 -0
  30. package/dist/errors.d.ts +1 -0
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/expression-parser.d.ts +9 -19
  33. package/dist/expression-parser.d.ts.map +1 -1
  34. package/dist/fold-render-reassignments.d.ts +43 -0
  35. package/dist/fold-render-reassignments.d.ts.map +1 -0
  36. package/dist/free-refs.d.ts +15 -0
  37. package/dist/free-refs.d.ts.map +1 -1
  38. package/dist/index.d.ts +21 -14
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +24620 -23233
  41. package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
  42. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts +2 -1
  43. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts.map +1 -1
  44. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -2
  45. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
  46. package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +10 -9
  48. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
  49. package/dist/ir-to-client-js/csr-substitute.d.ts +0 -13
  50. package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
  51. package/dist/ir-to-client-js/emit-reactive.d.ts +1 -1
  52. package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
  53. package/dist/ir-to-client-js/emit-registration.d.ts +10 -8
  54. package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
  55. package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
  56. package/dist/ir-to-client-js/html-template.d.ts +9 -19
  57. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  58. package/dist/ir-to-client-js/identifiers.d.ts +6 -8
  59. package/dist/ir-to-client-js/identifiers.d.ts.map +1 -1
  60. package/dist/ir-to-client-js/imports.d.ts +23 -2
  61. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  62. package/dist/ir-to-client-js/index.d.ts.map +1 -1
  63. package/dist/ir-to-client-js/phases/props-extraction.d.ts +3 -2
  64. package/dist/ir-to-client-js/phases/props-extraction.d.ts.map +1 -1
  65. package/dist/ir-to-client-js/plan/declaration-emit.d.ts +5 -0
  66. package/dist/ir-to-client-js/plan/declaration-emit.d.ts.map +1 -1
  67. package/dist/ir-to-client-js/prop-handling.d.ts +11 -12
  68. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  69. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +1 -1
  70. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
  71. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  72. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts +1 -1
  73. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts.map +1 -1
  74. package/dist/ir-to-client-js/safe-html.d.ts +20 -2
  75. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  76. package/dist/ir-to-client-js/types.d.ts +3 -3
  77. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  78. package/dist/ir-to-client-js/utils.d.ts +15 -11
  79. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  80. package/dist/jsx-to-ir.d.ts.map +1 -1
  81. package/dist/nullable-signal-attr.d.ts +43 -12
  82. package/dist/nullable-signal-attr.d.ts.map +1 -1
  83. package/dist/prop-rewrite.d.ts +18 -0
  84. package/dist/prop-rewrite.d.ts.map +1 -1
  85. package/dist/props-binding.d.ts +43 -6
  86. package/dist/props-binding.d.ts.map +1 -1
  87. package/dist/relocate.d.ts +16 -0
  88. package/dist/relocate.d.ts.map +1 -1
  89. package/dist/scanner/js-scanner.d.ts.map +1 -1
  90. package/dist/scanner/js-scanner.js +30 -2
  91. package/dist/signal-prop-name-collision.d.ts +6 -5
  92. package/dist/signal-prop-name-collision.d.ts.map +1 -1
  93. package/dist/ssr-defaults.d.ts +28 -0
  94. package/dist/ssr-defaults.d.ts.map +1 -1
  95. package/dist/ssr-seed-plan.d.ts +37 -18
  96. package/dist/ssr-seed-plan.d.ts.map +1 -1
  97. package/dist/types.d.ts +162 -20
  98. package/dist/types.d.ts.map +1 -1
  99. package/dist/value-references.d.ts +21 -0
  100. package/dist/value-references.d.ts.map +1 -1
  101. package/package.json +2 -2
  102. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +18 -18
  103. package/src/__tests__/adapter-output.test.ts +5 -3
  104. package/src/__tests__/analyzer.test.ts +33 -0
  105. package/src/__tests__/arithmetic-lowering.test.ts +44 -0
  106. package/src/__tests__/block-memo-type.test.ts +51 -0
  107. package/src/__tests__/callback-method.test.ts +75 -0
  108. package/src/__tests__/children-read.test.ts +226 -0
  109. package/src/__tests__/client-only-date-lowering.test.ts +2 -2
  110. package/src/__tests__/client-template-escape-soundness.test.ts +31 -1
  111. package/src/__tests__/component-props.test.ts +68 -1
  112. package/src/__tests__/computed-const.test.ts +101 -0
  113. package/src/__tests__/constant-inlining-tree.test.ts +136 -0
  114. package/src/__tests__/destructure-default-reads-earlier-param.test.ts +138 -0
  115. package/src/__tests__/dsl-template-adapter.test.ts +173 -0
  116. package/src/__tests__/element-shell.test.ts +78 -0
  117. package/src/__tests__/event-handler-verbatim.test.ts +73 -0
  118. package/src/__tests__/expression-parser.test.ts +1 -44
  119. package/src/__tests__/fold-render-reassignments.test.ts +96 -0
  120. package/src/__tests__/inlinable-local-method-call.test.ts +81 -0
  121. package/src/__tests__/memo-body-expr.test.ts +120 -0
  122. package/src/__tests__/nullable-signal-attr.test.ts +67 -3
  123. package/src/__tests__/prop-handling.test.ts +35 -16
  124. package/src/__tests__/props-alias-const.test.ts +65 -0
  125. package/src/__tests__/reference-graph-identifiers.test.ts +161 -0
  126. package/src/__tests__/runtime-import-detection.test.ts +134 -0
  127. package/src/__tests__/signal-prop-name-collision.test.ts +30 -0
  128. package/src/__tests__/signal-prop-seed.test.ts +90 -0
  129. package/src/__tests__/ssr-defaults.test.ts +19 -1
  130. package/src/__tests__/ssr-seed-plan.test.ts +173 -1
  131. package/src/__tests__/static-template-reachability.test.ts +137 -0
  132. package/src/__tests__/style-object-plan.test.ts +54 -0
  133. package/src/__tests__/zero-param-helper-inline.test.ts +57 -0
  134. package/src/adapters/attr-plan.ts +29 -1
  135. package/src/adapters/callback-method.ts +85 -0
  136. package/src/adapters/component-props.ts +130 -12
  137. package/src/adapters/computed-const.ts +185 -0
  138. package/src/adapters/dangerous-inner-html.ts +33 -0
  139. package/src/adapters/dsl-template-adapter.ts +248 -0
  140. package/src/adapters/element-shell.ts +160 -0
  141. package/src/adapters/interface.ts +8 -0
  142. package/src/adapters/jsx-adapter.ts +12 -6
  143. package/src/adapters/literal-value.ts +2 -2
  144. package/src/adapters/parsed-expr-emitter.ts +34 -0
  145. package/src/adapters/style-object.ts +61 -0
  146. package/src/analyzer.ts +382 -94
  147. package/src/augment-inherited-props.ts +12 -0
  148. package/src/children-nullish.ts +33 -0
  149. package/src/debug.ts +2 -2
  150. package/src/errors.ts +12 -0
  151. package/src/expression-parser.ts +56 -53
  152. package/src/fold-render-reassignments.ts +314 -0
  153. package/src/free-refs.ts +77 -17
  154. package/src/index.ts +27 -10
  155. package/src/ir-to-client-js/compute-inlinability.ts +122 -19
  156. package/src/ir-to-client-js/control-flow/plan/event-collision.ts +2 -1
  157. package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -2
  158. package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +3 -2
  159. package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +13 -12
  160. package/src/ir-to-client-js/csr-substitute.ts +25 -37
  161. package/src/ir-to-client-js/emit-reactive.ts +2 -2
  162. package/src/ir-to-client-js/emit-registration.ts +31 -59
  163. package/src/ir-to-client-js/generate-init.ts +17 -1
  164. package/src/ir-to-client-js/html-template.ts +56 -120
  165. package/src/ir-to-client-js/identifiers.ts +75 -24
  166. package/src/ir-to-client-js/imports.ts +56 -19
  167. package/src/ir-to-client-js/index.ts +5 -3
  168. package/src/ir-to-client-js/init-declarations.ts +1 -1
  169. package/src/ir-to-client-js/phases/event-handlers.ts +2 -2
  170. package/src/ir-to-client-js/phases/props-extraction.ts +16 -15
  171. package/src/ir-to-client-js/plan/build-declaration-emit.ts +26 -52
  172. package/src/ir-to-client-js/plan/declaration-emit.ts +5 -0
  173. package/src/ir-to-client-js/prop-handling.ts +13 -54
  174. package/src/ir-to-client-js/prune-unused-prop-extractions.ts +7 -4
  175. package/src/ir-to-client-js/reactivity.ts +2 -2
  176. package/src/ir-to-client-js/rewrite-destructured-props.ts +27 -9
  177. package/src/ir-to-client-js/safe-html.ts +29 -35
  178. package/src/ir-to-client-js/stringify/declaration-emit.ts +1 -1
  179. package/src/ir-to-client-js/types.ts +3 -2
  180. package/src/ir-to-client-js/utils.ts +13 -26
  181. package/src/jsx-to-ir.ts +318 -130
  182. package/src/nullable-signal-attr.ts +156 -37
  183. package/src/prop-rewrite.ts +41 -0
  184. package/src/props-binding.ts +117 -7
  185. package/src/relocate.ts +40 -8
  186. package/src/scanner/__tests__/js-scanner.test.ts +37 -0
  187. package/src/scanner/js-scanner.ts +64 -4
  188. package/src/signal-prop-name-collision.ts +50 -24
  189. package/src/ssr-defaults.ts +47 -20
  190. package/src/ssr-seed-plan.ts +121 -29
  191. package/src/types.ts +165 -21
  192. package/src/value-references.ts +132 -0
@@ -25,7 +25,7 @@
25
25
  */
26
26
 
27
27
  import ts from 'typescript'
28
- import type { PropUsage } from '../types.ts'
28
+ import { type PropUsage, isChildrenPropParam } from '../types.ts'
29
29
  import { computePropsUsedAsConditions } from './compute-prop-usage.ts'
30
30
  import { boundPropLocalNames, livePropReadExpr, resolveBodyPropAliases, type LivePropReadInfo } from '../props-binding.ts'
31
31
  import { parsePropReadInitializer } from './prune-unused-prop-extractions.ts'
@@ -54,7 +54,8 @@ export function rewriteDestructuredPropReads(
54
54
  * handler-local `const title = 'local'` keep their own binding even when
55
55
  * `title` is also a prop name.
56
56
  *
57
- * Excluding `children`: reading `_p.children` live re-invokes a getter that
57
+ * Excluding the children prop (`isChildrenPropParam`, renamed or not):
58
+ * reading `_p.children` live re-invokes a getter that
58
59
  * instantiates child components (see `emitPropsExtraction`) — `children`
59
60
  * must stay a captured-once read, by design.
60
61
  *
@@ -74,7 +75,7 @@ function rewriteParamDestructuredReads(
74
75
  propUsage: ReadonlyMap<string, PropUsage>,
75
76
  ): string {
76
77
  const names = new Set(boundPropLocalNames(ctx))
77
- names.delete('children')
78
+ for (const p of ctx.propsParams) if (isChildrenPropParam(p)) names.delete(p.name)
78
79
  if (names.size === 0) return code
79
80
 
80
81
  const propsUsedAsConditions = computePropsUsedAsConditions(ctx, names)
@@ -102,16 +103,27 @@ function rewriteParamDestructuredReads(
102
103
  return result
103
104
  }
104
105
 
106
+ /**
107
+ * The `defaultParts` the analyzer recorded on a body-destructured local's
108
+ * props param (`ParamInfo.defaultParts`), when its default reads an earlier
109
+ * binding of the same pattern.
110
+ */
111
+ function bodyAliasDefaultParts(ctx: ClientJsContext, local: string, key: string): Pick<LivePropReadInfo, 'defaultParts'> {
112
+ const param = ctx.propsParams.find(p => !p.isRest && p.name === local && (p.sourceName ?? p.name) === key)
113
+ return param?.defaultParts ? { defaultParts: param.defaultParts } : {}
114
+ }
115
+
105
116
  /**
106
117
  * Rewrite every bare value-position read of a BODY-destructured (or
107
118
  * bare-member-alias) prop local in `code` to a live `_p.<key>` read, for a
108
119
  * bare-props-form component (`function Foo(props: Props)`).
109
120
  *
110
- * `resolveBodyPropAliases` can't distinguish `const { value } = props` from
111
- * `const value = props.value` (the analyzer's IR is identical for both —
112
- * see its docstring), so this rewrite treats them identically too. That's
113
- * the correct call, not a shortcut: BOTH are pure single-prop passthroughs
114
- * with no computation of their own, so both should read live, matching
121
+ * `resolveBodyPropAliases` treats `const { value } = props` and `const value
122
+ * = props.value` alike (their `value` text is identical; only
123
+ * `ConstantInfo.propsDestructure` tells them apart, #3501), and so does this
124
+ * rewrite. That's the correct call, not a shortcut: BOTH are pure
125
+ * single-prop passthroughs with no computation of their own, so both should
126
+ * read live, matching
115
127
  * `props.value` used directly (which already reads live via
116
128
  * `rewritePropsObjectRef`).
117
129
  *
@@ -149,7 +161,7 @@ function rewriteBodyAliasReads(code: string, ctx: ClientJsContext): string {
149
161
  const sourceFile = ts.createSourceFile('init-body.ts', code, ts.ScriptTarget.Latest, /*setParentNodes*/ true, ts.ScriptKind.TS)
150
162
 
151
163
  const spans: Array<readonly [number, number]> = []
152
- const located = new Map<string, { key: string; defaultValue?: string; defaultContainsArrow?: boolean }>()
164
+ const located = new Map<string, Pick<LivePropReadInfo, 'defaultValue' | 'defaultContainsArrow' | 'defaultParts'> & { key: string }>()
153
165
  for (const stmt of sourceFile.statements) {
154
166
  if (!ts.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith('init') || !stmt.body) continue
155
167
  for (const inner of stmt.body.statements) {
@@ -180,6 +192,11 @@ function rewriteBodyAliasReads(code: string, ctx: ClientJsContext): string {
180
192
  defaultContainsArrow: alias.defaultContainsArrow && !(
181
193
  parsedInit.fallback && ts.isParenthesizedExpression(parsedInit.fallback)
182
194
  ),
195
+ // A default reading an earlier binding of the same destructure
196
+ // (`const { off = false, on = off } = props`, #3531): the analyzer
197
+ // split it on the binding's props param, and the earlier binding's
198
+ // declaration is gone from this body, so the read renders live.
199
+ ...bodyAliasDefaultParts(ctx, decl.name.text, alias.key),
183
200
  })
184
201
  spans.push([inner.getFullStart(), inner.getEnd()])
185
202
  }
@@ -204,6 +221,7 @@ function rewriteBodyAliasReads(code: string, ctx: ClientJsContext): string {
204
221
  sourceName: info.key,
205
222
  defaultValue: info.defaultValue,
206
223
  defaultContainsArrow: info.defaultContainsArrow,
224
+ ...(info.defaultParts && { defaultParts: info.defaultParts }),
207
225
  }
208
226
  return livePropReadExpr(prop, undefined, false)
209
227
  }
@@ -37,7 +37,7 @@
37
37
  */
38
38
 
39
39
  import type { IRExpression } from '../types.ts'
40
- import { parseExpression, type ParsedExpr } from '../expression-parser.ts'
40
+ import { PROPS_PARAM } from './utils.ts'
41
41
 
42
42
  /**
43
43
  * A JS expression string that evaluates, in the client template, to HTML
@@ -110,6 +110,27 @@ export function childrenMarkup(expr: string): SafeHtml {
110
110
  return safeHtml(`markupOrEmpty(${expr})`)
111
111
  }
112
112
 
113
+ /**
114
+ * `_p.children == null ? escapeText(expr) : markupOrEmpty(_p.children)` — a
115
+ * read of the children prop with a text fallback: `children ?? 'x'`,
116
+ * `(children ?? '<b>x</b>') ?? ''` (`absentWhen: 'nullish'`), or
117
+ * `children || 'x'` (`absentWhen: 'falsy'`, tested as `!_p.children`); #3554.
118
+ * Phase 1 decided from the binding that the chain's head is the component's
119
+ * own `children` prop (`IRExpression.childrenRead`), so the head is read where
120
+ * every client template finds that prop, `_p.children` (the same place the
121
+ * Phase 1 `templateExpr` rewrite and the alias inlining resolve a destructured
122
+ * or aliased `children` to). Present children are the HTML string
123
+ * `materializeComponent` joined, spliced as `childrenMarkup` does; otherwise
124
+ * `expr` (the whole lowered chain) evaluates to its fallback, which is text
125
+ * and escaped. `expr` is not split: when the head is absent,
126
+ * `(c ?? x) ?? y` and `c ?? (x ?? y)` both evaluate to `x ?? y`.
127
+ */
128
+ export function childrenMarkupOrEscapedFallback(expr: string, absentWhen: 'nullish' | 'falsy'): SafeHtml {
129
+ const children = `${PROPS_PARAM}.children`
130
+ const absent = absentWhen === 'nullish' ? `${children} == null` : `!${children}`
131
+ return safeHtml(`${absent} ? escapeText(${expr}) : markupOrEmpty(${children})`)
132
+ }
133
+
113
134
  /**
114
135
  * Stage 3 / D4 — an element-array child (`{out}`) built by an arbitrary
115
136
  * `.map()` preamble is an array of compiled-leaf HTML strings; join it
@@ -179,37 +200,6 @@ export const EMPTY_MARKUP: SafeHtml = safeHtml("''")
179
200
  // The door for a child-position expression node.
180
201
  // ---------------------------------------------------------------------------
181
202
 
182
- /**
183
- * Recognizes a JSX child-position expression that is exactly a reference to
184
- * the reserved `children` prop, optionally with `?? ''`: bare `children` (destructured) or
185
- * `<receiver>.children` for any single-identifier receiver (`props.children`,
186
- * a custom props-param name, a loop-scoped alias closing over props, ...).
187
- *
188
- * Deliberately LOOSER than `isTransparentFragment` (`jsx-to-ir.ts`), which
189
- * runs on the TS AST with the analyzer-resolved props name in hand. This
190
- * layer parses IR expressions without analyzer context, so any single-identifier receiver
191
- * is the available approximation. The looseness costs nothing measurable: an
192
- * unrelated `.children` member (a tree node's own `children` array, say) is a
193
- * reactive member expression that gets a `slotId` and takes the slotted arm
194
- * of `spliceChildValue` before this predicate is consulted.
195
- */
196
- function isChildrenPassthroughExpr(expr: string): boolean {
197
- return isChildrenPassthrough(parseExpression(expr))
198
- }
199
-
200
- function isChildrenPassthrough(expr: ParsedExpr): boolean {
201
- if (expr.kind === 'identifier') return expr.name === 'children'
202
- if (expr.kind === 'member') {
203
- return expr.object.kind === 'identifier' && expr.property === 'children'
204
- && !expr.computed && !expr.optional
205
- }
206
- // An empty fallback adds no untrusted text to the compiler-built markup.
207
- // Other fallbacks still take the escape-by-default path.
208
- return expr.kind === 'logical' && expr.op === '??'
209
- && expr.right.kind === 'literal' && expr.right.value === ''
210
- && isChildrenPassthrough(expr.left)
211
- }
212
-
213
203
  export interface ChildSpliceContext {
214
204
  /**
215
205
  * Set while emitting inside a conditional-branch `template()` arrow
@@ -241,7 +231,9 @@ export interface ChildSpliceContext {
241
231
  * 3. `slotId` ∈ markupSlotIds → `escapedTextOrMarkup`
242
232
  * 4. `slotId` → `escapedText`
243
233
  * 5. `{children}` passthrough → `childrenMarkup` (bare splice only, #2775/#2786)
244
- * 6. otherwise → `escapedText`
234
+ * 6. `children ?? fallback`, → `childrenMarkupOrEscapedFallback` (#3554)
235
+ * `children || fallback`
236
+ * 7. otherwise → `escapedText`
245
237
  *
246
238
  * Arm 5 tests BOTH `node.expr` (the original source text, stable across
247
239
  * builders) and the caller's resolved form (with parentheses handled structurally): a
@@ -250,7 +242,7 @@ export interface ChildSpliceContext {
250
242
  * either alone misses one of the two shapes (#2786).
251
243
  */
252
244
  export function spliceChildValue(
253
- node: Pick<IRExpression, 'expr' | 'slotId' | 'joinArrayChild'>,
245
+ node: Pick<IRExpression, 'expr' | 'slotId' | 'joinArrayChild' | 'childrenRead'>,
254
246
  valueExpr: string,
255
247
  cx: ChildSpliceContext,
256
248
  ): SafeHtml {
@@ -259,8 +251,10 @@ export function spliceChildValue(
259
251
  if (node.slotId) {
260
252
  return cx.markupSlotIds?.has(node.slotId) ? escapedTextOrMarkup(valueExpr) : escapedText(valueExpr)
261
253
  }
262
- if (isChildrenPassthroughExpr(node.expr) || isChildrenPassthroughExpr(valueExpr)) {
254
+ if (node.childrenRead === 'bare' || node.childrenRead === 'nullish-empty') {
263
255
  return childrenMarkup(valueExpr)
264
256
  }
257
+ if (node.childrenRead === 'nullish-fallback') return childrenMarkupOrEscapedFallback(valueExpr, 'nullish')
258
+ if (node.childrenRead === 'or-fallback') return childrenMarkupOrEscapedFallback(valueExpr, 'falsy')
265
259
  return escapedText(valueExpr)
266
260
  }
@@ -125,7 +125,7 @@ function emitSignal(lines: string[], plan: SignalEmitPlan): void {
125
125
  function emitControlledEffect(lines: string[], plan: ControlledSignalEffectPlan): void {
126
126
  lines.push(` createEffect(() => {`)
127
127
  lines.push(` const __val = ${plan.accessorExpr}`)
128
- lines.push(` if (__val !== undefined) ${plan.setter}(__val)`)
128
+ lines.push(` if (__val !== undefined) ${plan.setter}(${plan.valueExpr ?? '__val'})`)
129
129
  lines.push(` }${bfIdArg(plan.bfId)})`)
130
130
  }
131
131
 
@@ -24,6 +24,7 @@ import type {
24
24
  TypeDefinition,
25
25
  MapCallbackPreamble,
26
26
  PreambleRegionSource,
27
+ JsSourceText,
27
28
  } from '../types.ts'
28
29
  import type { CsrInlinabilityMap } from './csr-substitute.ts'
29
30
  import type { SkeletonSlotPaths } from './html-template.ts'
@@ -197,7 +198,7 @@ export interface DynamicElement {
197
198
  export interface ConditionalBranchEvent {
198
199
  slotId: string
199
200
  eventName: string
200
- handler: string
201
+ handler: JsSourceText
201
202
  }
202
203
 
203
204
  export interface ConditionalBranchRef {
@@ -528,7 +529,7 @@ export interface NestedLoop extends LoopCore {
528
529
  export interface LoopChildEvent {
529
530
  eventName: string // 'click', 'submit', etc.
530
531
  childSlotId: string // bf slot ID of the element with the event
531
- handler: string // Handler expression (may reference loop param)
532
+ handler: JsSourceText // Handler expression (may reference loop param)
532
533
  /** Nesting info for events inside nested inner loops. Empty = direct child. */
533
534
  nestedLoops: NestedLoop[]
534
535
  /** DOM nesting depth (0 = loop body root). Deepest-first sorting for event delegation (#774). */
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import ts from 'typescript'
7
- import type { AttrValue, IRTemplatePart, LoopParamBinding, FreeReference, IRNode, IRFragment, ComponentIR } from '../types.ts'
7
+ import type { AttrValue, IRTemplatePart, LoopParamBinding, FreeReference, IRNode, IRFragment, ComponentIR, JsSourceText } from '../types.ts'
8
8
  import type { TopLevelLoop, BranchLoop, LoopOffset } from './types.ts'
9
9
  import { isNonReferenceIdentifierPosition } from '../analyzer.ts'
10
10
  import { BindingScope, type LoopBindingSource } from '../scope/binding-scope.ts'
@@ -387,30 +387,6 @@ export function quotePropName(name: string): string {
387
387
  // toHtmlAttrName is now re-exported from @barefootjs/shared (classifyDOMProp's
388
388
  // toHTMLAttrName), keeping the same public name for downstream consumers.
389
389
 
390
- /**
391
- * Wrap arrow function handler in block to prevent accidental return false.
392
- * Returning false from a DOM event handler prevents default behavior.
393
- *
394
- * Example:
395
- * Input: (e) => e.key === 'Enter' && handleAdd()
396
- * Output: (e) => { e.key === 'Enter' && handleAdd() }
397
- */
398
- export function wrapHandlerInBlock(handler: string): string {
399
- const trimmed = handler.trim()
400
-
401
- if (trimmed.startsWith('(') && trimmed.includes('=>')) {
402
- const arrowIndex = trimmed.indexOf('=>')
403
- const params = trimmed.substring(0, arrowIndex + 2)
404
- const body = trimmed.substring(arrowIndex + 2).trim()
405
-
406
- if (!body.startsWith('{')) {
407
- return `${params} { ${body} }`
408
- }
409
- }
410
-
411
- return trimmed
412
- }
413
-
414
390
  /**
415
391
  * Profile mode (#1690, SR3): wrap an event handler so a profiling run can
416
392
  * attribute the reactive work it triggers to one turn. The original handler
@@ -424,7 +400,7 @@ export function wrapHandlerInBlock(handler: string): string {
424
400
  * emitted while it runs. Used at every handler emit site in profile mode so
425
401
  * no path is left unattributed.
426
402
  */
427
- export function wrapHandlerForTurn(handler: string, handlerId: string, loc?: string): string {
403
+ export function wrapHandlerForTurn(handler: JsSourceText, handlerId: string, loc?: string): string {
428
404
  const idArg = loc ? `${JSON.stringify(handlerId)}, ${JSON.stringify(loc)}` : JSON.stringify(handlerId)
429
405
  return `(...__bfa) => { beginTurn(${idArg}); try { return (${handler.trim()})(...__bfa) } finally { endTurn() } }`
430
406
  }
@@ -469,6 +445,17 @@ export function emitRefCall(callback: string, elementVar: string, ssrPortalOwner
469
445
  return `{ ${call}; if (__scopeId) ${elementVar}.setAttribute('${BF_PORTAL_OWNER}', __scopeId) }`
470
446
  }
471
447
 
448
+ /**
449
+ * Whether a signal's initializer is a bare read of the props object
450
+ * (`props.X`, `props.row.count`) with no fallback of its own
451
+ * (`SignalInfo.propSeed`, #3508), the one shape both the init
452
+ * body and the CSR template give a type default (`?? <inferDefaultValue>`)
453
+ * so an omitted prop never seeds the signal with `undefined`.
454
+ */
455
+ export function readsBareProp(signal: { propSeed?: { via: string; fallback: unknown } }): boolean {
456
+ return signal.propSeed?.via === 'member' && signal.propSeed.fallback === null
457
+ }
458
+
472
459
  /** Infer a sensible JS default value literal from a type descriptor. */
473
460
  export function inferDefaultValue(type: { kind: string; primitive?: string }): string {
474
461
  if (type.kind === 'primitive') {