@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
@@ -1,4 +1,4 @@
1
- import { pendingCheckActive } from "../core/core.js";
1
+ import "../core/core.js";
2
2
 
3
3
  import { SUPPORTS_PROXY } from "../core/constants.js";
4
4
 
@@ -12,162 +12,29 @@ import "../core/effect.js";
12
12
 
13
13
  import { createMemo } from "../signals.js";
14
14
 
15
- import { ownEnumerableKeys, $PROXY, isWrappable, $TARGET, lookupTarget, trackSelf, witnessAffectsMark, mergedOverlay, STORE_VALUE, storeLookup, STORE_LOOKUP, $DELETED, wrap, getStoreSymbols, getPropertyDescriptor, getStoreKeys, getKeys, $TRACK, rawValuesUsed, isRawValue } from "./store.js";
16
-
17
- function snapshotImpl(e, t, r, n) {
18
- let o, s, i, c, f, u;
19
- if (!isWrappable(e)) return e;
20
- if (r && r.has(e)) return r.get(e);
21
- if (!r) r = new Map;
22
- if (o = e[$TARGET] || lookupTarget(e, n)) {
23
- if (t) {
24
- trackSelf(o, $TRACK);
25
- // A tracked walk reads THROUGH the record without touching the proxy
26
- // traps — witness the record's affects() channel like a trap read would.
27
- if (pendingCheckActive) witnessAffectsMark(o);
28
- }
29
- i = mergedOverlay(o);
30
- // A derived store's STORE_VALUE is the inner store's live proxy
31
- // (store-in-store: createOptimisticStore/createProjection over a store).
32
- // Without an overlay of its own, the fast path below would map to — and
33
- // could return — that proxy verbatim. Recurse instead so the
34
- // inner store's own target branch unwraps it (chains of any depth).
35
- // With an overlay, a fresh `result` is always built, so the walk over the
36
- // inner proxy already copies plain values.
37
- if (!i && o[STORE_VALUE][$TARGET]) {
38
- f = snapshotImpl(o[STORE_VALUE], t, r, n);
39
- r.set(e, f);
40
- return f;
41
- }
42
- s = Array.isArray(o[STORE_VALUE]);
43
- r.set(e, i ? c = s ? [] : Object.create(Object.getPrototypeOf(o[STORE_VALUE])) : o[STORE_VALUE]);
44
- e = o[STORE_VALUE];
45
- n = o[STORE_LOOKUP] ?? storeLookup;
46
- } else {
47
- s = Array.isArray(e);
48
- r.set(e, e);
49
- }
50
- if (s) {
51
- const s = i?.length ?? e.length;
52
- for (let a = 0; a < s; a++) {
53
- u = i && a in i ? i[a] : e[a];
54
- if (u === $DELETED) continue;
55
- if (t && isWrappable(u) && !(rawValuesUsed && isRawValue(u))) wrap(u, o);
56
- if ((f = snapshotImpl(u, t, r, n)) !== u || c) {
57
- if (!c) r.set(e, c = [ ...e ]);
58
- c[a] = f;
59
- }
60
- }
61
- // Enumerate array symbols separately to avoid scanning indices twice.
62
- // Spread copies omit symbols, so assign them after the numeric walk.
63
- const a = n ? getStoreSymbols(e, i) : [];
64
- for (let s = 0, l = a.length; s < l; s++) {
65
- const l = a[s];
66
- const p = getPropertyDescriptor(e, i, l);
67
- if (!p || p.get) continue;
68
- u = i && l in i ? i[l] : e[l];
69
- if (t && isWrappable(u) && !(rawValuesUsed && isRawValue(u))) wrap(u, o);
70
- f = snapshotImpl(u, t, r, n);
71
- if (f !== u || c) {
72
- if (!c) r.set(e, c = Object.assign([ ...e ], e));
73
- c[l] = f;
74
- }
75
- }
76
- // Deleted trailing slots are skipped above, so restore length to preserve
77
- // holes instead of truncating the copy (#2846) — mirrors unwrapStoreValue.
78
- if (c) c.length = s;
79
- } else if (!i) {
80
- // Specialized walk for the common no-overlay case (from #2756): the own
81
- // descriptor gives the value directly, so each property is read once with
82
- // no overlay membership checks.
83
- // A lookup means this object belongs to an immutable store backing tree,
84
- // even if that nested value has not needed its own proxy yet.
85
- const s = n ? getStoreKeys(e, undefined) : getKeys(e, undefined);
86
- for (let i = 0, a = s.length; i < a; i++) {
87
- const a = s[i];
88
- const l = Object.getOwnPropertyDescriptor(e, a);
89
- if (l.get) continue;
90
- u = l.value;
91
- if (t && isWrappable(u) && !(rawValuesUsed && isRawValue(u))) wrap(u, o);
92
- if ((f = snapshotImpl(u, t, r, n)) !== u || c) {
93
- if (!c) {
94
- c = Object.create(Object.getPrototypeOf(e));
95
- Object.assign(c, e);
96
- }
97
- c[a] = f;
98
- }
99
- }
100
- } else {
101
- // An override only exists on a store record, and the target branch above
102
- // always set `lookup` alongside it — so this branch is always store-keyed.
103
- const s = getStoreKeys(e, i);
104
- for (let a = 0, l = s.length; a < l; a++) {
105
- let l = s[a];
106
- const p = getPropertyDescriptor(e, i, l);
107
- if (p.get) continue;
108
- u = l in i ? i[l] : e[l];
109
- if (t && isWrappable(u) && !(rawValuesUsed && isRawValue(u))) wrap(u, o);
110
- if ((f = snapshotImpl(u, t, r, n)) !== e[l] || c) {
111
- if (!c) {
112
- c = Object.create(Object.getPrototypeOf(e));
113
- Object.assign(c, e);
114
- }
115
- c[l] = f;
116
- }
117
- }
118
- }
119
- return c || e;
120
- }
121
-
122
- function snapshot(e, t, r) {
123
- return snapshotImpl(e, false, t, r);
124
- }
125
-
126
- /**
127
- * Returns a plain (non-proxy) deep copy **and** subscribes the current
128
- * tracking scope to every nested change in the source store. Any write
129
- * anywhere in the subtree invalidates the consumer.
130
- *
131
- * Use this when you need plain data inside a reactive scope and want to
132
- * react to deep mutations (e.g. passing a snapshot to `reconcile()` or to a
133
- * memo that should rerun on any nested change). For most read paths, prefer
134
- * direct property access — Solid stores already track per-property reads
135
- * with no `deep()` wrapper needed.
136
- *
137
- * @example
138
- * ```ts
139
- * const [state] = createStore({ a: { b: { c: 1 } } });
140
- *
141
- * createEffect(
142
- * () => deep(state), // reruns on any nested change
143
- * plain => sendToWorker(plain) // worker gets a non-proxy copy
144
- * );
145
- * ```
146
- */ function deep(e) {
147
- return snapshotImpl(e, true);
148
- }
15
+ import { ownEnumerableKeys, $PROXY } from "./store.js";
149
16
 
