@solidjs/signals 2.0.0-beta.8 → 2.0.0-rc.0

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 (95) hide show
  1. package/README.md +13 -9
  2. package/dist/dev.js +6078 -1440
  3. package/dist/node.cjs +7684 -3248
  4. package/dist/prod/affects.js +126 -0
  5. package/dist/prod/boundaries.js +572 -0
  6. package/dist/prod/core/action.js +139 -0
  7. package/dist/prod/core/async.js +553 -0
  8. package/dist/prod/core/constants.js +92 -0
  9. package/dist/prod/core/context.js +67 -0
  10. package/dist/prod/core/core.js +817 -0
  11. package/dist/prod/core/dev.js +3 -0
  12. package/dist/prod/core/effect.js +145 -0
  13. package/dist/prod/core/error.js +68 -0
  14. package/dist/prod/core/external.js +98 -0
  15. package/dist/prod/core/graph.js +104 -0
  16. package/dist/prod/core/heap.js +140 -0
  17. package/dist/prod/core/invariants.js +42 -0
  18. package/dist/prod/core/lanes.js +140 -0
  19. package/dist/prod/core/optimistic.js +245 -0
  20. package/dist/prod/core/owner.js +302 -0
  21. package/dist/prod/core/scheduler.js +749 -0
  22. package/dist/prod/core/verdict.js +369 -0
  23. package/dist/prod/index.js +45 -0
  24. package/dist/prod/map.js +317 -0
  25. package/dist/prod/signals.js +375 -0
  26. package/dist/prod/store/optimistic.js +217 -0
  27. package/dist/prod/store/projection.js +231 -0
  28. package/dist/prod/store/reconcile.js +707 -0
  29. package/dist/prod/store/store.js +1081 -0
  30. package/dist/prod/store/storePath.js +103 -0
  31. package/dist/prod/store/utils.js +328 -0
  32. package/dist/types/affects.d.ts +47 -0
  33. package/dist/types/boundaries.d.ts +93 -11
  34. package/dist/types/core/action.d.ts +63 -0
  35. package/dist/types/core/async.d.ts +16 -1
  36. package/dist/types/core/constants.d.ts +46 -0
  37. package/dist/types/core/context.d.ts +10 -2
  38. package/dist/types/core/core.d.ts +111 -17
  39. package/dist/types/core/dev.d.ts +17 -2
  40. package/dist/types/core/effect.d.ts +1 -2
  41. package/dist/types/core/error.d.ts +33 -0
  42. package/dist/types/core/external.d.ts +0 -11
  43. package/dist/types/core/graph.d.ts +2 -1
  44. package/dist/types/core/heap.d.ts +8 -0
  45. package/dist/types/core/index.d.ts +3 -2
  46. package/dist/types/core/invariants.d.ts +59 -0
  47. package/dist/types/core/lanes.d.ts +2 -0
  48. package/dist/types/core/optimistic.d.ts +6 -0
  49. package/dist/types/core/owner.d.ts +101 -3
  50. package/dist/types/core/scheduler.d.ts +97 -9
  51. package/dist/types/core/types.d.ts +68 -6
  52. package/dist/types/core/verdict.d.ts +2 -0
  53. package/dist/types/index.d.ts +4 -3
  54. package/dist/types/map.d.ts +50 -5
  55. package/dist/types/signals.d.ts +424 -19
  56. package/dist/types/store/index.d.ts +1 -1
  57. package/dist/types/store/optimistic.d.ts +39 -13
  58. package/dist/types/store/projection.d.ts +48 -18
  59. package/dist/types/store/reconcile.d.ts +46 -1
  60. package/dist/types/store/store.d.ts +164 -19
  61. package/dist/types/store/storePath.d.ts +28 -0
  62. package/dist/types/store/utils.d.ts +78 -7
  63. package/dist/types-cjs/affects.d.cts +47 -0
  64. package/dist/types-cjs/boundaries.d.cts +93 -11
  65. package/dist/types-cjs/core/action.d.cts +63 -0
  66. package/dist/types-cjs/core/async.d.cts +16 -1
  67. package/dist/types-cjs/core/constants.d.cts +46 -0
  68. package/dist/types-cjs/core/context.d.cts +10 -2
  69. package/dist/types-cjs/core/core.d.cts +111 -17
  70. package/dist/types-cjs/core/dev.d.cts +17 -2
  71. package/dist/types-cjs/core/effect.d.cts +1 -2
  72. package/dist/types-cjs/core/error.d.cts +33 -0
  73. package/dist/types-cjs/core/external.d.cts +0 -11
  74. package/dist/types-cjs/core/graph.d.cts +2 -1
  75. package/dist/types-cjs/core/heap.d.cts +8 -0
  76. package/dist/types-cjs/core/index.d.cts +3 -2
  77. package/dist/types-cjs/core/invariants.d.cts +59 -0
  78. package/dist/types-cjs/core/lanes.d.cts +2 -0
  79. package/dist/types-cjs/core/optimistic.d.cts +6 -0
  80. package/dist/types-cjs/core/owner.d.cts +101 -3
  81. package/dist/types-cjs/core/scheduler.d.cts +97 -9
  82. package/dist/types-cjs/core/types.d.cts +68 -6
  83. package/dist/types-cjs/core/verdict.d.cts +2 -0
  84. package/dist/types-cjs/index.d.cts +4 -3
  85. package/dist/types-cjs/map.d.cts +50 -5
  86. package/dist/types-cjs/signals.d.cts +424 -19
  87. package/dist/types-cjs/store/index.d.cts +1 -1
  88. package/dist/types-cjs/store/optimistic.d.cts +39 -13
  89. package/dist/types-cjs/store/projection.d.cts +48 -18
  90. package/dist/types-cjs/store/reconcile.d.cts +46 -1
  91. package/dist/types-cjs/store/store.d.cts +164 -19
  92. package/dist/types-cjs/store/storePath.d.cts +28 -0
  93. package/dist/types-cjs/store/utils.d.cts +78 -7
  94. package/package.json +14 -11
  95. package/dist/prod.js +0 -3577
