@solidjs/signals 2.0.0-beta.12 → 2.0.0-beta.14
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/README.md +4 -4
- package/dist/dev.js +95 -15
- package/dist/node.cjs +854 -790
- package/dist/prod.js +649 -585
- package/dist/types/boundaries.d.ts +7 -5
- package/dist/types/core/core.d.ts +6 -2
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/store.d.ts +6 -2
- package/dist/types-cjs/boundaries.d.cts +7 -5
- package/dist/types-cjs/core/core.d.cts +6 -2
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/store.d.cts +6 -2
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Queue, type Computed, type Effect } from "./core/index.js";
|
|
2
2
|
import type { Signal } from "./core/index.js";
|
|
3
|
+
import { type Accessor } from "./signals.js";
|
|
3
4
|
export interface BoundaryComputed<T> extends Computed<T> {
|
|
4
5
|
_propagationMask: number;
|
|
5
6
|
}
|
|
@@ -38,6 +39,7 @@ export declare class CollectionQueue extends Queue {
|
|
|
38
39
|
_tree?: BoundaryComputed<any>;
|
|
39
40
|
_pending: boolean;
|
|
40
41
|
_disabled: Signal<boolean>;
|
|
42
|
+
_error?: Signal<unknown>;
|
|
41
43
|
_collapsed: Signal<boolean>;
|
|
42
44
|
_revealController?: RevealController;
|
|
43
45
|
_initialized: boolean;
|
|
@@ -77,8 +79,8 @@ export declare function createLoadingBoundary(fn: () => any, fallback: () => any
|
|
|
77
79
|
/**
|
|
78
80
|
* Lower-level primitive that backs the `<Errored>` flow control. Catches
|
|
79
81
|
* thrown errors inside `fn` and invokes `fallback(error, reset)` instead.
|
|
80
|
-
* `
|
|
81
|
-
* recover.
|
|
82
|
+
* `error` is an accessor for the latest captured error; `reset()` recomputes
|
|
83
|
+
* the failing sources so the boundary can attempt to recover.
|
|
82
84
|
*
|
|
83
85
|
* App code should use `<Errored fallback={...}>` instead — reach for this only
|
|
84
86
|
* when authoring custom boundary components.
|
|
@@ -86,18 +88,18 @@ export declare function createLoadingBoundary(fn: () => any, fallback: () => any
|
|
|
86
88
|
* @example
|
|
87
89
|
* ```tsx
|
|
88
90
|
* // Custom boundary that wraps the primitive and adds telemetry.
|
|
89
|
-
* function TracedErrored(props: { fallback: (e: unknown) => JSX.Element; children: JSX.Element }) {
|
|
91
|
+
* function TracedErrored(props: { fallback: (e: () => unknown) => JSX.Element; children: JSX.Element }) {
|
|
90
92
|
* return createErrorBoundary(
|
|
91
93
|
* () => props.children,
|
|
92
94
|
* (err, reset) => {
|
|
93
|
-
* reportError(err);
|
|
95
|
+
* reportError(err());
|
|
94
96
|
* return props.fallback(err);
|
|
95
97
|
* }
|
|
96
98
|
* ) as unknown as JSX.Element;
|
|
97
99
|
* }
|
|
98
100
|
* ```
|
|
99
101
|
*/
|
|
100
|
-
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown
|
|
102
|
+
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: Accessor<unknown>, reset: () => void) => U): import("./signals.js").SourceAccessor<unknown>;
|
|
101
103
|
/**
|
|
102
104
|
* Coordinate the reveal timing of sibling loading boundaries.
|
|
103
105
|
*
|
|
@@ -123,18 +123,22 @@ export declare function staleValues<T>(fn: () => T, set?: boolean): T;
|
|
|
123
123
|
*/
|
|
124
124
|
export declare function latest<T>(fn: () => T): T;
|
|
125
125
|
/**
|
|
126
|
-
* Returns `true` if any reactive read inside `fn` is
|
|
127
|
-
*
|
|
126
|
+
* Returns `true` if any reactive read inside `fn` is showing a stale value
|
|
127
|
+
* while newer async work is pending. Does not subscribe — pair with a tracked
|
|
128
128
|
* memo if you want to react to pending status changes.
|
|
129
129
|
*
|
|
130
130
|
* Useful for showing inline transition indicators alongside the previous
|
|
131
131
|
* value (rather than swapping to a `<Loading>` fallback).
|
|
132
|
+
* Because `fn` is read normally, `isPending` participates in Loading/SSR
|
|
133
|
+
* readiness the same way the read itself would.
|
|
132
134
|
*
|
|
133
135
|
* @example
|
|
134
136
|
* ```tsx
|
|
135
137
|
* const pending = createMemo(() => isPending(() => user()));
|
|
136
138
|
*
|
|
137
139
|
* <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
|
|
140
|
+
*
|
|
141
|
+
* <button disabled={isPending(() => user())}>Save</button>
|
|
138
142
|
* ```
|
|
139
143
|
*/
|
|
140
144
|
export declare function isPending(fn: () => any): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Store, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.js";
|
|
1
|
+
export type { Store, StoreReturn, ProjectionStoreReturn, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.js";
|
|
2
2
|
export type { Merge, Omit } from "./utils.js";
|
|
3
3
|
export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.js";
|
|
4
4
|
export { createProjection } from "./projection.js";
|
|
@@ -17,6 +17,10 @@ export type Store<T> = Readonly<T>;
|
|
|
17
17
|
* whose derive function reconciles its return by `options.key`.
|
|
18
18
|
*/
|
|
19
19
|
export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
|
|
20
|
+
/** Tuple returned by the plain `createStore(initialValue)` form. */
|
|
21
|
+
export type StoreReturn<T> = [get: Store<T>, set: StoreSetter<T>];
|
|
22
|
+
/** Tuple returned by the derived `createStore(fn, seed, options?)` form. */
|
|
23
|
+
export type ProjectionStoreReturn<T> = [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
20
24
|
/** Base options for store primitives. */
|
|
21
25
|
export interface StoreOptions {
|
|
22
26
|
/** Debug name (dev mode only) */
|
|
@@ -120,6 +124,6 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
120
124
|
*
|
|
121
125
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
122
126
|
*/
|
|
123
|
-
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>):
|
|
124
|
-
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions):
|
|
127
|
+
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): StoreReturn<T>;
|
|
128
|
+
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): ProjectionStoreReturn<T>;
|
|
125
129
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Queue, type Computed, type Effect } from "./core/index.cjs";
|
|
2
2
|
import type { Signal } from "./core/index.cjs";
|
|
3
|
+
import { type Accessor } from "./signals.cjs";
|
|
3
4
|
export interface BoundaryComputed<T> extends Computed<T> {
|
|
4
5
|
_propagationMask: number;
|
|
5
6
|
}
|
|
@@ -38,6 +39,7 @@ export declare class CollectionQueue extends Queue {
|
|
|
38
39
|
_tree?: BoundaryComputed<any>;
|
|
39
40
|
_pending: boolean;
|
|
40
41
|
_disabled: Signal<boolean>;
|
|
42
|
+
_error?: Signal<unknown>;
|
|
41
43
|
_collapsed: Signal<boolean>;
|
|
42
44
|
_revealController?: RevealController;
|
|
43
45
|
_initialized: boolean;
|
|
@@ -77,8 +79,8 @@ export declare function createLoadingBoundary(fn: () => any, fallback: () => any
|
|
|
77
79
|
/**
|
|
78
80
|
* Lower-level primitive that backs the `<Errored>` flow control. Catches
|
|
79
81
|
* thrown errors inside `fn` and invokes `fallback(error, reset)` instead.
|
|
80
|
-
* `
|
|
81
|
-
* recover.
|
|
82
|
+
* `error` is an accessor for the latest captured error; `reset()` recomputes
|
|
83
|
+
* the failing sources so the boundary can attempt to recover.
|
|
82
84
|
*
|
|
83
85
|
* App code should use `<Errored fallback={...}>` instead — reach for this only
|
|
84
86
|
* when authoring custom boundary components.
|
|
@@ -86,18 +88,18 @@ export declare function createLoadingBoundary(fn: () => any, fallback: () => any
|
|
|
86
88
|
* @example
|
|
87
89
|
* ```tsx
|
|
88
90
|
* // Custom boundary that wraps the primitive and adds telemetry.
|
|
89
|
-
* function TracedErrored(props: { fallback: (e: unknown) => JSX.Element; children: JSX.Element }) {
|
|
91
|
+
* function TracedErrored(props: { fallback: (e: () => unknown) => JSX.Element; children: JSX.Element }) {
|
|
90
92
|
* return createErrorBoundary(
|
|
91
93
|
* () => props.children,
|
|
92
94
|
* (err, reset) => {
|
|
93
|
-
* reportError(err);
|
|
95
|
+
* reportError(err());
|
|
94
96
|
* return props.fallback(err);
|
|
95
97
|
* }
|
|
96
98
|
* ) as unknown as JSX.Element;
|
|
97
99
|
* }
|
|
98
100
|
* ```
|
|
99
101
|
*/
|
|
100
|
-
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown
|
|
102
|
+
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: Accessor<unknown>, reset: () => void) => U): import("./signals.cjs").SourceAccessor<unknown>;
|
|
101
103
|
/**
|
|
102
104
|
* Coordinate the reveal timing of sibling loading boundaries.
|
|
103
105
|
*
|
|
@@ -123,18 +123,22 @@ export declare function staleValues<T>(fn: () => T, set?: boolean): T;
|
|
|
123
123
|
*/
|
|
124
124
|
export declare function latest<T>(fn: () => T): T;
|
|
125
125
|
/**
|
|
126
|
-
* Returns `true` if any reactive read inside `fn` is
|
|
127
|
-
*
|
|
126
|
+
* Returns `true` if any reactive read inside `fn` is showing a stale value
|
|
127
|
+
* while newer async work is pending. Does not subscribe — pair with a tracked
|
|
128
128
|
* memo if you want to react to pending status changes.
|
|
129
129
|
*
|
|
130
130
|
* Useful for showing inline transition indicators alongside the previous
|
|
131
131
|
* value (rather than swapping to a `<Loading>` fallback).
|
|
132
|
+
* Because `fn` is read normally, `isPending` participates in Loading/SSR
|
|
133
|
+
* readiness the same way the read itself would.
|
|
132
134
|
*
|
|
133
135
|
* @example
|
|
134
136
|
* ```tsx
|
|
135
137
|
* const pending = createMemo(() => isPending(() => user()));
|
|
136
138
|
*
|
|
137
139
|
* <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
|
|
140
|
+
*
|
|
141
|
+
* <button disabled={isPending(() => user())}>Save</button>
|
|
138
142
|
* ```
|
|
139
143
|
*/
|
|
140
144
|
export declare function isPending(fn: () => any): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Store, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.cjs";
|
|
1
|
+
export type { Store, StoreReturn, ProjectionStoreReturn, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.cjs";
|
|
2
2
|
export type { Merge, Omit } from "./utils.cjs";
|
|
3
3
|
export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.cjs";
|
|
4
4
|
export { createProjection } from "./projection.cjs";
|
|
@@ -17,6 +17,10 @@ export type Store<T> = Readonly<T>;
|
|
|
17
17
|
* whose derive function reconciles its return by `options.key`.
|
|
18
18
|
*/
|
|
19
19
|
export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
|
|
20
|
+
/** Tuple returned by the plain `createStore(initialValue)` form. */
|
|
21
|
+
export type StoreReturn<T> = [get: Store<T>, set: StoreSetter<T>];
|
|
22
|
+
/** Tuple returned by the derived `createStore(fn, seed, options?)` form. */
|
|
23
|
+
export type ProjectionStoreReturn<T> = [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
20
24
|
/** Base options for store primitives. */
|
|
21
25
|
export interface StoreOptions {
|
|
22
26
|
/** Debug name (dev mode only) */
|
|
@@ -120,6 +124,6 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
120
124
|
*
|
|
121
125
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
122
126
|
*/
|
|
123
|
-
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>):
|
|
124
|
-
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions):
|
|
127
|
+
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): StoreReturn<T>;
|
|
128
|
+
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): ProjectionStoreReturn<T>;
|
|
125
129
|
export {};
|
package/package.json
CHANGED