@solidjs/signals 2.0.0-beta.18 → 2.0.0-beta.19

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 (56) hide show
  1. package/dist/dev.js +2743 -694
  2. package/dist/node.cjs +6419 -4234
  3. package/dist/prod/affects.js +222 -0
  4. package/dist/prod/boundaries.js +568 -0
  5. package/dist/prod/core/action.js +83 -0
  6. package/dist/prod/core/async.js +394 -0
  7. package/dist/prod/core/constants.js +78 -0
  8. package/dist/prod/core/context.js +67 -0
  9. package/dist/prod/core/core.js +772 -0
  10. package/dist/prod/core/dev.js +3 -0
  11. package/dist/prod/core/effect.js +145 -0
  12. package/dist/prod/core/error.js +59 -0
  13. package/dist/prod/core/external.js +98 -0
  14. package/dist/prod/core/graph.js +91 -0
  15. package/dist/prod/core/heap.js +132 -0
  16. package/dist/prod/core/invariants.js +42 -0
  17. package/dist/prod/core/lanes.js +130 -0
  18. package/dist/prod/core/optimistic.js +265 -0
  19. package/dist/prod/core/owner.js +293 -0
  20. package/dist/prod/core/scheduler.js +689 -0
  21. package/dist/prod/core/verdict.js +293 -0
  22. package/dist/prod/index.js +45 -0
  23. package/dist/prod/map.js +264 -0
  24. package/dist/prod/signals.js +389 -0
  25. package/dist/prod/store/optimistic.js +149 -0
  26. package/dist/prod/store/projection.js +184 -0
  27. package/dist/prod/store/reconcile.js +392 -0
  28. package/dist/prod/store/store.js +739 -0
  29. package/dist/prod/store/storePath.js +103 -0
  30. package/dist/prod/store/utils.js +297 -0
  31. package/dist/types/affects.d.ts +1 -1
  32. package/dist/types/boundaries.d.ts +6 -6
  33. package/dist/types/core/async.d.ts +4 -38
  34. package/dist/types/core/core.d.ts +12 -78
  35. package/dist/types/core/external.d.ts +0 -30
  36. package/dist/types/core/heap.d.ts +8 -0
  37. package/dist/types/core/index.d.ts +3 -2
  38. package/dist/types/core/optimistic.d.ts +6 -0
  39. package/dist/types/core/owner.d.ts +8 -0
  40. package/dist/types/core/scheduler.d.ts +39 -34
  41. package/dist/types/core/verdict.d.ts +2 -0
  42. package/dist/types/store/projection.d.ts +0 -1
  43. package/dist/types-cjs/affects.d.cts +1 -1
  44. package/dist/types-cjs/boundaries.d.cts +6 -6
  45. package/dist/types-cjs/core/async.d.cts +4 -38
  46. package/dist/types-cjs/core/core.d.cts +12 -78
  47. package/dist/types-cjs/core/external.d.cts +0 -30
  48. package/dist/types-cjs/core/heap.d.cts +8 -0
  49. package/dist/types-cjs/core/index.d.cts +3 -2
  50. package/dist/types-cjs/core/optimistic.d.cts +6 -0
  51. package/dist/types-cjs/core/owner.d.cts +8 -0
  52. package/dist/types-cjs/core/scheduler.d.cts +39 -34
  53. package/dist/types-cjs/core/verdict.d.cts +2 -0
  54. package/dist/types-cjs/store/projection.d.cts +0 -1
  55. package/package.json +8 -6
  56. package/dist/prod.js +0 -4637
