@solidjs/signals 2.0.0-rc.6 → 2.0.0-rc.8
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/dist/dev-shared.js +5243 -0
- package/dist/dev.attribution.js +2333 -0
- package/dist/dev.js +1758 -6621
- package/dist/observe/affects.js +127 -0
- package/dist/observe/attribution.js +1 -0
- package/dist/observe/boundaries.js +586 -0
- package/dist/observe/core/action.js +167 -0
- package/dist/observe/core/async.js +736 -0
- package/dist/observe/core/attribution-hooks.js +60 -0
- package/dist/observe/core/attribution.js +2318 -0
- package/dist/{types-cjs/core/constants.d.cts → observe/core/constants.js} +135 -71
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1289 -0
- package/dist/observe/core/dev.js +232 -0
- package/dist/observe/core/effect.js +179 -0
- package/dist/observe/core/error.js +80 -0
- package/dist/observe/core/external.js +98 -0
- package/dist/observe/core/graph.js +155 -0
- package/dist/observe/core/heap.js +147 -0
- package/dist/observe/core/invariants.js +43 -0
- package/dist/observe/core/lanes.js +168 -0
- package/dist/observe/core/optimistic.js +438 -0
- package/dist/observe/core/owner.js +308 -0
- package/dist/observe/core/scheduler.js +1190 -0
- package/dist/observe/core/verdict.js +551 -0
- package/dist/observe/index.js +55 -0
- package/dist/observe/map.js +482 -0
- package/dist/{types-cjs/signals.d.cts → observe/signals.js} +305 -317
- package/dist/observe/store/index.js +38 -0
- package/dist/observe/store/next/optimistic.js +651 -0
- package/dist/observe/store/next/projection.js +242 -0
- package/dist/observe/store/next/reconcile.js +373 -0
- package/dist/observe/store/next/store.js +2213 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +323 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +210 -0
- package/dist/prod/attribution.js +32 -0
- package/dist/prod/boundaries.js +3 -1
- package/dist/prod/core/action.js +52 -32
- package/dist/prod/core/async.js +177 -128
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +32 -1
- package/dist/prod/core/context.js +10 -16
- package/dist/prod/core/core.js +505 -286
- package/dist/prod/core/dev.js +2 -0
- package/dist/prod/core/effect.js +72 -43
- package/dist/prod/core/external.js +2 -2
- package/dist/prod/core/graph.js +40 -36
- package/dist/prod/core/heap.js +50 -51
- package/dist/prod/core/lanes.js +43 -22
- package/dist/prod/core/optimistic.js +224 -80
- package/dist/prod/core/owner.js +43 -39
- package/dist/prod/core/scheduler.js +347 -232
- package/dist/prod/core/verdict.js +71 -74
- package/dist/prod/index.js +9 -5
- package/dist/prod/map.js +311 -150
- package/dist/prod/signals.js +52 -38
- package/dist/prod/store/next/optimistic.js +127 -131
- package/dist/prod/store/next/projection.js +3 -3
- package/dist/prod/store/next/reconcile.js +149 -294
- package/dist/prod/store/next/store.js +694 -380
- package/dist/prod/store/next/target.js +32 -10
- package/dist/prod/store/store.js +12 -14
- package/dist/prod/store/utils.js +36 -27
- package/dist/types/attribution.d.ts +15 -0
- package/dist/types/attribution.prod.d.ts +13 -0
- package/dist/types/core/async.d.ts +1 -1
- package/dist/types/core/attribution-hooks.d.ts +183 -6
- package/dist/types/core/attribution.d.ts +435 -24
- package/dist/types/core/constants.d.ts +31 -0
- package/dist/types/core/core.d.ts +19 -3
- package/dist/types/core/dev.d.ts +165 -26
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/heap.d.ts +5 -3
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/invariants.d.ts +1 -1
- package/dist/types/core/lanes.d.ts +17 -0
- package/dist/types/core/scheduler.d.ts +69 -4
- package/dist/types/core/types.d.ts +29 -9
- package/dist/types/index.d.ts +9 -2
- package/dist/types/map.d.ts +2 -0
- package/dist/types/signals.d.ts +10 -0
- package/dist/types/store/index.d.ts +4 -6
- package/dist/types/store/next/optimistic.d.ts +4 -2
- package/dist/types/store/next/reconcile.d.ts +5 -12
- package/dist/types/store/next/store.d.ts +8 -9
- package/dist/types/store/next/target.d.ts +56 -55
- package/dist/types/store/store.d.ts +14 -9
- package/dist/types/store/utils.d.ts +7 -0
- package/package.json +21 -16
- package/dist/node.cjs +0 -11121
- package/dist/prod/store/next/patch-hooks.js +0 -13
- package/dist/prod/store/next/patch.js +0 -614
- package/dist/types/store/next/patch-hooks.d.ts +0 -41
- package/dist/types/store/next/patch.d.ts +0 -91
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -23
- package/dist/types-cjs/core/attribution-hooks.d.cts +0 -63
- package/dist/types-cjs/core/attribution.d.cts +0 -239
- package/dist/types-cjs/core/core.d.cts +0 -176
- package/dist/types-cjs/core/dev.d.cts +0 -95
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -56
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -28
- package/dist/types-cjs/core/heap.d.cts +0 -22
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -44
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -231
- package/dist/types-cjs/core/types.d.cts +0 -204
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/store/index.d.cts +0 -21
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -23
- package/dist/types-cjs/store/next/patch-hooks.d.cts +0 -41
- package/dist/types-cjs/store/next/patch.d.cts +0 -91
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -17
- package/dist/types-cjs/store/next/store.d.cts +0 -127
- package/dist/types-cjs/store/next/target.d.cts +0 -192
- package/dist/types-cjs/store/store.d.cts +0 -138
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -74
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { ContextNotFoundError, NoOwnerError, NotReadyError, TimeoutError } from "./error.cjs";
|
|
2
|
-
export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, installAuthoritativeRead, markRefresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
|
|
3
|
-
export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.cjs";
|
|
4
|
-
export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.cjs";
|
|
5
|
-
export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.cjs";
|
|
6
|
-
export { handleAsync } from "./async.cjs";
|
|
7
|
-
export { isPending, latest } from "./verdict.cjs";
|
|
8
|
-
export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.cjs";
|
|
9
|
-
export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.cjs";
|
|
10
|
-
export { action } from "./action.cjs";
|
|
11
|
-
export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.cjs";
|
|
12
|
-
export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.cjs";
|
|
13
|
-
export * from "./constants.cjs";
|
|
@@ -1,59 +0,0 @@
|
|
|
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/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 {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type QueueCallback, type Transition } from "./scheduler.cjs";
|
|
2
|
-
import type { Computed, Signal } from "./types.cjs";
|
|
3
|
-
/**
|
|
4
|
-
* OptimisticLane represents the context for a single optimistic write.
|
|
5
|
-
* Each optimistic signal creates its own lane. Lanes merge when their
|
|
6
|
-
* dependency graphs overlap.
|
|
7
|
-
*/
|
|
8
|
-
export interface OptimisticLane {
|
|
9
|
-
_source: Signal<any>;
|
|
10
|
-
_pendingAsync: Set<Computed<any>>;
|
|
11
|
-
_effectQueues: [QueueCallback[], QueueCallback[]];
|
|
12
|
-
_mergedInto: OptimisticLane | null;
|
|
13
|
-
_transition: Transition | null;
|
|
14
|
-
_parentLane: OptimisticLane | null;
|
|
15
|
-
}
|
|
16
|
-
export declare const signalLanes: WeakMap<Signal<any>, OptimisticLane>;
|
|
17
|
-
export declare const activeLanes: Set<OptimisticLane>;
|
|
18
|
-
/**
|
|
19
|
-
* Get an existing lane for a signal or create a new one.
|
|
20
|
-
* Reuses lane for multiple writes to the same signal.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getOrCreateLane(signal: Signal<any>): OptimisticLane;
|
|
23
|
-
/**
|
|
24
|
-
* Union-find: find the root lane.
|
|
25
|
-
*/
|
|
26
|
-
export declare function findLane(lane: OptimisticLane): OptimisticLane;
|
|
27
|
-
/**
|
|
28
|
-
* Merge two lanes when their dependency graphs overlap.
|
|
29
|
-
*/
|
|
30
|
-
export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
|
|
31
|
-
/**
|
|
32
|
-
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
33
|
-
*/
|
|
34
|
-
export declare function resolveLane(el: Signal<any> | Computed<any>): OptimisticLane | undefined;
|
|
35
|
-
export declare function resolveTransition(el: Signal<any> | Computed<any>): Transition | null | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Check if a node has an active optimistic override.
|
|
38
|
-
*/
|
|
39
|
-
export declare function hasActiveOverride(el: Signal<any> | Computed<any>): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Assign or merge a lane onto a node. At convergence points (node already has
|
|
42
|
-
* a different active lane), merge unless the node has an active override.
|
|
43
|
-
*/
|
|
44
|
-
export declare function assignOrMergeLane(el: Signal<any> | Computed<any>, sourceLane: OptimisticLane): void;
|
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Computed, Disposable, Owner, Root } from "./types.cjs";
|
|
2
|
-
export declare function markDisposal(el: Owner): void;
|
|
3
|
-
export declare function dispose(node: Computed<unknown>): void;
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
26
|
-
export declare function peekNextChildId(owner: Owner): string;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the currently-tracking observer (the computation that subscribes to
|
|
29
|
-
* reactive reads at this point), or `null` if reads here would be untracked.
|
|
30
|
-
* Used by reactive primitives that need to know whether they're inside a
|
|
31
|
-
* tracking scope. App code rarely needs this — see `getOwner()` for the
|
|
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
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function getObserver(): Owner | null;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the current reactive **owner** — the lifecycle node that the next
|
|
46
|
-
* `cleanup()` / `onCleanup()` / `createSignal()` etc. will be attached to.
|
|
47
|
-
*
|
|
48
|
-
* Returns `null` if called outside any owner. Capture the owner with
|
|
49
|
-
* `getOwner()` and re-enter it later with `runWithOwner(owner, fn)` to attach
|
|
50
|
-
* disposables created from a callback (event handler, async resolution, etc.)
|
|
51
|
-
* back to a component's lifecycle.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* function defer<T>(fn: () => T) {
|
|
56
|
-
* const owner = getOwner();
|
|
57
|
-
* queueMicrotask(() => runWithOwner(owner, fn));
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare function getOwner(): Owner | null;
|
|
62
|
-
/**
|
|
63
|
-
* Low-level: registers `fn` as a disposal callback on the current owner.
|
|
64
|
-
* Most code should use `onCleanup()` from `solid-js`, which adds dev-mode
|
|
65
|
-
* checks. `cleanup()` is the unchecked primitive used by internals.
|
|
66
|
-
*/
|
|
67
|
-
export declare function cleanup(fn: Disposable): Disposable;
|
|
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
|
-
*/
|
|
84
|
-
export declare function isDisposed(node: Owner): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Creates a fresh owner attached as a child of the current owner (or as a
|
|
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
|
|
92
|
-
*/
|
|
93
|
-
export declare function createOwner(options?: {
|
|
94
|
-
id?: string;
|
|
95
|
-
transparent?: boolean;
|
|
96
|
-
}): Root;
|
|
97
|
-
/**
|
|
98
|
-
* Creates a detached reactive root. The callback receives a `dispose()`
|
|
99
|
-
* function which, when called, tears down every signal, memo, effect, and
|
|
100
|
-
* `onCleanup` registered inside the root.
|
|
101
|
-
*
|
|
102
|
-
* Use this to host long-lived reactive scopes outside of a component (custom
|
|
103
|
-
* controllers, app bootstrapping, tests). Inside a component, prefer
|
|
104
|
-
* letting Solid's component lifecycle own things.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```ts
|
|
108
|
-
* const dispose = createRoot(dispose => {
|
|
109
|
-
* const [n, setN] = createSignal(0);
|
|
110
|
-
* createEffect(() => n(), value => console.log(value));
|
|
111
|
-
* setInterval(() => setN(x => x + 1), 1000);
|
|
112
|
-
* return dispose;
|
|
113
|
-
* });
|
|
114
|
-
*
|
|
115
|
-
* // Later, to tear everything down:
|
|
116
|
-
* dispose();
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
|
|
120
|
-
*/
|
|
121
|
-
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
122
|
-
id?: string;
|
|
123
|
-
transparent?: boolean;
|
|
124
|
-
}): T;
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { type Heap } from "./heap.cjs";
|
|
2
|
-
import { activeLanes, assignOrMergeLane, findLane, type OptimisticLane } from "./lanes.cjs";
|
|
3
|
-
import type { Computed, Signal } from "./types.cjs";
|
|
4
|
-
export { activeLanes, assignOrMergeLane, findLane };
|
|
5
|
-
export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.cjs";
|
|
6
|
-
export declare const dirtyQueue: Heap;
|
|
7
|
-
export declare const zombieQueue: Heap;
|
|
8
|
-
export declare let clock: number;
|
|
9
|
-
export declare let activeTransition: Transition | null;
|
|
10
|
-
export declare let projectionWriteActive: boolean;
|
|
11
|
-
export declare let _hitUnhandledAsync: boolean;
|
|
12
|
-
export declare function resetUnhandledAsync(): void;
|
|
13
|
-
/**
|
|
14
|
-
* Toggles the dev-mode "must be inside a `<Loading>` boundary" enforcement
|
|
15
|
-
* window. Only `render()` calls this — wrapping the initial mount so that a
|
|
16
|
-
* top-level uncaught async read surfaces the diagnostic. Not part of the
|
|
17
|
-
* user-facing API.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
export declare function enforceLoadingBoundary(enabled: boolean): void;
|
|
22
|
-
export declare function setProjectionWriteActive(value: boolean): void;
|
|
23
|
-
export declare function setTrackedQueueCallback(value: boolean): void;
|
|
24
|
-
export declare function setEffectCallback(value: boolean): void;
|
|
25
|
-
export type QueueCallback = (type: number) => void;
|
|
26
|
-
type QueueStub = {
|
|
27
|
-
_queues: [QueueCallback[], QueueCallback[]];
|
|
28
|
-
_children: QueueStub[];
|
|
29
|
-
};
|
|
30
|
-
type OptimisticNode = Signal<any> | Computed<any>;
|
|
31
|
-
export interface Transition {
|
|
32
|
-
_time: number;
|
|
33
|
-
_asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
|
|
34
|
-
_pendingNodes: Signal<any>[];
|
|
35
|
-
_optimisticNodes: OptimisticNode[];
|
|
36
|
-
_affectsNodes: OptimisticNode[];
|
|
37
|
-
_optimisticStores: Set<any>;
|
|
38
|
-
_actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
|
|
39
|
-
_queueStash: QueueStub;
|
|
40
|
-
_done: boolean | Transition;
|
|
41
|
-
_gatedSubs: Set<Computed<any>>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Flip-entanglement (#3164 follow-up): `until()` is a declaration of
|
|
45
|
-
* relatedness — the predicate names the condition that confirms the awaiting
|
|
46
|
-
* transaction. When the predicate settles truthy, every live foreign
|
|
47
|
-
* transition whose staged write it read IS the confirming event by the
|
|
48
|
-
* user's own definition, so it merges into the awaiting transaction and
|
|
49
|
-
* reveals at the joint settle — the cross-primitive twin of the family fold
|
|
50
|
-
* (a landing on an optimism-carrying family joins the retaining
|
|
51
|
-
* transaction). Non-flipping updates never pass through here: falsy
|
|
52
|
-
* evaluations don't entangle, so unrelated traffic on the watched sources
|
|
53
|
-
* reveals freely on its own schedule.
|
|
54
|
-
*
|
|
55
|
-
* Runs inside the predicate's compute (pure phase) — the confirming
|
|
56
|
-
* transition's stamps are still live and its commit decision hasn't run, so
|
|
57
|
-
* the merge lands before any reveal. Only the tree-shaken graphs that call
|
|
58
|
-
* `until()` retain this.
|
|
59
|
-
*/
|
|
60
|
-
export declare function entangleConfirmingTransitions(obs: Computed<any>, target: Transition): void;
|
|
61
|
-
export declare function schedule(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Permanently halts the reactive system. Called when a user error escapes
|
|
64
|
-
* every boundary — app state is undefined at that point, so scheduling stops
|
|
65
|
-
* entirely rather than limping along with a half-applied update.
|
|
66
|
-
*/
|
|
67
|
-
export declare function haltReactivity(cause?: unknown): void;
|
|
68
|
-
/** @internal Test/dev-reload hook. Revives scheduling after a halt. */
|
|
69
|
-
export declare function resetErrorHalt(): void;
|
|
70
|
-
export interface IQueue {
|
|
71
|
-
enqueue(type: number, fn: QueueCallback): void;
|
|
72
|
-
run(type: number): boolean | void;
|
|
73
|
-
addChild(child: IQueue): void;
|
|
74
|
-
removeChild(child: IQueue): void;
|
|
75
|
-
created: number;
|
|
76
|
-
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
77
|
-
stashQueues(stub: QueueStub): void;
|
|
78
|
-
restoreQueues(stub: QueueStub): void;
|
|
79
|
-
_parent: IQueue | null;
|
|
80
|
-
}
|
|
81
|
-
export declare class Queue implements IQueue {
|
|
82
|
-
_parent: IQueue | null;
|
|
83
|
-
_queues: [QueueCallback[], QueueCallback[]];
|
|
84
|
-
_children: IQueue[];
|
|
85
|
-
_ranAt: number;
|
|
86
|
-
created: number;
|
|
87
|
-
addChild(child: IQueue): void;
|
|
88
|
-
removeChild(child: IQueue): void;
|
|
89
|
-
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
90
|
-
run(type: number): void;
|
|
91
|
-
enqueue(type: number, fn: QueueCallback): void;
|
|
92
|
-
stashQueues(stub: QueueStub): void;
|
|
93
|
-
restoreQueues(stub: QueueStub): void;
|
|
94
|
-
}
|
|
95
|
-
export declare class GlobalQueue extends Queue {
|
|
96
|
-
_running: boolean;
|
|
97
|
-
_batch: Transition;
|
|
98
|
-
static _update: (el: Computed<unknown>) => void;
|
|
99
|
-
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
100
|
-
static _runEffect: (el: Computed<unknown>) => void;
|
|
101
|
-
static _clearOptimisticStores: ((stores: Set<any>, completing: Transition | null) => void) | null;
|
|
102
|
-
static _releaseAffectsScope: ((node: OptimisticNode) => void) | null;
|
|
103
|
-
static _releaseAffectsMarks: ((nodes: OptimisticNode[]) => void) | null;
|
|
104
|
-
static _markAffects: ((node: OptimisticNode) => void) | null;
|
|
105
|
-
static _releaseAffectsMark: ((node: OptimisticNode) => void) | null;
|
|
106
|
-
static _wireExternalSource: ((self: Computed<any>) => void) | null;
|
|
107
|
-
static _externalUntrack: (<T>(fn: () => T) => T) | null;
|
|
108
|
-
static _syncCompanions: (<T>(el: Signal<T> | Computed<T>, value: T) => void) | null;
|
|
109
|
-
static _updatePendingSignal: ((el: OptimisticNode) => void) | null;
|
|
110
|
-
static _updateChildCompanions: ((el: Computed<any>) => void) | null;
|
|
111
|
-
static _snapCompanions: ((el: OptimisticNode) => void) | null;
|
|
112
|
-
static _latestRead: (<T>(el: Signal<T> | Computed<T>) => T) | null;
|
|
113
|
-
static _pendingCheck: ((el: OptimisticNode, c: Computed<any> | null, owner: OptimisticNode, firewall: Computed<any> | null) => void) | null;
|
|
114
|
-
static _recordFresh: ((el: OptimisticNode, value: any) => void) | null;
|
|
115
|
-
static _applyReask: ((el: Computed<any>, hadReask: boolean) => boolean) | null;
|
|
116
|
-
static _repollVerdicts: ((el: Computed<any>, snap?: boolean) => void) | null;
|
|
117
|
-
static _witnessAffects: ((node: OptimisticNode) => void) | null;
|
|
118
|
-
static _wakeSuppressedProbes: ((transition: Transition) => void) | null;
|
|
119
|
-
static _optimisticWrite: (<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)) => T) | null;
|
|
120
|
-
static _resolveOptimistic: ((nodes: OptimisticNode[]) => void) | null;
|
|
121
|
-
static _transitionBlocked: ((transition: Transition) => boolean) | null;
|
|
122
|
-
static _cleanupLanes: ((completingTransition: Transition | null) => void) | null;
|
|
123
|
-
static _runLaneEffects: ((type: number) => void) | null;
|
|
124
|
-
/** Patch-channel optimistic drain (next/patch.ts): optimistic emissions
|
|
125
|
-
* apply at lane-effect timing — visible in flight, unlike the regular
|
|
126
|
-
* effect queues an action stashes. Injected; null when unused. */
|
|
127
|
-
static _drainPatchOptimistic: (() => void) | null;
|
|
128
|
-
static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
|
|
129
|
-
static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
|
|
130
|
-
static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
|
|
131
|
-
static _recomputeLane: ((el: Computed<any>, own: boolean) => OptimisticLane | null | false) | null;
|
|
132
|
-
static _laneAsyncPending: ((el: Computed<any>) => void) | null;
|
|
133
|
-
/** Authoritative-view reader wakeup (until()): installed at first until() call.
|
|
134
|
-
* Call sites are gated by CONFIG_AUTHORITATIVE_OBSERVED, which only until()'s
|
|
135
|
-
* carve-out read can set, so `!` invocations are safe once the gate holds. */
|
|
136
|
-
static _notifyAuthoritativeObservers: ((el: Signal<any> | Computed<any>) => void) | null;
|
|
137
|
-
static _laneAsyncSettled: ((el: Computed<any>) => void) | null;
|
|
138
|
-
static _trackOptimisticStore: ((store: any) => void) | null;
|
|
139
|
-
flush(): void;
|
|
140
|
-
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
141
|
-
initTransition(transition?: Transition | null): void;
|
|
142
|
-
}
|
|
143
|
-
export declare function queuePendingNode(node: Signal<any>): void;
|
|
144
|
-
export declare let reaskArmed: boolean;
|
|
145
|
-
/** §12d: bumped by every recompute and every new subscriber edge. A node's
|
|
146
|
-
* staged-rewrite skip is sound only while NOTHING recomputed or linked since
|
|
147
|
-
* its last notify — a mid-batch pull can clean a marked subscriber, and a
|
|
148
|
-
* skipped re-write would leave it stale. */
|
|
149
|
-
export declare let notifyEpoch: number;
|
|
150
|
-
export declare function bumpNotifyEpoch(): void;
|
|
151
|
-
export declare function armReaskClear(): void;
|
|
152
|
-
export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
|
|
153
|
-
export declare let storeCommitHook: (() => void) | null;
|
|
154
|
-
export declare function setStoreCommitHook(fn: () => void): void;
|
|
155
|
-
/** Patch-channel release hook (next/patch.ts): transition-stamped patch
|
|
156
|
-
* emissions are released when THEIR batch commits. Transitions never
|
|
157
|
-
* abort: failed actions still commit (only optimistic overrides revert),
|
|
158
|
-
* and merged-away transitions hand their stash to the survivor
|
|
159
|
-
* (mergeTransitionState) — every stash drains exactly once. Injected like
|
|
160
|
-
* storeCommitHook to stay tree-shakeable. */
|
|
161
|
-
export declare let patchCommitHook: ((batch: Transition) => void) | null;
|
|
162
|
-
export declare function setPatchCommitHook(fn: (batch: Transition) => void): void;
|
|
163
|
-
export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
|
|
164
|
-
/**
|
|
165
|
-
* Count of live `affects()` registrations across the system (including
|
|
166
|
-
* store-scope inherited marks). Gates the read-path mark check in `read()` so
|
|
167
|
-
* graphs that never use the feature pay one integer compare.
|
|
168
|
-
*/
|
|
169
|
-
export declare let activeAffectsMarks: number;
|
|
170
|
-
/**
|
|
171
|
-
* Counter mutation seam for the mark engine in affects.ts: an imported `let`
|
|
172
|
-
* binding is read-only, and the read-path gate above must stay a plain module
|
|
173
|
-
* variable so `read()` pays one integer compare, not a function call.
|
|
174
|
-
*
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
export declare function shiftAffectsMarks(delta: 1 | -1): void;
|
|
178
|
-
export declare const globalQueue: GlobalQueue;
|
|
179
|
-
/**
|
|
180
|
-
* Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
|
|
181
|
-
* flush scope before draining the queue.
|
|
182
|
-
*
|
|
183
|
-
* Reactive updates are normally batched onto the microtask queue, so multiple
|
|
184
|
-
* writes in a row collapse into a single update pass. Call `flush()` when you
|
|
185
|
-
* need to *observe* the result of those writes synchronously — most commonly
|
|
186
|
-
* in tests, but also at the boundary of imperative integration code. Pass a
|
|
187
|
-
* callback when the writes themselves should bypass microtask scheduling and
|
|
188
|
-
* drain synchronously when the callback returns.
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```ts
|
|
192
|
-
* const [count, setCount] = createSignal(0);
|
|
193
|
-
* const doubled = createMemo(() => count() * 2);
|
|
194
|
-
*
|
|
195
|
-
* setCount(5);
|
|
196
|
-
* flush();
|
|
197
|
-
* expect(doubled()).toBe(10);
|
|
198
|
-
*
|
|
199
|
-
* flush(() => setCount(6));
|
|
200
|
-
* expect(doubled()).toBe(12);
|
|
201
|
-
*
|
|
202
|
-
* // Nested flushes drain at each level:
|
|
203
|
-
* flush(() => {
|
|
204
|
-
* setCount(7);
|
|
205
|
-
* flush(() => setCount(8)); // inner drain — effects fire here
|
|
206
|
-
* // outer continues with up-to-date state
|
|
207
|
-
* });
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
export declare function flush(): void;
|
|
211
|
-
export declare function flush<T>(fn: () => T): T;
|
|
212
|
-
/** A fresh, unentered transaction (#3146): the optimistic store's truth
|
|
213
|
-
* flight DECLARES an owned transaction instead of relying on whatever the
|
|
214
|
-
* ambient adoption machinery stamped on its firewall. Activate it with
|
|
215
|
-
* initTransition; it is a plain batch until then. */
|
|
216
|
-
export declare function createTransition(): Transition;
|
|
217
|
-
export declare function currentTransition(transition: Transition): Transition;
|
|
218
|
-
export declare function setActiveTransition(transition: Transition | null): void;
|
|
219
|
-
export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
|
|
220
|
-
/** Run `fn` with `transition` as BOTH the ambient transaction and the
|
|
221
|
-
* registration batch, restoring both after. runInTransition alone is not
|
|
222
|
-
* enough for code that WRITES on behalf of a transaction from inside someone
|
|
223
|
-
* else's window (optimistic replay re-arming a still-open action's edits
|
|
224
|
-
* during a landing commit, #3123): registrations route through the queue's
|
|
225
|
-
* batch pointer, and a bare activeTransition swap leaves them in the ambient
|
|
226
|
-
* batch — a plain batch "completes" at the next flush and reverts optimistic
|
|
227
|
-
* registrations that were supposed to live with the transaction.
|
|
228
|
-
* initTransition is the wrong tool here: it MERGES the currently ambient
|
|
229
|
-
* transaction into the target, entangling whatever the interrupted window
|
|
230
|
-
* belonged to. */
|
|
231
|
-
export declare function runAsTransitionBatch<T>(transition: Transition, fn: () => T): T;
|