@kudzujs/core 0.8.57 → 0.8.59
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/MIGRATION_ROADMAP.md +3 -1
- package/PERFORMANCE.md +9 -1
- package/README.md +1 -1
- package/RELEASES.md +62 -0
- package/docs/next-architecture/README.md +1 -1
- package/docs/next-architecture/compiler-current-architecture.md +1 -1
- package/docs/next-architecture/large-application-ai-native-roadmap.md +2 -2
- package/docs/next-architecture/versioning.md +3 -1
- package/framework/README.md +1 -1
- package/framework/compiler/list-runtime-codegen.mjs +1 -1
- package/framework/compiler/route-capability-planner.mjs +1 -1
- package/framework/compiler/route-ir.mjs +1 -1
- package/framework/compiler/source-compiler.mjs +31 -11
- package/framework/core.d.ts +1 -1
- package/framework/core.mjs +4 -4
- package/framework/list-runtime.js +5 -5
- package/package.json +1 -1
package/MIGRATION_ROADMAP.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This document is the source of truth for Kudzu's product direction, architecture invariants, and future development order. Read it before extending React-shaped syntax or browser capabilities.
|
|
4
4
|
|
|
5
|
-
The executable post-`0.8.
|
|
5
|
+
The executable post-`0.8.59` compiler and large-application sequence is maintained in [`docs/next-architecture/large-application-ai-native-roadmap.md`](./docs/next-architecture/large-application-ai-native-roadmap.md). Follow its PR dependencies for implementation work; this document remains authoritative when selecting or accepting a migration capability.
|
|
6
6
|
|
|
7
7
|
[`GOAL_A.md`](./GOAL_A.md) and [`GOAL_B.md`](./GOAL_B.md) are completed capability-validation records. Their commerce and realtime dashboard fixtures prove general lifecycle, navigation, async-workflow, and Worker capabilities; they are not separate product verticals or future priority lists.
|
|
8
8
|
|
|
@@ -148,6 +148,8 @@ This queue orders the next investigations by general migration value. Start only
|
|
|
148
148
|
- Context actions inline into existing route handler ESM and compile to concrete state operations. Private captures, dynamic Provider objects, and multiple Provider implementations remain diagnosed; no browser Context tree, callback registry, or shared runtime was added.
|
|
149
149
|
- In `0.8.46`, the same Notes migration may omit action-only setters from its public Context type and authored Provider value when the corresponding state remains exposed. Kudzu restores those setters only in build scratch so existing concrete state operations, RouteIR signals, CRUD behavior, and zero-Context runtime output remain unchanged. Fully hidden action state and exposed setters without state remain diagnosed.
|
|
150
150
|
- In `0.8.47`, a specialized setter-callback child may initialize local state directly from one primitive parent state prop. Build scratch reads the parent signal's build value while retaining the structural prop signal for handlers/effects. `0.8.57` extends that exact path to a parent state authored with one JSON-safe plain-object literal; independent child draft state and parent commit behavior pass in the FIRE-derived callback fixture. Array props, aliases, property paths, composed expressions, and object `.toString()` remain diagnosed.
|
|
151
|
+
- In `0.8.58`, a direct keyed item prop may initialize one row-owned object draft. Retained keys preserve that draft and DOM identity through reorder; removal releases it, and re-adding the key clones the current item into fresh state. Aliases, property paths, composed expressions, and indirect item props remain diagnosed.
|
|
152
|
+
- In `0.8.59`, the ClimateCompatibleGrowth teaching-kit `Dropdown` migration may initialize local array state from one direct parent array-state prop and commit it through a direct `on*` callback or matching `set*` setter prop. Parent and child arrays remain independently owned, mounted drafts do not auto-synchronize, and aliases, property paths, composed arrays, indirect callbacks, and additional `set*` forwarding remain diagnosed.
|
|
151
153
|
- In `0.8.48`, one setter-callback prop may be called once from each of multiple direct intrinsic event handlers in the specialized leaf. Each call lowers independently to the same parent signal; forwarding fan-out, aliases, non-handler uses, and repeated calls inside one handler remain diagnosed, and no callback registry or handler runtime is added.
|
|
152
154
|
- In `0.8.49`, one component may forward the same destructured setter callback directly through multiple child component `on*` props. Each branch specializes independently to the original parent signal within the existing three-boundary limit; aliases, ordinary props, spreads, and a fourth boundary remain diagnosed.
|
|
153
155
|
|
package/PERFORMANCE.md
CHANGED
|
@@ -6,7 +6,15 @@ Reproducibility classes: `npm run benchmark`, `npm run benchmark:keyed`, `npm ru
|
|
|
6
6
|
|
|
7
7
|
The maintained 2026-08-13 comparison used Node 24.14.0 and an Intel Core i5-9500 Linux x64 host, one warm-up, and seven alternating fresh-process samples against clean `v0.8.44`. A narrow fast path skips Kudzu semantic transformation for 450 plain `.ts` modules whose runtime edges are exclusively resolvable relative TypeScript imports or exports; all other modules retain the existing transformer. Compile median fell from 2,323.9 ms to 1,413.2 ms (39.2%) and clean-build median from 3,325.3 ms to 2,382.4 ms (28.4%); every paired sample improved. Compile peak-RSS median fell from 571.2 MiB to 552.6 MiB, while build peak RSS was 570.9 MiB versus 568.8 MiB. Compiler scratch fell from 7,328,390 to 1,971,061 bytes. Both targets emitted the same 50 static HTML files, 10,980 bytes, and deploy SHA-256 `e107d78a7f55bc8a1af0ea6e53efeffa19b3d44d21c892484d103fa346e7ba7b`. This is a source-scale compiler comparison, not a cross-framework result.
|
|
8
8
|
|
|
9
|
-
## Current 0.8.
|
|
9
|
+
## Current 0.8.59 Release Snapshot
|
|
10
|
+
|
|
11
|
+
Kudzu 0.8.59 broadens existing compile-time setter-child specialization to one direct parent array-state prop and one direct `set*` setter prop in that prop-derived state shape. It adds no browser runtime code and makes no timing claim.
|
|
12
|
+
|
|
13
|
+
## Maintained 0.8.58 Release Snapshot
|
|
14
|
+
|
|
15
|
+
Kudzu 0.8.58 adds one narrow keyed-item initializer descriptor to the existing complex row-state path. Routes without that descriptor, including static siblings, retain their existing capability output. This release makes no timing claim.
|
|
16
|
+
|
|
17
|
+
## Maintained 0.8.57 Release Snapshot
|
|
10
18
|
|
|
11
19
|
Kudzu 0.8.57 broadens an existing compiler proof from direct primitive parent state to direct JSON-safe plain-object parent state for specialized child draft initialization. It adds no browser runtime code and makes no timing claim.
|
|
12
20
|
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Kudzu compiles ordinary React-shaped TypeScript and TSX into complete static HTM
|
|
|
14
14
|
|
|
15
15
|
> Experimental `0.8.x`: the compiler API and supported TSX surface may change.
|
|
16
16
|
|
|
17
|
-
**Latest release: 0.8.
|
|
17
|
+
**Latest release: 0.8.59 - Array prop draft state.** Specialized children can initialize independent array draft state from one direct parent state prop and retain an authored direct `set*` setter prop without a component runtime. Read the [release notes](./RELEASES.md#0859---array-prop-draft-state), open the [release page](https://github.com/kudzujs/kudzu/releases/tag/v0.8.59), or follow the [architecture packet](./docs/next-architecture/README.md).
|
|
18
18
|
|
|
19
19
|
- [Documentation](https://kudzujs.cloud/docs)
|
|
20
20
|
- [Installation guide](https://kudzujs.cloud/docs#install)
|
package/RELEASES.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# Kudzu Releases
|
|
2
2
|
|
|
3
|
+
## 0.8.59 - Array prop draft state
|
|
4
|
+
|
|
5
|
+
Kudzu 0.8.59 lets a specialized child initialize independent local array draft state directly from one parent array-state prop while preserving an authored direct `set*` setter prop.
|
|
6
|
+
|
|
7
|
+
### Changed in 0.8.59
|
|
8
|
+
|
|
9
|
+
- `const [draft, setDraft] = useState(selectedItems)` compiles when `selectedItems` is one direct prop backed by a parent `useState([...])` literal.
|
|
10
|
+
- A direct parent setter may enter that prop-draft specialization through an `on*` prop or an authored `set*` prop such as `setSelectedItems`.
|
|
11
|
+
- Parent and child retain distinct state IDs and independently serialized arrays.
|
|
12
|
+
- Mounted drafts remain local until the authored handler explicitly commits them to parent state.
|
|
13
|
+
|
|
14
|
+
### Boundaries
|
|
15
|
+
|
|
16
|
+
- `set*` support is limited to prop-derived state components; unrelated effect setter props retain their existing path.
|
|
17
|
+
- Additional forwarding remains `on*`-only.
|
|
18
|
+
- Aliases, property paths, array spreads, composed expressions, indirect callbacks, and automatic prop synchronization remain rejected.
|
|
19
|
+
- No runtime module, VDOM, hydration, or retained component tree is added.
|
|
20
|
+
|
|
21
|
+
### Validation
|
|
22
|
+
|
|
23
|
+
- A fixture reduced from ClimateCompatibleGrowth's MIT-licensed teaching-kit `Dropdown` preserves its direct `selectedItems` and `setSelectedItems` source shape.
|
|
24
|
+
- Browser coverage proves child draft independence, parent replacement without draft synchronization, explicit commit, and a static zero-JavaScript sibling.
|
|
25
|
+
- Existing conditional-effect `setResult` props remain outside setter-callback specialization.
|
|
26
|
+
- `npm run check`, `npm test`, and `npm run test:package` pass with all 225 tests and 174 generated pages.
|
|
27
|
+
|
|
28
|
+
### Upgrade
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @kudzujs/core@^0.8.59
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 0.8.58 - Keyed item draft state
|
|
35
|
+
|
|
36
|
+
Kudzu 0.8.58 lets a keyed row initialize independent local object draft state directly from its keyed item prop.
|
|
37
|
+
|
|
38
|
+
### Changed in 0.8.58
|
|
39
|
+
|
|
40
|
+
- `const [draft, setDraft] = useState(todo)` compiles when `todo` is the direct item prop of a keyed row.
|
|
41
|
+
- RouteIR marks the state with a narrow `list-item` initializer descriptor.
|
|
42
|
+
- New keys clone the current item into existing key-scoped row-state ownership without a component runtime.
|
|
43
|
+
- Retained keys preserve their draft state and DOM identity through item updates and reorder.
|
|
44
|
+
|
|
45
|
+
### Boundaries
|
|
46
|
+
|
|
47
|
+
- Removing a key releases its draft; re-adding that key creates a fresh draft from the current item.
|
|
48
|
+
- Aliases, property paths, composed expressions, and indirect item props remain rejected.
|
|
49
|
+
- This does not add prop-to-state synchronization, array prop drafts, a VDOM, hydration, or a retained component tree.
|
|
50
|
+
- Static sibling routes remain complete HTML with zero JavaScript.
|
|
51
|
+
|
|
52
|
+
### Validation
|
|
53
|
+
|
|
54
|
+
- The Todo reducer fixture proves independent row drafts, retained draft and DOM identity through reorder, exact removal, and fresh remount initialization.
|
|
55
|
+
- A dedicated alias fixture remains fail-closed with a source-located diagnostic.
|
|
56
|
+
- RouteIR records the `list-item` initializer and capability planning emits the existing complex row-state path only where required.
|
|
57
|
+
- `npm run check`, `npm test`, and `npm run test:package` pass with all 224 tests and 173 generated pages.
|
|
58
|
+
|
|
59
|
+
### Upgrade
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npm install @kudzujs/core@^0.8.58
|
|
63
|
+
```
|
|
64
|
+
|
|
3
65
|
## 0.8.57 - Plain-object prop draft state
|
|
4
66
|
|
|
5
67
|
Kudzu 0.8.57 lets a specialized setter-callback child initialize independent local draft state directly from one parent state prop authored with a JSON-safe plain-object literal.
|
|
@@ -11,7 +11,7 @@ The top-level [`GOAL_A.md`](../../GOAL_A.md) and [`GOAL_B.md`](../../GOAL_B.md)
|
|
|
11
11
|
| C: state/resource model | Research only | Reduced fixtures expose a limitation |
|
|
12
12
|
| D: routing compatibility | Current behavior preserved | Revisit only with migration evidence and invariant review |
|
|
13
13
|
|
|
14
|
-
The active post-`0.8.
|
|
14
|
+
The active post-`0.8.59` implementation sequence is [`large-application-ai-native-roadmap.md`](./large-application-ai-native-roadmap.md). P0.12 validation, property-level object-state dependencies, direct three-boundary callback/ref ownership, direct primitive, plain-object, array-prop, and keyed-item draft state initialization, repeated direct leaf-handler callback use, direct child callback fan-out, collision-free and private Context action setters, package-neutral shared-state/action IR, browser-only package imports and private mutable refs in owned effects, route/layout CSS closure, structural per-route capability/chunk reporting, signature-keyed runtime families, incremental source and affected-route development builds, measured route-entry output optimization, and the plain TypeScript source-scale fast path are complete. ResourceIR remains research for cross-owner transports and subscriptions; range ownership, virtualization, and optimistic transactions still require independent fixtures. The plan orders compiler semantic generalization, large-application foundations, compatibility boundaries, AI tooling, and production validation without changing the invariants below.
|
|
15
15
|
|
|
16
16
|
## Required Invariants
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Current Compiler Architecture
|
|
2
2
|
|
|
3
|
-
This maps the current `0.8.
|
|
3
|
+
This maps the current `0.8.59` architecture, built on the completed `0.8.23` Goal A compiler foundation. File and function names are the stable references; line numbers are intentionally omitted because later work may still move code.
|
|
4
4
|
|
|
5
5
|
## Responsibility Map
|
|
6
6
|
|
|
@@ -379,7 +379,7 @@ function increment(value) { setCount(value + 1) }; increment(count)
|
|
|
379
379
|
After the relevant P0 foundations, investigate capabilities in this order:
|
|
380
380
|
|
|
381
381
|
1. Property-level derived dependencies over ordinary object state. **Completed in `0.8.40`:** direct property paths and top-level immutable primitive locals over object state reuse tagged DerivedIR, subscribe to the source signal, and compare selected values with `Object.is`; whole-object and dynamic dependencies remain rejected.
|
|
382
|
-
2. Multi-boundary component/prop/callback/ref/context dataflow. **Three-boundary callback/ref ownership completed in `0.8.43`; collision-free Context action-private state completed in `0.8.44`; action-only Provider setter exposure removed in `0.8.46`; direct primitive prop state initialization completed in `0.8.47`; repeated direct leaf-handler callback use completed in `0.8.48`; direct child callback fan-out completed in `0.8.49`; direct plain-object prop state initialization completed in `0.8.57`:** forwarding preserves parent SignalIR, Context action lowering uses compiler-owned aliases when consumer locals reuse Provider state/setter names, action-required setters may remain compiler-only when their state is publicly exposed, specialized children may seed local state from a direct parent signal authored with a serializable primitive
|
|
382
|
+
2. Multi-boundary component/prop/callback/ref/context dataflow. **Three-boundary callback/ref ownership completed in `0.8.43`; collision-free Context action-private state completed in `0.8.44`; action-only Provider setter exposure removed in `0.8.46`; direct primitive prop state initialization completed in `0.8.47`; repeated direct leaf-handler callback use completed in `0.8.48`; direct child callback fan-out completed in `0.8.49`; direct plain-object prop state initialization completed in `0.8.57`; direct keyed item draft initialization completed in `0.8.58`; direct array prop draft initialization completed in `0.8.59`:** forwarding preserves parent SignalIR, Context action lowering uses compiler-owned aliases when consumer locals reuse Provider state/setter names, action-required setters may remain compiler-only when their state is publicly exposed, specialized children may seed local state from a direct parent signal authored with a serializable primitive, plain-object, or array literal, keyed rows may seed object draft state from their direct item prop, and one callback may branch through multiple component `on*` props and intrinsic handlers. A direct first-boundary parent setter may also retain its authored matching `set*` prop name; additional forwarding remains restricted to `on*` props. The ClimateCompatibleGrowth-derived dropdown proves independent array drafts, no automatic mounted prop synchronization, explicit parent commit, and zero-JavaScript static sibling output. A fourth callback boundary, callback aliases/non-handler uses, fully hidden Context state, additional `set*` forwarding, keyed item aliases, property paths, and composed expressions remain fail-closed. Broader prop, callback, ref, and Context graphs remain migration-led work.
|
|
383
383
|
3. Package-neutral shared state/actions and migration of current Zustand internals. **Completed in `0.8.50`:** Zustand source normalization produces one generic shared-state adapter descriptor; selectors and handlers register JSON-safe SharedStateIR/SharedActionIR records, handler lowering consumes package-neutral actions, and existing RouteIR, layout ownership, same-turn updates, navigation persistence, and browser output remain unchanged. Redux/RTK and public adapter APIs remain unsupported.
|
|
384
384
|
4. Browser-only package imports in owned effect/resource modules. **Completed in `0.8.51` for effects:** direct package references in inline effect setup/cleanup callbacks use existing package import records and route-owned effect ESM bundling; build-time component modules and static siblings omit the package. Helper-indirect, render-time, dynamic-import, and ResourceIR package graphs remain unsupported.
|
|
385
385
|
5. ResourceIR from at least two independent WebSocket/SSE/SDK fixtures with the same semantics. **Completed in `0.8.52` without ResourceIR for private ownership:** the E2B terminal and route-owned WebSocket fixtures lower refs used exclusively by one inline effect to invocation-private closure objects, while existing effect ownership supplies replacement, cleanup, stale setter invalidation, navigation, and BFCache disposal. ResourceIR remains unapproved and now requires independent cross-owner transport/subscription fixtures that cannot fit this narrower model.
|
|
@@ -481,4 +481,4 @@ The first comparison is Kudzu versus React + Vite using the same agent, model, t
|
|
|
481
481
|
|
|
482
482
|
## Immediate Decision
|
|
483
483
|
|
|
484
|
-
PR 1 through PR 12, the `0.8.40` property-dependency slice, the `0.8.41` and `0.8.43` direct multi-boundary callback/ref slices, the `0.8.44` Context alias slice, the `0.8.46` action-only Provider setter slice, the `0.8.47` direct primitive
|
|
484
|
+
PR 1 through PR 12, the `0.8.40` property-dependency slice, the `0.8.41` and `0.8.43` direct multi-boundary callback/ref slices, the `0.8.44` Context alias slice, the `0.8.46` action-only Provider setter slice, the `0.8.47` direct primitive, `0.8.57` plain-object prop, `0.8.58` direct keyed item, and `0.8.59` direct array prop initializer slices, the `0.8.48` repeated direct leaf-handler callback slice, the `0.8.49` direct child callback fan-out slice, the `0.8.50` package-neutral shared-state/action slice, the `0.8.51` owned-effect package import slice, the `0.8.52` effect-private mutable-ref slice, the `0.8.53` route/layout CSS closure slice, the `0.8.54` structural per-route capability/chunk report, the `0.8.55` signature-keyed runtime families, item 7 incremental source and affected-route builds, and the `0.8.42` measured route-output optimization are complete. Continue migration-led semantic generalization; keep ResourceIR limited to independent fixtures, and do not add range ownership, virtualization, optimistic transactions, a public adapter/store API, or a router before evidence justifies them.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Planned Version Sequence
|
|
2
2
|
|
|
3
|
-
This is an execution sequence, not release history. `0.8.16` through `0.8.
|
|
3
|
+
This is an execution sequence, not release history. `0.8.16` through `0.8.59` are completed scopes represented by package/release records.
|
|
4
4
|
|
|
5
5
|
Keep each patch behavior-preserving and independently reviewable. If a boundary proves inseparable, revise this plan before combining releases; do not silently broaden a patch.
|
|
6
6
|
|
|
@@ -48,6 +48,8 @@ Keep each patch behavior-preserving and independently reviewable. If a boundary
|
|
|
48
48
|
| `0.8.55` | Emit deduplicated signature-keyed runtime families while preserving navigation-group singleton ownership. | Equal standalone signatures share files, different signatures isolate output, grouped routes share one union family, and static routes emit no runtime. |
|
|
49
49
|
| `0.8.56` | Recompile and rerender only source-affected routes during development. | A route-owned helper edit recompiles two of four modules, rerenders one of two pages, and emits byte-identical deploy output to a fresh full build. |
|
|
50
50
|
| `0.8.57` | Initialize specialized child draft state from one direct parent plain-object state prop. | A FIRE-derived editor preserves independent child draft state and parent commit behavior; arrays, aliases, property paths, and composed expressions remain rejected without runtime changes. |
|
|
51
|
+
| `0.8.58` | Initialize keyed row object draft state from the direct keyed item prop. | Todo reducer rows retain independent drafts and DOM identity across reorder, release state on removal, recreate drafts from the current item on remount, reject aliases, and preserve a static zero-JavaScript sibling. |
|
|
52
|
+
| `0.8.59` | Initialize specialized child draft state from one direct parent array-state prop and accept a direct matching `set*` setter prop. | A ClimateCompatibleGrowth-derived dropdown preserves independent array drafts, explicit parent commit, source naming, nearby diagnostics, and a static zero-JavaScript sibling without runtime changes. |
|
|
51
53
|
|
|
52
54
|
## Sequence Rules
|
|
53
55
|
|
package/framework/README.md
CHANGED
|
@@ -90,7 +90,7 @@ Rendered collection selectors compile immutable local aliases and inline `(item)
|
|
|
90
90
|
|
|
91
91
|
The reduced `useReducer` form reuses ordinary state slots and React's pure reducer contract. An optional inline, same-file, or relative-imported synchronous one-parameter initializer may derive a directly serializable literal only from its directly serializable initial argument; the compiler substitutes that argument and lowers the call to the ordinary two-argument ownership path. A direct dispatch in a compiled handler becomes a functional `set` whose reducer is bundled from a relative TypeScript module into that handler graph. Pure reducer-owned keyed lists reuse unchanged item identities for reorder, one removal, and append fast paths; ordinary `useState` lists retain full validation. One direct dispatch prop into a same-file or relative-imported synchronous component, including a direct keyed row, is specialized to intrinsic JSX at the call site, so its handler retains the parent reducer scope and no dispatch capture or child handler asset is emitted. A reducer row reads the latest item through the existing list scope and uses the same multiple serializable state, effect, condition, and object-ref specialization as other keyed rows. Relative TypeScript imports referenced inside that child handler receive collision-free call-site aliases and join the parent handler graph. One nested relative-imported intrinsic child may receive an inline or simple `const` callback containing dispatch; the compiler recursively substitutes that callback once and omits the nested child handler asset. Missing directly serializable literal defaults and direct intrinsic rest props in these reducer specializations are substituted at the same call site. Reducer-free routes and shared runtimes are unchanged; no reducer runtime or browser component instance exists.
|
|
92
92
|
|
|
93
|
-
A direct setter or inline/simple `const` setter callback may cross one same-file or relative-imported component boundary and two additional direct forwarding components before an intrinsic handler invokes it exactly once. Value adapters such as `event => onValueChange(event.currentTarget.value)` specialize into the parent setter graph instead of serializing a function.
|
|
93
|
+
A direct setter or inline/simple `const` setter callback may cross one same-file or relative-imported component boundary and two additional direct forwarding components before an intrinsic handler invokes it exactly once. Value adapters such as `event => onValueChange(event.currentTarget.value)` specialize into the parent setter graph instead of serializing a function. The first boundary may pass a direct parent setter through an `on*` or `set*` prop; each additional forwarding component must destructure and directly forward the callback once as an `on*` JSX prop. Fourth-boundary forwarding, additional `set*` forwarding, aliases, spreads, intermediate adapters, and repeated uses remain unsupported. Specialized children may own directly serializable `useState()` values or initialize state from one direct parent state prop authored with a serializable primitive, plain-object, or array literal; zero-argument `.toString()` remains primitive-only. Prop aliases, property paths, and composed initializers remain unsupported. Specialized children may also own `useId()` values, supported effects, and object refs initialized with `null`. Same-file and relative-imported presentation components recursively specialize away; nested hooks join the same generated owner only on unconditional or statically truthy paths. A parent-owned `null`-initialized object ref may follow the proven tree to the direct intrinsic root. These remain compiler-owned descriptors: conditional removal drops the handler with the element, deletes child state, resolves refs to `null`, and runs effect cleanup, while remount creates fresh ownership and dependency effects synchronize prop-derived state without retaining a component instance.
|
|
94
94
|
|
|
95
95
|
`kudzu.config` may opt one emitted shared-layout group into same-document navigation with legacy `navigation: { routes: ["/product", "/items/[id]"] }`, or multiple groups with `navigation: { groups: [{ routes: [...] }, { routes: [...] }] }`. The forms are mutually exclusive. Identities are globally unique emitted exact paths or `runtimeParams` patterns; each group uses one page-exported layout function identity. Runtime records securely match concrete pathnames under `base`, and their cache-safe parameter initializer runs before route DOM/effects mount on every transition. Each group receives a deterministic route-hashed asset specialized to only its records, pattern decoder, and effect/parameter lifecycle needs. Cross-group and ungrouped anchors remain native and are not prefetched; overlapping path domains across groups fail the build. Route effect entries export cache-safe layout and route mount functions: layout effects, including conditional/keyed DOM-owned effects, persist for the group session; route effects receive a fresh owner registry after each route insertion; and non-persisted page disposal cleans route before layout. Direct primitive state, runtime parameter, and keyed-item property dependencies and cleanup are supported. Fragment payloads and coordinated View Transitions are not implemented.
|
|
96
96
|
|
|
@@ -40,7 +40,7 @@ export function generateListRuntime(source, capabilityIR) {
|
|
|
40
40
|
if (lists.rowHooks && !lists.generalRowHooks) runtime = replaceSequenceRequired(replaceRequired(runtime, /\/\* general-row-hooks \*\/[\s\S]*?\/\* general-row-hooks-end \*\/\n/, "", "general row hooks"), [
|
|
41
41
|
["initializeGeneralRowHooks", "initializeRowStates", "general row initializer", true],
|
|
42
42
|
["if (__KUDZU_LIST_ROW_HOOKS__) for (let index = 0; index < roots.length; index++) initializeRowStates(descriptor, descriptor.keys[index], roots[index], nested?.owner)", "if (__KUDZU_LIST_ROW_HOOKS__ && descriptor.rowStates) for (let index = 0; index < roots.length; index++) initializeRowStates(descriptor, descriptor.keys[index])", "flat row initialization"],
|
|
43
|
-
["if (__KUDZU_LIST_ROW_HOOKS__) initializeRowStates(list.descriptor, key, node, list.owner)", "if (__KUDZU_LIST_ROW_HOOKS__ && list.descriptor.rowStates) initializeRowStates(list.descriptor, key, node)", "flat row add", true],
|
|
43
|
+
["if (__KUDZU_LIST_ROW_HOOKS__) initializeRowStates(list.descriptor, key, node, list.owner, item)", "if (__KUDZU_LIST_ROW_HOOKS__ && list.descriptor.rowStates) initializeRowStates(list.descriptor, key, node)", "flat row add", true],
|
|
44
44
|
["for (const node of registration.list.roots.values()) deleteRowStates(registration.list.descriptor, ownershipPaths.get(node))", "for (const token of registration.list.roots.keys()) deleteFlatRowStates(registration.list.descriptor, token)", "flat registration cleanup"],
|
|
45
45
|
["deleteRowStates(list.descriptor, ownershipPaths.get(node))", "deleteFlatRowStates(list.descriptor, token)", "flat row cleanup", true],
|
|
46
46
|
[" if (__KUDZU_LIST_ROW_HOOKS__) replaceRowIds(root, rowReplacements.get(root))\n", "", "row ID replacement"],
|
|
@@ -70,7 +70,7 @@ export function planRouteCapabilities(records, { navigationRouteCount = 0 } = {}
|
|
|
70
70
|
lists.effects ||= Boolean(list.effects)
|
|
71
71
|
lists.rowHooks ||= Boolean(list.rowStates?.length || list.rowRefs?.length)
|
|
72
72
|
lists.rowRefs ||= Boolean(list.rowRefs?.length)
|
|
73
|
-
lists.complexRowState ||= Boolean(list.rowStates?.some(state => state.initialValue !== null && typeof state.initialValue === "object"))
|
|
73
|
+
lists.complexRowState ||= Boolean(list.rowStates?.some(state => state.initializer === "list-item" || state.initialValue !== null && typeof state.initialValue === "object"))
|
|
74
74
|
lists.nested ||= Boolean(list.ownerField)
|
|
75
75
|
lists.selectors ||= Boolean(list.selector)
|
|
76
76
|
lists.calculated ||= Boolean(list.source)
|
|
@@ -155,7 +155,7 @@ function assertList(list, index, ids, stateIds, listIds, parentByChild) {
|
|
|
155
155
|
if (!isRecord(child) || !nonempty(child.id) || !nonempty(child.field) || typeof child.key !== "string" && child.key !== null || parentByChild.has(child.id)) throw new Error(`${label} has invalid or duplicate child ${JSON.stringify(child?.id)}`)
|
|
156
156
|
parentByChild.set(child.id, list.id)
|
|
157
157
|
}
|
|
158
|
-
for (const row of list.rowStates ?? []) if (!isRecord(row) || !rowTemplate(row.id) || !Object.hasOwn(row, "initialValue")) throw new Error(`${label} has invalid row state`)
|
|
158
|
+
for (const row of list.rowStates ?? []) if (!isRecord(row) || !rowTemplate(row.id) || !Object.hasOwn(row, "initialValue") || row.initializer !== undefined && row.initializer !== "list-item") throw new Error(`${label} has invalid row state`)
|
|
159
159
|
for (const row of [...(list.rowRefs ?? []), ...(list.rowConditions ?? [])]) if (!rowTemplate(row)) throw new Error(`${label} has invalid row ownership ID`)
|
|
160
160
|
if (list.seed && list.valueSeed || list.seed !== undefined && !validSeed(list.seed) || list.valueSeed !== undefined && !validSeed(list.valueSeed)) throw new Error(`${label} has invalid seed`)
|
|
161
161
|
}
|
|
@@ -1157,7 +1157,7 @@ function createKudzuTransformer({ semantic, handlerUrl, file, sourceFiles, sourc
|
|
|
1157
1157
|
for (const state of aggregate.ordinaryStates) setters.set(state.setter, state.state)
|
|
1158
1158
|
const stateOwners = new Map(parentStateOwners)
|
|
1159
1159
|
for (const state of aggregate.ordinaryStates) stateOwners.set(state.state, state.analysisReference)
|
|
1160
|
-
const callbackProps = jsxSetterCallbackProps(node, setters, functionsForNode(node), reducersForNode(node, reducersByFunction))
|
|
1160
|
+
const callbackProps = supportedSetterCallbackProps(component, jsxSetterCallbackProps(node, setters, functionsForNode(node), reducersForNode(node, reducersByFunction)))
|
|
1161
1161
|
const callbackSubstitutions = new Map()
|
|
1162
1162
|
if (callbackProps.length) {
|
|
1163
1163
|
if (!callbackDepth) fail(node, "Setter callbacks cannot cross more than three component boundaries")
|
|
@@ -1295,7 +1295,7 @@ function createKudzuTransformer({ semantic, handlerUrl, file, sourceFiles, sourc
|
|
|
1295
1295
|
}
|
|
1296
1296
|
for (const [name, component] of components) {
|
|
1297
1297
|
for (const call of jsxTagUses(sourceFile, name)) {
|
|
1298
|
-
const callbackProps = jsxSetterCallbackProps(call, settersByFunction.get(nearestFunction(call)) ?? new Map(), functionsForNode(call), reducersForNode(call, reducersByFunction))
|
|
1298
|
+
const callbackProps = supportedSetterCallbackProps(component.function, jsxSetterCallbackProps(call, settersByFunction.get(nearestFunction(call)) ?? new Map(), functionsForNode(call), reducersForNode(call, reducersByFunction)))
|
|
1299
1299
|
if (callbackProps.length) specializeSetterCallbacks(call, component.function, callbackProps, false)
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
@@ -1311,7 +1311,10 @@ function createKudzuTransformer({ semantic, handlerUrl, file, sourceFiles, sourc
|
|
|
1311
1311
|
} catch {
|
|
1312
1312
|
fail(callbackCalls[0].call, "Setter callback props require a component imported from a relative TypeScript module")
|
|
1313
1313
|
}
|
|
1314
|
-
for (const { call, callbackProps } of callbackCalls)
|
|
1314
|
+
for (const { call, callbackProps } of callbackCalls) {
|
|
1315
|
+
const supportedProps = supportedSetterCallbackProps(component, callbackProps)
|
|
1316
|
+
if (supportedProps.length) specializeSetterCallbacks(call, component, supportedProps, true)
|
|
1317
|
+
}
|
|
1315
1318
|
}
|
|
1316
1319
|
for (const [name, component] of components) {
|
|
1317
1320
|
const calls = jsxTagUses(sourceFile, name)
|
|
@@ -2114,14 +2117,26 @@ function jsxCallHasDirectStateProp(call, setters) {
|
|
|
2114
2117
|
function jsxSetterCallbackProps(call, setters, functions, reducers) {
|
|
2115
2118
|
const attributes = ts.isJsxElement(call) ? call.openingElement.attributes : call.attributes
|
|
2116
2119
|
return attributes.properties.flatMap(attribute => {
|
|
2117
|
-
if (!ts.isJsxAttribute(attribute) ||
|
|
2120
|
+
if (!ts.isJsxAttribute(attribute) || !attribute.initializer || !ts.isJsxExpression(attribute.initializer) || !attribute.initializer.expression) return []
|
|
2118
2121
|
const value = unwrapExpression(attribute.initializer.expression)
|
|
2119
|
-
if (ts.isIdentifier(value) && setters.has(value.text)) return [attribute.name.text]
|
|
2122
|
+
if (ts.isIdentifier(value) && setters.has(value.text) && (/^on[A-Z]/.test(attribute.name.text) || /^set[A-Z]/.test(attribute.name.text))) return [attribute.name.text]
|
|
2123
|
+
if (!/^on[A-Z]/.test(attribute.name.text)) return []
|
|
2120
2124
|
const callback = ts.isArrowFunction(value) || ts.isFunctionExpression(value) ? value : ts.isIdentifier(value) ? functions.get(value.text) : undefined
|
|
2121
2125
|
return callback && !nativeCaptureNames(callback, setters).size && !referencedReducerDispatches(callback.body, reducers, callback).size && referencedStateNames(callback.body, setters, callback).size ? [attribute.name.text] : []
|
|
2122
2126
|
})
|
|
2123
2127
|
}
|
|
2124
2128
|
|
|
2129
|
+
function componentHasDirectPropStateInitializer(component) {
|
|
2130
|
+
if (!component || component.parameters.length !== 1 || !ts.isObjectBindingPattern(component.parameters[0].name) || !ts.isBlock(component.body)) return false
|
|
2131
|
+
const props = new Set(component.parameters[0].name.elements.filter(element => !element.dotDotDotToken && ts.isIdentifier(element.name)).map(element => element.name.text))
|
|
2132
|
+
return component.body.statements.some(statement => ts.isVariableStatement(statement) && statement.declarationList.declarations.some(declaration => declaration.initializer && ts.isCallExpression(declaration.initializer) && ts.isIdentifier(declaration.initializer.expression) && declaration.initializer.expression.text === "useState" && declaration.initializer.arguments.length === 1 && ts.isIdentifier(declaration.initializer.arguments[0]) && props.has(declaration.initializer.arguments[0].text)))
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
function supportedSetterCallbackProps(component, props) {
|
|
2136
|
+
const acceptsSetProp = componentHasDirectPropStateInitializer(component)
|
|
2137
|
+
return props.filter(prop => /^on[A-Z]/.test(prop) || acceptsSetProp)
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2125
2140
|
function jsxCallHasDirectReducerProp(call, reducers) {
|
|
2126
2141
|
const attributes = ts.isJsxElement(call) ? call.openingElement.attributes : call.attributes
|
|
2127
2142
|
return attributes.properties.some(attribute => {
|
|
@@ -2182,6 +2197,7 @@ function validateKeyedList(parts, sourceFile, setters, rowStates, componentSpeci
|
|
|
2182
2197
|
const analysis = { values: [], conditions: [], nested: [] }
|
|
2183
2198
|
const root = parts.root
|
|
2184
2199
|
const item = parts.item
|
|
2200
|
+
for (const state of rowStates) if (state.initializer && state.initializer !== item) throw sourceNodeError(state.source.initializer, state.source.getSourceFile(), "Keyed row useState() item initializer must be the direct keyed item prop")
|
|
2185
2201
|
const nestedDiagnostic = "Nested keyed list collections must be a direct property of the parent item"
|
|
2186
2202
|
const validateElement = node => {
|
|
2187
2203
|
const tag = ts.isJsxElement(node) ? node.openingElement.tagName : node.tagName
|
|
@@ -2492,13 +2508,15 @@ function specializeComponentCall(call, component, sourceFile, factory, context,
|
|
|
2492
2508
|
if (declaration.initializer && ts.isCallExpression(declaration.initializer) && ts.isIdentifier(declaration.initializer.expression) && declaration.initializer.expression.text === "useState") {
|
|
2493
2509
|
const hookLabel = ordinaryHooks ? "Setter-callback component" : "Keyed row"
|
|
2494
2510
|
const initialArgument = declaration.initializer.arguments[0]
|
|
2495
|
-
const propReceiver =
|
|
2511
|
+
const propReceiver = initialArgument && (ordinaryHooks ? ts.isIdentifier(initialArgument) ? initialArgument : ts.isCallExpression(initialArgument) && initialArgument.arguments.length === 0 && !initialArgument.questionDotToken && ts.isPropertyAccessExpression(initialArgument.expression) && !initialArgument.expression.questionDotToken && initialArgument.expression.name.text === "toString" && ts.isIdentifier(initialArgument.expression.expression) ? initialArgument.expression.expression : undefined : ts.isIdentifier(initialArgument) ? initialArgument : undefined)
|
|
2496
2512
|
const substitutedProp = propReceiver ? substitutions.get(propReceiver.text) : undefined
|
|
2497
2513
|
const substitutedState = substitutedProp && ts.isIdentifier(unwrapExpression(substitutedProp)) ? unwrapExpression(substitutedProp).text : undefined
|
|
2498
2514
|
const directProp = ts.isIdentifier(initialArgument)
|
|
2499
2515
|
const parentInitializer = substitutedState ? directStateInitializer(call, substitutedState) : undefined
|
|
2500
|
-
const propInitializer = substitutedState && ordinaryStateNames.has(substitutedState) && parentInitializer && (isPrimitiveDefaultLiteral(parentInitializer) || directProp && ts.isObjectLiteralExpression(parentInitializer))
|
|
2501
|
-
|
|
2516
|
+
const propInitializer = ordinaryHooks && substitutedState && ordinaryStateNames.has(substitutedState) && parentInitializer && (isPrimitiveDefaultLiteral(parentInitializer) || directProp && (ts.isObjectLiteralExpression(parentInitializer) || ts.isArrayLiteralExpression(parentInitializer)))
|
|
2517
|
+
const rowItemProp = propReceiver && elements.find(element => !element.dotDotDotToken && ts.isIdentifier(element.name) && element.name.text === propReceiver.text)
|
|
2518
|
+
const rowItemInitializer = !ordinaryHooks && directProp && substitutedState && rowItemProp && directProps.has((rowItemProp.propertyName ?? rowItemProp.name).text)
|
|
2519
|
+
if (declaration.initializer.arguments.length !== 1 || !isSerializableStateLiteral(initialArgument) && !propInitializer && !rowItemInitializer) throw sourceNodeError(declaration.initializer, component.getSourceFile(), `${hookLabel} useState() must use one directly serializable primitive, plain object, or array initial value${ordinaryHooks ? " or direct state prop initialized with a primitive, plain object, or array; .toString() requires a primitive prop" : " or the direct keyed item prop"}; other dynamic initializers are not supported`)
|
|
2502
2520
|
if (!ts.isArrayBindingPattern(declaration.name) || declaration.name.elements.length !== 2 || declaration.name.elements.some(element => !element || !ts.isBindingElement(element) || !ts.isIdentifier(element.name) || element.initializer || element.dotDotDotToken)) throw sourceNodeError(declaration.name, component.getSourceFile(), `${hookLabel} useState() must use [state, setter] identifier destructuring`)
|
|
2503
2521
|
const suffix = `${Math.max(0, call.pos)}_${ordinaryHooks ? ordinaryStates.length : rowStates.length}`
|
|
2504
2522
|
const state = ordinaryHooks ? `__kComponentState${suffix}` : `__kRowState${suffix}`
|
|
@@ -2509,16 +2527,18 @@ function specializeComponentCall(call, component, sourceFile, factory, context,
|
|
|
2509
2527
|
factory.createBindingElement(undefined, undefined, factory.createIdentifier(state)),
|
|
2510
2528
|
factory.createBindingElement(undefined, undefined, factory.createIdentifier(setter))
|
|
2511
2529
|
])
|
|
2512
|
-
const initialValue =
|
|
2530
|
+
const initialValue = rowItemInitializer
|
|
2531
|
+
? cloneAst(substitutedProp, factory, context)
|
|
2532
|
+
: propInitializer
|
|
2513
2533
|
? ts.isIdentifier(initialArgument)
|
|
2514
2534
|
? factory.createPropertyAccessExpression(cloneAst(substitutedProp, factory, context), "value")
|
|
2515
2535
|
: substituteClone(initialArgument, substitutions, factory, context)
|
|
2516
2536
|
: cloneAst(initialArgument, factory, context)
|
|
2517
2537
|
synthesizeTree(initialValue)
|
|
2518
|
-
const initializer = factory.createCallExpression(factory.createIdentifier(ordinaryHooks ? "__kComponentUseState" : "__kRowUseState"), undefined, [initialValue])
|
|
2538
|
+
const initializer = factory.createCallExpression(factory.createIdentifier(ordinaryHooks ? "__kComponentUseState" : "__kRowUseState"), undefined, rowItemInitializer ? [initialValue, factory.createStringLiteral(state), factory.createStringLiteral("list-item")] : [initialValue])
|
|
2519
2539
|
hookDeclarations.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(binding, undefined, undefined, initializer)], ts.NodeFlags.Const)))
|
|
2520
2540
|
if (ordinaryHooks) ordinaryStates.push({ state, setter, source: declaration })
|
|
2521
|
-
else rowStates.push({ state, setter, source: declaration })
|
|
2541
|
+
else rowStates.push({ state, setter, source: declaration, ...(rowItemInitializer ? { initializer: substitutedState } : {}) })
|
|
2522
2542
|
continue
|
|
2523
2543
|
}
|
|
2524
2544
|
if (declaration.initializer && ts.isCallExpression(declaration.initializer) && ts.isIdentifier(declaration.initializer.expression) && declaration.initializer.expression.text === "useRef") {
|
package/framework/core.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export type ListDescriptor = {
|
|
|
125
125
|
expressions?: true
|
|
126
126
|
expressionAttributes?: true
|
|
127
127
|
expressionStates?: string[]
|
|
128
|
-
rowStates?: Array<{ id: string; initialValue: unknown }>
|
|
128
|
+
rowStates?: Array<{ id: string; initialValue: unknown; initializer?: "list-item" }>
|
|
129
129
|
rowConditions?: string[]
|
|
130
130
|
rowRefs?: string[]
|
|
131
131
|
fastRelease?: true
|
package/framework/core.mjs
CHANGED
|
@@ -53,12 +53,12 @@ export function useId() {
|
|
|
53
53
|
return `k-${nextRenderId("i")}`
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function useState(initialValue, name) {
|
|
56
|
+
export function useState(initialValue, name, initializer) {
|
|
57
57
|
if (!renderContext) {
|
|
58
58
|
throw new Error("useState() can only run while rendering a Kudzu component")
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const id = renderContext.listRoot || renderContext.listRowRoot ? nextRowRenderId("s", initialValue) : nextRenderId("s")
|
|
61
|
+
const id = renderContext.listRoot || renderContext.listRowRoot ? nextRowRenderId("s", initialValue, initializer) : nextRenderId("s")
|
|
62
62
|
const signal = createSignal(id, initialValue)
|
|
63
63
|
|
|
64
64
|
const setter = () => {
|
|
@@ -1005,7 +1005,7 @@ function nextRenderId(kind) {
|
|
|
1005
1005
|
return `${kind}${renderContext[counters[kind]]++}`
|
|
1006
1006
|
}
|
|
1007
1007
|
|
|
1008
|
-
function nextRowRenderId(kind, initialValue) {
|
|
1008
|
+
function nextRowRenderId(kind, initialValue, initializer) {
|
|
1009
1009
|
const root = renderContext.listRoot ?? renderContext.listRowRoot
|
|
1010
1010
|
const index = root.rowIndexes[kind]++
|
|
1011
1011
|
const entries = kind === "s" ? renderContext.listRowStates : kind === "r" ? renderContext.listRowRefs : renderContext.listRowConditions
|
|
@@ -1013,7 +1013,7 @@ function nextRowRenderId(kind, initialValue) {
|
|
|
1013
1013
|
const entry = entries[index]
|
|
1014
1014
|
if (entry) return entry.id
|
|
1015
1015
|
const id = `${nextRenderId(kind)}:$k`
|
|
1016
|
-
entries[index] = kind === "s" ? { id, initialValue } : { id }
|
|
1016
|
+
entries[index] = kind === "s" ? { id, initialValue, ...(initializer ? { initializer } : {}) } : { id }
|
|
1017
1017
|
return id
|
|
1018
1018
|
}
|
|
1019
1019
|
const entry = entries[index]
|
|
@@ -237,7 +237,7 @@ function updateList(list) {
|
|
|
237
237
|
if (!node) throw new Error("Keyed list template has no root element")
|
|
238
238
|
node.removeAttribute("data-k-list-root")
|
|
239
239
|
if (__KUDZU_NESTED_LISTS__ && list.childPrototypes) childPrototypes.set(node, list.childPrototypes)
|
|
240
|
-
if (__KUDZU_LIST_ROW_HOOKS__) initializeGeneralRowHooks(list.descriptor, key, node, list.owner)
|
|
240
|
+
if (__KUDZU_LIST_ROW_HOOKS__) initializeGeneralRowHooks(list.descriptor, key, node, list.owner, item)
|
|
241
241
|
if (staticRoot) listItems.set(node, item)
|
|
242
242
|
else if (list.parts.directFill) {
|
|
243
243
|
listItems.set(node, item)
|
|
@@ -401,7 +401,7 @@ function updateStableList(list, items) {
|
|
|
401
401
|
if (node?.dataset.kListRoot !== list.descriptor.id) node = undefined
|
|
402
402
|
if (!node) throw new Error("Keyed list template has no root element")
|
|
403
403
|
node.removeAttribute("data-k-list-root")
|
|
404
|
-
if (__KUDZU_LIST_ROW_HOOKS__) initializeGeneralRowHooks(list.descriptor, key, node, list.owner)
|
|
404
|
+
if (__KUDZU_LIST_ROW_HOOKS__) initializeGeneralRowHooks(list.descriptor, key, node, list.owner, item)
|
|
405
405
|
if (list.parts.directFill) fillStructuralListParts(list.parts, node, item)
|
|
406
406
|
else fillListItem(node, item, list.descriptor.nested, index, mapListItemParts(list.parts, node, list.descriptor.nested))
|
|
407
407
|
fragment.append(node)
|
|
@@ -578,7 +578,7 @@ function addListRoot(list, { item, index = list.roots.size, key, token, value })
|
|
|
578
578
|
if (!node) throw new Error("Keyed list template has no root element")
|
|
579
579
|
node.removeAttribute("data-k-list-root")
|
|
580
580
|
if (__KUDZU_NESTED_LISTS__ && list.childPrototypes) childPrototypes.set(node, list.childPrototypes)
|
|
581
|
-
if (__KUDZU_LIST_ROW_HOOKS__) initializeGeneralRowHooks(list.descriptor, key, node, list.owner)
|
|
581
|
+
if (__KUDZU_LIST_ROW_HOOKS__) initializeGeneralRowHooks(list.descriptor, key, node, list.owner, item)
|
|
582
582
|
mapListItemParts(list.parts, node, list.descriptor.nested)
|
|
583
583
|
fillListItem(node, item, list.descriptor.nested, index)
|
|
584
584
|
const parent = list.container ?? list.start.parentNode
|
|
@@ -1046,7 +1046,7 @@ function keyToken(key) {
|
|
|
1046
1046
|
}
|
|
1047
1047
|
|
|
1048
1048
|
/* general-row-hooks */
|
|
1049
|
-
function initializeGeneralRowHooks(descriptor, key, root, owner) {
|
|
1049
|
+
function initializeGeneralRowHooks(descriptor, key, root, owner, item) {
|
|
1050
1050
|
const token = keyToken(key)
|
|
1051
1051
|
const path = [...(ownershipPaths.get(owner) ?? []), `${descriptor.id}=${token}`]
|
|
1052
1052
|
ownershipPaths.set(root, path)
|
|
@@ -1055,7 +1055,7 @@ function initializeGeneralRowHooks(descriptor, key, root, owner) {
|
|
|
1055
1055
|
const replacements = new Map()
|
|
1056
1056
|
for (const state of descriptor.rowStates ?? []) {
|
|
1057
1057
|
const id = rowStateId(state.id, statePath)
|
|
1058
|
-
if (!browserState.has(id)) browserState.set(id, __KUDZU_COMPLEX_LIST_ROW_STATE__ && state.initialValue !== null && typeof state.initialValue === "object" ? structuredClone(state.initialValue) : state.initialValue)
|
|
1058
|
+
if (!browserState.has(id)) browserState.set(id, state.initializer === "list-item" ? structuredClone(item) : __KUDZU_COMPLEX_LIST_ROW_STATE__ && state.initialValue !== null && typeof state.initialValue === "object" ? structuredClone(state.initialValue) : state.initialValue)
|
|
1059
1059
|
replacements.set(state.id, id)
|
|
1060
1060
|
}
|
|
1061
1061
|
if (__KUDZU_LIST_ROW_REFS__) for (const ref of descriptor.rowRefs ?? []) replacements.set(ref, rowStateId(ref, statePath))
|