@solidjs/signals 2.0.0-beta.9 → 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 +5971 -1426
- package/dist/node.cjs +7681 -3293
- 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 +60 -13
- package/dist/types/core/action.d.ts +35 -6
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +35 -6
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +58 -63
- 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 +50 -3
- package/dist/types/core/scheduler.d.ts +82 -10
- package/dist/types/core/types.d.ts +66 -1
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/map.d.ts +21 -5
- package/dist/types/signals.d.ts +164 -12
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +10 -6
- package/dist/types/store/reconcile.d.ts +31 -8
- package/dist/types/store/store.d.ts +101 -6
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +60 -13
- package/dist/types-cjs/core/action.d.cts +35 -6
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +35 -6
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +58 -63
- 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 +50 -3
- package/dist/types-cjs/core/scheduler.d.cts +82 -10
- package/dist/types-cjs/core/types.d.cts +66 -1
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +3 -2
- package/dist/types-cjs/map.d.cts +21 -5
- package/dist/types-cjs/signals.d.cts +164 -12
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/optimistic.d.cts +3 -3
- package/dist/types-cjs/store/projection.d.cts +10 -6
- package/dist/types-cjs/store/reconcile.d.cts +31 -8
- package/dist/types-cjs/store/store.d.cts +101 -6
- package/package.json +11 -9
- package/dist/prod.js +0 -3627
|
@@ -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
|
/**
|
|
@@ -17,6 +18,10 @@ export type Store<T> = Readonly<T>;
|
|
|
17
18
|
* whose derive function reconciles its return by `options.key`.
|
|
18
19
|
*/
|
|
19
20
|
export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
|
|
21
|
+
/** Tuple returned by the plain `createStore(initialValue)` form. */
|
|
22
|
+
export type StoreReturn<T> = [get: Store<T>, set: StoreSetter<T>];
|
|
23
|
+
/** Tuple returned by the derived `createStore(fn, seed, options?)` form. */
|
|
24
|
+
export type ProjectionStoreReturn<T> = [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
20
25
|
/** Base options for store primitives. */
|
|
21
26
|
export interface StoreOptions {
|
|
22
27
|
/** Debug name (dev mode only) */
|
|
@@ -24,26 +29,53 @@ export interface StoreOptions {
|
|
|
24
29
|
}
|
|
25
30
|
/** Options for derived/projected stores created with `createStore(fn)`, `createProjection`, or `createOptimisticStore(fn)`. */
|
|
26
31
|
export interface ProjectionOptions extends StoreOptions {
|
|
27
|
-
/** Key property name or function for reconciliation identity */
|
|
28
|
-
key?: string | ((item: NonNullable<any>) => any);
|
|
32
|
+
/** Key property name or function for reconciliation identity; `null` merges positionally */
|
|
33
|
+
key?: string | ((item: NonNullable<any>) => any) | null;
|
|
34
|
+
/** Single-layer store: root keys reactive, values raw records replaced by reference */
|
|
35
|
+
shallow?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Treat the seed as commit #0: the store is born committed with the seed's
|
|
38
|
+
* contents, shown until the derive's first real answer lands. While that
|
|
39
|
+
* first answer is in flight, reads serve the seed everywhere — nothing
|
|
40
|
+
* suspends to a `<Loading>` boundary, no transition is held, and
|
|
41
|
+
* `isPending` stays false (the seed answers by declaration; first-load
|
|
42
|
+
* affordances belong to the data, e.g. a `skeleton: true` field in the
|
|
43
|
+
* seed). Once the first answer lands (reconciled into the seed), refetches
|
|
44
|
+
* use normal pending semantics with `isPending` true.
|
|
45
|
+
*
|
|
46
|
+
* The store equivalent of `MemoOptions.loadingValue`; the seed already
|
|
47
|
+
* carries the placeholder shape, so this is just the opt-in.
|
|
48
|
+
*/
|
|
49
|
+
seedLoadingValue?: boolean;
|
|
29
50
|
}
|
|
30
51
|
export type NoFn<T> = T extends Function ? never : T;
|
|
31
52
|
type DataNode = Signal<any>;
|
|
32
53
|
type DataNodes = Record<PropertyKey, DataNode>;
|
|
33
|
-
|
|
34
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Brand symbols used internally by the store proxy / projection plumbing.
|
|
56
|
+
* Cross-package wiring; not part of the user-facing API.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
|
|
61
|
+
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";
|
|
35
62
|
export type StoreNode = {
|
|
36
63
|
[$PROXY]: any;
|
|
37
64
|
[STORE_VALUE]: Record<PropertyKey, any>;
|
|
38
65
|
[STORE_OVERRIDE]?: Record<PropertyKey, any>;
|
|
39
66
|
[STORE_OPTIMISTIC_OVERRIDE]?: Record<PropertyKey, any>;
|
|
67
|
+
[STORE_OPTIMISTIC_OWNERS]?: Record<PropertyKey, Transition | null>;
|
|
40
68
|
[STORE_NODE]?: DataNodes;
|
|
41
69
|
[STORE_HAS]?: DataNodes;
|
|
70
|
+
[STORE_CUSTOM_PROTO]?: boolean;
|
|
42
71
|
[STORE_WRAP]?: (value: any, target?: StoreNode) => any;
|
|
43
72
|
[STORE_LOOKUP]?: WeakMap<any, any>;
|
|
44
73
|
[STORE_FIREWALL]?: Computed<any>;
|
|
45
74
|
[STORE_OPTIMISTIC]?: boolean;
|
|
46
75
|
[STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
|
|
76
|
+
[STORE_PARENT]?: StoreNode;
|
|
77
|
+
[STORE_SHALLOW]?: boolean;
|
|
78
|
+
[STORE_DESC]?: boolean;
|
|
47
79
|
};
|
|
48
80
|
export declare namespace SolidStore {
|
|
49
81
|
interface Unwrappable {
|
|
@@ -52,11 +84,72 @@ export declare namespace SolidStore {
|
|
|
52
84
|
export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
|
|
53
85
|
export declare function createStoreProxy<T extends object>(value: T, traps?: ProxyHandler<StoreNode>, extend?: (target: StoreNode) => void): any;
|
|
54
86
|
export declare const storeLookup: WeakMap<WeakKey, any>;
|
|
87
|
+
export declare const symbolKeyedRecords: WeakSet<object>;
|
|
88
|
+
export declare function lookupTarget(value: any, lookup?: WeakMap<any, any>): StoreNode | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Marks a value as raw: no store will ever wrap it — every store presents it
|
|
91
|
+
* as-is, tracked by reference at whatever slot holds it and updated by
|
|
92
|
+
* replacement. Useful for class instances and external objects (editors,
|
|
93
|
+
* scene graphs, Maps) and for record-shaped data updated wholesale. Sticky
|
|
94
|
+
* for the value's lifetime.
|
|
95
|
+
*/
|
|
96
|
+
export declare let rawValuesUsed: boolean;
|
|
97
|
+
export declare function isRawValue(value: any): boolean;
|
|
98
|
+
export declare function markRaw<T>(value: T): T;
|
|
99
|
+
export declare function markRawIngest(container: any): void;
|
|
55
100
|
export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
|
|
101
|
+
export declare function wrapShallow<T extends Record<PropertyKey, any>>(value: T): T;
|
|
56
102
|
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
|
|
57
103
|
export declare function setWriteOverride(value: boolean): void;
|
|
104
|
+
export declare function ownEnumerableKeys(o: object): (string | symbol)[];
|
|
105
|
+
/**
|
|
106
|
+
* Single chokepoint for the store's layered value resolution: returns the
|
|
107
|
+
* override layer (optimistic first, then regular) that shadows `property`, or
|
|
108
|
+
* `undefined` when the base `STORE_VALUE` is authoritative. Every trap must
|
|
109
|
+
* resolve through this — hand-inlining the layer order is how the optimistic
|
|
110
|
+
* layer gets missed (#2850).
|
|
111
|
+
*/
|
|
112
|
+
export declare function getOverlayLayer(target: StoreNode, property: PropertyKey): Record<PropertyKey, any> | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* The value a store leaf's backing signal currently shows to readers: active
|
|
115
|
+
* override, else held pending value, else committed value.
|
|
116
|
+
*/
|
|
117
|
+
export declare function visibleNodeValue(node: DataNode): any;
|
|
118
|
+
/**
|
|
119
|
+
* Witness live mark coverage of a record into the active isPending() probe.
|
|
120
|
+
* Tracked reads don't need this — they go through real signal nodes, which
|
|
121
|
+
* carry marks directly (declaration walk or birth inheritance). This covers
|
|
122
|
+
* UNTRACKED probes reading through records whose nodes never materialized
|
|
123
|
+
* (no observer ever subscribed, so no node exists to carry the mark).
|
|
124
|
+
* Callers guard on `pendingCheckActive`, so plain reads never pay for this.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
export declare function witnessAffectsMark(target: StoreNode, property?: PropertyKey): void;
|
|
129
|
+
/**
|
|
130
|
+
* Resolves the store nodes an `affects()` declaration marks: with a `key`,
|
|
131
|
+
* the named slot's leaf node (upserted so the mark has an addressable
|
|
132
|
+
* carrier); without, the record's $AFFECTS carrier plus every LIVE node in
|
|
133
|
+
* its subtree (the edges existing readers subscribed through), with the
|
|
134
|
+
* subtree's identities snapshotted into the mark's scope so nodes created
|
|
135
|
+
* during the window — and untracked probes over captured proxies — resolve
|
|
136
|
+
* against it (#2882).
|
|
137
|
+
*
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
export declare function getStoreAffectsNodes(target: StoreNode, key?: PropertyKey): DataNode[];
|
|
58
141
|
export declare function trackSelf(target: StoreNode, symbol?: symbol): void;
|
|
142
|
+
export declare function notifySelf(target: StoreNode): void;
|
|
143
|
+
/**
|
|
144
|
+
* The write overlay a walk must read through: optimistic writes shadow
|
|
145
|
+
* regular pending writes, the same resolution order as every proxy trap and
|
|
146
|
+
* `reconcile` (#2850). Merging allocates only in the rare both-present case
|
|
147
|
+
* (a derived optimistic store with an in-flight projection commit).
|
|
148
|
+
*/
|
|
149
|
+
export declare function mergedOverlay(target: StoreNode): Record<PropertyKey, any> | undefined;
|
|
59
150
|
export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
|
|
151
|
+
export declare function getStoreKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): PropertyKey[];
|
|
152
|
+
export declare function getStoreSymbols(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined): symbol[];
|
|
60
153
|
export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
|
|
61
154
|
export declare const storeTraps: ProxyHandler<StoreNode>;
|
|
62
155
|
export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
|
|
@@ -113,6 +206,8 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
|
|
|
113
206
|
*
|
|
114
207
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
115
208
|
*/
|
|
116
|
-
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T
|
|
117
|
-
|
|
209
|
+
export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions & {
|
|
210
|
+
shallow?: boolean;
|
|
211
|
+
}): StoreReturn<T>;
|
|
212
|
+
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>;
|
|
118
213
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/signals",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"description": "Solid's reactive primitives: signals, memos, effects, stores, and async-aware computations.",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"main": "./dist/node.cjs",
|
|
17
|
-
"module": "./dist/prod.js",
|
|
17
|
+
"module": "./dist/prod/index.js",
|
|
18
|
+
"unpkg": "./dist/prod/index.js",
|
|
19
|
+
"jsdelivr": "./dist/prod/index.js",
|
|
18
20
|
"types": "./dist/types/index.d.ts",
|
|
19
21
|
"type": "module",
|
|
20
22
|
"sideEffects": false,
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"types": "./dist/types/index.d.ts",
|
|
29
31
|
"test": "./dist/dev.js",
|
|
30
32
|
"development": "./dist/dev.js",
|
|
31
|
-
"default": "./dist/prod.js"
|
|
33
|
+
"default": "./dist/prod/index.js"
|
|
32
34
|
},
|
|
33
35
|
"require": {
|
|
34
36
|
"types": "./dist/types-cjs/index.d.cts",
|
|
@@ -40,21 +42,21 @@
|
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
|
|
42
44
|
"@rollup/plugin-replace": "^6.0.3",
|
|
43
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
44
45
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
45
46
|
"@types/node": "^25.0.8",
|
|
46
47
|
"rimraf": "^5.0.1",
|
|
47
48
|
"rollup": "^4.53.4",
|
|
48
49
|
"rollup-plugin-prettier": "^4.1.2",
|
|
50
|
+
"terser": "^5.49.0",
|
|
49
51
|
"tslib": "^2.8.1",
|
|
50
|
-
"typescript": "
|
|
51
|
-
"vite": "^
|
|
52
|
-
"vitest": "^
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"vite": "^7.0.0",
|
|
54
|
+
"vitest": "^4.1.6"
|
|
53
55
|
},
|
|
54
56
|
"scripts": {
|
|
55
57
|
"build": "npm-run-all -nl build:* && pnpm types",
|
|
56
|
-
"build:clean": "rimraf dist/dev.js dist/prod.js dist/node.cjs",
|
|
57
|
-
"build:js": "rollup -c",
|
|
58
|
+
"build:clean": "rimraf dist/dev dist/prod dist/node dist/dev.js dist/prod.js dist/node.cjs",
|
|
59
|
+
"build:js": "rollup -c && node ./scripts/mangle-props.mjs dist/prod dist/node.cjs && node ./scripts/check-pure.mjs dist/prod",
|
|
58
60
|
"types": "tsc -p tsconfig.build.json && node ../../scripts/sync-dual-types.mjs ./dist/types ./dist/types-cjs",
|
|
59
61
|
"test": "vitest run",
|
|
60
62
|
"test:watch": "vitest watch tests",
|