@barefootjs/jsx 0.37.1 → 0.39.0

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 (168) hide show
  1. package/dist/action-accessor.d.ts +159 -0
  2. package/dist/action-accessor.d.ts.map +1 -0
  3. package/dist/adapters/env-signal.d.ts +0 -8
  4. package/dist/adapters/env-signal.d.ts.map +1 -1
  5. package/dist/adapters/interface.d.ts +12 -0
  6. package/dist/adapters/interface.d.ts.map +1 -1
  7. package/dist/adapters/jsx-adapter.d.ts.map +1 -1
  8. package/dist/analyzer.d.ts +61 -1
  9. package/dist/analyzer.d.ts.map +1 -1
  10. package/dist/async-action-refusal.d.ts +45 -0
  11. package/dist/async-action-refusal.d.ts.map +1 -0
  12. package/dist/builtin-lowering-plugins.d.ts.map +1 -1
  13. package/dist/compiler.d.ts.map +1 -1
  14. package/dist/component-root-scope-comment.d.ts +36 -0
  15. package/dist/component-root-scope-comment.d.ts.map +1 -0
  16. package/dist/debug.d.ts +61 -5
  17. package/dist/debug.d.ts.map +1 -1
  18. package/dist/errors.d.ts +7 -0
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/event-handler-name.d.ts +13 -0
  21. package/dist/event-handler-name.d.ts.map +1 -0
  22. package/dist/expression-parser.d.ts +9 -0
  23. package/dist/expression-parser.d.ts.map +1 -1
  24. package/dist/format-date-refusal.d.ts +33 -0
  25. package/dist/format-date-refusal.d.ts.map +1 -0
  26. package/dist/index.d.ts +6 -4
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3260 -1914
  29. package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  31. package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/compute-scope.d.ts.map +1 -1
  33. package/dist/ir-to-client-js/control-flow/plan/build-branch-loop.d.ts.map +1 -1
  34. package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
  35. package/dist/ir-to-client-js/control-flow/plan/build-composite-loop.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  37. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts.map +1 -1
  38. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -0
  39. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
  40. package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts +1 -1
  41. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +57 -12
  42. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  43. package/dist/ir-to-client-js/control-flow/shared.d.ts +44 -3
  44. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  45. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts +7 -5
  46. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
  48. package/dist/ir-to-client-js/declaration-sort.d.ts +2 -1
  49. package/dist/ir-to-client-js/declaration-sort.d.ts.map +1 -1
  50. package/dist/ir-to-client-js/emit-module-level.d.ts.map +1 -1
  51. package/dist/ir-to-client-js/emit-reactive.d.ts +43 -2
  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.map +1 -1
  54. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  55. package/dist/ir-to-client-js/plan/declaration-emit.d.ts +7 -5
  56. package/dist/ir-to-client-js/plan/declaration-emit.d.ts.map +1 -1
  57. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  58. package/dist/ir-to-client-js/reactivity.d.ts +9 -1
  59. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  60. package/dist/ir-to-client-js/source-map.d.ts.map +1 -1
  61. package/dist/ir-to-client-js/types.d.ts +4 -0
  62. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  63. package/dist/ir-to-client-js/utils.d.ts +66 -1
  64. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  65. package/dist/jsx-to-ir.d.ts.map +1 -1
  66. package/dist/opaque-local-accessor.d.ts +27 -0
  67. package/dist/opaque-local-accessor.d.ts.map +1 -0
  68. package/dist/signal-initializer.d.ts +24 -0
  69. package/dist/signal-initializer.d.ts.map +1 -0
  70. package/dist/template-position-walk.d.ts +68 -0
  71. package/dist/template-position-walk.d.ts.map +1 -0
  72. package/dist/to-locale-date-lowering.d.ts +7 -4
  73. package/dist/to-locale-date-lowering.d.ts.map +1 -1
  74. package/dist/types.d.ts +104 -17
  75. package/dist/types.d.ts.map +1 -1
  76. package/package.json +2 -2
  77. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +878 -4528
  78. package/src/__tests__/action-accessor.test.ts +166 -0
  79. package/src/__tests__/binding-scope-ratchet.test.ts +21 -10
  80. package/src/__tests__/branch-local-in-raw-capture.test.ts +1 -1
  81. package/src/__tests__/branch-local-same-name-collision.test.ts +9 -9
  82. package/src/__tests__/client-js-generation.test.ts +175 -0
  83. package/src/__tests__/component-root-scope-comment.test.ts +106 -0
  84. package/src/__tests__/create-mutation.test.ts +220 -0
  85. package/src/__tests__/create-query.test.ts +644 -0
  86. package/src/__tests__/csr-fragment-root-scope-shape.test.ts +156 -0
  87. package/src/__tests__/debug.test.ts +222 -0
  88. package/src/__tests__/doc-examples.test.ts +78 -25
  89. package/src/__tests__/event-handler-name.test.ts +74 -0
  90. package/src/__tests__/flatmap-segments.test.ts +11 -9
  91. package/src/__tests__/format-date-refusal.test.ts +134 -0
  92. package/src/__tests__/fragment-wrapped-conditional-return-branch.test.ts +132 -0
  93. package/src/__tests__/hydrate-template.test.ts +9 -1
  94. package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +2 -2
  95. package/src/__tests__/issue-3009-loop-branch-ref.test.ts +2 -2
  96. package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +213 -0
  97. package/src/__tests__/issue-3113-init-fn-name-collision.test.ts +133 -0
  98. package/src/__tests__/jsx-return-type-assertion.test.ts +2 -2
  99. package/src/__tests__/lazy-row-eligibility.test.ts +5 -4
  100. package/src/__tests__/loop-row-child-children-reactive-attrs.test.ts +108 -0
  101. package/src/__tests__/loop-row-child-text-children-markers.test.ts +158 -0
  102. package/src/__tests__/opaque-local-accessor.test.ts +90 -0
  103. package/src/__tests__/profiler-e2e.test.ts +13 -8
  104. package/src/__tests__/props-destructuring.test.ts +79 -4
  105. package/src/__tests__/reactive-factory-arity.test.ts +311 -0
  106. package/src/__tests__/ref-attr-absent-at-ssr.test.ts +472 -0
  107. package/src/__tests__/ssr-portal-ref-callback.test.ts +219 -0
  108. package/src/action-accessor.ts +289 -0
  109. package/src/adapters/env-signal.ts +2 -21
  110. package/src/adapters/interface.ts +13 -0
  111. package/src/adapters/jsx-adapter.ts +17 -0
  112. package/src/analyzer.ts +589 -60
  113. package/src/async-action-refusal.ts +254 -0
  114. package/src/builtin-lowering-plugins.ts +0 -2
  115. package/src/compiler.ts +27 -0
  116. package/src/component-root-scope-comment.ts +59 -0
  117. package/src/debug.ts +318 -103
  118. package/src/errors.ts +83 -1
  119. package/src/event-handler-name.ts +14 -0
  120. package/src/expression-parser.ts +41 -17
  121. package/src/format-date-refusal.ts +147 -0
  122. package/src/index.ts +14 -3
  123. package/src/ir-to-client-js/build-references.ts +6 -2
  124. package/src/ir-to-client-js/child-components.ts +8 -3
  125. package/src/ir-to-client-js/collect-elements.ts +28 -13
  126. package/src/ir-to-client-js/compute-inlinability.ts +2 -1
  127. package/src/ir-to-client-js/compute-scope.ts +3 -1
  128. package/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts +2 -4
  129. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +67 -5
  130. package/src/ir-to-client-js/control-flow/plan/build-composite-loop.ts +3 -6
  131. package/src/ir-to-client-js/control-flow/plan/build-insert.ts +1 -0
  132. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +2 -1
  133. package/src/ir-to-client-js/control-flow/plan/build-loop.ts +23 -11
  134. package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -0
  135. package/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts +3 -3
  136. package/src/ir-to-client-js/control-flow/plan/loop.ts +51 -10
  137. package/src/ir-to-client-js/control-flow/shared.ts +78 -5
  138. package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +25 -12
  139. package/src/ir-to-client-js/control-flow/stringify/insert.ts +1 -1
  140. package/src/ir-to-client-js/csr-substitute.ts +11 -3
  141. package/src/ir-to-client-js/declaration-sort.ts +7 -3
  142. package/src/ir-to-client-js/emit-module-level.ts +7 -4
  143. package/src/ir-to-client-js/emit-reactive.ts +140 -10
  144. package/src/ir-to-client-js/emit-registration.ts +6 -11
  145. package/src/ir-to-client-js/generate-init.ts +2 -2
  146. package/src/ir-to-client-js/html-template.ts +41 -19
  147. package/src/ir-to-client-js/index.ts +9 -3
  148. package/src/ir-to-client-js/phases/ref-callbacks.ts +1 -1
  149. package/src/ir-to-client-js/plan/build-declaration-emit.ts +16 -15
  150. package/src/ir-to-client-js/plan/declaration-emit.ts +7 -5
  151. package/src/ir-to-client-js/prop-handling.ts +4 -0
  152. package/src/ir-to-client-js/reactivity.ts +21 -16
  153. package/src/ir-to-client-js/source-map.ts +2 -1
  154. package/src/ir-to-client-js/stringify/declaration-emit.ts +14 -7
  155. package/src/ir-to-client-js/types.ts +4 -0
  156. package/src/ir-to-client-js/utils.ts +89 -7
  157. package/src/jsx-to-ir.ts +772 -50
  158. package/src/opaque-local-accessor.ts +44 -0
  159. package/src/rich-type-refusal.ts +1 -1
  160. package/src/signal-initializer.ts +36 -0
  161. package/src/template-position-walk.ts +203 -0
  162. package/src/to-locale-date-lowering.ts +7 -4
  163. package/src/types.ts +103 -15
  164. package/dist/format-date-lowering.d.ts +0 -30
  165. package/dist/format-date-lowering.d.ts.map +0 -1
  166. package/src/__tests__/create-selector.test.ts +0 -124
  167. package/src/__tests__/format-date-lowering.test.ts +0 -125
  168. package/src/format-date-lowering.ts +0 -55
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Structural recognition for a query/mutation action's reactive accessors
3
+ * (#3166, part B of #3158): `action.isPending()` / `action.error()` where
4
+ * `action` is the action binding of a recognised async factory
5
+ * (`const [, fetchPosts] = createQuery(…)`, #3165's `SignalInfo.factory`).
6
+ *
7
+ * This is the ONE place that recognises the shape, fed directly by #3165's
8
+ * binding metadata (`SignalInfo.factory.action`) rather than a name
9
+ * heuristic — never re-derived per call site — and the ONE place that
10
+ * decides where a recognised read may be seeded
11
+ * ({@link seedableActionAccessorRead}). Two consumers call that gate:
12
+ *
13
+ * - `seedActionAccessorReads` (below, run by `jsx-to-ir.ts` right after the
14
+ * parse-attach walk): substitutes a gated read with its seed, both in the
15
+ * structured `ParsedExpr` every DSL adapter lowers from and in the
16
+ * `templateCondition` / `templateExpr` text the CSR module-scope fallback
17
+ * template reads.
18
+ * - `async-action-refusal.ts` (BF117): lifts the refusal for exactly the
19
+ * positions the gate admits; every other read refuses as before #3166.
20
+ *
21
+ * Both walk the same positions (`walkTemplatePositions`), so the lift and
22
+ * the seed cannot disagree about which position is which.
23
+ *
24
+ * Where the seed is sound. The SSR seed (spec/async.md §7.3) is `false` for
25
+ * `isPending()` and `undefined` for `error()`; Hono (the reference) really
26
+ * calls a stub returning exactly those, while a DSL adapter renders the
27
+ * substituted `ParsedExpr` literal `false`. A position is gated in only where
28
+ * the two provably render the same bytes:
29
+ *
30
+ * - a `condition` (`IRConditional` / `IRIfStatement`), for both accessors —
31
+ * only truthiness is observed, and `false` ≡ `undefined` there;
32
+ * - an intrinsic element's ARIA boolean-state attribute
33
+ * ({@link ARIA_BOOLEAN_STATE_ATTRS}), for `isPending()` only — Hono renders
34
+ * `aria-busy={false}` as `aria-busy="false"`, and every DSL adapter
35
+ * stringifies a boolean there JS-style (`bool_str`);
36
+ * - an intrinsic element's HTML boolean attribute (`disabled`, `readonly`, …;
37
+ * the shared `isBooleanAttr` every adapter imports), for `isPending()` only
38
+ * (#3210) — Hono omits `disabled={false}`, and every DSL adapter renders a
39
+ * boolean attribute present-or-absent from the expression's truthiness.
40
+ *
41
+ * Everything else stays refused by BF117 exactly as before #3166, because the
42
+ * seed would silently diverge there: a text child (`{fetchPosts.error()}` —
43
+ * Hono renders nothing, a DSL adapter `false`), `error()` in any attribute
44
+ * (Hono omits an `undefined` attribute; the `false` literal renders it), and
45
+ * `isPending()` in any other attribute (Mojolicious / Xslate render the
46
+ * literal as `0` outside the ARIA boolean set and the HTML boolean
47
+ * attributes). A structured template
48
+ * attribute's ternary condition (`class={fetchPosts.isPending() ? 'a' : 'b'}`)
49
+ * is a truthiness test too, but its condition is raw text every adapter lowers
50
+ * on its own, so there is nothing to substitute — it stays refused rather
51
+ * than lifted with no seed behind it.
52
+ *
53
+ * `createMutation` (#3210) reuses this unchanged — `SignalFactoryCall.kind`
54
+ * only distinguishes how the value seeds, never how the action's accessors
55
+ * do, so nothing here is query-specific.
56
+ *
57
+ * Scope: only the accessor called as the WHOLE template-position expression
58
+ * is recognised. A compound use (`!fetchPosts.isPending()`,
59
+ * `fetchPosts.isPending() && x`) is not substituted here and stays refused
60
+ * by BF117 exactly as before #3166 — recognising it structurally too is
61
+ * future work, not a silent gap: nothing that used to compile now compiles
62
+ * differently, and nothing that used to refuse now silently mis-renders.
63
+ */
64
+
65
+ import type { ParsedExpr } from './expression-parser.ts'
66
+ import { isBooleanAttr } from './html-constants.ts'
67
+ import type { IRNode, SignalInfo } from './types.ts'
68
+ import { walkTemplatePositions, type TemplatePosition } from './template-position-walk.ts'
69
+
70
+ /** Reactive accessors every recognised action carries (spec/async.md §7.1/§7.3). */
71
+ export type ActionAccessorName = 'isPending' | 'error'
72
+
73
+ /**
74
+ * Exported so every consumer that needs the accessor-name set (not just the
75
+ * whole-expression-call recognition below) reads the same one — mirrors the
76
+ * `Reactive` members of `QueryAction` in `packages/client/src/create-query.ts`:
77
+ * an accessor added there must be added here.
78
+ */
79
+ export const ACTION_ACCESSOR_NAMES: ReadonlySet<string> = new Set(['isPending', 'error'])
80
+
81
+ export interface ActionAccessorRead {
82
+ action: string
83
+ accessor: ActionAccessorName
84
+ }
85
+
86
+ /** The action bindings a component's recognised async factories produced (#3165). */
87
+ export function collectActionNames(signals: readonly Pick<SignalInfo, 'factory'>[]): ReadonlySet<string> {
88
+ const actions = new Set<string>()
89
+ for (const signal of signals) {
90
+ if (signal.factory?.action) actions.add(signal.factory.action)
91
+ }
92
+ return actions
93
+ }
94
+
95
+ /**
96
+ * Recognises `<action>()` — a zero-arg call whose callee is a non-computed
97
+ * member access on an identifier in `actions`, naming `isPending` or
98
+ * `error`. Structural: never matches on the property name alone without the
99
+ * object also being a real recognised action binding.
100
+ */
101
+ export function matchActionAccessorCall(
102
+ expr: ParsedExpr,
103
+ actions: ReadonlySet<string>,
104
+ ): ActionAccessorRead | null {
105
+ if (expr.kind !== 'call' || expr.args.length !== 0) return null
106
+ const callee = expr.callee
107
+ if (callee.kind !== 'member' || callee.computed) return null
108
+ if (callee.object.kind !== 'identifier') return null
109
+ if (!actions.has(callee.object.name)) return null
110
+ if (!ACTION_ACCESSOR_NAMES.has(callee.property)) return null
111
+ return { action: callee.object.name, accessor: callee.property as ActionAccessorName }
112
+ }
113
+
114
+ /**
115
+ * The direct sub-expressions of `expr`, each with the arrow parameters it is
116
+ * evaluated under (`params`, set only for an arrow's body). The one traversal
117
+ * of a `ParsedExpr` for action reads: BF117's refusal walk
118
+ * (`async-action-refusal.ts`) and {@link collectActionAccessorReads} both
119
+ * recurse through it, so they cannot disagree about which sub-expressions a
120
+ * read can hide in, or which names an arrow parameter shadows.
121
+ */
122
+ export function parsedExprChildren(expr: ParsedExpr): Array<{ expr: ParsedExpr; params?: readonly string[] }> {
123
+ const all = (...exprs: ParsedExpr[]) => exprs.map((e) => ({ expr: e }))
124
+ switch (expr.kind) {
125
+ case 'member':
126
+ return all(expr.object)
127
+ case 'call':
128
+ return all(expr.callee, ...expr.args)
129
+ case 'index-access':
130
+ return all(expr.object, expr.index)
131
+ case 'binary':
132
+ case 'logical':
133
+ return all(expr.left, expr.right)
134
+ case 'unary':
135
+ return all(expr.argument)
136
+ case 'conditional':
137
+ return all(expr.test, expr.consequent, expr.alternate)
138
+ case 'template-literal':
139
+ return all(...expr.parts.flatMap((p) => (p.type === 'expression' ? [p.expr] : [])))
140
+ case 'array-literal':
141
+ return all(...expr.elements)
142
+ case 'object-literal':
143
+ return all(...expr.properties.map((p) => (p.kind === 'spread' ? p.expr : p.value)))
144
+ case 'array-method':
145
+ return all(expr.object, ...expr.args, ...(expr.method === 'flat' && expr.depthExpr ? [expr.depthExpr] : []))
146
+ case 'arrow':
147
+ return [{ expr: expr.body, params: expr.params }]
148
+ case 'identifier':
149
+ case 'literal':
150
+ case 'regex':
151
+ case 'unsupported':
152
+ return []
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Every `<action>.isPending()` / `<action>.error()` read in `expr`, in
158
+ * first-seen order and without duplicates (`bf debug graph`, #3167). An action
159
+ * name an enclosing arrow parameter rebinds, or that `isBound` reports bound
160
+ * (a loop row's parameter), is not the action.
161
+ */
162
+ export function collectActionAccessorReads(
163
+ expr: ParsedExpr,
164
+ actions: ReadonlySet<string>,
165
+ isBound: (name: string) => boolean = () => false,
166
+ ): ActionAccessorRead[] {
167
+ const reads: ActionAccessorRead[] = []
168
+ if (actions.size === 0) return reads
169
+ const visit = (e: ParsedExpr, bound: ReadonlySet<string>): void => {
170
+ const read = matchActionAccessorCall(e, actions)
171
+ if (read && !bound.has(read.action) && !isBound(read.action)) {
172
+ if (!reads.some((r) => r.action === read.action && r.accessor === read.accessor)) reads.push(read)
173
+ return
174
+ }
175
+ for (const child of parsedExprChildren(e)) {
176
+ visit(child.expr, child.params ? new Set([...bound, ...child.params]) : bound)
177
+ }
178
+ }
179
+ visit(expr, new Set())
180
+ return reads
181
+ }
182
+
183
+ /**
184
+ * ARIA boolean-state attributes: the attribute names on which every DSL
185
+ * adapter stringifies a boolean value JS-style (`"true"` / `"false"`), which
186
+ * is what Hono renders for `aria-*={false}`. Must stay a subset of each DSL
187
+ * adapter's own `isAriaBooleanAttr` set (Mojolicious / Xslate render a bare
188
+ * `false` literal as `0` on any other attribute); `action-accessor.test.ts`
189
+ * pins that across every adapter, so an adapter dropping a name fails there
190
+ * instead of silently diverging.
191
+ */
192
+ export const ARIA_BOOLEAN_STATE_ATTRS: ReadonlySet<string> = new Set([
193
+ 'aria-atomic',
194
+ 'aria-busy',
195
+ 'aria-checked',
196
+ 'aria-disabled',
197
+ 'aria-expanded',
198
+ 'aria-hidden',
199
+ 'aria-modal',
200
+ 'aria-multiline',
201
+ 'aria-multiselectable',
202
+ 'aria-pressed',
203
+ 'aria-readonly',
204
+ 'aria-required',
205
+ 'aria-selected',
206
+ ])
207
+
208
+ /**
209
+ * THE gate (see the file header): the recognised accessor read at this
210
+ * template position, if its seed renders there exactly as Hono renders the
211
+ * real stub's value — otherwise `null`, and the read stays refused (BF117).
212
+ * `seedActionAccessorReads` seeds exactly what this admits, and BF117 lifts
213
+ * exactly what this admits; neither re-decides it.
214
+ */
215
+ export function seedableActionAccessorRead(
216
+ position: Pick<TemplatePosition, 'expr' | 'role' | 'attrName'>,
217
+ actions: ReadonlySet<string>,
218
+ ): ActionAccessorRead | null {
219
+ const read = matchActionAccessorCall(position.expr, actions)
220
+ if (!read) return null
221
+ switch (position.role) {
222
+ case 'condition':
223
+ return read
224
+ case 'element-attr':
225
+ return read.accessor === 'isPending' &&
226
+ position.attrName !== undefined &&
227
+ (ARIA_BOOLEAN_STATE_ATTRS.has(position.attrName) || isBooleanAttr(position.attrName))
228
+ ? read
229
+ : null
230
+ default:
231
+ return null
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Seed every gated accessor read in `root` in place: the position's
237
+ * `ParsedExpr` (what DSL adapters lower) becomes {@link actionAccessorSeedParsed},
238
+ * and its CSR fallback text (`templateCondition` / `templateExpr`) becomes
239
+ * {@link actionAccessorSeedText}. Runs once, after `parsed` is attached and
240
+ * before any refusal pass or adapter reads the IR.
241
+ */
242
+ export function seedActionAccessorReads(root: IRNode, signals: readonly Pick<SignalInfo, 'factory'>[]): void {
243
+ const actions = collectActionNames(signals)
244
+ if (actions.size === 0) return
245
+ walkTemplatePositions(root, (position) => {
246
+ const read = seedableActionAccessorRead(position, actions)
247
+ if (!read || !position.host) return
248
+ const parsed = actionAccessorSeedParsed(read.accessor)
249
+ const text = actionAccessorSeedText(read.accessor)
250
+ if (position.host.kind === 'condition') {
251
+ position.host.node.parsedCondition = parsed
252
+ position.host.node.templateCondition = text
253
+ } else {
254
+ position.host.value.parsed = parsed
255
+ position.host.value.templateExpr = text
256
+ }
257
+ })
258
+ }
259
+
260
+ /**
261
+ * The SSR seed for a recognised accessor (spec/async.md §7.3): `isPending()`
262
+ * is `false`; `error()` is `undefined`. Represented as the `ParsedExpr`
263
+ * boolean literal `false` for the structured tree every DSL adapter's
264
+ * expression lowering reads (`IRConditional.parsedCondition` /
265
+ * `ExpressionAttr.parsed`). That is only equivalent to the real value where
266
+ * {@link seedableActionAccessorRead} admits the position: a truthiness test
267
+ * (`false` ≡ `undefined`), or `isPending()` (really `false`) in an ARIA
268
+ * boolean-state attribute or an HTML boolean attribute. Unlike the `null` literal, `false` is valid in
269
+ * every position every adapter's grammar accepts, including a bare
270
+ * `{{if …}}` command (Go's `text/template` rejects a bare `nil` there — "nil
271
+ * is not a command"). `ParsedExpr`'s `literal` kind has no `undefined`
272
+ * variant regardless, so something has to stand in for it; an `error()` read
273
+ * rendered as a VALUE would need a real "omit" seed, which is why the gate
274
+ * refuses it instead.
275
+ */
276
+ export function actionAccessorSeedParsed(_accessor: ActionAccessorName): ParsedExpr {
277
+ return { kind: 'literal', value: false, literalType: 'boolean' }
278
+ }
279
+
280
+ /**
281
+ * The SSR seed as JS source text — for the CSR module-scope fallback
282
+ * template (`templateCondition` / `templateExpr`), which cannot close over
283
+ * the action's real accessor (it is a local inside `initX`, never in scope
284
+ * at module level, the same reason a signal getter call is substituted with
285
+ * its initial value there instead of being called live).
286
+ */
287
+ export function actionAccessorSeedText(accessor: ActionAccessorName): string {
288
+ return accessor === 'isPending' ? 'false' : 'undefined'
289
+ }
@@ -128,33 +128,14 @@ export function queryHrefLocalNames(metadata: IRMetadata): Set<string> {
128
128
 
129
129
  /**
130
130
  * Entry points that re-export the pure client helpers with an SSR lowering
131
- * (`queryHref` #2042, `formatDate` #2324) — the main entry and the runtime
132
- * re-export. Importing from either must enable the lowering.
131
+ * (`queryHref` #2042) — the main entry and the runtime re-export. Importing
132
+ * from either must enable the lowering.
133
133
  */
134
134
  const CLIENT_HELPER_SOURCES: ReadonlySet<string> = new Set([
135
135
  '@barefootjs/client',
136
136
  '@barefootjs/client/runtime',
137
137
  ])
138
138
 
139
- /**
140
- * The local binding name(s) that `formatDate` is imported under in this
141
- * component (#2324) — the pure-function date formatter an adapter lowers to
142
- * its `format_date` helper (spec/template-helpers.md). Same resolution rules
143
- * as {@link queryHrefLocalNames}: matched by exported name, gated on the LOCAL
144
- * alias, accepted from both the main entry and the runtime re-export.
145
- */
146
- export function formatDateLocalNames(metadata: IRMetadata): Set<string> {
147
- const names = new Set<string>()
148
- for (const imp of metadata.imports) {
149
- if (!CLIENT_HELPER_SOURCES.has(imp.source) || imp.isTypeOnly) continue
150
- for (const s of imp.specifiers) {
151
- if (s.isTypeOnly || s.isNamespace || s.isDefault) continue
152
- if (s.name === 'formatDate') names.add(s.alias ?? s.name)
153
- }
154
- }
155
- return names
156
- }
157
-
158
139
  /**
159
140
  * Recognise a `<binding>().<method>(<args>)` env-signal method call from a
160
141
  * `call` node's callee + args, where `<binding>` is one of the local names
@@ -313,6 +313,19 @@ export interface TemplateAdapter {
313
313
  // Type generation (for typed languages)
314
314
  generateTypes?(ir: ComponentIR): string | null
315
315
 
316
+ /**
317
+ * Register a component's shape (declared props, rest bag, derived-field
318
+ * dependencies) with the adapter BEFORE any component that may nest it
319
+ * generates, so a parent finds a child's shape whatever the declaration
320
+ * order. Cross-file children reach it from the CLI / compat /
321
+ * test-render pre-passes (one call per sibling file);
322
+ * `compileMultipleComponents` calls it for every same-file component
323
+ * ahead of its generate loop, so a child declared AFTER its parent —
324
+ * legal through function-declaration hoisting — is registered too.
325
+ * Adapters with no cross-component shape registry leave it undefined.
326
+ */
327
+ registerChildComponentShape?(ir: ComponentIR): void
328
+
316
329
  /**
317
330
  * Generate the SSR declaration block for the user's reactive bindings
318
331
  * (signals, memos, locally-declared functions/constants) at the top
@@ -172,6 +172,23 @@ export abstract class JsxAdapter extends BaseAdapter {
172
172
  lines.push(` const ${signal.getter} = () => ${initialValue}`)
173
173
  }
174
174
 
175
+ // An async factory's action (#3165): the request function never runs on
176
+ // the server, so a reference that survives into SSR (e.g. forwarded to a
177
+ // child as a prop) gets a no-op. Since #3166, `action.isPending()` /
178
+ // `action.error()` are ordinary, IR-visible seeded values
179
+ // (`false` / `undefined`, spec/async.md §7.3) rather than refused —
180
+ // this SSR stub is what a template position's `fetchPosts.isPending()`
181
+ // actually calls at render time (this file's execution model runs the
182
+ // real JS text, unlike a DSL adapter's `parsedCondition`-based
183
+ // substitution), so it must carry working accessors, not just be
184
+ // callable itself.
185
+ const action = signal.factory?.action
186
+ if (action && identifierPattern(action).test(setterRefText)) {
187
+ lines.push(preserveTypes
188
+ ? ` const ${action}: any = Object.assign(() => {}, { isPending: () => false, error: () => undefined })`
189
+ : ` const ${action} = Object.assign(() => {}, { isPending: () => false, error: () => undefined })`)
190
+ }
191
+
175
192
  // Create a no-op setter for SSR — omit entirely if not referenced anywhere
176
193
  if (signal.setter) {
177
194
  const setterUsed = identifierPattern(signal.setter).test(setterRefText)