@solidjs/signals 2.0.0-beta.8 → 2.0.0-rc.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/README.md +13 -9
- package/dist/dev.js +6078 -1440
- package/dist/node.cjs +7684 -3248
- package/dist/prod/affects.js +126 -0
- package/dist/prod/boundaries.js +572 -0
- package/dist/prod/core/action.js +139 -0
- package/dist/prod/core/async.js +553 -0
- package/dist/prod/core/constants.js +92 -0
- package/dist/prod/core/context.js +67 -0
- package/dist/prod/core/core.js +817 -0
- package/dist/prod/core/dev.js +3 -0
- package/dist/prod/core/effect.js +145 -0
- package/dist/prod/core/error.js +68 -0
- package/dist/prod/core/external.js +98 -0
- package/dist/prod/core/graph.js +104 -0
- package/dist/prod/core/heap.js +140 -0
- package/dist/prod/core/invariants.js +42 -0
- package/dist/prod/core/lanes.js +140 -0
- package/dist/prod/core/optimistic.js +245 -0
- package/dist/prod/core/owner.js +302 -0
- package/dist/prod/core/scheduler.js +749 -0
- package/dist/prod/core/verdict.js +369 -0
- package/dist/prod/index.js +45 -0
- package/dist/prod/map.js +317 -0
- package/dist/prod/signals.js +375 -0
- package/dist/prod/store/optimistic.js +217 -0
- package/dist/prod/store/projection.js +231 -0
- package/dist/prod/store/reconcile.js +707 -0
- package/dist/prod/store/store.js +1081 -0
- package/dist/prod/store/storePath.js +103 -0
- package/dist/prod/store/utils.js +328 -0
- package/dist/types/affects.d.ts +47 -0
- package/dist/types/boundaries.d.ts +93 -11
- package/dist/types/core/action.d.ts +63 -0
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +46 -0
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +111 -17
- package/dist/types/core/dev.d.ts +17 -2
- package/dist/types/core/effect.d.ts +1 -2
- package/dist/types/core/error.d.ts +33 -0
- package/dist/types/core/external.d.ts +0 -11
- package/dist/types/core/graph.d.ts +2 -1
- package/dist/types/core/heap.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/invariants.d.ts +59 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/optimistic.d.ts +6 -0
- package/dist/types/core/owner.d.ts +101 -3
- package/dist/types/core/scheduler.d.ts +97 -9
- package/dist/types/core/types.d.ts +68 -6
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/map.d.ts +50 -5
- package/dist/types/signals.d.ts +424 -19
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +39 -13
- package/dist/types/store/projection.d.ts +48 -18
- package/dist/types/store/reconcile.d.ts +46 -1
- package/dist/types/store/store.d.ts +164 -19
- package/dist/types/store/storePath.d.ts +28 -0
- package/dist/types/store/utils.d.ts +78 -7
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +93 -11
- package/dist/types-cjs/core/action.d.cts +63 -0
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +46 -0
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +111 -17
- package/dist/types-cjs/core/dev.d.cts +17 -2
- package/dist/types-cjs/core/effect.d.cts +1 -2
- package/dist/types-cjs/core/error.d.cts +33 -0
- package/dist/types-cjs/core/external.d.cts +0 -11
- package/dist/types-cjs/core/graph.d.cts +2 -1
- package/dist/types-cjs/core/heap.d.cts +8 -0
- package/dist/types-cjs/core/index.d.cts +3 -2
- package/dist/types-cjs/core/invariants.d.cts +59 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/optimistic.d.cts +6 -0
- package/dist/types-cjs/core/owner.d.cts +101 -3
- package/dist/types-cjs/core/scheduler.d.cts +97 -9
- package/dist/types-cjs/core/types.d.cts +68 -6
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +4 -3
- package/dist/types-cjs/map.d.cts +50 -5
- package/dist/types-cjs/signals.d.cts +424 -19
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/optimistic.d.cts +39 -13
- package/dist/types-cjs/store/projection.d.cts +48 -18
- package/dist/types-cjs/store/reconcile.d.cts +46 -1
- package/dist/types-cjs/store/store.d.cts +164 -19
- package/dist/types-cjs/store/storePath.d.cts +28 -0
- package/dist/types-cjs/store/utils.d.cts +78 -7
- package/package.json +14 -11
- package/dist/prod.js +0 -3577
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Heap } from "./heap.js";
|
|
2
|
-
import { activeLanes, assignOrMergeLane, findLane } from "./lanes.js";
|
|
2
|
+
import { activeLanes, assignOrMergeLane, findLane, type OptimisticLane } from "./lanes.js";
|
|
3
3
|
import type { Computed, Signal } from "./types.js";
|
|
4
4
|
export { activeLanes, assignOrMergeLane, findLane };
|
|
5
5
|
export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.js";
|
|
@@ -11,8 +11,15 @@ export declare let projectionWriteActive: boolean;
|
|
|
11
11
|
export declare let _hitUnhandledAsync: boolean;
|
|
12
12
|
export declare function registerTransientStoreNode(node: Signal<any>): void;
|
|
13
13
|
export declare function resetUnhandledAsync(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Toggles the dev-mode "must be inside a `<Loading>` boundary" enforcement
|
|
16
|
+
* window. Only `render()` calls this — wrapping the initial mount so that a
|
|
17
|
+
* top-level uncaught async read surfaces the diagnostic. Not part of the
|
|
18
|
+
* user-facing API.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
14
22
|
export declare function enforceLoadingBoundary(enabled: boolean): void;
|
|
15
|
-
export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
|
|
16
23
|
export declare function setProjectionWriteActive(value: boolean): void;
|
|
17
24
|
export declare function setTrackedQueueCallback(value: boolean): void;
|
|
18
25
|
export type QueueCallback = (type: number) => void;
|
|
@@ -26,12 +33,22 @@ export interface Transition {
|
|
|
26
33
|
_asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
|
|
27
34
|
_pendingNodes: Signal<any>[];
|
|
28
35
|
_optimisticNodes: OptimisticNode[];
|
|
36
|
+
_affectsNodes: OptimisticNode[];
|
|
29
37
|
_optimisticStores: Set<any>;
|
|
30
38
|
_actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
|
|
31
39
|
_queueStash: QueueStub;
|
|
32
40
|
_done: boolean | Transition;
|
|
41
|
+
_gatedSubs: Set<Computed<any>>;
|
|
33
42
|
}
|
|
34
43
|
export declare function schedule(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Permanently halts the reactive system. Called when a user error escapes
|
|
46
|
+
* every boundary — app state is undefined at that point, so scheduling stops
|
|
47
|
+
* entirely rather than limping along with a half-applied update.
|
|
48
|
+
*/
|
|
49
|
+
export declare function haltReactivity(cause?: unknown): void;
|
|
50
|
+
/** @internal Test/dev-reload hook. Revives scheduling after a halt. */
|
|
51
|
+
export declare function resetErrorHalt(): void;
|
|
35
52
|
export interface IQueue {
|
|
36
53
|
enqueue(type: number, fn: QueueCallback): void;
|
|
37
54
|
run(type: number): boolean | void;
|
|
@@ -47,6 +64,7 @@ export declare class Queue implements IQueue {
|
|
|
47
64
|
_parent: IQueue | null;
|
|
48
65
|
_queues: [QueueCallback[], QueueCallback[]];
|
|
49
66
|
_children: IQueue[];
|
|
67
|
+
_ranAt: number;
|
|
50
68
|
created: number;
|
|
51
69
|
addChild(child: IQueue): void;
|
|
52
70
|
removeChild(child: IQueue): void;
|
|
@@ -58,25 +76,95 @@ export declare class Queue implements IQueue {
|
|
|
58
76
|
}
|
|
59
77
|
export declare class GlobalQueue extends Queue {
|
|
60
78
|
_running: boolean;
|
|
61
|
-
|
|
62
|
-
_optimisticNodes: OptimisticNode[];
|
|
63
|
-
_optimisticStores: Set<any>;
|
|
79
|
+
_batch: Transition;
|
|
64
80
|
static _update: (el: Computed<unknown>) => void;
|
|
65
81
|
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
66
|
-
static
|
|
82
|
+
static _runEffect: (el: Computed<unknown>) => void;
|
|
83
|
+
static _clearOptimisticStores: ((stores: Set<any>, completing: Transition | null) => void) | null;
|
|
84
|
+
static _releaseAffectsScope: ((node: OptimisticNode) => void) | null;
|
|
85
|
+
static _releaseAffectsMarks: ((nodes: OptimisticNode[]) => void) | null;
|
|
86
|
+
static _markAffects: ((node: OptimisticNode) => void) | null;
|
|
87
|
+
static _releaseAffectsMark: ((node: OptimisticNode) => void) | null;
|
|
88
|
+
static _wireExternalSource: ((self: Computed<any>) => void) | null;
|
|
89
|
+
static _externalUntrack: (<T>(fn: () => T) => T) | null;
|
|
90
|
+
static _syncCompanions: (<T>(el: Signal<T> | Computed<T>, value: T) => void) | null;
|
|
91
|
+
static _updatePendingSignal: ((el: OptimisticNode) => void) | null;
|
|
92
|
+
static _updateChildCompanions: ((el: Computed<any>) => void) | null;
|
|
93
|
+
static _snapCompanions: ((el: OptimisticNode) => void) | null;
|
|
94
|
+
static _latestRead: (<T>(el: Signal<T> | Computed<T>) => T) | null;
|
|
95
|
+
static _pendingCheck: ((el: OptimisticNode, c: Computed<any> | null, owner: OptimisticNode, firewall: Computed<any> | null) => void) | null;
|
|
96
|
+
static _recordFresh: ((el: OptimisticNode, value: any) => void) | null;
|
|
97
|
+
static _applyReask: ((el: Computed<any>, hadReask: boolean) => boolean) | null;
|
|
98
|
+
static _repollVerdicts: ((el: Computed<any>, snap?: boolean) => void) | null;
|
|
99
|
+
static _witnessAffects: ((node: OptimisticNode) => void) | null;
|
|
100
|
+
static _optimisticWrite: (<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)) => T) | null;
|
|
101
|
+
static _resolveOptimistic: ((nodes: OptimisticNode[]) => void) | null;
|
|
102
|
+
static _transitionBlocked: ((transition: Transition) => boolean) | null;
|
|
103
|
+
static _cleanupLanes: ((completingTransition: Transition | null) => void) | null;
|
|
104
|
+
static _runLaneEffects: ((type: number) => void) | null;
|
|
105
|
+
static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
|
|
106
|
+
static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
|
|
107
|
+
static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
|
|
108
|
+
static _recomputeLane: ((el: Computed<any>, own: boolean) => OptimisticLane | null) | null;
|
|
109
|
+
static _laneAsyncPending: ((el: Computed<any>) => void) | null;
|
|
110
|
+
static _laneAsyncSettled: ((el: Computed<any>) => void) | null;
|
|
111
|
+
static _trackOptimisticStore: ((store: any) => void) | null;
|
|
67
112
|
flush(): void;
|
|
68
113
|
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
69
114
|
initTransition(transition?: Transition | null): void;
|
|
70
115
|
}
|
|
116
|
+
export declare function queuePendingNode(node: Signal<any>): void;
|
|
117
|
+
export declare function armReaskClear(): void;
|
|
71
118
|
export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
|
|
72
119
|
export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
|
|
73
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Count of live `affects()` registrations across the system (including
|
|
122
|
+
* store-scope inherited marks). Gates the read-path mark check in `read()` so
|
|
123
|
+
* graphs that never use the feature pay one integer compare.
|
|
124
|
+
*/
|
|
125
|
+
export declare let activeAffectsMarks: number;
|
|
126
|
+
/**
|
|
127
|
+
* Counter mutation seam for the mark engine in affects.ts: an imported `let`
|
|
128
|
+
* binding is read-only, and the read-path gate above must stay a plain module
|
|
129
|
+
* variable so `read()` pays one integer compare, not a function call.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function shiftAffectsMarks(delta: 1 | -1): void;
|
|
74
134
|
export declare const globalQueue: GlobalQueue;
|
|
75
135
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
136
|
+
* Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
|
|
137
|
+
* flush scope before draining the queue.
|
|
138
|
+
*
|
|
139
|
+
* Reactive updates are normally batched onto the microtask queue, so multiple
|
|
140
|
+
* writes in a row collapse into a single update pass. Call `flush()` when you
|
|
141
|
+
* need to *observe* the result of those writes synchronously — most commonly
|
|
142
|
+
* in tests, but also at the boundary of imperative integration code. Pass a
|
|
143
|
+
* callback when the writes themselves should bypass microtask scheduling and
|
|
144
|
+
* drain synchronously when the callback returns.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const [count, setCount] = createSignal(0);
|
|
149
|
+
* const doubled = createMemo(() => count() * 2);
|
|
150
|
+
*
|
|
151
|
+
* setCount(5);
|
|
152
|
+
* flush();
|
|
153
|
+
* expect(doubled()).toBe(10);
|
|
154
|
+
*
|
|
155
|
+
* flush(() => setCount(6));
|
|
156
|
+
* expect(doubled()).toBe(12);
|
|
157
|
+
*
|
|
158
|
+
* // Nested flushes drain at each level:
|
|
159
|
+
* flush(() => {
|
|
160
|
+
* setCount(7);
|
|
161
|
+
* flush(() => setCount(8)); // inner drain — effects fire here
|
|
162
|
+
* // outer continues with up-to-date state
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
78
165
|
*/
|
|
79
166
|
export declare function flush(): void;
|
|
167
|
+
export declare function flush<T>(fn: () => T): T;
|
|
80
168
|
export declare function currentTransition(transition: Transition): Transition;
|
|
81
169
|
export declare function setActiveTransition(transition: Transition | null): void;
|
|
82
170
|
export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
|
|
@@ -10,6 +10,14 @@ export interface Link {
|
|
|
10
10
|
_nextDep: Link | null;
|
|
11
11
|
_prevSub: Link | null;
|
|
12
12
|
_nextSub: Link | null;
|
|
13
|
+
/**
|
|
14
|
+
* `_sub._depGen` at the time this link was created or last revalidated
|
|
15
|
+
* in-order. A link stamped with the subscriber's current pass generation is
|
|
16
|
+
* inside the validated `[deps.._depsTail]` prefix — an O(1) replacement for
|
|
17
|
+
* scanning the dep list to answer membership (see `link()`).
|
|
18
|
+
*/
|
|
19
|
+
_gen: number;
|
|
20
|
+
_pendingObserver?: boolean;
|
|
13
21
|
}
|
|
14
22
|
export interface NodeOptions<T> {
|
|
15
23
|
id?: string;
|
|
@@ -21,6 +29,17 @@ export interface NodeOptions<T> {
|
|
|
21
29
|
_noSnapshot?: boolean;
|
|
22
30
|
unobserved?: () => void;
|
|
23
31
|
lazy?: boolean;
|
|
32
|
+
sync?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Commit #0. When present (checked with `in`, so an explicit `undefined`
|
|
35
|
+
* counts), the node is born committed with this value instead of
|
|
36
|
+
* STATUS_UNINITIALIZED: reads serve it everywhere, nothing suspends to
|
|
37
|
+
* Loading boundaries, transitions are never held, and the window is
|
|
38
|
+
* verdict-quiet (`isPending` stays false — commit #0 answers the question
|
|
39
|
+
* by declaration; first-load affordances live in the value itself). After
|
|
40
|
+
* the first real answer lands, normal refetch/pending semantics apply.
|
|
41
|
+
*/
|
|
42
|
+
loadingValue?: T;
|
|
24
43
|
}
|
|
25
44
|
export interface RawSignal<T> {
|
|
26
45
|
_subs: Link | null;
|
|
@@ -29,17 +48,35 @@ export interface RawSignal<T> {
|
|
|
29
48
|
_snapshotValue?: any;
|
|
30
49
|
_name?: string;
|
|
31
50
|
_equals: false | ((a: T, b: T) => boolean);
|
|
32
|
-
|
|
33
|
-
_noSnapshot?: boolean;
|
|
51
|
+
_config: number;
|
|
34
52
|
_unobserved?: () => void;
|
|
35
53
|
_time: number;
|
|
36
54
|
_transition: Transition | null;
|
|
37
55
|
_pendingValue: T | typeof NOT_PENDING;
|
|
38
56
|
_overrideValue?: T | typeof NOT_PENDING;
|
|
57
|
+
/**
|
|
58
|
+
* The transaction that owns the active override (stamped at optimistic
|
|
59
|
+
* write, cleared at settle). Ownership must live on the node: a lane's
|
|
60
|
+
* _transition is a scheduling affinity that a shared subscriber can merge
|
|
61
|
+
* across transactions (#2912) — following it would let one action's settle
|
|
62
|
+
* revert another action's live override. Node-level sibling of the store
|
|
63
|
+
* layer's STORE_OPTIMISTIC_OWNERS stamps (#2899). `null` = ambient write.
|
|
64
|
+
*/
|
|
65
|
+
_overrideOwner?: Transition | null;
|
|
39
66
|
_optimisticLane?: OptimisticLane;
|
|
40
67
|
_pendingSignal?: Signal<boolean>;
|
|
41
68
|
_latestValueComputed?: Computed<T>;
|
|
42
69
|
_parentSource?: Signal<any> | Computed<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Live `affects()` marks on this node (refcount). Non-zero is declared
|
|
72
|
+
* motion: the node — and, via the verdict layer's dep-graph coverage walk,
|
|
73
|
+
* everything derived from it — reads pending regardless of graph state,
|
|
74
|
+
* until every declaring transaction settles/reverts and releases its mark.
|
|
75
|
+
* This count is the mark's ONLY graph state: the dedicated channel stores
|
|
76
|
+
* nothing downstream and never touches status flags, errors, or pending
|
|
77
|
+
* sources.
|
|
78
|
+
*/
|
|
79
|
+
_affectsCount?: number;
|
|
43
80
|
}
|
|
44
81
|
export interface FirewallSignal<T> extends RawSignal<T> {
|
|
45
82
|
_firewall: Computed<any>;
|
|
@@ -48,9 +85,10 @@ export interface FirewallSignal<T> extends RawSignal<T> {
|
|
|
48
85
|
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
|
|
49
86
|
export interface Owner {
|
|
50
87
|
id?: string;
|
|
51
|
-
|
|
52
|
-
_childrenForbidden?: boolean;
|
|
88
|
+
_config: number;
|
|
53
89
|
_snapshotScope?: boolean;
|
|
90
|
+
/** Effect-returned cleanup; managed across reruns, invoked at true disposal */
|
|
91
|
+
_cleanup?: () => void;
|
|
54
92
|
_disposal: Disposable | Disposable[] | null;
|
|
55
93
|
_parent: Owner | null;
|
|
56
94
|
_context: Record<symbol | string, unknown>;
|
|
@@ -58,16 +96,17 @@ export interface Owner {
|
|
|
58
96
|
_queue: IQueue;
|
|
59
97
|
_firstChild: Owner | null;
|
|
60
98
|
_nextSibling: Owner | null;
|
|
99
|
+
_prevSibling: Owner | null;
|
|
61
100
|
_pendingDisposal: Disposable | Disposable[] | null;
|
|
62
101
|
_pendingFirstChild: Owner | null;
|
|
63
102
|
}
|
|
64
103
|
export interface Computed<T> extends RawSignal<T>, Owner {
|
|
65
104
|
_deps: Link | null;
|
|
66
105
|
_depsTail: Link | null;
|
|
106
|
+
/** Recompute-pass counter; bumped when dep revalidation starts. */
|
|
107
|
+
_depGen: number;
|
|
67
108
|
_flags: number;
|
|
68
|
-
_inSnapshotScope?: boolean;
|
|
69
109
|
_blocked?: boolean;
|
|
70
|
-
_pendingSource?: Computed<any>;
|
|
71
110
|
_pendingSources?: Set<Computed<any>>;
|
|
72
111
|
_error?: unknown;
|
|
73
112
|
_statusFlags: number;
|
|
@@ -78,6 +117,29 @@ export interface Computed<T> extends RawSignal<T>, Owner {
|
|
|
78
117
|
_inFlight: PromiseLike<T> | AsyncIterable<T> | null;
|
|
79
118
|
_child: FirewallSignal<any> | null;
|
|
80
119
|
_notifyStatus?: (status?: number, error?: any) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Question-scoped pending classification of the node's CURRENT pending
|
|
122
|
+
* window: `true` means the in-flight recompute is a re-ask of the same
|
|
123
|
+
* question (refresh/poll/confirm — no tracked input changed value), so the
|
|
124
|
+
* shown answer still answers the question and the node reads NOT pending.
|
|
125
|
+
* Set by `recompute` from `REACTIVE_REASK`, cleared on landing
|
|
126
|
+
* (`clearStatus`). Meaningless while not STATUS_PENDING.
|
|
127
|
+
*/
|
|
128
|
+
_reask: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* True while a `loadingValue` node's first real answer hasn't landed: the
|
|
131
|
+
* node was born committed (commit #0 = the loading value) and `handleAsync`
|
|
132
|
+
* serves that committed value instead of throwing NotReadyError, so first
|
|
133
|
+
* flights never suspend readers, trip boundaries, or hold transitions.
|
|
134
|
+
* The window is verdict-quiet: `isPending` stays false, because commit #0
|
|
135
|
+
* answers the question by declaration (first-load affordances belong to
|
|
136
|
+
* the value channel). Cleared by the first value landing on any path (sync
|
|
137
|
+
* return, sync-resolved promise, first iterator yield, async settle); a
|
|
138
|
+
* real error leaves it set — errors answer reads but don't enter the value
|
|
139
|
+
* lineage, so a retry serves the loading value again. Once cleared, normal
|
|
140
|
+
* pending/refetch semantics apply forever.
|
|
141
|
+
*/
|
|
142
|
+
_loading: boolean;
|
|
81
143
|
}
|
|
82
144
|
export interface Root extends Owner {
|
|
83
145
|
_root: true;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest,
|
|
1
|
+
export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest, refresh, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, enforceLoadingBoundary, enableExternalSource, resetErrorHalt } from "./core/index.js";
|
|
2
2
|
import { type Dev } from "./core/index.js";
|
|
3
3
|
export declare const DEV: Dev | undefined;
|
|
4
|
-
export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.js";
|
|
4
|
+
export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Refreshable, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.js";
|
|
5
5
|
export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled, onCleanup } from "./signals.js";
|
|
6
|
-
export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
|
|
6
|
+
export type { Accessor, SourceAccessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
|
|
7
|
+
export { affects } from "./affects.js";
|
|
7
8
|
export { mapArray, repeat, type Maybe } from "./map.js";
|
|
8
9
|
export * from "./store/index.js";
|
|
9
10
|
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.js";
|
package/dist/types/map.d.ts
CHANGED
|
@@ -1,19 +1,64 @@
|
|
|
1
1
|
import { type Accessor } from "./signals.js";
|
|
2
2
|
export type Maybe<T> = T | void | null | undefined | false;
|
|
3
3
|
/**
|
|
4
|
-
* Reactively
|
|
4
|
+
* Reactively maps an array, reusing the previously-mapped value for unchanged
|
|
5
|
+
* items.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* The callback shape follows the keying mode:
|
|
8
|
+
* - default / `keyed: true` receives `(item, index)` where `item` is the raw
|
|
9
|
+
* row value and `index` is an accessor.
|
|
10
|
+
* - `keyed: false` receives `(item, index)` where `item` is an accessor and
|
|
11
|
+
* `index` is a stable number.
|
|
12
|
+
* - `keyed: item => key` receives accessors for both arguments.
|
|
13
|
+
*
|
|
14
|
+
* This is the underlying helper that powers `<For>`. App code should use
|
|
15
|
+
* `<For>` directly; reach for `mapArray` when implementing custom list
|
|
16
|
+
* components.
|
|
17
|
+
*
|
|
18
|
+
* - `options.keyed` — `true` (default for primitives) compares by identity;
|
|
19
|
+
* `false` falls back to index-only mapping; pass a function `(item) => key`
|
|
20
|
+
* for stable identity by extracted key.
|
|
21
|
+
* - `options.fallback` — accessor returning a value to show when the input is
|
|
22
|
+
* empty.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const view = mapArray(
|
|
27
|
+
* items,
|
|
28
|
+
* (item, index) => `${index()}: ${item.label}`,
|
|
29
|
+
* { fallback: () => "no items" }
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
7
32
|
*
|
|
8
33
|
* @description https://docs.solidjs.com/reference/reactive-utilities/map-array
|
|
9
34
|
*/
|
|
10
|
-
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value:
|
|
11
|
-
keyed?:
|
|
35
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Item, index: Accessor<number>) => MappedItem, options?: {
|
|
36
|
+
keyed?: true;
|
|
37
|
+
fallback?: Accessor<any>;
|
|
38
|
+
name?: string;
|
|
39
|
+
}): Accessor<MappedItem[]>;
|
|
40
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: number) => MappedItem, options: {
|
|
41
|
+
keyed: false;
|
|
42
|
+
fallback?: Accessor<any>;
|
|
43
|
+
name?: string;
|
|
44
|
+
}): Accessor<MappedItem[]>;
|
|
45
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options: {
|
|
46
|
+
keyed: (item: Item) => any;
|
|
12
47
|
fallback?: Accessor<any>;
|
|
13
48
|
name?: string;
|
|
14
49
|
}): Accessor<MappedItem[]>;
|
|
15
50
|
/**
|
|
16
|
-
* Reactively
|
|
51
|
+
* Reactively renders a callback `count` times, reusing previously-rendered
|
|
52
|
+
* entries when only the count changes. Underlying helper for `<Repeat>`.
|
|
53
|
+
*
|
|
54
|
+
* - `options.from` — start index (default `0`); useful for offset/windowed
|
|
55
|
+
* rendering.
|
|
56
|
+
* - `options.fallback` — accessor returning a value to show when count is `0`.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const view = repeat(count, i => `Item ${i}`, { fallback: () => "empty" });
|
|
61
|
+
* ```
|
|
17
62
|
*
|
|
18
63
|
* @description https://docs.solidjs.com/reference/reactive-utilities/repeat
|
|
19
64
|
*/
|