@barefootjs/jsx 0.40.1 → 0.40.2
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/ambiguous-nil-arithmetic.d.ts +4 -3
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -1
- package/dist/adapters/boolean-result.d.ts +32 -10
- package/dist/adapters/boolean-result.d.ts.map +1 -1
- package/dist/adapters/brace-delimiter-text.d.ts +18 -0
- package/dist/adapters/brace-delimiter-text.d.ts.map +1 -0
- package/dist/adapters/callback-method.d.ts +38 -5
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +11 -1
- package/dist/adapters/computed-const.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +21 -0
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
- package/dist/adapters/loop-bound-names.d.ts +9 -1
- package/dist/adapters/loop-bound-names.d.ts.map +1 -1
- package/dist/adapters/loop-row-type.d.ts +52 -0
- package/dist/adapters/loop-row-type.d.ts.map +1 -0
- package/dist/adapters/nil-reading.d.ts +68 -0
- package/dist/adapters/nil-reading.d.ts.map +1 -0
- package/dist/adapters/non-primitive-equality.d.ts +33 -0
- package/dist/adapters/non-primitive-equality.d.ts.map +1 -0
- package/dist/adapters/number-value.d.ts +5 -3
- package/dist/adapters/number-value.d.ts.map +1 -1
- package/dist/adapters/operand-typing.d.ts +126 -0
- package/dist/adapters/operand-typing.d.ts.map +1 -0
- package/dist/adapters/parsed-expr-emitter.d.ts +70 -12
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/primitive-plan.d.ts +291 -0
- package/dist/adapters/primitive-plan.d.ts.map +1 -0
- package/dist/analyzer-context.d.ts +4 -0
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts +63 -8
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/event-handler-name.d.ts +12 -0
- package/dist/event-handler-name.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +8 -0
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4628 -2198
- package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
- package/dist/ir-to-client-js/child-props-object.d.ts +64 -0
- package/dist/ir-to-client-js/child-props-object.d.ts.map +1 -0
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +4 -2
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +2 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/dist/ir-to-client-js/index.d.ts +2 -6
- package/dist/ir-to-client-js/index.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +30 -18
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts +3 -2
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts +1 -0
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +68 -9
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/prop-rewrite.d.ts +7 -0
- package/dist/prop-rewrite.d.ts.map +1 -1
- package/dist/props-object-whole-read.d.ts +15 -0
- package/dist/props-object-whole-read.d.ts.map +1 -0
- package/dist/rich-type-refusal.d.ts.map +1 -1
- package/dist/scope/binding-scope.d.ts +85 -10
- package/dist/scope/binding-scope.d.ts.map +1 -1
- package/dist/scope/lexical-scope-walk.d.ts +3 -2
- package/dist/scope/lexical-scope-walk.d.ts.map +1 -1
- package/dist/scope/root-prop-alias.d.ts +10 -7
- package/dist/scope/root-prop-alias.d.ts.map +1 -1
- package/dist/strip-types.d.ts +13 -0
- package/dist/strip-types.d.ts.map +1 -1
- package/dist/template-position-walk.d.ts +21 -3
- package/dist/template-position-walk.d.ts.map +1 -1
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +3 -3
- package/src/__tests__/binding-scope.test.ts +89 -1
- package/src/__tests__/body-destructure-props-object-alias.test.ts +123 -0
- package/src/__tests__/boolean-result.test.ts +22 -5
- package/src/__tests__/brace-delimiter-text.test.ts +26 -0
- package/src/__tests__/callback-method.test.ts +62 -2
- package/src/__tests__/child-components-in-map.test.ts +1 -1
- package/src/__tests__/computed-const.test.ts +103 -0
- package/src/__tests__/emit-to-string-call.test.ts +2 -1
- package/src/__tests__/hydration-payload-analysis.test.ts +166 -0
- package/src/__tests__/issue-2724-prop-alias-loop-not-static.test.ts +7 -7
- package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +5 -2
- package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +1 -1
- package/src/__tests__/issue-2835-props-type-member-name-collision.test.ts +4 -4
- package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +1 -1
- package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +2 -1
- package/src/__tests__/issue-3713-props-spread-loop-row.test.ts +65 -0
- package/src/__tests__/lookup-literal-const.test.ts +9 -3
- package/src/__tests__/loop-index-reactivity.test.ts +2 -2
- package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +1 -1
- package/src/__tests__/loop-plan.test.ts +1 -1
- package/src/__tests__/loop-row-const-initializer-shadow.test.ts +146 -0
- package/src/__tests__/loop-row-type.test.ts +64 -0
- package/src/__tests__/lowering-value-position.test.ts +4 -0
- package/src/__tests__/module-const-destructure-default.test.ts +156 -0
- package/src/__tests__/nested-loop-index-param.test.ts +1 -1
- package/src/__tests__/nested-loop-reactive-attrs.test.ts +2 -2
- package/src/__tests__/nested-row-shadowing.test.ts +2 -2
- package/src/__tests__/nil-reading.test.ts +77 -0
- package/src/__tests__/nullable-signal-attr.test.ts +134 -0
- package/src/__tests__/primitive-plan.test.ts +416 -0
- package/src/__tests__/profile-loop-binding-ids.test.ts +2 -2
- package/src/__tests__/profile-nested-binding-ids.test.ts +2 -2
- package/src/__tests__/props-object-whole-read.test.ts +40 -0
- package/src/__tests__/reactive-attrs-in-map.test.ts +1 -1
- package/src/__tests__/reactive-factory-inlining.test.ts +4 -1
- package/src/__tests__/rest-binding-gaps.test.ts +192 -0
- package/src/__tests__/root-prop-alias.test.ts +53 -8
- package/src/__tests__/static-loop-csr-materialize.test.ts +2 -2
- package/src/__tests__/static-record-literal-array.test.ts +171 -0
- package/src/__tests__/string-concat-identifier.test.ts +40 -1
- package/src/adapters/ambiguous-nil-arithmetic.ts +22 -13
- package/src/adapters/boolean-result.ts +72 -66
- package/src/adapters/brace-delimiter-text.ts +25 -0
- package/src/adapters/callback-method.ts +151 -27
- package/src/adapters/computed-const.ts +238 -4
- package/src/adapters/dsl-template-adapter.ts +40 -2
- package/src/adapters/loop-bound-names.ts +9 -1
- package/src/adapters/loop-plan.ts +1 -1
- package/src/adapters/loop-row-type.ts +139 -0
- package/src/adapters/nil-reading.ts +297 -0
- package/src/adapters/non-primitive-equality.ts +92 -0
- package/src/adapters/number-value.ts +17 -4
- package/src/adapters/operand-typing.ts +522 -0
- package/src/adapters/parsed-expr-emitter.ts +154 -19
- package/src/adapters/primitive-plan.ts +696 -0
- package/src/analyzer-context.ts +6 -0
- package/src/analyzer.ts +505 -19
- package/src/augment-inherited-props.ts +108 -10
- package/src/compiler.ts +17 -0
- package/src/event-handler-name.ts +15 -0
- package/src/expression-parser.ts +70 -1
- package/src/index.ts +33 -7
- package/src/ir-to-client-js/build-references.ts +69 -0
- package/src/ir-to-client-js/child-props-object.ts +106 -0
- package/src/ir-to-client-js/collect-elements.ts +30 -55
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +6 -1
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +29 -28
- package/src/ir-to-client-js/control-flow/shared.ts +20 -22
- package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +5 -3
- package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +1 -1
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/loop.ts +1 -1
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +3 -3
- package/src/ir-to-client-js/html-template.ts +25 -8
- package/src/ir-to-client-js/imports.ts +1 -1
- package/src/ir-to-client-js/index.ts +53 -11
- package/src/ir-to-client-js/plan/build-static-array-child-init.ts +31 -14
- package/src/ir-to-client-js/plan/static-array-child-init.ts +27 -18
- package/src/ir-to-client-js/prop-handling.ts +22 -3
- package/src/ir-to-client-js/stringify/static-array-child-init.ts +26 -10
- package/src/jsx-to-ir.ts +446 -37
- package/src/nullable-signal-attr.ts +246 -29
- package/src/prop-rewrite.ts +30 -6
- package/src/props-object-whole-read.ts +87 -0
- package/src/rich-type-refusal.ts +2 -1
- package/src/scope/binding-scope.ts +182 -18
- package/src/scope/lexical-scope-walk.ts +4 -3
- package/src/scope/root-prop-alias.ts +15 -8
- package/src/strip-types.ts +31 -3
- package/src/template-position-walk.ts +57 -28
- package/src/types.ts +87 -0
package/src/types.ts
CHANGED
|
@@ -112,6 +112,16 @@ export interface ParamInfo {
|
|
|
112
112
|
* `type` for the `props.n` form.
|
|
113
113
|
*/
|
|
114
114
|
declaredType?: TypeInfo
|
|
115
|
+
/**
|
|
116
|
+
* The values the prop's declared type admits when it is only string
|
|
117
|
+
* literals, `null` and `undefined` (`'ok' | 'err'`, a same-file alias of
|
|
118
|
+
* such a union, through a props type that is an intersection or an
|
|
119
|
+
* interface): the string keys, and which of `null` / `undefined` it also
|
|
120
|
+
* admits (the `?` modifier not included). Absent for any other type. A
|
|
121
|
+
* read of a const record indexed by the prop is projected from it
|
|
122
|
+
* (`computed-const.ts`).
|
|
123
|
+
*/
|
|
124
|
+
literalKeys?: { keys: string[]; nullish: Array<'null' | 'undefined'> }
|
|
115
125
|
optional: boolean
|
|
116
126
|
defaultValue?: JsSourceText
|
|
117
127
|
/**
|
|
@@ -126,6 +136,15 @@ export interface ParamInfo {
|
|
|
126
136
|
parsed?: ParsedExpr
|
|
127
137
|
/** When true, the default value contains an arrow function or function expression (computed from AST). */
|
|
128
138
|
defaultContainsArrow?: boolean
|
|
139
|
+
/**
|
|
140
|
+
* The free identifiers the default reads, from the initializer's own AST
|
|
141
|
+
* (`extractFreeIdentifiersFromNode`): an object key, a member name or a
|
|
142
|
+
* callback parameter inside the default is not one (`{ m = ({ label: 'm' })
|
|
143
|
+
* .label }` reads nothing outer). The client reference graph traces these,
|
|
144
|
+
* since the emitted read `_p.m ?? <default>` evaluates the default. Set
|
|
145
|
+
* only when the default reads at least one name.
|
|
146
|
+
*/
|
|
147
|
+
defaultFreeIdentifiers?: readonly string[]
|
|
129
148
|
/**
|
|
130
149
|
* `defaultValue` split at each read of an EARLIER binding of the same props
|
|
131
150
|
* destructure (`{ off = false, on = off }` → `on`'s parts are one `param`
|
|
@@ -735,6 +754,16 @@ export interface IRLoop {
|
|
|
735
754
|
param: string
|
|
736
755
|
predicate?: ParsedExpr // Boolean predicate expression (folded from any block body)
|
|
737
756
|
raw: string // Original string for error messages
|
|
757
|
+
/**
|
|
758
|
+
* `raw` with each destructured-prop read rewritten to its live `_p.<key>`
|
|
759
|
+
* read, the predicate's `templateArray` twin (#3845). The client
|
|
760
|
+
* template runs at module scope, where the component's destructured
|
|
761
|
+
* locals don't exist, so its `.filter(...)` reads this text. Decided in
|
|
762
|
+
* Phase 1 against the binding scope at the predicate (the predicate's
|
|
763
|
+
* own parameter and any enclosing row binding shadow a prop of the same
|
|
764
|
+
* name). Unset when the predicate reads no destructured prop.
|
|
765
|
+
*/
|
|
766
|
+
templateRaw?: string
|
|
738
767
|
}
|
|
739
768
|
|
|
740
769
|
/**
|
|
@@ -1511,6 +1540,17 @@ export interface SpreadAttr {
|
|
|
1511
1540
|
* any other spread, including a `{...rest}` bag.
|
|
1512
1541
|
*/
|
|
1513
1542
|
propsObject?: true
|
|
1543
|
+
/**
|
|
1544
|
+
* Which of the caller's own prop bags this spread forwards whole: `'props'`
|
|
1545
|
+
* for the component's props object, `'rest'` for its destructured
|
|
1546
|
+
* `...rest` binding, through any alias hop (`resolveRestSpreadOriginCore`).
|
|
1547
|
+
* Decided once in Phase 1, where a name an enclosing loop row or callback
|
|
1548
|
+
* binds is that binding, not the bag. Unset for any other spread, and never
|
|
1549
|
+
* set on a closed-type rest spread (that one unrolls per key). The client
|
|
1550
|
+
* reads every key of such a spread off `_p`, so the hydration payload must
|
|
1551
|
+
* carry the caller's whole bag (`ClientAnalysis.readsCallerBag`, #3845).
|
|
1552
|
+
*/
|
|
1553
|
+
callerBag?: 'props' | 'rest'
|
|
1514
1554
|
}
|
|
1515
1555
|
|
|
1516
1556
|
export interface JsxChildrenAttr {
|
|
@@ -1660,6 +1700,15 @@ export interface IRAttribute extends AttrMeta {
|
|
|
1660
1700
|
* like SSR / hydrated / csr-mount agree it should.
|
|
1661
1701
|
*/
|
|
1662
1702
|
restExpandedKey?: boolean
|
|
1703
|
+
/**
|
|
1704
|
+
* With `restExpandedKey`: the value an earlier attribute gave the same key
|
|
1705
|
+
* (`<p title="fixed" {...rest}>`), which the key keeps when the caller
|
|
1706
|
+
* omits it (#3851, `closedRestFallbacks` in jsx-to-ir.ts). Client-template
|
|
1707
|
+
* source text (destructured props spelled `_p.xxx`), so `collectElements`
|
|
1708
|
+
* binds `_p.<key> ?? (restFallback)` instead of a bare `_p.<key>` that
|
|
1709
|
+
* would remove the attribute SSR rendered.
|
|
1710
|
+
*/
|
|
1711
|
+
restFallback?: JsSourceText
|
|
1663
1712
|
}
|
|
1664
1713
|
|
|
1665
1714
|
export interface IREvent {
|
|
@@ -2328,6 +2377,15 @@ export interface ConstantInfo {
|
|
|
2328
2377
|
* was supposed to do.
|
|
2329
2378
|
*/
|
|
2330
2379
|
mutatedAfterDeclaration?: boolean
|
|
2380
|
+
/**
|
|
2381
|
+
* When true, this module-level const is shadowed inside the component: a
|
|
2382
|
+
* destructured prop, the props object, or a component-scope const,
|
|
2383
|
+
* function, signal or memo binds the same name, so a read of the name in
|
|
2384
|
+
* the component is that binding, never this const. Set by
|
|
2385
|
+
* `buildMetadata`; a compile-time lookup of a module const's value must
|
|
2386
|
+
* check it before resolving a read.
|
|
2387
|
+
*/
|
|
2388
|
+
shadowedInComponent?: boolean
|
|
2331
2389
|
/**
|
|
2332
2390
|
* Set when the component writes the binding anywhere in its body, event
|
|
2333
2391
|
* handlers and other callbacks included — the same fact
|
|
@@ -2401,9 +2459,25 @@ export interface IRMetadata {
|
|
|
2401
2459
|
propsParams: ParamInfo[]
|
|
2402
2460
|
/** Name of the props object parameter (e.g., 'props' in `function Component(props: Props)`) */
|
|
2403
2461
|
propsObjectName: string | null
|
|
2462
|
+
/**
|
|
2463
|
+
* Whether the component reads its props object as a whole (`{...props}`,
|
|
2464
|
+
* `Object.keys(props)`, `props[key]`, passing `props` on), so a key its
|
|
2465
|
+
* props type does not declare can still reach the output. Undefined on
|
|
2466
|
+
* hand-built metadata, which reads as false.
|
|
2467
|
+
*/
|
|
2468
|
+
propsObjectObservedWhole?: boolean
|
|
2404
2469
|
restPropsName: string | null
|
|
2405
2470
|
/** Keys statically expanded from rest props via type analysis (closed type only) */
|
|
2406
2471
|
restPropsExpandedKeys: string[]
|
|
2472
|
+
/**
|
|
2473
|
+
* Set when `restPropsName` is bound by a component-body destructure of the
|
|
2474
|
+
* props object (`function C(props) { const { label, ...rest } = props }`)
|
|
2475
|
+
* rather than by the signature: the caller keys that destructure takes
|
|
2476
|
+
* before its rest element. A backend that runs the component body as JS
|
|
2477
|
+
* declares the binding from the props object without them. Absent (or
|
|
2478
|
+
* null) for a signature rest and on hand-built metadata.
|
|
2479
|
+
*/
|
|
2480
|
+
restPropsOmittedKeys?: string[] | null
|
|
2407
2481
|
signals: SignalInfo[]
|
|
2408
2482
|
memos: MemoInfo[]
|
|
2409
2483
|
effects: EffectInfo[]
|
|
@@ -2582,6 +2656,19 @@ export interface PropUsage {
|
|
|
2582
2656
|
export interface ClientAnalysis {
|
|
2583
2657
|
needsInit: boolean
|
|
2584
2658
|
usedProps: string[]
|
|
2659
|
+
/**
|
|
2660
|
+
* Caller keys of a closed-type `...rest` (`restPropsExpandedKeys`) the
|
|
2661
|
+
* client reads as `_p.<key>`. They are not `propsParams`, so `usedProps`
|
|
2662
|
+
* never lists them, but the hydration payload must carry them (#3845).
|
|
2663
|
+
*/
|
|
2664
|
+
usedRestKeys: string[]
|
|
2665
|
+
/**
|
|
2666
|
+
* The client reads one of the caller's prop bags whole (a spread whose
|
|
2667
|
+
* `SpreadAttr.callerBag` is set): every key the caller passed reaches the
|
|
2668
|
+
* client through `_p`, so the hydration payload carries the caller's whole
|
|
2669
|
+
* bag, not only the named props (#3845).
|
|
2670
|
+
*/
|
|
2671
|
+
readsCallerBag: boolean
|
|
2585
2672
|
/**
|
|
2586
2673
|
* The subset of `usedProps` whose declared type is a function — the client
|
|
2587
2674
|
* code CALLS these, so they cannot arrive as JSON. Keyed by caller-facing
|