@solidjs/signals 0.13.13 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/dev.js +312 -174
- package/dist/node.cjs +1068 -953
- package/dist/prod.js +744 -619
- package/dist/types/boundaries.d.ts +44 -3
- package/dist/types/core/core.d.ts +2 -2
- package/dist/types/core/effect.d.ts +3 -2
- package/dist/types/core/graph.d.ts +1 -0
- package/dist/types/core/scheduler.d.ts +1 -0
- package/dist/types/core/types.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +34 -26
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +19 -5
- package/dist/types/store/store.d.ts +4 -4
- package/dist/types-cjs/boundaries.d.cts +93 -0
- package/dist/types-cjs/core/action.d.cts +1 -0
- package/dist/types-cjs/core/async.d.cts +6 -0
- package/dist/types-cjs/core/constants.d.cts +25 -0
- package/dist/types-cjs/core/context.d.cts +28 -0
- package/dist/types-cjs/core/core.d.cts +54 -0
- package/dist/types-cjs/core/dev.d.cts +49 -0
- package/dist/types-cjs/core/effect.d.cts +31 -0
- package/dist/types-cjs/core/error.d.cts +14 -0
- package/dist/types-cjs/core/external.d.cts +26 -0
- package/dist/types-cjs/core/graph.d.cts +4 -0
- package/dist/types-cjs/core/heap.d.cts +14 -0
- package/dist/types-cjs/core/index.d.cts +12 -0
- package/dist/types-cjs/core/lanes.d.cts +54 -0
- package/dist/types-cjs/core/owner.d.cts +26 -0
- package/dist/types-cjs/core/scheduler.d.cts +82 -0
- package/dist/types-cjs/core/types.d.cts +86 -0
- package/dist/types-cjs/index.d.cts +9 -0
- package/dist/types-cjs/map.d.cts +24 -0
- package/dist/types-cjs/package.json +3 -0
- package/dist/types-cjs/signals.d.cts +200 -0
- package/dist/types-cjs/store/index.d.cts +9 -0
- package/dist/types-cjs/store/optimistic.d.cts +19 -0
- package/dist/types-cjs/store/projection.d.cts +40 -0
- package/dist/types-cjs/store/reconcile.d.cts +1 -0
- package/dist/types-cjs/store/store.d.cts +68 -0
- package/dist/types-cjs/store/storePath.d.cts +30 -0
- package/dist/types-cjs/store/utils.d.cts +43 -0
- package/package.json +31 -24
|
@@ -5,18 +5,29 @@ export interface BoundaryComputed<T> extends Computed<T> {
|
|
|
5
5
|
}
|
|
6
6
|
type RevealSlot = CollectionQueue | RevealController;
|
|
7
7
|
type BoolAccessor = () => boolean;
|
|
8
|
+
export type RevealOrder = "sequential" | "together" | "natural";
|
|
9
|
+
type OrderAccessor = () => RevealOrder;
|
|
8
10
|
export declare class RevealController {
|
|
9
|
-
|
|
11
|
+
_orderAccessor: OrderAccessor;
|
|
10
12
|
_collapsedAccessor: BoolAccessor;
|
|
11
13
|
_slots: RevealSlot[];
|
|
12
14
|
_parentController?: RevealController;
|
|
13
15
|
_disabled: Signal<boolean>;
|
|
14
16
|
_collapsed: Signal<boolean>;
|
|
15
17
|
_ready: boolean;
|
|
18
|
+
_minimallyReady: boolean;
|
|
16
19
|
_evaluating: boolean;
|
|
17
|
-
constructor(
|
|
20
|
+
constructor(order: OrderAccessor, collapsed: BoolAccessor);
|
|
18
21
|
_forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
|
|
19
22
|
isReady(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* "Minimally ready" = this group has something visible to show under its own policy.
|
|
25
|
+
* Used by an enclosing `together` group to decide when it can release.
|
|
26
|
+
* - `together`: fully ready (atomic).
|
|
27
|
+
* - `sequential`: the first owned slot is minimally ready (frontier can advance).
|
|
28
|
+
* - `natural`: any owned slot is minimally ready.
|
|
29
|
+
*/
|
|
30
|
+
isMinimallyReady(): boolean;
|
|
20
31
|
register(slot: RevealSlot): void;
|
|
21
32
|
unregister(slot: RevealSlot): void;
|
|
22
33
|
evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
|
|
@@ -41,8 +52,38 @@ export declare function createLoadingBoundary(fn: () => any, fallback: () => any
|
|
|
41
52
|
on?: () => any;
|
|
42
53
|
}): import("./signals.js").Accessor<unknown>;
|
|
43
54
|
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.js").Accessor<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Coordinate the reveal timing of sibling loading boundaries.
|
|
57
|
+
*
|
|
58
|
+
* Accepts reactive accessors:
|
|
59
|
+
* - `order`: `"sequential"` (default) | `"together"` | `"natural"`.
|
|
60
|
+
* - `"sequential"` — classic frontier reveal: siblings reveal in registration order
|
|
61
|
+
* as each resolves; later siblings stay hidden until earlier ones complete.
|
|
62
|
+
* - `"together"` — every direct slot stays on its fallback until the whole group
|
|
63
|
+
* is "minimally ready" (each direct slot has produced its own first visible
|
|
64
|
+
* content under its own order), then the whole group releases at once.
|
|
65
|
+
* - `"natural"` — children reveal independently (as each resolves). At the top
|
|
66
|
+
* level this is a no-op compared to not using `createRevealOrder`; the mode
|
|
67
|
+
* exists for nesting, where the group registers as a single composite slot to
|
|
68
|
+
* any enclosing `createRevealOrder`.
|
|
69
|
+
* - `collapsed`: only meaningful when `order === "sequential"`. When set, tail siblings
|
|
70
|
+
* past the frontier suppress their own fallback output. Ignored under `"together"`
|
|
71
|
+
* and `"natural"` — those orders have no frontier.
|
|
72
|
+
*
|
|
73
|
+
* Nested `createRevealOrder` groups compose: the inner controller registers as a
|
|
74
|
+
* single slot in the outer controller and is held on its fallbacks until the outer
|
|
75
|
+
* releases that slot. Once released, the inner controller runs its own order locally
|
|
76
|
+
* over anything still pending. There is no opt-out from an outer hold.
|
|
77
|
+
*
|
|
78
|
+
* "Minimally ready" is what an order considers its first visible content:
|
|
79
|
+
* - `sequential` — frontier-0 is minimally ready (leaf: on resolve; nested: via its
|
|
80
|
+
* own minimal signal).
|
|
81
|
+
* - `together` — every direct slot is minimally ready.
|
|
82
|
+
* - `natural` — any direct slot has visible content (leaves on resolve; nested
|
|
83
|
+
* composites when fully ready, since natural treats composites as atomic).
|
|
84
|
+
*/
|
|
44
85
|
export declare function createRevealOrder<T>(fn: () => T, options?: {
|
|
45
|
-
|
|
86
|
+
order?: OrderAccessor;
|
|
46
87
|
collapsed?: BoolAccessor;
|
|
47
88
|
}): T;
|
|
48
89
|
export declare function flatten(children: any, options?: {
|
|
@@ -17,11 +17,11 @@ export declare function releaseSnapshotScope(owner: Owner): void;
|
|
|
17
17
|
export declare function clearSnapshots(): void;
|
|
18
18
|
export declare function recompute(el: Computed<any>, create?: boolean): void;
|
|
19
19
|
export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
|
|
20
|
-
export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>,
|
|
20
|
+
export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
|
|
21
21
|
export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
22
22
|
export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
|
|
23
23
|
export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
24
|
-
export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>,
|
|
24
|
+
export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
|
|
25
25
|
export declare function isEqual<T>(a: T, b: T): boolean;
|
|
26
26
|
/**
|
|
27
27
|
* When set to a component name string, any reactive read that is not inside a nested tracking
|
|
@@ -12,9 +12,10 @@ export interface Effect<T> extends Computed<T>, Owner {
|
|
|
12
12
|
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
|
|
13
13
|
* sources and recompute
|
|
14
14
|
*/
|
|
15
|
-
export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown, cleanup: () => void) => void | (() => void),
|
|
16
|
-
|
|
15
|
+
export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown, cleanup: () => void) => void | (() => void), options?: NodeOptions<any> & {
|
|
16
|
+
user?: boolean;
|
|
17
17
|
defer?: boolean;
|
|
18
|
+
schedule?: boolean;
|
|
18
19
|
}): void;
|
|
19
20
|
export interface TrackedEffect extends Computed<void> {
|
|
20
21
|
_cleanup?: () => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Computed, Link, Signal } from "./types.js";
|
|
2
2
|
export declare function unlinkSubs(link: Link): Link | null;
|
|
3
|
+
export declare function unobserved(el: Computed<unknown>): void;
|
|
3
4
|
export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
|
|
@@ -9,6 +9,7 @@ export declare let clock: number;
|
|
|
9
9
|
export declare let activeTransition: Transition | null;
|
|
10
10
|
export declare let projectionWriteActive: boolean;
|
|
11
11
|
export declare let _hitUnhandledAsync: boolean;
|
|
12
|
+
export declare function registerTransientStoreNode(node: Signal<any>): void;
|
|
12
13
|
export declare function resetUnhandledAsync(): void;
|
|
13
14
|
export declare function enforceLoadingBoundary(enabled: boolean): void;
|
|
14
15
|
export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
|
|
@@ -16,7 +16,7 @@ export interface NodeOptions<T> {
|
|
|
16
16
|
name?: string;
|
|
17
17
|
transparent?: boolean;
|
|
18
18
|
equals?: ((prev: T, next: T) => boolean) | false;
|
|
19
|
-
|
|
19
|
+
ownedWrite?: boolean;
|
|
20
20
|
/** Exclude this signal from snapshot capture (internal — not part of public API) */
|
|
21
21
|
_noSnapshot?: boolean;
|
|
22
22
|
unobserved?: () => void;
|
|
@@ -29,7 +29,7 @@ export interface RawSignal<T> {
|
|
|
29
29
|
_snapshotValue?: any;
|
|
30
30
|
_name?: string;
|
|
31
31
|
_equals: false | ((a: T, b: T) => boolean);
|
|
32
|
-
|
|
32
|
+
_ownedWrite?: boolean;
|
|
33
33
|
_noSnapshot?: boolean;
|
|
34
34
|
_unobserved?: () => void;
|
|
35
35
|
_time: number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { createSignal, createMemo, createEffect, createRenderEffect, createTrack
|
|
|
6
6
|
export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
|
|
7
7
|
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
8
8
|
export * from "./store/index.js";
|
|
9
|
-
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten } from "./boundaries.js";
|
|
9
|
+
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.js";
|
package/dist/types/signals.d.ts
CHANGED
|
@@ -15,12 +15,25 @@ export type EffectBundle<Prev, Next extends Prev = Prev> = {
|
|
|
15
15
|
effect: EffectFunction<Prev, Next>;
|
|
16
16
|
error: (err: unknown, cleanup: () => void) => void;
|
|
17
17
|
};
|
|
18
|
-
/** Options
|
|
19
|
-
|
|
18
|
+
/** Options shared by every effect primitive. */
|
|
19
|
+
interface BaseEffectOptions {
|
|
20
20
|
/** Debug name (dev mode only) */
|
|
21
21
|
name?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Options for effect primitives that support deferring/scheduling their initial run (`createEffect`, `createRenderEffect`, `createReaction`). */
|
|
24
|
+
export interface EffectOptions extends BaseEffectOptions {
|
|
22
25
|
/** When true, defers the initial effect execution until the next change */
|
|
23
26
|
defer?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When true, enqueues the initial effect callback through the effect queue instead of running
|
|
29
|
+
* it synchronously at creation. Lets the initial run participate in transitions -- if any
|
|
30
|
+
* source throws `NotReadyError` during the compute phase, the callback is held until the
|
|
31
|
+
* transition settles.
|
|
32
|
+
*
|
|
33
|
+
* Primarily for render effects that need transition-aware initial mounts (e.g. the root
|
|
34
|
+
* `insert()` in `render()`).
|
|
35
|
+
*/
|
|
36
|
+
schedule?: boolean;
|
|
24
37
|
}
|
|
25
38
|
/** Options for plain signals created with `createSignal(value)` or `createOptimistic(value)`. */
|
|
26
39
|
export interface SignalOptions<T> {
|
|
@@ -29,7 +42,7 @@ export interface SignalOptions<T> {
|
|
|
29
42
|
/** Custom equality function, or `false` to always notify subscribers */
|
|
30
43
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
31
44
|
/** Suppress dev-mode warnings when writing inside an owned scope */
|
|
32
|
-
|
|
45
|
+
ownedWrite?: boolean;
|
|
33
46
|
/** Callback invoked when the signal loses all subscribers */
|
|
34
47
|
unobserved?: () => void;
|
|
35
48
|
}
|
|
@@ -56,7 +69,7 @@ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
|
56
69
|
/**
|
|
57
70
|
* Creates a simple reactive state with a getter and setter.
|
|
58
71
|
*
|
|
59
|
-
* When called with a plain value, creates a signal with `SignalOptions` (name, equals,
|
|
72
|
+
* When called with a plain value, creates a signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
|
|
60
73
|
* When called with a function, creates a writable memo with `SignalOptions & MemoOptions` (adds id, lazy).
|
|
61
74
|
*
|
|
62
75
|
* ```typescript
|
|
@@ -74,52 +87,46 @@ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
|
74
87
|
*/
|
|
75
88
|
export declare function createSignal<T>(): Signal<T | undefined>;
|
|
76
89
|
export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
77
|
-
export declare function createSignal<T>(fn: ComputeFunction<T>,
|
|
90
|
+
export declare function createSignal<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
|
|
78
91
|
/**
|
|
79
92
|
* Creates a readonly derived reactive memoized signal.
|
|
80
93
|
*
|
|
81
94
|
* ```typescript
|
|
82
|
-
* const value = createMemo<T>(compute,
|
|
95
|
+
* const value = createMemo<T>(compute, options?: MemoOptions<T>);
|
|
83
96
|
* ```
|
|
84
|
-
* @param compute a function that receives its previous
|
|
85
|
-
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
97
|
+
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
86
98
|
* @param options `MemoOptions` -- id, name, equals, unobserved, lazy
|
|
87
99
|
*
|
|
88
100
|
* @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
|
|
89
101
|
*/
|
|
90
|
-
export declare function createMemo<
|
|
91
|
-
export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
|
|
102
|
+
export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): Accessor<T>;
|
|
92
103
|
/**
|
|
93
104
|
* Creates a reactive effect that runs after the render phase.
|
|
94
105
|
*
|
|
95
106
|
* ```typescript
|
|
96
|
-
* createEffect<T>(compute, effectFn | { effect, error },
|
|
107
|
+
* createEffect<T>(compute, effectFn | { effect, error }, options?: EffectOptions);
|
|
97
108
|
* ```
|
|
98
|
-
* @param compute a function that receives its previous
|
|
109
|
+
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
99
110
|
* @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
|
|
100
|
-
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
101
111
|
* @param options `EffectOptions` -- name, defer
|
|
102
112
|
*
|
|
103
113
|
* @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
|
|
104
114
|
*/
|
|
105
|
-
export declare function createEffect<
|
|
106
|
-
export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
|
|
115
|
+
export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
107
116
|
/**
|
|
108
117
|
* Creates a reactive computation that runs during the render phase as DOM elements
|
|
109
118
|
* are created and updated but not necessarily connected.
|
|
110
119
|
*
|
|
111
120
|
* ```typescript
|
|
112
|
-
* createRenderEffect<T>(compute, effectFn,
|
|
121
|
+
* createRenderEffect<T>(compute, effectFn, options?: EffectOptions);
|
|
113
122
|
* ```
|
|
114
|
-
* @param compute a function that receives its previous
|
|
123
|
+
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
115
124
|
* @param effectFn a function that receives the new value and is used to perform side effects
|
|
116
|
-
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
117
125
|
* @param options `EffectOptions` -- name, defer
|
|
118
126
|
*
|
|
119
127
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
|
|
120
128
|
*/
|
|
121
|
-
export declare function createRenderEffect<
|
|
122
|
-
export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
|
|
129
|
+
export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
123
130
|
/**
|
|
124
131
|
* Creates a tracked reactive effect where dependency tracking and side effects happen
|
|
125
132
|
* in the same scope.
|
|
@@ -129,14 +136,14 @@ export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFu
|
|
|
129
136
|
* state). Use only when dynamic subscription patterns require same-scope tracking.
|
|
130
137
|
*
|
|
131
138
|
* ```typescript
|
|
132
|
-
* createTrackedEffect(compute, options?:
|
|
139
|
+
* createTrackedEffect(compute, options?: { name?: string });
|
|
133
140
|
* ```
|
|
134
141
|
* @param compute a function that contains reactive reads to track and returns an optional cleanup function to run on disposal or before next execution
|
|
135
|
-
* @param options
|
|
142
|
+
* @param options -- name
|
|
136
143
|
*
|
|
137
144
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect
|
|
138
145
|
*/
|
|
139
|
-
export declare function createTrackedEffect(compute: () => void | (() => void), options?:
|
|
146
|
+
export declare function createTrackedEffect(compute: () => void | (() => void), options?: BaseEffectOptions): void;
|
|
140
147
|
/**
|
|
141
148
|
* Creates a reactive computation that runs after the render phase with flexible tracking.
|
|
142
149
|
*
|
|
@@ -159,14 +166,14 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
|
159
166
|
* Creates an optimistic signal that can be used to optimistically update a value
|
|
160
167
|
* and then revert it back to the previous value at end of transition.
|
|
161
168
|
*
|
|
162
|
-
* When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals,
|
|
169
|
+
* When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
|
|
163
170
|
* When called with a function, creates a writable optimistic memo with `SignalOptions & MemoOptions` (adds id, lazy).
|
|
164
171
|
*
|
|
165
172
|
* ```typescript
|
|
166
173
|
* // Plain optimistic signal
|
|
167
174
|
* const [state, setState] = createOptimistic<T>(value, options?: SignalOptions<T>);
|
|
168
175
|
* // Writable optimistic memo (function overload)
|
|
169
|
-
* const [state, setState] = createOptimistic<T>(fn,
|
|
176
|
+
* const [state, setState] = createOptimistic<T>(fn, options?: SignalOptions<T> & MemoOptions<T>);
|
|
170
177
|
* ```
|
|
171
178
|
* @param value initial value of the signal; if empty, the signal's type will automatically extended with undefined
|
|
172
179
|
* @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
|
|
@@ -177,7 +184,7 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
|
177
184
|
*/
|
|
178
185
|
export declare function createOptimistic<T>(): Signal<T | undefined>;
|
|
179
186
|
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
180
|
-
export declare function createOptimistic<T>(fn: ComputeFunction<T>,
|
|
187
|
+
export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
|
|
181
188
|
/**
|
|
182
189
|
* Runs a callback after the current flush cycle completes.
|
|
183
190
|
*
|
|
@@ -190,3 +197,4 @@ export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue
|
|
|
190
197
|
* @param callback Function to run, may return a cleanup function
|
|
191
198
|
*/
|
|
192
199
|
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
200
|
+
export {};
|
|
@@ -5,15 +5,15 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
|
|
|
5
5
|
* and then revert it back to the previous value at end of transition.
|
|
6
6
|
*
|
|
7
7
|
* When called with a plain value, creates an optimistic store.
|
|
8
|
-
* When called with a function, creates a derived optimistic store with `ProjectionOptions` (name, key
|
|
8
|
+
* When called with a function, creates a derived optimistic store with `ProjectionOptions` (name, key).
|
|
9
9
|
*
|
|
10
10
|
* @param fn a function that receives the current store and can be used to mutate it directly inside a transition
|
|
11
|
-
* @param
|
|
11
|
+
* @param store The plain store value, or the backing seed when using the derived-store form.
|
|
12
12
|
* @param options Optional projection options for reconciliation.
|
|
13
13
|
*
|
|
14
14
|
* @returns A tuple containing a store accessor and a setter function to apply changes.
|
|
15
15
|
*/
|
|
16
16
|
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
17
|
-
export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store
|
|
17
|
+
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: Store<T> & {
|
|
18
18
|
[$REFRESH]: any;
|
|
19
19
|
}, set: StoreSetter<T>];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $REFRESH, type Computed } from "../core/index.js";
|
|
2
2
|
import { type ProjectionOptions, type Store } from "./store.js";
|
|
3
|
-
export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>,
|
|
3
|
+
export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): {
|
|
4
4
|
store: Store<T> & {
|
|
5
5
|
[$REFRESH]: any;
|
|
6
6
|
};
|
|
@@ -11,16 +11,30 @@ export declare function createProjectionInternal<T extends object = {}>(fn: (dra
|
|
|
11
11
|
* draft and can mutate it directly or return a new value for reconciliation.
|
|
12
12
|
*
|
|
13
13
|
* ```typescript
|
|
14
|
-
* const store = createProjection<T>(fn,
|
|
14
|
+
* const store = createProjection<T>(fn, seed, options?: ProjectionOptions);
|
|
15
15
|
* ```
|
|
16
16
|
* @param fn a function that receives the current draft and mutates it or returns new data
|
|
17
|
-
* @param
|
|
18
|
-
* @param options `ProjectionOptions` -- name, key
|
|
17
|
+
* @param seed the backing store host value to wrap and reconcile into
|
|
18
|
+
* @param options `ProjectionOptions` -- name, key
|
|
19
19
|
*
|
|
20
20
|
* @see {@link https://github.com/solidjs/x-reactivity#createprojection}
|
|
21
21
|
*/
|
|
22
|
-
export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>,
|
|
22
|
+
export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): Store<T> & {
|
|
23
23
|
[$REFRESH]: any;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Shared projection computed body used by both `createProjection` and the derived
|
|
27
|
+
* form of `createOptimisticStore`. Encapsulates the write-trap draft, `storeSetter`
|
|
28
|
+
* wrapping, the `handleAsync` subscription with a setter callback, and the commit
|
|
29
|
+
* path (which must always go through `storeSetter` so the `writeOnly` guard is
|
|
30
|
+
* engaged during `reconcile`'s property reads).
|
|
31
|
+
*
|
|
32
|
+
* `wrapCommit` is invoked for every commit (sync return and each async yield) and
|
|
33
|
+
* lets callers layer extra context around the write — e.g. the optimistic store
|
|
34
|
+
* re-enters `setProjectionWriteActive` so reconciles target `STORE_OVERRIDE`
|
|
35
|
+
* instead of `STORE_OPTIMISTIC_OVERRIDE` even when an async yield fires outside
|
|
36
|
+
* the outer `setProjectionWriteActive` scope.
|
|
37
|
+
*/
|
|
38
|
+
export declare function runProjectionComputed<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any), wrapCommit?: (write: () => void) => void): Computed<void | T>;
|
|
25
39
|
export declare function createWriteTraps(isActive?: () => boolean): ProxyHandler<any>;
|
|
26
40
|
export declare const writeTraps: ProxyHandler<any>;
|
|
@@ -48,21 +48,21 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
48
48
|
* Creates a deeply reactive store with proxy-based tracking.
|
|
49
49
|
*
|
|
50
50
|
* When called with a plain value, wraps it in a reactive proxy.
|
|
51
|
-
* When called with a function, creates a derived projection store with `ProjectionOptions` (name, key
|
|
51
|
+
* When called with a function, creates a derived projection store with `ProjectionOptions` (name, key).
|
|
52
52
|
*
|
|
53
53
|
* ```typescript
|
|
54
54
|
* // Plain store
|
|
55
55
|
* const [store, setStore] = createStore<T>(initialValue);
|
|
56
56
|
* // Derived store (projection)
|
|
57
|
-
* const [store, setStore] = createStore<T>(fn,
|
|
57
|
+
* const [store, setStore] = createStore<T>(fn, seed, options?: ProjectionOptions);
|
|
58
58
|
* ```
|
|
59
59
|
* @param store initial value to wrap in a reactive proxy, or a derive function
|
|
60
|
-
* @param options `ProjectionOptions` -- name, key
|
|
60
|
+
* @param options `ProjectionOptions` -- name, key (only for derived stores)
|
|
61
61
|
*
|
|
62
62
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
63
63
|
*/
|
|
64
64
|
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
65
|
-
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store
|
|
65
|
+
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: Store<T> & {
|
|
66
66
|
[$REFRESH]: any;
|
|
67
67
|
}, set: StoreSetter<T>];
|
|
68
68
|
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Queue, type Computed, type Effect } from "./core/index.cjs";
|
|
2
|
+
import type { Signal } from "./core/index.cjs";
|
|
3
|
+
export interface BoundaryComputed<T> extends Computed<T> {
|
|
4
|
+
_propagationMask: number;
|
|
5
|
+
}
|
|
6
|
+
type RevealSlot = CollectionQueue | RevealController;
|
|
7
|
+
type BoolAccessor = () => boolean;
|
|
8
|
+
export type RevealOrder = "sequential" | "together" | "natural";
|
|
9
|
+
type OrderAccessor = () => RevealOrder;
|
|
10
|
+
export declare class RevealController {
|
|
11
|
+
_orderAccessor: OrderAccessor;
|
|
12
|
+
_collapsedAccessor: BoolAccessor;
|
|
13
|
+
_slots: RevealSlot[];
|
|
14
|
+
_parentController?: RevealController;
|
|
15
|
+
_disabled: Signal<boolean>;
|
|
16
|
+
_collapsed: Signal<boolean>;
|
|
17
|
+
_ready: boolean;
|
|
18
|
+
_minimallyReady: boolean;
|
|
19
|
+
_evaluating: boolean;
|
|
20
|
+
constructor(order: OrderAccessor, collapsed: BoolAccessor);
|
|
21
|
+
_forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
|
|
22
|
+
isReady(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* "Minimally ready" = this group has something visible to show under its own policy.
|
|
25
|
+
* Used by an enclosing `together` group to decide when it can release.
|
|
26
|
+
* - `together`: fully ready (atomic).
|
|
27
|
+
* - `sequential`: the first owned slot is minimally ready (frontier can advance).
|
|
28
|
+
* - `natural`: any owned slot is minimally ready.
|
|
29
|
+
*/
|
|
30
|
+
isMinimallyReady(): boolean;
|
|
31
|
+
register(slot: RevealSlot): void;
|
|
32
|
+
unregister(slot: RevealSlot): void;
|
|
33
|
+
evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
|
|
34
|
+
}
|
|
35
|
+
export declare class CollectionQueue extends Queue {
|
|
36
|
+
_collectionType: number;
|
|
37
|
+
_sources: Set<Computed<any>>;
|
|
38
|
+
_tree?: BoundaryComputed<any>;
|
|
39
|
+
_pending: boolean;
|
|
40
|
+
_disabled: Signal<boolean>;
|
|
41
|
+
_collapsed: Signal<boolean>;
|
|
42
|
+
_revealController?: RevealController;
|
|
43
|
+
_initialized: boolean;
|
|
44
|
+
_onFn: (() => any) | undefined;
|
|
45
|
+
_prevOn: any;
|
|
46
|
+
constructor(type: number);
|
|
47
|
+
run(type: number): void;
|
|
48
|
+
notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
|
|
49
|
+
checkSources(): void;
|
|
50
|
+
}
|
|
51
|
+
export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
|
|
52
|
+
on?: () => any;
|
|
53
|
+
}): import("./signals.cjs").Accessor<unknown>;
|
|
54
|
+
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").Accessor<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Coordinate the reveal timing of sibling loading boundaries.
|
|
57
|
+
*
|
|
58
|
+
* Accepts reactive accessors:
|
|
59
|
+
* - `order`: `"sequential"` (default) | `"together"` | `"natural"`.
|
|
60
|
+
* - `"sequential"` — classic frontier reveal: siblings reveal in registration order
|
|
61
|
+
* as each resolves; later siblings stay hidden until earlier ones complete.
|
|
62
|
+
* - `"together"` — every direct slot stays on its fallback until the whole group
|
|
63
|
+
* is "minimally ready" (each direct slot has produced its own first visible
|
|
64
|
+
* content under its own order), then the whole group releases at once.
|
|
65
|
+
* - `"natural"` — children reveal independently (as each resolves). At the top
|
|
66
|
+
* level this is a no-op compared to not using `createRevealOrder`; the mode
|
|
67
|
+
* exists for nesting, where the group registers as a single composite slot to
|
|
68
|
+
* any enclosing `createRevealOrder`.
|
|
69
|
+
* - `collapsed`: only meaningful when `order === "sequential"`. When set, tail siblings
|
|
70
|
+
* past the frontier suppress their own fallback output. Ignored under `"together"`
|
|
71
|
+
* and `"natural"` — those orders have no frontier.
|
|
72
|
+
*
|
|
73
|
+
* Nested `createRevealOrder` groups compose: the inner controller registers as a
|
|
74
|
+
* single slot in the outer controller and is held on its fallbacks until the outer
|
|
75
|
+
* releases that slot. Once released, the inner controller runs its own order locally
|
|
76
|
+
* over anything still pending. There is no opt-out from an outer hold.
|
|
77
|
+
*
|
|
78
|
+
* "Minimally ready" is what an order considers its first visible content:
|
|
79
|
+
* - `sequential` — frontier-0 is minimally ready (leaf: on resolve; nested: via its
|
|
80
|
+
* own minimal signal).
|
|
81
|
+
* - `together` — every direct slot is minimally ready.
|
|
82
|
+
* - `natural` — any direct slot has visible content (leaves on resolve; nested
|
|
83
|
+
* composites when fully ready, since natural treats composites as atomic).
|
|
84
|
+
*/
|
|
85
|
+
export declare function createRevealOrder<T>(fn: () => T, options?: {
|
|
86
|
+
order?: OrderAccessor;
|
|
87
|
+
collapsed?: BoolAccessor;
|
|
88
|
+
}): T;
|
|
89
|
+
export declare function flatten(children: any, options?: {
|
|
90
|
+
skipNonRendered?: boolean;
|
|
91
|
+
doNotUnwrap?: boolean;
|
|
92
|
+
}): any;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function action<Args extends any[], Y, R>(genFn: (...args: Args) => Generator<Y, R, any> | AsyncGenerator<Y, R, any>): (...args: Args) => Promise<R>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type OptimisticLane } from "./lanes.cjs";
|
|
2
|
+
import type { Computed } from "./types.cjs";
|
|
3
|
+
export declare function settlePendingSource(el: Computed<any>): void;
|
|
4
|
+
export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
|
|
5
|
+
export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
|
|
6
|
+
export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const REACTIVE_NONE = 0;
|
|
2
|
+
export declare const REACTIVE_CHECK: number;
|
|
3
|
+
export declare const REACTIVE_DIRTY: number;
|
|
4
|
+
export declare const REACTIVE_RECOMPUTING_DEPS: number;
|
|
5
|
+
export declare const REACTIVE_IN_HEAP: number;
|
|
6
|
+
export declare const REACTIVE_IN_HEAP_HEIGHT: number;
|
|
7
|
+
export declare const REACTIVE_ZOMBIE: number;
|
|
8
|
+
export declare const REACTIVE_DISPOSED: number;
|
|
9
|
+
export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
|
|
10
|
+
export declare const REACTIVE_SNAPSHOT_STALE: number;
|
|
11
|
+
export declare const REACTIVE_LAZY: number;
|
|
12
|
+
export declare const STATUS_NONE = 0;
|
|
13
|
+
export declare const STATUS_PENDING: number;
|
|
14
|
+
export declare const STATUS_ERROR: number;
|
|
15
|
+
export declare const STATUS_UNINITIALIZED: number;
|
|
16
|
+
export declare const EFFECT_PURE = 0;
|
|
17
|
+
export declare const EFFECT_RENDER = 1;
|
|
18
|
+
export declare const EFFECT_USER = 2;
|
|
19
|
+
export declare const EFFECT_TRACKED = 3;
|
|
20
|
+
export declare const NOT_PENDING: {};
|
|
21
|
+
export declare const NO_SNAPSHOT: {};
|
|
22
|
+
export declare const STORE_SNAPSHOT_PROPS = "sp";
|
|
23
|
+
export declare const SUPPORTS_PROXY: boolean;
|
|
24
|
+
export declare const defaultContext: {};
|
|
25
|
+
export declare const $REFRESH: unique symbol;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Owner } from "./types.cjs";
|
|
2
|
+
export interface Context<T> {
|
|
3
|
+
readonly id: symbol;
|
|
4
|
+
readonly defaultValue: T | undefined;
|
|
5
|
+
}
|
|
6
|
+
export type ContextRecord = Record<string | symbol, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Context provides a form of dependency injection. It is used to save from needing to pass
|
|
9
|
+
* data as props through intermediate components. This function creates a new context object
|
|
10
|
+
* that can be used with `getContext` and `setContext`.
|
|
11
|
+
*
|
|
12
|
+
* A default value can be provided here which will be used when a specific value is not provided
|
|
13
|
+
* via a `setContext` call.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Attempts to get a context value for the given key.
|
|
18
|
+
*
|
|
19
|
+
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
20
|
+
* @throws `ContextNotFoundError` if a context value has not been set yet.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
|
|
23
|
+
/**
|
|
24
|
+
* Attempts to set a context value on the parent scope with the given key.
|
|
25
|
+
*
|
|
26
|
+
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { $REFRESH } from "./constants.cjs";
|
|
2
|
+
import { type OptimisticLane } from "./lanes.cjs";
|
|
3
|
+
import type { Computed, FirewallSignal, NodeOptions, Owner, Signal } from "./types.cjs";
|
|
4
|
+
export declare let tracking: boolean;
|
|
5
|
+
export declare let stale: boolean;
|
|
6
|
+
export declare let refreshing: boolean;
|
|
7
|
+
export declare let pendingCheckActive: boolean;
|
|
8
|
+
export declare let foundPending: boolean;
|
|
9
|
+
export declare let latestReadActive: boolean;
|
|
10
|
+
export declare let context: Owner | null;
|
|
11
|
+
export declare let currentOptimisticLane: OptimisticLane | null;
|
|
12
|
+
export declare let snapshotCaptureActive: boolean;
|
|
13
|
+
export declare let snapshotSources: Set<any> | null;
|
|
14
|
+
export declare function setSnapshotCapture(active: boolean): void;
|
|
15
|
+
export declare function markSnapshotScope(owner: Owner): void;
|
|
16
|
+
export declare function releaseSnapshotScope(owner: Owner): void;
|
|
17
|
+
export declare function clearSnapshots(): void;
|
|
18
|
+
export declare function recompute(el: Computed<any>, create?: boolean): void;
|
|
19
|
+
export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
|
|
20
|
+
export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
|
|
21
|
+
export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
22
|
+
export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
|
|
23
|
+
export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
24
|
+
export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
|
|
25
|
+
export declare function isEqual<T>(a: T, b: T): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* When set to a component name string, any reactive read that is not inside a nested tracking
|
|
28
|
+
* scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
|
|
29
|
+
*/
|
|
30
|
+
export declare let strictRead: string | false;
|
|
31
|
+
export declare function setStrictRead(v: string | false): string | false;
|
|
32
|
+
/**
|
|
33
|
+
* Executes `fn` without tracking reactive dependencies.
|
|
34
|
+
*
|
|
35
|
+
* Pass a `strictReadLabel` string to enable strict-read warnings: any reactive read inside `fn`
|
|
36
|
+
* that is not inside a nested tracking scope will log a warning in dev mode.
|
|
37
|
+
*/
|
|
38
|
+
export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
|
|
39
|
+
export declare function read<T>(el: Signal<T> | Computed<T>): T;
|
|
40
|
+
export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
|
|
41
|
+
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
|
|
42
|
+
/**
|
|
43
|
+
* Update _pendingSignal when pending state changes. When the override clears
|
|
44
|
+
* (pending -> not pending), merge the sub-lane into the source's lane so
|
|
45
|
+
* isPending effects are blocked until the full scope resolves.
|
|
46
|
+
*/
|
|
47
|
+
export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
|
|
48
|
+
export declare function staleValues<T>(fn: () => T, set?: boolean): T;
|
|
49
|
+
export declare function latest<T>(fn: () => T): T;
|
|
50
|
+
export declare function isPending(fn: () => any): boolean;
|
|
51
|
+
export declare function refresh<T>(fn: (() => T) | (T & {
|
|
52
|
+
[$REFRESH]: any;
|
|
53
|
+
})): T;
|
|
54
|
+
export declare function isRefreshing(): boolean;
|