@@ -1,5 +1,6 @@
1
1
  import { Queue, type Computed, type Effect } from "./core/index.cjs";
2
2
  import type { Signal } from "./core/index.cjs";
3
+ import { type Accessor } from "./signals.cjs";
3
4
  export interface BoundaryComputed<T> extends Computed<T> {
4
5
  _propagationMask: number;
5
6
  }
@@ -19,18 +20,18 @@ export declare class RevealController {
19
20
  _evaluating: boolean;
20
21
  constructor(order: OrderAccessor, collapsed: BoolAccessor);
21
22
  _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
22
- isReady(): boolean;
23
+ _isReady(): boolean;
23
24
  /**
24
25
  * "Minimally ready" = this group has something visible to show under its own policy.
25
26
  * Used by an enclosing `together` group to decide when it can release.
26
- * - `together`: fully ready (atomic).
27
+ * - `together`: every direct slot is minimally ready.
27
28
  * - `sequential`: the first owned slot is minimally ready (frontier can advance).
28
29
  * - `natural`: any owned slot is minimally ready.
29
30
  */
30
- isMinimallyReady(): boolean;
31
- register(slot: RevealSlot): void;
32
- unregister(slot: RevealSlot): void;
33
- evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
31
+ _isMinimallyReady(): boolean;
32
+ _register(slot: RevealSlot): void;
33
+ _unregister(slot: RevealSlot): void;
34
+ _evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
34
35
  }
