@solidjs/signals 2.0.0-rc.0 → 2.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/dev.js +2622 -2438
  3. package/dist/node.cjs +3770 -3571
  4. package/dist/prod/core/async.js +186 -132
  5. package/dist/prod/core/core.js +118 -107
  6. package/dist/prod/core/effect.js +13 -13
  7. package/dist/prod/core/external.js +1 -1
  8. package/dist/prod/core/graph.js +8 -8
  9. package/dist/prod/core/heap.js +24 -24
  10. package/dist/prod/core/lanes.js +3 -3
  11. package/dist/prod/core/optimistic.js +38 -21
  12. package/dist/prod/core/owner.js +21 -21
  13. package/dist/prod/core/scheduler.js +55 -47
  14. package/dist/prod/core/verdict.js +40 -40
  15. package/dist/prod/index.js +7 -7
  16. package/dist/prod/map.js +81 -79
  17. package/dist/prod/signals.js +20 -1
  18. package/dist/prod/store/index.js +36 -0
  19. package/dist/prod/store/next/optimistic.js +377 -0
  20. package/dist/prod/store/next/projection.js +172 -0
  21. package/dist/prod/store/next/reconcile.js +327 -0
  22. package/dist/prod/store/next/store.js +1232 -0
  23. package/dist/prod/store/next/target.js +20 -0
  24. package/dist/prod/store/store.js +123 -879
  25. package/dist/prod/store/utils.js +59 -186
  26. package/dist/types/core/core.d.ts +8 -0
  27. package/dist/types/core/dev.d.ts +1 -1
  28. package/dist/types/core/scheduler.d.ts +4 -2
  29. package/dist/types/signals.d.ts +19 -0
  30. package/dist/types/store/index.d.ts +15 -5
  31. package/dist/types/store/next/optimistic.d.ts +20 -0
  32. package/dist/types/store/next/projection.d.ts +24 -0
  33. package/dist/types/store/next/reconcile.d.ts +3 -0
  34. package/dist/types/store/next/store.d.ts +71 -0
  35. package/dist/types/store/next/target.d.ts +99 -0
  36. package/dist/types/store/store.d.ts +26 -101
  37. package/dist/types/store/utils.d.ts +0 -40
  38. package/dist/types-cjs/core/core.d.cts +8 -0
  39. package/dist/types-cjs/core/dev.d.cts +1 -1
  40. package/dist/types-cjs/core/scheduler.d.cts +4 -2
  41. package/dist/types-cjs/signals.d.cts +19 -0
  42. package/dist/types-cjs/store/index.d.cts +15 -5
  43. package/dist/types-cjs/store/next/optimistic.d.cts +20 -0
  44. package/dist/types-cjs/store/next/projection.d.cts +24 -0
  45. package/dist/types-cjs/store/next/reconcile.d.cts +3 -0
  46. package/dist/types-cjs/store/next/store.d.cts +71 -0
  47. package/dist/types-cjs/store/next/target.d.cts +99 -0
  48. package/dist/types-cjs/store/store.d.cts +26 -101
  49. package/dist/types-cjs/store/utils.d.cts +0 -40
  50. package/package.json +2 -1
  51. package/dist/prod/store/optimistic.js +0 -217
  52. package/dist/prod/store/projection.js +0 -231
  53. package/dist/prod/store/reconcile.js +0 -707
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Store rewrite — target & ownership (INTERNALS-STORE-STATE.md §1, §5b).
3
+ *
4
+ * The proxy wraps this internal target, never the raw (proxy-target
5
+ * indirection, decision 2026-08-16d). `b` is the single committed home; `pb`
6
+ * is the per-target pending backing (RUL-1's pending home): the CoW clone
7
+ * created at first draft write, mutated natively by the draft, folded into
8
+ * `b` at flush commit. Adoption (setter replacement / reconcile) parks an
9
+ * UNOWNED incoming object in `pb` — fold swaps it in and ownership resets.
10
+ *
11
+ * Creation budget (§5b): one minimal target + one proxy + one storeLookup
12
+ * entry per read-through object; zero layer slots; nodes, has-nodes, and the
13
+ * key-set node are lazy, materialized only by subscription.
14
+ */
15
+ import type { Computed, Signal } from "../../core/types.js";
16
+ /** Projection family (§7b): children wrap into the family's own map (writes
17
+ * land in the projection, never the source family), and every node created
18
+ * under the family carries the projection computed as its firewall. */
19
+ export interface StoreNextFamily {
20
+ /** Optimistic family: nodes are born armed (`_overrideValue` slot) so every
21
+ * write rides the core optimistic engine — lanes, per-transaction ownership,
22
+ * reverts all core-native (§3, RUL-3). */
23
+ opt?: boolean;
24
+ /** Root proxy (registered with the scheduler's optimistic-store set for the
25
+ * transitionBlocked store-half, #2951). */
26
+ px?: any;
27
+ /** Targets currently carrying active node overrides (landing-consumption
28
+ * walk, RUL-2: visible landed truth replaces optimism). */
29
+ overlaid?: Set<any>;
30
+ map: WeakMap<object, StoreNextTarget>;
31
+ /** The projection computed — assigned after creation (accessor pattern). */
32
+ node: Computed<any> | null;
33
+ shallow?: boolean;
34
+ }
35
+ export interface StoreNextTarget {
36
+ /** Committed backing: source object (shared) or owned clone. */
37
+ v: Record<PropertyKey, any>;
38
+ /** Pending backing for the current flush (null when settled). */
39
+ pb: Record<PropertyKey, any> | null;
40
+ /** cached: committed backing is another store's proxy (§7b chained). */
41
+ ch: boolean;
42
+ /** live value-node count (deleted-key sweep fast-out in the fused walk). */
43
+ nc: number;
44
+ /** Lazy per-property subscription nodes (real core signals). */
45
+ n: Record<PropertyKey, Signal<any>> | null;
46
+ /** Lazy per-key presence nodes (`in` tracks presence, not value — R13). */
47
+ h: Record<PropertyKey, Signal<boolean>> | null;
48
+ /** Lazy key-set node: membership/iteration/$TRACK subscriptions (§6). */
49
+ k: Signal<number> | null;
50
+ /** Lazy deep-witness node: `deep()` subscribes ONE node per record instead
51
+ * of one per path; write paths bump it only when it exists. Separate from
52
+ * `k` so $TRACK/mapArray never rerun on leaf value changes (R9). */
53
+ dk: Signal<number> | null;
54
+ /** Parent target (path copying walks this at commit). */
55
+ u: StoreNextTarget | null;
56
+ /** Property key of this target in the parent's backing. */
57
+ pk: PropertyKey | null;
58
+ /** The proxy for this target (stable outward identity). */
59
+ px: any;
60
+ /** Sticky descendants flag (§6d). */
61
+ d: boolean;
62
+ /** Sticky accessors-seen flag: an own accessor property was observed on
63
+ * this target (first-read scan, defineProperty, or clone scan). Gates the
64
+ * fold diff's descriptor-safe path and the get trap's descriptor path. */
65
+ a: boolean;
66
+ /** Accessor scan performed (scan-once on first trap read; adopted data is
67
+ * not rescanned — legacy-parity behavior). */
68
+ sc: boolean;
69
+ /** Backing was swapped by adoption this batch (fold diff-notifies it). */
70
+ adopted: boolean;
71
+ /** Projection family, null for plain stores (§7b). */
72
+ fam: StoreNextFamily | null;
73
+ /** Shallow store root (values served raw). */
74
+ s: boolean;
75
+ }
76
+ /**
77
+ * Ownership (first cut, decision 2026-08-16d): one WeakSet of store-owned
78
+ * backings serving both the production identity-skip guard and the __TEST__
79
+ * no-mutation oracle.
80
+ */
81
+ export declare const ownedRaw: WeakSet<object>;
82
+ /** raw → target. The only raw-keyed lookup; boundary mechanism (O8). */
83
+ export declare const storeNextLookup: WeakMap<object, StoreNextTarget>;
84
+ /** __TEST__ oracle: every object ingested from a user (never mutate). */
85
+ export declare const ingestedRaw: WeakSet<object> | null;
86
+ export declare function devAssertNeverUserMutation(target: object): void;
87
+ /** Injection table for optimistic-only store machinery (next/optimistic.ts).
88
+ * Every call site is gated on `fam?.opt`, and optimistic families can only
89
+ * be created by createOptimisticStore — whose install populates this — so
90
+ * the non-null assertions at the sites hold by construction. Keeping the
91
+ * implementations out of next/store.ts lets plain-store bundles tree-shake
92
+ * the optimistic channel entirely. */
93
+ export interface OptStoreHooks {
94
+ notifyOptimisticWrites(t: any, pb: Record<PropertyKey, any>): void;
95
+ optimisticView(t: any, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
96
+ applyTentative(t: any, incoming: any, keyFn: ((item: any) => any) | null): void;
97
+ }
98
+ export declare let optHooks: OptStoreHooks | null;
99
+ export declare function setOptHooks(h: OptStoreHooks): void;
@@ -1,5 +1,5 @@
1
- import { STORE_SNAPSHOT_PROPS, type Computed, type Refreshable, type Signal } from "../core/index.js";
2
- import { type Transition } from "../core/scheduler.js";
1
+ import { type Signal } from "../core/index.js";
2
+ import type { Refreshable } from "../core/index.js";
3
3
  /** A read-only view of a store's value as seen by consumers. Mutate it via the paired `StoreSetter`. */
4
4
  export type Store<T> = Readonly<T>;
5
5
  /**
@@ -58,21 +58,14 @@ type DataNodes = Record<PropertyKey, DataNode>;
58
58
  * @internal
59
59
  */
60
60
  export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
61
- export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p", STORE_OPTIMISTIC_OWNERS = "t", STORE_PARENT = "u", STORE_DESC = "d", STORE_SHALLOW = "s";
61
+ export declare const STORE_VALUE = "v", STORE_NODE = "n", STORE_HAS = "h", STORE_PARENT = "u", STORE_DESC = "d", STORE_SHALLOW = "s";
62
+ /** Structural view of a store target as shared machinery sees it (the real
63
+ * shape is `StoreNextTarget` in ./next/target.ts). */
62
64
  export type StoreNode = {
63
65
  [$PROXY]: any;
64
66
  [STORE_VALUE]: Record<PropertyKey, any>;
65
- [STORE_OVERRIDE]?: Record<PropertyKey, any>;
66
- [STORE_OPTIMISTIC_OVERRIDE]?: Record<PropertyKey, any>;
67
- [STORE_OPTIMISTIC_OWNERS]?: Record<PropertyKey, Transition | null>;
68
67
  [STORE_NODE]?: DataNodes;
69
68
  [STORE_HAS]?: DataNodes;
70
- [STORE_CUSTOM_PROTO]?: boolean;
71
- [STORE_WRAP]?: (value: any, target?: StoreNode) => any;
72
- [STORE_LOOKUP]?: WeakMap<any, any>;
73
- [STORE_FIREWALL]?: Computed<any>;
74
- [STORE_OPTIMISTIC]?: boolean;
75
- [STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
76
69
  [STORE_PARENT]?: StoreNode;
77
70
  [STORE_SHALLOW]?: boolean;
78
71
  [STORE_DESC]?: boolean;
@@ -82,10 +75,6 @@ export declare namespace SolidStore {
82
75
  }
83
76
  }
84
77
  export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
85
- export declare function createStoreProxy<T extends object>(value: T, traps?: ProxyHandler<StoreNode>, extend?: (target: StoreNode) => void): any;
86
- export declare const storeLookup: WeakMap<WeakKey, any>;
87
- export declare const symbolKeyedRecords: WeakSet<object>;
88
- export declare function lookupTarget(value: any, lookup?: WeakMap<any, any>): StoreNode | undefined;
89
78
  /**
90
79
  * Marks a value as raw: no store will ever wrap it — every store presents it
91
80
  * as-is, tracked by reference at whatever slot holds it and updated by
@@ -96,25 +85,33 @@ export declare function lookupTarget(value: any, lookup?: WeakMap<any, any>): St
96
85
  export declare let rawValuesUsed: boolean;
97
86
  export declare function isRawValue(value: any): boolean;
98
87
  export declare function markRaw<T>(value: T): T;
88
+ export declare function markRawOne(v: any): void;
99
89
  export declare function markRawIngest(container: any): void;
100
- export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
101
- export declare function wrapShallow<T extends Record<PropertyKey, any>>(value: T): T;
102
90
  export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
103
91
  export declare function setWriteOverride(value: boolean): void;
92
+ export declare function getWriteOverride(): boolean;
104
93
  export declare function ownEnumerableKeys(o: object): (string | symbol)[];
105
94
  /**
106
- * Single chokepoint for the store's layered value resolution: returns the
107
- * override layer (optimistic first, then regular) that shadows `property`, or
108
- * `undefined` when the base `STORE_VALUE` is authoritative. Every trap must
109
- * resolve through this — hand-inlining the layer order is how the optimistic
110
- * layer gets missed (#2850).
95
+ * Scope inheritance for late-created nodes: every live mark whose identity
96
+ * scope contains the owning record's raw — and, for keyed marks, whose key
97
+ * is this property — gets counted on the new node. Inherited marks live
98
+ * exactly as long as the scope's carrier — the release hook below drops
99
+ * them with the entry.
111
100
  */
112
- export declare function getOverlayLayer(target: StoreNode, property: PropertyKey): Record<PropertyKey, any> | undefined;
113
- /**
114
- * The value a store leaf's backing signal currently shows to readers: active
115
- * override, else held pending value, else committed value.
116
- */
117
- export declare function visibleNodeValue(node: DataNode): any;
101
+ export declare function inheritAffectsMarks(node: DataNode, raw: object, property: PropertyKey): void;
102
+ /** Next-store node factory for affects carriers/slots: injected by the
103
+ * rewrite module (next targets alias the legacy field names, so everything
104
+ * here EXCEPT node creation works on them structurally). */
105
+ export declare let nextAffectsNodeResolver: ((target: any, key: PropertyKey) => DataNode) | null;
106
+ export declare function setNextAffectsNodeResolver(fn: (target: any, key: PropertyKey) => DataNode): void;
107
+ /** Next-store optimistic view for the declaration walk (optimistic rows
108
+ * pushed before the declaration are in motion too — legacy reads its write
109
+ * overlays; next composes armed-node overrides). */
110
+ export declare let nextOptimisticViewResolver: ((target: any, raw: any) => any) | null;
111
+ export declare function setNextOptimisticViewResolver(fn: (target: any, raw: any) => any): void;
112
+ /** @internal birth inheritance for nodes created inside a live mark window —
113
+ * exported for the rewrite's node factories. */
114
+ export declare function affectsScopesLive(): boolean;
118
115
  /**
119
116
  * Witness live mark coverage of a record into the active isPending() probe.
120
117
  * Tracked reads don't need this — they go through real signal nodes, which
@@ -138,76 +135,4 @@ export declare function witnessAffectsMark(target: StoreNode, property?: Propert
138
135
  * @internal
139
136
  */
140
137
  export declare function getStoreAffectsNodes(target: StoreNode, key?: PropertyKey): DataNode[];
141
- export declare function trackSelf(target: StoreNode, symbol?: symbol): void;
142
- export declare function notifySelf(target: StoreNode): void;
143
- /**
144
- * The write overlay a walk must read through: optimistic writes shadow
145
- * regular pending writes, the same resolution order as every proxy trap and
146
- * `reconcile` (#2850). Merging allocates only in the rare both-present case
147
- * (a derived optimistic store with an in-flight projection commit).
148
- */
149
- export declare function mergedOverlay(target: StoreNode): Record<PropertyKey, any> | undefined;
150
- export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
151
- export declare function getStoreKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): PropertyKey[];
152
- export declare function getStoreSymbols(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): symbol[];
153
- export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
154
- export declare const storeTraps: ProxyHandler<StoreNode>;
155
- export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
156
- /**
157
- * Creates a deeply-reactive store backed by a Proxy. Reads track each property
158
- * accessed; only the parts that change trigger updates.
159
- *
160
- * Store properties hold **plain values**, not accessors. The proxy already
161
- * tracks reads per-property — wrapping a value in `() => state.foo` produces
162
- * a getter that *won't* track when called, which looks like a reactivity bug
163
- * but is just a category error. If you have a signal-shaped piece of state,
164
- * make it a property of the store (`{ foo: 1 }`) rather than nesting an
165
- * accessor inside (`{ foo: () => signal() }`).
166
- *
167
- * The setter takes a **draft-mutating** function — mutate the draft in place
168
- * (canonical). The callback may also return a new value: arrays are replaced
169
- * by index (length adjusted), objects are shallow-diffed at the top level
170
- * (keys present in the returned value are written, missing keys deleted). Use
171
- * the return form for shapes where mutation is awkward — most commonly
172
- * removing items via `filter`. The setter does **not** do keyed reconciliation;
173
- * for that, use the derived/projection form (or `createProjection`).
174
- *
175
- * - Plain form: `createStore(initialValue)` — wraps a value in a reactive
176
- * proxy.
177
- * - Derived form: `createStore(fn, seed, options?)` — a *projection store*
178
- * whose contents are computed by `fn(draft)`. `fn` may be sync, async, or
179
- * an `AsyncIterable`; the projection's result reconciles against the
180
- * existing store by `options.key` (default `"id"`) for stable identity.
181
- *
182
- * @example
183
- * ```ts
184
- * const [state, setState] = createStore({
185
- * user: { name: "Ada", age: 36 },
186
- * todos: [] as { id: string; text: string; done: boolean }[]
187
- * });
188
- *
189
- * // Canonical: mutate the draft in place.
190
- * setState(s => { s.user.age = 37; });
191
- * setState(s => { s.todos.push({ id: "1", text: "x", done: false }); });
192
- *
193
- * // Return form: reach for it when mutation is awkward.
194
- * setState(s => s.todos.filter(t => !t.done)); // remove items
195
- * setState(s => ({ ...s, user: { name: "Grace", age: 85 } })); // shallow replace
196
- * ```
197
- *
198
- * @example
199
- * ```ts
200
- * // Derived store — auto-fetches & reconciles by `id`.
201
- * const [users] = createStore(
202
- * async () => fetch("/users").then(r => r.json()),
203
- * [] as User[]
204
- * );
205
- * ```
206
- *
207
- * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
208
- */
209
- export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
210
- shallow?: boolean;
211
- }): StoreReturn<T>;
212
- export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): ProjectionStoreReturn<T>;
213
138
  export {};
