@solidjs/signals 2.0.0-beta.14 → 2.0.0-beta.16

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 (87) hide show
  1. package/README.md +2 -3
  2. package/dist/dev.js +966 -550
  3. package/dist/node.cjs +2153 -1821
  4. package/dist/prod.js +1848 -1530
  5. package/dist/types/boundaries.d.ts +3 -3
  6. package/dist/types/core/async.d.ts +1 -0
  7. package/dist/types/core/core.d.ts +27 -15
  8. package/dist/types/core/dev.d.ts +10 -2
  9. package/dist/types/core/effect.d.ts +1 -3
  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 +4 -4
  18. package/dist/types/store/store.d.ts +29 -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 +27 -15
  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/graph.d.cts +1 -1
  25. package/dist/types-cjs/core/index.d.cts +2 -2
  26. package/dist/types-cjs/core/invariants.d.cts +49 -0
  27. package/dist/types-cjs/core/scheduler.d.cts +8 -0
  28. package/dist/types-cjs/core/types.d.cts +19 -0
  29. package/dist/types-cjs/index.d.cts +1 -1
  30. package/dist/types-cjs/signals.d.cts +39 -2
  31. package/dist/types-cjs/store/projection.d.cts +4 -4
  32. package/dist/types-cjs/store/store.d.cts +29 -1
  33. package/package.json +1 -1
  34. package/dist/types/src/boundaries.d.ts +0 -173
  35. package/dist/types/src/core/action.d.ts +0 -35
  36. package/dist/types/src/core/async.d.ts +0 -6
  37. package/dist/types/src/core/constants.d.ts +0 -51
  38. package/dist/types/src/core/context.d.ts +0 -36
  39. package/dist/types/src/core/core.d.ts +0 -174
  40. package/dist/types/src/core/dev.d.ts +0 -49
  41. package/dist/types/src/core/effect.d.ts +0 -32
  42. package/dist/types/src/core/error.d.ts +0 -38
  43. package/dist/types/src/core/external.d.ts +0 -45
  44. package/dist/types/src/core/graph.d.ts +0 -5
  45. package/dist/types/src/core/heap.d.ts +0 -14
  46. package/dist/types/src/core/index.d.ts +0 -12
  47. package/dist/types/src/core/lanes.d.ts +0 -54
  48. package/dist/types/src/core/owner.d.ts +0 -116
  49. package/dist/types/src/core/scheduler.d.ts +0 -122
  50. package/dist/types/src/core/types.d.ts +0 -85
  51. package/dist/types/src/index.d.ts +0 -9
  52. package/dist/types/src/map.d.ts +0 -53
  53. package/dist/types/src/signals.d.ts +0 -512
  54. package/dist/types/src/store/index.d.ts +0 -9
  55. package/dist/types/src/store/optimistic.d.ts +0 -45
  56. package/dist/types/src/store/projection.d.ts +0 -66
  57. package/dist/types/src/store/reconcile.d.ts +0 -23
  58. package/dist/types/src/store/store.d.ts +0 -125
  59. package/dist/types/src/store/storePath.d.ts +0 -58
  60. package/dist/types/src/store/utils.d.ts +0 -114
  61. package/dist/types-cjs/src/boundaries.d.cts +0 -173
  62. package/dist/types-cjs/src/core/action.d.cts +0 -35
  63. package/dist/types-cjs/src/core/async.d.cts +0 -6
  64. package/dist/types-cjs/src/core/constants.d.cts +0 -51
  65. package/dist/types-cjs/src/core/context.d.cts +0 -36
  66. package/dist/types-cjs/src/core/core.d.cts +0 -174
  67. package/dist/types-cjs/src/core/dev.d.cts +0 -49
  68. package/dist/types-cjs/src/core/effect.d.cts +0 -32
  69. package/dist/types-cjs/src/core/error.d.cts +0 -38
  70. package/dist/types-cjs/src/core/external.d.cts +0 -45
  71. package/dist/types-cjs/src/core/graph.d.cts +0 -5
  72. package/dist/types-cjs/src/core/heap.d.cts +0 -14
  73. package/dist/types-cjs/src/core/index.d.cts +0 -12
  74. package/dist/types-cjs/src/core/lanes.d.cts +0 -54
  75. package/dist/types-cjs/src/core/owner.d.cts +0 -116
  76. package/dist/types-cjs/src/core/scheduler.d.cts +0 -122
  77. package/dist/types-cjs/src/core/types.d.cts +0 -85
  78. package/dist/types-cjs/src/index.d.cts +0 -9
  79. package/dist/types-cjs/src/map.d.cts +0 -53
  80. package/dist/types-cjs/src/signals.d.cts +0 -512
  81. package/dist/types-cjs/src/store/index.d.cts +0 -9
  82. package/dist/types-cjs/src/store/optimistic.d.cts +0 -45
  83. package/dist/types-cjs/src/store/projection.d.cts +0 -66
  84. package/dist/types-cjs/src/store/reconcile.d.cts +0 -23
  85. package/dist/types-cjs/src/store/store.d.cts +0 -125
  86. package/dist/types-cjs/src/store/storePath.d.cts +0 -58
  87. package/dist/types-cjs/src/store/utils.d.cts +0 -114
