@solidjs/signals 2.0.0-rc.0 → 2.0.0-rc.10
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 +1 -1
- package/dist/dev-shared.js +7138 -0
- package/dist/dev.attribution.js +3307 -0
- package/dist/dev.js +8076 -6692
- package/dist/observe/affects.js +129 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +793 -0
- package/dist/observe/core/action.js +177 -0
- package/dist/observe/core/async.js +849 -0
- package/dist/observe/core/attribution-costs.js +66 -0
- package/dist/observe/core/attribution-feedback.js +280 -0
- package/dist/observe/core/attribution-hooks.js +83 -0
- package/dist/observe/core/attribution-queries.js +43 -0
- package/dist/observe/core/attribution.js +2904 -0
- package/dist/observe/core/constants.js +283 -0
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1999 -0
- package/dist/observe/core/dev.js +343 -0
- package/dist/observe/core/effect.js +200 -0
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/error.js +80 -0
- package/dist/observe/core/external.js +98 -0
- package/dist/observe/core/graph.js +155 -0
- package/dist/observe/core/heap.js +147 -0
- package/dist/observe/core/invariants.js +45 -0
- package/dist/observe/core/lanes.js +205 -0
- package/dist/observe/core/optimistic.js +627 -0
- package/dist/observe/core/owner.js +353 -0
- package/dist/observe/core/scheduler.js +1547 -0
- package/dist/observe/core/verdict.js +674 -0
- package/dist/observe/index.js +59 -0
- package/dist/observe/map.js +484 -0
- package/dist/observe/signals.js +731 -0
- package/dist/observe/store/index.js +44 -0
- package/dist/observe/store/next/optimistic.js +717 -0
- package/dist/observe/store/next/projection.js +266 -0
- package/dist/observe/store/next/reconcile.js +375 -0
- package/dist/observe/store/next/store.js +2480 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +331 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +1070 -0
- package/dist/prod/affects.js +10 -9
- package/dist/prod/attribution.js +45 -0
- package/dist/prod/boundaries.js +388 -178
- package/dist/prod/core/action.js +65 -37
- package/dist/prod/core/async.js +477 -208
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +186 -1
- package/dist/prod/core/context.js +10 -16
- package/dist/prod/core/core.js +1556 -415
- package/dist/prod/core/dev.js +18 -1
- package/dist/prod/core/effect.js +119 -79
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/error.js +13 -1
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +105 -54
- package/dist/prod/core/heap.js +72 -65
- package/dist/prod/core/invariants.js +3 -2
- package/dist/prod/core/lanes.js +117 -52
- package/dist/prod/core/optimistic.js +474 -103
- package/dist/prod/core/owner.js +131 -84
- package/dist/prod/core/scheduler.js +1013 -248
- package/dist/prod/core/verdict.js +418 -113
- package/dist/prod/index.js +25 -13
- package/dist/prod/map.js +314 -151
- package/dist/prod/signals.js +382 -32
- package/dist/prod/store/index.js +38 -0
- package/dist/prod/store/next/optimistic.js +710 -0
- package/dist/prod/store/next/projection.js +257 -0
- package/dist/prod/store/next/reconcile.js +373 -0
- package/dist/prod/store/next/store.js +2356 -0
- package/dist/prod/store/next/target.js +51 -0
- package/dist/prod/store/store.js +129 -881
- package/dist/prod/store/utils.js +982 -242
- package/dist/types/attribution.d.ts +19 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +78 -5
- package/dist/types/core/action.d.ts +12 -5
- package/dist/types/core/async.d.ts +3 -1
- package/dist/types/core/attribution-costs.d.ts +35 -0
- package/dist/types/core/attribution-feedback.d.ts +133 -0
- package/dist/types/core/attribution-hooks.d.ts +304 -0
- package/dist/types/core/attribution-queries.d.ts +24 -0
- package/dist/types/core/attribution.d.ts +892 -0
- package/dist/types/core/constants.d.ts +179 -0
- package/dist/types/core/core.d.ts +305 -23
- package/dist/types/core/dev.d.ts +421 -8
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/error.d.ts +9 -0
- package/dist/types/core/graph.d.ts +23 -0
- package/dist/types/core/heap.d.ts +5 -3
- package/dist/types/core/index.d.ts +6 -3
- package/dist/types/core/invariants.d.ts +5 -1
- package/dist/types/core/lanes.d.ts +51 -19
- package/dist/types/core/owner.d.ts +15 -3
- package/dist/types/core/scheduler.d.ts +252 -3
- package/dist/types/core/types.d.ts +124 -41
- package/dist/types/index.d.ts +18 -5
- package/dist/types/map.d.ts +2 -0
- package/dist/types/signals.d.ts +164 -13
- package/dist/types/store/index.d.ts +16 -5
- package/dist/types/store/next/optimistic.d.ts +25 -0
- package/dist/types/store/next/projection.d.ts +27 -0
- package/dist/types/store/next/reconcile.d.ts +10 -0
- package/dist/types/store/next/store.d.ts +143 -0
- package/dist/types/store/next/target.d.ts +196 -0
- package/dist/types/store/store.d.ts +46 -112
- package/dist/types/store/utils.d.ts +188 -40
- package/package.json +32 -26
- package/dist/node.cjs +0 -7938
- package/dist/prod/store/optimistic.js +0 -217
- package/dist/prod/store/projection.js +0 -231
- package/dist/prod/store/reconcile.js +0 -707
- package/dist/types/store/optimistic.d.ts +0 -45
- package/dist/types/store/projection.d.ts +0 -70
- package/dist/types/store/reconcile.d.ts +0 -46
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -21
- package/dist/types-cjs/core/constants.d.cts +0 -71
- package/dist/types-cjs/core/core.d.cts +0 -148
- package/dist/types-cjs/core/dev.d.cts +0 -64
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -47
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -5
- package/dist/types-cjs/core/heap.d.cts +0 -22
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -56
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -170
- package/dist/types-cjs/core/types.d.cts +0 -148
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/signals.d.cts +0 -605
- package/dist/types-cjs/store/index.d.cts +0 -9
- package/dist/types-cjs/store/optimistic.d.cts +0 -45
- package/dist/types-cjs/store/projection.d.cts +0 -70
- package/dist/types-cjs/store/reconcile.d.cts +0 -46
- package/dist/types-cjs/store/store.d.cts +0 -213
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -114
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a plain (non-proxy, non-reactive) deep copy of a store value.
|
|
3
|
-
* Reading via `snapshot` does **not** subscribe to changes — use this when you
|
|
4
|
-
* need to hand a stable plain object to non-reactive code (logging,
|
|
5
|
-
* serialization, structured-clone, network payloads, etc.).
|
|
6
|
-
*
|
|
7
|
-
* Returns the original object identity for any sub-tree that wasn't modified
|
|
8
|
-
* relative to the proxy's underlying source.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const [state] = createStore({ user: { name: "Ada" }, todos: [] });
|
|
13
|
-
*
|
|
14
|
-
* console.log(JSON.stringify(snapshot(state))); // safe, non-reactive copy
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function snapshot<T>(item: T): T;
|
|
18
|
-
export declare function snapshot<T>(item: T, map?: Map<unknown, unknown>, lookup?: WeakMap<any, any>): T;
|
|
19
|
-
/**
|
|
20
|
-
* Returns a plain (non-proxy) deep copy **and** subscribes the current
|
|
21
|
-
* tracking scope to every nested change in the source store. Any write
|
|
22
|
-
* anywhere in the subtree invalidates the consumer.
|
|
23
|
-
*
|
|
24
|
-
* Use this when you need plain data inside a reactive scope and want to
|
|
25
|
-
* react to deep mutations (e.g. passing a snapshot to `reconcile()` or to a
|
|
26
|
-
* memo that should rerun on any nested change). For most read paths, prefer
|
|
27
|
-
* direct property access — Solid stores already track per-property reads
|
|
28
|
-
* with no `deep()` wrapper needed.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const [state] = createStore({ a: { b: { c: 1 } } });
|
|
33
|
-
*
|
|
34
|
-
* createEffect(
|
|
35
|
-
* () => deep(state), // reruns on any nested change
|
|
36
|
-
* plain => sendToWorker(plain) // worker gets a non-proxy copy
|
|
37
|
-
* );
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function deep<T extends object>(store: T): T;
|
|
41
1
|
type DistributeOverride<T, F> = T extends undefined ? F : T;
|
|
42
2
|
type Override<T, U> = T extends any ? U extends any ? {
|
|
43
3
|
[K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
|
|
@@ -61,6 +21,173 @@ type _Merge<T extends unknown[], Curr = {}> = T extends [
|
|
|
61
21
|
...infer Rest
|
|
62
22
|
] ? _Merge<Rest, Override<Curr, Next>> : T extends [...infer Rest, infer Next | (() => infer Next)] ? Override<_Merge<Rest, Curr>, Next> : T extends [] ? Curr : T extends (infer I | (() => infer I))[] ? OverrideSpread<Curr, I> : Curr;
|
|
63
23
|
export type Merge<T extends unknown[]> = Simplify<_Merge<T>>;
|
|
24
|
+
/** @internal What a source ENTRY is, decided once when the view is built
|
|
25
|
+
* (`merge()` learns it while flattening; `omit()` from its argument) and
|
|
26
|
+
* carried beside the entry — `MergeView.kinds[i]`, `OmitView.kind` — so no
|
|
27
|
+
* read has to ask. Asking is the cost: any brand check on a Proxy is a trap
|
|
28
|
+
* (`instanceof` is a `getPrototypeOf` trap, ~20 ns on a store — as much as
|
|
29
|
+
* the read itself), and a merge over a store did two per read. */
|
|
30
|
+
export declare const SOURCE_PLAIN = 0;
|
|
31
|
+
export declare const SOURCE_OMIT = 1;
|
|
32
|
+
export declare const SOURCE_PROXY = 2;
|
|
33
|
+
export declare const SOURCE_MEMO = 3;
|
|
34
|
+
export declare const SOURCE_MERGE = 4;
|
|
35
|
+
export type SourceKind = 0 | 1 | 2 | 3 | 4;
|
|
36
|
+
/** @internal The record behind an `omit()` proxy: `source` with `hidden`
|
|
37
|
+
* keys removed. It is the proxy's TARGET, so the shared handler reads it as
|
|
38
|
+
* plain fields — no per-instance closures — and it is what props consumers
|
|
39
|
+
* walk directly (`merge`, `spread`, `ssrElement`): a view never materializes
|
|
40
|
+
* a copy, and a consumer that knows the record never goes through its traps
|
|
41
|
+
* (a `getOwnPropertyDescriptor` trap per key allocates a descriptor and a
|
|
42
|
+
* getter, so enumerating a proxy costs more than the copy it was avoiding).
|
|
43
|
+
* `hidden` is a key list or a predicate (`omit(props, k => k[0] === "$")`).
|
|
44
|
+
*
|
|
45
|
+
* An omit over a `merge()` holds the merge's RECORD (`MergeView`, kind
|
|
46
|
+
* `SOURCE_MERGE`) — never its proxy, so no read hops through a trap — and is
|
|
47
|
+
* one record however many leaves the merge has. A consumer walks it as ONE
|
|
48
|
+
* filtered entry (`sourceKeys` / `sourceGet` recurse into the merge's
|
|
49
|
+
* sources by function call), and a later `merge()` over it carries the
|
|
50
|
+
* record as one entry instead of copying its leaves: on a component chain of
|
|
51
|
+
* defaults + omit + spread (`merge(omit(merge(omit(props))))`) the layers
|
|
52
|
+
* nest as records, each a few fields, where a flatten to leaf views built a
|
|
53
|
+
* view and a combined key list per leaf per layer — the largest allocation
|
|
54
|
+
* of a Kobalte-shaped render. A merge leaf may be merge's memo for a
|
|
55
|
+
* function source; it is resolved on access. */
|
|
56
|
+
export declare class OmitView {
|
|
57
|
+
source: any;
|
|
58
|
+
/** of `source` — PLAIN, PROXY (a store or a foreign proxy), MEMO, or
|
|
59
|
+
* MERGE (a `MergeView` record); never OMIT, a view over a view folds
|
|
60
|
+
* into one. */
|
|
61
|
+
kind: SourceKind;
|
|
62
|
+
hidden: Hidden;
|
|
63
|
+
/** see `MergeView.table` */
|
|
64
|
+
table: Map<PropertyKey, any> | null | number;
|
|
65
|
+
/** see `tableOwnKeys` / `tableDescriptor` */
|
|
66
|
+
keys: (string | symbol)[] | undefined;
|
|
67
|
+
descs: Map<PropertyKey, PropertyDescriptor> | undefined;
|
|
68
|
+
constructor(source: any,
|
|
69
|
+
/** of `source` — PLAIN, PROXY (a store or a foreign proxy), MEMO, or
|
|
70
|
+
* MERGE (a `MergeView` record); never OMIT, a view over a view folds
|
|
71
|
+
* into one. */
|
|
72
|
+
kind: SourceKind, hidden: Hidden);
|
|
73
|
+
}
|
|
74
|
+
type Hidden = PropertyKey[] | ((key: PropertyKey) => boolean);
|
|
75
|
+
/** @internal The `OmitView` behind an `omit()` proxy, or undefined. */
|
|
76
|
+
export declare function omitView(o: any): OmitView | undefined;
|
|
77
|
+
/** @internal Own string keys of a source entry — every consumer skips
|
|
78
|
+
* symbols itself. */
|
|
79
|
+
export declare function sourceKeys(s: any, kind: SourceKind): (string | symbol)[];
|
|
80
|
+
/** @internal `key in entry`. */
|
|
81
|
+
export declare function sourceHas(s: any, kind: SourceKind, key: PropertyKey): boolean;
|
|
82
|
+
/** @internal `entry[key]` — the source's getter runs once, here. */
|
|
83
|
+
export declare function sourceGet(s: any, kind: SourceKind, key: PropertyKey): any;
|
|
84
|
+
/** @internal Whether the own key set of a props object cannot change
|
|
85
|
+
* reactively: a plain object, or a merge/omit view over plain objects only.
|
|
86
|
+
* A consumer may then decide from `Object.getOwnPropertyDescriptor` once —
|
|
87
|
+
* "no `children` key" or "a data `children`" holds for the object's lifetime,
|
|
88
|
+
* so no tracking scope is needed for it (#3388). For a store, or a view with
|
|
89
|
+
* a store or memo leaf, keys can appear later and the reactive path is the
|
|
90
|
+
* only correct one. */
|
|
91
|
+
export declare function hasStaticKeys(o: any): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Whether `o[key]` can never change for the lifetime of `o`: the key is a
|
|
94
|
+
* data property of a plain object, or is absent from an object whose key set
|
|
95
|
+
* is fixed. A getter, a key on a store, a memo-backed `merge()` source, or
|
|
96
|
+
* any key of an object whose keys can appear later (a store) is not static.
|
|
97
|
+
*
|
|
98
|
+
* Looks through `merge()`/`omit()` views to the leaf that owns the key. Any
|
|
99
|
+
* object will do, but props are the case it exists for: the compiler encodes
|
|
100
|
+
* a literal at the call site (`as="button"`) as a data property and an
|
|
101
|
+
* expression (`as={isLink() ? "a" : "button"}`) as a getter, so a component
|
|
102
|
+
* library reads the caller's own static/dynamic classification of a prop at
|
|
103
|
+
* runtime — identically on server and client, the compiler emitting the same
|
|
104
|
+
* own DESCRIPTORS on both (the object behind them may differ: the server
|
|
105
|
+
* builds props as a plain-prototype instance with shared getters) — and can
|
|
106
|
+
* take a no-computation path for the literal:
|
|
107
|
+
*
|
|
108
|
+
* ```tsx
|
|
109
|
+
* const Tag = dynamic(() => props.as, { static: isStatic(props, "as") });
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* One descriptor lookup; no read of the value, nothing tracked.
|
|
113
|
+
*/
|
|
114
|
+
export declare function isStatic(o: object, key: PropertyKey): boolean;
|
|
115
|
+
/** @internal */
|
|
116
|
+
export declare class MergeView {
|
|
117
|
+
sources: any[];
|
|
118
|
+
/** `kinds[i]` is what `sources[i]` is (see `SourceKind`). */
|
|
119
|
+
kinds: SourceKind[];
|
|
120
|
+
/** key → the plain leaf that owns it (later sources win), built by an
|
|
121
|
+
* enumeration or once the reads have paid for it (see `resolvedTable`)
|
|
122
|
+
* when every leaf has static keys; `null` when one doesn't. Until then
|
|
123
|
+
* the slot counts the per-key trap reads so far. One slot rather than a
|
|
124
|
+
* counter field of its own: a view is built per source per component
|
|
125
|
+
* layer, and each field initializer is a measurable share of a
|
|
126
|
+
* constructor that small in the lower JIT tiers. */
|
|
127
|
+
table: Map<PropertyKey, any> | null | number;
|
|
128
|
+
/** see `tableOwnKeys` / `tableDescriptor` */
|
|
129
|
+
keys: (string | symbol)[] | undefined;
|
|
130
|
+
descs: Map<PropertyKey, PropertyDescriptor> | undefined;
|
|
131
|
+
constructor(sources: any[],
|
|
132
|
+
/** `kinds[i]` is what `sources[i]` is (see `SourceKind`). */
|
|
133
|
+
kinds: SourceKind[]);
|
|
134
|
+
}
|
|
135
|
+
/** @internal The `MergeView` behind a `merge()` proxy — its flattened
|
|
136
|
+
* `sources` with their `kinds` — or undefined. */
|
|
137
|
+
export declare function mergeView(o: any): MergeView | undefined;
|
|
138
|
+
/** @internal The record behind a merge() or omit() proxy — a `MergeView`
|
|
139
|
+
* (flattened `sources` with their `kinds`) or an `OmitView` — or undefined
|
|
140
|
+
* for anything else (a plain object, a store, a foreign proxy). Two fast
|
|
141
|
+
* traps on a proxy (`has`, then `$RECORD`), none on a plain object. */
|
|
142
|
+
export declare function viewOf(o: any): MergeView | OmitView | undefined;
|
|
143
|
+
/** @internal The resolved key table of a merge/omit view — every own key of
|
|
144
|
+
* the view mapped to the plain object that owns it, in merged order (a key
|
|
145
|
+
* at the position of the last source that carries it, see `tableSet`) — or
|
|
146
|
+
* undefined when it has none: a leaf is a store or a memo source, whose
|
|
147
|
+
* keys can change, or the object is not a view at all.
|
|
148
|
+
*
|
|
149
|
+
* This is the flat object the eager copy used to build, made lazily and
|
|
150
|
+
* without copying: one pass over the leaves' own keys, then every
|
|
151
|
+
* `get`/`has`/descriptor is one lookup plus one read of the owning leaf, and
|
|
152
|
+
* a consumer (`spread` rerunning its effect) walks the table instead of
|
|
153
|
+
* re-deriving shadowing from the leaves each time. Own keys only, as the
|
|
154
|
+
* copy's were: a plain source's key set is fixed once merged (keys added to
|
|
155
|
+
* it later are not seen — the copy didn't see them either).
|
|
156
|
+
*
|
|
157
|
+
* It is built by an ENUMERATION — the `ownKeys` trap, or a consumer asking
|
|
158
|
+
* for it here — or once per-key reads have paid for it (`READS_FOR_TABLE`),
|
|
159
|
+
* not on the first read. A per-key read has a direct answer (a walk of the
|
|
160
|
+
* sources, last to first, one `in` each) whose cost is the source count,
|
|
161
|
+
* while the table's is every key of every leaf, so the walk wins until a
|
|
162
|
+
* view has been read about as many times as it has keys. On the server it
|
|
163
|
+
* never is: a component reads its props a few times, the element enumerates
|
|
164
|
+
* them once through its own source walk, and the view is gone — building on
|
|
165
|
+
* first read there cost a component chain a table per layer (profiled on
|
|
166
|
+
* the Kobalte-shaped chain: a third of SSR time in the table code and its
|
|
167
|
+
* garbage). On the
|
|
168
|
+
* client a view read on every reactive rerun crosses the threshold in its
|
|
169
|
+
* first few updates and is one lookup per read from then on, as before.
|
|
170
|
+
* Once built — by a `spread`, `Object.keys`, `{...props}`, or the count —
|
|
171
|
+
* every trap uses it. */
|
|
172
|
+
export declare function resolvedTable(o: any): Map<PropertyKey, any> | undefined;
|
|
173
|
+
/** @internal Every own string key of a props SOURCE — a plain object, a
|
|
174
|
+
* store or foreign proxy, or a merge/omit view — appended to `keys` in
|
|
175
|
+
* merged order with the object that owns each at the same index of
|
|
176
|
+
* `owners`: a key already listed (by this source or an earlier one) moves
|
|
177
|
+
* to the end, so several sources collected in turn give the order and the
|
|
178
|
+
* winners a merge of them would. A consumer that reads each key once
|
|
179
|
+
* (`ssrElement`) then reads `owners[i][keys[i]]` — the owner's getter runs
|
|
180
|
+
* there, once — and asks nothing else of a view: no table, no `in` walk per
|
|
181
|
+
* key through the merge/omit layers, no key list per leaf. One pass,
|
|
182
|
+
* however deep the layers nest. Symbols are listed; the consumer skips
|
|
183
|
+
* them. */
|
|
184
|
+
export declare function sourceOwners(s: any, keys: (string | symbol)[], owners: any[]): void;
|
|
185
|
+
/** @internal The flattened sources behind a `merge()` proxy, or undefined.
|
|
186
|
+
* A merge's writes are no-ops, so its sources are the whole truth. A COPY of
|
|
187
|
+
* a merge (`{...merged}`, a descriptor copy) is a plain object that carries
|
|
188
|
+
* no sources — `ownKeys` never lists $RECORD — so what is on the copy is
|
|
189
|
+
* the truth there and every consumer reads it directly (#3384). */
|
|
190
|
+
export declare function mergeSources(o: any): any[] | undefined;
|
|
64
191
|
/**
|
|
65
192
|
* Merges multiple props-like objects into a single proxy that *preserves
|
|
66
193
|
* reactivity*. Reads are forwarded to the right-most source that defines the
|
|
@@ -69,9 +196,23 @@ export type Merge<T extends unknown[]> = Simplify<_Merge<T>>;
|
|
|
69
196
|
* Function arguments are treated as memo-backed sources — useful for passing
|
|
70
197
|
* derived defaults whose computation should track reactively.
|
|
71
198
|
*
|
|
199
|
+
* The result is a live VIEW of its sources, never a copy: creating it costs
|
|
200
|
+
* nothing per key, every read goes to the source that owns the key (a getter
|
|
201
|
+
* runs there, a data property is read live), and writing to it is a no-op.
|
|
202
|
+
* A single non-function source is returned as is. To own a mutable object,
|
|
203
|
+
* copy it: `{ ...merged }` snapshots the current values.
|
|
204
|
+
*
|
|
72
205
|
* Use this in component bodies to merge defaults / overrides without losing
|
|
73
206
|
* Solid's per-property tracking.
|
|
74
207
|
*
|
|
208
|
+
* Reading props, here and anywhere: a prop's getter is defined only for a
|
|
209
|
+
* read through its own object (`props.x`, `{ ...props }`, `Reflect.get`,
|
|
210
|
+
* these views). Forwarding its descriptor onto another object and reading it
|
|
211
|
+
* there is not supported — the compiler's server-side props keep their state
|
|
212
|
+
* on the instance, so the getter needs its object as receiver. A copy that
|
|
213
|
+
* must stay live defines its own getter that reads through the source, as
|
|
214
|
+
* the no-Proxy paths of merge() and omit() do.
|
|
215
|
+
*
|
|
75
216
|
* @example
|
|
76
217
|
* ```tsx
|
|
77
218
|
* function Button(_props: { label: string; type?: string; disabled?: boolean }) {
|
|
@@ -92,6 +233,12 @@ export type Omit<T, K extends readonly (keyof T)[]> = {
|
|
|
92
233
|
* Use it to forward "rest" props to a child element while pulling out the
|
|
93
234
|
* keys your component handles itself — the equivalent of `splitProps(p, ["a","b"])[1]`.
|
|
94
235
|
*
|
|
236
|
+
* The result is a live VIEW of `props`, not a copy: nothing is read or
|
|
237
|
+
* materialized until a key is used, and a spread (`{...rest}`) or a later
|
|
238
|
+
* `merge()` walks the underlying object directly. A predicate hides keys by
|
|
239
|
+
* rule instead of by name — `omit(props, k => k[0] === "$")` — without
|
|
240
|
+
* enumerating first.
|
|
241
|
+
*
|
|
95
242
|
* @example
|
|
96
243
|
* ```tsx
|
|
97
244
|
* function Input(props: { label: string; value: string; onInput: (v: string) => void } & JSX.HTMLAttributes<HTMLInputElement>) {
|
|
@@ -111,4 +258,5 @@ export type Omit<T, K extends readonly (keyof T)[]> = {
|
|
|
111
258
|
* ```
|
|
112
259
|
*/
|
|
113
260
|
export declare function omit<T extends Record<any, any>, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit<T, K>;
|
|
261
|
+
export declare function omit<T extends Record<any, any>>(props: T, hidden: (key: keyof T & (string | symbol)) => boolean): Partial<T>;
|
|
114
262
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/signals",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.10",
|
|
4
4
|
"description": "Solid's reactive primitives: signals, memos, effects, stores, and async-aware computations.",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,17 +8,20 @@
|
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/solidjs/solid.git",
|
|
11
|
-
"directory": "packages/
|
|
11
|
+
"directory": "packages/signals"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"main": "./dist/
|
|
16
|
+
"main": "./dist/prod/index.js",
|
|
17
17
|
"module": "./dist/prod/index.js",
|
|
18
18
|
"unpkg": "./dist/prod/index.js",
|
|
19
19
|
"jsdelivr": "./dist/prod/index.js",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.12.0"
|
|
24
|
+
},
|
|
22
25
|
"sideEffects": false,
|
|
23
26
|
"files": [
|
|
24
27
|
"dist",
|
|
@@ -26,20 +29,35 @@
|
|
|
26
29
|
],
|
|
27
30
|
"exports": {
|
|
28
31
|
".": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"test": "./dist/dev.js",
|
|
34
|
+
"development": "./dist/dev.js",
|
|
35
|
+
"observe": "./dist/observe/index.js",
|
|
36
|
+
"default": "./dist/prod/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./attribution": {
|
|
39
|
+
"types": "./dist/types/attribution.d.ts",
|
|
40
|
+
"test": "./dist/dev.attribution.js",
|
|
41
|
+
"development": "./dist/dev.attribution.js",
|
|
42
|
+
"observe": "./dist/observe/attribution.js",
|
|
43
|
+
"default": "./dist/prod/attribution.js"
|
|
39
44
|
},
|
|
40
45
|
"./package.json": "./package.json"
|
|
41
46
|
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "npm-run-all -nl build:* && pnpm types",
|
|
49
|
+
"build:clean": "rimraf dist/dev dist/prod dist/observe dist/*.js",
|
|
50
|
+
"build:js": "rollup -c && node ./scripts/mangle-props.mjs dist/prod dist/observe && node ./scripts/check-pure.mjs dist/prod && node ./scripts/check-pure.mjs dist/observe",
|
|
51
|
+
"types": "tsc -p tsconfig.build.json",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:watch": "vitest watch tests",
|
|
54
|
+
"test:gc": "node --expose-gc ./vitest.js",
|
|
55
|
+
"test:gc:watch": "node --expose-gc ./vitest.js --watch",
|
|
56
|
+
"coverage": "vitest run --coverage",
|
|
57
|
+
"bench": "vitest bench --run"
|
|
58
|
+
},
|
|
42
59
|
"devDependencies": {
|
|
60
|
+
"@codspeed/vitest-plugin": "^5.4.0",
|
|
43
61
|
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
|
|
44
62
|
"@rollup/plugin-replace": "^6.0.3",
|
|
45
63
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
@@ -52,17 +70,5 @@
|
|
|
52
70
|
"typescript": "^6.0.3",
|
|
53
71
|
"vite": "^7.0.0",
|
|
54
72
|
"vitest": "^4.1.6"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "npm-run-all -nl build:* && pnpm types",
|
|
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",
|
|
60
|
-
"types": "tsc -p tsconfig.build.json && node ../../scripts/sync-dual-types.mjs ./dist/types ./dist/types-cjs",
|
|
61
|
-
"test": "vitest run",
|
|
62
|
-
"test:watch": "vitest watch tests",
|
|
63
|
-
"test:gc": "node --expose-gc ./vitest.js",
|
|
64
|
-
"test:gc:watch": "node --expose-gc ./vitest.js --watch",
|
|
65
|
-
"coverage": "vitest run --coverage",
|
|
66
|
-
"bench": "vitest bench --run"
|
|
67
73
|
}
|
|
68
|
-
}
|
|
74
|
+
}
|