@barefootjs/jsx 0.38.0 → 0.39.1
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/dist/action-accessor.d.ts +159 -0
- package/dist/action-accessor.d.ts.map +1 -0
- package/dist/adapters/interface.d.ts +19 -0
- package/dist/adapters/interface.d.ts.map +1 -1
- package/dist/adapters/jsx-adapter.d.ts.map +1 -1
- package/dist/analyzer.d.ts +49 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/async-action-refusal.d.ts +45 -0
- package/dist/async-action-refusal.d.ts.map +1 -0
- package/dist/compiler.d.ts.map +1 -1
- package/dist/debug.d.ts +61 -5
- package/dist/debug.d.ts.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/format-date-refusal.d.ts +2 -6
- package/dist/format-date-refusal.d.ts.map +1 -1
- package/dist/html-types.d.ts +5 -0
- package/dist/html-types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1261 -422
- package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
- package/dist/ir-to-client-js/collect-elements.d.ts +17 -1
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
- package/dist/ir-to-client-js/compute-scope.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/declaration-sort.d.ts +2 -1
- package/dist/ir-to-client-js/declaration-sort.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-module-level.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts +7 -5
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts +10 -2
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +4 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +52 -9
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/signal-initializer.d.ts +24 -0
- package/dist/signal-initializer.d.ts.map +1 -0
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/ssr-seed-plan.d.ts.map +1 -1
- package/dist/template-position-walk.d.ts +68 -0
- package/dist/template-position-walk.d.ts.map +1 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +194 -4
- package/src/__tests__/action-accessor.test.ts +166 -0
- package/src/__tests__/adapter-output.test.ts +142 -0
- package/src/__tests__/create-mutation.test.ts +250 -0
- package/src/__tests__/create-query.test.ts +696 -0
- package/src/__tests__/csr-fragment-root-scope-shape.test.ts +156 -0
- package/src/__tests__/debug.test.ts +305 -0
- package/src/__tests__/doc-examples.test.ts +66 -3
- package/src/__tests__/ir-fragment-transparency.test.ts +23 -0
- package/src/__tests__/issue-3240-nested-static-map-event-delegation.test.ts +245 -0
- package/src/__tests__/jsx-text-linebreak-whitespace.test.ts +80 -0
- package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +445 -0
- package/src/__tests__/props-destructuring.test.ts +79 -4
- package/src/__tests__/reactive-factory-arity.test.ts +311 -0
- package/src/__tests__/ssr-portal-ref-callback.test.ts +5 -3
- package/src/action-accessor.ts +289 -0
- package/src/adapters/interface.ts +19 -0
- package/src/adapters/jsx-adapter.ts +47 -20
- package/src/analyzer.ts +593 -44
- package/src/async-action-refusal.ts +254 -0
- package/src/compiler.ts +81 -46
- package/src/debug.ts +351 -104
- package/src/errors.ts +39 -0
- package/src/format-date-refusal.ts +6 -125
- package/src/html-types.ts +14 -0
- package/src/index.ts +3 -1
- package/src/ir-to-client-js/build-references.ts +6 -2
- package/src/ir-to-client-js/collect-elements.ts +65 -4
- package/src/ir-to-client-js/compute-inlinability.ts +2 -1
- package/src/ir-to-client-js/compute-scope.ts +3 -1
- package/src/ir-to-client-js/control-flow/plan/build-insert.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -0
- package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +112 -3
- package/src/ir-to-client-js/control-flow/stringify/insert.ts +1 -1
- package/src/ir-to-client-js/csr-substitute.ts +11 -3
- package/src/ir-to-client-js/declaration-sort.ts +7 -3
- package/src/ir-to-client-js/emit-module-level.ts +7 -4
- package/src/ir-to-client-js/emit-registration.ts +5 -10
- package/src/ir-to-client-js/index.ts +7 -2
- package/src/ir-to-client-js/phases/ref-callbacks.ts +1 -1
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +16 -15
- package/src/ir-to-client-js/plan/declaration-emit.ts +7 -5
- package/src/ir-to-client-js/prop-handling.ts +4 -0
- package/src/ir-to-client-js/reactivity.ts +32 -1
- package/src/ir-to-client-js/stringify/declaration-emit.ts +14 -7
- package/src/ir-to-client-js/types.ts +4 -0
- package/src/ir-to-client-js/utils.ts +184 -21
- package/src/jsx-to-ir.ts +111 -14
- package/src/signal-initializer.ts +36 -0
- package/src/ssr-defaults.ts +10 -0
- package/src/ssr-seed-plan.ts +12 -1
- package/src/template-position-walk.ts +203 -0
- package/src/types.ts +99 -0
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
IRTemplatePart,
|
|
13
13
|
ImportSpecifier,
|
|
14
14
|
} from '../types.ts'
|
|
15
|
+
import { isElidedFactoryGetter } from '../types.ts'
|
|
15
16
|
import { templatePartsToJsExpr } from '../template-parts.ts'
|
|
16
17
|
import { BF_SCOPE, BF_SLOT, BF_COND } from '@barefootjs/shared'
|
|
17
18
|
import { BaseAdapter } from './interface.ts'
|
|
@@ -150,26 +151,52 @@ export abstract class JsxAdapter extends BaseAdapter {
|
|
|
150
151
|
}
|
|
151
152
|
continue
|
|
152
153
|
}
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
154
|
+
// An elided async-factory value (#3245) has no getter binding in the
|
|
155
|
+
// source at all — `signal.getter` is a synthesized internal name that
|
|
156
|
+
// nothing in the template or event handlers ever references. Emitting
|
|
157
|
+
// its SSR stub would leak that compiler-internal name into the SSR
|
|
158
|
+
// module for a binding nothing reads; the action's own SSR stub
|
|
159
|
+
// (below) is unaffected and still emitted when referenced. See
|
|
160
|
+
// `isElidedFactoryGetter`'s docstring for the full rationale.
|
|
161
|
+
if (!isElidedFactoryGetter(signal)) {
|
|
162
|
+
// Create a getter that returns the initial value for SSR
|
|
163
|
+
const rawInitialValue = preserveTypes
|
|
164
|
+
? (signal.typedInitialValue ?? signal.initialValue)
|
|
165
|
+
: signal.initialValue
|
|
166
|
+
const initialValue = rawInitialValue.trim().startsWith('{') ? `(${rawInitialValue})` : rawInitialValue
|
|
167
|
+
|
|
168
|
+
// When preserveTypes and typedInitialValue is absent but signal.type has a meaningful
|
|
169
|
+
// type from a generic parameter, add a type assertion to prevent TS inference issues.
|
|
170
|
+
// A bare `object` raw is the analyzer's coarse KIND, not a real type — asserting
|
|
171
|
+
// `as object` only destroys the initializer's inferred literal type (a
|
|
172
|
+
// `{ x: 0, y: 0 }` signal getter stops matching `() => { x: number; y: number }`).
|
|
173
|
+
const needsTypeAssertion = preserveTypes
|
|
174
|
+
&& !signal.typedInitialValue
|
|
175
|
+
&& signal.type.kind !== 'unknown'
|
|
176
|
+
&& signal.type.kind !== 'primitive'
|
|
177
|
+
&& signal.type.raw !== 'object'
|
|
178
|
+
if (needsTypeAssertion) {
|
|
179
|
+
lines.push(` const ${signal.getter} = () => ${initialValue} as ${signal.type.raw}`)
|
|
180
|
+
} else {
|
|
181
|
+
lines.push(` const ${signal.getter} = () => ${initialValue}`)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// An async factory's action (#3165): the request function never runs on
|
|
186
|
+
// the server, so a reference that survives into SSR (e.g. forwarded to a
|
|
187
|
+
// child as a prop) gets a no-op. Since #3166, `action.isPending()` /
|
|
188
|
+
// `action.error()` are ordinary, IR-visible seeded values
|
|
189
|
+
// (`false` / `undefined`, spec/async.md §7.3) rather than refused —
|
|
190
|
+
// this SSR stub is what a template position's `fetchPosts.isPending()`
|
|
191
|
+
// actually calls at render time (this file's execution model runs the
|
|
192
|
+
// real JS text, unlike a DSL adapter's `parsedCondition`-based
|
|
193
|
+
// substitution), so it must carry working accessors, not just be
|
|
194
|
+
// callable itself.
|
|
195
|
+
const action = signal.factory?.action
|
|
196
|
+
if (action && identifierPattern(action).test(setterRefText)) {
|
|
197
|
+
lines.push(preserveTypes
|
|
198
|
+
? ` const ${action}: any = Object.assign(() => {}, { isPending: () => false, error: () => undefined })`
|
|
199
|
+
: ` const ${action} = Object.assign(() => {}, { isPending: () => false, error: () => undefined })`)
|
|
173
200
|
}
|
|
174
201
|
|
|
175
202
|
// Create a no-op setter for SSR — omit entirely if not referenced anywhere
|