@solidjs/signals 2.0.0-beta.10 → 2.0.0-beta.12

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 (82) hide show
  1. package/dist/dev.js +777 -397
  2. package/dist/node.cjs +1862 -1540
  3. package/dist/prod.js +1555 -1222
  4. package/dist/types/boundaries.d.ts +2 -2
  5. package/dist/types/core/constants.d.ts +8 -6
  6. package/dist/types/core/core.d.ts +29 -8
  7. package/dist/types/core/dev.d.ts +1 -1
  8. package/dist/types/core/effect.d.ts +1 -0
  9. package/dist/types/core/graph.d.ts +1 -0
  10. package/dist/types/core/index.d.ts +1 -1
  11. package/dist/types/core/scheduler.d.ts +19 -3
  12. package/dist/types/core/types.d.ts +2 -0
  13. package/dist/types/index.d.ts +1 -1
  14. package/dist/types/map.d.ts +21 -5
  15. package/dist/types/signals.d.ts +25 -4
  16. package/dist/types/src/boundaries.d.ts +173 -0
  17. package/dist/types/src/core/action.d.ts +35 -0
  18. package/dist/types/src/core/async.d.ts +6 -0
  19. package/dist/types/src/core/constants.d.ts +51 -0
  20. package/dist/types/src/core/context.d.ts +36 -0
  21. package/dist/types/src/core/core.d.ts +174 -0
  22. package/dist/types/src/core/dev.d.ts +49 -0
  23. package/dist/types/src/core/effect.d.ts +32 -0
  24. package/dist/types/src/core/error.d.ts +38 -0
  25. package/dist/types/src/core/external.d.ts +45 -0
  26. package/dist/types/src/core/graph.d.ts +5 -0
  27. package/dist/types/src/core/heap.d.ts +14 -0
  28. package/dist/types/src/core/index.d.ts +12 -0
  29. package/dist/types/src/core/lanes.d.ts +54 -0
  30. package/dist/types/src/core/owner.d.ts +116 -0
  31. package/dist/types/src/core/scheduler.d.ts +122 -0
  32. package/dist/types/src/core/types.d.ts +85 -0
  33. package/dist/types/src/index.d.ts +9 -0
  34. package/dist/types/src/map.d.ts +53 -0
  35. package/dist/types/src/signals.d.ts +512 -0
  36. package/dist/types/src/store/index.d.ts +9 -0
  37. package/dist/types/src/store/optimistic.d.ts +45 -0
  38. package/dist/types/src/store/projection.d.ts +66 -0
  39. package/dist/types/src/store/reconcile.d.ts +23 -0
  40. package/dist/types/src/store/store.d.ts +125 -0
  41. package/dist/types/src/store/storePath.d.ts +58 -0
  42. package/dist/types/src/store/utils.d.ts +114 -0
  43. package/dist/types-cjs/boundaries.d.cts +2 -2
  44. package/dist/types-cjs/core/constants.d.cts +8 -6
  45. package/dist/types-cjs/core/core.d.cts +29 -8
  46. package/dist/types-cjs/core/dev.d.cts +1 -1
  47. package/dist/types-cjs/core/effect.d.cts +1 -0
  48. package/dist/types-cjs/core/graph.d.cts +1 -0
  49. package/dist/types-cjs/core/index.d.cts +1 -1
  50. package/dist/types-cjs/core/scheduler.d.cts +19 -3
  51. package/dist/types-cjs/core/types.d.cts +2 -0
  52. package/dist/types-cjs/index.d.cts +1 -1
  53. package/dist/types-cjs/map.d.cts +21 -5
  54. package/dist/types-cjs/signals.d.cts +25 -4
  55. package/dist/types-cjs/src/boundaries.d.cts +173 -0
  56. package/dist/types-cjs/src/core/action.d.cts +35 -0
  57. package/dist/types-cjs/src/core/async.d.cts +6 -0
  58. package/dist/types-cjs/src/core/constants.d.cts +51 -0
  59. package/dist/types-cjs/src/core/context.d.cts +36 -0
  60. package/dist/types-cjs/src/core/core.d.cts +174 -0
  61. package/dist/types-cjs/src/core/dev.d.cts +49 -0
  62. package/dist/types-cjs/src/core/effect.d.cts +32 -0
  63. package/dist/types-cjs/src/core/error.d.cts +38 -0
  64. package/dist/types-cjs/src/core/external.d.cts +45 -0
  65. package/dist/types-cjs/src/core/graph.d.cts +5 -0
  66. package/dist/types-cjs/src/core/heap.d.cts +14 -0
  67. package/dist/types-cjs/src/core/index.d.cts +12 -0
  68. package/dist/types-cjs/src/core/lanes.d.cts +54 -0
  69. package/dist/types-cjs/src/core/owner.d.cts +116 -0
  70. package/dist/types-cjs/src/core/scheduler.d.cts +122 -0
  71. package/dist/types-cjs/src/core/types.d.cts +85 -0
  72. package/dist/types-cjs/src/index.d.cts +9 -0
  73. package/dist/types-cjs/src/map.d.cts +53 -0
  74. package/dist/types-cjs/src/signals.d.cts +512 -0
  75. package/dist/types-cjs/src/store/index.d.cts +9 -0
  76. package/dist/types-cjs/src/store/optimistic.d.cts +45 -0
  77. package/dist/types-cjs/src/store/projection.d.cts +66 -0
  78. package/dist/types-cjs/src/store/reconcile.d.cts +23 -0
  79. package/dist/types-cjs/src/store/store.d.cts +125 -0
  80. package/dist/types-cjs/src/store/storePath.d.cts +58 -0
  81. package/dist/types-cjs/src/store/utils.d.cts +114 -0
  82. package/package.json +4 -4
