@solidjs/signals 0.7.4 → 0.8.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 +1036 -1402
- package/dist/node.cjs +1164 -1532
- package/dist/prod.js +1151 -1511
- package/dist/types/boundaries.d.ts +10 -8
- package/dist/types/core/constants.d.ts +22 -13
- package/dist/types/core/context.d.ts +28 -0
- package/dist/types/core/core.d.ts +96 -135
- package/dist/types/core/effect.d.ts +14 -42
- package/dist/types/core/error.d.ts +2 -1
- package/dist/types/core/heap.d.ts +15 -0
- package/dist/types/core/index.d.ts +4 -5
- package/dist/types/core/scheduler.d.ts +28 -54
- package/dist/types/index.d.ts +4 -4
- package/dist/types/map.d.ts +1 -1
- package/dist/types/signals.d.ts +5 -43
- package/dist/types/store/projection.d.ts +1 -2
- package/dist/types/store/store.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/core/flags.d.ts +0 -11
- package/dist/types/core/owner.d.ts +0 -95
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { Queue, type Computed, type Effect } from "./core/index.js";
|
|
2
|
+
import type { Signal } from "./core/index.js";
|
|
3
|
+
export interface BoundaryComputed<T> extends Computed<T> {
|
|
4
|
+
_propagationMask: number;
|
|
5
|
+
}
|
|
3
6
|
export declare class CollectionQueue extends Queue {
|
|
4
7
|
_collectionType: number;
|
|
5
|
-
_nodes: Set<Effect
|
|
6
|
-
_disabled:
|
|
8
|
+
_nodes: Set<Effect<any>>;
|
|
9
|
+
_disabled: Signal<boolean>;
|
|
7
10
|
constructor(type: number);
|
|
8
11
|
run(type: number): void;
|
|
9
|
-
notify(node: Effect
|
|
10
|
-
merge(queue: CollectionQueue): void;
|
|
12
|
+
notify(node: Effect<any>, type: number, flags: number): boolean;
|
|
11
13
|
}
|
|
12
14
|
export declare enum BoundaryMode {
|
|
13
15
|
VISIBLE = "visible",
|
|
14
16
|
HIDDEN = "hidden"
|
|
15
17
|
}
|
|
16
18
|
export declare function createBoundary<T>(fn: () => T, condition: () => BoundaryMode): () => T | undefined;
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () =>
|
|
19
|
+
export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
|
|
20
|
+
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
|
|
19
21
|
export declare function flatten(children: any, options?: {
|
|
20
22
|
skipNonRendered?: boolean;
|
|
21
23
|
doNotUnwrap?: boolean;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
export declare const enum ReactiveFlags {
|
|
2
|
+
None = 0,
|
|
3
|
+
Check = 1,
|
|
4
|
+
Dirty = 2,
|
|
5
|
+
RecomputingDeps = 4,
|
|
6
|
+
InHeap = 8,
|
|
7
|
+
InHeapHeight = 16,
|
|
8
|
+
Zombie = 32,
|
|
9
|
+
Disposed = 64
|
|
10
|
+
}
|
|
11
|
+
export declare const enum StatusFlags {
|
|
12
|
+
None = 0,
|
|
13
|
+
Pending = 1,
|
|
14
|
+
Error = 2,
|
|
15
|
+
Uninitialized = 4
|
|
16
|
+
}
|
|
17
|
+
export declare const enum EffectType {
|
|
18
|
+
Pure = 0,
|
|
19
|
+
Render = 1,
|
|
20
|
+
User = 2
|
|
21
|
+
}
|
|
22
|
+
export declare const NOT_PENDING: {};
|
|
14
23
|
export declare const SUPPORTS_PROXY: boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Owner } from "./core.js";
|
|
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;
|
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* coalesce computations and skip altogether recalculating unused sections of the graph.
|
|
14
|
-
* - Each computation node tracks its sources and its observers (observers are other
|
|
15
|
-
* elements that have this node as a source). Source and observer links are updated automatically
|
|
16
|
-
* as observer computations re-evaluate and call get() on their sources.
|
|
17
|
-
* - Each node stores a cache state (clean/check/dirty) to support the change propagation algorithm:
|
|
18
|
-
*
|
|
19
|
-
* In general, execution proceeds in three passes:
|
|
20
|
-
*
|
|
21
|
-
* 1. write() propagates changes down the graph to the leaves
|
|
22
|
-
* direct children are marked as dirty and their deeper descendants marked as check
|
|
23
|
-
* (no computations are evaluated)
|
|
24
|
-
* 2. read() requests that parent nodes updateIfNecessary(), which proceeds recursively up the tree
|
|
25
|
-
* to decide whether the node is clean (parents unchanged) or dirty (parents changed)
|
|
26
|
-
* 3. updateIfNecessary() evaluates the computation if the node is dirty (the computations are
|
|
27
|
-
* executed in root to leaf order)
|
|
28
|
-
*/
|
|
29
|
-
import { type Flags } from "./flags.js";
|
|
30
|
-
import { Owner } from "./owner.js";
|
|
31
|
-
import { type Transition } from "./scheduler.js";
|
|
1
|
+
import { NOT_PENDING, ReactiveFlags, StatusFlags } from "./constants.js";
|
|
2
|
+
import { type IQueue, type Transition } from "./scheduler.js";
|
|
3
|
+
export interface Disposable {
|
|
4
|
+
(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface Link {
|
|
7
|
+
_dep: Signal<unknown> | Computed<unknown>;
|
|
8
|
+
_sub: Computed<unknown>;
|
|
9
|
+
_nextDep: Link | null;
|
|
10
|
+
_prevSub: Link | null;
|
|
11
|
+
_nextSub: Link | null;
|
|
12
|
+
}
|
|
32
13
|
export interface SignalOptions<T> {
|
|
33
14
|
id?: string;
|
|
34
15
|
name?: string;
|
|
@@ -36,125 +17,105 @@ export interface SignalOptions<T> {
|
|
|
36
17
|
pureWrite?: boolean;
|
|
37
18
|
unobserved?: () => void;
|
|
38
19
|
}
|
|
39
|
-
export interface
|
|
40
|
-
|
|
20
|
+
export interface RawSignal<T> {
|
|
21
|
+
id?: string;
|
|
22
|
+
_subs: Link | null;
|
|
23
|
+
_subsTail: Link | null;
|
|
24
|
+
_value: T;
|
|
25
|
+
_error?: unknown;
|
|
26
|
+
_statusFlags: StatusFlags;
|
|
27
|
+
_name?: string;
|
|
28
|
+
_equals: false | ((a: T, b: T) => boolean);
|
|
29
|
+
_pureWrite?: boolean;
|
|
41
30
|
_unobserved?: () => void;
|
|
42
|
-
_updateIfNecessary: () => void;
|
|
43
|
-
_stateFlags: Flags;
|
|
44
31
|
_time: number;
|
|
32
|
+
_pendingValue: T | typeof NOT_PENDING;
|
|
33
|
+
_pendingCheck?: Signal<boolean> & {
|
|
34
|
+
_set: (v: boolean) => void;
|
|
35
|
+
};
|
|
36
|
+
_pendingSignal?: Signal<T> & {
|
|
37
|
+
_set: (v: T) => void;
|
|
38
|
+
};
|
|
45
39
|
_transition?: Transition;
|
|
46
|
-
_cloned?: Computation;
|
|
47
40
|
}
|
|
48
|
-
export interface
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_handlerMask: Flags;
|
|
52
|
-
_notifyFlags: (mask: Flags, newFlags: Flags) => void;
|
|
53
|
-
_time: number;
|
|
54
|
-
_cloned?: Computation;
|
|
41
|
+
export interface FirewallSignal<T> extends RawSignal<T> {
|
|
42
|
+
_owner: Computed<any>;
|
|
43
|
+
_nextChild: FirewallSignal<unknown> | null;
|
|
55
44
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_name: string | undefined;
|
|
69
|
-
_equals: false | ((a: T, b: T) => boolean);
|
|
70
|
-
_unobserved: (() => void) | undefined;
|
|
71
|
-
_pureWrite: boolean;
|
|
72
|
-
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
73
|
-
_stateFlags: number;
|
|
74
|
-
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
75
|
-
_handlerMask: number;
|
|
76
|
-
_time: number;
|
|
77
|
-
_forceNotify: boolean;
|
|
78
|
-
_transition?: Transition | undefined;
|
|
79
|
-
_cloned?: Computation;
|
|
80
|
-
_optimistic?: (() => void) & {
|
|
81
|
-
_transition?: Transition;
|
|
82
|
-
_init?: () => void;
|
|
83
|
-
};
|
|
84
|
-
constructor(initialValue: T | undefined, compute: null | ((p?: T) => T), options?: SignalOptions<T>);
|
|
85
|
-
_read(): T;
|
|
86
|
-
/**
|
|
87
|
-
* Return the current value of this computation
|
|
88
|
-
* Automatically re-executes the surrounding computation when the value changes
|
|
89
|
-
*/
|
|
90
|
-
read(): T;
|
|
91
|
-
/**
|
|
92
|
-
* Return the current value of this computation
|
|
93
|
-
* Automatically re-executes the surrounding computation when the value changes
|
|
94
|
-
*
|
|
95
|
-
* If the computation has any unresolved ancestors, this function waits for the value to resolve
|
|
96
|
-
* before continuing
|
|
97
|
-
*/
|
|
98
|
-
wait(): T;
|
|
99
|
-
/** Update the computation with a new value. */
|
|
100
|
-
write(value: T | ((currentValue: T) => T) | UNCHANGED, flags?: number, raw?: boolean): T;
|
|
101
|
-
/**
|
|
102
|
-
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
103
|
-
*/
|
|
104
|
-
_notify(state: number, skipQueue?: boolean): void;
|
|
105
|
-
/**
|
|
106
|
-
* Notify the computation that one of its sources has changed flags.
|
|
107
|
-
*
|
|
108
|
-
* @param mask A bitmask for which flag(s) were changed.
|
|
109
|
-
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
110
|
-
*/
|
|
111
|
-
_notifyFlags(mask: Flags, newFlags: Flags): void;
|
|
112
|
-
_setError(error: unknown): void;
|
|
113
|
-
/**
|
|
114
|
-
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
115
|
-
* before they are read. We've also adapted it to return the loading state of the computation,
|
|
116
|
-
* so that we can propagate that to the computation's observers.
|
|
117
|
-
*
|
|
118
|
-
* This function will ensure that the value and states we read from the computation are up to date
|
|
119
|
-
*/
|
|
120
|
-
_updateIfNecessary(): void;
|
|
121
|
-
/**
|
|
122
|
-
* Remove ourselves from the owner graph and the computation graph
|
|
123
|
-
*/
|
|
124
|
-
_disposeNode(): void;
|
|
45
|
+
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
|
|
46
|
+
export interface Owner {
|
|
47
|
+
id?: string;
|
|
48
|
+
_disposal: Disposable | Disposable[] | null;
|
|
49
|
+
_parent: Owner | null;
|
|
50
|
+
_context: Record<symbol | string, unknown>;
|
|
51
|
+
_childCount: number;
|
|
52
|
+
_queue: IQueue;
|
|
53
|
+
_firstChild: Owner | null;
|
|
54
|
+
_nextSibling: Owner | null;
|
|
55
|
+
_pendingDisposal: Disposable | Disposable[] | null;
|
|
56
|
+
_pendingFirstChild: Owner | null;
|
|
125
57
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
58
|
+
export interface Computed<T> extends RawSignal<T>, Owner {
|
|
59
|
+
_deps: Link | null;
|
|
60
|
+
_depsTail: Link | null;
|
|
61
|
+
_flags: ReactiveFlags;
|
|
62
|
+
_height: number;
|
|
63
|
+
_nextHeap: Computed<any> | undefined;
|
|
64
|
+
_prevHeap: Computed<any>;
|
|
65
|
+
_fn: (prev?: T) => T;
|
|
66
|
+
_child: FirewallSignal<any> | null;
|
|
67
|
+
_notifyQueue?: (statusFlagsChanged: boolean, prevStatusFlags: number) => void;
|
|
68
|
+
}
|
|
69
|
+
export interface Root extends Owner {
|
|
70
|
+
_root: true;
|
|
71
|
+
_parentComputed: Computed<any> | null;
|
|
72
|
+
dispose(self?: boolean): void;
|
|
73
|
+
}
|
|
74
|
+
export declare function recompute(el: Computed<any>, create?: boolean): void;
|
|
75
|
+
export declare function getNextChildId(owner: Owner): string;
|
|
76
|
+
export declare function computed<T>(fn: (prev?: T) => T): Computed<T>;
|
|
77
|
+
export declare function computed<T>(fn: (prev: T) => T, initialValue?: T, options?: SignalOptions<T>): Computed<T>;
|
|
78
|
+
export declare function asyncComputed<T>(asyncFn: (prev?: T, refreshing?: boolean) => T | Promise<T> | AsyncIterable<T>): Computed<T> & {
|
|
79
|
+
_refresh: () => void;
|
|
80
|
+
};
|
|
81
|
+
export declare function asyncComputed<T>(asyncFn: (prev: T, refreshing?: boolean) => T | Promise<T> | AsyncIterable<T>, initialValue: T, options?: SignalOptions<T>): Computed<T> & {
|
|
82
|
+
_refresh: () => void;
|
|
83
|
+
};
|
|
84
|
+
export declare function signal<T>(v: T, options?: SignalOptions<T>): Signal<T>;
|
|
85
|
+
export declare function signal<T>(v: T, options?: SignalOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
|
|
134
86
|
export declare function isEqual<T>(a: T, b: T): boolean;
|
|
135
87
|
/**
|
|
136
88
|
* Returns the current value stored inside the given compute function without triggering any
|
|
137
89
|
* dependencies. Use `untrack` if you want to also disable owner tracking.
|
|
138
90
|
*/
|
|
139
91
|
export declare function untrack<T>(fn: () => T): T;
|
|
92
|
+
export declare function read<T>(el: Signal<T> | Computed<T>): T;
|
|
93
|
+
export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
|
|
94
|
+
export declare function getObserver(): Owner | null;
|
|
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;
|
|
140
100
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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
|
|
143
107
|
*/
|
|
144
|
-
export declare function
|
|
108
|
+
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
109
|
+
id: string;
|
|
110
|
+
}): T;
|
|
145
111
|
/**
|
|
146
|
-
*
|
|
112
|
+
* Runs the given function in the given owner to move ownership of nested primitives and cleanups.
|
|
113
|
+
* This method untracks the current scope.
|
|
114
|
+
*
|
|
115
|
+
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
|
|
147
116
|
*/
|
|
117
|
+
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
|
|
118
|
+
export declare function staleValues<T>(fn: () => T, set?: boolean): T;
|
|
119
|
+
export declare function pending<T>(fn: () => T): T;
|
|
148
120
|
export declare function isPending(fn: () => any): boolean;
|
|
149
121
|
export declare function isPending(fn: () => any, loadingValue: boolean): boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Attempts to resolve value of expression synchronously returning the last resolved value for any async computation.
|
|
152
|
-
*/
|
|
153
|
-
export declare function latest<T>(fn: () => T): T;
|
|
154
|
-
export declare function latest<T, U>(fn: () => T, fallback: U): T | U;
|
|
155
|
-
/**
|
|
156
|
-
* A convenient wrapper that calls `compute` with the `owner` and `observer` and is guaranteed
|
|
157
|
-
* to reset the global context after the computation is finished even if an error is thrown.
|
|
158
|
-
*/
|
|
159
|
-
export declare function compute<T>(owner: Owner | null, fn: (val: T) => T, observer: Computation<T>): T;
|
|
160
|
-
export declare function compute<T>(owner: Owner | null, fn: (val: undefined) => T, observer: null): T;
|
|
@@ -1,47 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type Computed, type Owner, type SignalOptions } from "./core.js";
|
|
2
|
+
export interface Effect<T> extends Computed<T>, Owner {
|
|
3
|
+
_effectFn: (val: T, prev: T | undefined) => void | (() => void);
|
|
4
|
+
_errorFn?: (err: unknown, cleanup: () => void) => void;
|
|
5
|
+
_cleanup?: () => void;
|
|
6
|
+
_modified: boolean;
|
|
7
|
+
_prevValue: T | undefined;
|
|
8
|
+
_type: number;
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
|
|
6
12
|
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
|
|
7
13
|
* sources and recompute
|
|
8
14
|
*/
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
_prevValue: T | undefined;
|
|
15
|
-
_type: typeof EFFECT_RENDER | typeof EFFECT_USER;
|
|
16
|
-
constructor(initialValue: T, compute: (val?: T) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown) => void | (() => void), options?: SignalOptions<T> & {
|
|
17
|
-
render?: boolean;
|
|
18
|
-
defer?: boolean;
|
|
19
|
-
});
|
|
20
|
-
write(value: T, flags?: number): T;
|
|
21
|
-
_notify(state: number, skipQueue?: boolean): void;
|
|
22
|
-
_notifyFlags(mask: Flags, newFlags: Flags): void;
|
|
23
|
-
_setError(error: unknown): void;
|
|
24
|
-
_disposeNode(): void;
|
|
25
|
-
_run(type: number): void;
|
|
26
|
-
}
|
|
27
|
-
export declare class TrackedEffect extends Computation {
|
|
28
|
-
_type: number;
|
|
29
|
-
_cleanup: (() => void) | undefined;
|
|
30
|
-
constructor(compute: () => void | (() => void), options?: SignalOptions<undefined>);
|
|
31
|
-
_notify(state: number, skipQueue?: boolean): void;
|
|
32
|
-
_disposeNode(): void;
|
|
33
|
-
_run(type: number): void;
|
|
34
|
-
}
|
|
35
|
-
export declare class EagerComputation<T = any> extends Computation<T> {
|
|
36
|
-
constructor(initialValue: T, compute: () => T, options?: SignalOptions<T> & {
|
|
37
|
-
defer?: boolean;
|
|
38
|
-
});
|
|
39
|
-
_notify(state: number, skipQueue?: boolean): void;
|
|
40
|
-
_run(): void;
|
|
41
|
-
}
|
|
42
|
-
export declare class FirewallComputation extends Computation {
|
|
43
|
-
firewall: boolean;
|
|
44
|
-
constructor(compute: () => void);
|
|
45
|
-
_notify(state: number, skipQueue?: boolean): void;
|
|
46
|
-
_run(): void;
|
|
47
|
-
}
|
|
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?: SignalOptions<any> & {
|
|
16
|
+
render?: boolean;
|
|
17
|
+
defer?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
export declare function runEffect(this: Effect<any>): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactiveFlags } from "./constants.js";
|
|
2
|
+
import type { Computed } from "./core.js";
|
|
3
|
+
export interface Heap {
|
|
4
|
+
_heap: (Computed<unknown> | undefined)[];
|
|
5
|
+
_marked: boolean;
|
|
6
|
+
_min: number;
|
|
7
|
+
_max: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function increaseHeapSize(n: number, heap: Heap): void;
|
|
10
|
+
export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
|
|
11
|
+
export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
|
|
12
|
+
export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
|
|
13
|
+
export declare function markHeap(heap: Heap): void;
|
|
14
|
+
export declare function markNode(el: Computed<unknown>, newState?: ReactiveFlags): void;
|
|
15
|
+
export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { flush, Queue,
|
|
2
|
+
export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
|
|
3
|
+
export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, signal, asyncComputed, read, setSignal, onCleanup, getNextChildId, isPending, pending, staleValues, type Owner, type Computed, type Root, type Signal, type SignalOptions } from "./core.js";
|
|
4
|
+
export { effect, type Effect } from "./effect.js";
|
|
5
|
+
export { flush, Queue, type IQueue } from "./scheduler.js";
|
|
6
6
|
export * from "./constants.js";
|
|
7
|
-
export * from "./flags.js";
|
|
@@ -1,77 +1,51 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { Computed, Signal } from "./core.js";
|
|
2
|
+
import { type Heap } from "./heap.js";
|
|
3
3
|
export declare let clock: number;
|
|
4
|
-
export declare
|
|
5
|
-
export declare let
|
|
6
|
-
export
|
|
4
|
+
export declare let activeTransition: Transition | null;
|
|
5
|
+
export declare let unobserved: Signal<unknown>[];
|
|
6
|
+
export interface Transition {
|
|
7
|
+
time: number;
|
|
8
|
+
asyncNodes: Computed<any>[];
|
|
9
|
+
pendingNodes: Signal<any>[];
|
|
10
|
+
queues: [QueueCallback[], QueueCallback[]];
|
|
11
|
+
}
|
|
12
|
+
export declare function schedule(): void;
|
|
13
|
+
export declare const dirtyQueue: Heap;
|
|
14
|
+
export declare const zombieQueue: Heap;
|
|
7
15
|
export type QueueCallback = (type: number) => void;
|
|
8
16
|
export interface IQueue {
|
|
9
17
|
enqueue(type: number, fn: QueueCallback): void;
|
|
10
18
|
run(type: number): boolean | void;
|
|
11
|
-
flush(): void;
|
|
12
19
|
addChild(child: IQueue): void;
|
|
13
20
|
removeChild(child: IQueue): void;
|
|
14
21
|
created: number;
|
|
15
|
-
notify(
|
|
16
|
-
merge(queue: IQueue): void;
|
|
22
|
+
notify(node: Computed<any>, mask: number, flags: number): boolean;
|
|
17
23
|
_parent: IQueue | null;
|
|
18
|
-
_cloned?: IQueue | undefined;
|
|
19
24
|
}
|
|
20
25
|
export declare class Queue implements IQueue {
|
|
21
26
|
_parent: IQueue | null;
|
|
22
|
-
_running: boolean;
|
|
23
27
|
_queues: [QueueCallback[], QueueCallback[]];
|
|
24
28
|
_children: IQueue[];
|
|
25
29
|
created: number;
|
|
26
|
-
|
|
30
|
+
addChild(child: IQueue): void;
|
|
31
|
+
removeChild(child: IQueue): void;
|
|
32
|
+
notify(node: Computed<any>, mask: number, flags: number): boolean;
|
|
27
33
|
run(type: number): void;
|
|
34
|
+
enqueue(type: number, fn: QueueCallback): void;
|
|
35
|
+
}
|
|
36
|
+
export declare class GlobalQueue extends Queue {
|
|
37
|
+
_running: boolean;
|
|
38
|
+
_pendingNodes: Signal<any>[];
|
|
39
|
+
static _update: (el: Computed<unknown>) => void;
|
|
40
|
+
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
28
41
|
flush(): void;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
notify(...args: any[]): boolean;
|
|
32
|
-
merge(queue: Queue): void;
|
|
42
|
+
notify(node: Computed<any>, mask: number, flags: number): boolean;
|
|
43
|
+
initTransition(node: Computed<any>): void;
|
|
33
44
|
}
|
|
34
|
-
export declare const globalQueue:
|
|
45
|
+
export declare const globalQueue: GlobalQueue;
|
|
35
46
|
/**
|
|
36
47
|
* By default, changes are batched on the microtask queue which is an async process. You can flush
|
|
37
48
|
* the queue synchronously to get the latest updates by calling `flush()`.
|
|
38
49
|
*/
|
|
39
50
|
export declare function flush(): void;
|
|
40
|
-
export declare function
|
|
41
|
-
export declare class Transition implements IQueue {
|
|
42
|
-
_sources: Map<Computation, Computation>;
|
|
43
|
-
_pendingNodes: Set<Effect>;
|
|
44
|
-
_promises: Set<Promise<any>>;
|
|
45
|
-
_optimistic: Set<(() => void) & {
|
|
46
|
-
_transition?: Transition;
|
|
47
|
-
}>;
|
|
48
|
-
_done: Transition | boolean;
|
|
49
|
-
_queues: [QueueCallback[], QueueCallback[]];
|
|
50
|
-
_clonedQueues: Map<Queue, Queue>;
|
|
51
|
-
_pureQueue: QueueCallback[];
|
|
52
|
-
_children: IQueue[];
|
|
53
|
-
_parent: IQueue | null;
|
|
54
|
-
_running: boolean;
|
|
55
|
-
_scheduled: boolean;
|
|
56
|
-
_cloned: Queue;
|
|
57
|
-
_signal: Computation;
|
|
58
|
-
created: number;
|
|
59
|
-
constructor(signal: Computation);
|
|
60
|
-
enqueue(type: number, fn: QueueCallback): void;
|
|
61
|
-
run(type: number): void;
|
|
62
|
-
flush(): void;
|
|
63
|
-
addChild(child: IQueue): void;
|
|
64
|
-
removeChild(child: IQueue): void;
|
|
65
|
-
notify(node: Effect, type: number, flags: number): boolean;
|
|
66
|
-
merge(queue: Transition): void;
|
|
67
|
-
schedule(): void;
|
|
68
|
-
runTransition(fn: () => any | Promise<any>, force?: boolean): void;
|
|
69
|
-
addOptimistic(fn: (() => void) & {
|
|
70
|
-
_transition?: Transition;
|
|
71
|
-
}): void;
|
|
72
|
-
}
|
|
73
|
-
export declare function cloneGraph(node: Computation): Computation;
|
|
74
|
-
export declare function getOGSource<T extends Computation>(input: T): T;
|
|
75
|
-
export declare function getTransitionSource<T extends Computation>(input: T): T;
|
|
76
|
-
export declare function getQueue(node: Computation): IQueue;
|
|
77
|
-
export declare function initialDispose(node: any): void;
|
|
51
|
+
export declare function transitionComplete(transition: Transition): boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { SignalOptions, Context, ContextRecord,
|
|
3
|
-
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
1
|
+
export { ContextNotFoundError, NoOwnerError, NotReadyError, createContext, createRoot, runWithOwner, flush, getNextChildId, getContext, setContext, getOwner, onCleanup, getObserver, isEqual, untrack, isPending, pending, SUPPORTS_PROXY } from "./core/index.js";
|
|
2
|
+
export type { Owner, SignalOptions, Context, ContextRecord, IQueue } from "./core/index.js";
|
|
4
3
|
export * from "./signals.js";
|
|
4
|
+
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
5
5
|
export * from "./store/index.js";
|
|
6
|
-
export {
|
|
6
|
+
export { createLoadBoundary, createErrorBoundary, createBoundary, flatten, type BoundaryMode } from "./boundaries.js";
|
package/dist/types/map.d.ts
CHANGED