@@ -1,43 +1,3 @@
1
- /**
2
- * Returns a plain (non-proxy, non-reactive) deep copy of a store value.
3
- * Reading via `snapshot` does **not** subscribe to changes — use this when you
4
- * need to hand a stable plain object to non-reactive code (logging,
5
- * serialization, structured-clone, network payloads, etc.).
6
- *
7
- * Returns the original object identity for any sub-tree that wasn't modified
8
- * relative to the proxy's underlying source.
9
- *
10
- * @example
11
- * ```ts
12
- * const [state] = createStore({ user: { name: "Ada" }, todos: [] });
13
- *
14
- * console.log(JSON.stringify(snapshot(state))); // safe, non-reactive copy
15
- * ```
16
- */
17
- export declare function snapshot<T>(item: T): T;
18
- export declare function snapshot<T>(item: T, map?: Map<unknown, unknown>, lookup?: WeakMap<any, any>): T;
19
- /**
20
- * Returns a plain (non-proxy) deep copy **and** subscribes the current
21
- * tracking scope to every nested change in the source store. Any write
22
- * anywhere in the subtree invalidates the consumer.
23
- *
24
- * Use this when you need plain data inside a reactive scope and want to
25
- * react to deep mutations (e.g. passing a snapshot to `reconcile()` or to a
26
- * memo that should rerun on any nested change). For most read paths, prefer
27
- * direct property access — Solid stores already track per-property reads
28
- * with no `deep()` wrapper needed.
29
- *
30
- * @example
31
- * ```ts
32
- * const [state] = createStore({ a: { b: { c: 1 } } });
33
- *
34
- * createEffect(
35
- * () => deep(state), // reruns on any nested change
36
- * plain => sendToWorker(plain) // worker gets a non-proxy copy
37
- * );
38
- * ```
39
- */
40
- export declare function deep<T extends object>(store: T): T;
41
1
  type DistributeOverride<T, F> = T extends undefined ? F : T;