35
36
  export declare class CollectionQueue extends Queue {
36
37
  _collectionType: number;
@@ -38,6 +39,7 @@ export declare class CollectionQueue extends Queue {
38
39
  _tree?: BoundaryComputed<any>;
39
40
  _pending: boolean;
40
41
  _disabled: Signal<boolean>;
42
+ _error?: Signal<unknown>;
41
43
  _collapsed: Signal<boolean>;
42
44
  _revealController?: RevealController;
43
45
  _initialized: boolean;
@@ -46,12 +48,58 @@ export declare class CollectionQueue extends Queue {
46
48
  constructor(type: number);
47
49
  run(type: number): void;
48
50
  notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
49
- checkSources(): void;
51
+ _checkSources(): void;
50
52
  }
51
- export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
53
+ /**
54
+ * Lower-level primitive that backs the `<Loading>` flow control. Catches
55
+ * pending async reads inside `fn` and renders `fallback` until they settle.
56
+ *
57
+ * App code should use `<Loading fallback={...}>` instead — reach for this only
58
+ * when authoring custom boundary components.
59
+ *
60
+ * @param fn the tracked subtree
61
+ * @param fallback the fallback shown while async reads in `fn` are unresolved
62
+ * @param options `on` — accessor whose value scopes the boundary; when set,
63
+ * transitions caused by writes to other reactive sources are *not* caught
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * // Custom boundary component built on top of the primitive.
68
+ * function MyLoading(props: { fallback: JSX.Element; children: JSX.Element }) {
69
+ * return createLoadingBoundary(
70
+ * () => props.children,
71
+ * () => props.fallback
72
+ * ) as unknown as JSX.Element;
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function createLoadingBoundary<T, U>(fn: () => T, fallback: () => U, options?: {
52
77
  on?: () => any;
53
- }): import("./signals.cjs").Accessor<unknown>;
54
- export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").Accessor<unknown>;
78
+ }): Accessor<T | U>;
79
+ /**
80
+ * Lower-level primitive that backs the `<Errored>` flow control. Catches
81
+ * thrown errors inside `fn` and invokes `fallback(error, reset)` instead.
82
+ * `error` is an accessor for the latest captured error; `reset()` recomputes
83
+ * the failing sources so the boundary can attempt to recover.
84
+ *
85
+ * App code should use `<Errored fallback={...}>` instead — reach for this only
86
+ * when authoring custom boundary components.
87
+ *
88
+ * @example
89
+ * ```tsx
90
+ * // Custom boundary that wraps the primitive and adds telemetry.
91
+ * function TracedErrored(props: { fallback: (e: () => unknown) => JSX.Element; children: JSX.Element }) {
92
+ * return createErrorBoundary(
93
+ * () => props.children,
94
+ * (err, reset) => {
95
+ * reportError(err());
96
+ * return props.fallback(err);
97
+ * }
98
+ * ) as unknown as JSX.Element;
99
+ * }
100
+ * ```
101
+ */
102
+ export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error: Accessor<unknown>, reset: () => void) => U): Accessor<T | U>;
55
103
  /**
56
104
  * Coordinate the reveal timing of sibling loading boundaries.
57
105
  *
@@ -80,12 +128,46 @@ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error:
80
128
  * own minimal signal).
81
129
  * - `together` — every direct slot is minimally ready.
82
130
  * - `natural` — any direct slot has visible content (leaves on resolve; nested
83
- * composites when fully ready, since natural treats composites as atomic).
131
+ * composites via their own minimal signal).
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * // Primitive form of `<Reveal>` — coordinate sibling loading boundaries
136
+ * // programmatically. App code uses the JSX `<Reveal>` component instead.
137
+ * // Both options are accessors so they can react to state changes.
138
+ * createRevealOrder(
139
+ * () => renderSiblings(),
140
+ * { order: () => mode(), collapsed: () => true }
141
+ * );
142
+ * ```
84
143
  */
85
144
  export declare function createRevealOrder<T>(fn: () => T, options?: {
86
145
  order?: OrderAccessor;
87
146
  collapsed?: BoolAccessor;
88
147
  }): T;
