@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.20
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 +6505 -0
- package/dist/dev.attribution.js +3484 -0
- package/dist/dev.js +10227 -9508
- package/dist/observe/affects-marks.js +86 -0
- package/dist/observe/affects.js +112 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +696 -0
- package/dist/observe/core/action.js +182 -0
- package/dist/observe/core/async.js +824 -0
- package/dist/observe/core/attribution-costs.js +66 -0
- package/dist/observe/core/attribution-feedback.js +280 -0
- package/dist/observe/core/attribution-hooks.js +83 -0
- package/dist/observe/core/attribution-queries.js +43 -0
- package/dist/observe/core/attribution.js +3079 -0
- package/dist/observe/core/constants.js +269 -0
- package/dist/observe/core/context.js +63 -0
- package/dist/observe/core/copies.js +10 -0
- package/dist/observe/core/core.js +1707 -0
- package/dist/observe/core/dev.js +394 -0
- package/dist/observe/core/effect.js +193 -0
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/error.js +82 -0
- package/dist/observe/core/external.js +97 -0
- package/dist/observe/core/graph.js +162 -0
- package/dist/observe/core/heap.js +124 -0
- package/dist/observe/core/identities.js +62 -0
- package/dist/observe/core/invariants.js +12 -0
- package/dist/observe/core/lanes.js +972 -0
- package/dist/observe/core/owner.js +371 -0
- package/dist/observe/core/scheduler.js +1157 -0
- package/dist/observe/core/truth.js +47 -0
- package/dist/observe/core/verdict.js +470 -0
- package/dist/observe/deferred.js +186 -0
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/from.js +248 -0
- package/dist/observe/index.js +71 -0
- package/dist/observe/map.js +593 -0
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +717 -0
- package/dist/observe/store/affects.js +142 -0
- package/dist/observe/store/edges.js +39 -0
- package/dist/observe/store/hooks.js +16 -0
- package/dist/observe/store/index.js +47 -0
- package/dist/observe/store/optimistic.js +713 -0
- package/dist/observe/store/projection.js +345 -0
- package/dist/observe/store/reconcile.js +281 -0
- package/dist/observe/store/store.js +2127 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/target.js +46 -0
- package/dist/observe/store/types.js +83 -0
- package/dist/observe/store/utils.js +1063 -0
- package/dist/prod/affects-marks.js +86 -0
- package/dist/prod/affects.js +98 -112
- package/dist/prod/attribution.js +45 -0
- package/dist/prod/boundaries.js +578 -468
- package/dist/prod/core/action.js +92 -59
- package/dist/prod/core/async.js +522 -336
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +168 -44
- package/dist/prod/core/context.js +12 -16
- package/dist/prod/core/copies.js +10 -0
- package/dist/prod/core/core.js +1345 -627
- package/dist/prod/core/dev.js +123 -1
- package/dist/prod/core/effect.js +113 -80
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/error.js +18 -4
- package/dist/prod/core/external.js +6 -7
- package/dist/prod/core/graph.js +119 -72
- package/dist/prod/core/heap.js +85 -109
- package/dist/prod/core/identities.js +62 -0
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +931 -132
- package/dist/prod/core/owner.js +192 -129
- package/dist/prod/core/scheduler.js +948 -642
- package/dist/prod/core/truth.js +47 -0
- package/dist/prod/core/verdict.js +409 -420
- package/dist/prod/deferred.js +184 -0
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/from.js +248 -0
- package/dist/prod/index.js +40 -16
- package/dist/prod/map.js +481 -211
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +401 -84
- package/dist/prod/store/affects.js +142 -0
- package/dist/prod/store/edges.js +39 -0
- package/dist/prod/store/hooks.js +16 -0
- package/dist/prod/store/index.js +27 -18
- package/dist/prod/store/optimistic.js +707 -0
- package/dist/prod/store/projection.js +331 -0
- package/dist/prod/store/reconcile.js +281 -0
- package/dist/prod/store/store.js +1952 -267
- package/dist/prod/store/storePath.js +1 -1
- package/dist/prod/store/target.js +43 -0
- package/dist/prod/store/types.js +83 -0
- package/dist/prod/store/utils.js +997 -138
- package/dist/types/affects-marks.d.ts +14 -0
- package/dist/types/affects.d.ts +12 -30
- package/dist/types/attribution.d.ts +19 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +99 -124
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +23 -9
- package/dist/types/core/async.d.ts +34 -6
- package/dist/types/core/attribution-costs.d.ts +35 -0
- package/dist/types/core/attribution-feedback.d.ts +133 -0
- package/dist/types/core/attribution-hooks.d.ts +307 -8
- package/dist/types/core/attribution-queries.d.ts +24 -0
- package/dist/types/core/attribution.d.ts +802 -72
- package/dist/types/core/constants.d.ts +195 -38
- package/dist/types/core/copies.d.ts +54 -0
- package/dist/types/core/core.d.ts +295 -65
- package/dist/types/core/dev.d.ts +509 -22
- package/dist/types/core/effect.d.ts +1 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/error.d.ts +18 -1
- package/dist/types/core/graph.d.ts +40 -1
- package/dist/types/core/heap.d.ts +5 -5
- package/dist/types/core/identities.d.ts +17 -0
- package/dist/types/core/index.d.ts +11 -7
- package/dist/types/core/invariants.d.ts +1 -26
- package/dist/types/core/lanes.d.ts +74 -43
- package/dist/types/core/owner.d.ts +27 -9
- package/dist/types/core/scheduler.d.ts +353 -102
- package/dist/types/core/truth.d.ts +18 -0
- package/dist/types/core/types.d.ts +97 -71
- package/dist/types/core/verdict.d.ts +35 -0
- package/dist/types/deferred.d.ts +28 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/from.d.ts +47 -0
- package/dist/types/index.d.ts +33 -7
- package/dist/types/map.d.ts +4 -2
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +196 -45
- package/dist/types/store/affects.d.ts +12 -0
- package/dist/types/store/edges.d.ts +9 -0
- package/dist/types/store/hooks.d.ts +62 -0
- package/dist/types/store/index.d.ts +42 -15
- package/dist/types/store/optimistic.d.ts +24 -45
- package/dist/types/store/projection.d.ts +17 -68
- package/dist/types/store/reconcile.d.ts +3 -46
- package/dist/types/store/store.d.ts +133 -136
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +166 -0
- package/dist/types/store/types.d.ts +105 -0
- package/dist/types/store/utils.d.ts +188 -0
- package/package.json +31 -26
- package/dist/node.cjs +0 -8745
- package/dist/prod/core/optimistic.js +0 -265
- package/dist/prod/store/next/optimistic.js +0 -385
- package/dist/prod/store/next/projection.js +0 -172
- package/dist/prod/store/next/reconcile.js +0 -331
- package/dist/prod/store/next/store.js +0 -1499
- package/dist/prod/store/next/target.js +0 -20
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -20
- package/dist/types/store/next/projection.d.ts +0 -8
- package/dist/types/store/next/reconcile.d.ts +0 -3
- package/dist/types/store/next/store.d.ts +0 -77
- package/dist/types/store/next/target.d.ts +0 -117
- 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 -21
- package/dist/types-cjs/core/attribution-hooks.d.cts +0 -52
- package/dist/types-cjs/core/attribution.d.cts +0 -186
- package/dist/types-cjs/core/constants.d.cts +0 -97
- package/dist/types-cjs/core/context.d.cts +0 -36
- package/dist/types-cjs/core/core.d.cts +0 -163
- package/dist/types-cjs/core/dev.d.cts +0 -81
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -47
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -6
- 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 -180
- package/dist/types-cjs/core/types.d.cts +0 -192
- 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/signals.d.cts +0 -624
- package/dist/types-cjs/store/index.d.cts +0 -19
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
- package/dist/types-cjs/store/next/store.d.cts +0 -77
- package/dist/types-cjs/store/next/target.d.cts +0 -117
- package/dist/types-cjs/store/optimistic.d.cts +0 -45
- package/dist/types-cjs/store/projection.d.cts +0 -70
- package/dist/types-cjs/store/reconcile.d.cts +0 -46
- 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,624 +0,0 @@
|
|
|
1
|
-
import type { Disposable, Refreshable } from "./core/index.cjs";
|
|
2
|
-
/**
|
|
3
|
-
* Low-level reactive-cleanup primitive. Registers a callback that runs when
|
|
4
|
-
* the surrounding owner is disposed.
|
|
5
|
-
*
|
|
6
|
-
* **In 2.0 user code this is rare.** The two cases where you might reach for
|
|
7
|
-
* it have better-shaped tools:
|
|
8
|
-
*
|
|
9
|
-
* - **Component lifecycle (mount/unmount, listeners, intervals):** use
|
|
10
|
-
* {@link onSettled} and **return** a cleanup function. Setup and teardown
|
|
11
|
-
* stay paired in one block. This replaces the 1.x `onMount` + `onCleanup`
|
|
12
|
-
* pairing.
|
|
13
|
-
* - **Cleanup tied to an effect run:** `onCleanup` does not belong in
|
|
14
|
-
* `createEffect`'s apply phase. If a compute phase genuinely needs per-run
|
|
15
|
-
* teardown, that's usually a sign the work should be a memo/projection
|
|
16
|
-
* instead, or moved to `onSettled` if it's lifecycle-shaped.
|
|
17
|
-
*
|
|
18
|
-
* Where `onCleanup` is the right tool is **library / custom-primitive
|
|
19
|
-
* internals** — coordinating disposal inside a `createRoot` body, or wiring
|
|
20
|
-
* cleanup to a captured owner via `runWithOwner` from a custom factory.
|
|
21
|
-
* Application code rarely needs to write any of those shapes directly.
|
|
22
|
-
*
|
|
23
|
-
* Must be called inside an owner. Calling outside an owner is a no-op (with a
|
|
24
|
-
* dev-mode warning).
|
|
25
|
-
*
|
|
26
|
-
* Cannot be used inside `createTrackedEffect` or `onSettled` — return a
|
|
27
|
-
* cleanup function from the callback body instead.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* // Library shape: thread a resource's disposal into a *captured* owner
|
|
32
|
-
* // from a factory that has no settle-phase setup of its own. `onSettled`
|
|
33
|
-
* // would queue a callback we don't need; `onCleanup` is the leaner
|
|
34
|
-
* // primitive when the only job is "register disposal on this owner".
|
|
35
|
-
* function bindToOwner<T extends { dispose(): void }>(owner: Owner, resource: T): T {
|
|
36
|
-
* runWithOwner(owner, () => onCleanup(() => resource.dispose()));
|
|
37
|
-
* return resource;
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare function onCleanup(fn: Disposable): Disposable;
|
|
42
|
-
/**
|
|
43
|
-
* A zero-arg getter for a reactive value. Calling it inside a tracking scope
|
|
44
|
-
* (memo, effect compute, JSX expression) subscribes the scope to changes.
|
|
45
|
-
*
|
|
46
|
-
* Reading outside any tracking scope simply returns the current value without
|
|
47
|
-
* creating a subscription.
|
|
48
|
-
*/
|
|
49
|
-
export type Accessor<T> = () => T;
|
|
50
|
-
export type SourceAccessor<T> = Refreshable<Accessor<T>>;
|
|
51
|
-
export declare function accessor<T>(node: any): SourceAccessor<T>;
|
|
52
|
-
/**
|
|
53
|
-
* A signal setter. Accepts either a new value or an updater `(prev) => next`.
|
|
54
|
-
*
|
|
55
|
-
* If the type permits `undefined`, `setState()` (no args) clears to `undefined`.
|
|
56
|
-
*
|
|
57
|
-
* To store a function as the value itself (rather than as an updater), wrap it
|
|
58
|
-
* with an updater: `setHandler(() => myHandler)`.
|
|
59
|
-
*/
|
|
60
|
-
export type Setter<in out T> = {
|
|
61
|
-
<U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
|
|
62
|
-
<U extends T>(value: (prev: T) => U): U;
|
|
63
|
-
<U extends T>(value: Exclude<U, Function>): U;
|
|
64
|
-
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
|
|
65
|
-
};
|
|
66
|
-
/** A `[get, set]` pair returned from `createSignal` / `createOptimistic`. */
|
|
67
|
-
export type Signal<T> = [get: SourceAccessor<T>, set: Setter<T>];
|
|
68
|
-
export type ComputeFunction<Prev, Next extends Prev = Prev> = (v: Prev) => PromiseLike<Next> | AsyncIterable<Next> | Next;
|
|
69
|
-
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Next, p?: Prev) => (() => void) | void;
|
|
70
|
-
export type EffectBundle<Prev, Next extends Prev = Prev> = {
|
|
71
|
-
effect: EffectFunction<Prev, Next>;
|
|
72
|
-
/**
|
|
73
|
-
* Intercepts compute-phase errors (thrown by the compute function or arriving
|
|
74
|
-
* from upstream sources). Effect-phase throws are NOT routed here — they are
|
|
75
|
-
* your own imperative code and escalate to the nearest error boundary.
|
|
76
|
-
*
|
|
77
|
-
* This is the error arm of the effect phase: it runs on the same queue and
|
|
78
|
-
* in the same imperative, writable scope as `effect` (signal writes are
|
|
79
|
-
* legal), receives the error the user code threw, and observes settled
|
|
80
|
-
* outcomes — an error that recovers before the effect phase runs the
|
|
81
|
-
* `effect` arm instead, and a held transition defers it like `effect`.
|
|
82
|
-
*/
|
|
83
|
-
error: (err: unknown, cleanup: () => void) => void;
|
|
84
|
-
};
|
|
85
|
-
/** Options shared by every effect primitive. */
|
|
86
|
-
interface BaseEffectOptions {
|
|
87
|
-
/** Debug name (dev mode only) */
|
|
88
|
-
name?: string;
|
|
89
|
-
}
|
|
90
|
-
/** Options for effect primitives that support deferring/scheduling their initial run (`createEffect`, `createRenderEffect`, `createReaction`). */
|
|
91
|
-
export interface EffectOptions extends BaseEffectOptions {
|
|
92
|
-
/** When true, defers the initial effect execution until the next change */
|
|
93
|
-
defer?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* When true, enqueues the initial effect callback through the effect queue instead of running
|
|
96
|
-
* it synchronously at creation. Lets the initial run participate in transitions -- if any
|
|
97
|
-
* source throws `NotReadyError` during the compute phase, the callback is held until the
|
|
98
|
-
* transition settles.
|
|
99
|
-
*
|
|
100
|
-
* Primarily for render effects that need transition-aware initial mounts (e.g. the root
|
|
101
|
-
* `insert()` in `render()`).
|
|
102
|
-
*/
|
|
103
|
-
schedule?: boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Advanced. When true, asserts the compute function returns synchronous
|
|
106
|
-
* values only (never `PromiseLike` / `AsyncIterable`). Skips the
|
|
107
|
-
* async-shape probe in `recompute` for a small fixed-cost win per run.
|
|
108
|
-
* Intended for compiler emissions (`_$effect`) and library code that
|
|
109
|
-
* provably returns sync values. Returning a Promise or async iterable
|
|
110
|
-
* from a `sync: true` effect is undefined behavior — the value will be
|
|
111
|
-
* stored as-is and never awaited.
|
|
112
|
-
*/
|
|
113
|
-
sync?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Advanced (integration tier). When true, the effect is invisible to the
|
|
116
|
-
* hydration id scheme: it inherits its parent's id instead of consuming a
|
|
117
|
-
* child slot, and during hydration its compute runs live instead of
|
|
118
|
-
* adopting the serialized server value (its first run is not frozen to
|
|
119
|
-
* the server's decision).
|
|
120
|
-
*
|
|
121
|
-
* For **client-only effects created while hydrating** — effects with no
|
|
122
|
-
* server-rendered counterpart (a router wiring link state, scroll
|
|
123
|
-
* restoration, etc.). An id-consuming node the server never created would
|
|
124
|
-
* shift every later sibling's hydration id, making serialized lookups and
|
|
125
|
-
* template claims after it miss. `transparent` is also the supported
|
|
126
|
-
* alternative to branching on hydration state
|
|
127
|
-
* (`if (hydrating) createEffect(...)`), which freezes whatever the first
|
|
128
|
-
* run decided: create the effect unconditionally and let it observe live
|
|
129
|
-
* state instead.
|
|
130
|
-
*
|
|
131
|
-
* SSR ignores this option (a server-side effect always allocates its id
|
|
132
|
-
* slot), so only mark effects the server does not create. Outside
|
|
133
|
-
* hydration it is a no-op.
|
|
134
|
-
*/
|
|
135
|
-
transparent?: boolean;
|
|
136
|
-
}
|
|
137
|
-
/** Options for plain signals created with `createSignal(value)` or `createOptimistic(value)`. */
|
|
138
|
-
export interface SignalOptions<T> {
|
|
139
|
-
/** Debug name (dev mode only) */
|
|
140
|
-
name?: string;
|
|
141
|
-
/**
|
|
142
|
-
* Custom equality function, or `false` to always notify subscribers.
|
|
143
|
-
* Defaults to reference equality (`isEqual`). Pass a comparator (e.g.
|
|
144
|
-
* `(a, b) => a.id === b.id`) for value-based equality, or `false` to
|
|
145
|
-
* notify on every write regardless of equality.
|
|
146
|
-
*/
|
|
147
|
-
equals?: false | ((prev: T, next: T) => boolean);
|
|
148
|
-
/** Suppress dev-mode warnings when writing inside an owned scope */
|
|
149
|
-
ownedWrite?: boolean;
|
|
150
|
-
/** Callback invoked when the signal loses all subscribers */
|
|
151
|
-
unobserved?: () => void;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Options for read-only memos created with `createMemo`.
|
|
155
|
-
* Also used in combination with `SignalOptions` for writable memos
|
|
156
|
-
* (`createSignal(fn)` / `createOptimistic(fn)`).
|
|
157
|
-
*/
|
|
158
|
-
export interface MemoOptions<T> {
|
|
159
|
-
/** Stable identifier for the owner hierarchy */
|
|
160
|
-
id?: string;
|
|
161
|
-
/** Debug name (dev mode only) */
|
|
162
|
-
name?: string;
|
|
163
|
-
/**
|
|
164
|
-
* Advanced (integration tier). When true, the memo is invisible to the
|
|
165
|
-
* hydration id scheme: it inherits its parent's id instead of consuming a
|
|
166
|
-
* child slot, and during hydration it computes live instead of adopting
|
|
167
|
-
* the serialized server value. For client-only memos with no
|
|
168
|
-
* server-rendered counterpart — see {@link EffectOptions.transparent} for
|
|
169
|
-
* the full semantics. No-op outside hydration.
|
|
170
|
-
*/
|
|
171
|
-
transparent?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Custom equality function, or `false` to always notify subscribers.
|
|
174
|
-
* Defaults to reference equality (`isEqual`). Pass a comparator (e.g.
|
|
175
|
-
* `(a, b) => a.id === b.id`) for value-based equality, or `false` to
|
|
176
|
-
* notify on every recompute regardless of equality.
|
|
177
|
-
*/
|
|
178
|
-
equals?: false | ((prev: T, next: T) => boolean);
|
|
179
|
-
/** Callback invoked when the computed loses all subscribers */
|
|
180
|
-
unobserved?: () => void;
|
|
181
|
-
/**
|
|
182
|
-
* When true, defers the initial computation until the value is first read,
|
|
183
|
-
* **and** opts the memo into autodisposal — once it has no remaining
|
|
184
|
-
* subscribers it is torn down and recomputed from scratch on the next read.
|
|
185
|
-
* Use it for compute-on-demand values that should not retain state across
|
|
186
|
-
* idle periods. Non-lazy owned memos live for their owner's lifetime and
|
|
187
|
-
* never autodispose.
|
|
188
|
-
*/
|
|
189
|
-
lazy?: boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Advanced. When true, asserts the compute function returns synchronous
|
|
192
|
-
* values only (never `PromiseLike` / `AsyncIterable`). Skips the
|
|
193
|
-
* async-shape probe in `recompute` for a small fixed-cost win per run.
|
|
194
|
-
* Intended for compiler emissions (`_$memo`) and library code that
|
|
195
|
-
* provably returns sync values. Returning a Promise or async iterable
|
|
196
|
-
* from a `sync: true` memo is undefined behavior — the value will be
|
|
197
|
-
* stored as-is and never awaited.
|
|
198
|
-
*/
|
|
199
|
-
sync?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Commit #0: a committed value the memo is born with, shown until the
|
|
202
|
-
* compute's first real answer lands. While that first answer is in flight
|
|
203
|
-
* the memo reads as a settled value everywhere — nothing suspends to a
|
|
204
|
-
* `<Loading>` boundary, no transition is held (first-flight work is
|
|
205
|
-
* loading-class, like a boundary fallback), and `isPending(memo)` stays
|
|
206
|
-
* **false**: commit #0 answers the question by declaration, so first-load
|
|
207
|
-
* affordances are driven from the value itself (a `null` placeholder, a
|
|
208
|
-
* `skeleton: true` field, etc.). Once the first answer lands, the loading
|
|
209
|
-
* value leaves the lineage forever: refetches use normal pending semantics
|
|
210
|
-
* (stale value shown, `isPending` true, boundaries/transitions coordinate)
|
|
211
|
-
* — the canonical guard is `data.skeleton || isPending(data)`, whose two
|
|
212
|
-
* terms cover the two disjoint states.
|
|
213
|
-
*
|
|
214
|
-
* Typed strictly as `T`: to use `null`/`undefined` as the placeholder,
|
|
215
|
-
* declare it in the memo's type (e.g. `createMemo<User | null>(...)`), so
|
|
216
|
-
* every consumer sees the nullable window honestly. If the placeholder is
|
|
217
|
-
* shaped data standing in for real data, encode its provenance in the data
|
|
218
|
-
* (e.g. a `skeleton: true` field) rather than letting it impersonate truth.
|
|
219
|
-
*
|
|
220
|
-
* The loading value is also the compute's first `prev`, so `prev`-based
|
|
221
|
-
* memos fold from it.
|
|
222
|
-
*/
|
|
223
|
-
loadingValue?: T;
|
|
224
|
-
}
|
|
225
|
-
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
226
|
-
/**
|
|
227
|
-
* Creates a simple reactive state with a getter and setter.
|
|
228
|
-
*
|
|
229
|
-
* When called with a plain value, creates a signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
|
|
230
|
-
* When called with a function, creates a writable memo with `SignalOptions & MemoOptions` (adds id, lazy).
|
|
231
|
-
*
|
|
232
|
-
* ```typescript
|
|
233
|
-
* // Plain signal
|
|
234
|
-
* const [state, setState] = createSignal<T>(value, options?: SignalOptions<T>);
|
|
235
|
-
* // Writable memo (function overload)
|
|
236
|
-
* const [state, setState] = createSignal<T>(fn, initialValue?, options?: SignalOptions<T> & MemoOptions<T>);
|
|
237
|
-
* ```
|
|
238
|
-
* @param value initial value of the state; if empty, the state's type will automatically extended with undefined
|
|
239
|
-
* @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity
|
|
240
|
-
*
|
|
241
|
-
* @returns `[state: Accessor<T>, setState: Setter<T>]`
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```ts
|
|
245
|
-
* const [count, setCount] = createSignal(0);
|
|
246
|
-
*
|
|
247
|
-
* count(); // 0
|
|
248
|
-
* setCount(1); // explicit value
|
|
249
|
-
* setCount(c => c + 1); // updater
|
|
250
|
-
* ```
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* ```ts
|
|
254
|
-
* // Writable memo: starts as `fn()`, can be locally overwritten by setter.
|
|
255
|
-
* const [user, setUser] = createSignal(() => fetchUser(userId()));
|
|
256
|
-
*
|
|
257
|
-
* setUser({ ...user(), name: "Alice" }); // optimistic local edit
|
|
258
|
-
* ```
|
|
259
|
-
*
|
|
260
|
-
* @description https://docs.solidjs.com/reference/basic-reactivity/create-signal
|
|
261
|
-
*/
|
|
262
|
-
export declare function createSignal<T>(): Signal<T | undefined>;
|
|
263
|
-
export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
264
|
-
export declare function createSignal<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
|
|
265
|
-
/**
|
|
266
|
-
* Creates a readonly derived reactive memoized signal.
|
|
267
|
-
*
|
|
268
|
-
* ```typescript
|
|
269
|
-
* const value = createMemo<T>(compute, options?: MemoOptions<T>);
|
|
270
|
-
* ```
|
|
271
|
-
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
272
|
-
* @param options `MemoOptions` -- id, name, equals, unobserved, lazy, transparent
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```ts
|
|
276
|
-
* const [first, setFirst] = createSignal("Ada");
|
|
277
|
-
* const [last, setLast] = createSignal("Lovelace");
|
|
278
|
-
*
|
|
279
|
-
* const fullName = createMemo(() => `${first()} ${last()}`);
|
|
280
|
-
*
|
|
281
|
-
* fullName(); // "Ada Lovelace"
|
|
282
|
-
* ```
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```ts
|
|
286
|
-
* // Async memo — reads surface as pending inside <Loading>
|
|
287
|
-
* const user = createMemo(async () => {
|
|
288
|
-
* const res = await fetch(`/users/${id()}`);
|
|
289
|
-
* return res.json();
|
|
290
|
-
* });
|
|
291
|
-
* ```
|
|
292
|
-
*
|
|
293
|
-
* @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
|
|
294
|
-
*/
|
|
295
|
-
export declare function createMemo<T>(compute: ComputeFunction<NoInfer<T>, T>, options: MemoOptions<T> & {
|
|
296
|
-
loadingValue: T;
|
|
297
|
-
}): SourceAccessor<T>;
|
|
298
|
-
export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): SourceAccessor<T>;
|
|
299
|
-
/**
|
|
300
|
-
* Creates a reactive effect with **separate compute and effect phases**.
|
|
301
|
-
*
|
|
302
|
-
* - `compute(prev)` runs reactively — *put all reactive reads here*. The
|
|
303
|
-
* returned value is passed to `effect` and is also the new "previous" value
|
|
304
|
-
* for the next run.
|
|
305
|
-
* - `effect(next, prev?)` runs imperatively (untracked) after the queue
|
|
306
|
-
* flushes. *Put DOM writes / fetch / logging / subscriptions here.* It may
|
|
307
|
-
* return a cleanup function which runs before the next effect or on
|
|
308
|
-
* disposal.
|
|
309
|
-
*
|
|
310
|
-
* Reactive reads inside `effect` will *not* re-trigger this effect — that's
|
|
311
|
-
* intentional. If you need a single-phase tracked effect, use
|
|
312
|
-
* `createTrackedEffect` (with the tradeoffs noted there).
|
|
313
|
-
*
|
|
314
|
-
* Pass an `EffectBundle` (`{ effect, error }`) instead of a plain function to
|
|
315
|
-
* intercept **compute-phase** errors — errors thrown by `compute` or arriving
|
|
316
|
-
* from upstream reactive sources (including async rejections), which your own
|
|
317
|
-
* code has no frame to `try/catch`. The `error` handler is the error arm of
|
|
318
|
-
* the effect phase: it runs on the same schedule and in the same imperative,
|
|
319
|
-
* writable scope as `effect` (setting error state via signals is fine), and
|
|
320
|
-
* only for *settled* errors — a transient error that recovers before the
|
|
321
|
-
* effect phase runs `effect` with the recovered value instead, and a held
|
|
322
|
-
* transition defers it exactly as it defers `effect`. Without an `error`
|
|
323
|
-
* handler a compute-phase error is logged and the effect simply skips that
|
|
324
|
-
* run — a non-render effect's reactivity failing does not crash the app.
|
|
325
|
-
* Rethrowing from `error` escalates it to the nearest error boundary
|
|
326
|
-
* (halting the system if none exists).
|
|
327
|
-
*
|
|
328
|
-
* The **effect phase is different**: it is your own imperative code, so handle
|
|
329
|
-
* failures with `try/catch` where they occur. An uncaught effect-phase throw
|
|
330
|
-
* is treated as an unhandled application error — caught by the nearest
|
|
331
|
-
* `createErrorBoundary`/`<Errored>`, and permanently halting the reactive
|
|
332
|
-
* system if there is none. It is *not* routed to the bundle's `error` handler.
|
|
333
|
-
*
|
|
334
|
-
* ```typescript
|
|
335
|
-
* createEffect<T>(compute, effectFn | { effect, error }, options?: EffectOptions);
|
|
336
|
-
* ```
|
|
337
|
-
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
338
|
-
* @param effectFn a function that receives the new value and is used to perform side effects (return a cleanup function), or an `EffectBundle` with `effect` and `error` handlers
|
|
339
|
-
* @param options `EffectOptions` -- name, defer, schedule, transparent
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```ts
|
|
343
|
-
* const [count, setCount] = createSignal(0);
|
|
344
|
-
*
|
|
345
|
-
* createEffect(
|
|
346
|
-
* () => count(), // compute: tracks `count`
|
|
347
|
-
* value => console.log(value) // effect: side effect
|
|
348
|
-
* );
|
|
349
|
-
*
|
|
350
|
-
* setCount(1); // logs 1 after the next flush
|
|
351
|
-
* ```
|
|
352
|
-
*
|
|
353
|
-
* @example
|
|
354
|
-
* ```ts
|
|
355
|
-
* createEffect(
|
|
356
|
-
* () => userId(),
|
|
357
|
-
* id => {
|
|
358
|
-
* const ctrl = new AbortController();
|
|
359
|
-
* fetch(`/users/${id}`, { signal: ctrl.signal });
|
|
360
|
-
* return () => ctrl.abort(); // cleanup before next run / disposal
|
|
361
|
-
* }
|
|
362
|
-
* );
|
|
363
|
-
* ```
|
|
364
|
-
*
|
|
365
|
-
* @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
|
|
366
|
-
*/
|
|
367
|
-
export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
368
|
-
/**
|
|
369
|
-
* @deprecated `createEffect(compute)` (single argument) is no longer supported.
|
|
370
|
-
* Pass a separate effect function as the second argument:
|
|
371
|
-
* `createEffect(compute, effect)`. See [MISSING_EFFECT_FN].
|
|
372
|
-
*
|
|
373
|
-
* - For a side effect that reacts to changes, split the work:
|
|
374
|
-
* `createEffect(() => signal(), value => doWork(value))`.
|
|
375
|
-
* - For a derived value, use `createMemo(() => signal())`.
|
|
376
|
-
* - For a one-shot side effect at construction time, just call the function.
|
|
377
|
-
*/
|
|
378
|
-
export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>): never;
|
|
379
|
-
/**
|
|
380
|
-
* Creates a reactive computation that runs during the render phase as DOM elements
|
|
381
|
-
* are created and updated but not necessarily connected.
|
|
382
|
-
*
|
|
383
|
-
* Same compute / effect split as `createEffect`, but scheduled inside the render
|
|
384
|
-
* queue rather than after it. Reach for this only when authoring renderer
|
|
385
|
-
* plumbing (custom DOM bindings, JSX-generated `insert()` / `spread()` calls).
|
|
386
|
-
* App code should use `createEffect`.
|
|
387
|
-
*
|
|
388
|
-
* ```typescript
|
|
389
|
-
* createRenderEffect<T>(compute, effectFn, options?: EffectOptions);
|
|
390
|
-
* ```
|
|
391
|
-
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
392
|
-
* @param effectFn a function that receives the new value and is used to perform side effects
|
|
393
|
-
* @param options `EffectOptions` -- name, defer, schedule, transparent
|
|
394
|
-
*
|
|
395
|
-
* @example
|
|
396
|
-
* ```ts
|
|
397
|
-
* // Custom directive: bind an element's textContent to a reactive source.
|
|
398
|
-
* function bindText(el: HTMLElement, source: () => string) {
|
|
399
|
-
* createRenderEffect(
|
|
400
|
-
* () => source(),
|
|
401
|
-
* value => { el.textContent = value; }
|
|
402
|
-
* );
|
|
403
|
-
* }
|
|
404
|
-
* ```
|
|
405
|
-
*
|
|
406
|
-
* @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
|
|
407
|
-
*/
|
|
408
|
-
export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
409
|
-
/**
|
|
410
|
-
* Creates a tracked reactive effect where dependency tracking and side effects happen
|
|
411
|
-
* in the same scope.
|
|
412
|
-
*
|
|
413
|
-
* WARNING: Because tracking and effects happen in the same scope, this primitive
|
|
414
|
-
* may run multiple times for a single change or show tearing (reading inconsistent
|
|
415
|
-
* state). Use only when dynamic subscription patterns require same-scope tracking.
|
|
416
|
-
*
|
|
417
|
-
* The callback runs during the flush itself: writes made inside it are queued
|
|
418
|
-
* into the same flush's continuation and are never visible to the callback's
|
|
419
|
-
* own reads (reads return settled values, as in every effect-phase scope), and
|
|
420
|
-
* `flush()` cannot be called from inside it (dev throws; production is a
|
|
421
|
-
* no-op) — defer with `queueMicrotask(() => flush())` if needed.
|
|
422
|
-
*
|
|
423
|
-
* ```typescript
|
|
424
|
-
* createTrackedEffect(compute, options?: { name?: string });
|
|
425
|
-
* ```
|
|
426
|
-
* @param compute a function that contains reactive reads to track and returns an optional cleanup function to run on disposal or before next execution
|
|
427
|
-
* @param options -- name
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```ts
|
|
431
|
-
* createTrackedEffect(() => {
|
|
432
|
-
* const target = focusedNode();
|
|
433
|
-
* if (!target) return;
|
|
434
|
-
*
|
|
435
|
-
* const handler = () => log(target.value());
|
|
436
|
-
* target.on("change", handler);
|
|
437
|
-
*
|
|
438
|
-
* return () => target.off("change", handler);
|
|
439
|
-
* });
|
|
440
|
-
* ```
|
|
441
|
-
*
|
|
442
|
-
* @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect
|
|
443
|
-
*/
|
|
444
|
-
export declare function createTrackedEffect(compute: () => void | (() => void), options?: BaseEffectOptions): void;
|
|
445
|
-
/**
|
|
446
|
-
* Creates a reactive computation that runs after the render phase with flexible tracking.
|
|
447
|
-
*
|
|
448
|
-
* ```typescript
|
|
449
|
-
* const track = createReaction(effectFn, options?: EffectOptions);
|
|
450
|
-
* track(() => { // reactive reads });
|
|
451
|
-
* ```
|
|
452
|
-
* @param effectFn a function (or `EffectBundle`) that is called when tracked function is invalidated
|
|
453
|
-
* @param options `EffectOptions` -- name, defer
|
|
454
|
-
*
|
|
455
|
-
* @example
|
|
456
|
-
* ```ts
|
|
457
|
-
* const [count, setCount] = createSignal(0);
|
|
458
|
-
*
|
|
459
|
-
* const track = createReaction(() => {
|
|
460
|
-
* console.log("count changed once, re-arm to listen again");
|
|
461
|
-
* track(() => count()); // re-arm
|
|
462
|
-
* });
|
|
463
|
-
*
|
|
464
|
-
* track(() => count()); // initial arm
|
|
465
|
-
*
|
|
466
|
-
* setCount(1); // logs once, reaction re-armed for next change
|
|
467
|
-
* ```
|
|
468
|
-
*
|
|
469
|
-
* @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
|
|
470
|
-
*/
|
|
471
|
-
export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
|
|
472
|
-
/**
|
|
473
|
-
* Awaits a reactive expression and returns its first fully-settled value as a
|
|
474
|
-
* `Promise`. Pending async reads (`createMemo` returning a promise, etc.) are
|
|
475
|
-
* waited on; once the expression returns synchronously without `NotReadyError`
|
|
476
|
-
* the promise resolves with that value. If the expression settles with an
|
|
477
|
-
* error instead — including an async source that rejects — the promise
|
|
478
|
-
* rejects with it.
|
|
479
|
-
*
|
|
480
|
-
* Must be called *outside* a tracking scope — it doesn't subscribe, it just
|
|
481
|
-
* resolves the current value once.
|
|
482
|
-
*
|
|
483
|
-
* @example
|
|
484
|
-
* ```ts
|
|
485
|
-
* const user = createMemo(() => fetch(`/users/${id()}`).then(r => r.json()));
|
|
486
|
-
*
|
|
487
|
-
* // outside any reactive scope
|
|
488
|
-
* const initial = await resolve(() => user());
|
|
489
|
-
* ```
|
|
490
|
-
*
|
|
491
|
-
* @param fn a reactive expression to resolve
|
|
492
|
-
*/
|
|
493
|
-
export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
494
|
-
/**
|
|
495
|
-
* Creates an optimistic signal that can be used to optimistically update a value
|
|
496
|
-
* and then revert it back to the previous value at end of transition.
|
|
497
|
-
*
|
|
498
|
-
* When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
|
|
499
|
-
* When called with a function, creates a writable optimistic memo with `SignalOptions & MemoOptions` (adds id, lazy).
|
|
500
|
-
*
|
|
501
|
-
* ```typescript
|
|
502
|
-
* // Plain optimistic signal
|
|
503
|
-
* const [state, setState] = createOptimistic<T>(value, options?: SignalOptions<T>);
|
|
504
|
-
* // Writable optimistic memo (function overload)
|
|
505
|
-
* const [state, setState] = createOptimistic<T>(fn, options?: SignalOptions<T> & MemoOptions<T>);
|
|
506
|
-
* ```
|
|
507
|
-
* @param value initial value of the signal; if empty, the signal's type will automatically extended with undefined
|
|
508
|
-
* @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity
|
|
509
|
-
*
|
|
510
|
-
* @returns `[state: Accessor<T>, setState: Setter<T>]`
|
|
511
|
-
*
|
|
512
|
-
* @example
|
|
513
|
-
* ```ts
|
|
514
|
-
* const [todos, setTodos] = createOptimistic(initialTodos);
|
|
515
|
-
*
|
|
516
|
-
* const addTodo = action(function* (text: string) {
|
|
517
|
-
* const tempId = crypto.randomUUID();
|
|
518
|
-
* setTodos(t => [...t, { id: tempId, text, pending: true }]); // optimistic
|
|
519
|
-
* const saved = yield api.createTodo(text);
|
|
520
|
-
* setTodos(t => t.map(x => (x.id === tempId ? saved : x))); // reconcile
|
|
521
|
-
* });
|
|
522
|
-
* ```
|
|
523
|
-
*
|
|
524
|
-
* @description https://docs.solidjs.com/reference/basic-reactivity/create-optimistic-signal
|
|
525
|
-
*/
|
|
526
|
-
export declare function createOptimistic<T>(): Signal<T | undefined>;
|
|
527
|
-
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
528
|
-
export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
|
|
529
|
-
/**
|
|
530
|
-
* Schedules `callback` to run **once** after the reactive graph has fully
|
|
531
|
-
* settled — i.e. once every pending async read inside the current owner has
|
|
532
|
-
* resolved and the queue has flushed. Each call registers a single fire; it
|
|
533
|
-
* does not create an ongoing subscription.
|
|
534
|
-
*
|
|
535
|
-
* The canonical lifecycle primitive in 2.0. Three main usages:
|
|
536
|
-
*
|
|
537
|
-
* - **Component-level setup-and-teardown** *(the most common shape)*: run
|
|
538
|
-
* setup after the component's first stable render and **return a cleanup
|
|
539
|
-
* function** to dispose it on owner disposal. This is the replacement for
|
|
540
|
-
* the 1.x `onMount` + `onCleanup` pairing — setup and teardown live in one
|
|
541
|
-
* block, and `onCleanup` is no longer the right tool for component
|
|
542
|
-
* bodies. (`onMount` no longer exists in 2.0.)
|
|
543
|
-
* - **Post-settle "ready" hook:** run once after a component's first stable
|
|
544
|
-
* render — analytics ping, focus, scroll-into-view, etc. No cleanup needed.
|
|
545
|
-
* - **Inside an event handler:** schedule work to run after the action /
|
|
546
|
-
* transition triggered by the event has completed.
|
|
547
|
-
*
|
|
548
|
-
* Reactive reads inside the callback are *not* tracked — to react to
|
|
549
|
-
* subsequent settles, register a new `onSettled` each time.
|
|
550
|
-
*
|
|
551
|
-
* The callback runs during the settle flush itself, which gives it the same
|
|
552
|
-
* write semantics as every other effect-phase scope (the effect half of
|
|
553
|
-
* `createEffect`, event handlers):
|
|
554
|
-
*
|
|
555
|
-
* - **Writes** are queued into the same flush's continuation — dependent memos
|
|
556
|
-
* and effects update before the flush returns — but reads inside the
|
|
557
|
-
* callback keep returning the settled (pre-write) values. A callback never
|
|
558
|
-
* observes its own unsettled write. Functional setters still compose:
|
|
559
|
-
* `set(v => v + 1)` twice increments twice.
|
|
560
|
-
* - **`flush()` cannot be called** from inside the callback — the flush is
|
|
561
|
-
* already running (dev throws; production is a no-op). To force a drain
|
|
562
|
-
* after this settle, defer it: `queueMicrotask(() => flush())`.
|
|
563
|
-
*
|
|
564
|
-
* `onCleanup` is **not** allowed inside the callback — return a cleanup
|
|
565
|
-
* function instead. The returned cleanup runs on owner disposal.
|
|
566
|
-
*
|
|
567
|
-
* A cleanup return is only honored when `onSettled` is called from an **owned**
|
|
568
|
-
* scope (e.g. a component body). When it fires out of band from an *unowned*
|
|
569
|
-
* scope — an event handler, a tracked effect, or another `onSettled` — there is
|
|
570
|
-
* no owner lifecycle to bind a cleanup to; returning one is a dev-mode error
|
|
571
|
-
* (and is dropped in production). Use the post-settle/event-handler forms below
|
|
572
|
-
* for one-shot work, and keep setup-with-teardown in an owned scope.
|
|
573
|
-
*
|
|
574
|
-
* @example
|
|
575
|
-
* ```tsx
|
|
576
|
-
* // Component-level setup + teardown — replaces onMount + onCleanup.
|
|
577
|
-
* // Subscribe to an external source on mount, unsubscribe on dispose.
|
|
578
|
-
* function useViewportWidth() {
|
|
579
|
-
* const [width, setWidth] = createSignal(window.innerWidth);
|
|
580
|
-
* onSettled(() => {
|
|
581
|
-
* const onResize = () => setWidth(window.innerWidth);
|
|
582
|
-
* window.addEventListener("resize", onResize);
|
|
583
|
-
* return () => window.removeEventListener("resize", onResize);
|
|
584
|
-
* });
|
|
585
|
-
* return width;
|
|
586
|
-
* }
|
|
587
|
-
* ```
|
|
588
|
-
*
|
|
589
|
-
* @example
|
|
590
|
-
* ```tsx
|
|
591
|
-
* // Post-settle "ready" hook — no cleanup needed.
|
|
592
|
-
* function Dashboard() {
|
|
593
|
-
* const data = createMemo(async () => fetchData());
|
|
594
|
-
*
|
|
595
|
-
* onSettled(() => {
|
|
596
|
-
* analytics.track("dashboard.ready");
|
|
597
|
-
* });
|
|
598
|
-
*
|
|
599
|
-
* return <Loading fallback={<Spinner />}><pre>{data()}</pre></Loading>;
|
|
600
|
-
* }
|
|
601
|
-
* ```
|
|
602
|
-
*
|
|
603
|
-
* @example
|
|
604
|
-
* ```tsx
|
|
605
|
-
* // Event-handler — runs after the action settles.
|
|
606
|
-
* function SaveButton() {
|
|
607
|
-
* const save = action(function* () {
|
|
608
|
-
* yield api.save();
|
|
609
|
-
* });
|
|
610
|
-
*
|
|
611
|
-
* const handleClick = () => {
|
|
612
|
-
* save();
|
|
613
|
-
* onSettled(() => toast("Saved!"));
|
|
614
|
-
* };
|
|
615
|
-
*
|
|
616
|
-
* return <button onClick={handleClick}>Save</button>;
|
|
617
|
-
* }
|
|
618
|
-
* ```
|
|
619
|
-
*
|
|
620
|
-
* @param callback Function to run; may return a cleanup function that fires
|
|
621
|
-
* on owner disposal
|
|
622
|
-
*/
|
|
623
|
-
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
624
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type { Store, StoreReturn, ProjectionStoreReturn, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.cjs";
|
|
2
|
-
export type { Merge, Omit } from "./utils.cjs";
|
|
3
|
-
export { isWrappable, $TRACK, $PROXY, $TARGET } from "./store.cjs";
|
|
4
|
-
import type { NoFn, ProjectionOptions, Store, StoreOptions, StoreSetter } from "./store.cjs";
|
|
5
|
-
import type { Refreshable } from "../core/index.cjs";
|
|
6
|
-
export { createProjectionNext as createProjection } from "./next/projection.cjs";
|
|
7
|
-
export { createOptimisticStoreNext as createOptimisticStore } from "./next/optimistic.cjs";
|
|
8
|
-
/** Public createStore: plain form `(init, options?)` and derived writable
|
|
9
|
-
* form `(fn, seed, options?)`. */
|
|
10
|
-
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
|
|
11
|
-
shallow?: boolean;
|
|
12
|
-
}): [get: Store<T>, set: StoreSetter<T>];
|
|
13
|
-
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
14
|
-
export declare function reconcile<T extends U, U>(value: T, key?: string | ((item: NonNullable<any>) => any) | null): (state: U) => T;
|
|
15
|
-
export declare function snapshot<T>(value: T): T;
|
|
16
|
-
export declare function deep<T>(value: T): T;
|
|
17
|
-
export { storePath } from "./storePath.cjs";
|
|
18
|
-
export type { PathSetter, Part, StorePathRange, ArrayFilterFn, CustomPartial } from "./storePath.cjs";
|
|
19
|
-
export { merge, omit } from "./utils.cjs";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "../store.cjs";
|
|
2
|
-
import type { StoreNextFamily, StoreNextTarget } from "./target.cjs";
|
|
3
|
-
export declare function createOptimisticStoreNext<T extends object = {}>(first: T | ((store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>), second?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
4
|
-
/** Diff the draft against the current OPTIMISTIC VIEW (committed + active
|
|
5
|
-
* overrides — the same view the draft was seeded from) and emit engine writes
|
|
6
|
-
* for exactly the changed keys. Visible-view diffing keeps no-op writes from
|
|
7
|
-
* entangling lanes (RUL-10 / opt R38). */
|
|
8
|
-
export declare function notifyOptimisticWrites(t: StoreNextTarget, pb: Record<PropertyKey, any>): void;
|
|
9
|
-
/**
|
|
10
|
-
* Landing consumption (RUL-2): fresh authoritative data supersedes every
|
|
11
|
-
* tentative override in the family. Mirrors legacy clearProjectionOverride —
|
|
12
|
-
* drop the override, clear lane/ownership, notify subscribers whose visible
|
|
13
|
-
* value changes (reversion effects go to regular queues via the projection
|
|
14
|
-
* write posture the caller holds).
|
|
15
|
-
*/
|
|
16
|
-
export declare function consumeOverridesNext(fam: StoreNextFamily): void;
|
|
17
|
-
/** Optimistic-view composition for snapshot/deep (O1: snapshot is the CURRENT
|
|
18
|
-
* view, lane values included; a fresh copy per call during pending windows —
|
|
19
|
-
* RUL-12). Returns `src` untouched when no override is active on `t`. */
|
|
20
|
-
export declare function optimisticView(t: StoreNextTarget, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Computed, type Refreshable } from "../../core/index.cjs";
|
|
2
|
-
import { type NoFn, type ProjectionOptions, type Store } from "../store.cjs";
|
|
3
|
-
export declare function createProjectionNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): Refreshable<Store<T>>;
|
|
4
|
-
/** Derived writable store (legacy parity): a projection whose public setter
|
|
5
|
-
* masks the recompute for the tick (core R31 — the manual write wins over a
|
|
6
|
-
* same-flush dependency change). */
|
|
7
|
-
export declare function createStoreDerivedNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [Refreshable<Store<T>>, (f: (draft: T) => T | void) => void];
|
|
8
|
-
export declare function runProjectionComputedNext<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any) | null, wrapCommit?: (write: () => void) => void, onDraftWrite?: () => void): Computed<void | T>;
|