@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.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.
Files changed (198) hide show
  1. package/dist/dev-shared.js +6505 -0
  2. package/dist/dev.attribution.js +3484 -0
  3. package/dist/dev.js +10227 -9508
  4. package/dist/observe/affects-marks.js +86 -0
  5. package/dist/observe/affects.js +112 -0
  6. package/dist/observe/attribution.js +7 -0
  7. package/dist/observe/boundaries.js +696 -0
  8. package/dist/observe/core/action.js +182 -0
  9. package/dist/observe/core/async.js +824 -0
  10. package/dist/observe/core/attribution-costs.js +66 -0
  11. package/dist/observe/core/attribution-feedback.js +280 -0
  12. package/dist/observe/core/attribution-hooks.js +83 -0
  13. package/dist/observe/core/attribution-queries.js +43 -0
  14. package/dist/observe/core/attribution.js +3079 -0
  15. package/dist/observe/core/constants.js +269 -0
  16. package/dist/observe/core/context.js +63 -0
  17. package/dist/observe/core/copies.js +10 -0
  18. package/dist/observe/core/core.js +1707 -0
  19. package/dist/observe/core/dev.js +394 -0
  20. package/dist/observe/core/effect.js +193 -0
  21. package/dist/observe/core/error-hooks.js +71 -0
  22. package/dist/observe/core/error.js +82 -0
  23. package/dist/observe/core/external.js +97 -0
  24. package/dist/observe/core/graph.js +162 -0
  25. package/dist/observe/core/heap.js +124 -0
  26. package/dist/observe/core/identities.js +62 -0
  27. package/dist/observe/core/invariants.js +12 -0
  28. package/dist/observe/core/lanes.js +972 -0
  29. package/dist/observe/core/owner.js +371 -0
  30. package/dist/observe/core/scheduler.js +1157 -0
  31. package/dist/observe/core/truth.js +47 -0
  32. package/dist/observe/core/verdict.js +470 -0
  33. package/dist/observe/deferred.js +186 -0
  34. package/dist/observe/flatten.js +79 -0
  35. package/dist/observe/from.js +248 -0
  36. package/dist/observe/index.js +71 -0
  37. package/dist/observe/map.js +593 -0
  38. package/dist/observe/reveal.js +212 -0
  39. package/dist/observe/signals.js +717 -0
  40. package/dist/observe/store/affects.js +142 -0
  41. package/dist/observe/store/edges.js +39 -0
  42. package/dist/observe/store/hooks.js +16 -0
  43. package/dist/observe/store/index.js +47 -0
  44. package/dist/observe/store/optimistic.js +713 -0
  45. package/dist/observe/store/projection.js +345 -0
  46. package/dist/observe/store/reconcile.js +281 -0
  47. package/dist/observe/store/store.js +2127 -0
  48. package/dist/observe/store/storePath.js +103 -0
  49. package/dist/observe/store/target.js +46 -0
  50. package/dist/observe/store/types.js +83 -0
  51. package/dist/observe/store/utils.js +1063 -0
  52. package/dist/prod/affects-marks.js +86 -0
  53. package/dist/prod/affects.js +98 -112
  54. package/dist/prod/attribution.js +45 -0
  55. package/dist/prod/boundaries.js +578 -468
  56. package/dist/prod/core/action.js +92 -59
  57. package/dist/prod/core/async.js +522 -336
  58. package/dist/prod/core/attribution-hooks.js +3 -0
  59. package/dist/prod/core/constants.js +168 -44
  60. package/dist/prod/core/context.js +12 -16
  61. package/dist/prod/core/copies.js +10 -0
  62. package/dist/prod/core/core.js +1345 -627
  63. package/dist/prod/core/dev.js +123 -1
  64. package/dist/prod/core/effect.js +113 -80
  65. package/dist/prod/core/error-hooks.js +71 -0
  66. package/dist/prod/core/error.js +18 -4
  67. package/dist/prod/core/external.js +6 -7
  68. package/dist/prod/core/graph.js +119 -72
  69. package/dist/prod/core/heap.js +85 -109
  70. package/dist/prod/core/identities.js +62 -0
  71. package/dist/prod/core/invariants.js +1 -32
  72. package/dist/prod/core/lanes.js +931 -132
  73. package/dist/prod/core/owner.js +192 -129
  74. package/dist/prod/core/scheduler.js +948 -642
  75. package/dist/prod/core/truth.js +47 -0
  76. package/dist/prod/core/verdict.js +409 -420
  77. package/dist/prod/deferred.js +184 -0
  78. package/dist/prod/flatten.js +77 -0
  79. package/dist/prod/from.js +248 -0
  80. package/dist/prod/index.js +40 -16
  81. package/dist/prod/map.js +481 -211
  82. package/dist/prod/reveal.js +212 -0
  83. package/dist/prod/signals.js +401 -84
  84. package/dist/prod/store/affects.js +142 -0
  85. package/dist/prod/store/edges.js +39 -0
  86. package/dist/prod/store/hooks.js +16 -0
  87. package/dist/prod/store/index.js +27 -18
  88. package/dist/prod/store/optimistic.js +707 -0
  89. package/dist/prod/store/projection.js +331 -0
  90. package/dist/prod/store/reconcile.js +281 -0
  91. package/dist/prod/store/store.js +1952 -267
  92. package/dist/prod/store/storePath.js +1 -1
  93. package/dist/prod/store/target.js +43 -0
  94. package/dist/prod/store/types.js +83 -0
  95. package/dist/prod/store/utils.js +997 -138
  96. package/dist/types/affects-marks.d.ts +14 -0
  97. package/dist/types/affects.d.ts +12 -30
  98. package/dist/types/attribution.d.ts +19 -0
  99. package/dist/types/attribution.prod.d.ts +22 -0
  100. package/dist/types/boundaries.d.ts +99 -124
  101. package/dist/types/carved.d.ts +1 -0
  102. package/dist/types/core/action.d.ts +23 -9
  103. package/dist/types/core/async.d.ts +34 -6
  104. package/dist/types/core/attribution-costs.d.ts +35 -0
  105. package/dist/types/core/attribution-feedback.d.ts +133 -0
  106. package/dist/types/core/attribution-hooks.d.ts +307 -8
  107. package/dist/types/core/attribution-queries.d.ts +24 -0
  108. package/dist/types/core/attribution.d.ts +802 -72
  109. package/dist/types/core/constants.d.ts +195 -38
  110. package/dist/types/core/copies.d.ts +54 -0
  111. package/dist/types/core/core.d.ts +295 -65
  112. package/dist/types/core/dev.d.ts +509 -22
  113. package/dist/types/core/effect.d.ts +1 -1
  114. package/dist/types/core/error-hooks.d.ts +71 -0
  115. package/dist/types/core/error.d.ts +18 -1
  116. package/dist/types/core/graph.d.ts +40 -1
  117. package/dist/types/core/heap.d.ts +5 -5
  118. package/dist/types/core/identities.d.ts +17 -0
  119. package/dist/types/core/index.d.ts +11 -7
  120. package/dist/types/core/invariants.d.ts +1 -26
  121. package/dist/types/core/lanes.d.ts +74 -43
  122. package/dist/types/core/owner.d.ts +27 -9
  123. package/dist/types/core/scheduler.d.ts +353 -102
  124. package/dist/types/core/truth.d.ts +18 -0
  125. package/dist/types/core/types.d.ts +97 -71
  126. package/dist/types/core/verdict.d.ts +35 -0
  127. package/dist/types/deferred.d.ts +28 -0
  128. package/dist/types/flatten.d.ts +8 -0
  129. package/dist/types/from.d.ts +47 -0
  130. package/dist/types/index.d.ts +33 -7
  131. package/dist/types/map.d.ts +4 -2
  132. package/dist/types/reveal.d.ts +19 -0
  133. package/dist/types/signals.d.ts +196 -45
  134. package/dist/types/store/affects.d.ts +12 -0
  135. package/dist/types/store/edges.d.ts +9 -0
  136. package/dist/types/store/hooks.d.ts +62 -0
  137. package/dist/types/store/index.d.ts +42 -15
  138. package/dist/types/store/optimistic.d.ts +24 -45
  139. package/dist/types/store/projection.d.ts +17 -68
  140. package/dist/types/store/reconcile.d.ts +3 -46
  141. package/dist/types/store/store.d.ts +133 -136
  142. package/dist/types/store/storePath.d.ts +1 -1
  143. package/dist/types/store/target.d.ts +166 -0
  144. package/dist/types/store/types.d.ts +105 -0
  145. package/dist/types/store/utils.d.ts +188 -0
  146. package/package.json +31 -26
  147. package/dist/node.cjs +0 -8745
  148. package/dist/prod/core/optimistic.js +0 -265
  149. package/dist/prod/store/next/optimistic.js +0 -385
  150. package/dist/prod/store/next/projection.js +0 -172
  151. package/dist/prod/store/next/reconcile.js +0 -331
  152. package/dist/prod/store/next/store.js +0 -1499
  153. package/dist/prod/store/next/target.js +0 -20
  154. package/dist/types/core/optimistic.d.ts +0 -6
  155. package/dist/types/store/next/optimistic.d.ts +0 -20
  156. package/dist/types/store/next/projection.d.ts +0 -8
  157. package/dist/types/store/next/reconcile.d.ts +0 -3
  158. package/dist/types/store/next/store.d.ts +0 -77
  159. package/dist/types/store/next/target.d.ts +0 -117
  160. package/dist/types-cjs/affects.d.cts +0 -47
  161. package/dist/types-cjs/boundaries.d.cts +0 -175
  162. package/dist/types-cjs/core/action.d.cts +0 -64
  163. package/dist/types-cjs/core/async.d.cts +0 -21
  164. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -52
  165. package/dist/types-cjs/core/attribution.d.cts +0 -186
  166. package/dist/types-cjs/core/constants.d.cts +0 -97
  167. package/dist/types-cjs/core/context.d.cts +0 -36
  168. package/dist/types-cjs/core/core.d.cts +0 -163
  169. package/dist/types-cjs/core/dev.d.cts +0 -81
  170. package/dist/types-cjs/core/effect.d.cts +0 -30
  171. package/dist/types-cjs/core/error.d.cts +0 -47
  172. package/dist/types-cjs/core/external.d.cts +0 -15
  173. package/dist/types-cjs/core/graph.d.cts +0 -6
  174. package/dist/types-cjs/core/heap.d.cts +0 -22
  175. package/dist/types-cjs/core/index.d.cts +0 -13
  176. package/dist/types-cjs/core/invariants.d.cts +0 -59
  177. package/dist/types-cjs/core/lanes.d.cts +0 -44
  178. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  179. package/dist/types-cjs/core/owner.d.cts +0 -124
  180. package/dist/types-cjs/core/scheduler.d.cts +0 -180
  181. package/dist/types-cjs/core/types.d.cts +0 -192
  182. package/dist/types-cjs/core/verdict.d.cts +0 -2
  183. package/dist/types-cjs/index.d.cts +0 -10
  184. package/dist/types-cjs/map.d.cts +0 -69
  185. package/dist/types-cjs/package.json +0 -3
  186. package/dist/types-cjs/signals.d.cts +0 -624
  187. package/dist/types-cjs/store/index.d.cts +0 -19
  188. package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
  189. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  190. package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
  191. package/dist/types-cjs/store/next/store.d.cts +0 -77
  192. package/dist/types-cjs/store/next/target.d.cts +0 -117
  193. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  194. package/dist/types-cjs/store/projection.d.cts +0 -70
  195. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  196. package/dist/types-cjs/store/store.d.cts +0 -138
  197. package/dist/types-cjs/store/storePath.d.cts +0 -58
  198. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Store — public types, brand symbols, wrappability and raw marking. Shared