150
17
  function trueFn() {
151
18
  return true;
152
19
  }
153
20
 
154
21
  const propTraps = {
155
- get(e, t, r) {
156
- if (t === $PROXY) return r;
157
- return e.get(t);
22
+ get(e, r, t) {
23
+ if (r === $PROXY) return t;
24
+ return e.get(r);
158
25
  },
159
- has(e, t) {
160
- if (t === $PROXY) return true;
161
- return e.has(t);
26
+ has(e, r) {
27
+ if (r === $PROXY) return true;
28
+ return e.has(r);
162
29
  },
163
30
  set: trueFn,
164
31
  deleteProperty: trueFn,
165
- getOwnPropertyDescriptor(e, t) {
32
+ getOwnPropertyDescriptor(e, r) {
166
33
  return {
167
34
  configurable: true,
168
35
  enumerable: true,
169
36
  get() {
170
- return e.get(t);
37
+ return e.get(r);
171
38
  },
172
39
  set: trueFn,
173
40
  deleteProperty: trueFn
@@ -205,36 +72,36 @@ const $SOURCES = Symbol(0);
205
72
  * ```
206
73
  */ function merge(...e) {
207
74
  if (e.length === 1 && typeof e[0] !== "function") return e[0];
208
- let t = false;
209
- const r = [];
75
+ let r = false;
76
+ const t = [];
210
77
  for (let n = 0; n < e.length; n++) {
211
78
  const o = e[n];
212
- t = t || !!o && $PROXY in o;
79
+ r = r || !!o && $PROXY in o;
213
80
  const s = !!o && o[$SOURCES];
214
81
  if (s) {
215
- for (let e = 0; e < s.length; e++) r.push(s[e]);
216
- } else r.push(typeof o === "function" ? (t = true, createMemo(o)) : o);
82
+ for (let e = 0; e < s.length; e++) t.push(s[e]);
83
+ } else t.push(typeof o === "function" ? (r = true, createMemo(o)) : o);
217
84
  }
218
- if (SUPPORTS_PROXY && t) {
85
+ if (SUPPORTS_PROXY && r) {
219
86
  return new Proxy({
220
87
  get(e) {
221
- if (e === $SOURCES) return r;
222
- for (let t = r.length - 1; t >= 0; t--) {
223
- const n = resolveSource(r[t]);
88
+ if (e === $SOURCES) return t;
89
+ for (let r = t.length - 1; r >= 0; r--) {
90
+ const n = resolveSource(t[r]);
224
91
  if (e in n) return n[e];
225
92
  }
226
93
  },
227
94
  has(e) {
228
- for (let t = r.length - 1; t >= 0; t--) {
229
- if (e in resolveSource(r[t])) return true;
95
+ for (let r = t.length - 1; r >= 0; r--) {
96
+ if (e in resolveSource(t[r])) return true;
230
97
  }
231
98
  return false;
232
99
  },
233
100
  keys() {
234
101
  const e = new Set;
235
- for (let t = 0; t < r.length; t++) {
236
- const n = ownEnumerableKeys(resolveSource(r[t]));
237
- for (let t = 0; t < n.length; t++) e.add(n[t]);
102
+ for (let r = 0; r < t.length; r++) {
103
+ const n = ownEnumerableKeys(resolveSource(t[r]));
104
+ for (let r = 0; r < n.length; r++) e.add(n[r]);
238
105
  }
239
106
  return [ ...e ];
240
107
  }
@@ -242,37 +109,37 @@ const $SOURCES = Symbol(0);
242
109
  }
243
110
  const n = Object.create(null);
244
111
  let o = false;
245
- let s = r.length - 1;
112
+ let s = t.length - 1;
246
113
  for (let e = s; e >= 0; e--) {
247
- const t = r[e];
248
- if (!t) {
114
+ const r = t[e];
115
+ if (!r) {
249
116
  e === s && s--;
250
117
  continue;
251
118
  }
252
- const i = Object.getOwnPropertyNames(t);
253
- for (let r = i.length - 1; r >= 0; r--) {
254
- const c = i[r];
119
+ const u = Object.getOwnPropertyNames(r);
120
+ for (let t = u.length - 1; t >= 0; t--) {
121
+ const c = u[t];
255
122
  if (c === "__proto__" || c === "constructor") continue;
256
123
  if (!n[c]) {
257
124
  o = o || e !== s;
258
- const r = Object.getOwnPropertyDescriptor(t, c);
259
- n[c] = r.get ? {
125
+ const t = Object.getOwnPropertyDescriptor(r, c);
126
+ n[c] = t.get ? {
260
127
  enumerable: true,
261
128
  configurable: true,
262
- get: r.get.bind(t)
263
- } : r;
129
+ get: t.get.bind(r)
130
+ } : t;
264
131
  }
265
132
  }
266
133
  }
267
- if (!o) return r[s];
268
- const i = {};
134
+ if (!o) return t[s];
135
+ const u = {};
269
136
  const c = Object.keys(n);
270
137
  for (let e = c.length - 1; e >= 0; e--) {
271
- const t = c[e], r = n[t];
272
- if (r.get) Object.defineProperty(i, t, r); else i[t] = r.value;
138
+ const r = c[e], t = n[r];
139
+ if (t.get) Object.defineProperty(u, r, t); else u[r] = t.value;
273
140
  }
274
- i[$SOURCES] = r;
275
- return i;
141
+ u[$SOURCES] = t;
142
+ return u;
276
143
  }
277
144
 
278
145
  /**
@@ -299,30 +166,36 @@ const $SOURCES = Symbol(0);
299
166
  * );
300
167
  * }
301
168
  * ```
302
- */ function omit(e, ...t) {
169
+ */ function omit(e, ...r) {
303
170
  if (SUPPORTS_PROXY && $PROXY in e) {
304
171
  return new Proxy({
305
- get(r) {
306
- return t.includes(r) ? undefined : e[r];
172
+ get(t) {
173
+ // $SOURCES must not tunnel through the filter: merge() flattens
174
+ // whatever answers it, so forwarding would hand a re-merge the
175
+ // UNFILTERED sources of an underlying merge proxy and the omitted
176
+ // keys leak back in (#3014 — the SSR element-spread path re-merges
177
+ // static attributes with the rest object). Opaque here: merge
178
+ // composes omit proxies through their traps instead.
179
+ return t === $SOURCES || r.includes(t) ? undefined : e[t];
307
180
  },
308
- has(r) {
309
- return !t.includes(r) && r in e;
181
+ has(t) {
182
+ return t !== $SOURCES && !r.includes(t) && t in e;
310
183
  },
311
184
  keys() {
312
- return ownEnumerableKeys(e).filter(e => !t.includes(e));
185
+ return ownEnumerableKeys(e).filter(e => !r.includes(e));
313
186
  }
314
187
  }, propTraps);
315
188
  }
316
- const r = {};
189
+ const t = {};
317
190
  const n = Object.getOwnPropertyNames(e);
318
- const o = t.length > 4 && n.length > t.length ? new Set(t) : undefined;
191
+ const o = r.length > 4 && n.length > r.length ? new Set(r) : undefined;
319
192
  for (const s of n) {
320
- if (o ? !o.has(s) : !t.includes(s)) {
321
- const t = Object.getOwnPropertyDescriptor(e, s);
322
- !t.get && !t.set && t.enumerable && t.writable && t.configurable ? r[s] = t.value : Object.defineProperty(r, s, t);
193
+ if (o ? !o.has(s) : !r.includes(s)) {
194
+ const r = Object.getOwnPropertyDescriptor(e, s);
195
+ !r.get && !r.set && r.enumerable && r.writable && r.configurable ? t[s] = r.value : Object.defineProperty(t, s, r);
323
196
  }
324
197
  }
325
- return r;
198
+ return t;
326
199
  }
327
200
 
328
- export { deep, merge, omit, snapshot };
201
+ export { merge, omit };
@@ -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.js";
2
2
  export type { Merge, Omit } from "./utils.js";
3
- export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.js";
4
- export { createProjection } from "./projection.js";
5
- export { createOptimisticStore } from "./optimistic.js";
6
- export { reconcile } from "./reconcile.js";
3
+ export { isWrappable, $TRACK, $PROXY, $TARGET } from "./store.js";
4
+ import type { NoFn, ProjectionOptions, Store, StoreOptions, StoreSetter } from "./store.js";
5
+ import type { Refreshable } from "../core/index.js";
6
+ export { createProjectionNext as createProjection } from "./next/projection.js";
7
+ export { createOptimisticStoreNext as createOptimisticStore } from "./next/optimistic.js";
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.js";
8
18
  export type { PathSetter, Part, StorePathRange, ArrayFilterFn, CustomPartial } from "./storePath.js";
9
- export { snapshot, deep, merge, omit } from "./utils.js";
19
+ export { merge, omit } from "./utils.js";
@@ -0,0 +1,20 @@
1
+ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "../store.js";
2
+ import type { StoreNextFamily, StoreNextTarget } from "./target.js";
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.js";
18
+ import { type NoFn, type ProjectionOptions, type Store } from "../store.js";
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.js";
2
+ import { type StoreNextFamily, type StoreNextTarget } from "./target.js";
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;