@solidjs/signals 2.0.0-beta.15 → 2.0.0-beta.17

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 (88) hide show
  1. package/dist/dev.js +782 -413
  2. package/dist/node.cjs +1927 -1625
  3. package/dist/prod.js +1525 -1227
  4. package/dist/types/boundaries.d.ts +3 -3
  5. package/dist/types/core/async.d.ts +1 -0
  6. package/dist/types/core/core.d.ts +25 -1
  7. package/dist/types/core/dev.d.ts +10 -2
  8. package/dist/types/core/effect.d.ts +1 -3
  9. package/dist/types/core/error.d.ts +2 -0
  10. package/dist/types/core/graph.d.ts +1 -1
  11. package/dist/types/core/index.d.ts +2 -2
  12. package/dist/types/core/invariants.d.ts +49 -0
  13. package/dist/types/core/scheduler.d.ts +8 -0
  14. package/dist/types/core/types.d.ts +19 -0
  15. package/dist/types/index.d.ts +1 -1
  16. package/dist/types/signals.d.ts +39 -2
  17. package/dist/types/store/projection.d.ts +2 -2
  18. package/dist/types/store/store.d.ts +28 -1
  19. package/dist/types-cjs/boundaries.d.cts +3 -3
  20. package/dist/types-cjs/core/async.d.cts +1 -0
  21. package/dist/types-cjs/core/core.d.cts +25 -1
  22. package/dist/types-cjs/core/dev.d.cts +10 -2
  23. package/dist/types-cjs/core/effect.d.cts +1 -3
  24. package/dist/types-cjs/core/error.d.cts +2 -0
  25. package/dist/types-cjs/core/graph.d.cts +1 -1
  26. package/dist/types-cjs/core/index.d.cts +2 -2
  27. package/dist/types-cjs/core/invariants.d.cts +49 -0
  28. package/dist/types-cjs/core/scheduler.d.cts +8 -0
  29. package/dist/types-cjs/core/types.d.cts +19 -0
  30. package/dist/types-cjs/index.d.cts +1 -1
  31. package/dist/types-cjs/signals.d.cts +39 -2
  32. package/dist/types-cjs/store/projection.d.cts +2 -2
  33. package/dist/types-cjs/store/store.d.cts +28 -1
  34. package/package.json +1 -1
  35. package/dist/types/src/boundaries.d.ts +0 -173
  36. package/dist/types/src/core/action.d.ts +0 -35
  37. package/dist/types/src/core/async.d.ts +0 -6
  38. package/dist/types/src/core/constants.d.ts +0 -51
  39. package/dist/types/src/core/context.d.ts +0 -36
  40. package/dist/types/src/core/core.d.ts +0 -174
  41. package/dist/types/src/core/dev.d.ts +0 -49
  42. package/dist/types/src/core/effect.d.ts +0 -32
  43. package/dist/types/src/core/error.d.ts +0 -38
  44. package/dist/types/src/core/external.d.ts +0 -45
  45. package/dist/types/src/core/graph.d.ts +0 -5
  46. package/dist/types/src/core/heap.d.ts +0 -14
  47. package/dist/types/src/core/index.d.ts +0 -12
  48. package/dist/types/src/core/lanes.d.ts +0 -54
  49. package/dist/types/src/core/owner.d.ts +0 -116
  50. package/dist/types/src/core/scheduler.d.ts +0 -122
  51. package/dist/types/src/core/types.d.ts +0 -85
  52. package/dist/types/src/index.d.ts +0 -9
  53. package/dist/types/src/map.d.ts +0 -53
  54. package/dist/types/src/signals.d.ts +0 -512
  55. package/dist/types/src/store/index.d.ts +0 -9
  56. package/dist/types/src/store/optimistic.d.ts +0 -45
  57. package/dist/types/src/store/projection.d.ts +0 -66
  58. package/dist/types/src/store/reconcile.d.ts +0 -23
  59. package/dist/types/src/store/store.d.ts +0 -125
  60. package/dist/types/src/store/storePath.d.ts +0 -58
  61. package/dist/types/src/store/utils.d.ts +0 -114
  62. package/dist/types-cjs/src/boundaries.d.cts +0 -173
  63. package/dist/types-cjs/src/core/action.d.cts +0 -35
  64. package/dist/types-cjs/src/core/async.d.cts +0 -6
  65. package/dist/types-cjs/src/core/constants.d.cts +0 -51
  66. package/dist/types-cjs/src/core/context.d.cts +0 -36
  67. package/dist/types-cjs/src/core/core.d.cts +0 -174
  68. package/dist/types-cjs/src/core/dev.d.cts +0 -49
  69. package/dist/types-cjs/src/core/effect.d.cts +0 -32
  70. package/dist/types-cjs/src/core/error.d.cts +0 -38
  71. package/dist/types-cjs/src/core/external.d.cts +0 -45
  72. package/dist/types-cjs/src/core/graph.d.cts +0 -5
  73. package/dist/types-cjs/src/core/heap.d.cts +0 -14
  74. package/dist/types-cjs/src/core/index.d.cts +0 -12
  75. package/dist/types-cjs/src/core/lanes.d.cts +0 -54
  76. package/dist/types-cjs/src/core/owner.d.cts +0 -116
  77. package/dist/types-cjs/src/core/scheduler.d.cts +0 -122
  78. package/dist/types-cjs/src/core/types.d.cts +0 -85
  79. package/dist/types-cjs/src/index.d.cts +0 -9
  80. package/dist/types-cjs/src/map.d.cts +0 -53
  81. package/dist/types-cjs/src/signals.d.cts +0 -512
  82. package/dist/types-cjs/src/store/index.d.cts +0 -9
  83. package/dist/types-cjs/src/store/optimistic.d.cts +0 -45
  84. package/dist/types-cjs/src/store/projection.d.cts +0 -66
  85. package/dist/types-cjs/src/store/reconcile.d.cts +0 -23
  86. package/dist/types-cjs/src/store/store.d.cts +0 -125
  87. package/dist/types-cjs/src/store/storePath.d.cts +0 -58
  88. package/dist/types-cjs/src/store/utils.d.cts +0 -114