3
+ * by every store module; carries no reactive machinery of its own.
4
+ */
5
+ import type { Refreshable } from "../core/index.js";
6
+ /** A reactive view of a store's value. Update it through the paired `StoreSetter`. */
7
+ export type Store<T> = T;
8
+ /**
9
+ * A store setter. The callback receives a writable **draft** of the store.
10
+ *
11
+ * - **Mutate in place (canonical):** `s.foo = 1`, `s.list.push(x)`,
12
+ * `s.list.splice(i, 1)`. This is the default form for most updates.
13
+ * - **Return a new value:** for shapes where mutation is awkward, most
14
+ * commonly removing items (`s => s.list.filter(...)`). Arrays are replaced
15
+ * by index (length adjusted); objects are shallow-diffed at the top level
16
+ * (keys present in the returned value are written, missing keys deleted).
17
+ *
18
+ * The setter does **not** perform keyed reconciliation. If you need surviving
19
+ * items to keep their store identity across full-array replacement, use the
20
+ * projection form — `createStore(fn, seed, { key })` or
21
+ * `createProjection(fn, seed, { key })` — whose derive function reconciles
22
+ * its return by `options.key`.
23
+ */
24
+ export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
25
+ /** Tuple returned by the plain `createStore(initialValue, options?)` form. */
26
+ export type StoreReturn<T> = [get: Store<T>, set: StoreSetter<T>];
27
+ /** Tuple returned by the derived `createStore(fn, seed, options?)` form. */
28
+ export type ProjectionStoreReturn<T> = [get: Refreshable<Store<T>>, set: StoreSetter<T>];
29
+ /** Options shared by all store primitives. */
30
+ export interface StoreOptions {
31
+ /**
32
+ * Debug name (dev and observe builds). Property nodes are labelled
33
+ * `<name>.<key>` in attribution output (`todos.title`); a derived store's
34
+ * projection node carries the name itself.
35
+ */
36
+ name?: string;
37
+ /**
38
+ * Source location (`file:line:col`, root-relative) written by the
39
+ * compiler's `sourceNames` `locations` kind; dev and observe builds keep it
40
+ * for console reports and diagnostic events, production ignores it. Not
41
+ * meant to be written by hand.
42
+ */
43
+ loc?: string;
44
+ /** Single-layer store: root keys reactive, values raw records replaced by reference */
45
+ shallow?: boolean;
46
+ }
47
+ /**
48
+ * Options for derived/projected stores created with
49
+ * `createStore(fn, seed, options?)`, `createProjection(fn, seed, options?)`,
50
+ * or `createOptimisticStore(fn, seed, options?)`.
51
+ */
52
+ export interface ProjectionOptions extends StoreOptions {
53
+ /** Key property name or function for reconciliation identity; `null` merges positionally */
54
+ key?: string | ((item: NonNullable<any>) => any) | null;
55
+ /**
56
+ * Treat the seed as commit #0: the store is born committed with the seed's
57
+ * contents, shown until the derive's first real answer lands. While that
58
+ * first answer is in flight, reads serve the seed everywhere — nothing
59
+ * suspends to a `<Loading>` boundary, no transition is held, and
60
+ * `isPending` stays false (the seed answers by declaration; first-load
61
+ * affordances belong to the data, e.g. a `skeleton: true` field in the
62
+ * seed). Once the first answer lands (reconciled into the seed), refetches
63
+ * use normal pending semantics with `isPending` true.
64
+ *
65
+ * The store equivalent of `MemoOptions.loadingValue`; the seed already
66
+ * carries the placeholder shape, so this is just the opt-in.
67
+ */
68
+ seedLoadingValue?: boolean;
69
+ }
70
+ /** @internal */
71
+ export type NoFn<T> = T extends Function ? never : T;
72
+ /**
73
+ * Rejects array roots on the seedless derived form: a store's root shape is
74
+ * fixed when it is created, and `[]` is already a complete seed for an array.
75
+ * @internal
76
+ */
77
+ export type NoArray<T> = Extract<T, readonly unknown[]> extends never ? unknown : never;
78
+ /** Brand keys the proxy answers directly (never user data). */
79
+ export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $RECORD: unique symbol;
80
+ export declare namespace SolidStore {
81
+ interface Unwrappable {
82
+ }
83
+ }
84
+ export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
85
+ export declare let rawValuesUsed: boolean;
86
+ export declare function isRawValue(value: any): boolean;
87
+ /** Mark a value so no store ever wraps it (sticky; it reads as a leaf). */
88
+ export declare function markRaw<T>(value: T): T;
89
+ /** A shallow store's ingested record: raw by contract (values served
90
+ * verbatim, slots replaced by reference). */
91
+ export declare function markRawOne(v: any): void;
92
+ export declare function markRawIngest(container: any): void;
93
+ /** Plain objects and arrays wrap; class instances, DOM nodes, frozen objects
94
+ * and markRaw'd values are leaves. Per-prototype verdict cached. */
95
+ export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
96
+ export declare function ownEnumerableKeys(o: object): (string | symbol)[];
97
+ export declare let writeOverride: boolean;
98
+ export declare function setWriteOverride(value: boolean): void;
99
+ /** The list driver's view of a shallow store (map.ts): the backing a read of
100
+ * every slot serves this reader, or `undefined` when the list is no shallow
101
+ * store or a slot read could differ from it. Installed by store.ts's top
102
+ * level, so a `<For>` in an app without stores carries none of it; it lives
103
+ * beside `$TRACK` so map.ts reaches no other store module. */
104
+ export declare let shallowView: ((t: any) => any[] | undefined) | null;
105
+ export declare function installShallowView(view: (t: any) => any[] | undefined): void;
@@ -21,6 +21,173 @@ type _Merge<T extends unknown[], Curr = {}> = T extends [
21
21
  ...infer Rest
22
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;
23
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;
24
191
  /**
25
192
  * Merges multiple props-like objects into a single proxy that *preserves
26
193
  * reactivity*. Reads are forwarded to the right-most source that defines the
@@ -29,9 +196,23 @@ export type Merge<T extends unknown[]> = Simplify<_Merge<T>>;
29
196
  * Function arguments are treated as memo-backed sources — useful for passing
30
197
  * derived defaults whose computation should track reactively.
31
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
+ *
32
205
  * Use this in component bodies to merge defaults / overrides without losing
33
206
  * Solid's per-property tracking.
34
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
+ *
35
216
  * @example
36
217
  * ```tsx
37
218
  * function Button(_props: { label: string; type?: string; disabled?: boolean }) {
@@ -52,6 +233,12 @@ export type Omit<T, K extends readonly (keyof T)[]> = {
52
233
  * Use it to forward "rest" props to a child element while pulling out the
53
234
  * keys your component handles itself — the equivalent of `splitProps(p, ["a","b"])[1]`.
54
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
+ *
55
242
  * @example
56
243
  * ```tsx
57
244
  * function Input(props: { label: string; value: string; onInput: (v: string) => void } & JSX.HTMLAttributes<HTMLInputElement>) {
@@ -71,4 +258,5 @@ export type Omit<T, K extends readonly (keyof T)[]> = {
71
258
  * ```
72
259
  */
73
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>;
74
262
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.20",
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/solid-signals"
11
+ "directory": "packages/signals"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "main": "./dist/node.cjs",
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,19 +29,33 @@
26
29
  ],
