@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
package/dist/types/signals.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SignalOptions } from "./core/index.js";
|
|
2
|
-
import { Owner } from "./core/index.js";
|
|
3
2
|
export type Accessor<T> = () => T;
|
|
4
3
|
export type Setter<in out T> = {
|
|
5
4
|
<U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
|
|
@@ -102,7 +101,7 @@ export declare function createAsync<T>(compute: (prev: T | undefined, refreshing
|
|
|
102
101
|
*
|
|
103
102
|
* @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
|
|
104
103
|
*/
|
|
105
|
-
export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>,
|
|
104
|
+
export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
|
|
106
105
|
export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
|
|
107
106
|
/**
|
|
108
107
|
* Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
|
|
@@ -121,8 +120,8 @@ export declare function createEffect<Next, Init = Next>(compute: ComputeFunction
|
|
|
121
120
|
*
|
|
122
121
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
|
|
123
122
|
*/
|
|
124
|
-
export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>,
|
|
125
|
-
export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>,
|
|
123
|
+
export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
|
|
124
|
+
export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
|
|
126
125
|
/**
|
|
127
126
|
* Creates a tracked reactive effect that only tracks dependencies inside the effect itself
|
|
128
127
|
* ```typescript
|
|
@@ -150,25 +149,7 @@ export declare function createTrackedEffect(compute: () => void | (() => void),
|
|
|
150
149
|
*
|
|
151
150
|
* @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
|
|
152
151
|
*/
|
|
153
|
-
export declare function createReaction(effect: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions):
|
|
154
|
-
/**
|
|
155
|
-
* Creates a new non-tracked reactive context with manual disposal
|
|
156
|
-
*
|
|
157
|
-
* @param fn a function in which the reactive state is scoped
|
|
158
|
-
* @returns the output of `fn`.
|
|
159
|
-
*
|
|
160
|
-
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
|
|
161
|
-
*/
|
|
162
|
-
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
163
|
-
id: string;
|
|
164
|
-
}): T;
|
|
165
|
-
/**
|
|
166
|
-
* Runs the given function in the given owner to move ownership of nested primitives and cleanups.
|
|
167
|
-
* This method untracks the current scope.
|
|
168
|
-
*
|
|
169
|
-
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
|
|
170
|
-
*/
|
|
171
|
-
export declare function runWithOwner<T>(owner: Owner | null, run: () => T): T;
|
|
152
|
+
export declare function createReaction(effect: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): void;
|
|
172
153
|
/**
|
|
173
154
|
* Returns a promise of the resolved value of a reactive expression
|
|
174
155
|
* @param fn a reactive expression to resolve
|
|
@@ -177,23 +158,4 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
|
177
158
|
export declare function createOptimistic<T>(): Signal<T | undefined>;
|
|
178
159
|
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
179
160
|
export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
|
|
180
|
-
|
|
181
|
-
* Runs the given function in a transition scope, allowing for batch updates and optimizations.
|
|
182
|
-
* This is useful for grouping multiple state updates together to avoid unnecessary re-renders.
|
|
183
|
-
*
|
|
184
|
-
* @param fn A function that receives a resume function to continue the transition.
|
|
185
|
-
* The resume function can be called with another function to continue the transition.
|
|
186
|
-
*
|
|
187
|
-
* @description https://docs.solidjs.com/reference/advanced-reactivity/transition
|
|
188
|
-
*/
|
|
189
|
-
export declare function transition(fn: (resume: (fn: () => any | Promise<any>) => void) => any | Promise<any> | Iterable<any>): void;
|
|
190
|
-
/** Allows the user to mark a state change as non-urgent.
|
|
191
|
-
*
|
|
192
|
-
* @see {@link https://docs.solidjs.com/reference/advanced-reactivity/transition}
|
|
193
|
-
*
|
|
194
|
-
* @returns A tuple containing an accessor for the pending state and a function to start a transition.
|
|
195
|
-
*/
|
|
196
|
-
export declare function useTransition(): [
|
|
197
|
-
get: Accessor<boolean>,
|
|
198
|
-
start: (fn: (resume: (fn: () => any | Promise<any>) => void) => any | Promise<any> | Iterable<any>) => void
|
|
199
|
-
];
|
|
161
|
+
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { FirewallComputation } from "../core/effect.js";
|
|
2
1
|
import { type Store, type StoreOptions } from "./store.js";
|
|
3
2
|
export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T, initialValue?: T, options?: StoreOptions): {
|
|
4
3
|
store: Readonly<T>;
|
|
5
|
-
node:
|
|
4
|
+
node: any;
|
|
6
5
|
};
|
|
7
6
|
/**
|
|
8
7
|
* Creates a mutable derived value
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Signal } from "../core/index.js";
|
|
2
2
|
export type Store<T> = Readonly<T>;
|
|
3
3
|
export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
|
|
4
4
|
export type StoreOptions = {
|
|
5
5
|
key?: string | ((item: NonNullable<any>) => any);
|
|
6
6
|
all?: boolean;
|
|
7
7
|
};
|
|
8
|
-
type DataNode =
|
|
8
|
+
type DataNode = Signal<any>;
|
|
9
9
|
type DataNodes = Record<PropertyKey, DataNode>;
|
|
10
10
|
export declare const $TRACK: unique symbol, $DEEP: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
|
|
11
11
|
export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l";
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type Flags = number;
|
|
2
|
-
export declare const ERROR_OFFSET = 0;
|
|
3
|
-
export declare const ERROR_BIT: number;
|
|
4
|
-
export declare const ERROR: unique symbol;
|
|
5
|
-
export declare const LOADING_OFFSET = 1;
|
|
6
|
-
export declare const LOADING_BIT: number;
|
|
7
|
-
export declare const LOADING: unique symbol;
|
|
8
|
-
export declare const UNINITIALIZED_OFFSET = 2;
|
|
9
|
-
export declare const UNINITIALIZED_BIT: number;
|
|
10
|
-
export declare const UNINITIALIZED: unique symbol;
|
|
11
|
-
export declare const DEFAULT_FLAGS: number;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Owner tracking is used to enable nested tracking scopes with automatic cleanup.
|
|
3
|
-
* We also use owners to also keep track of which error handling context we are in.
|
|
4
|
-
*
|
|
5
|
-
* If you write the following
|
|
6
|
-
*
|
|
7
|
-
* const a = createOwner(() => {
|
|
8
|
-
* const b = createOwner(() => {});
|
|
9
|
-
*
|
|
10
|
-
* const c = createOwner(() => {
|
|
11
|
-
* const d = createOwner(() => {});
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* const e = createOwner(() => {});
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* The owner tree will look like this:
|
|
18
|
-
*
|
|
19
|
-
* a
|
|
20
|
-
* /|\
|
|
21
|
-
* b-c-e
|
|
22
|
-
* |
|
|
23
|
-
* d
|
|
24
|
-
*
|
|
25
|
-
* Following the _nextSibling pointers of each owner will first give you its children, and then its siblings (in reverse).
|
|
26
|
-
* a -> e -> c -> d -> b
|
|
27
|
-
*
|
|
28
|
-
* Note that the owner tree is largely orthogonal to the reactivity tree, and is much closer to the component tree.
|
|
29
|
-
*/
|
|
30
|
-
import { type IQueue } from "./scheduler.js";
|
|
31
|
-
export type ContextRecord = Record<string | symbol, unknown>;
|
|
32
|
-
export interface Disposable {
|
|
33
|
-
(): void;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Returns the currently executing parent owner.
|
|
37
|
-
*/
|
|
38
|
-
export declare function getOwner(): Owner | null;
|
|
39
|
-
export declare function setOwner(owner: Owner | null): Owner | null;
|
|
40
|
-
export declare class Owner {
|
|
41
|
-
_parent: Owner | null;
|
|
42
|
-
_nextSibling: Owner | null;
|
|
43
|
-
_prevSibling: Owner | null;
|
|
44
|
-
_state: number;
|
|
45
|
-
_disposal: Disposable | Disposable[] | null;
|
|
46
|
-
_context: ContextRecord;
|
|
47
|
-
_queue: IQueue;
|
|
48
|
-
_childCount: number;
|
|
49
|
-
id: string | null;
|
|
50
|
-
constructor(id?: string | null, skipAppend?: boolean);
|
|
51
|
-
append(child: Owner): void;
|
|
52
|
-
dispose(this: Owner, self?: boolean): void;
|
|
53
|
-
_disposeNode(): void;
|
|
54
|
-
emptyDisposal(): void;
|
|
55
|
-
getNextChildId(): string;
|
|
56
|
-
}
|
|
57
|
-
export interface Context<T> {
|
|
58
|
-
readonly id: symbol;
|
|
59
|
-
readonly defaultValue: T | undefined;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Context provides a form of dependency injection. It is used to save from needing to pass
|
|
63
|
-
* data as props through intermediate components. This function creates a new context object
|
|
64
|
-
* that can be used with `getContext` and `setContext`.
|
|
65
|
-
*
|
|
66
|
-
* A default value can be provided here which will be used when a specific value is not provided
|
|
67
|
-
* via a `setContext` call.
|
|
68
|
-
*/
|
|
69
|
-
export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
|
|
70
|
-
/**
|
|
71
|
-
* Attempts to get a context value for the given key.
|
|
72
|
-
*
|
|
73
|
-
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
74
|
-
* @throws `ContextNotFoundError` if a context value has not been set yet.
|
|
75
|
-
*/
|
|
76
|
-
export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
|
|
77
|
-
/**
|
|
78
|
-
* Attempts to set a context value on the parent scope with the given key.
|
|
79
|
-
*
|
|
80
|
-
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
81
|
-
*/
|
|
82
|
-
export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
|
|
83
|
-
/**
|
|
84
|
-
* Whether the given context is currently defined.
|
|
85
|
-
*/
|
|
86
|
-
export declare function hasContext(context: Context<any>, owner?: Owner | null): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Runs an effect once before the reactive scope is disposed
|
|
89
|
-
* @param fn an effect that should run only once on cleanup
|
|
90
|
-
*
|
|
91
|
-
* @returns the same {@link fn} function that was passed in
|
|
92
|
-
*
|
|
93
|
-
* @description https://docs.solidjs.com/reference/lifecycle/on-cleanup
|
|
94
|
-
*/
|
|
95
|
-
export declare function onCleanup(fn: Disposable): Disposable;
|