@barefootjs/jsx 0.29.0 → 0.30.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.
- package/dist/adapters/child-scope.d.ts +17 -0
- package/dist/adapters/child-scope.d.ts.map +1 -0
- package/dist/adapters/loop-bound-names.d.ts.map +1 -1
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +876 -352
- package/dist/ir-to-client-js/collect-elements.d.ts +5 -25
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +66 -2
- package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/lazy-conditional.d.ts +92 -0
- package/dist/ir-to-client-js/control-flow/plan/lazy-conditional.d.ts.map +1 -0
- package/dist/ir-to-client-js/control-flow/plan/lazy-preamble.d.ts +134 -0
- package/dist/ir-to-client-js/control-flow/plan/lazy-preamble.d.ts.map +1 -0
- package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts +46 -11
- package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +7 -0
- package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +2 -3
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts +6 -0
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts +1 -10
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +12 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/rich-type-evidence.d.ts.map +1 -1
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/to-locale-date-lowering.d.ts.map +1 -1
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +6 -24
- package/src/__tests__/branch-loop-plain.test.ts +28 -45
- package/src/__tests__/csr-substitution-safety-divergence.test.ts +9 -3
- package/src/__tests__/csr-template-scope-soundness.test.ts +96 -0
- package/src/__tests__/early-return-branch-switch.test.ts +96 -0
- package/src/__tests__/form-control-value-ssr.test.ts +102 -0
- package/src/__tests__/lazy-conditional.test.ts +190 -0
- package/src/__tests__/lazy-preamble.test.ts +297 -0
- package/src/__tests__/lazy-row-eligibility.test.ts +97 -28
- package/src/__tests__/loop-item-root-scope.test.ts +213 -0
- package/src/__tests__/map-multi-return-body.test.ts +30 -3
- package/src/__tests__/nested-loop-conditional.test.ts +27 -6
- package/src/__tests__/preamble-attr-reactivity.test.ts +217 -0
- package/src/__tests__/preamble-declarations.test.ts +207 -0
- package/src/__tests__/ssr-defaults.test.ts +44 -0
- package/src/adapters/child-scope.ts +22 -0
- package/src/adapters/loop-bound-names.ts +6 -0
- package/src/analyzer-context.ts +43 -0
- package/src/analyzer.ts +33 -3
- package/src/index.ts +1 -0
- package/src/ir-to-client-js/collect-elements.ts +51 -10
- package/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts +1 -1
- package/src/ir-to-client-js/control-flow/plan/build-composite-loop.ts +2 -2
- package/src/ir-to-client-js/control-flow/plan/build-event-delegation.ts +3 -3
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +2 -2
- package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +147 -5
- package/src/ir-to-client-js/control-flow/plan/build-loop.ts +2 -2
- package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/lazy-conditional.ts +151 -0
- package/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts +287 -0
- package/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts +85 -22
- package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +7 -0
- package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +133 -35
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +24 -4
- package/src/ir-to-client-js/csr-substitute.ts +6 -1
- package/src/ir-to-client-js/emit-registration.ts +1 -1
- package/src/ir-to-client-js/html-template.ts +51 -40
- package/src/ir-to-client-js/index.ts +1 -1
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +2 -0
- package/src/ir-to-client-js/plan/build-static-array-child-init.ts +1 -1
- package/src/ir-to-client-js/plan/declaration-emit.ts +6 -0
- package/src/ir-to-client-js/reactivity.ts +25 -0
- package/src/ir-to-client-js/stringify/declaration-emit.ts +9 -4
- package/src/ir-to-client-js/types.ts +12 -0
- package/src/jsx-to-ir.ts +400 -24
- package/src/rich-type-evidence.ts +6 -7
- package/src/ssr-defaults.ts +7 -2
- package/src/to-locale-date-lowering.ts +8 -2
- package/src/types.ts +80 -0
package/src/types.ts
CHANGED
|
@@ -60,6 +60,13 @@ export interface TypeInfo {
|
|
|
60
60
|
// For primitives
|
|
61
61
|
primitive?: 'string' | 'number' | 'boolean' | 'null' | 'undefined'
|
|
62
62
|
|
|
63
|
+
/** Set when the type is a LITERAL of its primitive family (`'a'`, `42`,
|
|
64
|
+
* `true`) — the literal's source value. `typeNodeToTypeInfo` lowers a
|
|
65
|
+
* literal type to `kind: 'primitive'` + this field, so family-only
|
|
66
|
+
* consumers need no special case and value consumers never re-parse
|
|
67
|
+
* `raw`. */
|
|
68
|
+
literalValue?: string
|
|
69
|
+
|
|
63
70
|
// For objects/interfaces
|
|
64
71
|
properties?: PropertyInfo[]
|
|
65
72
|
|
|
@@ -854,6 +861,28 @@ export interface MapCallbackPreamble {
|
|
|
854
861
|
ssrText: TsxSourceText
|
|
855
862
|
/** const/let/function names the preamble declares (D5 key-derivability guard). */
|
|
856
863
|
declaredNames: string[]
|
|
864
|
+
/**
|
|
865
|
+
* The whole preamble as backend-neutral value declarations — set only when
|
|
866
|
+
* EVERY statement is one (#2447). This is the DSL SSR carrier: a template
|
|
867
|
+
* language cannot execute `segments` (that is JS text, for the client bundle
|
|
868
|
+
* and for JS-runtime SSR), but it CAN declare a per-row local, and each
|
|
869
|
+
* declaration's initializer is a {@link ParsedExpr} every adapter already
|
|
870
|
+
* knows how to emit in its own syntax — the same door `arrayParsed` /
|
|
871
|
+
* `filterPredicate.predicate` / `sortComparator` go through.
|
|
872
|
+
*
|
|
873
|
+
* All-or-nothing on purpose. A preamble is a statement SEQUENCE with
|
|
874
|
+
* order-dependent scope; lowering the declarable prefix and dropping the rest
|
|
875
|
+
* would leave later statements' effects missing with no diagnostic — the
|
|
876
|
+
* silent divergence #2447 was. So one non-declaration statement (an
|
|
877
|
+
* assignment, a loop, a call for side effects) or one initializer the
|
|
878
|
+
* expression subset cannot model leaves this `undefined`, and the Phase-1
|
|
879
|
+
* DSL gate refuses the whole loop with `/* @client *\/` guidance.
|
|
880
|
+
*
|
|
881
|
+
* Declarations appear in source order and may read earlier ones; adapters
|
|
882
|
+
* emit them in order, so an earlier local is in scope for a later
|
|
883
|
+
* initializer, exactly as in the source.
|
|
884
|
+
*/
|
|
885
|
+
declarations?: PreambleValueDeclaration[]
|
|
857
886
|
/**
|
|
858
887
|
* The subset of {@link declaredNames} that accumulate JSX leaves — the
|
|
859
888
|
* `push`/`unshift` targets of a `jsx` segment and the declaration targets of
|
|
@@ -864,6 +893,25 @@ export interface MapCallbackPreamble {
|
|
|
864
893
|
builderNames: string[]
|
|
865
894
|
}
|
|
866
895
|
|
|
896
|
+
/**
|
|
897
|
+
* One `const`/`let` value declaration from a `.map()` callback preamble, in
|
|
898
|
+
* backend-neutral form (#2447 — see {@link MapCallbackPreamble.declarations}).
|
|
899
|
+
* `name` is always a simple identifier: a destructuring binding declares
|
|
900
|
+
* several names from one initializer, which no adapter has a single per-row
|
|
901
|
+
* local form for, so that shape refuses instead of being carried here.
|
|
902
|
+
*/
|
|
903
|
+
export interface PreambleValueDeclaration {
|
|
904
|
+
/** Declared local name (simple identifier binding). */
|
|
905
|
+
name: string
|
|
906
|
+
/** Initializer, structured for per-adapter emission. */
|
|
907
|
+
valueParsed: ParsedExpr
|
|
908
|
+
/**
|
|
909
|
+
* Initializer source text, for a diagnostic that needs to quote it. Never an
|
|
910
|
+
* emission input — emission goes through `valueParsed`.
|
|
911
|
+
*/
|
|
912
|
+
raw: string
|
|
913
|
+
}
|
|
914
|
+
|
|
867
915
|
/**
|
|
868
916
|
* One loop-body expression child classified as a preamble-patched region
|
|
869
917
|
* (#2389 — see `IRLoop.preambleRegions`). `expr` is the raw (unwrapped)
|
|
@@ -1002,6 +1050,20 @@ export interface IRComponent {
|
|
|
1002
1050
|
* Omitted (undefined) for ordinary components to keep IR diffs minimal.
|
|
1003
1051
|
*/
|
|
1004
1052
|
dynamicTag?: boolean
|
|
1053
|
+
/**
|
|
1054
|
+
* True when this component is a DIRECT member of an `IRLoop.children`
|
|
1055
|
+
* array (the loop's row-root component, e.g. `{rows().map(r => <Row/>)}`).
|
|
1056
|
+
* Such a component owns its own per-row identity and gets a freshly
|
|
1057
|
+
* randomized `bf-s` — it does NOT derive its scope id from the parent
|
|
1058
|
+
* scope + mount slot the way an ordinarily-slotted child does.
|
|
1059
|
+
*
|
|
1060
|
+
* A component nested *below* the row root (e.g. `<li><Badge/></li>` where
|
|
1061
|
+
* `<li>` is the loop row root) is NOT marked — it derives its scope id
|
|
1062
|
+
* from parent scope + slot like any other slotted child. See
|
|
1063
|
+
* `derivesScopeFromSlot` in `./adapters/child-scope.ts`, which is the one
|
|
1064
|
+
* predicate every backend must consult instead of re-deriving this fact.
|
|
1065
|
+
*/
|
|
1066
|
+
loopItemRoot?: boolean
|
|
1005
1067
|
loc: SourceLocation
|
|
1006
1068
|
}
|
|
1007
1069
|
|
|
@@ -1399,6 +1461,15 @@ export interface SignalInfo {
|
|
|
1399
1461
|
* AST-level pre-rewrite).
|
|
1400
1462
|
*/
|
|
1401
1463
|
templateInitialValue?: string
|
|
1464
|
+
/**
|
|
1465
|
+
* True for the getter-elided declaration form `const [, setX] =
|
|
1466
|
+
* createSignal(...)`. `getter` then holds a synthesized internal name
|
|
1467
|
+
* (`__bfGet_<setter>`) that no expression ever references — it exists so
|
|
1468
|
+
* getter-keyed consumers (substitution env, SSR seeding) stay total.
|
|
1469
|
+
* Emit reproduces the source's `[, setter]` hole instead of introducing
|
|
1470
|
+
* the synthesized name into output.
|
|
1471
|
+
*/
|
|
1472
|
+
getterElided?: boolean
|
|
1402
1473
|
type: TypeInfo
|
|
1403
1474
|
loc: SourceLocation
|
|
1404
1475
|
/**
|
|
@@ -1458,6 +1529,15 @@ export interface SignalInfo {
|
|
|
1458
1529
|
export interface MemoInfo {
|
|
1459
1530
|
name: string
|
|
1460
1531
|
computation: string
|
|
1532
|
+
/**
|
|
1533
|
+
* `computation` with bare destructured-prop refs rewritten to `_p.X` —
|
|
1534
|
+
* the memo twin of `SignalInfo.templateInitialValue` (#2265). Consumed by
|
|
1535
|
+
* `buildSignalMemoEnv` when the memo body is inlined into the module-scope
|
|
1536
|
+
* CSR `template:` arrow, which is not a closure over init's destructured
|
|
1537
|
+
* extractions (#2468). Only set for destructured-arg components that
|
|
1538
|
+
* actually reference a prop.
|
|
1539
|
+
*/
|
|
1540
|
+
templateComputation?: string
|
|
1461
1541
|
/** Computation with TypeScript type annotations preserved, for .tsx output */
|
|
1462
1542
|
typedComputation?: string
|
|
1463
1543
|
/**
|