@solidjs/signals 2.0.0-beta.7 → 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/dist/dev.js +231 -122
- package/dist/node.cjs +1001 -905
- package/dist/prod.js +678 -580
- 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/scheduler.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +19 -5
- package/dist/types/store/optimistic.d.ts +1 -1
- package/dist/types/store/projection.d.ts +15 -1
- package/dist/types/store/store.d.ts +2 -2
- package/dist/types-cjs/boundaries.d.cts +44 -3
- package/dist/types-cjs/core/core.d.cts +2 -2
- package/dist/types-cjs/core/effect.d.cts +3 -2
- package/dist/types-cjs/core/scheduler.d.cts +1 -0
- package/dist/types-cjs/index.d.cts +1 -1
- package/dist/types-cjs/signals.d.cts +19 -5
- package/dist/types-cjs/store/optimistic.d.cts +1 -1
- package/dist/types-cjs/store/projection.d.cts +15 -1
- package/dist/types-cjs/store/store.d.cts +2 -2
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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;
|
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> {
|
|
@@ -123,14 +136,14 @@ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined
|
|
|
123
136
|
* state). Use only when dynamic subscription patterns require same-scope tracking.
|
|
124
137
|
*
|
|
125
138
|
* ```typescript
|
|
126
|
-
* createTrackedEffect(compute, options?:
|
|
139
|
+
* createTrackedEffect(compute, options?: { name?: string });
|
|
127
140
|
* ```
|
|
128
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
|
|
129
|
-
* @param options
|
|
142
|
+
* @param options -- name
|
|
130
143
|
*
|
|
131
144
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect
|
|
132
145
|
*/
|
|
133
|
-
export declare function createTrackedEffect(compute: () => void | (() => void), options?:
|
|
146
|
+
export declare function createTrackedEffect(compute: () => void | (() => void), options?: BaseEffectOptions): void;
|
|
134
147
|
/**
|
|
135
148
|
* Creates a reactive computation that runs after the render phase with flexible tracking.
|
|
136
149
|
*
|
|
@@ -184,3 +197,4 @@ export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: Si
|
|
|
184
197
|
* @param callback Function to run, may return a cleanup function
|
|
185
198
|
*/
|
|
186
199
|
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
200
|
+
export {};
|
|
@@ -5,7 +5,7 @@ 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
11
|
* @param store The plain store value, or the backing seed when using the derived-store form.
|
|
@@ -15,12 +15,26 @@ export declare function createProjectionInternal<T extends object = {}>(fn: (dra
|
|
|
15
15
|
* ```
|
|
16
16
|
* @param fn a function that receives the current draft and mutates it or returns new data
|
|
17
17
|
* @param seed the backing store host value to wrap and reconcile into
|
|
18
|
-
* @param options `ProjectionOptions` -- name, key
|
|
18
|
+
* @param options `ProjectionOptions` -- name, key
|
|
19
19
|
*
|
|
20
20
|
* @see {@link https://github.com/solidjs/x-reactivity#createprojection}
|
|
21
21
|
*/
|
|
22
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,7 +48,7 @@ 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
|
|
@@ -57,7 +57,7 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
57
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
|
*/
|
|
@@ -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.cjs").Accessor<unknown>;
|
|
43
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
|
+
*/
|
|
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;
|
|
@@ -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;
|
|
@@ -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.cjs";
|
|
7
7
|
export { mapArray, repeat, type Maybe } from "./map.cjs";
|
|
8
8
|
export * from "./store/index.cjs";
|
|
9
|
-
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten } from "./boundaries.cjs";
|
|
9
|
+
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.cjs";
|
|
@@ -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> {
|
|
@@ -123,14 +136,14 @@ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined
|
|
|
123
136
|
* state). Use only when dynamic subscription patterns require same-scope tracking.
|
|
124
137
|
*
|
|
125
138
|
* ```typescript
|
|
126
|
-
* createTrackedEffect(compute, options?:
|
|
139
|
+
* createTrackedEffect(compute, options?: { name?: string });
|
|
127
140
|
* ```
|
|
128
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
|
|
129
|
-
* @param options
|
|
142
|
+
* @param options -- name
|
|
130
143
|
*
|
|
131
144
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect
|
|
132
145
|
*/
|
|
133
|
-
export declare function createTrackedEffect(compute: () => void | (() => void), options?:
|
|
146
|
+
export declare function createTrackedEffect(compute: () => void | (() => void), options?: BaseEffectOptions): void;
|
|
134
147
|
/**
|
|
135
148
|
* Creates a reactive computation that runs after the render phase with flexible tracking.
|
|
136
149
|
*
|
|
@@ -184,3 +197,4 @@ export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: Si
|
|
|
184
197
|
* @param callback Function to run, may return a cleanup function
|
|
185
198
|
*/
|
|
186
199
|
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
200
|
+
export {};
|
|
@@ -5,7 +5,7 @@ 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
11
|
* @param store The plain store value, or the backing seed when using the derived-store form.
|
|
@@ -15,12 +15,26 @@ export declare function createProjectionInternal<T extends object = {}>(fn: (dra
|
|
|
15
15
|
* ```
|
|
16
16
|
* @param fn a function that receives the current draft and mutates it or returns new data
|
|
17
17
|
* @param seed the backing store host value to wrap and reconcile into
|
|
18
|
-
* @param options `ProjectionOptions` -- name, key
|
|
18
|
+
* @param options `ProjectionOptions` -- name, key
|
|
19
19
|
*
|
|
20
20
|
* @see {@link https://github.com/solidjs/x-reactivity#createprojection}
|
|
21
21
|
*/
|
|
22
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,7 +48,7 @@ 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
|
|
@@ -57,7 +57,7 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
57
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
|
*/
|