@solidjs/signals 0.13.13 → 2.0.0-beta.11

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 (110) hide show
  1. package/README.md +8 -7
  2. package/dist/dev.js +1230 -598
  3. package/dist/node.cjs +2064 -1555
  4. package/dist/prod.js +1783 -1251
  5. package/dist/types/boundaries.d.ts +126 -5
  6. package/dist/types/core/action.d.ts +34 -0
  7. package/dist/types/core/constants.d.ts +26 -0
  8. package/dist/types/core/context.d.ts +10 -2
  9. package/dist/types/core/core.d.ts +129 -9
  10. package/dist/types/core/dev.d.ts +1 -1
  11. package/dist/types/core/effect.d.ts +4 -2
  12. package/dist/types/core/error.d.ts +24 -0
  13. package/dist/types/core/external.d.ts +19 -0
  14. package/dist/types/core/graph.d.ts +2 -0
  15. package/dist/types/core/index.d.ts +1 -1
  16. package/dist/types/core/owner.d.ts +93 -3
  17. package/dist/types/core/scheduler.d.ts +43 -2
  18. package/dist/types/core/types.d.ts +5 -6
  19. package/dist/types/index.d.ts +3 -3
  20. package/dist/types/map.d.ts +32 -3
  21. package/dist/types/signals.d.ts +362 -42
  22. package/dist/types/src/boundaries.d.ts +173 -0
  23. package/dist/types/src/core/action.d.ts +35 -0
  24. package/dist/types/src/core/async.d.ts +6 -0
  25. package/dist/types/src/core/constants.d.ts +51 -0
  26. package/dist/types/src/core/context.d.ts +36 -0
  27. package/dist/types/src/core/core.d.ts +174 -0
  28. package/dist/types/src/core/dev.d.ts +49 -0
  29. package/dist/types/src/core/effect.d.ts +32 -0
  30. package/dist/types/src/core/error.d.ts +38 -0
  31. package/dist/types/src/core/external.d.ts +45 -0
  32. package/dist/types/src/core/graph.d.ts +5 -0
  33. package/dist/types/src/core/heap.d.ts +14 -0
  34. package/dist/types/src/core/index.d.ts +12 -0
  35. package/dist/types/src/core/lanes.d.ts +54 -0
  36. package/dist/types/src/core/owner.d.ts +116 -0
  37. package/dist/types/src/core/scheduler.d.ts +122 -0
  38. package/dist/types/src/core/types.d.ts +85 -0
  39. package/dist/types/src/index.d.ts +9 -0
  40. package/dist/types/src/map.d.ts +53 -0
  41. package/dist/types/src/signals.d.ts +512 -0
  42. package/dist/types/src/store/index.d.ts +9 -0
  43. package/dist/types/src/store/optimistic.d.ts +45 -0
  44. package/dist/types/src/store/projection.d.ts +66 -0
  45. package/dist/types/src/store/reconcile.d.ts +23 -0
  46. package/dist/types/src/store/store.d.ts +125 -0
  47. package/dist/types/src/store/storePath.d.ts +58 -0
  48. package/dist/types/src/store/utils.d.ts +114 -0
  49. package/dist/types/store/optimistic.d.ts +38 -12
  50. package/dist/types/store/projection.d.ts +55 -15
  51. package/dist/types/store/reconcile.d.ts +22 -0
  52. package/dist/types/store/store.d.ts +72 -15
  53. package/dist/types/store/storePath.d.ts +28 -0
  54. package/dist/types/store/utils.d.ts +78 -7
  55. package/dist/types-cjs/boundaries.d.cts +173 -0
  56. package/dist/types-cjs/core/action.d.cts +35 -0
  57. package/dist/types-cjs/core/async.d.cts +6 -0
  58. package/dist/types-cjs/core/constants.d.cts +51 -0
  59. package/dist/types-cjs/core/context.d.cts +36 -0
  60. package/dist/types-cjs/core/core.d.cts +174 -0
  61. package/dist/types-cjs/core/dev.d.cts +49 -0
  62. package/dist/types-cjs/core/effect.d.cts +32 -0
  63. package/dist/types-cjs/core/error.d.cts +38 -0
  64. package/dist/types-cjs/core/external.d.cts +45 -0
  65. package/dist/types-cjs/core/graph.d.cts +5 -0
  66. package/dist/types-cjs/core/heap.d.cts +14 -0
  67. package/dist/types-cjs/core/index.d.cts +12 -0
  68. package/dist/types-cjs/core/lanes.d.cts +54 -0
  69. package/dist/types-cjs/core/owner.d.cts +116 -0
  70. package/dist/types-cjs/core/scheduler.d.cts +122 -0
  71. package/dist/types-cjs/core/types.d.cts +85 -0
  72. package/dist/types-cjs/index.d.cts +9 -0
  73. package/dist/types-cjs/map.d.cts +53 -0
  74. package/dist/types-cjs/package.json +3 -0
  75. package/dist/types-cjs/signals.d.cts +512 -0
  76. package/dist/types-cjs/src/boundaries.d.cts +173 -0
  77. package/dist/types-cjs/src/core/action.d.cts +35 -0
  78. package/dist/types-cjs/src/core/async.d.cts +6 -0
  79. package/dist/types-cjs/src/core/constants.d.cts +51 -0
  80. package/dist/types-cjs/src/core/context.d.cts +36 -0
  81. package/dist/types-cjs/src/core/core.d.cts +174 -0
  82. package/dist/types-cjs/src/core/dev.d.cts +49 -0
  83. package/dist/types-cjs/src/core/effect.d.cts +32 -0
  84. package/dist/types-cjs/src/core/error.d.cts +38 -0
  85. package/dist/types-cjs/src/core/external.d.cts +45 -0
  86. package/dist/types-cjs/src/core/graph.d.cts +5 -0
  87. package/dist/types-cjs/src/core/heap.d.cts +14 -0
  88. package/dist/types-cjs/src/core/index.d.cts +12 -0
  89. package/dist/types-cjs/src/core/lanes.d.cts +54 -0
  90. package/dist/types-cjs/src/core/owner.d.cts +116 -0
  91. package/dist/types-cjs/src/core/scheduler.d.cts +122 -0
  92. package/dist/types-cjs/src/core/types.d.cts +85 -0
  93. package/dist/types-cjs/src/index.d.cts +9 -0
  94. package/dist/types-cjs/src/map.d.cts +53 -0
  95. package/dist/types-cjs/src/signals.d.cts +512 -0
  96. package/dist/types-cjs/src/store/index.d.cts +9 -0
  97. package/dist/types-cjs/src/store/optimistic.d.cts +45 -0
  98. package/dist/types-cjs/src/store/projection.d.cts +66 -0
  99. package/dist/types-cjs/src/store/reconcile.d.cts +23 -0
  100. package/dist/types-cjs/src/store/store.d.cts +125 -0
  101. package/dist/types-cjs/src/store/storePath.d.cts +58 -0
  102. package/dist/types-cjs/src/store/utils.d.cts +114 -0
  103. package/dist/types-cjs/store/index.d.cts +9 -0
  104. package/dist/types-cjs/store/optimistic.d.cts +45 -0
  105. package/dist/types-cjs/store/projection.d.cts +66 -0
  106. package/dist/types-cjs/store/reconcile.d.cts +23 -0
  107. package/dist/types-cjs/store/store.d.cts +125 -0
  108. package/dist/types-cjs/store/storePath.d.cts +58 -0
  109. package/dist/types-cjs/store/utils.d.cts +114 -0
  110. package/package.json +35 -27