@@ -0,0 +1,125 @@
1
+ import { STORE_SNAPSHOT_PROPS, type Computed, type Refreshable, type Signal } from "../core/index.js";
2
+ /** A read-only view of a store's value as seen by consumers. Mutate it via the paired `StoreSetter`. */
3
+ export type Store<T> = Readonly<T>;
4
+ /**
5
+ * A store setter. The callback receives a writable **draft** of the store.
6
+ *
7
+ * - **Mutate in place (canonical):** `s.foo = 1`, `s.list.push(x)`,
8
+ * `s.list.splice(i, 1)`. This is the default form for most updates.
9
+ * - **Return a new value:** for shapes where mutation is awkward, most
10
+ * commonly removing items (`s => s.list.filter(...)`). Arrays are replaced
11
+ * by index (length adjusted); objects are shallow-diffed at the top level
12
+ * (keys present in the returned value are written, missing keys deleted).
13
+ *
14
+ * The setter does **not** perform keyed reconciliation. If you need surviving
15
+ * items to keep their store identity across full-array replacement, use the
16
+ * projection form — `createStore(fn, seed, { key })` or `createProjection` —
17
+ * whose derive function reconciles its return by `options.key`.
18
+ */
19
+ export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
20
+ /** Base options for store primitives. */
21
+ export interface StoreOptions {
22
+ /** Debug name (dev mode only) */
23
+ name?: string;
24
+ }
25
+ /** Options for derived/projected stores created with `createStore(fn)`, `createProjection`, or `createOptimisticStore(fn)`. */
26
+ export interface ProjectionOptions extends StoreOptions {
27
+ /** Key property name or function for reconciliation identity */
28
+ key?: string | ((item: NonNullable<any>) => any);
29
+ }
30
+ export type NoFn<T> = T extends Function ? never : T;
31
+ type DataNode = Signal<any>;
32
+ type DataNodes = Record<PropertyKey, DataNode>;
33
+ /**
34
+ * Brand symbols used internally by the store proxy / projection plumbing.
35
+ * Cross-package wiring; not part of the user-facing API.
36
+ *
37
+ * @internal
38
+ */
39
+ export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
40
+ 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";
41
+ export type StoreNode = {
42
+ [$PROXY]: any;
43
+ [STORE_VALUE]: Record<PropertyKey, any>;
44
+ [STORE_OVERRIDE]?: Record<PropertyKey, any>;
45
+ [STORE_OPTIMISTIC_OVERRIDE]?: Record<PropertyKey, any>;
46
+ [STORE_NODE]?: DataNodes;
47
+ [STORE_HAS]?: DataNodes;
48
+ [STORE_CUSTOM_PROTO]?: boolean;
49
+ [STORE_WRAP]?: (value: any, target?: StoreNode) => any;
50
+ [STORE_LOOKUP]?: WeakMap<any, any>;
51
+ [STORE_FIREWALL]?: Computed<any>;
52
+ [STORE_OPTIMISTIC]?: boolean;
53
+ [STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
54
+ };
55
+ export declare namespace SolidStore {
56
+ interface Unwrappable {
57
+ }
58
+ }
59
+ export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
60
+ export declare function createStoreProxy<T extends object>(value: T, traps?: ProxyHandler<StoreNode>, extend?: (target: StoreNode) => void): any;
61
+ export declare const storeLookup: WeakMap<WeakKey, any>;
62
+ export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
63
+ export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
64
+ export declare function setWriteOverride(value: boolean): void;
65
+ export declare function trackSelf(target: StoreNode, symbol?: symbol): void;
66
+ export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
67
+ export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
68
+ export declare const storeTraps: ProxyHandler<StoreNode>;
69
+ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
70
+ /**
71
+ * Creates a deeply-reactive store backed by a Proxy. Reads track each property
72
+ * accessed; only the parts that change trigger updates.
73
+ *
74
+ * Store properties hold **plain values**, not accessors. The proxy already
75
+ * tracks reads per-property — wrapping a value in `() => state.foo` produces
76
+ * a getter that *won't* track when called, which looks like a reactivity bug
77
+ * but is just a category error. If you have a signal-shaped piece of state,
78
+ * make it a property of the store (`{ foo: 1 }`) rather than nesting an
79
+ * accessor inside (`{ foo: () => signal() }`).
80
+ *
81
+ * The setter takes a **draft-mutating** function — mutate the draft in place
82
+ * (canonical). The callback may also return a new value: arrays are replaced
83
+ * by index (length adjusted), objects are shallow-diffed at the top level
84
+ * (keys present in the returned value are written, missing keys deleted). Use
85
+ * the return form for shapes where mutation is awkward — most commonly
86
+ * removing items via `filter`. The setter does **not** do keyed reconciliation;
87
+ * for that, use the derived/projection form (or `createProjection`).
88
+ *
89
+ * - Plain form: `createStore(initialValue)` — wraps a value in a reactive
90
+ * proxy.
91
+ * - Derived form: `createStore(fn, seed, options?)` — a *projection store*
92
+ * whose contents are computed by `fn(draft)`. `fn` may be sync, async, or
93
+ * an `AsyncIterable`; the projection's result reconciles against the
94
+ * existing store by `options.key` (default `"id"`) for stable identity.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const [state, setState] = createStore({
99
+ * user: { name: "Ada", age: 36 },
100
+ * todos: [] as { id: string; text: string; done: boolean }[]
101
+ * });
102
+ *
103
+ * // Canonical: mutate the draft in place.
104
+ * setState(s => { s.user.age = 37; });
105
+ * setState(s => { s.todos.push({ id: "1", text: "x", done: false }); });
106
+ *
107
+ * // Return form: reach for it when mutation is awkward.
108
+ * setState(s => s.todos.filter(t => !t.done)); // remove items
109
+ * setState(s => ({ ...s, user: { name: "Grace", age: 85 } })); // shallow replace
110
+ * ```
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * // Derived store — auto-fetches & reconciles by `id`.
115
+ * const [users] = createStore(
116
+ * async () => fetch("/users").then(r => r.json()),
117
+ * [] as User[]
118
+ * );
119
+ * ```
120
+ *
121
+ * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
122
+ */
123
+ export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
124
+ 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): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
125
+ export {};
@@ -0,0 +1,58 @@
1
+ import { type NotWrappable } from "./store.js";
2
+ type W<T> = Exclude<T, NotWrappable>;
3
+ type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [never] ? never : [T] extends [readonly unknown[]] ? number : keyof T : keyof T;
4
+ export type CustomPartial<T> = T extends readonly unknown[] ? "0" extends keyof T ? {
5
+ [K in Extract<keyof T, `${number}`>]?: T[K];
6
+ } : {
7
+ [x: number]: T[number];
8
+ } : Partial<T>;
9
+ export type StorePathRange = {
10
+ from?: number;
11
+ to?: number;
12
+ by?: number;
13
+ };
14
+ export type ArrayFilterFn<T> = (item: T, index: number) => boolean;
15
+ export type PathSetter<T> = T | CustomPartial<T> | ((prev: T) => T | CustomPartial<T>) | typeof DELETE;
16
+ export type Part<T, K extends KeyOf<T> = KeyOf<T>> = K | ([K] extends [never] ? never : readonly K[]) | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
17
+ declare const DELETE: unique symbol;
18
+ export interface storePath {
19
+ DELETE: typeof DELETE;
20
+ <T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>, K7 extends KeyOf<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, k7: Part<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>, K7>, setter: PathSetter<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>[K7]>): (state: T) => void;
21
+ <T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, setter: PathSetter<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>): (state: T) => void;
22
+ <T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, setter: PathSetter<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>): (state: T) => void;
23
+ <T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, setter: PathSetter<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>): (state: T) => void;
24
+ <T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, setter: PathSetter<W<W<W<T>[K1]>[K2]>[K3]>): (state: T) => void;
25
+ <T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, setter: PathSetter<W<W<T>[K1]>[K2]>): (state: T) => void;
26
+ <T, K1 extends KeyOf<W<T>>>(k1: Part<W<T>, K1>, setter: PathSetter<W<T>[K1]>): (state: T) => void;
27
+ <T>(setter: PathSetter<T>): (state: T) => void;
28
+ }
29
+ /**
30
+ * Path-based setter helper for `createStore`. Call `storePath(...path, value)`
31
+ * to produce a draft-mutating function suitable for passing to `setStore`.
32
+ *
33
+ * The canonical setter form in Solid 2.0 is the draft-mutating callback
34
+ * (`setStore(s => { s.user.name = "Ada"; })`). `storePath` is a backwards-
35
+ * compatibility helper for users porting from Solid 1.x's
36
+ * `setStore("user", "name", "Ada")` style — it's optional and you can mix the
37
+ * two styles freely.
38
+ *
39
+ * Path parts can be:
40
+ * - a single key — `"user"`, `0`
41
+ * - an array of keys — `[0, 1, 2]`
42
+ * - a range over an array — `{ from?, to?, by? }`
43
+ * - a filter `(item, index) => boolean` for arrays
44
+ *
45
+ * The final argument is the new value or an updater `(prev) => next`. Use
46
+ * `storePath.DELETE` to remove a property.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const [state, setState] = createStore({ user: { name: "Ada" }, todos: [] });
51
+ *
52
+ * setState(storePath("user", "name", "Grace"));
53
+ * setState(storePath("todos", t => !t.done, "done", true)); // mark all undone as done
54
+ * setState(storePath("user", "nickname", storePath.DELETE));
55
+ * ```
56
+ */
57
+ export declare const storePath: storePath;
58
+ export {};
@@ -0,0 +1,114 @@
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
+ type DistributeOverride<T, F> = T extends undefined ? F : T;
42
+ type Override<T, U> = T extends any ? U extends any ? {
43
+ [K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
44
+ } & {
45
+ [K in keyof U]: K extends keyof T ? DistributeOverride<U[K], T[K]> : U[K];
46
+ } : T & U : T & U;
47
+ type OverrideSpread<T, U> = T extends any ? {
48
+ [K in keyof ({
49
+ [K in keyof T]: any;
50
+ } & {
51
+ [K in keyof U]?: any;
52
+ } & {
53
+ [K in U extends any ? keyof U : keyof U]?: any;
54
+ })]: K extends keyof T ? Exclude<U extends any ? U[K & keyof U] : never, undefined> | T[K] : U extends any ? U[K & keyof U] : never;
55
+ } : T & U;
56
+ type Simplify<T> = T extends any ? {
57
+ [K in keyof T]: T[K];
58
+ } : T;
59
+ type _Merge<T extends unknown[], Curr = {}> = T extends [
60
+ infer Next | (() => infer Next),
61
+ ...infer Rest
62
+ ] ? _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
+ export type Merge<T extends unknown[]> = Simplify<_Merge<T>>;
64
+ /**
65
+ * Merges multiple props-like objects into a single proxy that *preserves
66
+ * reactivity*. Reads are forwarded to the right-most source that defines the
67
+ * property, so later sources override earlier ones (like `Object.assign`).
68
+ *
69
+ * Function arguments are treated as memo-backed sources — useful for passing
70
+ * derived defaults whose computation should track reactively.
71
+ *
72
+ * Use this in component bodies to merge defaults / overrides without losing
73
+ * Solid's per-property tracking.
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * function Button(_props: { label: string; type?: string; disabled?: boolean }) {
78
+ * const props = merge({ type: "button", disabled: false }, _props);
79
+ *
80
+ * return <button type={props.type} disabled={props.disabled}>{props.label}</button>;
81
+ * }
82
+ * ```
83
+ */
84
+ export declare function merge<T extends unknown[]>(...sources: T): Merge<T>;
85
+ export type Omit<T, K extends readonly (keyof T)[]> = {
86
+ [P in keyof T as Exclude<P, K[number]>]: T[P];
87
+ };
88
+ /**
89
+ * Returns a reactive proxy of `props` with the listed keys hidden. Tracking
90
+ * on the remaining keys is preserved.
91
+ *
92
+ * Use it to forward "rest" props to a child element while pulling out the
93
+ * keys your component handles itself — the equivalent of `splitProps(p, ["a","b"])[1]`.
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * function Input(props: { label: string; value: string; onInput: (v: string) => void } & JSX.HTMLAttributes<HTMLInputElement>) {
98
+ * const rest = omit(props, "label", "value", "onInput");
99
+ *
100
+ * return (
101
+ * <label>
102
+ * {props.label}
103
+ * <input
104
+ * {...rest}
105
+ * value={props.value}
106
+ * onInput={e => props.onInput(e.currentTarget.value)}
107
+ * />
108
+ * </label>
109
+ * );
110
+ * }
111
+ * ```
112
+ */
113
+ export declare function omit<T extends Record<any, any>, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit<T, K>;
114
+ export {};
@@ -73,7 +73,7 @@ export declare class CollectionQueue extends Queue {
73
73
  */
74
74
  export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
75
75
  on?: () => any;
76
- }): import("./signals.cjs").Accessor<unknown>;
76
+ }): import("./signals.cjs").SourceAccessor<unknown>;
77
77
  /**
78
78
  * Lower-level primitive that backs the `<Errored>` flow control. Catches
79
79
  * thrown errors inside `fn` and invokes `fallback(error, reset)` instead.
@@ -97,7 +97,7 @@ export declare function createLoadingBoundary(fn: () => any, fallback: () => any
97
97
  * }
98
98
  * ```
99
99
  */
