@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
|
@@ -2,11 +2,17 @@ import { type Refreshable } from "./constants.cjs";
|
|
|
2
2
|
import { type OptimisticLane } from "./lanes.cjs";
|
|
3
3
|
import type { Computed, FirewallSignal, NodeOptions, Owner, Signal } from "./types.cjs";
|
|
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;
|
|
@@ -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.cjs";
|
|
|
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.cjs";
|
|
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.cjs";
|
|
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.cjs";
|
|
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.cjs";
|
|
3
3
|
export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.cjs";
|
|
4
4
|
export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.cjs";
|
|
5
5
|
export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.cjs";
|
|
6
6
|
export { handleAsync } from "./async.cjs";
|
|
7
|
+
export { isPending, latest } from "./verdict.cjs";
|
|
7
8
|
export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.cjs";
|
|
8
9
|
export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.cjs";
|
|
9
10
|
export { action } from "./action.cjs";
|
|
10
|
-
export { flush, Queue, GlobalQueue,
|
|
11
|
+
export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.cjs";
|
|
11
12
|
export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.cjs";
|
|
12
13
|
export * from "./constants.cjs";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { OptimisticLane } from "./lanes.cjs";
|
|
2
|
+
import type { Computed, Signal } from "./types.cjs";
|
|
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.cjs";
|
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Heap } from "./heap.cjs";
|
|
2
|
-
import { activeLanes, assignOrMergeLane, findLane } from "./lanes.cjs";
|
|
2
|
+
import { activeLanes, assignOrMergeLane, findLane, type OptimisticLane } from "./lanes.cjs";
|
|
3
3
|
import type { Computed, Signal } from "./types.cjs";
|
|
4
4
|
export { activeLanes, assignOrMergeLane, findLane };
|
|
5
5
|
export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.cjs";
|
|
@@ -11,8 +11,15 @@ export declare let projectionWriteActive: boolean;
|
|
|
11
11
|
export declare let _hitUnhandledAsync: boolean;
|
|
12
12
|
export declare function registerTransientStoreNode(node: Signal<any>): void;
|
|
13
13
|
export declare function resetUnhandledAsync(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Toggles the dev-mode "must be inside a `<Loading>` boundary" enforcement
|
|
16
|
+
* window. Only `render()` calls this — wrapping the initial mount so that a
|
|
17
|
+
* top-level uncaught async read surfaces the diagnostic. Not part of the
|
|
18
|
+
* user-facing API.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
14
22
|
export declare function enforceLoadingBoundary(enabled: boolean): void;
|
|
15
|
-
export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
|
|
16
23
|
export declare function setProjectionWriteActive(value: boolean): void;
|
|
17
24
|
export declare function setTrackedQueueCallback(value: boolean): void;
|
|
18
25
|
export type QueueCallback = (type: number) => void;
|
|
@@ -26,6 +33,7 @@ export interface Transition {
|
|
|
26
33
|
_asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
|
|
27
34
|
_pendingNodes: Signal<any>[];
|
|
28
35
|
_optimisticNodes: OptimisticNode[];
|
|
36
|
+
_affectsNodes: OptimisticNode[];
|
|
29
37
|
_optimisticStores: Set<any>;
|
|
30
38
|
_actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
|
|
31
39
|
_queueStash: QueueStub;
|
|
@@ -33,6 +41,14 @@ export interface Transition {
|
|
|
33
41
|
_gatedSubs: Set<Computed<any>>;
|
|
34
42
|
}
|
|
35
43
|
export declare function schedule(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Permanently halts the reactive system. Called when a user error escapes
|
|
46
|
+
* every boundary — app state is undefined at that point, so scheduling stops
|
|
47
|
+
* entirely rather than limping along with a half-applied update.
|
|
48
|
+
*/
|
|
49
|
+
export declare function haltReactivity(cause?: unknown): void;
|
|
50
|
+
/** @internal Test/dev-reload hook. Revives scheduling after a halt. */
|
|
51
|
+
export declare function resetErrorHalt(): void;
|
|
36
52
|
export interface IQueue {
|
|
37
53
|
enqueue(type: number, fn: QueueCallback): void;
|
|
38
54
|
run(type: number): boolean | void;
|
|
@@ -48,6 +64,7 @@ export declare class Queue implements IQueue {
|
|
|
48
64
|
_parent: IQueue | null;
|
|
49
65
|
_queues: [QueueCallback[], QueueCallback[]];
|
|
50
66
|
_children: IQueue[];
|
|
67
|
+
_ranAt: number;
|
|
51
68
|
created: number;
|
|
52
69
|
addChild(child: IQueue): void;
|
|
53
70
|
removeChild(child: IQueue): void;
|
|
@@ -59,28 +76,72 @@ export declare class Queue implements IQueue {
|
|
|
59
76
|
}
|
|
60
77
|
export declare class GlobalQueue extends Queue {
|
|
61
78
|
_running: boolean;
|
|
62
|
-
|
|
63
|
-
_optimisticNodes: OptimisticNode[];
|
|
64
|
-
_optimisticStores: Set<any>;
|
|
79
|
+
_batch: Transition;
|
|
65
80
|
static _update: (el: Computed<unknown>) => void;
|
|
66
81
|
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
67
|
-
static
|
|
82
|
+
static _runEffect: (el: Computed<unknown>) => void;
|
|
83
|
+
static _clearOptimisticStores: ((stores: Set<any>, completing: Transition | null) => void) | null;
|
|
84
|
+
static _releaseAffectsScope: ((node: OptimisticNode) => void) | null;
|
|
85
|
+
static _releaseAffectsMarks: ((nodes: OptimisticNode[]) => void) | null;
|
|
86
|
+
static _markAffects: ((node: OptimisticNode) => void) | null;
|
|
87
|
+
static _releaseAffectsMark: ((node: OptimisticNode) => void) | null;
|
|
88
|
+
static _wireExternalSource: ((self: Computed<any>) => void) | null;
|
|
89
|
+
static _externalUntrack: (<T>(fn: () => T) => T) | null;
|
|
90
|
+
static _syncCompanions: (<T>(el: Signal<T> | Computed<T>, value: T) => void) | null;
|
|
91
|
+
static _updatePendingSignal: ((el: OptimisticNode) => void) | null;
|
|
92
|
+
static _updateChildCompanions: ((el: Computed<any>) => void) | null;
|
|
93
|
+
static _snapCompanions: ((el: OptimisticNode) => void) | null;
|
|
94
|
+
static _latestRead: (<T>(el: Signal<T> | Computed<T>) => T) | null;
|
|
95
|
+
static _pendingCheck: ((el: OptimisticNode, c: Computed<any> | null, owner: OptimisticNode, firewall: Computed<any> | null) => void) | null;
|
|
96
|
+
static _recordFresh: ((el: OptimisticNode, value: any) => void) | null;
|
|
97
|
+
static _applyReask: ((el: Computed<any>, hadReask: boolean) => boolean) | null;
|
|
98
|
+
static _repollVerdicts: ((el: Computed<any>, snap?: boolean) => void) | null;
|
|
99
|
+
static _witnessAffects: ((node: OptimisticNode) => void) | null;
|
|
100
|
+
static _optimisticWrite: (<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)) => T) | null;
|
|
101
|
+
static _resolveOptimistic: ((nodes: OptimisticNode[]) => void) | null;
|
|
102
|
+
static _transitionBlocked: ((transition: Transition) => boolean) | null;
|
|
103
|
+
static _cleanupLanes: ((completingTransition: Transition | null) => void) | null;
|
|
104
|
+
static _runLaneEffects: ((type: number) => void) | null;
|
|
105
|
+
static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
|
|
106
|
+
static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
|
|
107
|
+
static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
|
|
108
|
+
static _recomputeLane: ((el: Computed<any>, own: boolean) => OptimisticLane | null) | null;
|
|
109
|
+
static _laneAsyncPending: ((el: Computed<any>) => void) | null;
|
|
110
|
+
static _laneAsyncSettled: ((el: Computed<any>) => void) | null;
|
|
111
|
+
static _trackOptimisticStore: ((store: any) => void) | null;
|
|
68
112
|
flush(): void;
|
|
69
113
|
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
70
114
|
initTransition(transition?: Transition | null): void;
|
|
71
115
|
}
|
|
116
|
+
export declare function queuePendingNode(node: Signal<any>): void;
|
|
117
|
+
export declare function armReaskClear(): void;
|
|
72
118
|
export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
|
|
73
119
|
export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
|
|
74
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Count of live `affects()` registrations across the system (including
|
|
122
|
+
* store-scope inherited marks). Gates the read-path mark check in `read()` so
|
|
123
|
+
* graphs that never use the feature pay one integer compare.
|
|
124
|
+
*/
|
|
125
|
+
export declare let activeAffectsMarks: number;
|
|
126
|
+
/**
|
|
127
|
+
* Counter mutation seam for the mark engine in affects.ts: an imported `let`
|
|
128
|
+
* binding is read-only, and the read-path gate above must stay a plain module
|
|
129
|
+
* variable so `read()` pays one integer compare, not a function call.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function shiftAffectsMarks(delta: 1 | -1): void;
|
|
75
134
|
export declare const globalQueue: GlobalQueue;
|
|
76
135
|
/**
|
|
77
|
-
* Synchronously processes the pending reactive queue
|
|
78
|
-
*
|
|
136
|
+
* Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
|
|
137
|
+
* flush scope before draining the queue.
|
|
79
138
|
*
|
|
80
139
|
* Reactive updates are normally batched onto the microtask queue, so multiple
|
|
81
140
|
* writes in a row collapse into a single update pass. Call `flush()` when you
|
|
82
141
|
* need to *observe* the result of those writes synchronously — most commonly
|
|
83
|
-
* in tests, but also at the boundary of imperative integration code.
|
|
142
|
+
* in tests, but also at the boundary of imperative integration code. Pass a
|
|
143
|
+
* callback when the writes themselves should bypass microtask scheduling and
|
|
144
|
+
* drain synchronously when the callback returns.
|
|
84
145
|
*
|
|
85
146
|
* @example
|
|
86
147
|
* ```ts
|
|
@@ -90,9 +151,20 @@ export declare const globalQueue: GlobalQueue;
|
|
|
90
151
|
* setCount(5);
|
|
91
152
|
* flush();
|
|
92
153
|
* expect(doubled()).toBe(10);
|
|
154
|
+
*
|
|
155
|
+
* flush(() => setCount(6));
|
|
156
|
+
* expect(doubled()).toBe(12);
|
|
157
|
+
*
|
|
158
|
+
* // Nested flushes drain at each level:
|
|
159
|
+
* flush(() => {
|
|
160
|
+
* setCount(7);
|
|
161
|
+
* flush(() => setCount(8)); // inner drain — effects fire here
|
|
162
|
+
* // outer continues with up-to-date state
|
|
163
|
+
* });
|
|
93
164
|
* ```
|
|
94
165
|
*/
|
|
95
166
|
export declare function flush(): void;
|
|
167
|
+
export declare function flush<T>(fn: () => T): T;
|
|
96
168
|
export declare function currentTransition(transition: Transition): Transition;
|
|
97
169
|
export declare function setActiveTransition(transition: Transition | null): void;
|
|
98
170
|
export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
|