@solidjs/signals 0.9.10 → 0.10.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/dist/dev.js +539 -601
- package/dist/node.cjs +850 -906
- package/dist/prod.js +795 -851
- package/dist/types/boundaries.d.ts +0 -5
- package/dist/types/core/action.d.ts +1 -0
- package/dist/types/core/async.d.ts +5 -0
- package/dist/types/core/context.d.ts +1 -1
- package/dist/types/core/core.d.ts +25 -104
- package/dist/types/core/effect.d.ts +4 -3
- package/dist/types/core/graph.d.ts +3 -0
- package/dist/types/core/heap.d.ts +1 -1
- package/dist/types/core/index.d.ts +4 -2
- package/dist/types/core/lanes.d.ts +52 -0
- package/dist/types/core/owner.d.ts +22 -0
- package/dist/types/core/scheduler.d.ts +6 -59
- package/dist/types/core/types.d.ts +74 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/signals.d.ts +73 -76
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +9 -12
- package/dist/types/store/projection.d.ts +12 -4
- package/dist/types/store/store.d.ts +26 -1
- package/package.json +2 -2
|
@@ -13,11 +13,6 @@ export declare class CollectionQueue extends Queue {
|
|
|
13
13
|
notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
|
|
14
14
|
checkSources(): void;
|
|
15
15
|
}
|
|
16
|
-
export declare const enum BoundaryMode {
|
|
17
|
-
VISIBLE = "visible",
|
|
18
|
-
HIDDEN = "hidden"
|
|
19
|
-
}
|
|
20
|
-
export declare function createBoundary<T>(fn: () => T, condition: () => BoundaryMode): () => T | undefined;
|
|
21
16
|
export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
|
|
22
17
|
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
|
|
23
18
|
export declare function flatten(children: any, options?: {
|
|
@@ -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,5 @@
|
|
|
1
|
+
import { type OptimisticLane } from "./lanes.js";
|
|
2
|
+
import type { Computed } from "./types.js";
|
|
3
|
+
export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
|
|
4
|
+
export declare function clearStatus(el: Computed<any>): void;
|
|
5
|
+
export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
|
|
@@ -1,88 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
name?: string;
|
|
16
|
-
equals?: ((prev: T, next: T) => boolean) | false;
|
|
17
|
-
pureWrite?: boolean;
|
|
18
|
-
unobserved?: () => void;
|
|
19
|
-
lazy?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface RawSignal<T> {
|
|
22
|
-
_subs: Link | null;
|
|
23
|
-
_subsTail: Link | null;
|
|
24
|
-
_value: T;
|
|
25
|
-
_name?: string;
|
|
26
|
-
_equals: false | ((a: T, b: T) => boolean);
|
|
27
|
-
_pureWrite?: boolean;
|
|
28
|
-
_unobserved?: () => void;
|
|
29
|
-
_time: number;
|
|
30
|
-
_transition: Transition | null;
|
|
31
|
-
_pendingValue: T | typeof NOT_PENDING;
|
|
32
|
-
_optimistic?: boolean;
|
|
33
|
-
_optimisticLane?: OptimisticLane;
|
|
34
|
-
_pendingSignal?: Signal<boolean>;
|
|
35
|
-
_pendingValueComputed?: Computed<T>;
|
|
36
|
-
_parentSource?: Signal<any> | Computed<any>;
|
|
37
|
-
}
|
|
38
|
-
export interface FirewallSignal<T> extends RawSignal<T> {
|
|
39
|
-
_firewall: Computed<any>;
|
|
40
|
-
_nextChild: FirewallSignal<unknown> | null;
|
|
41
|
-
}
|
|
42
|
-
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
|
|
43
|
-
export interface Owner {
|
|
44
|
-
id?: string;
|
|
45
|
-
_disposal: Disposable | Disposable[] | null;
|
|
46
|
-
_parent: Owner | null;
|
|
47
|
-
_context: Record<symbol | string, unknown>;
|
|
48
|
-
_childCount: number;
|
|
49
|
-
_queue: IQueue;
|
|
50
|
-
_firstChild: Owner | null;
|
|
51
|
-
_nextSibling: Owner | null;
|
|
52
|
-
_pendingDisposal: Disposable | Disposable[] | null;
|
|
53
|
-
_pendingFirstChild: Owner | null;
|
|
54
|
-
}
|
|
55
|
-
export interface Computed<T> extends RawSignal<T>, Owner {
|
|
56
|
-
_deps: Link | null;
|
|
57
|
-
_depsTail: Link | null;
|
|
58
|
-
_flags: number;
|
|
59
|
-
_error?: unknown;
|
|
60
|
-
_statusFlags: number;
|
|
61
|
-
_height: number;
|
|
62
|
-
_nextHeap: Computed<any> | undefined;
|
|
63
|
-
_prevHeap: Computed<any>;
|
|
64
|
-
_fn: (prev?: T) => T;
|
|
65
|
-
_inFlight: PromiseLike<T> | AsyncIterable<T> | null;
|
|
66
|
-
_child: FirewallSignal<any> | null;
|
|
67
|
-
_notifyStatus?: (status?: number, error?: any) => void;
|
|
68
|
-
}
|
|
69
|
-
export interface Root extends Owner {
|
|
70
|
-
_root: true;
|
|
71
|
-
_parentComputed: Computed<any> | null;
|
|
72
|
-
dispose(self?: boolean): void;
|
|
73
|
-
}
|
|
1
|
+
import { handleAsync } from "./async.js";
|
|
2
|
+
import { $REFRESH } from "./constants.js";
|
|
3
|
+
import { type OptimisticLane } from "./lanes.js";
|
|
4
|
+
import { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, onCleanup } from "./owner.js";
|
|
5
|
+
import type { Computed, Disposable, FirewallSignal, Link, NodeOptions, Owner, Root, Signal } from "./types.js";
|
|
6
|
+
export { handleAsync };
|
|
7
|
+
export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions };
|
|
8
|
+
export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, onCleanup };
|
|
9
|
+
export declare let tracking: boolean;
|
|
10
|
+
export declare let stale: boolean;
|
|
11
|
+
export declare let refreshing: boolean;
|
|
12
|
+
export declare let pendingCheckActive: boolean;
|
|
13
|
+
export declare let foundPending: boolean;
|
|
14
|
+
export declare let pendingReadActive: boolean;
|
|
74
15
|
export declare let context: Owner | null;
|
|
75
|
-
export declare
|
|
16
|
+
export declare let currentOptimisticLane: OptimisticLane | null;
|
|
76
17
|
export declare function recompute(el: Computed<any>, create?: boolean): void;
|
|
77
|
-
export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
|
|
78
|
-
export declare function dispose(node: Computed<unknown>): void;
|
|
79
|
-
export declare function getNextChildId(owner: Owner): string;
|
|
80
18
|
export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
|
|
81
|
-
export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, initialValue?: T, options?:
|
|
82
|
-
export declare function signal<T>(v: T, options?:
|
|
83
|
-
export declare function signal<T>(v: T, options?:
|
|
84
|
-
export declare function optimisticSignal<T>(v: T, options?:
|
|
85
|
-
export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, initialValue?: T, options?:
|
|
19
|
+
export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, initialValue?: T, options?: NodeOptions<T>): Computed<T>;
|
|
20
|
+
export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
21
|
+
export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
|
|
22
|
+
export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
|
|
23
|
+
export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, initialValue?: T, options?: NodeOptions<T>): Computed<T>;
|
|
86
24
|
export declare function isEqual<T>(a: T, b: T): boolean;
|
|
87
25
|
/**
|
|
88
26
|
* Returns the current value stored inside the given compute function without triggering any
|
|
@@ -91,30 +29,13 @@ export declare function isEqual<T>(a: T, b: T): boolean;
|
|
|
91
29
|
export declare function untrack<T>(fn: () => T): T;
|
|
92
30
|
export declare function read<T>(el: Signal<T> | Computed<T>): T;
|
|
93
31
|
export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
|
|
94
|
-
export declare function
|
|
95
|
-
export declare function getOwner(): Owner | null;
|
|
96
|
-
export declare function onCleanup(fn: Disposable): Disposable;
|
|
97
|
-
export declare function createOwner(options?: {
|
|
98
|
-
id: string;
|
|
99
|
-
}): Root;
|
|
100
|
-
/**
|
|
101
|
-
* Creates a new non-tracked reactive context with manual disposal
|
|
102
|
-
*
|
|
103
|
-
* @param fn a function in which the reactive state is scoped
|
|
104
|
-
* @returns the output of `fn`.
|
|
105
|
-
*
|
|
106
|
-
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
|
|
107
|
-
*/
|
|
108
|
-
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
109
|
-
id: string;
|
|
110
|
-
}): T;
|
|
32
|
+
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
|
|
111
33
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
|
|
34
|
+
* Update _pendingSignal when pending state changes. When the override clears
|
|
35
|
+
* (pending -> not pending), merge the sub-lane into the source's lane so
|
|
36
|
+
* isPending effects are blocked until the full scope resolves.
|
|
116
37
|
*/
|
|
117
|
-
export declare function
|
|
38
|
+
export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
|
|
118
39
|
export declare function staleValues<T>(fn: () => T, set?: boolean): T;
|
|
119
40
|
export declare function pending<T>(fn: () => T): T;
|
|
120
41
|
export declare function isPending(fn: () => any): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Computed, NodeOptions, Owner } from "./types.js";
|
|
2
|
+
export declare let leafEffectActive: boolean;
|
|
2
3
|
export interface Effect<T> extends Computed<T>, Owner {
|
|
3
4
|
_effectFn: (val: T, prev: T | undefined) => void | (() => void);
|
|
4
5
|
_errorFn?: (err: unknown, cleanup: () => void) => void;
|
|
@@ -12,7 +13,7 @@ export interface Effect<T> extends Computed<T>, Owner {
|
|
|
12
13
|
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
|
|
13
14
|
* sources and recompute
|
|
14
15
|
*/
|
|
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), initialValue?: T, options?:
|
|
16
|
+
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), initialValue?: T, options?: NodeOptions<any> & {
|
|
16
17
|
render?: boolean;
|
|
17
18
|
defer?: boolean;
|
|
18
19
|
}): void;
|
|
@@ -26,4 +27,4 @@ export interface TrackedEffect extends Computed<void> {
|
|
|
26
27
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
27
28
|
* Children forbidden (__DEV__ throws). Uses stale reads.
|
|
28
29
|
*/
|
|
29
|
-
export declare function trackedEffect(fn: () => void | (() => void), options?:
|
|
30
|
+
export declare function trackedEffect(fn: () => void | (() => void), options?: NodeOptions<any>): void;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
|
|
2
2
|
export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
|
|
3
|
-
export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, dispose, signal, read, setSignal, onCleanup, optimisticSignal, optimisticComputed, getNextChildId, isPending, pending, refresh, isRefreshing, staleValues, handleAsync
|
|
3
|
+
export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, dispose, signal, read, setSignal, onCleanup, optimisticSignal, optimisticComputed, getNextChildId, isPending, pending, refresh, isRefreshing, staleValues, handleAsync } from "./core.js";
|
|
4
|
+
export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.js";
|
|
4
5
|
export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.js";
|
|
5
|
-
export { action
|
|
6
|
+
export { action } from "./action.js";
|
|
7
|
+
export { flush, Queue, GlobalQueue, trackOptimisticStore, type IQueue, type QueueCallback } from "./scheduler.js";
|
|
6
8
|
export * from "./constants.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type QueueCallback, type Transition } from "./scheduler.js";
|
|
2
|
+
import type { Computed, Signal } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* OptimisticLane represents the context for a single optimistic write.
|
|
5
|
+
* Each optimistic signal creates its own lane. Lanes merge when their
|
|
6
|
+
* dependency graphs overlap.
|
|
7
|
+
*/
|
|
8
|
+
export interface OptimisticLane {
|
|
9
|
+
_source: Signal<any>;
|
|
10
|
+
_pendingAsync: Set<Computed<any>>;
|
|
11
|
+
_effectQueues: [QueueCallback[], QueueCallback[]];
|
|
12
|
+
_mergedInto: OptimisticLane | null;
|
|
13
|
+
_transition: Transition | null;
|
|
14
|
+
_parentLane: OptimisticLane | null;
|
|
15
|
+
}
|
|
16
|
+
export declare const signalLanes: WeakMap<Signal<any>, OptimisticLane>;
|
|
17
|
+
export declare const activeLanes: Set<OptimisticLane>;
|
|
18
|
+
/**
|
|
19
|
+
* Get an existing lane for a signal or create a new one.
|
|
20
|
+
* Reuses lane for multiple writes to the same signal.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getOrCreateLane(signal: Signal<any>): OptimisticLane;
|
|
23
|
+
/**
|
|
24
|
+
* Union-find: find the root lane.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findLane(lane: OptimisticLane): OptimisticLane;
|
|
27
|
+
/**
|
|
28
|
+
* Merge two lanes when their dependency graphs overlap.
|
|
29
|
+
*/
|
|
30
|
+
export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveLane(el: {
|
|
35
|
+
_optimisticLane?: OptimisticLane;
|
|
36
|
+
}): OptimisticLane | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a node has an active optimistic override (pending value differs from base).
|
|
39
|
+
*/
|
|
40
|
+
export declare function hasActiveOverride(el: {
|
|
41
|
+
_optimistic?: boolean;
|
|
42
|
+
_pendingValue?: any;
|
|
43
|
+
}): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Assign or merge a lane onto a node. At convergence points (node already has
|
|
46
|
+
* a different active lane), merge unless the node has an active override.
|
|
47
|
+
*/
|
|
48
|
+
export declare function assignOrMergeLane(el: {
|
|
49
|
+
_optimisticLane?: OptimisticLane;
|
|
50
|
+
_optimistic?: boolean;
|
|
51
|
+
_pendingValue?: any;
|
|
52
|
+
}, sourceLane: OptimisticLane): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Computed, Disposable, Owner, Root } from "./types.js";
|
|
2
|
+
export declare function markDisposal(el: Owner): void;
|
|
3
|
+
export declare function dispose(node: Computed<unknown>): void;
|
|
4
|
+
export declare function disposeChildren(node: Owner, self?: boolean, zombie?: boolean): void;
|
|
5
|
+
export declare function getNextChildId(owner: Owner): string;
|
|
6
|
+
export declare function getObserver(): Owner | null;
|
|
7
|
+
export declare function getOwner(): Owner | null;
|
|
8
|
+
export declare function onCleanup(fn: Disposable): Disposable;
|
|
9
|
+
export declare function createOwner(options?: {
|
|
10
|
+
id: string;
|
|
11
|
+
}): Root;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new non-tracked reactive context with manual disposal
|
|
14
|
+
*
|
|
15
|
+
* @param fn a function in which the reactive state is scoped
|
|
16
|
+
* @returns the output of `fn`.
|
|
17
|
+
*
|
|
18
|
+
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
21
|
+
id: string;
|
|
22
|
+
}): T;
|
|
@@ -1,66 +1,13 @@
|
|
|
1
|
-
import type { Computed, Signal } from "./core.js";
|
|
2
1
|
import { type Heap } from "./heap.js";
|
|
2
|
+
import { activeLanes, assignOrMergeLane, findLane } from "./lanes.js";
|
|
3
|
+
import type { Computed, Signal } from "./types.js";
|
|
4
|
+
export { activeLanes, assignOrMergeLane, findLane };
|
|
5
|
+
export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane, type OptimisticLane } from "./lanes.js";
|
|
3
6
|
export declare const dirtyQueue: Heap;
|
|
4
7
|
export declare const zombieQueue: Heap;
|
|
5
8
|
export declare let clock: number;
|
|
6
9
|
export declare let activeTransition: Transition | null;
|
|
7
10
|
export declare let projectionWriteActive: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* OptimisticLane represents the context for a single optimistic write.
|
|
10
|
-
* Each optimistic signal creates its own lane. Lanes merge when their
|
|
11
|
-
* dependency graphs overlap.
|
|
12
|
-
*/
|
|
13
|
-
export interface OptimisticLane {
|
|
14
|
-
_source: Signal<any>;
|
|
15
|
-
_pendingAsync: Set<Computed<any>>;
|
|
16
|
-
_effectQueues: [QueueCallback[], QueueCallback[]];
|
|
17
|
-
_mergedInto: OptimisticLane | null;
|
|
18
|
-
_transition: Transition | null;
|
|
19
|
-
_parentLane: OptimisticLane | null;
|
|
20
|
-
}
|
|
21
|
-
export declare const activeLanes: Set<OptimisticLane>;
|
|
22
|
-
export declare let currentOptimisticLane: OptimisticLane | null;
|
|
23
|
-
export declare function setCurrentOptimisticLane(lane: OptimisticLane | null): void;
|
|
24
|
-
/**
|
|
25
|
-
* Get an existing lane for a signal or create a new one.
|
|
26
|
-
* Reuses lane for multiple writes to the same signal.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getOrCreateLane(signal: Signal<any>): OptimisticLane;
|
|
29
|
-
/**
|
|
30
|
-
* Union-find: find the root lane.
|
|
31
|
-
*/
|
|
32
|
-
export declare function findLane(lane: OptimisticLane): OptimisticLane;
|
|
33
|
-
/**
|
|
34
|
-
* Merge two lanes when their dependency graphs overlap.
|
|
35
|
-
*/
|
|
36
|
-
export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
|
|
37
|
-
/**
|
|
38
|
-
* Clear a signal's lane entry so the next getOrCreateLane creates a fresh lane.
|
|
39
|
-
* Used after merging a sub-lane (e.g., _pendingSignal) into a parent lane.
|
|
40
|
-
*/
|
|
41
|
-
export declare function clearLaneEntry(signal: Signal<any>): void;
|
|
42
|
-
/**
|
|
43
|
-
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
44
|
-
*/
|
|
45
|
-
export declare function resolveLane(el: {
|
|
46
|
-
_optimisticLane?: OptimisticLane;
|
|
47
|
-
}): OptimisticLane | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Check if a node has an active optimistic override (pending value differs from base).
|
|
50
|
-
*/
|
|
51
|
-
export declare function hasActiveOverride(el: {
|
|
52
|
-
_optimistic?: boolean;
|
|
53
|
-
_pendingValue?: any;
|
|
54
|
-
}): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Assign or merge a lane onto a node. At convergence points (node already has
|
|
57
|
-
* a different active lane), merge unless the node has an active override.
|
|
58
|
-
*/
|
|
59
|
-
export declare function assignOrMergeLane(el: {
|
|
60
|
-
_optimisticLane?: OptimisticLane;
|
|
61
|
-
_optimistic?: boolean;
|
|
62
|
-
_pendingValue?: any;
|
|
63
|
-
}, sourceLane: OptimisticLane): void;
|
|
64
11
|
export declare function setProjectionWriteActive(value: boolean): void;
|
|
65
12
|
export type QueueCallback = (type: number) => void;
|
|
66
13
|
type QueueStub = {
|
|
@@ -123,6 +70,6 @@ export declare const globalQueue: GlobalQueue;
|
|
|
123
70
|
* the queue synchronously to get the latest updates by calling `flush()`.
|
|
124
71
|
*/
|
|
125
72
|
export declare function flush(): void;
|
|
73
|
+
export declare function currentTransition(transition: Transition): Transition;
|
|
74
|
+
export declare function setActiveTransition(transition: Transition | null): void;
|
|
126
75
|
export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
|
|
127
|
-
export declare function action<Args extends any[], Y, R>(genFn: (...args: Args) => Generator<Y, R, any> | AsyncGenerator<Y, R, any>): (...args: Args) => Promise<R>;
|
|
128
|
-
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { NOT_PENDING } from "./constants.js";
|
|
2
|
+
import type { OptimisticLane } from "./lanes.js";
|
|
3
|
+
import type { IQueue, Transition } from "./scheduler.js";
|
|
4
|
+
export interface Disposable {
|
|
5
|
+
(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface Link {
|
|
8
|
+
_dep: Signal<unknown> | Computed<unknown>;
|
|
9
|
+
_sub: Computed<unknown>;
|
|
10
|
+
_nextDep: Link | null;
|
|
11
|
+
_prevSub: Link | null;
|
|
12
|
+
_nextSub: Link | null;
|
|
13
|
+
}
|
|
14
|
+
export interface NodeOptions<T> {
|
|
15
|
+
id?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
equals?: ((prev: T, next: T) => boolean) | false;
|
|
18
|
+
pureWrite?: boolean;
|
|
19
|
+
unobserved?: () => void;
|
|
20
|
+
lazy?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface RawSignal<T> {
|
|
23
|
+
_subs: Link | null;
|
|
24
|
+
_subsTail: Link | null;
|
|
25
|
+
_value: T;
|
|
26
|
+
_name?: string;
|
|
27
|
+
_equals: false | ((a: T, b: T) => boolean);
|
|
28
|
+
_pureWrite?: boolean;
|
|
29
|
+
_unobserved?: () => void;
|
|
30
|
+
_time: number;
|
|
31
|
+
_transition: Transition | null;
|
|
32
|
+
_pendingValue: T | typeof NOT_PENDING;
|
|
33
|
+
_optimistic?: boolean;
|
|
34
|
+
_optimisticLane?: OptimisticLane;
|
|
35
|
+
_pendingSignal?: Signal<boolean>;
|
|
36
|
+
_pendingValueComputed?: Computed<T>;
|
|
37
|
+
_parentSource?: Signal<any> | Computed<any>;
|
|
38
|
+
}
|
|
39
|
+
export interface FirewallSignal<T> extends RawSignal<T> {
|
|
40
|
+
_firewall: Computed<any>;
|
|
41
|
+
_nextChild: FirewallSignal<unknown> | null;
|
|
42
|
+
}
|
|
43
|
+
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
|
|
44
|
+
export interface Owner {
|
|
45
|
+
id?: string;
|
|
46
|
+
_disposal: Disposable | Disposable[] | null;
|
|
47
|
+
_parent: Owner | null;
|
|
48
|
+
_context: Record<symbol | string, unknown>;
|
|
49
|
+
_childCount: number;
|
|
50
|
+
_queue: IQueue;
|
|
51
|
+
_firstChild: Owner | null;
|
|
52
|
+
_nextSibling: Owner | null;
|
|
53
|
+
_pendingDisposal: Disposable | Disposable[] | null;
|
|
54
|
+
_pendingFirstChild: Owner | null;
|
|
55
|
+
}
|
|
56
|
+
export interface Computed<T> extends RawSignal<T>, Owner {
|
|
57
|
+
_deps: Link | null;
|
|
58
|
+
_depsTail: Link | null;
|
|
59
|
+
_flags: number;
|
|
60
|
+
_error?: unknown;
|
|
61
|
+
_statusFlags: number;
|
|
62
|
+
_height: number;
|
|
63
|
+
_nextHeap: Computed<any> | undefined;
|
|
64
|
+
_prevHeap: Computed<any>;
|
|
65
|
+
_fn: (prev?: T) => T;
|
|
66
|
+
_inFlight: PromiseLike<T> | AsyncIterable<T> | null;
|
|
67
|
+
_child: FirewallSignal<any> | null;
|
|
68
|
+
_notifyStatus?: (status?: number, error?: any) => void;
|
|
69
|
+
}
|
|
70
|
+
export interface Root extends Owner {
|
|
71
|
+
_root: true;
|
|
72
|
+
_parentComputed: Computed<any> | null;
|
|
73
|
+
dispose(self?: boolean): void;
|
|
74
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createRoot, runWithOwner, flush, getNextChildId, getContext, setContext, getOwner, onCleanup, getObserver, isEqual, untrack, isPending, pending, isRefreshing, refresh, SUPPORTS_PROXY } from "./core/index.js";
|
|
2
|
-
export type { Owner,
|
|
1
|
+
export { ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, getContext, setContext, getOwner, onCleanup, getObserver, isEqual, untrack, isPending, pending, isRefreshing, refresh, SUPPORTS_PROXY } from "./core/index.js";
|
|
2
|
+
export type { Owner, Context, ContextRecord, IQueue } from "./core/index.js";
|
|
3
3
|
export * from "./signals.js";
|
|
4
4
|
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
5
5
|
export * from "./store/index.js";
|
|
6
|
-
export { createLoadBoundary, createErrorBoundary,
|
|
6
|
+
export { createLoadBoundary, createErrorBoundary, flatten } from "./boundaries.js";
|