@solidjs/signals 2.0.0-beta.24 → 2.0.0-beta.25
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 +465 -81
- package/dist/node.cjs +990 -652
- package/dist/prod/core/core.js +110 -76
- package/dist/prod/core/effect.js +9 -9
- package/dist/prod/core/graph.js +3 -3
- package/dist/prod/core/heap.js +23 -23
- package/dist/prod/core/optimistic.js +6 -4
- package/dist/prod/core/owner.js +10 -10
- package/dist/prod/core/scheduler.js +12 -12
- package/dist/prod/core/verdict.js +3 -3
- package/dist/prod/store/optimistic.js +12 -5
- package/dist/prod/store/projection.js +25 -18
- package/dist/prod/store/reconcile.js +405 -211
- package/dist/prod/store/store.js +196 -102
- package/dist/prod/store/utils.js +22 -22
- package/dist/types/core/core.d.ts +15 -0
- package/dist/types/store/optimistic.d.ts +1 -1
- package/dist/types/store/store.d.ts +20 -2
- package/dist/types-cjs/core/core.d.cts +15 -0
- package/dist/types-cjs/store/optimistic.d.cts +1 -1
- package/dist/types-cjs/store/store.d.cts +20 -2
- package/package.json +1 -1
|
@@ -41,5 +41,5 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
|
|
|
41
41
|
*
|
|
42
42
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
43
43
|
*/
|
|
44
|
-
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T
|
|
44
|
+
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
45
45
|
export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
@@ -31,6 +31,8 @@ export interface StoreOptions {
|
|
|
31
31
|
export interface ProjectionOptions extends StoreOptions {
|
|
32
32
|
/** Key property name or function for reconciliation identity */
|
|
33
33
|
key?: string | ((item: NonNullable<any>) => any);
|
|
34
|
+
/** Single-layer store: root keys reactive, values raw records replaced by reference */
|
|
35
|
+
shallow?: boolean;
|
|
34
36
|
}
|
|
35
37
|
export type NoFn<T> = T extends Function ? never : T;
|
|
36
38
|
type DataNode = Signal<any>;
|
|
@@ -42,7 +44,7 @@ type DataNodes = Record<PropertyKey, DataNode>;
|
|
|
42
44
|
* @internal
|
|
43
45
|
*/
|
|
44
46
|
export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
|
|
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";
|
|
47
|
+
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", STORE_SHALLOW = "s";
|
|
46
48
|
export type StoreNode = {
|
|
47
49
|
[$PROXY]: any;
|
|
48
50
|
[STORE_VALUE]: Record<PropertyKey, any>;
|
|
@@ -58,6 +60,7 @@ export type StoreNode = {
|
|
|
58
60
|
[STORE_OPTIMISTIC]?: boolean;
|
|
59
61
|
[STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
|
|
60
62
|
[STORE_PARENT]?: StoreNode;
|
|
63
|
+
[STORE_SHALLOW]?: boolean;
|
|
61
64
|
[STORE_DESC]?: boolean;
|
|
62
65
|
};
|
|
63
66
|
export declare namespace SolidStore {
|
|
@@ -68,7 +71,20 @@ export type NotWrappable = string | number | bigint | symbol | boolean | Functio
|
|
|
68
71
|
export declare function createStoreProxy<T extends object>(value: T, traps?: ProxyHandler<StoreNode>, extend?: (target: StoreNode) => void): any;
|
|
69
72
|
export declare const storeLookup: WeakMap<WeakKey, any>;
|
|
70
73
|
export declare const symbolKeyedRecords: WeakSet<object>;
|
|
74
|
+
export declare function lookupTarget(value: any, lookup?: WeakMap<any, any>): StoreNode | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Marks a value as raw: no store will ever wrap it — every store presents it
|
|
77
|
+
* as-is, tracked by reference at whatever slot holds it and updated by
|
|
78
|
+
* replacement. Useful for class instances and external objects (editors,
|
|
79
|
+
* scene graphs, Maps) and for record-shaped data updated wholesale. Sticky
|
|
80
|
+
* for the value's lifetime.
|
|
81
|
+
*/
|
|
82
|
+
export declare let rawValuesUsed: boolean;
|
|
83
|
+
export declare function isRawValue(value: any): boolean;
|
|
84
|
+
export declare function markRaw<T>(value: T): T;
|
|
85
|
+
export declare function markRawIngest(container: any): void;
|
|
71
86
|
export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
|
|
87
|
+
export declare function wrapShallow<T extends Record<PropertyKey, any>>(value: T): T;
|
|
72
88
|
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
|
|
73
89
|
export declare function setWriteOverride(value: boolean): void;
|
|
74
90
|
export declare function ownEnumerableKeys(o: object): (string | symbol)[];
|
|
@@ -176,6 +192,8 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
176
192
|
*
|
|
177
193
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
178
194
|
*/
|
|
179
|
-
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T
|
|
195
|
+
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
|
|
196
|
+
shallow?: boolean;
|
|
197
|
+
}): StoreReturn<T>;
|
|
180
198
|
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>;
|
|
181
199
|
export {};
|
|
@@ -72,6 +72,21 @@ export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false
|
|
|
72
72
|
* date so its status flags reflect the current graph.
|
|
73
73
|
*/
|
|
74
74
|
export declare function prepareComputed(comp: Computed<unknown>, refresh: boolean): void;
|
|
75
|
+
/**
|
|
76
|
+
* Sentinel returned by readNodeFast when the plain-signal fast path does not
|
|
77
|
+
* apply and the caller must fall back to the full read().
|
|
78
|
+
*/
|
|
79
|
+
export declare const READ_SLOW: unique symbol;
|
|
80
|
+
/**
|
|
81
|
+
* read()'s plain-signal fast path as a standalone entry for hot callers
|
|
82
|
+
* (store traps). Safe to substitute for read() only because the bail
|
|
83
|
+
* conditions mirror read()'s prelude and fast-path guard exactly: the
|
|
84
|
+
* latestRead and pendingCheck windows run side-effectful hooks before the
|
|
85
|
+
* fast path, `_fn` nodes need prepareComputed, and firewall / override /
|
|
86
|
+
* snapshot / transition / lane / dev-strictRead state all take the full
|
|
87
|
+
* resolution. Anything slow returns READ_SLOW; the caller then calls read().
|
|
88
|
+
*/
|
|
89
|
+
export declare function readNodeFast<T>(el: Signal<T>): T | typeof READ_SLOW;
|
|
75
90
|
export declare function read<T>(el: Signal<T> | Computed<T>): T;
|
|
76
91
|
export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
|
|
77
92
|
/**
|
|
@@ -41,5 +41,5 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
|
|
|
41
41
|
*
|
|
42
42
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
43
43
|
*/
|
|
44
|
-
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T
|
|
44
|
+
export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
45
45
|
export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
@@ -31,6 +31,8 @@ export interface StoreOptions {
|
|
|
31
31
|
export interface ProjectionOptions extends StoreOptions {
|
|
32
32
|
/** Key property name or function for reconciliation identity */
|
|
33
33
|
key?: string | ((item: NonNullable<any>) => any);
|
|
34
|
+
/** Single-layer store: root keys reactive, values raw records replaced by reference */
|
|
35
|
+
shallow?: boolean;
|
|
34
36
|
}
|
|
35
37
|
export type NoFn<T> = T extends Function ? never : T;
|
|
36
38
|
type DataNode = Signal<any>;
|
|
@@ -42,7 +44,7 @@ type DataNodes = Record<PropertyKey, DataNode>;
|
|
|
42
44
|
* @internal
|
|
43
45
|
*/
|
|
44
46
|
export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
|
|
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";
|
|
47
|
+
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", STORE_SHALLOW = "s";
|
|
46
48
|
export type StoreNode = {
|
|
47
49
|
[$PROXY]: any;
|
|
48
50
|
[STORE_VALUE]: Record<PropertyKey, any>;
|
|
@@ -58,6 +60,7 @@ export type StoreNode = {
|
|
|
58
60
|
[STORE_OPTIMISTIC]?: boolean;
|
|
59
61
|
[STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
|
|
60
62
|
[STORE_PARENT]?: StoreNode;
|
|
63
|
+
[STORE_SHALLOW]?: boolean;
|
|
61
64
|
[STORE_DESC]?: boolean;
|
|
62
65
|
};
|
|
63
66
|
export declare namespace SolidStore {
|
|
@@ -68,7 +71,20 @@ export type NotWrappable = string | number | bigint | symbol | boolean | Functio
|
|
|
68
71
|
export declare function createStoreProxy<T extends object>(value: T, traps?: ProxyHandler<StoreNode>, extend?: (target: StoreNode) => void): any;
|
|
69
72
|
export declare const storeLookup: WeakMap<WeakKey, any>;
|
|
70
73
|
export declare const symbolKeyedRecords: WeakSet<object>;
|
|
74
|
+
export declare function lookupTarget(value: any, lookup?: WeakMap<any, any>): StoreNode | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Marks a value as raw: no store will ever wrap it — every store presents it
|
|
77
|
+
* as-is, tracked by reference at whatever slot holds it and updated by
|
|
78
|
+
* replacement. Useful for class instances and external objects (editors,
|
|
79
|
+
* scene graphs, Maps) and for record-shaped data updated wholesale. Sticky
|
|
80
|
+
* for the value's lifetime.
|
|
81
|
+
*/
|
|
82
|
+
export declare let rawValuesUsed: boolean;
|
|
83
|
+
export declare function isRawValue(value: any): boolean;
|
|
84
|
+
export declare function markRaw<T>(value: T): T;
|
|
85
|
+
export declare function markRawIngest(container: any): void;
|
|
71
86
|
export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
|
|
87
|
+
export declare function wrapShallow<T extends Record<PropertyKey, any>>(value: T): T;
|
|
72
88
|
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
|
|
73
89
|
export declare function setWriteOverride(value: boolean): void;
|
|
74
90
|
export declare function ownEnumerableKeys(o: object): (string | symbol)[];
|
|
@@ -176,6 +192,8 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
176
192
|
*
|
|
177
193
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
178
194
|
*/
|
|
179
|
-
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T
|
|
195
|
+
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
|
|
196
|
+
shallow?: boolean;
|
|
197
|
+
}): StoreReturn<T>;
|
|
180
198
|
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>;
|
|
181
199
|
export {};
|
package/package.json
CHANGED