148
+ /**
149
+ * Resolves a children value to its renderable form: unwraps zero-arg functions
150
+ * (accessors), recursively flattens arrays, and optionally skips
151
+ * non-rendering values (`null`, `undefined`, `true`, `false`, `""`).
152
+ *
153
+ * Used internally by flow components and by the renderer to walk a children
154
+ * tree. App code rarely needs this directly — see `children()` in `solid-js`
155
+ * for the user-facing helper that memoizes the result.
156
+ *
157
+ * @param children value or array of values to flatten
158
+ * @param options
159
+ * - `skipNonRendered` — drop values that won't render
160
+ * - `doNotUnwrap` — leave function children as-is (caller will resolve)
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * // Custom renderer walking a children tree manually. Most authors should
165
+ * // use `children()` from solid-js, which memoizes the resolved value.
166
+ * function renderChildren(value: unknown): unknown {
167
+ * return flatten(value, { skipNonRendered: true });
168
+ * }
169
+ * ```
170
+ */
89
171
  export declare function flatten(children: any, options?: {
90
172
  skipNonRendered?: boolean;
91
173
  doNotUnwrap?: boolean;
@@ -1 +1,64 @@
1
+ /**
2
+ * The primitive for mutations: imperative async workflows whose *writes span
3
+ * an async gap* — optimistic write, server round-trip, reconciling write —
4
+ * where intermediate state must not leak and failure must revert cleanly
5
+ * (pair with `createOptimistic` / `createOptimisticStore`).
6
+ *
7
+ * Navigation-shaped updates do not need an action. A plain setter call is
8
+ * enough: reads pull the async, and downstream async computeds hold their
9
+ * previous values per-node until the new ones are ready (`isPending` /
10
+ * `latest` expose the in-flight state). Reach for `action` only when writes
11
+ * happen *after* async work, not merely upstream of it.
12
+ *
13
+ * Framework-level actions (router form actions, server actions) are
14
+ * specializations of this primitive: they are actions in exactly this sense —
15
+ * the same transactional semantics — with form binding, serialization, and
16
+ * submission tracking layered on top. The shared name is deliberate.
17
+ *
18
+ * Wraps a generator function so each invocation runs as a single transaction
19
+ * (a "transition") that batches every signal/store write between yields. The
20
+ * surrounding UI sees one atomic update per yielded step; nothing is committed
21
+ * until the action either completes or the next `yield` resolves.
22
+ *
23
+ * `yield` is the transaction-safe suspension point: the action waits for a
24
+ * yielded promise and re-enters the transaction before running the code after
25
+ * it. A plain `await` does NOT — the runtime has no hook into an async
26
+ * generator's internal await continuations, so writes to fresh signals
27
+ * between an `await` and the next `yield` escape the transaction and commit
28
+ * immediately. `await` is still the ergonomic choice for typed results; just
29
+ * put a bare `yield` before any writes that follow it:
30
+ *
31
+ * ```ts
32
+ * const saved = await api.createTodo(text); // typed result
33
+ * yield; // re-enter the transaction before writing
34
+ * setTodos(t => { ... });
35
+ * ```
36
+ *
37
+ * (For the same reason, don't call `flush()` inside an action body — it
38
+ * drains the transaction mid-step.)
39
+ *
40
+ * Each call returns a `Promise` that resolves with the generator's return
41
+ * value, or rejects if it throws. Pair with `createOptimistic` /
42
+ * `createOptimisticStore` to apply tentative writes that auto-revert if the
43
+ * action fails.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const [todos, setTodos] = createOptimisticStore<Todo[]>([]);
48
+ *
49
+ * const addTodo = action(async function* (text: string) {
50
+ * const tempId = crypto.randomUUID();
51
+ * setTodos(t => { t.push({ id: tempId, text, pending: true }); }); // optimistic
52
+ * const saved = await api.createTodo(text); // network round-trip, typed
53
+ * yield; // re-enter the transaction
54
+ * setTodos(t => {
55
+ * const i = t.findIndex(x => x.id === tempId);
56
+ * if (i >= 0) t[i] = saved;
57
+ * });
58
+ * return saved;
59
+ * });
60
+ *
61
+ * await addTodo("buy milk");
62
+ * ```
63
+ */
1
64
  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 +1,21 @@
1
+ import { NotReadyError } from "./error.cjs";
1
2
  import { type OptimisticLane } from "./lanes.cjs";
2
- import type { Computed } from "./types.cjs";
3
+ import type { Computed, Link } from "./types.cjs";
4
+ export declare function addPendingSource(el: Computed<any>, source: Computed<any>): boolean;
5
+ /**
6
+ * A loading-window node hit an unready source (sync throw in recompute, or a
7
+ * NotReadyError-rejected flight): register for the source's settle — the
8
+ * settlePendingSource walk runs off `_pendingSources` + `_blocked` alone —
9
+ * with NO read-visible pending status, no downstream propagation, no
10
+ * transition, no lane registration. Commit #0 keeps serving.
11
+ */
12
+ export declare function parkLoadingWindow(el: Computed<any>, e: NotReadyError): void;
13
+ export declare function setPendingError(el: Computed<any>, source?: Computed<any>, error?: any): void;
14
+ export declare function forEachDependent(el: Computed<any>, fn: (node: Computed<any>, link: Link) => void): void;
15
+ export declare function releaseSettledDependents(el: Computed<any>): void;
16
+ export declare function settleErroredDependents(el: Computed<any>, error: any): void;
3
17
  export declare function settlePendingSource(el: Computed<any>): void;
18
+ export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
4
19
  export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
5
20
  export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
6
21
  export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
@@ -9,6 +9,22 @@ 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;
13
+ /**
14
+ * The pending recompute is a re-ask of the same question: `refresh()` dirtied
15
+ * the node while no tracked input changed value. Cleared whenever a real
16
+ * value-change notification arrives (`insertSubs`), and consumed by
17
+ * `recompute` into the node's `_reask` classification — a quiet (re-ask)
18
+ * pending window does not read as pending (question-scoped pending model).
19
+ */
20
+ export declare const REACTIVE_REASK: number;
21
+ export declare const CONFIG_OWNED_WRITE: number;
22
+ export declare const CONFIG_NO_SNAPSHOT: number;
23
+ export declare const CONFIG_TRANSPARENT: number;
24
+ export declare const CONFIG_IN_SNAPSHOT_SCOPE: number;
25
+ export declare const CONFIG_CHILDREN_FORBIDDEN: number;
26
+ export declare const CONFIG_AUTO_DISPOSE: number;
27
+ export declare const CONFIG_SYNC: number;
12
28
  export declare const STATUS_NONE = 0;
13
29
  export declare const STATUS_PENDING: number;
14
30
  export declare const STATUS_ERROR: number;
@@ -19,7 +35,37 @@ export declare const EFFECT_USER = 2;
19
35
  export declare const EFFECT_TRACKED = 3;
20
36
  export declare const NOT_PENDING: {};
21
37
  export declare const NO_SNAPSHOT: {};
38
+ /**
39
+ * Stand-in stored in `_overrideValue` for an optimistic write of literal
40
+ * `undefined` (#2898). The slot doubles as the optimistic-node brand
41
+ * (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
42
+ * would erase the node's optimistic identity: the write turns invisible and
43
+ * follow-up writes route off the optimistic path and commit permanently.
44
+ * Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
45
+ * via `visibleOverrideValue`; slot identity tests stay raw.
46
+ */
47
+ export declare const OVERRIDE_UNDEFINED: {};
48
+ /** Unwrap an active override's stored value for surfacing to readers (#2898). */
49
+ export declare function unwrapOverride<T = any>(v: unknown): T;
22
50
  export declare const STORE_SNAPSHOT_PROPS = "sp";
23
51
  export declare const SUPPORTS_PROXY: boolean;
24
52
  export declare const defaultContext: {};
53
+ /**
54
+ * Brand symbol used by `Refreshable<T>` values (projection stores, async
55
+ * memos) to expose their underlying computation to `refresh()`. Not part of
56
+ * the user-facing API.
57
+ *
58
+ * @internal
59
+ */
25
60
  export declare const $REFRESH: unique symbol;
61
+ /**
62
+ * Brand applied to values that participate in the `refresh()` re-run protocol.
63
+ * Accessors receive this handle internally; projected stores expose it through
64
+ * their public return type so user-defined hooks that wrap `createOptimisticStore`
65
+ * / `createProjection` / projection-form `createStore` can have their return
66
+ * types inferred without leaking the internal `$REFRESH` symbol into public type
67
+ * signatures (TS4058).
68
+ */
69
+ export type Refreshable<T> = T & {
70
+ readonly [$REFRESH]: any;
71
+ };
@@ -14,15 +14,23 @@ export type ContextRecord = Record<string | symbol, unknown>;
14
14
  */
15
15
  export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
16
16
  /**
17
- * Attempts to get a context value for the given key.
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).
18
20
  *
19
21
  * @throws `NoOwnerError` if there's no owner at the time of call.
20
22
  * @throws `ContextNotFoundError` if a context value has not been set yet.
23
+ *
24
+ * @internal
21
25
  */
22
26
  export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
23
27
  /**
24
- * Attempts to set a context value on the parent scope with the given key.
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.
25
31
  *
26
32
  * @throws `NoOwnerError` if there's no owner at the time of call.
33
+ *
34
+ * @internal
27
35
  */
28
36
  export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
@@ -1,11 +1,18 @@
1
- import { $REFRESH } from "./constants.cjs";
1
+ import { type Refreshable } from "./constants.cjs";
2
2
  import { type OptimisticLane } from "./lanes.cjs";
3
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 const REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE: string;
6
+ export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE: string;
4
7
  export declare let tracking: boolean;
8
+ /** @internal verdict-module glue */
9
+ export declare function setPendingCheckActive(v: boolean): void;
10
+ /** @internal verdict-module glue */
11
+ export declare function setLatestReadActive(v: boolean): void;
12
+ /** @internal verdict-module glue */
13
+ export declare function setContextInternal(v: Owner | null): void;
5
14
  export declare let stale: boolean;
6
- export declare let refreshing: boolean;
7
15
  export declare let pendingCheckActive: boolean;
8
- export declare let foundPending: boolean;
9
16
  export declare let latestReadActive: boolean;
10
17
  export declare let context: Owner | null;
11
18
  export declare let currentOptimisticLane: OptimisticLane | null;
@@ -18,6 +25,13 @@ export declare function clearSnapshots(): void;
18
25
  export declare function recompute(el: Computed<any>, create?: boolean): void;
19
26
  export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
20
27
  export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
28
+ /**
29
+ * Build an Effect node with all effect-specific fields baked into a single object literal,
30
+ * so V8 sees the full hidden class shape at construction time. Effects always run in lazy
31
+ * mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
32
+ * the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
33
+ */
34
+ 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;
21
35
  export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
22
36
  export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
23
37
  export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
@@ -30,25 +44,105 @@ export declare function isEqual<T>(a: T, b: T): boolean;
30
44
  export declare let strictRead: string | false;
31
45
  export declare function setStrictRead(v: string | false): string | false;
32
46
  /**
33
- * Executes `fn` without tracking reactive dependencies.
47
+ * Runs `fn` outside of any reactive tracking — reads inside `fn` will not
48
+ * subscribe the current scope. Returns whatever `fn` returns.
49
+ *
50
+ * Use `untrack` inside a memo or effect when you need to read a signal once
51
+ * without making the surrounding computation depend on its future changes.
34
52
  *
35
- * Pass a `strictReadLabel` string to enable strict-read warnings: any reactive read inside `fn`
36
- * that is not inside a nested tracking scope will log a warning in dev mode.
53
+ * Pass a `strictReadLabel` string to enable a dev-mode warning: any reactive
54
+ * read inside `fn` that isn't inside a nested tracking scope will log a
55
+ * warning naming the label.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * createEffect(
60
+ * () => trigger(), // tracks `trigger` only
61
+ * () => {
62
+ * const snapshot = untrack(() => state); // read once, untracked
63
+ * log(snapshot);
64
+ * }
65
+ * );
66
+ * ```
37
67
  */
38
68
  export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
69
+ /**
70
+ * Bring a computed to a readable state: lazy/disposed nodes are (re)computed;
71
+ * an isPending() probe (`refresh`) additionally pulls the node fully up to
72
+ * date so its status flags reflect the current graph.
73
+ */
74
+ export declare function prepareComputed(comp: Computed<unknown>, refresh: boolean): void;
75
+ /**
76
+ * Sentinel returned by readNodeFast when the plain-signal fast path does not
77
+ * apply and the caller must fall back to the full read().
78
+ */
79
+ export declare const READ_SLOW: unique symbol;
80
+ /**
81
+ * read()'s plain-signal fast path as a standalone entry for hot callers
82
+ * (store traps). Safe to substitute for read() only because the bail
83
+ * conditions mirror read()'s prelude and fast-path guard exactly: the
84
+ * latestRead and pendingCheck windows run side-effectful hooks before the
85
+ * fast path, `_fn` nodes need prepareComputed, and firewall / override /
86
+ * snapshot / transition / lane / dev-strictRead state all take the full
87
+ * resolution. Anything slow returns READ_SLOW; the caller then calls read().
88
+ */
89
+ export declare function readNodeFast<T>(el: Signal<T>): T | typeof READ_SLOW;
39
90
  export declare function read<T>(el: Signal<T> | Computed<T>): T;
40
91
  export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
41
- export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
42
92
  /**
43
- * Update _pendingSignal when pending state changes. When the override clears
44
- * (pending -> not pending), merge the sub-lane into the source's lane so
45
- * isPending effects are blocked until the full scope resolves.
93
+ * Suppresses automatic recomputation of `el` until the scheduler drains. Used
94
+ * when a manual write should win over dependency changes queued in the same
95
+ * tick. The MANUAL_WRITE flag is cleared by the pending-node drain; projection
96
+ * computeds don't commit values, but they still need the same end-of-tick
97
+ * cleanup point.
98
+ */
99
+ export declare function suppressComputedRecompute(el: Computed<unknown>): void;
100
+ /**
101
+ * User-facing setter for the memo form of `createSignal(fn)`. Behaves like
102
+ * `setSignal`, but also cancels any pending recompute of the memo so the
103
+ * manual value wins over a value that would otherwise be produced by an
104
+ * upstream change in the same tick.
105
+ */
106
+ export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
107
+ /**
108
+ * Executes `fn` with the given `owner` set as the current owner. Any reactive
109
+ * primitives (`createSignal`, `createMemo`, `createEffect`, `onCleanup`,
110
+ * `cleanup`, etc.) created inside `fn` are attached to that owner, so they
111
+ * are disposed when the owner is disposed.
112
+ *
113
+ * The classic pattern: capture the current owner with `getOwner()` inside a
114
+ * component, then re-enter it from a callback (event handler, async resolve,
115
+ * setTimeout) so disposables created in the callback get cleaned up with the
116
+ * component.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * function delayed<T>(ms: number, fn: () => T) {
121
+ * const owner = getOwner();
122
+ * setTimeout(() => runWithOwner(owner, fn), ms);
123
+ * }
124
+ * ```
46
125
  */
47
- export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
126
+ export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
48
127
  export declare function staleValues<T>(fn: () => T, set?: boolean): T;
49
- export declare function latest<T>(fn: () => T): T;
50
- export declare function isPending(fn: () => any): boolean;
51
- export declare function refresh<T>(fn: (() => T) | (T & {
52
- [$REFRESH]: any;
53
- })): T;
54
- export declare function isRefreshing(): boolean;
128
+ /**
129
+ * Invalidates one reactive source, forcing it to re-execute even if its inputs
130
+ * haven't changed.
131
+ *
132
+ * Pass either a Solid-created accessor or a projected store created from
133
+ * `createStore(fn, ...)` / `createProjection(...)`. `refresh()` is a
134
+ * write-like invalidation operation: it does not read the target's value, and
135
+ * refreshing a plain signal accessor is a no-op.
136
+ *
137
+ * Use it to invalidate cached async values (e.g. force a re-fetch) without
138
+ * tearing the consumer down.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const user = createMemo(async () => fetch(`/users/${id()}`).then(r => r.json()));
143
+ *
144
+ * // Re-fetch on demand
145
+ * <button onClick={() => refresh(user)}>Reload</button>
146
+ * ```
147
+ */
148
+ export declare function refresh<T>(target: Refreshable<T>): void;
@@ -6,8 +6,8 @@ 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" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY";
10
- export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner";
9
+ export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "REACTIVE_WRITE_IN_OWNED_SCOPE" | "ACTION_CALLED_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "SETTLED_CLEANUP_UNOWNED" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "INVALID_REFRESH_TARGET" | "INVALID_AFFECTS_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC" | "REACTIVITY_HALTED" | "INVARIANT_VIOLATION";
10
+ export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner" | "error";
11
11
  export interface DiagnosticEvent {
12
12
  sequence: number;
13
13
  code: DiagnosticCode;
@@ -39,7 +39,22 @@ export interface Dev {
39
39
  getObservers: typeof getObservers;
40
40
  }
41
41
  export declare const DEV: Dev;
42
+ /**
43
+ * Dev-mode internal consistency check. A failure means the reactive system
44
+ * contradicted itself (not that user code misbehaved) — see
45
+ * INTERNALS-ASYNC-STATE.md for the invariant catalog. Throws under __TEST__
46
+ * so the suite (and fuzzing) treats any violation as a hard failure; logs in
47
+ * dev builds so user apps degrade instead of crashing.
48
+ */
49
+ export declare function assertInvariant(condition: boolean, name: string, message: string): void;
42
50
  export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
51
+ /**
52
+ * Shared strict-read diagnostics for core read() and the store proxy traps.
53
+ * Single source for the message text — the #2897 safeguard parity between
54
+ * memos and stores is exactly these firing identically from both paths.
55
+ */
56
+ export declare function throwPendingUntrackedRead(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "data">>): never;
57
+ export declare function warnStrictReadUntracked(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence">>): void;
43
58
  export declare function registerGraph(value: any, owner: Owner | null): void;
44
59
  export declare function clearSignals(node: Owner): void;
45
60
  export declare function getChildren(owner: Owner): Owner[];
@@ -2,10 +2,10 @@ import type { Computed, NodeOptions, Owner } from "./types.cjs";
2
2
  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
- _cleanup?: () => void;
6
5
  _modified: boolean;
7
6
  _prevValue: T | undefined;
8
7
  _type: number;
8
+ _boundRunEffect?: () => void;
9
9
  }
10
10
  /**
11
11
  * Effects are the leaf nodes of our reactive graph. When their sources change, they are
@@ -18,7 +18,6 @@ export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (
18
18
  schedule?: boolean;
19
19
  }): void;
20
20
  export interface TrackedEffect extends Computed<void> {
21
- _cleanup?: () => void;
22
21
  _modified: boolean;
23
22
  _type: number;
24
23
  _run: () => void;
@@ -1,4 +1,35 @@
1
+ /**
2
+ * Thrown by a tracked read whose value is currently pending (an async memo /
3
+ * `createSignal(asyncFn)` / projection / store derivation that hasn't settled
4
+ * yet). Surfacing through the reactive graph is what suspends the consumer
5
+ * scope — the nearest enclosing `<Loading>` boundary catches the throw and
6
+ * renders its fallback until the source resolves.
7
+ *
8
+ * App code rarely catches this directly; `<Loading>` is the canonical
9
+ * handler. The error type is exposed for advanced cases — e.g. interop layers
10
+ * that bridge Solid's pending-throw protocol to a different async strategy,
11
+ * or tests that want to assert on the suspension shape.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Advanced: distinguish "not ready yet" from a real error in custom
16
+ * // boundary plumbing. App code should rely on `<Loading>` / `<Errored>`.
17
+ * try {
18
+ * const value = readReactiveSource();
19
+ * } catch (err) {
20
+ * if (err instanceof NotReadyError) throw err; // re-throw to suspend
21
+ * reportError(err);
22
+ * }
23
+ * ```
24
+ */
1
25
  export declare class NotReadyError extends Error {
26
+ /**
27
+ * Tags a visibility-only notification on the affects() boundary channel:
28
+ * boundaries update display state from it, but the root queue never
29
+ * registers a reporter — marks are invisible to completion accounting by
30
+ * construction.
31
+ */
32
+ _markVisual?: boolean;
2
33
  source: any;
3
34
  constructor(source: any);
4
35
  }
@@ -6,6 +37,8 @@ export declare class StatusError extends Error {
6
37
  source: any;
7
38
  constructor(source: any, original: any);
8
39
  }
40
+ /** Return the user's error from an internal status wrapper. */
41
+ export declare function unwrapStatusError(error: unknown): unknown;
9
42
  export declare class NoOwnerError extends Error {
10
43
  constructor();
11
44
  }
@@ -11,16 +11,5 @@ export declare let externalSourceConfig: {
11
11
  factory: ExternalSourceFactory;
12
12
  untrack: <T>(fn: () => T) => T;
13
13
  } | null;
14
- /**
15
- * Registers a factory that bridges external reactive systems (e.g. MobX, Vue refs)
16
- * into Solid's tracking graph. Every computation will be wrapped so that the
17
- * external library can track its own dependencies alongside Solid's.
18
- *
19
- * Multiple calls pipe together: each new factory wraps the previous one.
20
- *
21
- * @param config.factory receives `(fn, trigger)` — wrap fn execution in external tracking,
22
- * call trigger when external deps change. Return `{ track, dispose }`.
23
- * @param config.untrack optional wrapper for `untrack` — disables external tracking too.
24
- */
25
14
  export declare function enableExternalSource(config: ExternalSourceConfig): void;
26
15
  export declare function _resetExternalSourceConfig(): void;
@@ -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
- export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
5
+ export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>, pendingObserver?: boolean): void;
@@ -1,4 +1,12 @@
1
1
  import type { Computed } from "./types.cjs";
2
+ /** The queue a node belongs to, picked from its own zombie flag. */
3
+ export declare function queueFor(n: Computed<any>): Heap;
4
+ /**
5
+ * Schedule one subscriber to re-run on the next flush: tracked effects bypass
6
+ * the heap and go directly to their effect queue; everything else is inserted
7
+ * into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
8
+ */
9
+ export declare function enqueueSub(node: Computed<any>): void;
2
10
  export interface Heap {
3
11
  _heap: (Computed<unknown> | undefined)[];
4
12
  _marked: boolean;
@@ -1,12 +1,13 @@
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, refresh, 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";
6
6
  export { handleAsync } from "./async.cjs";
7
+ export { isPending, latest } from "./verdict.cjs";
7
8
  export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.cjs";
8
9
  export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.cjs";
9
10
  export { action } from "./action.cjs";
10
- export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, type IQueue, type QueueCallback } from "./scheduler.cjs";
11
+ export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.cjs";
11
12
  export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.cjs";
12
13
  export * from "./constants.cjs";