100
- export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").Accessor<unknown>;
100
+ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").SourceAccessor<unknown>;
101
101
  /**
102
102
  * Coordinate the reveal timing of sibling loading boundaries.
103
103
  *
@@ -9,12 +9,14 @@ export declare const REACTIVE_DISPOSED: number;
9
9
  export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
10
10
  export declare const REACTIVE_SNAPSHOT_STALE: number;
11
11
  export declare const REACTIVE_LAZY: number;
12
+ export declare const REACTIVE_MANUAL_WRITE: number;
12
13
  export declare const CONFIG_OWNED_WRITE: number;
13
14
  export declare const CONFIG_NO_SNAPSHOT: number;
14
15
  export declare const CONFIG_TRANSPARENT: number;
15
16
  export declare const CONFIG_IN_SNAPSHOT_SCOPE: number;
16
17
  export declare const CONFIG_CHILDREN_FORBIDDEN: number;
17
18
  export declare const CONFIG_AUTO_DISPOSE: number;
19
+ export declare const CONFIG_SYNC: number;
18
20
  export declare const STATUS_NONE = 0;
19
21
  export declare const STATUS_PENDING: number;
20
22
  export declare const STATUS_ERROR: number;
@@ -37,12 +39,12 @@ export declare const defaultContext: {};
37
39
  */