@@ -1,45 +0,0 @@
1
- import { type Refreshable } from "../core/index.js";
2
- import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from "./store.js";
3
- /**
4
- * The store equivalent of `createOptimistic`. Writes inside an `action`
5
- * transition are tentative — they show up immediately but auto-revert (or
6
- * reconcile to the action's resolved value) once the transition finishes.
7
- *
8
- * Use this for optimistic UI on collection-shaped data. For single-value
9
- * optimistic state, prefer `createOptimistic`.
10
- *
11
- * - Plain form: `createOptimisticStore(initialValue)`.
12
- * - Derived form: `createOptimisticStore(fn, seed, options?)` — a projection
13
- * store whose authoritative value is recomputed by `fn` and whose
14
- * optimistic overlay reverts after each transition.
15
- *
16
- * `options.key` defaults to `"id"`; specify it only when your data uses a
17
- * different identity field (e.g. `{ key: "uuid" }` or `{ key: t => t.slug }`).
18
- * Restating the default just adds noise.
19
- *
20
- * @example
21
- * ```ts
22
- * const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
23
- *
24
- * // Mutation: optimistic add, then in-place reconcile to the saved row.
25
- * const addTodo = action(function* (text: string) {
26
- * const tempId = crypto.randomUUID();
27
- * setTodos(t => { t.push({ id: tempId, text, pending: true }); });
28
- * const saved = yield api.createTodo(text);
29
- * setTodos(t => {
30
- * const i = t.findIndex(x => x.id === tempId);
31
- * if (i >= 0) t[i] = saved;
32
- * });
33
- * });
34
- *
35
- * // Return form: filter is the natural shape for removal.
36
- * const removeTodo = action(function* (id: string) {
37
- * setTodos(t => t.filter(x => x.id !== id));
38
- * yield api.removeTodo(id);
39
- * });
40
- * ```
41
- *
42
- * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
43
- */
44
- export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
45
- export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
@@ -1,66 +0,0 @@
1
- import { type Computed, type Refreshable } from "../core/index.js";
2
- import { type ProjectionOptions, type Store } from "./store.js";
3
- export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): {
4
- store: Refreshable<Store<T>>;
5
- node: Computed<void | T>;
6
- };
7
- /**
8
- * Creates a derived (projected) store. Like `createMemo` but for stores: the
9
- * derive function receives a mutable draft and either mutates it in place
10
- * (canonical) or returns a new value. Either way the result is reconciled
11
- * against the previous draft by `options.key` (default `"id"`), so surviving
12
- * items keep their proxy identity — only added/removed items are
13
- * created/disposed.
14
- *
15
- * Returns the projected store directly (no setter — reads only).
16
- *
17
- * Use this when you want the structural-sharing / per-property tracking
18
- * behaviour of a store on top of a derived computation. For simple read-only
19
- * derivations, `createMemo` is lighter.
20
- *
21
- * @param fn receives the current draft; mutate it in place or return new
22
- * data. Return is convenient for filter/derive shapes where mutation is
23
- * awkward.
24
- * @param seed the backing store value to wrap and reconcile into
25
- * @param options `ProjectionOptions` — `name`, `key`. `key` defaults to
26
- * `"id"`; specify it only when your data uses a different identity field
27
- * (e.g. `{ key: "uuid" }` or `{ key: u => u.slug }`).
28
- *
29
- * @example
30
- * ```ts
31
- * // Mutation form — update individual fields on the draft.
32
- * const summary = createProjection<{ total: number; active: number }>(
33
- * draft => {
34
- * draft.total = users().length;
35
- * draft.active = users().filter(u => u.active).length;
36
- * },
37
- * { total: 0, active: 0 }
38
- * );
39
- *
40
- * // Return form — produce a derived collection. Reconciled by `id` so each
41
- * // surviving user keeps the same store identity across recomputes.
42
- * const activeUsers = createProjection<User[]>(
43
- * () => allUsers().filter(u => u.active),
44
- * []
45
- * );
46
- * ```
47
- *
48
- * @see {@link https://github.com/solidjs/x-reactivity#createprojection}
49
- */
50
- export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): Refreshable<Store<T>>;
51
- /**
52
- * Shared projection computed body used by both `createProjection` and the derived
53
- * form of `createOptimisticStore`. Encapsulates the write-trap draft, `storeSetter`
54
- * wrapping, the `handleAsync` subscription with a setter callback, and the commit
55
- * path (which must always go through `storeSetter` so the `writeOnly` guard is
56
- * engaged during `reconcile`'s property reads).
57
- *
58
- * `wrapCommit` is invoked for every commit (sync return and each async yield) and
59
- * lets callers layer extra context around the write — e.g. the optimistic store
60
- * re-enters `setProjectionWriteActive` so reconciles target `STORE_OVERRIDE`
61
- * instead of `STORE_OPTIMISTIC_OVERRIDE` even when an async yield fires outside
62
- * the outer `setProjectionWriteActive` scope.
63
- */
64
- export declare function runProjectionComputed<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any), wrapCommit?: (write: () => void) => void): Computed<void | T>;
65
- export declare function createWriteTraps(isActive?: () => boolean): ProxyHandler<any>;
66
- export declare const writeTraps: ProxyHandler<any>;
@@ -1,23 +0,0 @@
1
- /**
2
- * Returns a draft-mutating function that smart-merges `value` into a store,
3
- * preserving the identity of items whose `key` field matches between old and
4
- * new states. Useful when applying server payloads or full-replacement data
5
- * onto an existing store without losing fine-grained reactivity.
6
- *
7
- * Items with the same key are updated in place (only changed properties
8
- * trigger updates). Items added or removed update the corresponding signals.
9
- *
10
- * @param value the next state to merge in
11
- * @param key property name (string) or extractor function for stable identity
12
- *
13
- * @example
14
- * ```ts
15
- * const [todos, setTodos] = createStore<Todo[]>([]);
16
- *
17
- * async function refresh() {
18
- * const fresh = await api.getTodos();
19
- * setTodos(reconcile(fresh, "id")); // diff-merge by `id`
20
- * }
21
- * ```
22
- */
23
- export declare function reconcile<T extends U, U>(value: T, key: string | ((item: NonNullable<any>) => any)): (state: U) => void;
@@ -1,125 +0,0 @@
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 {};
@@ -1,58 +0,0 @@
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 {};
@@ -1,114 +0,0 @@
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 {};
@@ -1,173 +0,0 @@
1
- import { Queue, type Computed, type Effect } from "./core/index.cjs";
2
- import type { Signal } from "./core/index.cjs";
3
- export interface BoundaryComputed<T> extends Computed<T> {
4
- _propagationMask: number;
5
- }
6
- type RevealSlot = CollectionQueue | RevealController;
7
- type BoolAccessor = () => boolean;
8
- export type RevealOrder = "sequential" | "together" | "natural";
9
- type OrderAccessor = () => RevealOrder;
10
- export declare class RevealController {
11
- _orderAccessor: OrderAccessor;
12
- _collapsedAccessor: BoolAccessor;
13
- _slots: RevealSlot[];
14
- _parentController?: RevealController;
15
- _disabled: Signal<boolean>;
16
- _collapsed: Signal<boolean>;
17
- _ready: boolean;
18
- _minimallyReady: boolean;
19
- _evaluating: boolean;
20
- constructor(order: OrderAccessor, collapsed: BoolAccessor);
21
- _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
22
- isReady(): boolean;
23
- /**
24
- * "Minimally ready" = this group has something visible to show under its own policy.
25
- * Used by an enclosing `together` group to decide when it can release.
26
- * - `together`: fully ready (atomic).
27
- * - `sequential`: the first owned slot is minimally ready (frontier can advance).
28
- * - `natural`: any owned slot is minimally ready.
29
- */
30
- isMinimallyReady(): boolean;
31
- register(slot: RevealSlot): void;
32
- unregister(slot: RevealSlot): void;
33
- evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
34
- }
35
- export declare class CollectionQueue extends Queue {
36
- _collectionType: number;
37
- _sources: Set<Computed<any>>;
38
- _tree?: BoundaryComputed<any>;
39
- _pending: boolean;
40
- _disabled: Signal<boolean>;
41
- _collapsed: Signal<boolean>;
42
- _revealController?: RevealController;
43
- _initialized: boolean;
44
- _onFn: (() => any) | undefined;
45
- _prevOn: any;
46
- constructor(type: number);
47
- run(type: number): void;
48
- notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
49
- checkSources(): void;
50
- }
51
- /**
52
- * Lower-level primitive that backs the `<Loading>` flow control. Catches
53
- * pending async reads inside `fn` and renders `fallback` until they settle.
54
- *
55
- * App code should use `<Loading fallback={...}>` instead — reach for this only
56
- * when authoring custom boundary components.
57
- *
58
- * @param fn the tracked subtree
59
- * @param fallback the fallback shown while async reads in `fn` are unresolved
60
- * @param options `on` — accessor whose value scopes the boundary; when set,
61
- * transitions caused by writes to other reactive sources are *not* caught
62
- *
63
- * @example
64
- * ```tsx
65
- * // Custom boundary component built on top of the primitive.
66
- * function MyLoading(props: { fallback: JSX.Element; children: JSX.Element }) {
67
- * return createLoadingBoundary(
68
- * () => props.children,
69
- * () => props.fallback
70
- * ) as unknown as JSX.Element;
71
- * }
72
- * ```
73
- */
74
- export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
75
- on?: () => any;
76
- }): import("./signals.cjs").SourceAccessor<unknown>;
77
- /**
78
- * Lower-level primitive that backs the `<Errored>` flow control. Catches
79
- * thrown errors inside `fn` and invokes `fallback(error, reset)` instead.
80
- * `reset()` recomputes the failing sources so the boundary can attempt to
81
- * recover.
82
- *
83
- * App code should use `<Errored fallback={...}>` instead — reach for this only
84
- * when authoring custom boundary components.
85
- *
86
- * @example
87
- * ```tsx
88
- * // Custom boundary that wraps the primitive and adds telemetry.
89
- * function TracedErrored(props: { fallback: (e: unknown) => JSX.Element; children: JSX.Element }) {
90
- * return createErrorBoundary(
91
- * () => props.children,
92
- * (err, reset) => {
93
- * reportError(err);
94
- * return props.fallback(err);
95
- * }
96
- * ) as unknown as JSX.Element;
97
- * }
98
- * ```
99
- */
100
- export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").SourceAccessor<unknown>;
101
- /**
102
- * Coordinate the reveal timing of sibling loading boundaries.
103
- *
104
- * Accepts reactive accessors:
105
- * - `order`: `"sequential"` (default) | `"together"` | `"natural"`.
106
- * - `"sequential"` — classic frontier reveal: siblings reveal in registration order
107
- * as each resolves; later siblings stay hidden until earlier ones complete.
108
- * - `"together"` — every direct slot stays on its fallback until the whole group
109
- * is "minimally ready" (each direct slot has produced its own first visible
110
- * content under its own order), then the whole group releases at once.
111
- * - `"natural"` — children reveal independently (as each resolves). At the top
112
- * level this is a no-op compared to not using `createRevealOrder`; the mode
113
- * exists for nesting, where the group registers as a single composite slot to
114
- * any enclosing `createRevealOrder`.
115
- * - `collapsed`: only meaningful when `order === "sequential"`. When set, tail siblings
116
- * past the frontier suppress their own fallback output. Ignored under `"together"`
117
- * and `"natural"` — those orders have no frontier.
118
- *
119
- * Nested `createRevealOrder` groups compose: the inner controller registers as a
120
- * single slot in the outer controller and is held on its fallbacks until the outer
121
- * releases that slot. Once released, the inner controller runs its own order locally
122
- * over anything still pending. There is no opt-out from an outer hold.
123
- *
124
- * "Minimally ready" is what an order considers its first visible content:
125
- * - `sequential` — frontier-0 is minimally ready (leaf: on resolve; nested: via its
126
- * own minimal signal).
127
- * - `together` — every direct slot is minimally ready.
128
- * - `natural` — any direct slot has visible content (leaves on resolve; nested
129
- * composites when fully ready, since natural treats composites as atomic).
130
- *
131
- * @example
132
- * ```ts
133
- * // Primitive form of `<Reveal>` — coordinate sibling loading boundaries
134
- * // programmatically. App code uses the JSX `<Reveal>` component instead.
135
- * // Both options are accessors so they can react to state changes.
136
- * createRevealOrder(
137
- * () => renderSiblings(),
138
- * { order: () => mode(), collapsed: () => true }
139
- * );
140
- * ```
141
- */
142
- export declare function createRevealOrder<T>(fn: () => T, options?: {
143
- order?: OrderAccessor;
144
- collapsed?: BoolAccessor;
145
- }): T;
146
- /**
147
- * Resolves a children value to its renderable form: unwraps zero-arg functions
148
- * (accessors), recursively flattens arrays, and optionally skips
149
- * non-rendering values (`null`, `undefined`, `true`, `false`, `""`).
150
- *
151
- * Used internally by flow components and by the renderer to walk a children
152
- * tree. App code rarely needs this directly — see `children()` in `solid-js`
153
- * for the user-facing helper that memoizes the result.
154
- *
155
- * @param children value or array of values to flatten
156
- * @param options
157
- * - `skipNonRendered` — drop values that won't render
158
- * - `doNotUnwrap` — leave function children as-is (caller will resolve)
159
- *
160
- * @example
161
- * ```ts
162
- * // Custom renderer walking a children tree manually. Most authors should
163
- * // use `children()` from solid-js, which memoizes the resolved value.
164
- * function renderChildren(value: unknown): unknown {
165
- * return flatten(value, { skipNonRendered: true });
166
- * }
167
- * ```
168
- */
169
- export declare function flatten(children: any, options?: {
170
- skipNonRendered?: boolean;
171
- doNotUnwrap?: boolean;
172
- }): any;
173
- export {};
@@ -1,35 +0,0 @@
1
- /**
2
- * Wraps a generator function so each invocation runs as a single transaction
3
- * (a "transition") that batches every signal/store write between yields. The
4
- * surrounding UI sees one atomic update per yielded step; nothing is committed
5
- * until the action either completes or the next `yield` resolves.
6
- *
7
- * Yield promises (or any awaitable) inside the generator — the action waits
8
- * for each before continuing, but the writes you made beforehand are already
9
- * visible (or held by `<Loading>` if optimistic). Yield bare values for
10
- * synchronous batched steps.
11
- *
12
- * Each call returns a `Promise` that resolves with the generator's return
13
- * value, or rejects if it throws. Pair with `createOptimistic` /
14
- * `createOptimisticStore` to apply tentative writes that auto-revert if the
15
- * action fails.
16
- *
17
- * @example
18
- * ```ts
19
- * const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
20
- *
21
- * const addTodo = action(function* (text: string) {
22
- * const tempId = crypto.randomUUID();
23
- * setTodos(t => { t.push({ id: tempId, text, pending: true }); }); // optimistic
24
- * const saved = yield api.createTodo(text); // network round-trip
25
- * setTodos(t => {
26
- * const i = t.findIndex(x => x.id === tempId);
27
- * if (i >= 0) t[i] = saved;
28
- * });
29
- * return saved;
30
- * });
31
- *
32
- * await addTodo("buy milk");
33
- * ```
34
- */
35
- export declare function action<Args extends any[], Y, R>(genFn: (...args: Args) => Generator<Y, R, any> | AsyncGenerator<Y, R, any>): (...args: Args) => Promise<R>;
@@ -1,6 +0,0 @@
1
- import { type OptimisticLane } from "./lanes.cjs";
2
- import type { Computed } from "./types.cjs";
3
- export declare function settlePendingSource(el: Computed<any>): void;
4
- export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
5
- export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
6
- export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;