@@ -1,15 +1,41 @@
1
1
  /**
2
- * Returns a non reactive copy of the store object.
3
- * It will attempt to preserver the original reference unless the value has been modified.
4
- * @param item store proxy object
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
+ * ```
5
16
  */
6
17
  export declare function snapshot<T>(item: T): T;
7
18
  export declare function snapshot<T>(item: T, map?: Map<unknown, unknown>, lookup?: WeakMap<any, any>): T;
8
19
  /**
9
- * Returns a non-reactive snapshot of the store while subscribing to all nested changes.
10
- * Subscribes to `$TRACK` at every level so that any deep change triggers recomputation,
11
- * and returns plain (non-proxy) data. Works correctly with `reconcile()`.
12
- * @param store store proxy object
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
+ * ```
13
39
  */
14
40
  export declare function deep<T extends object>(store: T): T;
15
41
  type DistributeOverride<T, F> = T extends undefined ? F : T;
@@ -35,9 +61,54 @@ type _Merge<T extends unknown[], Curr = {}> = T extends [
35
61
  ...infer Rest
36
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;
37
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
+ */
38
84
  export declare function merge<T extends unknown[]>(...sources: T): Merge<T>;
39
85
  export type Omit<T, K extends readonly (keyof T)[]> = {
40
86
  [P in keyof T as Exclude<P, K[number]>]: T[P];
41
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
+ */
42
113
  export declare function omit<T extends Record<any, any>, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit<T, K>;
43
114
  export {};
@@ -0,0 +1,173 @@
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 {};
@@ -0,0 +1,35 @@
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>;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,51 @@
1
+ export declare const REACTIVE_NONE = 0;
2
+ export declare const REACTIVE_CHECK: number;
3
+ export declare const REACTIVE_DIRTY: number;
4
+ export declare const REACTIVE_RECOMPUTING_DEPS: number;
5
+ export declare const REACTIVE_IN_HEAP: number;
6
+ export declare const REACTIVE_IN_HEAP_HEIGHT: number;
7
+ export declare const REACTIVE_ZOMBIE: number;
8
+ export declare const REACTIVE_DISPOSED: number;
9
+ export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
10
+ export declare const REACTIVE_SNAPSHOT_STALE: number;
11
+ export declare const REACTIVE_LAZY: number;
12
+ export declare const REACTIVE_MANUAL_WRITE: number;
13
+ export declare const CONFIG_OWNED_WRITE: number;
14
+ export declare const CONFIG_NO_SNAPSHOT: number;
15
+ export declare const CONFIG_TRANSPARENT: number;
16
+ export declare const CONFIG_IN_SNAPSHOT_SCOPE: number;
17
+ export declare const CONFIG_CHILDREN_FORBIDDEN: number;
18
+ export declare const CONFIG_AUTO_DISPOSE: number;
19
+ export declare const CONFIG_SYNC: number;
20
+ export declare const STATUS_NONE = 0;
21
+ export declare const STATUS_PENDING: number;
22
+ export declare const STATUS_ERROR: number;
23
+ export declare const STATUS_UNINITIALIZED: number;
24
+ export declare const EFFECT_PURE = 0;
25
+ export declare const EFFECT_RENDER = 1;
26
+ export declare const EFFECT_USER = 2;
27
+ export declare const EFFECT_TRACKED = 3;
28
+ export declare const NOT_PENDING: {};
29
+ export declare const NO_SNAPSHOT: {};
30
+ export declare const STORE_SNAPSHOT_PROPS = "sp";
31
+ export declare const SUPPORTS_PROXY: boolean;
32
+ export declare const defaultContext: {};
33
+ /**
34
+ * Brand symbol used by `Refreshable<T>` values (projection stores, async
35
+ * memos) to expose their underlying computation to `refresh()`. Not part of
36
+ * the user-facing API.
37
+ *
38
+ * @internal
39
+ */
40
+ export declare const $REFRESH: unique symbol;
41
+ /**
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).
48
+ */
49
+ export type Refreshable<T> = T & {
50
+ readonly [$REFRESH]: any;
51
+ };
@@ -0,0 +1,36 @@
1
+ import type { Owner } from "./types.cjs";
2
+ export interface Context<T> {
3
+ readonly id: symbol;
4
+ readonly defaultValue: T | undefined;
5
+ }
6
+ export type ContextRecord = Record<string | symbol, unknown>;
7
+ /**
8
+ * Context provides a form of dependency injection. It is used to save from needing to pass
9
+ * data as props through intermediate components. This function creates a new context object
10
+ * that can be used with `getContext` and `setContext`.
11
+ *
12
+ * A default value can be provided here which will be used when a specific value is not provided
13
+ * via a `setContext` call.
14
+ */
15
+ export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
16
+ /**
17
+ * Low-level owner-targeted context read. The user-facing read API is
18
+ * `useContext` (in `solid-js`), which wraps this primitive. Exposed here for
19
+ * cross-package wiring (e.g. hydration-aware context plumbing).
20
+ *
21
+ * @throws `NoOwnerError` if there's no owner at the time of call.
22
+ * @throws `ContextNotFoundError` if a context value has not been set yet.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
27
+ /**
28
+ * Low-level owner-targeted context write. The user-facing API is
29
+ * `createContext` (in `solid-js`); its provider component wraps this
30
+ * primitive. Exposed here for cross-package wiring.
31
+ *
32
+ * @throws `NoOwnerError` if there's no owner at the time of call.
33
+ *
34
+ * @internal
35
+ */
36
+ export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
@@ -0,0 +1,174 @@
1
+ import { type Refreshable } from "./constants.cjs";
2
+ import { type OptimisticLane } from "./lanes.cjs";
3
+ import type { Computed, FirewallSignal, NodeOptions, Owner, Signal } from "./types.cjs";
4
+ export declare const PRIMITIVE_IN_FORBIDDEN_SCOPE_MESSAGE = "[PRIMITIVE_IN_FORBIDDEN_SCOPE] Cannot create reactive primitives inside createTrackedEffect or owner-backed onSettled";
5
+ export declare let tracking: boolean;
6
+ export declare let stale: boolean;
7
+ export declare let refreshing: boolean;
8
+ export declare let pendingCheckActive: boolean;
9
+ export declare let foundPending: boolean;
10
+ export declare let latestReadActive: boolean;
11
+ export declare let context: Owner | null;
12
+ export declare let currentOptimisticLane: OptimisticLane | null;
13
+ export declare let snapshotCaptureActive: boolean;
14
+ export declare let snapshotSources: Set<any> | null;
15
+ export declare function setSnapshotCapture(active: boolean): void;
16
+ export declare function markSnapshotScope(owner: Owner): void;
17
+ export declare function releaseSnapshotScope(owner: Owner): void;
18
+ export declare function clearSnapshots(): void;
19
+ export declare function recompute(el: Computed<any>, create?: boolean): void;
20
+ export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
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;
29
+ export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
30
+ export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
31
+ export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
32
+ export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
33
+ export declare function isEqual<T>(a: T, b: T): boolean;
34
+ /**
35
+ * When set to a component name string, any reactive read that is not inside a nested tracking
36
+ * scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
37
+ */
38
+ export declare let strictRead: string | false;
39
+ export declare function setStrictRead(v: string | false): string | false;
40
+ /**
41
+ * Runs `fn` outside of any reactive tracking — reads inside `fn` will not
42
+ * subscribe the current scope. Returns whatever `fn` returns.
43
+ *
44
+ * Use `untrack` inside a memo or effect when you need to read a signal once
45
+ * without making the surrounding computation depend on its future changes.
46
+ *
47
+ * Pass a `strictReadLabel` string to enable a dev-mode warning: any reactive
48
+ * read inside `fn` that isn't inside a nested tracking scope will log a
49
+ * warning naming the label.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * createEffect(
54
+ * () => trigger(), // tracks `trigger` only
55
+ * () => {
56
+ * const snapshot = untrack(() => state); // read once, untracked
57
+ * log(snapshot);
58
+ * }
59
+ * );
60
+ * ```
61
+ */
62
+ export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
63
+ export declare function read<T>(el: Signal<T> | Computed<T>): T;
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;
80
+ /**
81
+ * Executes `fn` with the given `owner` set as the current owner. Any reactive
82
+ * primitives (`createSignal`, `createMemo`, `createEffect`, `onCleanup`,
83
+ * `cleanup`, etc.) created inside `fn` are attached to that owner, so they
84
+ * are disposed when the owner is disposed.
85
+ *
86
+ * The classic pattern: capture the current owner with `getOwner()` inside a
87
+ * component, then re-enter it from a callback (event handler, async resolve,
88
+ * setTimeout) so disposables created in the callback get cleaned up with the
89
+ * component.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * function delayed<T>(ms: number, fn: () => T) {
94
+ * const owner = getOwner();
95
+ * setTimeout(() => runWithOwner(owner, fn), ms);
96
+ * }
97
+ * ```
98
+ */
99
+ export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
100
+ /**
101
+ * Update _pendingSignal when pending state changes. When the override clears
102
+ * (pending -> not pending), merge the sub-lane into the source's lane so
103
+ * isPending effects are blocked until the full scope resolves.
104
+ */
105
+ export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
106
+ export declare function staleValues<T>(fn: () => T, set?: boolean): T;
107
+ /**
108
+ * Reads reactive expressions while bypassing any pending async overlay — i.e.
109
+ * always returns the most-recently-committed value, even when newer reads
110
+ * inside `fn` are still in flight.
111
+ *
112
+ * Useful inside a `<Loading>` boundary's children when you want to keep
113
+ * showing the previous resolved data instead of the fallback while the next
114
+ * value loads.
115
+ *
116
+ * @example
117
+ * ```tsx
118
+ * <Loading fallback={<Skeleton />}>
119
+ * {/* During a transition, render the previous user instead of skeleton: *\/}
120
+ * <UserCard user={latest(() => user())} />
121
+ * </Loading>
122
+ * ```
123
+ */
124
+ export declare function latest<T>(fn: () => T): T;
125
+ /**
126
+ * Returns `true` if any reactive read inside `fn` is currently in a pending
127
+ * (async, not-yet-settled) state. Does not subscribe — pair with a tracked
128
+ * memo if you want to react to pending status changes.
129
+ *
130
+ * Useful for showing inline transition indicators alongside the previous
131
+ * value (rather than swapping to a `<Loading>` fallback).
132
+ *
133
+ * @example
134
+ * ```tsx
135
+ * const pending = createMemo(() => isPending(() => user()));
136
+ *
137
+ * <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
138
+ * ```
139
+ */
140
+ export declare function isPending(fn: () => any): boolean;
141
+ /**
142
+ * Invalidates one reactive source, forcing it to re-execute even if its inputs
143
+ * haven't changed.
144
+ *
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.
149
+ *
150
+ * Use it to invalidate cached async values (e.g. force a re-fetch) without
151
+ * tearing the consumer down.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * const user = createMemo(async () => fetch(`/users/${id()}`).then(r => r.json()));
156
+ *
157
+ * // Re-fetch on demand
158
+ * <button onClick={() => refresh(user)}>Reload</button>
159
+ * ```
160
+ */
161
+ export declare function refresh<T>(target: Refreshable<T>): void;
162
+ /**
163
+ * Returns `true` while a `refresh()` call is in progress. Useful for showing
164
+ * a "refreshing" indicator distinct from the initial-load `<Loading>`
165
+ * fallback.
166
+ *
167
+ * @example
168
+ * ```tsx
169
+ * <Show when={isRefreshing()}>
170
+ * <span class="badge">refreshing…</span>
171
+ * </Show>
172
+ * ```
173
+ */
174
+ export declare function isRefreshing(): boolean;
@@ -0,0 +1,49 @@
1
+ import type { Computed, Owner, Signal } from "./types.cjs";
2
+ export interface DevHooks {
3
+ onOwner?: (owner: Owner) => void;
4
+ onGraph?: (value: any, owner: Owner | null) => void;
5
+ onUpdate?: () => void;
6
+ onStoreNodeUpdate?: (state: any, property: PropertyKey, value: any, prev: any) => void;
7
+ }
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" | "INVALID_REFRESH_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC";
10
+ export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner";
11
+ export interface DiagnosticEvent {
12
+ sequence: number;
13
+ code: DiagnosticCode;
14
+ kind: DiagnosticKind;
15
+ severity: DiagnosticSeverity;
16
+ message: string;
17
+ ownerId?: string;
18
+ ownerName?: string;
19
+ nodeName?: string;
20
+ data?: Record<string, unknown>;
21
+ }
22
+ export type DiagnosticListener = (event: DiagnosticEvent) => void;
23
+ export interface DiagnosticCapture {
24
+ readonly events: readonly DiagnosticEvent[];
25
+ clear(): void;
26
+ stop(): DiagnosticEvent[];
27
+ }
28
+ export interface Diagnostics {
29
+ subscribe(listener: DiagnosticListener): () => void;
30
+ capture(): DiagnosticCapture;
31
+ }
32
+ export interface Dev {
33
+ hooks: DevHooks;
34
+ diagnostics: Diagnostics;
35
+ getChildren: typeof getChildren;
36
+ getSignals: typeof getSignals;
37
+ getParent: typeof getParent;
38
+ getSources: typeof getSources;
39
+ getObservers: typeof getObservers;
40
+ }
41
+ export declare const DEV: Dev;
42
+ export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
43
+ export declare function registerGraph(value: any, owner: Owner | null): void;
44
+ export declare function clearSignals(node: Owner): void;
45
+ export declare function getChildren(owner: Owner): Owner[];
46
+ export declare function getSignals(owner: Owner): any[];
47
+ export declare function getParent(owner: Owner): Owner | null;
48
+ export declare function getSources(computation: Computed<any>): (Signal<any> | Computed<any>)[];
49
+ export declare function getObservers(node: Signal<any> | Computed<any>): Computed<any>[];
@@ -0,0 +1,32 @@
1
+ import type { Computed, NodeOptions, Owner } from "./types.cjs";
2
+ export interface Effect<T> extends Computed<T>, Owner {
3
+ _effectFn: (val: T, prev: T | undefined) => void | (() => void);
4
+ _errorFn?: (err: unknown, cleanup: () => void) => void;
5
+ _cleanup?: () => void;
6
+ _cleanupRegistered?: boolean;
7
+ _modified: boolean;
8
+ _prevValue: T | undefined;
9
+ _type: number;
10
+ }
11
+ /**
12
+ * Effects are the leaf nodes of our reactive graph. When their sources change, they are
13
+ * automatically added to the queue of effects to re-execute, which will cause them to fetch their
14
+ * sources and recompute
15
+ */
16
+ export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown, cleanup: () => void) => void | (() => void), options?: NodeOptions<any> & {
17
+ user?: boolean;
18
+ defer?: boolean;
19
+ schedule?: boolean;
20
+ }): void;
21
+ export interface TrackedEffect extends Computed<void> {
22
+ _cleanup?: () => void;
23
+ _modified: boolean;
24
+ _type: number;
25
+ _run: () => void;
26
+ }
27
+ /**
28
+ * Internal tracked effect - bypasses heap, goes directly to effect queue.
29
+ * Runs as a leaf owner: child primitives and onCleanup are forbidden (__DEV__ throws).
30
+ * Uses stale reads.
31
+ */
32
+ export declare function trackedEffect(fn: () => void | (() => void), options?: NodeOptions<any>): void;