@barefootjs/jsx 0.39.6 → 0.39.7
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/adapters/attr-plan.d.ts +8 -1
- package/dist/adapters/attr-plan.d.ts.map +1 -1
- package/dist/adapters/callback-method.d.ts +27 -0
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +52 -0
- package/dist/adapters/computed-const.d.ts.map +1 -0
- package/dist/adapters/dangerous-inner-html.d.ts +10 -0
- package/dist/adapters/dangerous-inner-html.d.ts.map +1 -1
- package/dist/adapters/element-shell.d.ts +44 -0
- package/dist/adapters/element-shell.d.ts.map +1 -0
- package/dist/adapters/interface.d.ts +2 -0
- package/dist/adapters/interface.d.ts.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts +7 -0
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/fold-render-reassignments.d.ts +43 -0
- package/dist/fold-render-reassignments.d.ts.map +1 -0
- package/dist/free-refs.d.ts +9 -0
- package/dist/free-refs.d.ts.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2285 -1583
- package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts +0 -13
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +9 -10
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/index.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts +5 -0
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts +11 -12
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +13 -0
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +3 -2
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/props-binding.d.ts +34 -5
- package/dist/props-binding.d.ts.map +1 -1
- package/dist/relocate.d.ts +16 -0
- package/dist/relocate.d.ts.map +1 -1
- package/dist/ssr-seed-plan.d.ts +0 -6
- package/dist/ssr-seed-plan.d.ts.map +1 -1
- package/dist/types.d.ts +54 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/block-memo-type.test.ts +51 -0
- package/src/__tests__/callback-method.test.ts +75 -0
- package/src/__tests__/client-only-date-lowering.test.ts +2 -2
- package/src/__tests__/computed-const.test.ts +101 -0
- package/src/__tests__/element-shell.test.ts +78 -0
- package/src/__tests__/fold-render-reassignments.test.ts +96 -0
- package/src/__tests__/inlinable-local-method-call.test.ts +81 -0
- package/src/__tests__/memo-body-expr.test.ts +120 -0
- package/src/__tests__/prop-handling.test.ts +35 -16
- package/src/__tests__/props-alias-const.test.ts +65 -0
- package/src/__tests__/signal-prop-seed.test.ts +90 -0
- package/src/__tests__/ssr-seed-plan.test.ts +54 -1
- package/src/__tests__/static-template-reachability.test.ts +137 -0
- package/src/adapters/attr-plan.ts +29 -1
- package/src/adapters/callback-method.ts +62 -0
- package/src/adapters/computed-const.ts +185 -0
- package/src/adapters/dangerous-inner-html.ts +33 -0
- package/src/adapters/element-shell.ts +160 -0
- package/src/adapters/interface.ts +8 -0
- package/src/analyzer.ts +271 -82
- package/src/augment-inherited-props.ts +12 -0
- package/src/fold-render-reassignments.ts +314 -0
- package/src/free-refs.ts +49 -0
- package/src/index.ts +9 -2
- package/src/ir-to-client-js/compute-inlinability.ts +93 -17
- package/src/ir-to-client-js/csr-substitute.ts +13 -35
- package/src/ir-to-client-js/emit-registration.ts +3 -2
- package/src/ir-to-client-js/html-template.ts +26 -70
- package/src/ir-to-client-js/index.ts +3 -2
- package/src/ir-to-client-js/init-declarations.ts +1 -1
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +25 -51
- package/src/ir-to-client-js/plan/declaration-emit.ts +5 -0
- package/src/ir-to-client-js/prop-handling.ts +13 -54
- package/src/ir-to-client-js/rewrite-destructured-props.ts +6 -5
- package/src/ir-to-client-js/stringify/declaration-emit.ts +1 -1
- package/src/ir-to-client-js/utils.ts +11 -0
- package/src/jsx-to-ir.ts +39 -52
- package/src/nullable-signal-attr.ts +7 -4
- package/src/props-binding.ts +100 -5
- package/src/relocate.ts +40 -8
- package/src/ssr-seed-plan.ts +18 -6
- package/src/types.ts +50 -2
package/src/props-binding.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript'
|
|
2
|
-
import type { ConstantInfo, ParamInfo, PropUsage } from './types.ts'
|
|
2
|
+
import type { ConstantInfo, ParamInfo, PropUsage, SignalPropSeed } from './types.ts'
|
|
3
|
+
import type { ParsedExpr } from './expression-parser.ts'
|
|
3
4
|
import { propHasPropertyAccess } from './ir-to-client-js/compute-prop-usage.ts'
|
|
4
5
|
import { parsePropReadInitializer } from './ir-to-client-js/prune-unused-prop-extractions.ts'
|
|
5
6
|
import { PROPS_PARAM } from './ir-to-client-js/utils.ts'
|
|
@@ -52,6 +53,99 @@ export function propsDestructureBinding(p: ParamInfo): string {
|
|
|
52
53
|
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The prop a parsed initializer reads off the props object: a bare
|
|
58
|
+
* `props.<key>` member read, or one with a `?? <default>` fallback.
|
|
59
|
+
* `null` for any other shape.
|
|
60
|
+
*/
|
|
61
|
+
function parsedPropRead(
|
|
62
|
+
read: ParsedExpr | undefined,
|
|
63
|
+
propsObjectName: string,
|
|
64
|
+
): { key: string; hasDefault: boolean } | null {
|
|
65
|
+
const hasDefault = read?.kind === 'logical' && read.op === '??'
|
|
66
|
+
const member = hasDefault ? read.left : read
|
|
67
|
+
if (member?.kind !== 'member' || member.computed || member.optional) return null
|
|
68
|
+
if (member.object.kind !== 'identifier' || member.object.name !== propsObjectName) return null
|
|
69
|
+
return { key: member.property, hasDefault }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether a component-scope const is the props-object read of its own prop,
|
|
74
|
+
* so a template may read the prop in its place: a bare alias
|
|
75
|
+
* (`const label = props.label`, read from its parsed initializer), or an
|
|
76
|
+
* un-renamed binding of a body destructure (`const { label = 'Default' } =
|
|
77
|
+
* props`, whose default the analyzer also records on the prop's `ParamInfo`).
|
|
78
|
+
*
|
|
79
|
+
* A hand-written `const label = props.label ?? 'Default'` has the same
|
|
80
|
+
* `value` text as that destructure but is NOT the prop: its default lives
|
|
81
|
+
* only in the const, and reading the prop instead drops it (#3501). The
|
|
82
|
+
* analyzer marks the destructure on `ConstantInfo.propsDestructure`, so the
|
|
83
|
+
* two are told apart by that field, not by the text. A reassignment that
|
|
84
|
+
* directly follows the declaration folds into the initializer
|
|
85
|
+
* (`fold-render-reassignments.ts`), so the binding keeps one value; one that
|
|
86
|
+
* cannot fold (`mutatedAfterDeclaration`) leaves no single value a template
|
|
87
|
+
* could inline, so the binding reads the prop it holds until reassigned.
|
|
88
|
+
*/
|
|
89
|
+
export function isPropsAliasConst(
|
|
90
|
+
c: Pick<ConstantInfo, 'name' | 'parsed' | 'propsDestructure' | 'mutatedAfterDeclaration'>,
|
|
91
|
+
propsObjectName: string | null,
|
|
92
|
+
): boolean {
|
|
93
|
+
if (propsObjectName === null) return false
|
|
94
|
+
if (c.propsDestructure) return c.propsDestructure.sourceKey === c.name
|
|
95
|
+
const read = parsedPropRead(c.parsed, propsObjectName)
|
|
96
|
+
return read !== null && read.key === c.name && (!read.hasDefault || c.mutatedAfterDeclaration === true)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* How a parsed signal initializer reads a prop: a member chain rooted at the
|
|
101
|
+
* props object (`props.<name>`, `props.row.count`, `props.items[0]`) or a
|
|
102
|
+
* destructured binding `<name>`, bare or under a `??` / `||` fallback chain
|
|
103
|
+
* of one operator (`props.a ?? props.b ?? 0`). `null` for any other shape
|
|
104
|
+
* (`props.a && x`, `props.a + 1`, a call). A binding counts only when it is
|
|
105
|
+
* one of `propsParams`.
|
|
106
|
+
*/
|
|
107
|
+
export function signalPropSeed(
|
|
108
|
+
parsed: ParsedExpr | undefined,
|
|
109
|
+
propsParams: readonly ParamInfo[],
|
|
110
|
+
propsObjectName: string | null,
|
|
111
|
+
): SignalPropSeed | null {
|
|
112
|
+
if (!parsed) return null
|
|
113
|
+
const { read, fallback } = splitFallbackChain(parsed)
|
|
114
|
+
const declared = (name: string) => propsParams.some(p => p.name === name)
|
|
115
|
+
if (read.kind === 'identifier') {
|
|
116
|
+
return declared(read.name) ? { propName: read.name, via: 'binding', nested: false, declared: true, fallback } : null
|
|
117
|
+
}
|
|
118
|
+
const hop = propsMemberRoot(read, propsObjectName)
|
|
119
|
+
if (!hop) return null
|
|
120
|
+
return { propName: hop.property, via: 'member', nested: hop !== read, declared: declared(hop.property), fallback }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Split a left-associated `??` / `||` chain of ONE operator into its leftmost
|
|
125
|
+
* operand and the fallback after it: `(a ?? b) ?? 0` reads `a` with fallback
|
|
126
|
+
* `b ?? 0`. Anything else is a read with no fallback.
|
|
127
|
+
*/
|
|
128
|
+
function splitFallbackChain(parsed: ParsedExpr): { read: ParsedExpr; fallback: SignalPropSeed['fallback'] } {
|
|
129
|
+
if (parsed.kind !== 'logical' || (parsed.op !== '??' && parsed.op !== '||')) return { read: parsed, fallback: null }
|
|
130
|
+
const op = parsed.op
|
|
131
|
+
const rights: ParsedExpr[] = []
|
|
132
|
+
let node: ParsedExpr = parsed
|
|
133
|
+
while (node.kind === 'logical' && node.op === op) {
|
|
134
|
+
rights.unshift(node.right)
|
|
135
|
+
node = node.left
|
|
136
|
+
}
|
|
137
|
+
const expr = rights.slice(1).reduce<ParsedExpr>((left, right) => ({ ...parsed, left, right }), rights[0])
|
|
138
|
+
return { read: node, fallback: { op, expr } }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The `props.<name>` hop a member / index chain is rooted at, or `null`. */
|
|
142
|
+
function propsMemberRoot(read: ParsedExpr, propsObjectName: string | null): Extract<ParsedExpr, { kind: 'member' }> | null {
|
|
143
|
+
let node = read
|
|
144
|
+
while ((node.kind === 'member' || node.kind === 'index-access') && !(node.object.kind === 'identifier')) node = node.object
|
|
145
|
+
if (node.kind !== 'member' || node.computed || node.optional) return null
|
|
146
|
+
return node.object.kind === 'identifier' && node.object.name === propsObjectName ? node : null
|
|
147
|
+
}
|
|
148
|
+
|
|
55
149
|
/**
|
|
56
150
|
* Local-name → caller-facing-key map for prop-reference rewrites —
|
|
57
151
|
* entries only for `ParamInfo`s that actually rename (`sourceName` set,
|
|
@@ -120,10 +214,11 @@ export function resolveBodyDestructuredPropAliases(
|
|
|
120
214
|
* Foo(props: Props)`) whose value is a PURE alias of a single caller-facing
|
|
121
215
|
* prop — either a body destructure (`const { value } = props`, `const {
|
|
122
216
|
* label = 'none' } = props`) or an equivalent bare member read (`const label
|
|
123
|
-
* = props.label ?? 'fallback'`)
|
|
124
|
-
*
|
|
125
|
-
* resolver — see
|
|
126
|
-
*
|
|
217
|
+
* = props.label ?? 'fallback'`). Both shapes share the same `value` text;
|
|
218
|
+
* the IR tells them apart via `ConstantInfo.propsDestructure` (#3501), but
|
|
219
|
+
* this resolver deliberately treats them alike — see
|
|
220
|
+
* `rewriteBodyAliasReads`'s (`rewrite-destructured-props.ts`) docstring for
|
|
221
|
+
* why that's the right call.
|
|
127
222
|
*/
|
|
128
223
|
export interface BodyPropAlias {
|
|
129
224
|
/** Caller-facing prop key (`props.<key>`). */
|
package/src/relocate.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { Scope, BindingKind, IRMetadata } from './types.ts'
|
|
|
15
15
|
import { isVisibleIn } from './types.ts'
|
|
16
16
|
import type { AnalyzerContext } from './analyzer-context.ts'
|
|
17
17
|
import { PROPS_PARAM } from './ir-to-client-js/utils.ts'
|
|
18
|
-
import { buildPropAliasMap } from './props-binding.ts'
|
|
18
|
+
import { buildPropAliasMap, isPropsAliasConst } from './props-binding.ts'
|
|
19
19
|
import type {
|
|
20
20
|
TemplatePrimitiveRegistry,
|
|
21
21
|
TemplateCallAcceptor,
|
|
@@ -78,6 +78,15 @@ export interface RelocateEnv {
|
|
|
78
78
|
* in `templatePrimitives`. Returning true marks the call as accepted.
|
|
79
79
|
*/
|
|
80
80
|
acceptsTemplateCall?: TemplateCallAcceptor
|
|
81
|
+
/**
|
|
82
|
+
* Component-scope locals already classified as inlinable into template
|
|
83
|
+
* scope (#3513), filled in declaration order by `computeInlinability`. A
|
|
84
|
+
* method call on one (`text.toUpperCase()` with `const text = props.label
|
|
85
|
+
* ?? 'd'`) runs on the local's inlined value, so a broad
|
|
86
|
+
* `acceptsTemplateCall` can vouch for it even though the receiver is an
|
|
87
|
+
* init-local.
|
|
88
|
+
*/
|
|
89
|
+
inlinableLocals?: ReadonlySet<string>
|
|
81
90
|
/**
|
|
82
91
|
* Lowering-registry matchers (#2057) bound to this component's metadata
|
|
83
92
|
* (`prepareLoweringMatchers`), consulted by `isCallAcceptedByAdapter` as a
|
|
@@ -476,6 +485,24 @@ const REGISTRY_SAFE_BINDING_KINDS: ReadonlySet<BindingKind> = new Set([
|
|
|
476
485
|
'module-local',
|
|
477
486
|
])
|
|
478
487
|
|
|
488
|
+
/**
|
|
489
|
+
* A method call on an inlinable local (`text.toUpperCase()`) runs on that
|
|
490
|
+
* local's value in template scope (#3513). Only the broad
|
|
491
|
+
* `acceptsTemplateCall` can vouch for it: the path-keyed registries name
|
|
492
|
+
* globals, which this receiver isn't. A bare call of the local itself is
|
|
493
|
+
* never accepted.
|
|
494
|
+
*/
|
|
495
|
+
function isAcceptedMethodCallOnInlinableLocal(
|
|
496
|
+
originalPath: string,
|
|
497
|
+
leftmost: string | null,
|
|
498
|
+
resolvedLeftmost: string,
|
|
499
|
+
resolvedPath: string,
|
|
500
|
+
env: RelocateEnv,
|
|
501
|
+
): boolean {
|
|
502
|
+
if (originalPath === leftmost || env.inlinableLocals?.has(resolvedLeftmost) !== true) return false
|
|
503
|
+
return env.acceptsTemplateCall?.(resolvedPath) === true
|
|
504
|
+
}
|
|
505
|
+
|
|
479
506
|
/**
|
|
480
507
|
* Whether `env`'s adapter promises it can render this call in template
|
|
481
508
|
* scope. Three independent acceptance paths, any of which is sufficient:
|
|
@@ -540,7 +567,7 @@ function isCallAcceptedByAdapter(
|
|
|
540
567
|
if (resolvedLeftmost !== null) {
|
|
541
568
|
const kind = env.bindings.get(resolvedLeftmost)
|
|
542
569
|
if (kind !== undefined && !REGISTRY_SAFE_BINDING_KINDS.has(kind)) {
|
|
543
|
-
return
|
|
570
|
+
return isAcceptedMethodCallOnInlinableLocal(originalPath, leftmost, resolvedLeftmost, resolvedPath, env)
|
|
544
571
|
}
|
|
545
572
|
}
|
|
546
573
|
|
|
@@ -791,6 +818,16 @@ export function buildRelocateEnvFromIR(
|
|
|
791
818
|
return env
|
|
792
819
|
}
|
|
793
820
|
|
|
821
|
+
/**
|
|
822
|
+
* Every name the component or its module binds, by kind: imports, module
|
|
823
|
+
* consts and functions, props, init locals, signals and memos (`classify`'s
|
|
824
|
+
* table). A free name absent from it, and bound by no enclosing loop or
|
|
825
|
+
* callback, is a JavaScript global.
|
|
826
|
+
*/
|
|
827
|
+
export function componentBindings(metadata: IRMetadata): ReadonlyMap<string, BindingKind> {
|
|
828
|
+
return buildRelocateEnvFromFields(metadata).bindings
|
|
829
|
+
}
|
|
830
|
+
|
|
794
831
|
interface EnvFields {
|
|
795
832
|
imports: AnalyzerContext['imports']
|
|
796
833
|
localFunctions: AnalyzerContext['localFunctions']
|
|
@@ -841,12 +878,7 @@ function buildRelocateEnvFromFields(src: EnvFields): RelocateEnv {
|
|
|
841
878
|
const propsObjectName = src.propsObjectName
|
|
842
879
|
for (const c of src.localConstants) {
|
|
843
880
|
if (c.isModule) continue
|
|
844
|
-
|
|
845
|
-
typeof c.value === 'string' &&
|
|
846
|
-
propsObjectName !== null &&
|
|
847
|
-
(c.value === `${propsObjectName}.${c.name}` ||
|
|
848
|
-
c.value.startsWith(`${propsObjectName}.${c.name} ??`))
|
|
849
|
-
bindings.set(c.name, isPureAlias ? 'prop' : 'init-local')
|
|
881
|
+
bindings.set(c.name, isPropsAliasConst(c, propsObjectName) ? 'prop' : 'init-local')
|
|
850
882
|
}
|
|
851
883
|
|
|
852
884
|
// Init-body local functions.
|
package/src/ssr-seed-plan.ts
CHANGED
|
@@ -35,11 +35,11 @@ import { collectModuleStringConsts } from './augment-inherited-props.ts'
|
|
|
35
35
|
import { collectAliasableGetterNames, resolveGetterAliases } from './ir-to-client-js/csr-substitute.ts'
|
|
36
36
|
import { envSignalReaderFor, type EnvSignalReader } from './adapters/env-signal.ts'
|
|
37
37
|
import {
|
|
38
|
-
extractArrowBodyExpression,
|
|
39
38
|
freeIdentifiers,
|
|
40
39
|
inlineBinding,
|
|
41
40
|
isSupportedValue,
|
|
42
41
|
parseExpression,
|
|
42
|
+
stringifyParsedExpr,
|
|
43
43
|
type ParsedExpr,
|
|
44
44
|
} from './expression-parser.ts'
|
|
45
45
|
import type { IRMetadata } from './types.ts'
|
|
@@ -174,10 +174,23 @@ function resolveThroughLocalConsts(
|
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
176
|
* Compute the component's SSR seed plan from its metadata. See the module
|
|
177
|
-
* doc for the contract.
|
|
178
|
-
* (`
|
|
179
|
-
* `
|
|
177
|
+
* doc for the contract. A memo step reads the expression its callback
|
|
178
|
+
* returns (`MemoInfo.bodyExpr`): an arrow expression body, or a block or
|
|
179
|
+
* `function` body that is a single `return`. A multi-statement body seeds
|
|
180
|
+
* from the analyzer's fold of its statements (`MemoInfo.parsed`, #2040,
|
|
181
|
+
* #3523), and is `opaque` when the fold failed.
|
|
180
182
|
*/
|
|
183
|
+
/**
|
|
184
|
+
* The expression a memo seeds from: the returned expression, as the analyzer
|
|
185
|
+
* read it from the callback node (#3510). A body that must be called as a
|
|
186
|
+
* whole seeds from the analyzer's fold of its statements into one expression
|
|
187
|
+
* when there is one (#3523); `''` (opaque) otherwise.
|
|
188
|
+
*/
|
|
189
|
+
function memoSeedExpr(memo: IRMetadata['memos'][number]): string {
|
|
190
|
+
if (!memo.bodyExprIsCall) return memo.bodyExpr?.trim() ?? ''
|
|
191
|
+
return memo.parsed ? stringifyParsedExpr(memo.parsed) : ''
|
|
192
|
+
}
|
|
193
|
+
|
|
181
194
|
export function computeSsrSeedPlan(metadata: IRMetadata): SsrSeedPlan {
|
|
182
195
|
const baseScope: string[] = metadata.propsParams.map(p => p.name)
|
|
183
196
|
if (metadata.propsObjectName) baseScope.push(metadata.propsObjectName)
|
|
@@ -236,8 +249,7 @@ export function computeSsrSeedPlan(metadata: IRMetadata): SsrSeedPlan {
|
|
|
236
249
|
}
|
|
237
250
|
|
|
238
251
|
for (const memo of metadata.memos) {
|
|
239
|
-
const
|
|
240
|
-
const expr = body?.trim() ?? ''
|
|
252
|
+
const expr = memoSeedExpr(memo)
|
|
241
253
|
steps.push(
|
|
242
254
|
expr === ''
|
|
243
255
|
? { kind: 'opaque', name: memo.name, origin: 'memo' }
|
package/src/types.ts
CHANGED
|
@@ -1578,6 +1578,18 @@ export interface IRProp extends AttrMeta {
|
|
|
1578
1578
|
// Metadata
|
|
1579
1579
|
// =============================================================================
|
|
1580
1580
|
|
|
1581
|
+
/** How a signal's initial value reads a prop (`SignalInfo.propSeed`). */
|
|
1582
|
+
export interface SignalPropSeed {
|
|
1583
|
+
/** The prop read: the first property after the props object, or the destructured binding. */
|
|
1584
|
+
propName: string
|
|
1585
|
+
via: 'member' | 'binding'
|
|
1586
|
+
/** True when the read goes past the prop (`props.row.count`, `props.items[0]`). */
|
|
1587
|
+
nested: boolean
|
|
1588
|
+
/** Whether `propName` is one of the component's declared props (`propsParams`). */
|
|
1589
|
+
declared: boolean
|
|
1590
|
+
fallback: { op: '??' | '||'; expr: ParsedExpr } | null
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1581
1593
|
export interface SignalInfo {
|
|
1582
1594
|
getter: string
|
|
1583
1595
|
setter: string | null
|
|
@@ -1590,6 +1602,16 @@ export interface SignalInfo {
|
|
|
1590
1602
|
* consumers fall back to parsing `initialValue`.
|
|
1591
1603
|
*/
|
|
1592
1604
|
parsed?: ParsedExpr
|
|
1605
|
+
/**
|
|
1606
|
+
* Set when `initialValue` is a read of one prop, bare or with a single
|
|
1607
|
+
* `??` / `||` fallback (`props.checked`, `checked ?? false`,
|
|
1608
|
+
* `props.value || ''`, `props.row.count`), recorded by the analyzer from
|
|
1609
|
+
* `parsed`. `via` is
|
|
1610
|
+
* how the prop is read: a member of the props object, or a binding a props
|
|
1611
|
+
* destructure introduced. The CSR init body asks this field, not the text,
|
|
1612
|
+
* whether the signal seeds from a prop and what default it keeps (#3508).
|
|
1613
|
+
*/
|
|
1614
|
+
propSeed?: SignalPropSeed
|
|
1593
1615
|
/** Initial value with TypeScript type annotations preserved, for .tsx output */
|
|
1594
1616
|
typedInitialValue?: string
|
|
1595
1617
|
/**
|
|
@@ -1738,14 +1760,30 @@ export interface MemoInfo {
|
|
|
1738
1760
|
name: string
|
|
1739
1761
|
computation: string
|
|
1740
1762
|
/**
|
|
1741
|
-
*
|
|
1763
|
+
* The expression the memo evaluates to, read from the callback node at
|
|
1764
|
+
* analysis time (#3510): the body of a zero-parameter arrow or `function`
|
|
1765
|
+
* expression (`() => e`, `() => { return e }`, `function () { return e }`),
|
|
1766
|
+
* or a call of the whole callback (`(() => { … })()`) for any other shape.
|
|
1767
|
+
* Type-stripped. Consumers substitute it for `memo()` instead of matching
|
|
1768
|
+
* `computation` against `() =>`. Unset only when `createMemo` has no
|
|
1769
|
+
* argument.
|
|
1770
|
+
*/
|
|
1771
|
+
bodyExpr?: string
|
|
1772
|
+
/**
|
|
1773
|
+
* Set when `bodyExpr` is a call of the whole callback rather than the
|
|
1774
|
+
* expression the callback returns — a multi-statement body, or a callback
|
|
1775
|
+
* that is not a plain zero-parameter function.
|
|
1776
|
+
*/
|
|
1777
|
+
bodyExprIsCall?: boolean
|
|
1778
|
+
/**
|
|
1779
|
+
* `bodyExpr` with bare destructured-prop refs rewritten to `_p.X` —
|
|
1742
1780
|
* the memo twin of `SignalInfo.templateInitialValue` (#2265). Consumed by
|
|
1743
1781
|
* `buildSignalMemoEnv` when the memo body is inlined into the module-scope
|
|
1744
1782
|
* CSR `template:` arrow, which is not a closure over init's destructured
|
|
1745
1783
|
* extractions (#2468). Only set for destructured-arg components that
|
|
1746
1784
|
* actually reference a prop.
|
|
1747
1785
|
*/
|
|
1748
|
-
|
|
1786
|
+
templateBodyExpr?: string
|
|
1749
1787
|
/** Computation with TypeScript type annotations preserved, for .tsx output */
|
|
1750
1788
|
typedComputation?: string
|
|
1751
1789
|
/**
|
|
@@ -2119,6 +2157,16 @@ export interface ConstantInfo {
|
|
|
2119
2157
|
isJsxFunction?: boolean
|
|
2120
2158
|
/** When true, the initializer contains an arrow function or function expression (computed from AST). */
|
|
2121
2159
|
containsArrow?: boolean
|
|
2160
|
+
/**
|
|
2161
|
+
* Set when this const is a binding of a body destructure of the props
|
|
2162
|
+
* object (`const { label = 'Default' } = props`), recorded by the analyzer
|
|
2163
|
+
* from the binding pattern itself. `sourceKey` is the prop it reads (the
|
|
2164
|
+
* property key, which differs from `name` for a renamed binding). Its
|
|
2165
|
+
* `value` text (`props.label ?? 'Default'`) is the same as a hand-written
|
|
2166
|
+
* `const label = props.label ?? 'Default'`, so consumers ask this field,
|
|
2167
|
+
* not the text, whether the const IS the prop (#3501).
|
|
2168
|
+
*/
|
|
2169
|
+
propsDestructure?: { sourceKey: string }
|
|
2122
2170
|
/**
|
|
2123
2171
|
* When true, the initializer IS an arrow function or function expression
|
|
2124
2172
|
* (`const status = () => …`), so reading the constant yields a function and
|