@solidjs/signals 2.0.0-beta.19 → 2.0.0-beta.20
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 +670 -371
- package/dist/node.cjs +1878 -1606
- package/dist/prod/affects.js +17 -21
- package/dist/prod/core/action.js +19 -6
- package/dist/prod/core/async.js +57 -71
- package/dist/prod/core/constants.js +15 -1
- package/dist/prod/core/core.js +39 -39
- package/dist/prod/core/effect.js +14 -14
- package/dist/prod/core/graph.js +1 -1
- package/dist/prod/core/heap.js +2 -2
- package/dist/prod/core/lanes.js +23 -13
- package/dist/prod/core/optimistic.js +107 -99
- package/dist/prod/core/owner.js +23 -23
- package/dist/prod/core/scheduler.js +180 -180
- package/dist/prod/core/verdict.js +12 -13
- package/dist/prod/map.js +196 -167
- package/dist/prod/signals.js +1 -1
- package/dist/prod/store/optimistic.js +103 -68
- package/dist/prod/store/reconcile.js +80 -46
- package/dist/prod/store/store.js +204 -73
- package/dist/prod/store/utils.js +61 -42
- package/dist/types/core/action.d.ts +19 -6
- package/dist/types/core/constants.d.ts +12 -0
- package/dist/types/core/dev.d.ts +7 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/scheduler.d.ts +2 -6
- package/dist/types/core/types.d.ts +9 -1
- package/dist/types/store/store.d.ts +8 -2
- package/dist/types-cjs/core/action.d.cts +19 -6
- package/dist/types-cjs/core/constants.d.cts +12 -0
- package/dist/types-cjs/core/dev.d.cts +7 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/scheduler.d.cts +2 -6
- package/dist/types-cjs/core/types.d.cts +9 -1
- package/dist/types-cjs/store/store.d.cts +8 -2
- package/package.json +1 -1
|
@@ -4,10 +4,22 @@
|
|
|
4
4
|
* surrounding UI sees one atomic update per yielded step; nothing is committed
|
|
5
5
|
* until the action either completes or the next `yield` resolves.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* `yield` is the transaction-safe suspension point: the action waits for a
|
|
8
|
+
* yielded promise and re-enters the transaction before running the code after
|
|
9
|
+
* it. A plain `await` does NOT — the runtime has no hook into an async
|
|
10
|
+
* generator's internal await continuations, so writes to fresh signals
|
|
11
|
+
* between an `await` and the next `yield` escape the transaction and commit
|
|
12
|
+
* immediately. `await` is still the ergonomic choice for typed results; just
|
|
13
|
+
* put a bare `yield` before any writes that follow it:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const saved = await api.createTodo(text); // typed result
|
|
17
|
+
* yield; // re-enter the transaction before writing
|
|
18
|
+
* setTodos(t => { ... });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* (For the same reason, don't call `flush()` inside an action body — it
|
|
22
|
+
* drains the transaction mid-step.)
|
|
11
23
|
*
|
|
12
24
|
* Each call returns a `Promise` that resolves with the generator's return
|
|
13
25
|
* value, or rejects if it throws. Pair with `createOptimistic` /
|
|
@@ -18,10 +30,11 @@
|
|
|
18
30
|
* ```ts
|
|
19
31
|
* const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
|
|
20
32
|
*
|
|
21
|
-
* const addTodo = action(function* (text: string) {
|
|
33
|
+
* const addTodo = action(async function* (text: string) {
|
|
22
34
|
* const tempId = crypto.randomUUID();
|
|
23
35
|
* setTodos(t => { t.push({ id: tempId, text, pending: true }); }); // optimistic
|
|
24
|
-
* const saved =
|
|
36
|
+
* const saved = await api.createTodo(text); // network round-trip, typed
|
|
37
|
+
* yield; // re-enter the transaction
|
|
25
38
|
* setTodos(t => {
|
|
26
39
|
* const i = t.findIndex(x => x.id === tempId);
|
|
27
40
|
* if (i >= 0) t[i] = saved;
|
|
@@ -35,6 +35,18 @@ export declare const EFFECT_USER = 2;
|
|
|
35
35
|
export declare const EFFECT_TRACKED = 3;
|
|
36
36
|
export declare const NOT_PENDING: {};
|
|
37
37
|
export declare const NO_SNAPSHOT: {};
|
|
38
|
+
/**
|
|
39
|
+
* Stand-in stored in `_overrideValue` for an optimistic write of literal
|
|
40
|
+
* `undefined` (#2898). The slot doubles as the optimistic-node brand
|
|
41
|
+
* (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
|
|
42
|
+
* would erase the node's optimistic identity: the write turns invisible and
|
|
43
|
+
* follow-up writes route off the optimistic path and commit permanently.
|
|
44
|
+
* Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
|
|
45
|
+
* via `visibleOverrideValue`; slot identity tests stay raw.
|
|
46
|
+
*/
|
|
47
|
+
export declare const OVERRIDE_UNDEFINED: {};
|
|
48
|
+
/** Unwrap an active override's stored value for surfacing to readers (#2898). */
|
|
49
|
+
export declare function unwrapOverride<T = any>(v: unknown): T;
|
|
38
50
|
export declare const STORE_SNAPSHOT_PROPS = "sp";
|
|
39
51
|
export declare const SUPPORTS_PROXY: boolean;
|
|
40
52
|
export declare const defaultContext: {};
|
package/dist/types/core/dev.d.ts
CHANGED
|
@@ -48,6 +48,13 @@ export declare const DEV: Dev;
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function assertInvariant(condition: boolean, name: string, message: string): void;
|
|
50
50
|
export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
|
|
51
|
+
/**
|
|
52
|
+
* Shared strict-read diagnostics for core read() and the store proxy traps.
|
|
53
|
+
* Single source for the message text — the #2897 safeguard parity between
|
|
54
|
+
* memos and stores is exactly these firing identically from both paths.
|
|
55
|
+
*/
|
|
56
|
+
export declare function throwPendingUntrackedRead(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "data">>): never;
|
|
57
|
+
export declare function warnStrictReadUntracked(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence">>): void;
|
|
51
58
|
export declare function registerGraph(value: any, owner: Owner | null): void;
|
|
52
59
|
export declare function clearSignals(node: Owner): void;
|
|
53
60
|
export declare function getChildren(owner: Owner): Owner[];
|
|
@@ -37,6 +37,8 @@ export declare function resolveLane(el: {
|
|
|
37
37
|
export declare function resolveTransition(el: {
|
|
38
38
|
_optimisticLane?: OptimisticLane;
|
|
39
39
|
_transition?: Transition | null;
|
|
40
|
+
_overrideValue?: any;
|
|
41
|
+
_overrideOwner?: Transition | null;
|
|
40
42
|
}): Transition | null | undefined;
|
|
41
43
|
/**
|
|
42
44
|
* Check if a node has an active optimistic override.
|
|
@@ -75,15 +75,11 @@ export declare class Queue implements IQueue {
|
|
|
75
75
|
}
|
|
76
76
|
export declare class GlobalQueue extends Queue {
|
|
77
77
|
_running: boolean;
|
|
78
|
-
|
|
79
|
-
_pendingNodes: Signal<any>[];
|
|
80
|
-
_optimisticNodes: OptimisticNode[];
|
|
81
|
-
_affectsNodes: OptimisticNode[];
|
|
82
|
-
_optimisticStores: Set<any>;
|
|
78
|
+
_batch: Transition;
|
|
83
79
|
static _update: (el: Computed<unknown>) => void;
|
|
84
80
|
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
85
81
|
static _runEffect: (el: Computed<unknown>) => void;
|
|
86
|
-
static _clearOptimisticStores: ((stores: Set<any
|
|
82
|
+
static _clearOptimisticStores: ((stores: Set<any>, completing: Transition | null) => void) | null;
|
|
87
83
|
static _releaseAffectsScope: ((node: OptimisticNode) => void) | null;
|
|
88
84
|
static _applyAffectsReads: ((el: Computed<any>, sources: (Signal<any> | Computed<any>)[]) => void) | null;
|
|
89
85
|
static _releaseAffectsMarks: ((nodes: OptimisticNode[]) => void) | null;
|
|
@@ -44,6 +44,15 @@ export interface RawSignal<T> {
|
|
|
44
44
|
_transition: Transition | null;
|
|
45
45
|
_pendingValue: T | typeof NOT_PENDING;
|
|
46
46
|
_overrideValue?: T | typeof NOT_PENDING;
|
|
47
|
+
/**
|
|
48
|
+
* The transaction that owns the active override (stamped at optimistic
|
|
49
|
+
* write, cleared at settle). Ownership must live on the node: a lane's
|
|
50
|
+
* _transition is a scheduling affinity that a shared subscriber can merge
|
|
51
|
+
* across transactions (#2912) — following it would let one action's settle
|
|
52
|
+
* revert another action's live override. Node-level sibling of the store
|
|
53
|
+
* layer's STORE_OPTIMISTIC_OWNERS stamps (#2899). `null` = ambient write.
|
|
54
|
+
*/
|
|
55
|
+
_overrideOwner?: Transition | null;
|
|
47
56
|
_optimisticLane?: OptimisticLane;
|
|
48
57
|
_pendingSignal?: Signal<boolean>;
|
|
49
58
|
_latestValueComputed?: Computed<T>;
|
|
@@ -93,7 +102,6 @@ export interface Computed<T> extends RawSignal<T>, Owner {
|
|
|
93
102
|
_depGen: number;
|
|
94
103
|
_flags: number;
|
|
95
104
|
_blocked?: boolean;
|
|
96
|
-
_pendingSource?: Computed<any>;
|
|
97
105
|
_pendingSources?: Set<Computed<any>>;
|
|
98
106
|
_error?: unknown;
|
|
99
107
|
_statusFlags: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { STORE_SNAPSHOT_PROPS, type Computed, type Refreshable, type Signal } from "../core/index.js";
|
|
2
|
+
import { type Transition } from "../core/scheduler.js";
|
|
2
3
|
/** A read-only view of a store's value as seen by consumers. Mutate it via the paired `StoreSetter`. */
|
|
3
4
|
export type Store<T> = Readonly<T>;
|
|
4
5
|
/**
|
|
@@ -41,12 +42,13 @@ type DataNodes = Record<PropertyKey, DataNode>;
|
|
|
41
42
|
* @internal
|
|
42
43
|
*/
|
|
43
44
|
export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
|
|
44
|
-
export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p";
|
|
45
|
+
export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p", STORE_OPTIMISTIC_OWNERS = "t", STORE_PARENT = "u", STORE_DESC = "d";
|
|
45
46
|
export type StoreNode = {
|
|
46
47
|
[$PROXY]: any;
|
|
47
48
|
[STORE_VALUE]: Record<PropertyKey, any>;
|
|
48
49
|
[STORE_OVERRIDE]?: Record<PropertyKey, any>;
|
|
49
50
|
[STORE_OPTIMISTIC_OVERRIDE]?: Record<PropertyKey, any>;
|
|
51
|
+
[STORE_OPTIMISTIC_OWNERS]?: Record<PropertyKey, Transition | null>;
|
|
50
52
|
[STORE_NODE]?: DataNodes;
|
|
51
53
|
[STORE_HAS]?: DataNodes;
|
|
52
54
|
[STORE_CUSTOM_PROTO]?: boolean;
|
|
@@ -55,6 +57,8 @@ export type StoreNode = {
|
|
|
55
57
|
[STORE_FIREWALL]?: Computed<any>;
|
|
56
58
|
[STORE_OPTIMISTIC]?: boolean;
|
|
57
59
|
[STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
|
|
60
|
+
[STORE_PARENT]?: StoreNode;
|
|
61
|
+
[STORE_DESC]?: boolean;
|
|
58
62
|
};
|
|
59
63
|
export declare namespace SolidStore {
|
|
60
64
|
interface Unwrappable {
|
|
@@ -91,7 +95,7 @@ export declare function visibleNodeValue(node: DataNode): any;
|
|
|
91
95
|
*
|
|
92
96
|
* @internal
|
|
93
97
|
*/
|
|
94
|
-
export declare function witnessAffectsMark(target: StoreNode): void;
|
|
98
|
+
export declare function witnessAffectsMark(target: StoreNode, property?: PropertyKey): void;
|
|
95
99
|
/**
|
|
96
100
|
* Resolves the store nodes an `affects()` declaration marks: with a `key`,
|
|
97
101
|
* the named slot's leaf node (upserted so the mark has an addressable
|
|
@@ -114,6 +118,8 @@ export declare function notifySelf(target: StoreNode): void;
|
|
|
114
118
|
*/
|
|
115
119
|
export declare function mergedOverlay(target: StoreNode): Record<PropertyKey, any> | undefined;
|
|
116
120
|
export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
|
|
121
|
+
export declare function getStoreKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): PropertyKey[];
|
|
122
|
+
export declare function getStoreSymbols(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): symbol[];
|
|
117
123
|
export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
|
|
118
124
|
export declare const storeTraps: ProxyHandler<StoreNode>;
|
|
119
125
|
export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
|
|
@@ -4,10 +4,22 @@
|
|
|
4
4
|
* surrounding UI sees one atomic update per yielded step; nothing is committed
|
|
5
5
|
* until the action either completes or the next `yield` resolves.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* `yield` is the transaction-safe suspension point: the action waits for a
|
|
8
|
+
* yielded promise and re-enters the transaction before running the code after
|
|
9
|
+
* it. A plain `await` does NOT — the runtime has no hook into an async
|
|
10
|
+
* generator's internal await continuations, so writes to fresh signals
|
|
11
|
+
* between an `await` and the next `yield` escape the transaction and commit
|
|
12
|
+
* immediately. `await` is still the ergonomic choice for typed results; just
|
|
13
|
+
* put a bare `yield` before any writes that follow it:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const saved = await api.createTodo(text); // typed result
|
|
17
|
+
* yield; // re-enter the transaction before writing
|
|
18
|
+
* setTodos(t => { ... });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* (For the same reason, don't call `flush()` inside an action body — it
|
|
22
|
+
* drains the transaction mid-step.)
|
|
11
23
|
*
|
|
12
24
|
* Each call returns a `Promise` that resolves with the generator's return
|
|
13
25
|
* value, or rejects if it throws. Pair with `createOptimistic` /
|
|
@@ -18,10 +30,11 @@
|
|
|
18
30
|
* ```ts
|
|
19
31
|
* const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
|
|
20
32
|
*
|
|
21
|
-
* const addTodo = action(function* (text: string) {
|
|
33
|
+
* const addTodo = action(async function* (text: string) {
|
|
22
34
|
* const tempId = crypto.randomUUID();
|
|
23
35
|
* setTodos(t => { t.push({ id: tempId, text, pending: true }); }); // optimistic
|
|
24
|
-
* const saved =
|
|
36
|
+
* const saved = await api.createTodo(text); // network round-trip, typed
|
|
37
|
+
* yield; // re-enter the transaction
|
|
25
38
|
* setTodos(t => {
|
|
26
39
|
* const i = t.findIndex(x => x.id === tempId);
|
|
27
40
|
* if (i >= 0) t[i] = saved;
|
|
@@ -35,6 +35,18 @@ export declare const EFFECT_USER = 2;
|
|
|
35
35
|
export declare const EFFECT_TRACKED = 3;
|
|
36
36
|
export declare const NOT_PENDING: {};
|
|
37
37
|
export declare const NO_SNAPSHOT: {};
|
|
38
|
+
/**
|
|
39
|
+
* Stand-in stored in `_overrideValue` for an optimistic write of literal
|
|
40
|
+
* `undefined` (#2898). The slot doubles as the optimistic-node brand
|
|
41
|
+
* (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
|
|
42
|
+
* would erase the node's optimistic identity: the write turns invisible and
|
|
43
|
+
* follow-up writes route off the optimistic path and commit permanently.
|
|
44
|
+
* Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
|
|
45
|
+
* via `visibleOverrideValue`; slot identity tests stay raw.
|
|
46
|
+
*/
|
|
47
|
+
export declare const OVERRIDE_UNDEFINED: {};
|
|
48
|
+
/** Unwrap an active override's stored value for surfacing to readers (#2898). */
|
|
49
|
+
export declare function unwrapOverride<T = any>(v: unknown): T;
|
|
38
50
|
export declare const STORE_SNAPSHOT_PROPS = "sp";
|
|
39
51
|
export declare const SUPPORTS_PROXY: boolean;
|
|
40
52
|
export declare const defaultContext: {};
|
|
@@ -48,6 +48,13 @@ export declare const DEV: Dev;
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function assertInvariant(condition: boolean, name: string, message: string): void;
|
|
50
50
|
export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
|
|
51
|
+
/**
|
|
52
|
+
* Shared strict-read diagnostics for core read() and the store proxy traps.
|
|
53
|
+
* Single source for the message text — the #2897 safeguard parity between
|
|
54
|
+
* memos and stores is exactly these firing identically from both paths.
|
|
55
|
+
*/
|
|
56
|
+
export declare function throwPendingUntrackedRead(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "data">>): never;
|
|
57
|
+
export declare function warnStrictReadUntracked(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence">>): void;
|
|
51
58
|
export declare function registerGraph(value: any, owner: Owner | null): void;
|
|
52
59
|
export declare function clearSignals(node: Owner): void;
|
|
53
60
|
export declare function getChildren(owner: Owner): Owner[];
|
|
@@ -37,6 +37,8 @@ export declare function resolveLane(el: {
|
|
|
37
37
|
export declare function resolveTransition(el: {
|
|
38
38
|
_optimisticLane?: OptimisticLane;
|
|
39
39
|
_transition?: Transition | null;
|
|
40
|
+
_overrideValue?: any;
|
|
41
|
+
_overrideOwner?: Transition | null;
|
|
40
42
|
}): Transition | null | undefined;
|
|
41
43
|
/**
|
|
42
44
|
* Check if a node has an active optimistic override.
|
|
@@ -75,15 +75,11 @@ export declare class Queue implements IQueue {
|
|
|
75
75
|
}
|
|
76
76
|
export declare class GlobalQueue extends Queue {
|
|
77
77
|
_running: boolean;
|
|
78
|
-
|
|
79
|
-
_pendingNodes: Signal<any>[];
|
|
80
|
-
_optimisticNodes: OptimisticNode[];
|
|
81
|
-
_affectsNodes: OptimisticNode[];
|
|
82
|
-
_optimisticStores: Set<any>;
|
|
78
|
+
_batch: Transition;
|
|
83
79
|
static _update: (el: Computed<unknown>) => void;
|
|
84
80
|
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
85
81
|
static _runEffect: (el: Computed<unknown>) => void;
|
|
86
|
-
static _clearOptimisticStores: ((stores: Set<any
|
|
82
|
+
static _clearOptimisticStores: ((stores: Set<any>, completing: Transition | null) => void) | null;
|
|
87
83
|
static _releaseAffectsScope: ((node: OptimisticNode) => void) | null;
|
|
88
84
|
static _applyAffectsReads: ((el: Computed<any>, sources: (Signal<any> | Computed<any>)[]) => void) | null;
|
|
89
85
|
static _releaseAffectsMarks: ((nodes: OptimisticNode[]) => void) | null;
|
|
@@ -44,6 +44,15 @@ export interface RawSignal<T> {
|
|
|
44
44
|
_transition: Transition | null;
|
|
45
45
|
_pendingValue: T | typeof NOT_PENDING;
|
|
46
46
|
_overrideValue?: T | typeof NOT_PENDING;
|
|
47
|
+
/**
|
|
48
|
+
* The transaction that owns the active override (stamped at optimistic
|
|
49
|
+
* write, cleared at settle). Ownership must live on the node: a lane's
|
|
50
|
+
* _transition is a scheduling affinity that a shared subscriber can merge
|
|
51
|
+
* across transactions (#2912) — following it would let one action's settle
|
|
52
|
+
* revert another action's live override. Node-level sibling of the store
|
|
53
|
+
* layer's STORE_OPTIMISTIC_OWNERS stamps (#2899). `null` = ambient write.
|
|
54
|
+
*/
|
|
55
|
+
_overrideOwner?: Transition | null;
|
|
47
56
|
_optimisticLane?: OptimisticLane;
|
|
48
57
|
_pendingSignal?: Signal<boolean>;
|
|
49
58
|
_latestValueComputed?: Computed<T>;
|
|
@@ -93,7 +102,6 @@ export interface Computed<T> extends RawSignal<T>, Owner {
|
|
|
93
102
|
_depGen: number;
|
|
94
103
|
_flags: number;
|
|
95
104
|
_blocked?: boolean;
|
|
96
|
-
_pendingSource?: Computed<any>;
|
|
97
105
|
_pendingSources?: Set<Computed<any>>;
|
|
98
106
|
_error?: unknown;
|
|
99
107
|
_statusFlags: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { STORE_SNAPSHOT_PROPS, type Computed, type Refreshable, type Signal } from "../core/index.cjs";
|
|
2
|
+
import { type Transition } from "../core/scheduler.cjs";
|
|
2
3
|
/** A read-only view of a store's value as seen by consumers. Mutate it via the paired `StoreSetter`. */
|
|
3
4
|
export type Store<T> = Readonly<T>;
|
|
4
5
|
/**
|
|
@@ -41,12 +42,13 @@ type DataNodes = Record<PropertyKey, DataNode>;
|
|
|
41
42
|
* @internal
|
|
42
43
|
*/
|
|
43
44
|
export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
|
|
44
|
-
export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p";
|
|
45
|
+
export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p", STORE_OPTIMISTIC_OWNERS = "t", STORE_PARENT = "u", STORE_DESC = "d";
|
|
45
46
|
export type StoreNode = {
|
|
46
47
|
[$PROXY]: any;
|
|
47
48
|
[STORE_VALUE]: Record<PropertyKey, any>;
|
|
48
49
|
[STORE_OVERRIDE]?: Record<PropertyKey, any>;
|
|
49
50
|
[STORE_OPTIMISTIC_OVERRIDE]?: Record<PropertyKey, any>;
|
|
51
|
+
[STORE_OPTIMISTIC_OWNERS]?: Record<PropertyKey, Transition | null>;
|
|
50
52
|
[STORE_NODE]?: DataNodes;
|
|
51
53
|
[STORE_HAS]?: DataNodes;
|
|
52
54
|
[STORE_CUSTOM_PROTO]?: boolean;
|
|
@@ -55,6 +57,8 @@ export type StoreNode = {
|
|
|
55
57
|
[STORE_FIREWALL]?: Computed<any>;
|
|
56
58
|
[STORE_OPTIMISTIC]?: boolean;
|
|
57
59
|
[STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
|
|
60
|
+
[STORE_PARENT]?: StoreNode;
|
|
61
|
+
[STORE_DESC]?: boolean;
|
|
58
62
|
};
|
|
59
63
|
export declare namespace SolidStore {
|
|
60
64
|
interface Unwrappable {
|
|
@@ -91,7 +95,7 @@ export declare function visibleNodeValue(node: DataNode): any;
|
|
|
91
95
|
*
|
|
92
96
|
* @internal
|
|
93
97
|
*/
|
|
94
|
-
export declare function witnessAffectsMark(target: StoreNode): void;
|
|
98
|
+
export declare function witnessAffectsMark(target: StoreNode, property?: PropertyKey): void;
|
|
95
99
|
/**
|
|
96
100
|
* Resolves the store nodes an `affects()` declaration marks: with a `key`,
|
|
97
101
|
* the named slot's leaf node (upserted so the mark has an addressable
|
|
@@ -114,6 +118,8 @@ export declare function notifySelf(target: StoreNode): void;
|
|
|
114
118
|
*/
|
|
115
119
|
export declare function mergedOverlay(target: StoreNode): Record<PropertyKey, any> | undefined;
|
|
116
120
|
export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
|
|
121
|
+
export declare function getStoreKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): PropertyKey[];
|
|
122
|
+
export declare function getStoreSymbols(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): symbol[];
|
|
117
123
|
export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
|
|
118
124
|
export declare const storeTraps: ProxyHandler<StoreNode>;
|
|
119
125
|
export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
|
package/package.json
CHANGED