42
2
  type Override<T, U> = T extends any ? U extends any ? {
43
3
  [K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
@@ -88,6 +88,14 @@ export declare const READ_SLOW: unique symbol;
88
88
  */
89
89
  export declare function readNodeFast<T>(el: Signal<T>): T | typeof READ_SLOW;
90
90
  export declare function read<T>(el: Signal<T> | Computed<T>): T;
91
+ /**
92
+ * Store-rewrite setter guard: the rewrite parks writes in a pending backing
93
+ * (no setSignal at write time), so the owned-scope write protection must
94
+ * fire at the setter entry instead. Mirrors setSignal's guard condition
95
+ * minus the node-specific exemptions (ownedWrite/firewall), which don't
96
+ * apply to plain store setters.
97
+ */
98
+ export declare function devGuardStoreSetterWrite(): void;
91
99
  export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
92
100
  /**
93
101
  * Suppresses automatic recomputation of `el` until the scheduler drains. Used
@@ -6,7 +6,7 @@ export interface DevHooks {
6
6
  onStoreNodeUpdate?: (state: any, property: PropertyKey, value: any, prev: any) => void;
7
7
  }
8
8
  export type DiagnosticSeverity = "warn" | "error";
9
- export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "REACTIVE_WRITE_IN_OWNED_SCOPE" | "ACTION_CALLED_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "SETTLED_CLEANUP_UNOWNED" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "INVALID_REFRESH_TARGET" | "INVALID_AFFECTS_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC" | "REACTIVITY_HALTED" | "INVARIANT_VIOLATION";
9
+ export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "REACTIVE_WRITE_IN_OWNED_SCOPE" | "ACTION_CALLED_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "SETTLED_CLEANUP_UNOWNED" | "FLUSH_IN_EFFECT_CALLBACK" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "INVALID_REFRESH_TARGET" | "INVALID_AFFECTS_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC" | "REACTIVITY_HALTED" | "INVARIANT_VIOLATION";
10
10
  export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner" | "error";
11
11
  export interface DiagnosticEvent {
12
12
  sequence: number;
@@ -9,7 +9,6 @@ export declare let clock: number;
9
9
  export declare let activeTransition: Transition | null;
10
10
  export declare let projectionWriteActive: boolean;
11
11
  export declare let _hitUnhandledAsync: boolean;
12
- export declare function registerTransientStoreNode(node: Signal<any>): void;
13
12
  export declare function resetUnhandledAsync(): void;
14
13
  /**
15
14
  * Toggles the dev-mode "must be inside a `<Loading>` boundary" enforcement
@@ -22,6 +21,7 @@ export declare function resetUnhandledAsync(): void;
22
21
  export declare function enforceLoadingBoundary(enabled: boolean): void;
23
22
  export declare function setProjectionWriteActive(value: boolean): void;
24
23
  export declare function setTrackedQueueCallback(value: boolean): void;
24
+ export declare function setEffectCallback(value: boolean): void;
25
25
  export type QueueCallback = (type: number) => void;
26
26
  type QueueStub = {
27
27
  _queues: [QueueCallback[], QueueCallback[]];
@@ -105,7 +105,7 @@ export declare class GlobalQueue extends Queue {
105
105
  static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
106
106
  static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
107
107
  static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
108
- static _recomputeLane: ((el: Computed<any>, own: boolean) => OptimisticLane | null) | null;
108
+ static _recomputeLane: ((el: Computed<any>, own: boolean) => OptimisticLane | null | false) | null;
109
109
  static _laneAsyncPending: ((el: Computed<any>) => void) | null;
110
110
  static _laneAsyncSettled: ((el: Computed<any>) => void) | null;
111
111
  static _trackOptimisticStore: ((store: any) => void) | null;
@@ -116,6 +116,8 @@ export declare class GlobalQueue extends Queue {
116
116
  export declare function queuePendingNode(node: Signal<any>): void;
117
117
  export declare function armReaskClear(): void;
118
118
  export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
119
+ export declare let storeCommitHook: (() => void) | null;
120
+ export declare function setStoreCommitHook(fn: () => void): void;
119
121
  export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
120
122
  /**
121
123
  * Count of live `affects()` registrations across the system (including
@@ -414,6 +414,12 @@ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined
414
414
  * may run multiple times for a single change or show tearing (reading inconsistent
415
415
  * state). Use only when dynamic subscription patterns require same-scope tracking.
416
416
  *
417
+ * The callback runs during the flush itself: writes made inside it are queued
418
+ * into the same flush's continuation and are never visible to the callback's
419
+ * own reads (reads return settled values, as in every effect-phase scope), and
420
+ * `flush()` cannot be called from inside it (dev throws; production is a
421
+ * no-op) — defer with `queueMicrotask(() => flush())` if needed.
422
+ *
417
423
  * ```typescript
418
424
  * createTrackedEffect(compute, options?: { name?: string });
419
425
  * ```
@@ -542,6 +548,19 @@ export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: Si
542
548
  * Reactive reads inside the callback are *not* tracked — to react to
543
549
  * subsequent settles, register a new `onSettled` each time.
544
550
  *
551
+ * The callback runs during the settle flush itself, which gives it the same
552
+ * write semantics as every other effect-phase scope (the effect half of
553
+ * `createEffect`, event handlers):
554
+ *
555
+ * - **Writes** are queued into the same flush's continuation — dependent memos
556
+ * and effects update before the flush returns — but reads inside the
557
+ * callback keep returning the settled (pre-write) values. A callback never
558
+ * observes its own unsettled write. Functional setters still compose:
559
+ * `set(v => v + 1)` twice increments twice.
560
+ * - **`flush()` cannot be called** from inside the callback — the flush is
561
+ * already running (dev throws; production is a no-op). To force a drain
562
+ * after this settle, defer it: `queueMicrotask(() => flush())`.
563
+ *
545
564
  * `onCleanup` is **not** allowed inside the callback — return a cleanup
546
565
  * function instead. The returned cleanup runs on owner disposal.
547
566
  *
@@ -1,9 +1,19 @@
1
1
  export type { Store, StoreReturn, ProjectionStoreReturn, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.cjs";
2
2
  export type { Merge, Omit } from "./utils.cjs";
3
- export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.cjs";
4
- export { createProjection } from "./projection.cjs";
5
- export { createOptimisticStore } from "./optimistic.cjs";
6
- export { reconcile } from "./reconcile.cjs";
3
+ export { isWrappable, $TRACK, $PROXY, $TARGET } from "./store.cjs";
4
+ import type { NoFn, ProjectionOptions, Store, StoreOptions, StoreSetter } from "./store.cjs";
5
+ import type { Refreshable } from "../core/index.cjs";
6
+ export { createProjectionNext as createProjection } from "./next/projection.cjs";
7
+ export { createOptimisticStoreNext as createOptimisticStore } from "./next/optimistic.cjs";
8
+ /** Public createStore: plain form `(init, options?)` and derived writable
9
+ * form `(fn, seed, options?)`. */
10
+ export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
11
+ shallow?: boolean;
12
+ }): [get: Store<T>, set: StoreSetter<T>];
13
+ export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
14
+ export declare function reconcile<T extends U, U>(value: T, key?: string | ((item: NonNullable<any>) => any) | null): (state: U) => T;
15
+ export declare function snapshot<T>(value: T): T;
16
+ export declare function deep<T>(value: T): T;
7
17
  export { storePath } from "./storePath.cjs";
