@solidjs/signals 0.2.5 → 0.3.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 +170 -175
- package/dist/node.cjs +394 -401
- package/dist/prod.js +392 -397
- package/dist/types/core/{suspense.d.ts → boundaries.d.ts} +3 -3
- package/dist/types/core/core.d.ts +1 -13
- package/dist/types/core/index.d.ts +4 -3
- package/dist/types/core/owner.d.ts +6 -1
- package/dist/types/core/scheduler.d.ts +1 -1
- package/dist/types/core/utils.d.ts +3 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +3 -11
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ import { type Effect } from "./effect.js";
|
|
|
3
3
|
import { Queue } from "./scheduler.js";
|
|
4
4
|
export declare class SuspenseQueue extends Queue {
|
|
5
5
|
_nodes: Set<Effect>;
|
|
6
|
-
_fallback: boolean
|
|
7
|
-
|
|
8
|
-
run(type: number): true | undefined;
|
|
6
|
+
_fallback: Computation<boolean>;
|
|
7
|
+
run(type: number): boolean | undefined;
|
|
9
8
|
_update(node: Effect): void;
|
|
10
9
|
}
|
|
11
10
|
export declare function createSuspense(fn: () => any, fallback: () => any): () => any;
|
|
11
|
+
export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error: unknown, reset: () => void) => U): () => any;
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { type Flags } from "./flags.js";
|
|
30
30
|
import { Owner } from "./owner.js";
|
|
31
|
-
import { type IQueue } from "./scheduler.js";
|
|
32
31
|
export interface SignalOptions<T> {
|
|
33
32
|
name?: string;
|
|
34
33
|
equals?: ((prev: T, next: T) => boolean) | false;
|
|
@@ -67,7 +66,6 @@ export declare class Computation<T = any> extends Owner implements SourceType, O
|
|
|
67
66
|
_stateFlags: number;
|
|
68
67
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
69
68
|
_handlerMask: number;
|
|
70
|
-
_loading: Computation<boolean> | null;
|
|
71
69
|
_time: number;
|
|
72
70
|
_forceNotify: boolean;
|
|
73
71
|
constructor(initialValue: T | undefined, compute: null | ((p?: T) => T), options?: SignalOptions<T>);
|
|
@@ -85,14 +83,6 @@ export declare class Computation<T = any> extends Owner implements SourceType, O
|
|
|
85
83
|
* before continuing
|
|
86
84
|
*/
|
|
87
85
|
wait(): T;
|
|
88
|
-
/**
|
|
89
|
-
* Return true if the computation is the value is dependent on an unresolved promise
|
|
90
|
-
* Triggers re-execution of the computation when the loading state changes
|
|
91
|
-
*
|
|
92
|
-
* This is useful especially when effects want to re-execute when a computation's
|
|
93
|
-
* loading state changes
|
|
94
|
-
*/
|
|
95
|
-
loading(): boolean;
|
|
96
86
|
/** Update the computation with a new value. */
|
|
97
87
|
write(value: T | ((currentValue: T) => T) | UNCHANGED, flags?: number, raw?: boolean): T;
|
|
98
88
|
/**
|
|
@@ -140,7 +130,7 @@ export declare function untrack<T>(fn: () => T): T;
|
|
|
140
130
|
*/
|
|
141
131
|
export declare function hasUpdated(fn: () => any): boolean;
|
|
142
132
|
/**
|
|
143
|
-
* Returns true if the given function contains async signals are out of date.
|
|
133
|
+
* Returns an accessor that is true if the given function contains async signals are out of date.
|
|
144
134
|
*/
|
|
145
135
|
export declare function isPending(fn: () => any): boolean;
|
|
146
136
|
export declare function isPending(fn: () => any, loadingValue: boolean): boolean;
|
|
@@ -149,7 +139,6 @@ export declare function isPending(fn: () => any, loadingValue: boolean): boolean
|
|
|
149
139
|
*/
|
|
150
140
|
export declare function latest<T>(fn: () => T): T;
|
|
151
141
|
export declare function latest<T, U>(fn: () => T, fallback: U): T | U;
|
|
152
|
-
export declare function catchError(fn: () => void): unknown | undefined;
|
|
153
142
|
/**
|
|
154
143
|
* Runs the given function in the given observer.
|
|
155
144
|
*
|
|
@@ -166,5 +155,4 @@ export declare function flatten(children: any, options?: {
|
|
|
166
155
|
skipNonRendered?: boolean;
|
|
167
156
|
doNotUnwrap?: boolean;
|
|
168
157
|
}): any;
|
|
169
|
-
export declare function createBoundary<T>(fn: () => T, queue: IQueue): T;
|
|
170
158
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { ContextNotFoundError, NoOwnerError, NotReadyError, type ErrorHandler } from "./error.js";
|
|
2
2
|
export { Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, type Context, type ContextRecord, type Disposable } from "./owner.js";
|
|
3
|
-
export { Computation,
|
|
3
|
+
export { Computation, getObserver, isEqual, untrack, hasUpdated, isPending, latest, flatten, UNCHANGED, compute, runWithObserver, type SignalOptions } from "./core.js";
|
|
4
4
|
export { Effect, EagerComputation } from "./effect.js";
|
|
5
|
-
export { flushSync,
|
|
6
|
-
export { createSuspense } from "./
|
|
5
|
+
export { flushSync, type IQueue, Queue } from "./scheduler.js";
|
|
6
|
+
export { createSuspense, createErrorBoundary } from "./boundaries.js";
|
|
7
7
|
export { SUPPORTS_PROXY } from "./constants.js";
|
|
8
|
+
export { tryCatch, type TryCatchResult } from "./utils.js";
|
|
8
9
|
export * from "./flags.js";
|
|
@@ -47,12 +47,17 @@ export declare class Owner {
|
|
|
47
47
|
_context: ContextRecord;
|
|
48
48
|
_handlers: ErrorHandler[] | null;
|
|
49
49
|
_queue: IQueue;
|
|
50
|
-
|
|
50
|
+
_siblingCount: number | null;
|
|
51
|
+
_childCount: number;
|
|
52
|
+
id: string | null;
|
|
53
|
+
constructor(id?: string | null, skipAppend?: boolean);
|
|
51
54
|
append(child: Owner): void;
|
|
52
55
|
dispose(this: Owner, self?: boolean): void;
|
|
53
56
|
_disposeNode(): void;
|
|
54
57
|
emptyDisposal(): void;
|
|
58
|
+
addErrorHandler(handler: ErrorHandler): void;
|
|
55
59
|
handleError(error: unknown): void;
|
|
60
|
+
getNextChildId(): string;
|
|
56
61
|
}
|
|
57
62
|
export interface Context<T> {
|
|
58
63
|
readonly id: symbol;
|
|
@@ -16,7 +16,7 @@ export declare class Queue implements IQueue {
|
|
|
16
16
|
_children: IQueue[];
|
|
17
17
|
created: number;
|
|
18
18
|
enqueue<T extends Computation | Effect>(type: number, node: T): void;
|
|
19
|
-
run(type: number):
|
|
19
|
+
run(type: number): boolean | undefined;
|
|
20
20
|
flush(): void;
|
|
21
21
|
addChild(child: IQueue): void;
|
|
22
22
|
removeChild(child: IQueue): void;
|
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export declare function isUndefined(value: any): value is undefined;
|
|
2
|
+
export type TryCatchResult<T, E> = [undefined, T] | [E];
|
|
3
|
+
export declare function tryCatch<T, E = Error>(fn: () => Promise<T>): Promise<TryCatchResult<T, E>>;
|
|
4
|
+
export declare function tryCatch<T, E = Error>(fn: () => T): TryCatchResult<T, E>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flatten, flushSync,
|
|
1
|
+
export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flatten, flushSync, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated, isPending, latest, tryCatch, runWithObserver, createErrorBoundary, createSuspense, SUPPORTS_PROXY } from "./core/index.js";
|
|
2
2
|
export type { ErrorHandler, SignalOptions, Context, ContextRecord, Disposable, IQueue } from "./core/index.js";
|
|
3
3
|
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
4
4
|
export * from "./signals.js";
|
package/dist/types/signals.d.ts
CHANGED
|
@@ -125,7 +125,9 @@ export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFu
|
|
|
125
125
|
*
|
|
126
126
|
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
|
|
127
127
|
*/
|
|
128
|
-
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T)
|
|
128
|
+
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
129
|
+
id: string;
|
|
130
|
+
}): T;
|
|
129
131
|
/**
|
|
130
132
|
* Runs the given function in the given owner to move ownership of nested primitives and cleanups.
|
|
131
133
|
* This method untracks the current scope.
|
|
@@ -133,16 +135,6 @@ export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() =
|
|
|
133
135
|
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
|
|
134
136
|
*/
|
|
135
137
|
export declare function runWithOwner<T>(owner: Owner | null, run: () => T): T;
|
|
136
|
-
/**
|
|
137
|
-
* Switches to fallback whenever an error is thrown within the context of the child scopes
|
|
138
|
-
* @param fn boundary for the error
|
|
139
|
-
* @param fallback an error handler that receives the error
|
|
140
|
-
*
|
|
141
|
-
* * If the error is thrown again inside the error handler, it will trigger the next available parent handler
|
|
142
|
-
*
|
|
143
|
-
* @description https://docs.solidjs.com/reference/reactive-utilities/catch-error
|
|
144
|
-
*/
|
|
145
|
-
export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error: unknown, reset: () => void) => U): Accessor<T | U>;
|
|
146
138
|
/**
|
|
147
139
|
* Returns a promise of the resolved value of a reactive expression
|
|
148
140
|
* @param fn a reactive expression to resolve
|