@@ -0,0 +1,103 @@
1
+ import { isWrappable, ownEnumerableKeys } from "./store.js";
2
+
3
+ const DELETE = Symbol(0);
4
+
5
+ function isPrototypePollutionKey(t) {
6
+ return t === "__proto__" || t === "constructor" || t === "prototype";
7
+ }
8
+
9
+ function updatePath(t, e, o = 0) {
10
+ let r, n = t;
11
+ if (o < e.length - 1) {
12
+ r = e[o];
13
+ const i = typeof r;
14
+ const f = Array.isArray(t);
15
+ if (i === "string" && isPrototypePollutionKey(r)) return;
16
+ if (Array.isArray(r)) {
17
+ for (let n = 0; n < r.length; n++) {
18
+ e[o] = r[n];
19
+ updatePath(t, e, o);
20
+ }
21
+ e[o] = r;
22
+ return;
23
+ } else if (f && i === "function") {
24
+ for (let n = 0; n < t.length; n++) {
25
+ if (r(t[n], n)) {
26
+ e[o] = n;
27
+ updatePath(t, e, o);
28
+ }
29
+ }
30
+ e[o] = r;
31
+ return;
32
+ } else if (f && i === "object") {
33
+ const {from: n = 0, to: i = t.length - 1, by: f = 1} = r;
34
+ for (let r = n; r <= i; r += f) {
35
+ e[o] = r;
36
+ updatePath(t, e, o);
37
+ }
38
+ e[o] = r;
39
+ return;
40
+ } else if (o < e.length - 2) {
41
+ updatePath(t[r], e, o + 1);
42
+ return;
43
+ }
44
+ n = t[r];
45
+ }
46
+ let i = e[e.length - 1];
47
+ if (typeof i === "function") {
48
+ i = i(n);
49
+ if (i === n) return;
50
+ }
51
+ if (r === undefined && i == undefined) return;
52
+ if (i === DELETE) {
53
+ delete t[r];
54
+ } else if (r === undefined || isWrappable(n) && isWrappable(i) && !Array.isArray(i)) {
55
+ const e = r !== undefined ? t[r] : t;
56
+ const o = ownEnumerableKeys(i);
57
+ for (let t = 0; t < o.length; t++) {
58
+ const r = o[t];
59
+ if (typeof r === "string" && isPrototypePollutionKey(r)) continue;
60
+ const n = Object.getOwnPropertyDescriptor(i, r);
61
+ if (n.get || n.set) Object.defineProperty(e, r, n); else e[r] = n.value;
62
+ }
63
+ } else {
64
+ t[r] = i;
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Path-based setter helper for `createStore`. Call `storePath(...path, value)`
70
+ * to produce a draft-mutating function suitable for passing to `setStore`.
71
+ *
72
+ * The canonical setter form in Solid 2.0 is the draft-mutating callback
73
+ * (`setStore(s => { s.user.name = "Ada"; })`). `storePath` is a backwards-
74
+ * compatibility helper for users porting from Solid 1.x's
75
+ * `setStore("user", "name", "Ada")` style — it's optional and you can mix the
76
+ * two styles freely.
77
+ *
78
+ * Path parts can be:
79
+ * - a single key — `"user"`, `0`
80
+ * - an array of keys — `[0, 1, 2]`
81
+ * - a range over an array — `{ from?, to?, by? }`
82
+ * - a filter `(item, index) => boolean` for arrays
83
+ *
84
+ * The final argument is the new value or an updater `(prev) => next`. Use
85
+ * `storePath.DELETE` to remove a property.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const [state, setState] = createStore({ user: { name: "Ada" }, todos: [] });
90
+ *
91
+ * setState(storePath("user", "name", "Grace"));
92
+ * setState(storePath("todos", t => !t.done, "done", true)); // mark all undone as done
93
+ * setState(storePath("user", "nickname", storePath.DELETE));
94
+ * ```
95
+ */ const storePath = /* @__PURE__ */ Object.assign(function storePath(...t) {
96
+ return e => {
97
+ updatePath(e, t);
98
+ };
99
+ }, {
100
+ DELETE: DELETE
101
+ });
102
+
103
+ export { storePath };
@@ -0,0 +1,297 @@
1
+ import { pendingCheckActive } from "../core/core.js";
2
+
3
+ import { SUPPORTS_PROXY } from "../core/constants.js";
4
+
5
+ import "../core/scheduler.js";
6
+
7
+ import "../core/invariants.js";
8
+
9
+ import "../core/verdict.js";
10
+
11
+ import "../core/effect.js";
12
+
13
+ import { createMemo } from "../signals.js";
14
+
15
+ import { ownEnumerableKeys, $PROXY, isWrappable, $TARGET, trackSelf, witnessAffectsMark, mergedOverlay, STORE_VALUE, storeLookup, STORE_LOOKUP, $DELETED, wrap, getKeys, getPropertyDescriptor, $TRACK } from "./store.js";
16
+
17
+ function snapshotImpl(e, t, r, n) {
18
+ let o, s, c, i, 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] || n?.get(e)?.[$TARGET]) {
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
+ c = mergedOverlay(o);
30
+ s = Array.isArray(o[STORE_VALUE]);
31
+ r.set(e, c ? i = s ? [] : Object.create(Object.getPrototypeOf(o[STORE_VALUE])) : o[STORE_VALUE]);
32
+ e = o[STORE_VALUE];
33
+ n = o[STORE_LOOKUP] ?? storeLookup;
34
+ } else {
35
+ s = Array.isArray(e);
36
+ r.set(e, e);
37
+ }
38
+ if (s) {
39
+ const s = c?.length ?? e.length;
40
+ for (let p = 0; p < s; p++) {
41
+ u = c && p in c ? c[p] : e[p];
42
+ if (u === $DELETED) continue;
43
+ if (t && isWrappable(u)) wrap(u, o);
44
+ if ((f = snapshotImpl(u, t, r, n)) !== u || i) {
45
+ if (!i) r.set(e, i = [ ...e ]);
46
+ i[p] = f;
47
+ }
48
+ }
49
+ // Deleted trailing slots are skipped above, so restore length to preserve
50
+ // holes instead of truncating the copy (#2846) — mirrors unwrapStoreValue.
51
+ if (i) i.length = s;
52
+ } else if (!c) {
53
+ // Specialized walk for the common no-overlay case (from #2756): the own
54
+ // descriptor gives the value directly, so each property is read once with
55
+ // no overlay membership checks.
56
+ const s = getKeys(e, undefined);
57
+ for (let c = 0, p = s.length; c < p; c++) {
58
+ const p = s[c];
59
+ const l = Object.getOwnPropertyDescriptor(e, p);
60
+ if (l.get) continue;
61
+ u = l.value;
62
+ if (t && isWrappable(u)) wrap(u, o);
63
+ if ((f = snapshotImpl(u, t, r, n)) !== u || i) {
64
+ if (!i) {
65
+ i = Object.create(Object.getPrototypeOf(e));
66
+ Object.assign(i, e);
67
+ }
68
+ i[p] = f;
69
+ }
70
+ }
71
+ } else {
72
+ const s = getKeys(e, c);
73
+ for (let p = 0, l = s.length; p < l; p++) {
74
+ let l = s[p];
75
+ const a = getPropertyDescriptor(e, c, l);
76
+ if (a.get) continue;
77
+ u = l in c ? c[l] : e[l];
78
+ if (t && isWrappable(u)) wrap(u, o);
79
+ if ((f = snapshotImpl(u, t, r, n)) !== e[l] || i) {
80
+ if (!i) {
81
+ i = Object.create(Object.getPrototypeOf(e));
82
+ Object.assign(i, e);
83
+ }
84
+ i[l] = f;
85
+ }
86
+ }
87
+ }
88
+ return i || e;
89
+ }
90
+
91
+ function snapshot(e, t, r) {
92
+ return snapshotImpl(e, false, t, r);
93
+ }
94
+
95
+ /**
96
+ * Returns a plain (non-proxy) deep copy **and** subscribes the current
97
+ * tracking scope to every nested change in the source store. Any write
98
+ * anywhere in the subtree invalidates the consumer.
99
+ *
100
+ * Use this when you need plain data inside a reactive scope and want to
101
+ * react to deep mutations (e.g. passing a snapshot to `reconcile()` or to a
102
+ * memo that should rerun on any nested change). For most read paths, prefer
103
+ * direct property access — Solid stores already track per-property reads
104
+ * with no `deep()` wrapper needed.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * const [state] = createStore({ a: { b: { c: 1 } } });
109
+ *
110
+ * createEffect(
111
+ * () => deep(state), // reruns on any nested change
112
+ * plain => sendToWorker(plain) // worker gets a non-proxy copy
113
+ * );
114
+ * ```
115
+ */ function deep(e) {
116
+ return snapshotImpl(e, true);
117
+ }
118
+
119
+ function trueFn() {
120
+ return true;
121
+ }
122
+
123
+ const propTraps = {
124
+ get(e, t, r) {
125
+ if (t === $PROXY) return r;
126
+ return e.get(t);
127
+ },
128
+ has(e, t) {
129
+ if (t === $PROXY) return true;
130
+ return e.has(t);
131
+ },
132
+ set: trueFn,
133
+ deleteProperty: trueFn,
134
+ getOwnPropertyDescriptor(e, t) {
135
+ return {
136
+ configurable: true,
137
+ enumerable: true,
138
+ get() {
139
+ return e.get(t);
140
+ },
141
+ set: trueFn,
142
+ deleteProperty: trueFn
143
+ };
144
+ },
145
+ ownKeys(e) {
146
+ return e.keys();
147
+ }
148
+ };
149
+
150
+ function resolveSource(e) {
151
+ return !(e = typeof e === "function" ? e() : e) ? {} : e;
152
+ }
153
+
154
+ const $SOURCES = Symbol(0);
155
+
156
+ /**
157
+ * Merges multiple props-like objects into a single proxy that *preserves
158
+ * reactivity*. Reads are forwarded to the right-most source that defines the
159
+ * property, so later sources override earlier ones (like `Object.assign`).
160
+ *
161
+ * Function arguments are treated as memo-backed sources — useful for passing
162
+ * derived defaults whose computation should track reactively.
163
+ *
164
+ * Use this in component bodies to merge defaults / overrides without losing
165
+ * Solid's per-property tracking.
166
+ *
167
+ * @example
168
+ * ```tsx
169
+ * function Button(_props: { label: string; type?: string; disabled?: boolean }) {
170
+ * const props = merge({ type: "button", disabled: false }, _props);
171
+ *
172
+ * return <button type={props.type} disabled={props.disabled}>{props.label}</button>;
173
+ * }
174
+ * ```
175
+ */ function merge(...e) {
176
+ if (e.length === 1 && typeof e[0] !== "function") return e[0];
177
+ let t = false;
178
+ const r = [];
179
+ for (let n = 0; n < e.length; n++) {
180
+ const o = e[n];
181
+ t = t || !!o && $PROXY in o;
182
+ const s = !!o && o[$SOURCES];
183
+ if (s) {
184
+ for (let e = 0; e < s.length; e++) r.push(s[e]);
185
+ } else r.push(typeof o === "function" ? (t = true, createMemo(o)) : o);
186
+ }
187
+ if (SUPPORTS_PROXY && t) {
188
+ return new Proxy({
189
+ get(e) {
190
+ if (e === $SOURCES) return r;
191
+ for (let t = r.length - 1; t >= 0; t--) {
192
+ const n = resolveSource(r[t]);
193
+ if (e in n) return n[e];
194
+ }
195
+ },
196
+ has(e) {
197
+ for (let t = r.length - 1; t >= 0; t--) {
198
+ if (e in resolveSource(r[t])) return true;
199
+ }
200
+ return false;
201
+ },
202
+ keys() {
203
+ const e = new Set;
204
+ for (let t = 0; t < r.length; t++) {
205
+ const n = ownEnumerableKeys(resolveSource(r[t]));
206
+ for (let t = 0; t < n.length; t++) e.add(n[t]);
207
+ }
208
+ return [ ...e ];
209
+ }
210
+ }, propTraps);
211
+ }
212
+ const n = Object.create(null);
213
+ let o = false;
214
+ let s = r.length - 1;
215
+ for (let e = s; e >= 0; e--) {
216
+ const t = r[e];
217
+ if (!t) {
218
+ e === s && s--;
219
+ continue;
220
+ }
221
+ const c = Object.getOwnPropertyNames(t);
222
+ for (let r = c.length - 1; r >= 0; r--) {
223
+ const i = c[r];
224
+ if (i === "__proto__" || i === "constructor") continue;
225
+ if (!n[i]) {
226
+ o = o || e !== s;
227
+ const r = Object.getOwnPropertyDescriptor(t, i);
228
+ n[i] = r.get ? {
229
+ enumerable: true,
230
+ configurable: true,
231
+ get: r.get.bind(t)
232
+ } : r;
233
+ }
234
+ }
235
+ }
236
+ if (!o) return r[s];
237
+ const c = {};
238
+ const i = Object.keys(n);
239
+ for (let e = i.length - 1; e >= 0; e--) {
240
+ const t = i[e], r = n[t];
241
+ if (r.get) Object.defineProperty(c, t, r); else c[t] = r.value;
242
+ }
243
+ c[$SOURCES] = r;
244
+ return c;
245
+ }
246
+
247
+ /**
248
+ * Returns a reactive proxy of `props` with the listed keys hidden. Tracking
249
+ * on the remaining keys is preserved.
250
+ *
251
+ * Use it to forward "rest" props to a child element while pulling out the
252
+ * keys your component handles itself — the equivalent of `splitProps(p, ["a","b"])[1]`.
253
+ *
254
+ * @example
255
+ * ```tsx
256
+ * function Input(props: { label: string; value: string; onInput: (v: string) => void } & JSX.HTMLAttributes<HTMLInputElement>) {
257
+ * const rest = omit(props, "label", "value", "onInput");
258
+ *
259
+ * return (
260
+ * <label>
261
+ * {props.label}
262
+ * <input
263
+ * {...rest}
264
+ * value={props.value}
265
+ * onInput={e => props.onInput(e.currentTarget.value)}
266
+ * />
267
+ * </label>
268
+ * );
269
+ * }
270
+ * ```
271
+ */ function omit(e, ...t) {
272
+ if (SUPPORTS_PROXY && $PROXY in e) {
273
+ return new Proxy({
274
+ get(r) {
275
+ return t.includes(r) ? undefined : e[r];
276
+ },
277
+ has(r) {
278
+ return !t.includes(r) && r in e;
279
+ },
280
+ keys() {
281
+ return ownEnumerableKeys(e).filter(e => !t.includes(e));
282
+ }
283
+ }, propTraps);
284
+ }
285
+ const r = {};
286
+ const n = Object.getOwnPropertyNames(e);
287
+ const o = t.length > 4 && n.length > t.length ? new Set(t) : undefined;
288
+ for (const s of n) {
289
+ if (o ? !o.has(s) : !t.includes(s)) {
290
+ const t = Object.getOwnPropertyDescriptor(e, s);
291
+ !t.get && !t.set && t.enumerable && t.writable && t.configurable ? r[s] = t.value : Object.defineProperty(r, s, t);
292
+ }
293
+ }
294
+ return r;
295
+ }
296
+
297
+ export { deep, merge, omit, snapshot };
@@ -1,5 +1,5 @@
1
- import { type Store } from "./store/store.js";
2
1
  import type { Accessor } from "./signals.js";
2
+ import { type Store } from "./store/store.js";
3
3
  /**
4
4
  * Declares that in-flight work will change the targeted data: the named
5
5
  * slot(s) — and everything DERIVED from them — read as pending
@@ -20,7 +20,7 @@ export declare class RevealController {
20
20
  _evaluating: boolean;
21
21
  constructor(order: OrderAccessor, collapsed: BoolAccessor);
22
22
  _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
23
- isReady(): boolean;
23
+ _isReady(): boolean;
24
24
  /**
25
25
  * "Minimally ready" = this group has something visible to show under its own policy.
26
26
  * Used by an enclosing `together` group to decide when it can release.
@@ -28,10 +28,10 @@ export declare class RevealController {
28
28
  * - `sequential`: the first owned slot is minimally ready (frontier can advance).
29
29
  * - `natural`: any owned slot is minimally ready.
30
30
  */
31
- isMinimallyReady(): boolean;
32
- register(slot: RevealSlot): void;
33
- unregister(slot: RevealSlot): void;
34
- evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
31
+ _isMinimallyReady(): boolean;
32
+ _register(slot: RevealSlot): void;
33
+ _unregister(slot: RevealSlot): void;
34
+ _evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
35
35
  }
36
36
  export declare class CollectionQueue extends Queue {
37
37
  _collectionType: number;
@@ -48,7 +48,7 @@ export declare class CollectionQueue extends Queue {
48
48
  constructor(type: number);
49
49
  run(type: number): void;
50
50
  notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
51
- checkSources(): void;
51
+ _checkSources(): void;
52
52
  }
53
53
  /**
54
54
  * Lower-level primitive that backs the `<Loading>` flow control. Catches
@@ -1,44 +1,10 @@
1
1
  import { type OptimisticLane } from "./lanes.js";
2
- import type { Computed, Signal } from "./types.js";
2
+ import type { Computed, Link } from "./types.js";
3
+ export declare function addPendingSource(el: Computed<any>, source: Computed<any>): boolean;
4
+ export declare function setPendingError(el: Computed<any>, source?: Computed<any>, error?: any): void;
5
+ export declare function forEachDependent(el: Computed<any>, fn: (node: Computed<any>, link: Link) => void): void;
3
6
  export declare function settlePendingSource(el: Computed<any>, source?: Computed<any>, snap?: boolean): void;
4
7
  export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
5
8
  export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
6
9
  export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
7
10
  export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
8
- /**
9
- * The pending-source identity of a live `affects()` mark on `node` (lazy,
10
- * one per node, shared by overlapping registrations via the refcount).
11
- *
12
- * A mark rides the SAME status rails as real in-flight async — downstream
13
- * subscribers hold the sentinel in `_pendingSources` — but under its own
14
- * identity so the two channels can't clear each other:
15
- * - `_reask` is permanently `false`: a mark is by definition a declared
16
- * value change, so `quietPending` never silences a window it participates
17
- * in — even when the mark rides over an otherwise-quiet `refresh()`
18
- * re-ask of the same node (the whole point of declaring one).
19
- * - A landing on the marked node settles only the node's OWN source entry;
20
- * the sentinel entry survives until the mark's transaction releases it.
21
- * - The sentinel itself never carries `STATUS_PENDING`, so
22
- * `transitionComplete` never counts a mark as a blocker of its own
23
- * transaction (release happens AT settle — self-blocking would deadlock),
24
- * and reads of the marked node never throw (marks are value-transparent
25
- * at the source; pendingness is what propagates).
26
- */
27
- export declare function getAffectsSentinel(node: Signal<any> | Computed<any>): Computed<any>;
28
- /**
29
- * Push a live mark's pendingness downstream from the marked node through the
30
- * normal status rails. Runs on every registration (dedup in `notifyStatus`
31
- * stops re-descent at already-covered subscribers). Subscribers that
32
- * recompute mid-window shed this via `clearStatus` and re-acquire it through
33
- * the read path (`applyAffectsReads`) — the same shape as real async, where
34
- * the re-throw on read re-establishes the source.
35
- */
36
- export declare function propagateAffectsMark(node: Signal<any> | Computed<any>): void;
37
- /**
38
- * Re-establish mark pendingness on a computed that read marked sources
39
- * during its recompute (`clearStatus` at the top of the commit path wiped
40
- * any sentinel entries it held). Called by `recompute` after the commit —
41
- * not before, because setting `_error` earlier would make the commit path
42
- * treat the node as errored and skip the value write.
43
- */
44
- export declare function applyAffectsReads(el: Computed<any>, sources: (Signal<any> | Computed<any>)[]): void;
@@ -5,6 +5,12 @@ export declare const PRIMITIVE_IN_FORBIDDEN_SCOPE_MESSAGE = "[PRIMITIVE_IN_FORBI
5
5
  export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE: string;
6
6
  export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE: string;
7
7
  export declare let tracking: boolean;
8
+ /** @internal verdict-module glue */
9
+ export declare function setPendingCheckActive(v: boolean): void;
10
+ /** @internal verdict-module glue */
11
+ export declare function setLatestReadActive(v: boolean): void;
12
+ /** @internal verdict-module glue */
13
+ export declare function setContextInternal(v: Owner | null): void;
8
14
  export declare let stale: boolean;
9
15
  export declare let pendingCheckActive: boolean;
10
16
  export declare let latestReadActive: boolean;
@@ -60,6 +66,12 @@ export declare function setStrictRead(v: string | false): string | false;
60
66
  * ```
61
67
  */
62
68
  export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
69
+ /**
70
+ * Bring a computed to a readable state: lazy/disposed nodes are (re)computed;
71
+ * an isPending() probe (`refresh`) additionally pulls the node fully up to
72
+ * date so its status flags reflect the current graph.
73
+ */
74
+ export declare function prepareComputed(comp: Computed<unknown>, refresh: boolean): void;
63
75
  export declare function read<T>(el: Signal<T> | Computed<T>): T;
64
76
  export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
65
77
  /**
@@ -97,85 +109,7 @@ export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
97
109
  * ```
98
110
  */
99
111
  export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
100
- /**
101
- * Adds a node to the active isPending() probe without reading it. The store's
102
- * untracked-probe fallback (`witnessAffectsMark`) calls this with `affects()`
103
- * carrier nodes: an untracked read through a marked record may touch no real
104
- * signal node at all, so the probe collects the mark's carrier directly.
105
- *
106
- * @internal
107
- */
108
- export declare function witnessAffects(node: Signal<any> | Computed<any>): void;
109
- /**
110
- * Keep the lazily-created isPending()/latest() companion nodes in sync with a
111
- * new value. Every path that produces a value for `el` — direct set, async
112
- * resolution, transition-held sync recompute — must route through here so a
113
- * new write path can't silently skip the companions (#2831).
114
- */
115
- export declare function syncCompanions<T>(el: Signal<T> | Computed<T>, value: T): void;
116
- /**
117
- * Update _pendingSignal when pending state changes. When the override clears
118
- * (pending -> not pending), merge the sub-lane into the source's lane so
119
- * isPending effects are blocked until the full scope resolves.
120
- */
121
- export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
122
- /**
123
- * A firewall's status change re-derives the verdicts of its probed leaves:
124
- * leaf companions consult the firewall (broad inheritance), so async
125
- * starting/settling on the firewall must poke them or they keep a stale
126
- * verdict forever (V4 stuck-companion class, #2838).
127
- */
128
- export declare function updateChildCompanions(el: Computed<any>): void;
129
- /**
130
- * Settlement checkpoint (#2838): re-derive a node's companions directly from
131
- * its committed state. Called when the transition machinery for the node is
132
- * done with it — a pending commit or an optimistic revert. Verdicts are
133
- * written committed (not through setSignal) because a transition-scoped
134
- * override window opened here would itself need a settlement, re-scheduling
135
- * forever while async is still in flight. This is what keeps companions
136
- * coherent past transition completion: a verdict is a property of the data
137
- * (A19), so it must survive the transition that happened to produce it.
138
- */
139
- export declare function snapCompanionsToState(owner: Signal<any> | Computed<any>): void;
140
112
  export declare function staleValues<T>(fn: () => T, set?: boolean): T;
141
- /**
142
- * Reads reactive expressions while bypassing any pending async overlay — i.e.
143
- * always returns the most-recently-committed value, even when newer reads
144
- * inside `fn` are still in flight.
145
- *
146
- * Useful inside a `<Loading>` boundary's children when you want to keep
147
- * showing the previous resolved data instead of the fallback while the next
148
- * value loads.
149
- *
150
- * @example
151
- * ```tsx
152
- * <Loading fallback={<Skeleton />}>
153
- * {/* During a transition, render the previous user instead of skeleton: *\/}
154
- * <UserCard user={latest(() => user())} />
155
- * </Loading>
156
- * ```
157
- */
158
- export declare function latest<T>(fn: () => T): T;
159
- /**
160
- * Returns `true` if any reactive read inside `fn` is showing a stale value
161
- * while newer async work is pending. Does not subscribe — pair with a tracked
162
- * memo if you want to react to pending status changes.
163
- *
164
- * Useful for showing inline transition indicators alongside the previous
165
- * value (rather than swapping to a `<Loading>` fallback).
166
- * Because `fn` is read normally, `isPending` participates in Loading/SSR
167
- * readiness the same way the read itself would.
168
- *
169
- * @example
170
- * ```tsx
171
- * const pending = createMemo(() => isPending(() => user()));
172
- *
173
- * <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
174
- *
175
- * <button disabled={isPending(() => user())}>Save</button>
176
- * ```
177
- */
178
- export declare function isPending(fn: () => any): boolean;
179
113
  /**
180
114
  * Invalidates one reactive source, forcing it to re-execute even if its inputs
181
115
  * haven't changed.
@@ -11,35 +11,5 @@ export declare let externalSourceConfig: {
11
11
  factory: ExternalSourceFactory;
12
12
  untrack: <T>(fn: () => T) => T;
13
13
  } | null;
14
- /**
15
- * Registers a factory that bridges external reactive systems (e.g. MobX, Vue refs)
16
- * into Solid's tracking graph. Every computation will be wrapped so that the
17
- * external library can track its own dependencies alongside Solid's.
18
- *
19
- * Multiple calls pipe together: each new factory wraps the previous one.
20
- *
21
- * @param config.factory receives `(fn, trigger)` — wrap fn execution in external tracking,
22
- * call trigger when external deps change. Return `{ track, dispose }`.
23
- * @param config.untrack optional wrapper for `untrack` — disables external tracking too.
24
- *
25
- * @example
26
- * ```ts
27
- * // Bridge an external "subscribe / notify" library into Solid's graph.
28
- * // `factory` wraps every Solid compute so the external library can attach
29
- * // its own dependency tracker; `trigger` re-runs the compute on external
30
- * // change. `untrack` mirrors Solid's `untrack()` into the external library
31
- * // so that reads inside `untrack(...)` don't get tracked twice.
32
- * enableExternalSource({
33
- * factory: (compute, trigger) => {
34
- * const sub = externalLib.subscribe(trigger);
35
- * return {
36
- * track: prev => externalLib.run(() => compute(prev)),
37
- * dispose: () => sub.unsubscribe()
38
- * };
39
- * },
40
- * untrack: fn => externalLib.untracked(fn)
41
- * });
42
- * ```
43
- */
44
14
  export declare function enableExternalSource(config: ExternalSourceConfig): void;
45
15
  export declare function _resetExternalSourceConfig(): void;
@@ -1,4 +1,12 @@
1
1
  import type { Computed } from "./types.js";
2
+ /** The queue a node belongs to, picked from its own zombie flag. */
3
+ export declare function queueFor(n: Computed<any>): Heap;
4
+ /**
5
+ * Schedule one subscriber to re-run on the next flush: tracked effects bypass
6
+ * the heap and go directly to their effect queue; everything else is inserted
7
+ * into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
8
+ */
9
+ export declare function enqueueSub(node: Computed<any>): void;
2
10
  export interface Heap {
3
11
  _heap: (Computed<unknown> | undefined)[];
4
12
  _marked: boolean;
@@ -1,12 +1,13 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, isPending, latest, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.js";
2
+ export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.js";
3
3
  export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.js";
4
4
  export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.js";
5
5
  export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
6
6
  export { handleAsync } from "./async.js";
7
+ export { isPending, latest } from "./verdict.js";
7
8
  export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.js";
8
9
  export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.js";
9
10
  export { action } from "./action.js";
10
- export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.js";
11
+ export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.js";
11
12
  export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.js";
12
13
  export * from "./constants.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Installs the engine's hooks. Idempotent; called by every module that can
3
+ * create optimistic state (verdict.ts at module top level, createOptimistic
4
+ * and createOptimisticStore at first call) BEFORE any optimistic node exists.
5
+ */
6
+ export declare function installOptimisticEngine(): void;