@solidjs/signals 2.0.0-beta.12 → 2.0.0-beta.13
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 +5 -4
- package/dist/dev.js +30 -8
- package/dist/node.cjs +264 -247
- package/dist/prod.js +217 -200
- package/dist/types/boundaries.d.ts +7 -5
- package/dist/types/core/core.d.ts +11 -3
- package/dist/types-cjs/boundaries.d.cts +7 -5
- package/dist/types-cjs/core/core.d.cts +11 -3
- 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,21 +123,29 @@ 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
132
|
*
|
|
133
|
+
* Pass `true` as the second argument for render guards that directly read an
|
|
134
|
+
* async source. If the source is on the Loading path for that read, the
|
|
135
|
+
* pending read follows that path instead of being treated as `false`.
|
|
136
|
+
*
|
|
133
137
|
* @example
|
|
134
138
|
* ```tsx
|
|
135
139
|
* const pending = createMemo(() => isPending(() => user()));
|
|
136
140
|
*
|
|
137
141
|
* <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
|
|
142
|
+
*
|
|
143
|
+
* <Loading fallback={<button disabled>Loading...</button>}>
|
|
144
|
+
* <button disabled={isPending(() => user(), true)}>Save</button>
|
|
145
|
+
* </Loading>
|
|
138
146
|
* ```
|
|
139
147
|
*/
|
|
140
|
-
export declare function isPending(fn: () => any): boolean;
|
|
148
|
+
export declare function isPending(fn: () => any, loading?: boolean): boolean;
|
|
141
149
|
/**
|
|
142
150
|
* Invalidates one reactive source, forcing it to re-execute even if its inputs
|
|
143
151
|
* haven't changed.
|
|
@@ -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,21 +123,29 @@ 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
132
|
*
|
|
133
|
+
* Pass `true` as the second argument for render guards that directly read an
|
|
134
|
+
* async source. If the source is on the Loading path for that read, the
|
|
135
|
+
* pending read follows that path instead of being treated as `false`.
|
|
136
|
+
*
|
|
133
137
|
* @example
|
|
134
138
|
* ```tsx
|
|
135
139
|
* const pending = createMemo(() => isPending(() => user()));
|
|
136
140
|
*
|
|
137
141
|
* <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
|
|
142
|
+
*
|
|
143
|
+
* <Loading fallback={<button disabled>Loading...</button>}>
|
|
144
|
+
* <button disabled={isPending(() => user(), true)}>Save</button>
|
|
145
|
+
* </Loading>
|
|
138
146
|
* ```
|
|
139
147
|
*/
|
|
140
|
-
export declare function isPending(fn: () => any): boolean;
|
|
148
|
+
export declare function isPending(fn: () => any, loading?: boolean): boolean;
|
|
141
149
|
/**
|
|
142
150
|
* Invalidates one reactive source, forcing it to re-execute even if its inputs
|
|
143
151
|
* haven't changed.
|
package/package.json
CHANGED