38
40
  export declare const $REFRESH: unique symbol;
39
41
  /**
40
- * Brand applied to derived/projected stores indicating they participate in
41
- * the `refresh()` re-run protocol. Use this alias instead of inlining
42
- * `T & { [$REFRESH]: any }` so that user-defined hooks that wrap
43
- * `createOptimisticStore` / `createProjection` / projection-form
44
- * `createStore` can have their return types inferred without leaking the
45
- * internal `$REFRESH` symbol into public type signatures (TS4058).
42
+ * Brand applied to values that participate in the `refresh()` re-run protocol.
43
+ * Accessors receive this handle internally; projected stores expose it through
44
+ * their public return type so user-defined hooks that wrap `createOptimisticStore`
45
+ * / `createProjection` / projection-form `createStore` can have their return
46
+ * types inferred without leaking the internal `$REFRESH` symbol into public type
47
+ * signatures (TS4058).
46
48
  */
47
49
  export type Refreshable<T> = T & {
48
50
  readonly [$REFRESH]: any;
@@ -19,6 +19,13 @@ export declare function clearSnapshots(): void;
19
19
  export declare function recompute(el: Computed<any>, create?: boolean): void;
20
20
  export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
21
21
  export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
22
+ /**
23
+ * Build an Effect node with all effect-specific fields baked into a single object literal,
24
+ * so V8 sees the full hidden class shape at construction time. Effects always run in lazy
25
+ * mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
26
+ * the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
27
+ */
28
+ export declare function createEffectNode<T>(fn: (prev?: T) => T, effectFn: (val: T, prev: T | undefined) => void | (() => void), errorFn: ((err: unknown, cleanup: () => void) => void | (() => void)) | undefined, type: number, notifyStatus: ((status?: number, error?: any) => void) | undefined, options: NodeOptions<T> | undefined): any;
22
29
  export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
23
30
  export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
24
31
  export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
@@ -55,6 +62,21 @@ export declare function setStrictRead(v: string | false): string | false;
55
62
  export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
56
63
  export declare function read<T>(el: Signal<T> | Computed<T>): T;
57
64
  export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
65
+ /**
66
+ * Suppresses automatic recomputation of `el` until the scheduler drains. Used
67
+ * when a manual write should win over dependency changes queued in the same
68
+ * tick. The MANUAL_WRITE flag is cleared by the pending-node drain; projection
69
+ * computeds don't commit values, but they still need the same end-of-tick
70
+ * cleanup point.
71
+ */
72
+ export declare function suppressComputedRecompute(el: Computed<unknown>): void;
73
+ /**
74
+ * User-facing setter for the memo form of `createSignal(fn)`. Behaves like
75
+ * `setSignal`, but also cancels any pending recompute of the memo so the
76
+ * manual value wins over a value that would otherwise be produced by an
77
+ * upstream change in the same tick.
78
+ */
79
+ export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
58
80
  /**
59
81
  * Executes `fn` with the given `owner` set as the current owner. Any reactive
60
82
  * primitives (`createSignal`, `createMemo`, `createEffect`, `onCleanup`,
@@ -117,14 +139,13 @@ export declare function latest<T>(fn: () => T): T;
117
139
  */
118
140
  export declare function isPending(fn: () => any): boolean;
119
141
  /**
120
- * Forces a reactive source to re-execute, even if its inputs haven't changed.
142
+ * Invalidates one reactive source, forcing it to re-execute even if its inputs
143
+ * haven't changed.
121
144
  *
122
- * Two forms:
123
- * - `refresh(memo)` pass an accessor (memo / signal getter) and its
124
- * underlying computation reruns.
125
- * - `refresh(store)` pass a *projected* store created from
126
- * `createStore(fn, ...)` or `createProjection(...)` and the projection
127
- * recomputes.
145
+ * Pass either a Solid-created accessor or a projected store created from
146
+ * `createStore(fn, ...)` / `createProjection(...)`. `refresh()` is a
147
+ * write-like invalidation operation: it does not read the target's value, and
148
+ * refreshing a plain signal accessor is a no-op.
128
149
  *
129
150
  * Use it to invalidate cached async values (e.g. force a re-fetch) without
130
151
  * tearing the consumer down.
@@ -137,7 +158,7 @@ export declare function isPending(fn: () => any): boolean;
137
158
  * <button onClick={() => refresh(user)}>Reload</button>
138
159
  * ```
139
160
  */
140
- export declare function refresh<T>(fn: (() => T) | Refreshable<T>): T;
161
+ export declare function refresh<T>(target: Refreshable<T>): void;
141
162
  /**
142
163
  * Returns `true` while a `refresh()` call is in progress. Useful for showing
143
164
  * a "refreshing" indicator distinct from the initial-load `<Loading>`
@@ -6,7 +6,7 @@ export interface DevHooks {
6
6
  onStoreNodeUpdate?: (state: any, property: PropertyKey, value: any, prev: any) => void;
7
7
  }
8
8
  export type DiagnosticSeverity = "warn" | "error";
9
- export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "SIGNAL_WRITE_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "MISSING_EFFECT_FN";
9
+ export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "SIGNAL_WRITE_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "INVALID_REFRESH_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC";
10
10
  export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner";
11
11
  export interface DiagnosticEvent {
12
12
  sequence: number;
@@ -3,6 +3,7 @@ export interface Effect<T> extends Computed<T>, Owner {
3
3
  _effectFn: (val: T, prev: T | undefined) => void | (() => void);
4
4
  _errorFn?: (err: unknown, cleanup: () => void) => void;
5
5
  _cleanup?: () => void;
6
+ _cleanupRegistered?: boolean;
6
7
  _modified: boolean;
7
8
  _prevValue: T | undefined;
8
9
  _type: number;
@@ -1,4 +1,5 @@
1
1
  import type { Computed, Link, Signal } from "./types.cjs";
2
2
  export declare function unlinkSubs(link: Link): Link | null;
3
+ export declare function trimStaleDeps(el: Computed<any>): void;
3
4
  export declare function unobserved(el: Computed<unknown>): void;
4
5
  export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
@@ -1,5 +1,5 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.cjs";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, optimisticSignal, optimisticComputed, isPending, latest, refresh, isRefreshing, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
2
+ export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, isPending, latest, refresh, isRefreshing, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
3
3
  export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.cjs";
4
4
  export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.cjs";
5
5
  export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.cjs";
@@ -67,28 +67,33 @@ export declare class Queue implements IQueue {
67
67
  }
68
68
  export declare class GlobalQueue extends Queue {
69
69
  _running: boolean;
70
+ _pendingNode: Signal<any> | null;
70
71
  _pendingNodes: Signal<any>[];
71
72
  _optimisticNodes: OptimisticNode[];
72
73
  _optimisticStores: Set<any>;
73
74
  static _update: (el: Computed<unknown>) => void;
74
75
  static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
76
+ static _runEffect: (el: Computed<unknown>) => void;
75
77
  static _clearOptimisticStore: ((store: any) => void) | null;
76
78
  flush(): void;
77
79
  notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
78
80
  initTransition(transition?: Transition | null): void;
79
81
  }
82
+ export declare function queuePendingNode(node: Signal<any>): void;
80
83
  export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
81
84
  export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
82
85
  export declare function trackOptimisticStore(store: any): void;
83
86
  export declare const globalQueue: GlobalQueue;
84
87
  /**
85
- * Synchronously processes the pending reactive queue: runs every scheduled
86
- * memo/effect/computation that has dirty inputs, until the graph is settled.
88
+ * Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
89
+ * flush scope before draining the queue.
87
90
  *
88
91
  * Reactive updates are normally batched onto the microtask queue, so multiple
89
92
  * writes in a row collapse into a single update pass. Call `flush()` when you
90
93
  * need to *observe* the result of those writes synchronously — most commonly
91
- * in tests, but also at the boundary of imperative integration code.
94
+ * in tests, but also at the boundary of imperative integration code. Pass a
95
+ * callback when the writes themselves should bypass microtask scheduling and
96
+ * drain synchronously when the callback returns.
92
97
  *
93
98
  * @example
94
99
  * ```ts
@@ -98,9 +103,20 @@ export declare const globalQueue: GlobalQueue;
98
103
  * setCount(5);
99
104
  * flush();
100
105
  * expect(doubled()).toBe(10);
106
+ *
107
+ * flush(() => setCount(6));
108
+ * expect(doubled()).toBe(12);
109
+ *
110
+ * // Nested flushes drain at each level:
111
+ * flush(() => {
112
+ * setCount(7);
113
+ * flush(() => setCount(8)); // inner drain — effects fire here
114
+ * // outer continues with up-to-date state
115
+ * });
101
116
  * ```
102
117
  */
103
118
  export declare function flush(): void;
119
+ export declare function flush<T>(fn: () => T): T;
104
120
  export declare function currentTransition(transition: Transition): Transition;
105
121
  export declare function setActiveTransition(transition: Transition | null): void;
106
122
  export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
@@ -21,6 +21,7 @@ export interface NodeOptions<T> {
21
21
  _noSnapshot?: boolean;
22
22
  unobserved?: () => void;
23
23
  lazy?: boolean;
24
+ sync?: boolean;
24
25
  }
25
26
  export interface RawSignal<T> {
26
27
  _subs: Link | null;
@@ -56,6 +57,7 @@ export interface Owner {
56
57
  _queue: IQueue;
57
58
  _firstChild: Owner | null;
58
59
  _nextSibling: Owner | null;
60
+ _prevSibling: Owner | null;
59
61
  _pendingDisposal: Disposable | Disposable[] | null;
60
62
  _pendingFirstChild: Owner | null;
61
63
  }
@@ -3,7 +3,7 @@ import { type Dev } from "./core/index.cjs";
3
3
  export declare const DEV: Dev | undefined;
4
4
  export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Refreshable, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.cjs";
5
5
  export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled, onCleanup } from "./signals.cjs";
6
- export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.cjs";
6
+ export type { Accessor, SourceAccessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.cjs";
7
7
  export { mapArray, repeat, type Maybe } from "./map.cjs";
8
8
  export * from "./store/index.cjs";
9
9
  export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.cjs";
@@ -2,8 +2,14 @@ import { type Accessor } from "./signals.cjs";
2
2
  export type Maybe<T> = T | void | null | undefined | false;
3
3
  /**
4
4
  * Reactively maps an array, reusing the previously-mapped value for unchanged
5
- * items. The callback receives `(value, index)` as accessors so individual
6
- * items and indexes can be subscribed to without re-running the mapper.
5
+ * items.
6
+ *
7
+ * The callback shape follows the keying mode:
8
+ * - default / `keyed: true` receives `(item, index)` where `item` is the raw
9
+ * row value and `index` is an accessor.
10
+ * - `keyed: false` receives `(item, index)` where `item` is an accessor and
11
+ * `index` is a stable number.
12
+ * - `keyed: item => key` receives accessors for both arguments.
7
13
  *
8
14
  * This is the underlying helper that powers `<For>`. App code should use
9
15
  * `<For>` directly; reach for `mapArray` when implementing custom list
@@ -19,15 +25,25 @@ export type Maybe<T> = T | void | null | undefined | false;
19
25
  * ```ts
20
26
  * const view = mapArray(
21
27
  * items,
22
- * (item, index) => `${index()}: ${item().label}`,
28
+ * (item, index) => `${index()}: ${item.label}`,
23
29
  * { fallback: () => "no items" }
24
30
  * );
25
31
  * ```
26
32
  *
27
33
  * @description https://docs.solidjs.com/reference/reactive-utilities/map-array
28
34
  */
29
- export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options?: {
30
- keyed?: boolean | ((item: Item) => any);
35
+ export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Item, index: Accessor<number>) => MappedItem, options?: {
36
+ keyed?: true;
37
+ fallback?: Accessor<any>;
38
+ name?: string;
39
+ }): Accessor<MappedItem[]>;
40
+ export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: number) => MappedItem, options: {
41
+ keyed: false;
42
+ fallback?: Accessor<any>;
43
+ name?: string;
44
+ }): Accessor<MappedItem[]>;
45
+ export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options: {
46
+ keyed: (item: Item) => any;
31
47
  fallback?: Accessor<any>;
32
48
  name?: string;
33
49
  }): Accessor<MappedItem[]>;