27
30
  "exports": {
28
31
  ".": {
29
- "import": {
30
- "types": "./dist/types/index.d.ts",
31
- "test": "./dist/dev.js",
32
- "development": "./dist/dev.js",
33
- "default": "./dist/prod/index.js"
34
- },
35
- "require": {
36
- "types": "./dist/types-cjs/index.d.cts",
37
- "default": "./dist/node.cjs"
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": {
43
60
  "@codspeed/vitest-plugin": "^5.4.0",
44
61
  "@ianvs/prettier-plugin-sort-imports": "^4.1.1",
@@ -53,17 +70,5 @@
53
70
  "typescript": "^6.0.3",
54
71
  "vite": "^7.0.0",
55
72
  "vitest": "^4.1.6"
56
- },
57
- "scripts": {
58
- "build": "npm-run-all -nl build:* && pnpm types",
59
- "build:clean": "rimraf dist/dev dist/prod dist/node dist/dev.js dist/prod.js dist/node.cjs",
60
- "build:js": "rollup -c && node ./scripts/mangle-props.mjs dist/prod dist/node.cjs && node ./scripts/check-pure.mjs dist/prod",
61
- "types": "tsc -p tsconfig.build.json && node ../../scripts/sync-dual-types.mjs ./dist/types ./dist/types-cjs",
62
- "test": "vitest run",
63
- "test:watch": "vitest watch tests",
64
- "test:gc": "node --expose-gc ./vitest.js",
65
- "test:gc:watch": "node --expose-gc ./vitest.js --watch",
66
- "coverage": "vitest run --coverage",
67
- "bench": "vitest bench --run"
68
73
  }
69
- }
74
+ }