8
18
  export type { PathSetter, Part, StorePathRange, ArrayFilterFn, CustomPartial } from "./storePath.cjs";
9
- export { snapshot, deep, merge, omit } from "./utils.cjs";
19
+ export { merge, omit } from "./utils.cjs";
@@ -0,0 +1,20 @@
1
+ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "../store.cjs";
2
+ import type { StoreNextFamily, StoreNextTarget } from "./target.cjs";
3
+ export declare function createOptimisticStoreNext<T extends object = {}>(first: T | ((store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>), second?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
4
+ /** Diff the draft against the current OPTIMISTIC VIEW (committed + active
5
+ * overrides — the same view the draft was seeded from) and emit engine writes
6
+ * for exactly the changed keys. Visible-view diffing keeps no-op writes from
7
+ * entangling lanes (RUL-10 / opt R38). */
8
+ export declare function notifyOptimisticWrites(t: StoreNextTarget, pb: Record<PropertyKey, any>): void;
9
+ /**
10
+ * Landing consumption (RUL-2): fresh authoritative data supersedes every
11
+ * tentative override in the family. Mirrors legacy clearProjectionOverride —
12
+ * drop the override, clear lane/ownership, notify subscribers whose visible
13
+ * value changes (reversion effects go to regular queues via the projection
14
+ * write posture the caller holds).
15
+ */
16
+ export declare function consumeOverridesNext(fam: StoreNextFamily): void;
17
+ /** Optimistic-view composition for snapshot/deep (O1: snapshot is the CURRENT
18
+ * view, lane values included; a fresh copy per call during pending windows —
19
+ * RUL-12). Returns `src` untouched when no override is active on `t`. */
20
+ export declare function optimisticView(t: StoreNextTarget, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Store rewrite — projections (§7/§7b): a projection is a computed store.
3
+ * The derive runs inside a computed whose recompute merges its output into
4
+ * the projection's backing through the adoption channel (replace-mode root:
5
+ * entity changes merge in place, the root proxy is stable for life). Children
6
+ * wrap into the projection's own FAMILY (writes land here, never in a source
7
+ * family), and every family node carries the projection computed as its
8
+ * firewall — reads link the derive's status and lifecycle natively. The §6c
9
+ * status gate in the traps makes an uninitialized async derive's seed
10
+ * unobservable through every read surface.
11
+ *
12
+ * Mirrors the legacy runProjectionComputed shape (shadow runs for open
13
+ * loading windows, handleAsync landings, commit-through-setter) on next
14
+ * primitives; the generic draft write-traps are reused from the legacy
15
+ * module unchanged.
16
+ */
17
+ import { type Computed, type Refreshable } from "../../core/index.cjs";
18
+ import { type NoFn, type ProjectionOptions, type Store } from "../store.cjs";
19
+ export declare function createProjectionNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): Refreshable<Store<T>>;
20
+ /** Derived writable store (legacy parity): a projection whose public setter
21
+ * masks the recompute for the tick (core R31 — the manual write wins over a
22
+ * same-flush dependency change). */
23
+ export declare function createStoreDerivedNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [Refreshable<Store<T>>, (f: (draft: T) => T | void) => void];
24
+ export declare function runProjectionComputedNext<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any) | null, wrapCommit?: (write: () => void) => void, onDraftWrite?: () => void): Computed<void | T>;
@@ -0,0 +1,3 @@
1
+ type KeyFn = (item: any) => any;
2
+ export declare function reconcileNextState(value: any, state: any, key: string | KeyFn | null | undefined, replace?: boolean): void;
3
+ export {};
@@ -0,0 +1,71 @@
1
+ import type { Signal } from "../../core/types.cjs";
2
+ import { type StoreNextFamily, type StoreNextTarget } from "./target.cjs";
3
+ export declare function wrapNext<T extends Record<PropertyKey, any>>(value: T, parent?: StoreNextTarget | null, parentKey?: PropertyKey | null, fam?: StoreNextFamily | null): T;
4
+ /** Unwrap our own proxies to their current backing; leave everything else. */
5
+ export declare function unwrapValue(v: any): any;
6
+ export declare function getNode(target: StoreNextTarget, key: PropertyKey, current: any): Signal<any>;
7
+ export declare function getHasNode(target: StoreNextTarget, key: PropertyKey, present: boolean): Signal<boolean>;
8
+ export declare function getKeySetNode(target: StoreNextTarget): Signal<number>;
9
+ /** Deep-witness bump: any value/shape change on a record with a live deep()
10
+ * subscriber notifies it. One null check when unused. */
11
+ export declare function bumpDeep(t: StoreNextTarget): void;
12
+ /**
13
+ * Adoption (2026-08-16c): the incoming object becomes the committed backing
14
+ * IMMEDIATELY — reconcile is eagerly visible to every reader (shipped
15
+ * contract; only its notifications batch), unlike setter writes which stay
16
+ * pending until flush. Ownership resets (incoming is unowned/user data). Any
17
+ * staged draft clone folds into the diff and is discarded — next is the
18
+ * authoritative base (R21/R32).
19
+ */
20
+ export declare function adoptPB(target: StoreNextTarget, incoming: Record<PropertyKey, any>, eager?: boolean): void;
21
+ /** Same logical slot: both values resolve to one (re-pointed) child target —
22
+ * adoption preserved identity, so the slot did not change (R9). */
23
+ export declare function targetsEqual(ov: any, nv: any): boolean;
24
+ /**
25
+ * The fold diff walks SUBSCRIPTION KEYS ONLY (legacy parity: `for key in
26
+ * nodes`): nodes exist exactly where something tracked, so unobserved data
27
+ * costs nothing here regardless of object size. Accessor safety rides the
28
+ * sticky `t.a` flag — a node's key was necessarily read, so the get trap has
29
+ * already seen whether it is an accessor.
30
+ */
31
+ /** One node's fold notification (shared by notifyFold's walk and the fused
32
+ * adoption walk): accessor-aware compare + equality/identity-gated setSignal. */
33
+ export declare function notifyKeyDiff(node: Signal<any>, key: PropertyKey, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>, probe?: boolean): void;
34
+ /** Accessor-flag probe for the fused walk's early-continue (accessor keys
35
+ * can never identity-skip: their VALUE is the descriptor's product). */
36
+ export declare function hasAccessorFlag(node: Signal<any>): boolean;
37
+ /** Fused-walk per-key notification with values already in hand: the caller
38
+ * fetched both sides and handled the identity skip; this applies the
39
+ * accessor branch (cached flag only — reconcile channel) or the plain
40
+ * equality/identity-gated write. */
41
+ export declare function notifyKeyValue(node: Signal<any>, key: PropertyKey, ov: any, nv: any, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
42
+ /** Presence + membership halves of a fold notification (shared tail). */
43
+ export declare function notifyFoldTail(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
44
+ export declare function notifyFold(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
45
+ /** Authoritative-write wrapper exported for the optimistic module: sets the
46
+ * scheduler's projectionWriteActive through THIS module's binding (proven to
47
+ * share the instance core reads — cross-module live-binding writes from other
48
+ * store modules were observed not to propagate under the test transform). */
49
+ export declare function runAuthoritative<T>(fn: () => T): T;
50
+ /** Active optimistic override on an armed node (armed slot idles at
51
+ * NOT_PENDING; undefined = unarmed plain node). */
52
+ export declare function hasActiveOverride(node: Signal<any>): boolean;
53
+ export type SetStoreNextFunction<T> = (fn: (draft: T) => T | void) => void;
54
+ /** Low-level setter primitive: opens write mode on a next proxy, runs `fn`,
55
+ * emits write-time notifications at outermost exit, applies returned
56
+ * replacements as adoptions. `guard=false` skips the owned-scope dev guard —
57
+ * projection recomputes legitimately write from inside their computed. */
58
+ export declare function storeSetterNext<T>(proxy: T, fn: (draft: T) => T | void, guard?: boolean): void;
59
+ export declare function createStoreNext<T extends Record<PropertyKey, any>>(init: T, shallow?: boolean): [T, SetStoreNextFunction<T>];
60
+ /** Tracking deep snapshot (`deep()` for next targets): subscribes to the
61
+ * key-set and every property node at every reachable level, then returns the
62
+ * plain view. Shared references and cycles handled via the visited set. */
63
+ export declare function deepNext<T>(value: T): T;
64
+ /**
65
+ * Snapshot with per-object registration resolution (RUL-12 DAG ruling): every
66
+ * reachable wrappable resolves through its target's CURRENT backing, so
67
+ * privatized subtrees are seen through any parent path. Identity-preserving:
68
+ * a subtree with no substitutions below returns its own object (zero copy for
69
+ * settled, never-diverged graphs).
70
+ */
71
+ export declare function snapshotNext<T>(value: T): T;