@@ -1,174 +0,0 @@
1
- import { type Refreshable } from "./constants.js";
2
- import { type OptimisticLane } from "./lanes.js";
3
- import type { Computed, FirewallSignal, NodeOptions, Owner, Signal } from "./types.js";
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;
@@ -1,49 +0,0 @@
1
- import type { Computed, Owner, Signal } from "./types.js";
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>[];
@@ -1,32 +0,0 @@
1
- import type { Computed, NodeOptions, Owner } from "./types.js";
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;
@@ -1,38 +0,0 @@
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
- */
25
- export declare class NotReadyError extends Error {
26
- source: any;
27
- constructor(source: any);
28
- }
29
- export declare class StatusError extends Error {
30
- source: any;
31
- constructor(source: any, original: any);
32
- }
33
- export declare class NoOwnerError extends Error {
34
- constructor();
35
- }
36
- export declare class ContextNotFoundError extends Error {
37
- constructor();
38
- }
@@ -1,45 +0,0 @@
1
- export type ExternalSourceFactory = (fn: (prev: any) => any, trigger: () => void) => ExternalSource;
2
- export interface ExternalSource {
3
- track: (prev: any) => any;
4
- dispose: () => void;
5
- }
6
- export interface ExternalSourceConfig {
7
- factory: ExternalSourceFactory;
8
- untrack?: <T>(fn: () => T) => T;
9
- }
10
- export declare let externalSourceConfig: {
11
- factory: ExternalSourceFactory;
12
- untrack: <T>(fn: () => T) => T;
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
- * @example
26
- * ```ts
27
- * // Bridge an external "subscribe / notify" library into Solid's graph.
28
- * // `factory` wraps every Solid compute so the external library can attach
29
- * // its own dependency tracker; `trigger` re-runs the compute on external
30
- * // change. `untrack` mirrors Solid's `untrack()` into the external library
31
- * // so that reads inside `untrack(...)` don't get tracked twice.
32
- * enableExternalSource({
33
- * factory: (compute, trigger) => {
34
- * const sub = externalLib.subscribe(trigger);
35
- * return {
36
- * track: prev => externalLib.run(() => compute(prev)),
37
- * dispose: () => sub.unsubscribe()
38
- * };
39
- * },
40
- * untrack: fn => externalLib.untracked(fn)
41
- * });
42
- * ```
43
- */
44
- export declare function enableExternalSource(config: ExternalSourceConfig): void;
45
- export declare function _resetExternalSourceConfig(): void;
@@ -1,5 +0,0 @@
1
- import type { Computed, Link, Signal } from "./types.js";
2
- export declare function unlinkSubs(link: Link): Link | null;
3
- export declare function trimStaleDeps(el: Computed<any>): void;
4
- export declare function unobserved(el: Computed<unknown>): void;
5
- export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
@@ -1,14 +0,0 @@
1
- import type { Computed } from "./types.js";
2
- export interface Heap {
3
- _heap: (Computed<unknown> | undefined)[];
4
- _marked: boolean;
5
- _min: number;
6
- _max: number;
7
- }
8
- export declare function increaseHeapSize(n: number, heap: Heap): void;
9
- export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
10
- export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
11
- export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
12
- export declare function markHeap(heap: Heap): void;
13
- export declare function markNode(el: Computed<unknown>, newState?: number): void;
14
- export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;
@@ -1,12 +0,0 @@
1
- export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, isPending, latest, refresh, isRefreshing, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.js";
3
- export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.js";
4
- export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.js";
5
- export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
6
- export { handleAsync } from "./async.js";
7
- export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.js";
8
- export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.js";
9
- export { action } from "./action.js";
10
- export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, type IQueue, type QueueCallback } from "./scheduler.js";
11
- export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.js";
12
- export * from "./constants.js";
@@ -1,54 +0,0 @@
1
- import { type QueueCallback, type Transition } from "./scheduler.js";
2
- import type { Computed, Signal } from "./types.js";
3
- /**
4
- * OptimisticLane represents the context for a single optimistic write.
5
- * Each optimistic signal creates its own lane. Lanes merge when their
6
- * dependency graphs overlap.
7
- */
8
- export interface OptimisticLane {
9
- _source: Signal<any>;
10
- _pendingAsync: Set<Computed<any>>;
11
- _effectQueues: [QueueCallback[], QueueCallback[]];
12
- _mergedInto: OptimisticLane | null;
13
- _transition: Transition | null;
14
- _parentLane: OptimisticLane | null;
15
- }
16
- export declare const signalLanes: WeakMap<Signal<any>, OptimisticLane>;
17
- export declare const activeLanes: Set<OptimisticLane>;
18
- /**
19
- * Get an existing lane for a signal or create a new one.
20
- * Reuses lane for multiple writes to the same signal.
21
- */
22
- export declare function getOrCreateLane(signal: Signal<any>): OptimisticLane;
23
- /**
24
- * Union-find: find the root lane.
25
- */
26
- export declare function findLane(lane: OptimisticLane): OptimisticLane;
27
- /**
28
- * Merge two lanes when their dependency graphs overlap.
29
- */
30
- export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
31
- /**
32
- * Resolve a node's lane: follow union-find chain, verify active, clear if stale.
33
- */
34
- export declare function resolveLane(el: {
35
- _optimisticLane?: OptimisticLane;
36
- }): OptimisticLane | undefined;
37
- export declare function resolveTransition(el: {
38
- _optimisticLane?: OptimisticLane;
39
- _transition?: Transition | null;
40
- }): Transition | null | undefined;
41
- /**
42
- * Check if a node has an active optimistic override.
43
- */
44
- export declare function hasActiveOverride(el: {
45
- _overrideValue?: any;
46
- }): boolean;
47
- /**
48
- * Assign or merge a lane onto a node. At convergence points (node already has
49
- * a different active lane), merge unless the node has an active override.
50
- */
51
- export declare function assignOrMergeLane(el: {
52
- _optimisticLane?: OptimisticLane;
53
- _overrideValue?: any;
54
- }, sourceLane: OptimisticLane): void;
@@ -1,116 +0,0 @@
1
- import type { Computed, Disposable, Owner, Root } from "./types.js";
2
- export declare function markDisposal(el: Owner): void;
3
- export declare function dispose(node: Computed<unknown>): void;
4
- export declare function disposeChildren(node: Owner, self?: boolean, zombie?: boolean): void;
5
- /**
6
- * Allocates and returns the next stable child id for `owner`. Used by
7
- * hydration plumbing and `createUniqueId`. Not part of the user-facing API.
8
- *
9
- * @internal
10
- */
11
- export declare function getNextChildId(owner: Owner): string;
12
- /**
13
- * Returns the *next* child id for `owner` without consuming it. Used by
14
- * hydration plumbing to peek at the id a future child will receive.
15
- *
16
- * @internal
17
- */
18
- export declare function peekNextChildId(owner: Owner): string;
19
- /**
20
- * Returns the currently-tracking observer (the computation that subscribes to
21
- * reactive reads at this point), or `null` if reads here would be untracked.
22
- * Used by reactive primitives that need to know whether they're inside a
23
- * tracking scope. App code rarely needs this — see `getOwner()` for the
24
- * lifecycle owner instead.
25
- *
26
- * @example
27
- * ```ts
28
- * // Library predicate: only register a hot-path subscription when the
29
- * // caller is inside a tracking scope (memo / effect compute / JSX).
30
- * function trackIfTracked(source: () => unknown) {
31
- * if (getObserver()) source();
32
- * }
33
- * ```
34
- */
35
- export declare function getObserver(): Owner | null;
36
- /**
37
- * Returns the current reactive **owner** — the lifecycle node that the next
38
- * `cleanup()` / `onCleanup()` / `createSignal()` etc. will be attached to.
39
- *
40
- * Returns `null` if called outside any owner. Capture the owner with
41
- * `getOwner()` and re-enter it later with `runWithOwner(owner, fn)` to attach
42
- * disposables created from a callback (event handler, async resolution, etc.)
43
- * back to a component's lifecycle.
44
- *
45
- * @example
46
- * ```ts
47
- * function defer<T>(fn: () => T) {
48
- * const owner = getOwner();
49
- * queueMicrotask(() => runWithOwner(owner, fn));
50
- * }
51
- * ```
52
- */
53
- export declare function getOwner(): Owner | null;
54
- /**
55
- * Low-level: registers `fn` as a disposal callback on the current owner.
56
- * Most code should use `onCleanup()` from `solid-js`, which adds dev-mode
57
- * checks. `cleanup()` is the unchecked primitive used by internals.
58
- */
59
- export declare function cleanup(fn: Disposable): Disposable;
60
- /**
61
- * Returns `true` if the owner has been disposed (or marked zombie pending
62
- * disposal). Pair with a captured owner to bail out of late callbacks whose
63
- * surrounding component already unmounted.
64
- *
65
- * @example
66
- * ```ts
67
- * function onSettleSafe(fn: () => void) {
68
- * const owner = getOwner();
69
- * queueMicrotask(() => {
70
- * if (owner && isDisposed(owner)) return; // component unmounted; skip
71
- * runWithOwner(owner, fn);
72
- * });
73
- * }
74
- * ```
75
- */
76
- export declare function isDisposed(node: Owner): boolean;
77
- /**
78
- * Creates a fresh owner attached as a child of the current owner (or as a
79
- * detached root if there is none). Used by framework internals to group
80
- * cleanups; app code should use `createRoot()` (host a reactive scope outside
81
- * a component) or `runWithOwner()` (re-enter a captured owner).
82
- *
83
- * @internal
84
- */
85
- export declare function createOwner(options?: {
86
- id?: string;
87
- transparent?: boolean;
88
- }): Root;
89
- /**
90
- * Creates a detached reactive root. The callback receives a `dispose()`
91
- * function which, when called, tears down every signal, memo, effect, and
92
- * `onCleanup` registered inside the root.
93
- *
94
- * Use this to host long-lived reactive scopes outside of a component (custom
95
- * controllers, app bootstrapping, tests). Inside a component, prefer
96
- * letting Solid's component lifecycle own things.
97
- *
98
- * @example
99
- * ```ts
100
- * const dispose = createRoot(dispose => {
101
- * const [n, setN] = createSignal(0);
102
- * createEffect(() => n(), value => console.log(value));
103
- * setInterval(() => setN(x => x + 1), 1000);
104
- * return dispose;
105
- * });
106
- *
107
- * // Later, to tear everything down:
108
- * dispose();
109
- * ```
110
- *
111
- * @description https://docs.solidjs.com/reference/reactive-utilities/create-root
112
- */
113
- export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
114
- id?: string;
115
- transparent?: boolean;
116
- }): T;
@@ -1,122 +0,0 @@
1
- import { type Heap } from "./heap.js";
2
- import { activeLanes, assignOrMergeLane, findLane } from "./lanes.js";
3
- import type { Computed, Signal } from "./types.js";
4
- export { activeLanes, assignOrMergeLane, findLane };
5
- export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.js";
6
- export declare const dirtyQueue: Heap;
7
- export declare const zombieQueue: Heap;
8
- export declare let clock: number;
9
- export declare let activeTransition: Transition | null;
10
- export declare let projectionWriteActive: boolean;
11
- export declare let _hitUnhandledAsync: boolean;
12
- export declare function registerTransientStoreNode(node: Signal<any>): void;
13
- export declare function resetUnhandledAsync(): void;
14
- /**
15
- * Toggles the dev-mode "must be inside a `<Loading>` boundary" enforcement
16
- * window. Only `render()` calls this — wrapping the initial mount so that a
17
- * top-level uncaught async read surfaces the diagnostic. Not part of the
18
- * user-facing API.
19
- *
20
- * @internal
21
- */
22
- export declare function enforceLoadingBoundary(enabled: boolean): void;
23
- export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
24
- export declare function setProjectionWriteActive(value: boolean): void;
25
- export declare function setTrackedQueueCallback(value: boolean): void;
26
- export type QueueCallback = (type: number) => void;
27
- type QueueStub = {
28
- _queues: [QueueCallback[], QueueCallback[]];
29
- _children: QueueStub[];
30
- };
31
- type OptimisticNode = Signal<any> | Computed<any>;
32
- export interface Transition {
33
- _time: number;
34
- _asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
35
- _pendingNodes: Signal<any>[];
36
- _optimisticNodes: OptimisticNode[];
37
- _optimisticStores: Set<any>;
38
- _actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
39
- _queueStash: QueueStub;
40
- _done: boolean | Transition;
41
- _gatedSubs: Set<Computed<any>>;
42
- }
43
- export declare function schedule(): void;
44
- export interface IQueue {
45
- enqueue(type: number, fn: QueueCallback): void;
46
- run(type: number): boolean | void;
47
- addChild(child: IQueue): void;
48
- removeChild(child: IQueue): void;
49
- created: number;
50
- notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
51
- stashQueues(stub: QueueStub): void;
52
- restoreQueues(stub: QueueStub): void;
53
- _parent: IQueue | null;
54
- }
55
- export declare class Queue implements IQueue {
56
- _parent: IQueue | null;
57
- _queues: [QueueCallback[], QueueCallback[]];
58
- _children: IQueue[];
59
- created: number;
60
- addChild(child: IQueue): void;
61
- removeChild(child: IQueue): void;
62
- notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
63
- run(type: number): void;
64
- enqueue(type: number, fn: QueueCallback): void;
65
- stashQueues(stub: QueueStub): void;
66
- restoreQueues(stub: QueueStub): void;
67
- }
68
- export declare class GlobalQueue extends Queue {
69
- _running: boolean;
70
- _pendingNode: Signal<any> | null;
71
- _pendingNodes: Signal<any>[];
72
- _optimisticNodes: OptimisticNode[];
73
- _optimisticStores: Set<any>;
74
- static _update: (el: Computed<unknown>) => void;
75
- static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
76
- static _runEffect: (el: Computed<unknown>) => void;
77
- static _clearOptimisticStore: ((store: any) => void) | null;
78
- flush(): void;
79
- notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
80
- initTransition(transition?: Transition | null): void;
81
- }
82
- export declare function queuePendingNode(node: Signal<any>): void;
83
- export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
84
- export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
85
- export declare function trackOptimisticStore(store: any): void;
86
- export declare const globalQueue: GlobalQueue;
87
- /**
88
- * Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
89
- * flush scope before draining the queue.
90
- *
91
- * Reactive updates are normally batched onto the microtask queue, so multiple
92
- * writes in a row collapse into a single update pass. Call `flush()` when you
93
- * need to *observe* the result of those writes synchronously — most commonly
94
- * in tests, but also at the boundary of imperative integration code. Pass a
95
- * callback when the writes themselves should bypass microtask scheduling and
96
- * drain synchronously when the callback returns.
97
- *
98
- * @example
99
- * ```ts
100
- * const [count, setCount] = createSignal(0);
101
- * const doubled = createMemo(() => count() * 2);
102
- *
103
- * setCount(5);
104
- * flush();
105
- * expect(doubled()).toBe(10);
106
- *
107
- * flush(() => setCount(6));
108
- * expect(doubled()).toBe(12);
109
- *
110
- * // Nested flushes drain at each level:
111
- * flush(() => {
112
- * setCount(7);
113
- * flush(() => setCount(8)); // inner drain — effects fire here
114
- * // outer continues with up-to-date state
115
- * });
116
- * ```
117
- */
118
- export declare function flush(): void;
119
- export declare function flush<T>(fn: () => T): T;
120
- export declare function currentTransition(transition: Transition): Transition;
121
- export declare function setActiveTransition(transition: Transition | null): void;
122
- export declare function runInTransition<T>(transition: Transition, fn: () => T): T;