@solidjs/signals 2.0.0-beta.9 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/dist/dev.js +5971 -1426
- package/dist/node.cjs +7681 -3293
- package/dist/prod/affects.js +126 -0
- package/dist/prod/boundaries.js +572 -0
- package/dist/prod/core/action.js +139 -0
- package/dist/prod/core/async.js +553 -0
- package/dist/prod/core/constants.js +92 -0
- package/dist/prod/core/context.js +67 -0
- package/dist/prod/core/core.js +817 -0
- package/dist/prod/core/dev.js +3 -0
- package/dist/prod/core/effect.js +145 -0
- package/dist/prod/core/error.js +68 -0
- package/dist/prod/core/external.js +98 -0
- package/dist/prod/core/graph.js +104 -0
- package/dist/prod/core/heap.js +140 -0
- package/dist/prod/core/invariants.js +42 -0
- package/dist/prod/core/lanes.js +140 -0
- package/dist/prod/core/optimistic.js +245 -0
- package/dist/prod/core/owner.js +302 -0
- package/dist/prod/core/scheduler.js +749 -0
- package/dist/prod/core/verdict.js +369 -0
- package/dist/prod/index.js +45 -0
- package/dist/prod/map.js +317 -0
- package/dist/prod/signals.js +375 -0
- package/dist/prod/store/optimistic.js +217 -0
- package/dist/prod/store/projection.js +231 -0
- package/dist/prod/store/reconcile.js +707 -0
- package/dist/prod/store/store.js +1081 -0
- package/dist/prod/store/storePath.js +103 -0
- package/dist/prod/store/utils.js +328 -0
- package/dist/types/affects.d.ts +47 -0
- package/dist/types/boundaries.d.ts +60 -13
- package/dist/types/core/action.d.ts +35 -6
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +35 -6
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +58 -63
- package/dist/types/core/dev.d.ts +17 -2
- package/dist/types/core/effect.d.ts +1 -2
- package/dist/types/core/error.d.ts +33 -0
- package/dist/types/core/external.d.ts +0 -11
- package/dist/types/core/graph.d.ts +2 -1
- package/dist/types/core/heap.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/invariants.d.ts +59 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/optimistic.d.ts +6 -0
- package/dist/types/core/owner.d.ts +50 -3
- package/dist/types/core/scheduler.d.ts +82 -10
- package/dist/types/core/types.d.ts +66 -1
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/map.d.ts +21 -5
- package/dist/types/signals.d.ts +164 -12
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +10 -6
- package/dist/types/store/reconcile.d.ts +31 -8
- package/dist/types/store/store.d.ts +101 -6
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +60 -13
- package/dist/types-cjs/core/action.d.cts +35 -6
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +35 -6
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +58 -63
- package/dist/types-cjs/core/dev.d.cts +17 -2
- package/dist/types-cjs/core/effect.d.cts +1 -2
- package/dist/types-cjs/core/error.d.cts +33 -0
- package/dist/types-cjs/core/external.d.cts +0 -11
- package/dist/types-cjs/core/graph.d.cts +2 -1
- package/dist/types-cjs/core/heap.d.cts +8 -0
- package/dist/types-cjs/core/index.d.cts +3 -2
- package/dist/types-cjs/core/invariants.d.cts +59 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/optimistic.d.cts +6 -0
- package/dist/types-cjs/core/owner.d.cts +50 -3
- package/dist/types-cjs/core/scheduler.d.cts +82 -10
- package/dist/types-cjs/core/types.d.cts +66 -1
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +3 -2
- package/dist/types-cjs/map.d.cts +21 -5
- package/dist/types-cjs/signals.d.cts +164 -12
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/optimistic.d.cts +3 -3
- package/dist/types-cjs/store/projection.d.cts +10 -6
- package/dist/types-cjs/store/reconcile.d.cts +31 -8
- package/dist/types-cjs/store/store.d.cts +101 -6
- package/package.json +11 -9
- package/dist/prod.js +0 -3627
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Heap } from "./heap.js";
|
|
2
|
-
import { activeLanes, assignOrMergeLane, findLane } from "./lanes.js";
|
|
2
|
+
import { activeLanes, assignOrMergeLane, findLane, type OptimisticLane } from "./lanes.js";
|
|
3
3
|
import type { Computed, Signal } from "./types.js";
|
|
4
4
|
export { activeLanes, assignOrMergeLane, findLane };
|
|
5
5
|
export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.js";
|
|
@@ -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;
|
|
@@ -10,6 +10,14 @@ export interface Link {
|
|
|
10
10
|
_nextDep: Link | null;
|
|
11
11
|
_prevSub: Link | null;
|
|
12
12
|
_nextSub: Link | null;
|
|
13
|
+
/**
|
|
14
|
+
* `_sub._depGen` at the time this link was created or last revalidated
|
|
15
|
+
* in-order. A link stamped with the subscriber's current pass generation is
|
|
16
|
+
* inside the validated `[deps.._depsTail]` prefix — an O(1) replacement for
|
|
17
|
+
* scanning the dep list to answer membership (see `link()`).
|
|
18
|
+
*/
|
|
19
|
+
_gen: number;
|
|
20
|
+
_pendingObserver?: boolean;
|
|
13
21
|
}
|
|
14
22
|
export interface NodeOptions<T> {
|
|
15
23
|
id?: string;
|
|
@@ -21,6 +29,17 @@ export interface NodeOptions<T> {
|
|
|
21
29
|
_noSnapshot?: boolean;
|
|
22
30
|
unobserved?: () => void;
|
|
23
31
|
lazy?: boolean;
|
|
32
|
+
sync?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Commit #0. When present (checked with `in`, so an explicit `undefined`
|
|
35
|
+
* counts), the node is born committed with this value instead of
|
|
36
|
+
* STATUS_UNINITIALIZED: reads serve it everywhere, nothing suspends to
|
|
37
|
+
* Loading boundaries, transitions are never held, and the window is
|
|
38
|
+
* verdict-quiet (`isPending` stays false — commit #0 answers the question
|
|
39
|
+
* by declaration; first-load affordances live in the value itself). After
|
|
40
|
+
* the first real answer lands, normal refetch/pending semantics apply.
|
|
41
|
+
*/
|
|
42
|
+
loadingValue?: T;
|
|
24
43
|
}
|
|
25
44
|
export interface RawSignal<T> {
|
|
26
45
|
_subs: Link | null;
|
|
@@ -35,10 +54,29 @@ export interface RawSignal<T> {
|
|
|
35
54
|
_transition: Transition | null;
|
|
36
55
|
_pendingValue: T | typeof NOT_PENDING;
|
|
37
56
|
_overrideValue?: T | typeof NOT_PENDING;
|
|
57
|
+
/**
|
|
58
|
+
* The transaction that owns the active override (stamped at optimistic
|
|
59
|
+
* write, cleared at settle). Ownership must live on the node: a lane's
|
|
60
|
+
* _transition is a scheduling affinity that a shared subscriber can merge
|
|
61
|
+
* across transactions (#2912) — following it would let one action's settle
|
|
62
|
+
* revert another action's live override. Node-level sibling of the store
|
|
63
|
+
* layer's STORE_OPTIMISTIC_OWNERS stamps (#2899). `null` = ambient write.
|
|
64
|
+
*/
|
|
65
|
+
_overrideOwner?: Transition | null;
|
|
38
66
|
_optimisticLane?: OptimisticLane;
|
|
39
67
|
_pendingSignal?: Signal<boolean>;
|
|
40
68
|
_latestValueComputed?: Computed<T>;
|
|
41
69
|
_parentSource?: Signal<any> | Computed<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Live `affects()` marks on this node (refcount). Non-zero is declared
|
|
72
|
+
* motion: the node — and, via the verdict layer's dep-graph coverage walk,
|
|
73
|
+
* everything derived from it — reads pending regardless of graph state,
|
|
74
|
+
* until every declaring transaction settles/reverts and releases its mark.
|
|
75
|
+
* This count is the mark's ONLY graph state: the dedicated channel stores
|
|
76
|
+
* nothing downstream and never touches status flags, errors, or pending
|
|
77
|
+
* sources.
|
|
78
|
+
*/
|
|
79
|
+
_affectsCount?: number;
|
|
42
80
|
}
|
|
43
81
|
export interface FirewallSignal<T> extends RawSignal<T> {
|
|
44
82
|
_firewall: Computed<any>;
|
|
@@ -49,6 +87,8 @@ export interface Owner {
|
|
|
49
87
|
id?: string;
|
|
50
88
|
_config: number;
|
|
51
89
|
_snapshotScope?: boolean;
|
|
90
|
+
/** Effect-returned cleanup; managed across reruns, invoked at true disposal */
|
|
91
|
+
_cleanup?: () => void;
|
|
52
92
|
_disposal: Disposable | Disposable[] | null;
|
|
53
93
|
_parent: Owner | null;
|
|
54
94
|
_context: Record<symbol | string, unknown>;
|
|
@@ -56,15 +96,17 @@ export interface Owner {
|
|
|
56
96
|
_queue: IQueue;
|
|
57
97
|
_firstChild: Owner | null;
|
|
58
98
|
_nextSibling: Owner | null;
|
|
99
|
+
_prevSibling: Owner | null;
|
|
59
100
|
_pendingDisposal: Disposable | Disposable[] | null;
|
|
60
101
|
_pendingFirstChild: Owner | null;
|
|
61
102
|
}
|
|
62
103
|
export interface Computed<T> extends RawSignal<T>, Owner {
|
|
63
104
|
_deps: Link | null;
|
|
64
105
|
_depsTail: Link | null;
|
|
106
|
+
/** Recompute-pass counter; bumped when dep revalidation starts. */
|
|
107
|
+
_depGen: number;
|
|
65
108
|
_flags: number;
|
|
66
109
|
_blocked?: boolean;
|
|
67
|
-
_pendingSource?: Computed<any>;
|
|
68
110
|
_pendingSources?: Set<Computed<any>>;
|
|
69
111
|
_error?: unknown;
|
|
70
112
|
_statusFlags: number;
|
|
@@ -75,6 +117,29 @@ export interface Computed<T> extends RawSignal<T>, Owner {
|
|
|
75
117
|
_inFlight: PromiseLike<T> | AsyncIterable<T> | null;
|
|
76
118
|
_child: FirewallSignal<any> | null;
|
|
77
119
|
_notifyStatus?: (status?: number, error?: any) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Question-scoped pending classification of the node's CURRENT pending
|
|
122
|
+
* window: `true` means the in-flight recompute is a re-ask of the same
|
|
123
|
+
* question (refresh/poll/confirm — no tracked input changed value), so the
|
|
124
|
+
* shown answer still answers the question and the node reads NOT pending.
|
|
125
|
+
* Set by `recompute` from `REACTIVE_REASK`, cleared on landing
|
|
126
|
+
* (`clearStatus`). Meaningless while not STATUS_PENDING.
|
|
127
|
+
*/
|
|
128
|
+
_reask: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* True while a `loadingValue` node's first real answer hasn't landed: the
|
|
131
|
+
* node was born committed (commit #0 = the loading value) and `handleAsync`
|
|
132
|
+
* serves that committed value instead of throwing NotReadyError, so first
|
|
133
|
+
* flights never suspend readers, trip boundaries, or hold transitions.
|
|
134
|
+
* The window is verdict-quiet: `isPending` stays false, because commit #0
|
|
135
|
+
* answers the question by declaration (first-load affordances belong to
|
|
136
|
+
* the value channel). Cleared by the first value landing on any path (sync
|
|
137
|
+
* return, sync-resolved promise, first iterator yield, async settle); a
|
|
138
|
+
* real error leaves it set — errors answer reads but don't enter the value
|
|
139
|
+
* lineage, so a retry serves the loading value again. Once cleared, normal
|
|
140
|
+
* pending/refetch semantics apply forever.
|
|
141
|
+
*/
|
|
142
|
+
_loading: boolean;
|
|
78
143
|
}
|
|
79
144
|
export interface Root extends Owner {
|
|
80
145
|
_root: true;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest,
|
|
1
|
+
export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest, refresh, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, enforceLoadingBoundary, enableExternalSource, resetErrorHalt } from "./core/index.js";
|
|
2
2
|
import { type Dev } from "./core/index.js";
|
|
3
3
|
export declare const DEV: Dev | undefined;
|
|
4
4
|
export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Refreshable, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.js";
|
|
5
5
|
export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled, onCleanup } from "./signals.js";
|
|
6
|
-
export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
|
|
6
|
+
export type { Accessor, SourceAccessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
|
|
7
|
+
export { affects } from "./affects.js";
|
|
7
8
|
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
8
9
|
export * from "./store/index.js";
|
|
9
10
|
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.js";
|
package/dist/types/map.d.ts
CHANGED
|
@@ -2,8 +2,14 @@ import { type Accessor } from "./signals.js";
|
|
|
2
2
|
export type Maybe<T> = T | void | null | undefined | false;
|
|
3
3
|
/**
|
|
4
4
|
* Reactively maps an array, reusing the previously-mapped value for unchanged
|
|
5
|
-
* items.
|
|
6
|
-
*
|
|
5
|
+
* items.
|
|
6
|
+
*
|
|
7
|
+
* The callback shape follows the keying mode:
|
|
8
|
+
* - default / `keyed: true` receives `(item, index)` where `item` is the raw
|
|
9
|
+
* row value and `index` is an accessor.
|
|
10
|
+
* - `keyed: false` receives `(item, index)` where `item` is an accessor and
|
|
11
|
+
* `index` is a stable number.
|
|
12
|
+
* - `keyed: item => key` receives accessors for both arguments.
|
|
7
13
|
*
|
|
8
14
|
* This is the underlying helper that powers `<For>`. App code should use
|
|
9
15
|
* `<For>` directly; reach for `mapArray` when implementing custom list
|
|
@@ -19,15 +25,25 @@ export type Maybe<T> = T | void | null | undefined | false;
|
|
|
19
25
|
* ```ts
|
|
20
26
|
* const view = mapArray(
|
|
21
27
|
* items,
|
|
22
|
-
* (item, index) => `${index()}: ${item
|
|
28
|
+
* (item, index) => `${index()}: ${item.label}`,
|
|
23
29
|
* { fallback: () => "no items" }
|
|
24
30
|
* );
|
|
25
31
|
* ```
|
|
26
32
|
*
|
|
27
33
|
* @description https://docs.solidjs.com/reference/reactive-utilities/map-array
|
|
28
34
|
*/
|
|
29
|
-
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value:
|
|
30
|
-
keyed?:
|
|
35
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Item, index: Accessor<number>) => MappedItem, options?: {
|
|
36
|
+
keyed?: true;
|
|
37
|
+
fallback?: Accessor<any>;
|
|
38
|
+
name?: string;
|
|
39
|
+
}): Accessor<MappedItem[]>;
|
|
40
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: number) => MappedItem, options: {
|
|
41
|
+
keyed: false;
|
|
42
|
+
fallback?: Accessor<any>;
|
|
43
|
+
name?: string;
|
|
44
|
+
}): Accessor<MappedItem[]>;
|
|
45
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options: {
|
|
46
|
+
keyed: (item: Item) => any;
|
|
31
47
|
fallback?: Accessor<any>;
|
|
32
48
|
name?: string;
|
|
33
49
|
}): Accessor<MappedItem[]>;
|
package/dist/types/signals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Disposable } from "./core/index.js";
|
|
1
|
+
import type { Disposable, Refreshable } from "./core/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Low-level reactive-cleanup primitive. Registers a callback that runs when
|
|
4
4
|
* the surrounding owner is disposed.
|
|
@@ -25,6 +25,18 @@ import type { Disposable } from "./core/index.js";
|
|
|
25
25
|
*
|
|
26
26
|
* Cannot be used inside `createTrackedEffect` or `onSettled` — return a
|
|
27
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
|
+
* ```
|
|
28
40
|
*/
|
|
29
41
|
export declare function onCleanup(fn: Disposable): Disposable;
|
|
30
42
|
/**
|
|
@@ -35,7 +47,8 @@ export declare function onCleanup(fn: Disposable): Disposable;
|
|
|
35
47
|
* creating a subscription.
|
|
36
48
|
*/
|
|
37
49
|
export type Accessor<T> = () => T;
|
|
38
|
-
export
|
|
50
|
+
export type SourceAccessor<T> = Refreshable<Accessor<T>>;
|
|
51
|
+
export declare function accessor<T>(node: any): SourceAccessor<T>;
|
|
39
52
|
/**
|
|
40
53
|
* A signal setter. Accepts either a new value or an updater `(prev) => next`.
|
|
41
54
|
*
|
|
@@ -51,11 +64,22 @@ export type Setter<in out T> = {
|
|
|
51
64
|
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
|
|
52
65
|
};
|
|
53
66
|
/** A `[get, set]` pair returned from `createSignal` / `createOptimistic`. */
|
|
54
|
-
export type Signal<T> = [get:
|
|
67
|
+
export type Signal<T> = [get: SourceAccessor<T>, set: Setter<T>];
|
|
55
68
|
export type ComputeFunction<Prev, Next extends Prev = Prev> = (v: Prev) => PromiseLike<Next> | AsyncIterable<Next> | Next;
|
|
56
69
|
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Next, p?: Prev) => (() => void) | void;
|
|
57
70
|
export type EffectBundle<Prev, Next extends Prev = Prev> = {
|
|
58
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
|
+
*/
|
|
59
83
|
error: (err: unknown, cleanup: () => void) => void;
|
|
60
84
|
};
|
|
61
85
|
/** Options shared by every effect primitive. */
|
|
@@ -77,12 +101,49 @@ export interface EffectOptions extends BaseEffectOptions {
|
|
|
77
101
|
* `insert()` in `render()`).
|
|
78
102
|
*/
|
|
79
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;
|
|
80
136
|
}
|
|
81
137
|
/** Options for plain signals created with `createSignal(value)` or `createOptimistic(value)`. */
|
|
82
138
|
export interface SignalOptions<T> {
|
|
83
139
|
/** Debug name (dev mode only) */
|
|
84
140
|
name?: string;
|
|
85
|
-
/**
|
|
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
|
+
*/
|
|
86
147
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
87
148
|
/** Suppress dev-mode warnings when writing inside an owned scope */
|
|
88
149
|
ownedWrite?: boolean;
|
|
@@ -99,9 +160,21 @@ export interface MemoOptions<T> {
|
|
|
99
160
|
id?: string;
|
|
100
161
|
/** Debug name (dev mode only) */
|
|
101
162
|
name?: string;
|
|
102
|
-
/**
|
|
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
|
+
*/
|
|
103
171
|
transparent?: boolean;
|
|
104
|
-
/**
|
|
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
|
+
*/
|
|
105
178
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
106
179
|
/** Callback invoked when the computed loses all subscribers */
|
|
107
180
|
unobserved?: () => void;
|
|
@@ -114,6 +187,40 @@ export interface MemoOptions<T> {
|
|
|
114
187
|
* never autodispose.
|
|
115
188
|
*/
|
|
116
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;
|
|
117
224
|
}
|
|
118
225
|
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
119
226
|
/**
|
|
@@ -162,7 +269,7 @@ export declare function createSignal<T>(fn: ComputeFunction<T>, options?: Signal
|
|
|
162
269
|
* const value = createMemo<T>(compute, options?: MemoOptions<T>);
|
|
163
270
|
* ```
|
|
164
271
|
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
165
|
-
* @param options `MemoOptions` -- id, name, equals, unobserved, lazy
|
|
272
|
+
* @param options `MemoOptions` -- id, name, equals, unobserved, lazy, transparent
|
|
166
273
|
*
|
|
167
274
|
* @example
|
|
168
275
|
* ```ts
|
|
@@ -185,7 +292,10 @@ export declare function createSignal<T>(fn: ComputeFunction<T>, options?: Signal
|
|
|
185
292
|
*
|
|
186
293
|
* @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
|
|
187
294
|
*/
|
|
188
|
-
export declare function createMemo<T>(compute: ComputeFunction<
|
|
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>;
|
|
189
299
|
/**
|
|
190
300
|
* Creates a reactive effect with **separate compute and effect phases**.
|
|
191
301
|
*
|
|
@@ -202,14 +312,31 @@ export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInf
|
|
|
202
312
|
* `createTrackedEffect` (with the tradeoffs noted there).
|
|
203
313
|
*
|
|
204
314
|
* Pass an `EffectBundle` (`{ effect, error }`) instead of a plain function to
|
|
205
|
-
* intercept errors thrown
|
|
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.
|
|
206
333
|
*
|
|
207
334
|
* ```typescript
|
|
208
335
|
* createEffect<T>(compute, effectFn | { effect, error }, options?: EffectOptions);
|
|
209
336
|
* ```
|
|
210
337
|
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
211
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
|
|
212
|
-
* @param options `EffectOptions` -- name, defer, schedule
|
|
339
|
+
* @param options `EffectOptions` -- name, defer, schedule, transparent
|
|
213
340
|
*
|
|
214
341
|
* @example
|
|
215
342
|
* ```ts
|
|
@@ -253,12 +380,28 @@ export declare function createEffect<T>(compute: ComputeFunction<undefined | NoI
|
|
|
253
380
|
* Creates a reactive computation that runs during the render phase as DOM elements
|
|
254
381
|
* are created and updated but not necessarily connected.
|
|
255
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
|
+
*
|
|
256
388
|
* ```typescript
|
|
257
389
|
* createRenderEffect<T>(compute, effectFn, options?: EffectOptions);
|
|
258
390
|
* ```
|
|
259
391
|
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
260
392
|
* @param effectFn a function that receives the new value and is used to perform side effects
|
|
261
|
-
* @param options `EffectOptions` -- name, defer, schedule
|
|
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
|
+
* ```
|
|
262
405
|
*
|
|
263
406
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
|
|
264
407
|
*/
|
|
@@ -324,7 +467,9 @@ export declare function createReaction(effectFn: EffectFunction<undefined> | Eff
|
|
|
324
467
|
* Awaits a reactive expression and returns its first fully-settled value as a
|
|
325
468
|
* `Promise`. Pending async reads (`createMemo` returning a promise, etc.) are
|
|
326
469
|
* waited on; once the expression returns synchronously without `NotReadyError`
|
|
327
|
-
* the promise resolves with that value.
|
|
470
|
+
* the promise resolves with that value. If the expression settles with an
|
|
471
|
+
* error instead — including an async source that rejects — the promise
|
|
472
|
+
* rejects with it.
|
|
328
473
|
*
|
|
329
474
|
* Must be called *outside* a tracking scope — it doesn't subscribe, it just
|
|
330
475
|
* resolves the current value once.
|
|
@@ -400,6 +545,13 @@ export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: Si
|
|
|
400
545
|
* `onCleanup` is **not** allowed inside the callback — return a cleanup
|
|
401
546
|
* function instead. The returned cleanup runs on owner disposal.
|
|
402
547
|
*
|
|
548
|
+
* A cleanup return is only honored when `onSettled` is called from an **owned**
|
|
549
|
+
* scope (e.g. a component body). When it fires out of band from an *unowned*
|
|
550
|
+
* scope — an event handler, a tracked effect, or another `onSettled` — there is
|
|
551
|
+
* no owner lifecycle to bind a cleanup to; returning one is a dev-mode error
|
|
552
|
+
* (and is dropped in production). Use the post-settle/event-handler forms below
|
|
553
|
+
* for one-shot work, and keep setup-with-teardown in an owned scope.
|
|
554
|
+
*
|
|
403
555
|
* @example
|
|
404
556
|
* ```tsx
|
|
405
557
|
* // Component-level setup + teardown — replaces onMount + onCleanup.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Store, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.js";
|
|
1
|
+
export type { Store, StoreReturn, ProjectionStoreReturn, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.js";
|
|
2
2
|
export type { Merge, Omit } from "./utils.js";
|
|
3
3
|
export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.js";
|
|
4
4
|
export { createProjection } from "./projection.js";
|
|
@@ -14,8 +14,8 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
|
|
|
14
14
|
* optimistic overlay reverts after each transition.
|
|
15
15
|
*
|
|
16
16
|
* `options.key` defaults to `"id"`; specify it only when your data uses a
|
|
17
|
-
* different identity field (e.g. `{ key: "uuid" }` or `{ key: t => t.slug }`)
|
|
18
|
-
* Restating the default just adds noise.
|
|
17
|
+
* different identity field (e.g. `{ key: "uuid" }` or `{ key: t => t.slug }`),
|
|
18
|
+
* or `null` to merge positionally. Restating the default just adds noise.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
@@ -41,5 +41,5 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
|
|
|
41
41
|
*
|
|
42
42
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
43
43
|
*/
|
|
44
|
-
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T
|
|
44
|
+
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
45
45
|
export declare function createOptimisticStore<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>];
|