@solidjs/signals 2.0.0-rc.1 → 2.0.0-rc.10

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 (150) hide show
  1. package/dist/dev-shared.js +7138 -0
  2. package/dist/dev.attribution.js +3307 -0
  3. package/dist/dev.js +5691 -4491
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +793 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +849 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +280 -0
  11. package/dist/observe/core/attribution-hooks.js +83 -0
  12. package/dist/observe/core/attribution-queries.js +43 -0
  13. package/dist/observe/core/attribution.js +2904 -0
  14. package/dist/observe/core/constants.js +283 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1999 -0
  17. package/dist/observe/core/dev.js +343 -0
  18. package/dist/observe/core/effect.js +200 -0
  19. package/dist/observe/core/error-hooks.js +71 -0
  20. package/dist/observe/core/error.js +80 -0
  21. package/dist/observe/core/external.js +98 -0
  22. package/dist/observe/core/graph.js +155 -0
  23. package/dist/observe/core/heap.js +147 -0
  24. package/dist/observe/core/invariants.js +45 -0
  25. package/dist/observe/core/lanes.js +205 -0
  26. package/dist/observe/core/optimistic.js +627 -0
  27. package/dist/observe/core/owner.js +353 -0
  28. package/dist/observe/core/scheduler.js +1547 -0
  29. package/dist/observe/core/verdict.js +674 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/observe/signals.js +731 -0
  33. package/dist/observe/store/index.js +44 -0
  34. package/dist/observe/store/next/optimistic.js +717 -0
  35. package/dist/observe/store/next/projection.js +266 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2480 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +331 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1070 -0
  42. package/dist/prod/affects.js +10 -9
  43. package/dist/prod/attribution.js +45 -0
  44. package/dist/prod/boundaries.js +388 -178
  45. package/dist/prod/core/action.js +65 -37
  46. package/dist/prod/core/async.js +378 -163
  47. package/dist/prod/core/attribution-hooks.js +3 -0
  48. package/dist/prod/core/constants.js +186 -1
  49. package/dist/prod/core/context.js +10 -16
  50. package/dist/prod/core/core.js +1546 -416
  51. package/dist/prod/core/dev.js +18 -1
  52. package/dist/prod/core/effect.js +119 -79
  53. package/dist/prod/core/error-hooks.js +71 -0
  54. package/dist/prod/core/error.js +13 -1
  55. package/dist/prod/core/external.js +4 -4
  56. package/dist/prod/core/graph.js +105 -54
  57. package/dist/prod/core/heap.js +72 -65
  58. package/dist/prod/core/invariants.js +3 -2
  59. package/dist/prod/core/lanes.js +117 -52
  60. package/dist/prod/core/optimistic.js +458 -104
  61. package/dist/prod/core/owner.js +131 -84
  62. package/dist/prod/core/scheduler.js +998 -241
  63. package/dist/prod/core/verdict.js +417 -112
  64. package/dist/prod/index.js +20 -8
  65. package/dist/prod/map.js +312 -151
  66. package/dist/prod/signals.js +363 -32
  67. package/dist/prod/store/index.js +2 -0
  68. package/dist/prod/store/next/optimistic.js +530 -197
  69. package/dist/prod/store/next/projection.js +142 -57
  70. package/dist/prod/store/next/reconcile.js +149 -103
  71. package/dist/prod/store/next/store.js +1470 -346
  72. package/dist/prod/store/next/target.js +40 -9
  73. package/dist/prod/store/store.js +23 -19
  74. package/dist/prod/store/utils.js +997 -130
  75. package/dist/types/attribution.d.ts +19 -0
  76. package/dist/types/attribution.prod.d.ts +22 -0
  77. package/dist/types/boundaries.d.ts +78 -5
  78. package/dist/types/core/action.d.ts +12 -5
  79. package/dist/types/core/async.d.ts +3 -1
  80. package/dist/types/core/attribution-costs.d.ts +35 -0
  81. package/dist/types/core/attribution-feedback.d.ts +133 -0
  82. package/dist/types/core/attribution-hooks.d.ts +304 -0
  83. package/dist/types/core/attribution-queries.d.ts +24 -0
  84. package/dist/types/core/attribution.d.ts +892 -0
  85. package/dist/types/core/constants.d.ts +179 -0
  86. package/dist/types/core/core.d.ts +299 -25
  87. package/dist/types/core/dev.d.ts +421 -8
  88. package/dist/types/core/effect.d.ts +8 -1
  89. package/dist/types/core/error-hooks.d.ts +71 -0
  90. package/dist/types/core/error.d.ts +9 -0
  91. package/dist/types/core/graph.d.ts +23 -0
  92. package/dist/types/core/heap.d.ts +5 -3
  93. package/dist/types/core/index.d.ts +6 -3
  94. package/dist/types/core/invariants.d.ts +5 -1
  95. package/dist/types/core/lanes.d.ts +51 -19
  96. package/dist/types/core/owner.d.ts +15 -3
  97. package/dist/types/core/scheduler.d.ts +248 -1
  98. package/dist/types/core/types.d.ts +124 -41
  99. package/dist/types/index.d.ts +18 -5
  100. package/dist/types/map.d.ts +2 -0
  101. package/dist/types/signals.d.ts +145 -13
  102. package/dist/types/store/index.d.ts +7 -6
  103. package/dist/types/store/next/optimistic.d.ts +18 -13
  104. package/dist/types/store/next/projection.d.ts +5 -2
  105. package/dist/types/store/next/reconcile.d.ts +7 -0
  106. package/dist/types/store/next/store.d.ts +83 -11
  107. package/dist/types/store/next/target.d.ts +108 -11
  108. package/dist/types/store/store.d.ts +20 -11
  109. package/dist/types/store/utils.d.ts +188 -0
  110. package/package.json +31 -26
  111. package/dist/node.cjs +0 -8137
  112. package/dist/types/store/optimistic.d.ts +0 -45
  113. package/dist/types/store/projection.d.ts +0 -70
  114. package/dist/types/store/reconcile.d.ts +0 -46
  115. package/dist/types-cjs/affects.d.cts +0 -47
  116. package/dist/types-cjs/boundaries.d.cts +0 -175
  117. package/dist/types-cjs/core/action.d.cts +0 -64
  118. package/dist/types-cjs/core/async.d.cts +0 -21
  119. package/dist/types-cjs/core/constants.d.cts +0 -71
  120. package/dist/types-cjs/core/core.d.cts +0 -156
  121. package/dist/types-cjs/core/dev.d.cts +0 -64
  122. package/dist/types-cjs/core/effect.d.cts +0 -30
  123. package/dist/types-cjs/core/error.d.cts +0 -47
  124. package/dist/types-cjs/core/external.d.cts +0 -15
  125. package/dist/types-cjs/core/graph.d.cts +0 -5
  126. package/dist/types-cjs/core/heap.d.cts +0 -22
  127. package/dist/types-cjs/core/index.d.cts +0 -13
  128. package/dist/types-cjs/core/invariants.d.cts +0 -59
  129. package/dist/types-cjs/core/lanes.d.cts +0 -56
  130. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  131. package/dist/types-cjs/core/owner.d.cts +0 -124
  132. package/dist/types-cjs/core/scheduler.d.cts +0 -172
  133. package/dist/types-cjs/core/types.d.cts +0 -148
  134. package/dist/types-cjs/core/verdict.d.cts +0 -2
  135. package/dist/types-cjs/index.d.cts +0 -10
  136. package/dist/types-cjs/map.d.cts +0 -69
  137. package/dist/types-cjs/package.json +0 -3
  138. package/dist/types-cjs/signals.d.cts +0 -624
  139. package/dist/types-cjs/store/index.d.cts +0 -19
  140. package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
  141. package/dist/types-cjs/store/next/projection.d.cts +0 -24
  142. package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
  143. package/dist/types-cjs/store/next/store.d.cts +0 -71
  144. package/dist/types-cjs/store/next/target.d.cts +0 -99
  145. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  146. package/dist/types-cjs/store/projection.d.cts +0 -70
  147. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  148. package/dist/types-cjs/store/store.d.cts +0 -138
  149. package/dist/types-cjs/store/storePath.d.cts +0 -58
  150. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,156 +0,0 @@
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 const REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE: string;
6
- export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE: string;
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;
14
- export declare let stale: boolean;
15
- export declare let pendingCheckActive: boolean;
16
- export declare let latestReadActive: boolean;
17
- export declare let context: Owner | null;
18
- export declare let currentOptimisticLane: OptimisticLane | null;
19
- export declare let snapshotCaptureActive: boolean;
20
- export declare let snapshotSources: Set<any> | null;
21
- export declare function setSnapshotCapture(active: boolean): void;
22
- export declare function markSnapshotScope(owner: Owner): void;
23
- export declare function releaseSnapshotScope(owner: Owner): void;
24
- export declare function clearSnapshots(): void;
25
- export declare function recompute(el: Computed<any>, create?: boolean): void;
26
- export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
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;
35
- export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
36
- export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
37
- export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
38
- export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
39
- export declare function isEqual<T>(a: T, b: T): boolean;
40
- /**
41
- * When set to a component name string, any reactive read that is not inside a nested tracking
42
- * scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
43
- */
44
- export declare let strictRead: string | false;
45
- export declare function setStrictRead(v: string | false): string | false;
46
- /**
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.
52
- *
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
- * ```
67
- */
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;
90
- export declare function read<T>(el: Signal<T> | Computed<T>): T;
91
- /**
92
- * Store-rewrite setter guard: the rewrite parks writes in a pending backing
93
- * (no setSignal at write time), so the owned-scope write protection must
94
- * fire at the setter entry instead. Mirrors setSignal's guard condition
95
- * minus the node-specific exemptions (ownedWrite/firewall), which don't
96
- * apply to plain store setters.
97
- */
98
- export declare function devGuardStoreSetterWrite(): void;
99
- export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
100
- /**
101
- * Suppresses automatic recomputation of `el` until the scheduler drains. Used
102
- * when a manual write should win over dependency changes queued in the same
103
- * tick. The MANUAL_WRITE flag is cleared by the pending-node drain; projection
104
- * computeds don't commit values, but they still need the same end-of-tick
105
- * cleanup point.
106
- */
107
- export declare function suppressComputedRecompute(el: Computed<unknown>): void;
108
- /**
109
- * User-facing setter for the memo form of `createSignal(fn)`. Behaves like
110
- * `setSignal`, but also cancels any pending recompute of the memo so the
111
- * manual value wins over a value that would otherwise be produced by an
112
- * upstream change in the same tick.
113
- */
114
- export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
115
- /**
116
- * Executes `fn` with the given `owner` set as the current owner. Any reactive
117
- * primitives (`createSignal`, `createMemo`, `createEffect`, `onCleanup`,
118
- * `cleanup`, etc.) created inside `fn` are attached to that owner, so they
119
- * are disposed when the owner is disposed.
120
- *
121
- * The classic pattern: capture the current owner with `getOwner()` inside a
122
- * component, then re-enter it from a callback (event handler, async resolve,
123
- * setTimeout) so disposables created in the callback get cleaned up with the
124
- * component.
125
- *
126
- * @example
127
- * ```ts
128
- * function delayed<T>(ms: number, fn: () => T) {
129
- * const owner = getOwner();
130
- * setTimeout(() => runWithOwner(owner, fn), ms);
131
- * }
132
- * ```
133
- */
134
- export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
135
- export declare function staleValues<T>(fn: () => T, set?: boolean): T;
136
- /**
137
- * Invalidates one reactive source, forcing it to re-execute even if its inputs
138
- * haven't changed.
139
- *
140
- * Pass either a Solid-created accessor or a projected store created from
141
- * `createStore(fn, ...)` / `createProjection(...)`. `refresh()` is a
142
- * write-like invalidation operation: it does not read the target's value, and
143
- * refreshing a plain signal accessor is a no-op.
144
- *
145
- * Use it to invalidate cached async values (e.g. force a re-fetch) without
146
- * tearing the consumer down.
147
- *
148
- * @example
149
- * ```ts
150
- * const user = createMemo(async () => fetch(`/users/${id()}`).then(r => r.json()));
151
- *
152
- * // Re-fetch on demand
153
- * <button onClick={() => refresh(user)}>Reload</button>
154
- * ```
155
- */
156
- export declare function refresh<T>(target: Refreshable<T>): void;
@@ -1,64 +0,0 @@
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" | "REACTIVE_WRITE_IN_OWNED_SCOPE" | "ACTION_CALLED_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "SETTLED_CLEANUP_UNOWNED" | "FLUSH_IN_EFFECT_CALLBACK" | "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
- 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
- /**
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;
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;
58
- export declare function registerGraph(value: any, owner: Owner | null): void;
59
- export declare function clearSignals(node: Owner): void;
60
- export declare function getChildren(owner: Owner): Owner[];
61
- export declare function getSignals(owner: Owner): any[];
62
- export declare function getParent(owner: Owner): Owner | null;
63
- export declare function getSources(computation: Computed<any>): (Signal<any> | Computed<any>)[];
64
- export declare function getObservers(node: Signal<any> | Computed<any>): Computed<any>[];
@@ -1,30 +0,0 @@
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
- _modified: boolean;
6
- _prevValue: T | undefined;
7
- _type: number;
8
- _boundRunEffect?: () => void;
9
- }
10
- /**
11
- * Effects are the leaf nodes of our reactive graph. When their sources change, they are
12
- * automatically added to the queue of effects to re-execute, which will cause them to fetch their
13
- * sources and recompute
14
- */
15
- 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> & {
16
- user?: boolean;
17
- defer?: boolean;
18
- schedule?: boolean;
19
- }): void;
20
- export interface TrackedEffect extends Computed<void> {
21
- _modified: boolean;
22
- _type: number;
23
- _run: () => void;
24
- }
25
- /**
26
- * Internal tracked effect - bypasses heap, goes directly to effect queue.
27
- * Runs as a leaf owner: child primitives and onCleanup are forbidden (__DEV__ throws).
28
- * Uses stale reads.
29
- */
30
- export declare function trackedEffect(fn: () => void | (() => void), options?: NodeOptions<any>): void;
@@ -1,47 +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
- /**
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;
33
- source: any;
34
- constructor(source: any);
35
- }
36
- export declare class StatusError extends Error {
37
- source: any;
38
- constructor(source: any, original: any);
39
- }
40
- /** Return the user's error from an internal status wrapper. */
41
- export declare function unwrapStatusError(error: unknown): unknown;
42
- export declare class NoOwnerError extends Error {
43
- constructor();
44
- }
45
- export declare class ContextNotFoundError extends Error {
46
- constructor();
47
- }
@@ -1,15 +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
- export declare function enableExternalSource(config: ExternalSourceConfig): void;
15
- export declare function _resetExternalSourceConfig(): void;
@@ -1,5 +0,0 @@
1
- import type { Computed, Link, Signal } from "./types.cjs";
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>, pendingObserver?: boolean): void;
@@ -1,22 +0,0 @@
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;
10
- export interface Heap {
11
- _heap: (Computed<unknown> | undefined)[];
12
- _marked: boolean;
13
- _min: number;
14
- _max: number;
15
- }
16
- export declare function increaseHeapSize(n: number, heap: Heap): void;
17
- export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
18
- export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
19
- export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
20
- export declare function markHeap(heap: Heap): void;
21
- export declare function markNode(el: Computed<unknown>, newState?: number): void;
22
- export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;
@@ -1,13 +0,0 @@
1
- export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.cjs";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
3
- export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.cjs";
4
- export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.cjs";
5
- export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.cjs";
6
- export { handleAsync } from "./async.cjs";
7
- export { isPending, latest } from "./verdict.cjs";
8
- export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.cjs";
9
- export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.cjs";
10
- export { action } from "./action.cjs";
11
- export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.cjs";
12
- export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.cjs";
13
- export * from "./constants.cjs";
@@ -1,59 +0,0 @@
1
- import type { OptimisticLane } from "./lanes.cjs";
2
- import type { Computed, Signal } from "./types.cjs";
3
- /**
4
- * Test-mode invariant checks for the async/transition/lane machinery.
5
- * Catalog and rationale: packages/solid-signals/INTERNALS-ASYNC-STATE.md.
6
- *
7
- * These are implementation self-consistency checks, not semantic rules: a
8
- * violation means the reactive system contradicted itself.
9
- *
10
- * They are gated on `__TEST__` (not just `__DEV__`): the per-write Set
11
- * tracking and per-flush quiescence sweep are too expensive for shipped dev
12
- * builds and for benchmarks (they showed up as a 5-21% hit across the
13
- * CodSpeed suite when they ran under `__DEV__`). Call sites stay `__DEV__`
14
- * guarded so production tree-shakes the calls; each entry point here
15
- * early-returns unless `__TEST__` is set, so dev builds pay only a no-op
16
- * call. The test suite (vitest run) defines `__TEST__: true`; benchmark mode
17
- * defines `__TEST__: false`.
18
- */
19
- type AnyNode = Signal<any> | Computed<any>;
20
- /** Wired by core.ts at module init to avoid import cycles. */
21
- export declare const InvariantHooks: {
22
- pendingProbeActive: (() => boolean) | null;
23
- /** Fresh oracle for what an isPending companion SHOULD read right now. */
24
- computePendingState: ((node: AnyNode) => boolean) | null;
25
- };
26
- export declare function devTrackHeldPending(node: AnyNode): void;
27
- export declare function devTrackCompanionOwner(node: AnyNode): void;
28
- export declare function devTrackOptimistic(node: AnyNode): void;
29
- export declare function devTrackAffects(node: AnyNode): void;
30
- /**
31
- * Open/close the sanctioned registration window. Call sites are `__DEV__`
32
- * guarded (no prod cost); the code inside the window must not throw.
33
- */
34
- export declare function beginAsyncReporterWrites(): void;
35
- export declare function endAsyncReporterWrites(): void;
36
- export declare function createAsyncReporters(): Map<Computed<any>, Set<Computed<any>>>;
37
- /**
38
- * INV-2: a node with an *active* override must be registered for reversion in
39
- * the queue's or a transition's `_optimisticNodes`. An unregistered active
40
- * override would survive transition completion forever. Runs at the end of
41
- * every flush (not just quiescence — the invariant holds mid-transition).
42
- * (There is no revert-target requirement: authoritative values commit
43
- * silently into `_value` under the override mask — A17 — so reverting is
44
- * just dropping the override.)
45
- */
46
- export declare function devCheckActiveOverrides(isRegisteredForRevert: (node: AnyNode) => boolean): void;
47
- /** INV-1: an isPending() probe must never leak past its own call. */
48
- export declare function devCheckFlushStart(): void;
49
- /** INV-5: a merged lane's work moved to its root on merge and must stay empty. */
50
- export declare function devCheckMergedLaneEmpty(lane: OptimisticLane): void;
51
- export declare function devCensusCompanions(isQueuedForCommit?: (node: AnyNode) => boolean): void;
52
- /**
53
- * Quiescence checks. Run only when the system is fully drained: nothing
54
- * scheduled, no active/stashed transitions, no live lanes. At that point no
55
- * transition-scoped state may survive, and the lazily-created companions must
56
- * agree with a fresh computation of their owner's state.
57
- */
58
- export declare function devCheckQuiescent(isQueuedForCommit: (node: AnyNode) => boolean): void;
59
- export {};
@@ -1,56 +0,0 @@
1
- import { type QueueCallback, type Transition } from "./scheduler.cjs";
2
- import type { Computed, Signal } from "./types.cjs";
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
- _overrideValue?: any;
41
- _overrideOwner?: Transition | null;
42
- }): Transition | null | undefined;
43
- /**
44
- * Check if a node has an active optimistic override.
45
- */
46
- export declare function hasActiveOverride(el: {
47
- _overrideValue?: any;
48
- }): boolean;
49
- /**
50
- * Assign or merge a lane onto a node. At convergence points (node already has
51
- * a different active lane), merge unless the node has an active override.
52
- */
53
- export declare function assignOrMergeLane(el: {
54
- _optimisticLane?: OptimisticLane;
55
- _overrideValue?: any;
56
- }, sourceLane: OptimisticLane): void;
@@ -1,6 +0,0 @@
1
- /**
2
- * Installs the engine's hooks. Idempotent; called by every module that can
3
- * create optimistic state (verdict.ts at module top level, createOptimistic
4
- * and createOptimisticStore at first call) BEFORE any optimistic node exists.
5
- */
6
- export declare function installOptimisticEngine(): void;
@@ -1,124 +0,0 @@
1
- import type { Computed, Disposable, Owner, Root } from "./types.cjs";
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
- * The id a freshly-created node inherits: an explicit `options.id` wins;
14
- * transparent nodes share their parent's id; otherwise the parent's next
15
- * child id is consumed (or `undefined` outside an id-carrying tree).
16
- */
17
- export declare function inheritId(options: {
18
- id?: string;
19
- } | undefined, transparent: boolean, parent: Owner | null | undefined): string | undefined;
20
- /**
21
- * Returns the *next* child id for `owner` without consuming it. Used by
22
- * hydration plumbing to peek at the id a future child will receive.
23
- *
24
- * @internal
25
- */
26
- export declare function peekNextChildId(owner: Owner): string;
27
- /**
28
- * Returns the currently-tracking observer (the computation that subscribes to
29
- * reactive reads at this point), or `null` if reads here would be untracked.
30
- * Used by reactive primitives that need to know whether they're inside a
31
- * tracking scope. App code rarely needs this — see `getOwner()` for the
32
- * lifecycle owner instead.
33
- *
34
- * @example
35
- * ```ts
36
- * // Library predicate: only register a hot-path subscription when the
37
- * // caller is inside a tracking scope (memo / effect compute / JSX).
38
- * function trackIfTracked(source: () => unknown) {
39
- * if (getObserver()) source();
40
- * }
41
- * ```
42
- */
43
- export declare function getObserver(): Owner | null;
44
- /**
45
- * Returns the current reactive **owner** — the lifecycle node that the next
46
- * `cleanup()` / `onCleanup()` / `createSignal()` etc. will be attached to.
47
- *
48
- * Returns `null` if called outside any owner. Capture the owner with
49
- * `getOwner()` and re-enter it later with `runWithOwner(owner, fn)` to attach
50
- * disposables created from a callback (event handler, async resolution, etc.)
51
- * back to a component's lifecycle.
52
- *
53
- * @example
54
- * ```ts
55
- * function defer<T>(fn: () => T) {
56
- * const owner = getOwner();
57
- * queueMicrotask(() => runWithOwner(owner, fn));
58
- * }
59
- * ```
60
- */
61
- export declare function getOwner(): Owner | null;
62
- /**
63
- * Low-level: registers `fn` as a disposal callback on the current owner.
64
- * Most code should use `onCleanup()` from `solid-js`, which adds dev-mode
65
- * checks. `cleanup()` is the unchecked primitive used by internals.
66
- */
67
- export declare function cleanup(fn: Disposable): Disposable;
68
- /**
69
- * Returns `true` if the owner has been disposed (or marked zombie pending
70
- * disposal). Pair with a captured owner to bail out of late callbacks whose
71
- * surrounding component already unmounted.
72
- *
73
- * @example
74
- * ```ts
75
- * function onSettleSafe(fn: () => void) {
76
- * const owner = getOwner();
77
- * queueMicrotask(() => {
78
- * if (owner && isDisposed(owner)) return; // component unmounted; skip
79
- * runWithOwner(owner, fn);
80
- * });
81
- * }
82
- * ```
83
- */
84
- export declare function isDisposed(node: Owner): boolean;
85
- /**
86
- * Creates a fresh owner attached as a child of the current owner (or as a
87
- * detached root if there is none). Used by framework internals to group
88
- * cleanups; app code should use `createRoot()` (host a reactive scope outside
89
- * a component) or `runWithOwner()` (re-enter a captured owner).
90
- *
91
- * @internal
92
- */
93
- export declare function createOwner(options?: {
94
- id?: string;
95
- transparent?: boolean;
96
- }): Root;
97
- /**
98
- * Creates a detached reactive root. The callback receives a `dispose()`
99
- * function which, when called, tears down every signal, memo, effect, and
100
- * `onCleanup` registered inside the root.
101
- *
102
- * Use this to host long-lived reactive scopes outside of a component (custom
103
- * controllers, app bootstrapping, tests). Inside a component, prefer
104
- * letting Solid's component lifecycle own things.
105
- *
106
- * @example
107
- * ```ts
108
- * const dispose = createRoot(dispose => {
109
- * const [n, setN] = createSignal(0);
110
- * createEffect(() => n(), value => console.log(value));
111
- * setInterval(() => setN(x => x + 1), 1000);
112
- * return dispose;
113
- * });
114
- *
115
- * // Later, to tear everything down:
116
- * dispose();
117
- * ```
118
- *
119
- * @description https://docs.solidjs.com/reference/reactive-utilities/create-root
120
- */
121
- export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
122
- id?: string;
123
- transparent?: boolean;
124
- }): T;