@solidjs/signals 2.0.0-beta.9 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/dist/dev.js +5971 -1426
- package/dist/node.cjs +7681 -3293
- package/dist/prod/affects.js +126 -0
- package/dist/prod/boundaries.js +572 -0
- package/dist/prod/core/action.js +139 -0
- package/dist/prod/core/async.js +553 -0
- package/dist/prod/core/constants.js +92 -0
- package/dist/prod/core/context.js +67 -0
- package/dist/prod/core/core.js +817 -0
- package/dist/prod/core/dev.js +3 -0
- package/dist/prod/core/effect.js +145 -0
- package/dist/prod/core/error.js +68 -0
- package/dist/prod/core/external.js +98 -0
- package/dist/prod/core/graph.js +104 -0
- package/dist/prod/core/heap.js +140 -0
- package/dist/prod/core/invariants.js +42 -0
- package/dist/prod/core/lanes.js +140 -0
- package/dist/prod/core/optimistic.js +245 -0
- package/dist/prod/core/owner.js +302 -0
- package/dist/prod/core/scheduler.js +749 -0
- package/dist/prod/core/verdict.js +369 -0
- package/dist/prod/index.js +45 -0
- package/dist/prod/map.js +317 -0
- package/dist/prod/signals.js +375 -0
- package/dist/prod/store/optimistic.js +217 -0
- package/dist/prod/store/projection.js +231 -0
- package/dist/prod/store/reconcile.js +707 -0
- package/dist/prod/store/store.js +1081 -0
- package/dist/prod/store/storePath.js +103 -0
- package/dist/prod/store/utils.js +328 -0
- package/dist/types/affects.d.ts +47 -0
- package/dist/types/boundaries.d.ts +60 -13
- package/dist/types/core/action.d.ts +35 -6
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +35 -6
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +58 -63
- package/dist/types/core/dev.d.ts +17 -2
- package/dist/types/core/effect.d.ts +1 -2
- package/dist/types/core/error.d.ts +33 -0
- package/dist/types/core/external.d.ts +0 -11
- package/dist/types/core/graph.d.ts +2 -1
- package/dist/types/core/heap.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/invariants.d.ts +59 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/optimistic.d.ts +6 -0
- package/dist/types/core/owner.d.ts +50 -3
- package/dist/types/core/scheduler.d.ts +82 -10
- package/dist/types/core/types.d.ts +66 -1
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/map.d.ts +21 -5
- package/dist/types/signals.d.ts +164 -12
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +10 -6
- package/dist/types/store/reconcile.d.ts +31 -8
- package/dist/types/store/store.d.ts +101 -6
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +60 -13
- package/dist/types-cjs/core/action.d.cts +35 -6
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +35 -6
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +58 -63
- package/dist/types-cjs/core/dev.d.cts +17 -2
- package/dist/types-cjs/core/effect.d.cts +1 -2
- package/dist/types-cjs/core/error.d.cts +33 -0
- package/dist/types-cjs/core/external.d.cts +0 -11
- package/dist/types-cjs/core/graph.d.cts +2 -1
- package/dist/types-cjs/core/heap.d.cts +8 -0
- package/dist/types-cjs/core/index.d.cts +3 -2
- package/dist/types-cjs/core/invariants.d.cts +59 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/optimistic.d.cts +6 -0
- package/dist/types-cjs/core/owner.d.cts +50 -3
- package/dist/types-cjs/core/scheduler.d.cts +82 -10
- package/dist/types-cjs/core/types.d.cts +66 -1
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +3 -2
- package/dist/types-cjs/map.d.cts +21 -5
- package/dist/types-cjs/signals.d.cts +164 -12
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/optimistic.d.cts +3 -3
- package/dist/types-cjs/store/projection.d.cts +10 -6
- package/dist/types-cjs/store/reconcile.d.cts +31 -8
- package/dist/types-cjs/store/store.d.cts +101 -6
- package/package.json +11 -9
- package/dist/prod.js +0 -3627
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import { NotReadyError } from "./error.js";
|
|
1
2
|
import { type OptimisticLane } from "./lanes.js";
|
|
2
|
-
import type { Computed } from "./types.js";
|
|
3
|
+
import type { Computed, Link } from "./types.js";
|
|
4
|
+
export declare function addPendingSource(el: Computed<any>, source: Computed<any>): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* A loading-window node hit an unready source (sync throw in recompute, or a
|
|
7
|
+
* NotReadyError-rejected flight): register for the source's settle — the
|
|
8
|
+
* settlePendingSource walk runs off `_pendingSources` + `_blocked` alone —
|
|
9
|
+
* with NO read-visible pending status, no downstream propagation, no
|
|
10
|
+
* transition, no lane registration. Commit #0 keeps serving.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parkLoadingWindow(el: Computed<any>, e: NotReadyError): void;
|
|
13
|
+
export declare function setPendingError(el: Computed<any>, source?: Computed<any>, error?: any): void;
|
|
14
|
+
export declare function forEachDependent(el: Computed<any>, fn: (node: Computed<any>, link: Link) => void): void;
|
|
15
|
+
export declare function releaseSettledDependents(el: Computed<any>): void;
|
|
16
|
+
export declare function settleErroredDependents(el: Computed<any>, error: any): void;
|
|
3
17
|
export declare function settlePendingSource(el: Computed<any>): void;
|
|
18
|
+
export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
|
|
4
19
|
export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
|
|
5
20
|
export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
|
|
6
21
|
export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
|
|
@@ -9,12 +9,22 @@ export declare const REACTIVE_DISPOSED: number;
|
|
|
9
9
|
export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
|
|
10
10
|
export declare const REACTIVE_SNAPSHOT_STALE: number;
|
|
11
11
|
export declare const REACTIVE_LAZY: number;
|
|
12
|
+
export declare const REACTIVE_MANUAL_WRITE: number;
|
|
13
|
+
/**
|
|
14
|
+
* The pending recompute is a re-ask of the same question: `refresh()` dirtied
|
|
15
|
+
* the node while no tracked input changed value. Cleared whenever a real
|
|
16
|
+
* value-change notification arrives (`insertSubs`), and consumed by
|
|
17
|
+
* `recompute` into the node's `_reask` classification — a quiet (re-ask)
|
|
18
|
+
* pending window does not read as pending (question-scoped pending model).
|
|
19
|
+
*/
|
|
20
|
+
export declare const REACTIVE_REASK: number;
|
|
12
21
|
export declare const CONFIG_OWNED_WRITE: number;
|
|
13
22
|
export declare const CONFIG_NO_SNAPSHOT: number;
|
|
14
23
|
export declare const CONFIG_TRANSPARENT: number;
|
|
15
24
|
export declare const CONFIG_IN_SNAPSHOT_SCOPE: number;
|
|
16
25
|
export declare const CONFIG_CHILDREN_FORBIDDEN: number;
|
|
17
26
|
export declare const CONFIG_AUTO_DISPOSE: number;
|
|
27
|
+
export declare const CONFIG_SYNC: number;
|
|
18
28
|
export declare const STATUS_NONE = 0;
|
|
19
29
|
export declare const STATUS_PENDING: number;
|
|
20
30
|
export declare const STATUS_ERROR: number;
|
|
@@ -25,17 +35,36 @@ export declare const EFFECT_USER = 2;
|
|
|
25
35
|
export declare const EFFECT_TRACKED = 3;
|
|
26
36
|
export declare const NOT_PENDING: {};
|
|
27
37
|
export declare const NO_SNAPSHOT: {};
|
|
38
|
+
/**
|
|
39
|
+
* Stand-in stored in `_overrideValue` for an optimistic write of literal
|
|
40
|
+
* `undefined` (#2898). The slot doubles as the optimistic-node brand
|
|
41
|
+
* (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
|
|
42
|
+
* would erase the node's optimistic identity: the write turns invisible and
|
|
43
|
+
* follow-up writes route off the optimistic path and commit permanently.
|
|
44
|
+
* Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
|
|
45
|
+
* via `visibleOverrideValue`; slot identity tests stay raw.
|
|
46
|
+
*/
|
|
47
|
+
export declare const OVERRIDE_UNDEFINED: {};
|
|
48
|
+
/** Unwrap an active override's stored value for surfacing to readers (#2898). */
|
|
49
|
+
export declare function unwrapOverride<T = any>(v: unknown): T;
|
|
28
50
|
export declare const STORE_SNAPSHOT_PROPS = "sp";
|
|
29
51
|
export declare const SUPPORTS_PROXY: boolean;
|
|
30
52
|
export declare const defaultContext: {};
|
|
53
|
+
/**
|
|
54
|
+
* Brand symbol used by `Refreshable<T>` values (projection stores, async
|
|
55
|
+
* memos) to expose their underlying computation to `refresh()`. Not part of
|
|
56
|
+
* the user-facing API.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
31
60
|
export declare const $REFRESH: unique symbol;
|
|
32
61
|
/**
|
|
33
|
-
* Brand applied to
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
62
|
+
* Brand applied to values that participate in the `refresh()` re-run protocol.
|
|
63
|
+
* Accessors receive this handle internally; projected stores expose it through
|
|
64
|
+
* their public return type so user-defined hooks that wrap `createOptimisticStore`
|
|
65
|
+
* / `createProjection` / projection-form `createStore` can have their return
|
|
66
|
+
* types inferred without leaking the internal `$REFRESH` symbol into public type
|
|
67
|
+
* signatures (TS4058).
|
|
39
68
|
*/
|
|
40
69
|
export type Refreshable<T> = T & {
|
|
41
70
|
readonly [$REFRESH]: any;
|
|
@@ -14,15 +14,23 @@ export type ContextRecord = Record<string | symbol, unknown>;
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Low-level owner-targeted context read. The user-facing read API is
|
|
18
|
+
* `useContext` (in `solid-js`), which wraps this primitive. Exposed here for
|
|
19
|
+
* cross-package wiring (e.g. hydration-aware context plumbing).
|
|
18
20
|
*
|
|
19
21
|
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
20
22
|
* @throws `ContextNotFoundError` if a context value has not been set yet.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
21
25
|
*/
|
|
22
26
|
export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
28
|
+
* Low-level owner-targeted context write. The user-facing API is
|
|
29
|
+
* `createContext` (in `solid-js`); its provider component wraps this
|
|
30
|
+
* primitive. Exposed here for cross-package wiring.
|
|
25
31
|
*
|
|
26
32
|
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
27
35
|
*/
|
|
28
36
|
export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
|
|
@@ -2,11 +2,17 @@ import { type Refreshable } from "./constants.js";
|
|
|
2
2
|
import { type OptimisticLane } from "./lanes.js";
|
|
3
3
|
import type { Computed, FirewallSignal, NodeOptions, Owner, Signal } from "./types.js";
|
|
4
4
|
export declare const PRIMITIVE_IN_FORBIDDEN_SCOPE_MESSAGE = "[PRIMITIVE_IN_FORBIDDEN_SCOPE] Cannot create reactive primitives inside createTrackedEffect or owner-backed onSettled";
|
|
5
|
+
export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE: string;
|
|
6
|
+
export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE: string;
|
|
5
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;
|
|
6
14
|
export declare let stale: boolean;
|
|
7
|
-
export declare let refreshing: boolean;
|
|
8
15
|
export declare let pendingCheckActive: boolean;
|
|
9
|
-
export declare let foundPending: boolean;
|
|
10
16
|
export declare let latestReadActive: boolean;
|
|
11
17
|
export declare let context: Owner | null;
|
|
12
18
|
export declare let currentOptimisticLane: OptimisticLane | null;
|
|
@@ -19,6 +25,13 @@ export declare function clearSnapshots(): void;
|
|
|
19
25
|
export declare function recompute(el: Computed<any>, create?: boolean): void;
|
|
20
26
|
export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
|
|
21
27
|
export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Build an Effect node with all effect-specific fields baked into a single object literal,
|
|
30
|
+
* so V8 sees the full hidden class shape at construction time. Effects always run in lazy
|
|
31
|
+
* mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
|
|
32
|
+
* the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
|
|
33
|
+
*/
|
|
34
|
+
export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val: T, prev: T | undefined) => void | (() => void), errorFn: ((err: unknown, cleanup: () => void) => void | (() => void)) | undefined, type: number, notifyStatus: ((status?: number, error?: any) => void) | undefined, options: NodeOptions<T> | undefined): any;
|
|
22
35
|
export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
23
36
|
export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
|
|
24
37
|
export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
@@ -53,8 +66,44 @@ export declare function setStrictRead(v: string | false): string | false;
|
|
|
53
66
|
* ```
|
|
54
67
|
*/
|
|
55
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;
|
|
75
|
+
/**
|
|
76
|
+
* Sentinel returned by readNodeFast when the plain-signal fast path does not
|
|
77
|
+
* apply and the caller must fall back to the full read().
|
|
78
|
+
*/
|
|
79
|
+
export declare const READ_SLOW: unique symbol;
|
|
80
|
+
/**
|
|
81
|
+
* read()'s plain-signal fast path as a standalone entry for hot callers
|
|
82
|
+
* (store traps). Safe to substitute for read() only because the bail
|
|
83
|
+
* conditions mirror read()'s prelude and fast-path guard exactly: the
|
|
84
|
+
* latestRead and pendingCheck windows run side-effectful hooks before the
|
|
85
|
+
* fast path, `_fn` nodes need prepareComputed, and firewall / override /
|
|
86
|
+
* snapshot / transition / lane / dev-strictRead state all take the full
|
|
87
|
+
* resolution. Anything slow returns READ_SLOW; the caller then calls read().
|
|
88
|
+
*/
|
|
89
|
+
export declare function readNodeFast<T>(el: Signal<T>): T | typeof READ_SLOW;
|
|
56
90
|
export declare function read<T>(el: Signal<T> | Computed<T>): T;
|
|
57
91
|
export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
|
|
92
|
+
/**
|
|
93
|
+
* Suppresses automatic recomputation of `el` until the scheduler drains. Used
|
|
94
|
+
* when a manual write should win over dependency changes queued in the same
|
|
95
|
+
* tick. The MANUAL_WRITE flag is cleared by the pending-node drain; projection
|
|
96
|
+
* computeds don't commit values, but they still need the same end-of-tick
|
|
97
|
+
* cleanup point.
|
|
98
|
+
*/
|
|
99
|
+
export declare function suppressComputedRecompute(el: Computed<unknown>): void;
|
|
100
|
+
/**
|
|
101
|
+
* User-facing setter for the memo form of `createSignal(fn)`. Behaves like
|
|
102
|
+
* `setSignal`, but also cancels any pending recompute of the memo so the
|
|
103
|
+
* manual value wins over a value that would otherwise be produced by an
|
|
104
|
+
* upstream change in the same tick.
|
|
105
|
+
*/
|
|
106
|
+
export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
|
|
58
107
|
/**
|
|
59
108
|
* Executes `fn` with the given `owner` set as the current owner. Any reactive
|
|
60
109
|
* primitives (`createSignal`, `createMemo`, `createEffect`, `onCleanup`,
|
|
@@ -75,56 +124,15 @@ export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev:
|
|
|
75
124
|
* ```
|
|
76
125
|
*/
|
|
77
126
|
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
|
|
78
|
-
/**
|
|
79
|
-
* Update _pendingSignal when pending state changes. When the override clears
|
|
80
|
-
* (pending -> not pending), merge the sub-lane into the source's lane so
|
|
81
|
-
* isPending effects are blocked until the full scope resolves.
|
|
82
|
-
*/
|
|
83
|
-
export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
|
|
84
127
|
export declare function staleValues<T>(fn: () => T, set?: boolean): T;
|
|
85
128
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* inside `fn` are still in flight.
|
|
89
|
-
*
|
|
90
|
-
* Useful inside a `<Loading>` boundary's children when you want to keep
|
|
91
|
-
* showing the previous resolved data instead of the fallback while the next
|
|
92
|
-
* value loads.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```tsx
|
|
96
|
-
* <Loading fallback={<Skeleton />}>
|
|
97
|
-
* {/* During a transition, render the previous user instead of skeleton: *\/}
|
|
98
|
-
* <UserCard user={latest(() => user())} />
|
|
99
|
-
* </Loading>
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
export declare function latest<T>(fn: () => T): T;
|
|
103
|
-
/**
|
|
104
|
-
* Returns `true` if any reactive read inside `fn` is currently in a pending
|
|
105
|
-
* (async, not-yet-settled) state. Does not subscribe — pair with a tracked
|
|
106
|
-
* memo if you want to react to pending status changes.
|
|
107
|
-
*
|
|
108
|
-
* Useful for showing inline transition indicators alongside the previous
|
|
109
|
-
* value (rather than swapping to a `<Loading>` fallback).
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```tsx
|
|
113
|
-
* const pending = createMemo(() => isPending(() => user()));
|
|
114
|
-
*
|
|
115
|
-
* <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
export declare function isPending(fn: () => any): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Forces a reactive source to re-execute, even if its inputs haven't changed.
|
|
129
|
+
* Invalidates one reactive source, forcing it to re-execute even if its inputs
|
|
130
|
+
* haven't changed.
|
|
121
131
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* `createStore(fn, ...)` or `createProjection(...)` and the projection
|
|
127
|
-
* recomputes.
|
|
132
|
+
* Pass either a Solid-created accessor or a projected store created from
|
|
133
|
+
* `createStore(fn, ...)` / `createProjection(...)`. `refresh()` is a
|
|
134
|
+
* write-like invalidation operation: it does not read the target's value, and
|
|
135
|
+
* refreshing a plain signal accessor is a no-op.
|
|
128
136
|
*
|
|
129
137
|
* Use it to invalidate cached async values (e.g. force a re-fetch) without
|
|
130
138
|
* tearing the consumer down.
|
|
@@ -137,17 +145,4 @@ export declare function isPending(fn: () => any): boolean;
|
|
|
137
145
|
* <button onClick={() => refresh(user)}>Reload</button>
|
|
138
146
|
* ```
|
|
139
147
|
*/
|
|
140
|
-
export declare function refresh<T>(
|
|
141
|
-
/**
|
|
142
|
-
* Returns `true` while a `refresh()` call is in progress. Useful for showing
|
|
143
|
-
* a "refreshing" indicator distinct from the initial-load `<Loading>`
|
|
144
|
-
* fallback.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```tsx
|
|
148
|
-
* <Show when={isRefreshing()}>
|
|
149
|
-
* <span class="badge">refreshing…</span>
|
|
150
|
-
* </Show>
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
export declare function isRefreshing(): boolean;
|
|
148
|
+
export declare function refresh<T>(target: Refreshable<T>): void;
|
package/dist/types/core/dev.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ 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" | "
|
|
10
|
-
export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner";
|
|
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";
|
|
10
|
+
export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner" | "error";
|
|
11
11
|
export interface DiagnosticEvent {
|
|
12
12
|
sequence: number;
|
|
13
13
|
code: DiagnosticCode;
|
|
@@ -39,7 +39,22 @@ export interface Dev {
|
|
|
39
39
|
getObservers: typeof getObservers;
|
|
40
40
|
}
|
|
41
41
|
export declare const DEV: Dev;
|
|
42
|
+
/**
|
|
43
|
+
* Dev-mode internal consistency check. A failure means the reactive system
|
|
44
|
+
* contradicted itself (not that user code misbehaved) — see
|
|
45
|
+
* INTERNALS-ASYNC-STATE.md for the invariant catalog. Throws under __TEST__
|
|
46
|
+
* so the suite (and fuzzing) treats any violation as a hard failure; logs in
|
|
47
|
+
* dev builds so user apps degrade instead of crashing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertInvariant(condition: boolean, name: string, message: string): void;
|
|
42
50
|
export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
|
|
51
|
+
/**
|
|
52
|
+
* Shared strict-read diagnostics for core read() and the store proxy traps.
|
|
53
|
+
* Single source for the message text — the #2897 safeguard parity between
|
|
54
|
+
* memos and stores is exactly these firing identically from both paths.
|
|
55
|
+
*/
|
|
56
|
+
export declare function throwPendingUntrackedRead(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "data">>): never;
|
|
57
|
+
export declare function warnStrictReadUntracked(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence">>): void;
|
|
43
58
|
export declare function registerGraph(value: any, owner: Owner | null): void;
|
|
44
59
|
export declare function clearSignals(node: Owner): void;
|
|
45
60
|
export declare function getChildren(owner: Owner): Owner[];
|
|
@@ -2,10 +2,10 @@ import type { Computed, NodeOptions, Owner } from "./types.js";
|
|
|
2
2
|
export interface Effect<T> extends Computed<T>, Owner {
|
|
3
3
|
_effectFn: (val: T, prev: T | undefined) => void | (() => void);
|
|
4
4
|
_errorFn?: (err: unknown, cleanup: () => void) => void;
|
|
5
|
-
_cleanup?: () => void;
|
|
6
5
|
_modified: boolean;
|
|
7
6
|
_prevValue: T | undefined;
|
|
8
7
|
_type: number;
|
|
8
|
+
_boundRunEffect?: () => void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
|
|
@@ -18,7 +18,6 @@ export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (
|
|
|
18
18
|
schedule?: boolean;
|
|
19
19
|
}): void;
|
|
20
20
|
export interface TrackedEffect extends Computed<void> {
|
|
21
|
-
_cleanup?: () => void;
|
|
22
21
|
_modified: boolean;
|
|
23
22
|
_type: number;
|
|
24
23
|
_run: () => void;
|
|
@@ -1,4 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by a tracked read whose value is currently pending (an async memo /
|
|
3
|
+
* `createSignal(asyncFn)` / projection / store derivation that hasn't settled
|
|
4
|
+
* yet). Surfacing through the reactive graph is what suspends the consumer
|
|
5
|
+
* scope — the nearest enclosing `<Loading>` boundary catches the throw and
|
|
6
|
+
* renders its fallback until the source resolves.
|
|
7
|
+
*
|
|
8
|
+
* App code rarely catches this directly; `<Loading>` is the canonical
|
|
9
|
+
* handler. The error type is exposed for advanced cases — e.g. interop layers
|
|
10
|
+
* that bridge Solid's pending-throw protocol to a different async strategy,
|
|
11
|
+
* or tests that want to assert on the suspension shape.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Advanced: distinguish "not ready yet" from a real error in custom
|
|
16
|
+
* // boundary plumbing. App code should rely on `<Loading>` / `<Errored>`.
|
|
17
|
+
* try {
|
|
18
|
+
* const value = readReactiveSource();
|
|
19
|
+
* } catch (err) {
|
|
20
|
+
* if (err instanceof NotReadyError) throw err; // re-throw to suspend
|
|
21
|
+
* reportError(err);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
1
25
|
export declare class NotReadyError extends Error {
|
|
26
|
+
/**
|
|
27
|
+
* Tags a visibility-only notification on the affects() boundary channel:
|
|
28
|
+
* boundaries update display state from it, but the root queue never
|
|
29
|
+
* registers a reporter — marks are invisible to completion accounting by
|
|
30
|
+
* construction.
|
|
31
|
+
*/
|
|
32
|
+
_markVisual?: boolean;
|
|
2
33
|
source: any;
|
|
3
34
|
constructor(source: any);
|
|
4
35
|
}
|
|
@@ -6,6 +37,8 @@ export declare class StatusError extends Error {
|
|
|
6
37
|
source: any;
|
|
7
38
|
constructor(source: any, original: any);
|
|
8
39
|
}
|
|
40
|
+
/** Return the user's error from an internal status wrapper. */
|
|
41
|
+
export declare function unwrapStatusError(error: unknown): unknown;
|
|
9
42
|
export declare class NoOwnerError extends Error {
|
|
10
43
|
constructor();
|
|
11
44
|
}
|
|
@@ -11,16 +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
14
|
export declare function enableExternalSource(config: ExternalSourceConfig): void;
|
|
26
15
|
export declare function _resetExternalSourceConfig(): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Computed, Link, Signal } from "./types.js";
|
|
2
2
|
export declare function unlinkSubs(link: Link): Link | null;
|
|
3
|
+
export declare function trimStaleDeps(el: Computed<any>): void;
|
|
3
4
|
export declare function unobserved(el: Computed<unknown>): void;
|
|
4
|
-
export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any
|
|
5
|
+
export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>, pendingObserver?: boolean): 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,
|
|
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,
|
|
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,59 @@
|
|
|
1
|
+
import type { OptimisticLane } from "./lanes.js";
|
|
2
|
+
import type { Computed, Signal } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Test-mode invariant checks for the async/transition/lane machinery.
|
|
5
|
+
* Catalog and rationale: packages/solid-signals/INTERNALS-ASYNC-STATE.md.
|
|
6
|
+
*
|
|
7
|
+
* These are implementation self-consistency checks, not semantic rules: a
|
|
8
|
+
* violation means the reactive system contradicted itself.
|
|
9
|
+
*
|
|
10
|
+
* They are gated on `__TEST__` (not just `__DEV__`): the per-write Set
|
|
11
|
+
* tracking and per-flush quiescence sweep are too expensive for shipped dev
|
|
12
|
+
* builds and for benchmarks (they showed up as a 5-21% hit across the
|
|
13
|
+
* CodSpeed suite when they ran under `__DEV__`). Call sites stay `__DEV__`
|
|
14
|
+
* guarded so production tree-shakes the calls; each entry point here
|
|
15
|
+
* early-returns unless `__TEST__` is set, so dev builds pay only a no-op
|
|
16
|
+
* call. The test suite (vitest run) defines `__TEST__: true`; benchmark mode
|
|
17
|
+
* defines `__TEST__: false`.
|
|
18
|
+
*/
|
|
19
|
+
type AnyNode = Signal<any> | Computed<any>;
|
|
20
|
+
/** Wired by core.ts at module init to avoid import cycles. */
|
|
21
|
+
export declare const InvariantHooks: {
|
|
22
|
+
pendingProbeActive: (() => boolean) | null;
|
|
23
|
+
/** Fresh oracle for what an isPending companion SHOULD read right now. */
|
|
24
|
+
computePendingState: ((node: AnyNode) => boolean) | null;
|
|
25
|
+
};
|
|
26
|
+
export declare function devTrackHeldPending(node: AnyNode): void;
|
|
27
|
+
export declare function devTrackCompanionOwner(node: AnyNode): void;
|
|
28
|
+
export declare function devTrackOptimistic(node: AnyNode): void;
|
|
29
|
+
export declare function devTrackAffects(node: AnyNode): void;
|
|
30
|
+
/**
|
|
31
|
+
* Open/close the sanctioned registration window. Call sites are `__DEV__`
|
|
32
|
+
* guarded (no prod cost); the code inside the window must not throw.
|
|
33
|
+
*/
|
|
34
|
+
export declare function beginAsyncReporterWrites(): void;
|
|
35
|
+
export declare function endAsyncReporterWrites(): void;
|
|
36
|
+
export declare function createAsyncReporters(): Map<Computed<any>, Set<Computed<any>>>;
|
|
37
|
+
/**
|
|
38
|
+
* INV-2: a node with an *active* override must be registered for reversion in
|
|
39
|
+
* the queue's or a transition's `_optimisticNodes`. An unregistered active
|
|
40
|
+
* override would survive transition completion forever. Runs at the end of
|
|
41
|
+
* every flush (not just quiescence — the invariant holds mid-transition).
|
|
42
|
+
* (There is no revert-target requirement: authoritative values commit
|
|
43
|
+
* silently into `_value` under the override mask — A17 — so reverting is
|
|
44
|
+
* just dropping the override.)
|
|
45
|
+
*/
|
|
46
|
+
export declare function devCheckActiveOverrides(isRegisteredForRevert: (node: AnyNode) => boolean): void;
|
|
47
|
+
/** INV-1: an isPending() probe must never leak past its own call. */
|
|
48
|
+
export declare function devCheckFlushStart(): void;
|
|
49
|
+
/** INV-5: a merged lane's work moved to its root on merge and must stay empty. */
|
|
50
|
+
export declare function devCheckMergedLaneEmpty(lane: OptimisticLane): void;
|
|
51
|
+
export declare function devCensusCompanions(isQueuedForCommit?: (node: AnyNode) => boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Quiescence checks. Run only when the system is fully drained: nothing
|
|
54
|
+
* scheduled, no active/stashed transitions, no live lanes. At that point no
|
|
55
|
+
* transition-scoped state may survive, and the lazily-created companions must
|
|
56
|
+
* agree with a fresh computation of their owner's state.
|
|
57
|
+
*/
|
|
58
|
+
export declare function devCheckQuiescent(isQueuedForCommit: (node: AnyNode) => boolean): void;
|
|
59
|
+
export {};
|
|
@@ -37,6 +37,8 @@ export declare function resolveLane(el: {
|
|
|
37
37
|
export declare function resolveTransition(el: {
|
|
38
38
|
_optimisticLane?: OptimisticLane;
|
|
39
39
|
_transition?: Transition | null;
|
|
40
|
+
_overrideValue?: any;
|
|
41
|
+
_overrideOwner?: Transition | null;
|
|
40
42
|
}): Transition | null | undefined;
|
|
41
43
|
/**
|
|
42
44
|
* Check if a node has an active optimistic override.
|
|
@@ -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;
|
|
@@ -2,7 +2,27 @@ import type { Computed, Disposable, Owner, Root } from "./types.js";
|
|
|
2
2
|
export declare function markDisposal(el: Owner): void;
|
|
3
3
|
export declare function dispose(node: Computed<unknown>): void;
|
|
4
4
|
export declare function disposeChildren(node: Owner, self?: boolean, zombie?: boolean): void;
|
|
5
|
+
/**
|
|
6
|
+
* Allocates and returns the next stable child id for `owner`. Used by
|
|
7
|
+
* hydration plumbing and `createUniqueId`. Not part of the user-facing API.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
5
11
|
export declare function getNextChildId(owner: Owner): string;
|
|
12
|
+
/**
|
|
13
|
+
* The id a freshly-created node inherits: an explicit `options.id` wins;
|
|
14
|
+
* transparent nodes share their parent's id; otherwise the parent's next
|
|
15
|
+
* child id is consumed (or `undefined` outside an id-carrying tree).
|
|
16
|
+
*/
|
|
17
|
+
export declare function inheritId(options: {
|
|
18
|
+
id?: string;
|
|
19
|
+
} | undefined, transparent: boolean, parent: Owner | null | undefined): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the *next* child id for `owner` without consuming it. Used by
|
|
22
|
+
* hydration plumbing to peek at the id a future child will receive.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
6
26
|
export declare function peekNextChildId(owner: Owner): string;
|
|
7
27
|
/**
|
|
8
28
|
* Returns the currently-tracking observer (the computation that subscribes to
|
|
@@ -10,6 +30,15 @@ export declare function peekNextChildId(owner: Owner): string;
|
|
|
10
30
|
* Used by reactive primitives that need to know whether they're inside a
|
|
11
31
|
* tracking scope. App code rarely needs this — see `getOwner()` for the
|
|
12
32
|
* lifecycle owner instead.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Library predicate: only register a hot-path subscription when the
|
|
37
|
+
* // caller is inside a tracking scope (memo / effect compute / JSX).
|
|
38
|
+
* function trackIfTracked(source: () => unknown) {
|
|
39
|
+
* if (getObserver()) source();
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
13
42
|
*/
|
|
14
43
|
export declare function getObserver(): Owner | null;
|
|
15
44
|
/**
|
|
@@ -36,12 +65,30 @@ export declare function getOwner(): Owner | null;
|
|
|
36
65
|
* checks. `cleanup()` is the unchecked primitive used by internals.
|
|
37
66
|
*/
|
|
38
67
|
export declare function cleanup(fn: Disposable): Disposable;
|
|
39
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Returns `true` if the owner has been disposed (or marked zombie pending
|
|
70
|
+
* disposal). Pair with a captured owner to bail out of late callbacks whose
|
|
71
|
+
* surrounding component already unmounted.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* function onSettleSafe(fn: () => void) {
|
|
76
|
+
* const owner = getOwner();
|
|
77
|
+
* queueMicrotask(() => {
|
|
78
|
+
* if (owner && isDisposed(owner)) return; // component unmounted; skip
|
|
79
|
+
* runWithOwner(owner, fn);
|
|
80
|
+
* });
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
40
84
|
export declare function isDisposed(node: Owner): boolean;
|
|
41
85
|
/**
|
|
42
86
|
* Creates a fresh owner attached as a child of the current owner (or as a
|
|
43
|
-
* detached root if there is none).
|
|
44
|
-
*
|
|
87
|
+
* detached root if there is none). Used by framework internals to group
|
|
88
|
+
* cleanups; app code should use `createRoot()` (host a reactive scope outside
|
|
89
|
+
* a component) or `runWithOwner()` (re-enter a captured owner).
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
45
92
|
*/
|
|
46
93
|
export declare function createOwner(options?: {
|
|
47
94
|
id?: string;
|