@solidjs/signals 2.0.0-rc.7 → 2.0.0-rc.8

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 (117) hide show
  1. package/dist/dev-shared.js +5243 -0
  2. package/dist/dev.attribution.js +2333 -0
  3. package/dist/dev.js +1229 -6834
  4. package/dist/observe/affects.js +127 -0
  5. package/dist/observe/attribution.js +1 -0
  6. package/dist/observe/boundaries.js +586 -0
  7. package/dist/observe/core/action.js +167 -0
  8. package/dist/observe/core/async.js +736 -0
  9. package/dist/observe/core/attribution-hooks.js +60 -0
  10. package/dist/observe/core/attribution.js +2318 -0
  11. package/dist/{types-cjs/core/constants.d.cts → observe/core/constants.js} +129 -73
  12. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  13. package/dist/observe/core/core.js +1289 -0
  14. package/dist/observe/core/dev.js +232 -0
  15. package/dist/observe/core/effect.js +179 -0
  16. package/dist/observe/core/error.js +80 -0
  17. package/dist/observe/core/external.js +98 -0
  18. package/dist/observe/core/graph.js +155 -0
  19. package/dist/observe/core/heap.js +147 -0
  20. package/dist/observe/core/invariants.js +43 -0
  21. package/dist/observe/core/lanes.js +168 -0
  22. package/dist/observe/core/optimistic.js +438 -0
  23. package/dist/observe/core/owner.js +308 -0
  24. package/dist/observe/core/scheduler.js +1190 -0
  25. package/dist/observe/core/verdict.js +551 -0
  26. package/dist/observe/index.js +55 -0
  27. package/dist/observe/map.js +482 -0
  28. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +295 -317
  29. package/dist/observe/store/index.js +38 -0
  30. package/dist/observe/store/next/optimistic.js +651 -0
  31. package/dist/observe/store/next/projection.js +242 -0
  32. package/dist/observe/store/next/reconcile.js +373 -0
  33. package/dist/observe/store/next/store.js +2213 -0
  34. package/dist/observe/store/next/target.js +51 -0
  35. package/dist/observe/store/store.js +323 -0
  36. package/dist/observe/store/storePath.js +103 -0
  37. package/dist/observe/store/utils.js +210 -0
  38. package/dist/prod/attribution.js +32 -0
  39. package/dist/prod/core/action.js +52 -32
  40. package/dist/prod/core/async.js +171 -127
  41. package/dist/prod/core/constants.js +24 -1
  42. package/dist/prod/core/context.js +3 -3
  43. package/dist/prod/core/core.js +434 -291
  44. package/dist/prod/core/effect.js +54 -34
  45. package/dist/prod/core/external.js +2 -2
  46. package/dist/prod/core/graph.js +32 -32
  47. package/dist/prod/core/heap.js +49 -44
  48. package/dist/prod/core/lanes.js +45 -38
  49. package/dist/prod/core/optimistic.js +207 -73
  50. package/dist/prod/core/owner.js +43 -39
  51. package/dist/prod/core/scheduler.js +319 -190
  52. package/dist/prod/core/verdict.js +67 -67
  53. package/dist/prod/index.js +9 -3
  54. package/dist/prod/map.js +292 -141
  55. package/dist/prod/signals.js +7 -10
  56. package/dist/prod/store/next/optimistic.js +140 -125
  57. package/dist/prod/store/next/projection.js +3 -3
  58. package/dist/prod/store/next/reconcile.js +87 -84
  59. package/dist/prod/store/next/store.js +524 -280
  60. package/dist/prod/store/next/target.js +32 -10
  61. package/dist/prod/store/store.js +12 -14
  62. package/dist/prod/store/utils.js +36 -27
  63. package/dist/types/attribution.d.ts +15 -0
  64. package/dist/types/attribution.prod.d.ts +13 -0
  65. package/dist/types/core/async.d.ts +1 -1
  66. package/dist/types/core/attribution-hooks.d.ts +119 -6
  67. package/dist/types/core/attribution.d.ts +208 -53
  68. package/dist/types/core/constants.d.ts +23 -0
  69. package/dist/types/core/core.d.ts +7 -0
  70. package/dist/types/core/dev.d.ts +124 -26
  71. package/dist/types/core/effect.d.ts +8 -1
  72. package/dist/types/core/index.d.ts +2 -1
  73. package/dist/types/core/lanes.d.ts +8 -1
  74. package/dist/types/core/scheduler.d.ts +60 -0
  75. package/dist/types/core/types.d.ts +29 -9
  76. package/dist/types/index.d.ts +9 -2
  77. package/dist/types/map.d.ts +2 -0
  78. package/dist/types/store/index.d.ts +1 -0
  79. package/dist/types/store/next/store.d.ts +5 -0
  80. package/dist/types/store/next/target.d.ts +36 -9
  81. package/dist/types/store/utils.d.ts +7 -0
  82. package/package.json +21 -17
  83. package/dist/node.cjs +0 -10541
  84. package/dist/node.dev.cjs +0 -13724
  85. package/dist/types-cjs/affects.d.cts +0 -47
  86. package/dist/types-cjs/boundaries.d.cts +0 -175
  87. package/dist/types-cjs/core/action.d.cts +0 -64
  88. package/dist/types-cjs/core/async.d.cts +0 -23
  89. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
  90. package/dist/types-cjs/core/attribution.d.cts +0 -495
  91. package/dist/types-cjs/core/core.d.cts +0 -185
  92. package/dist/types-cjs/core/dev.d.cts +0 -136
  93. package/dist/types-cjs/core/effect.d.cts +0 -30
  94. package/dist/types-cjs/core/error.d.cts +0 -56
  95. package/dist/types-cjs/core/external.d.cts +0 -15
  96. package/dist/types-cjs/core/graph.d.cts +0 -28
  97. package/dist/types-cjs/core/heap.d.cts +0 -24
  98. package/dist/types-cjs/core/index.d.cts +0 -13
  99. package/dist/types-cjs/core/invariants.d.cts +0 -59
  100. package/dist/types-cjs/core/lanes.d.cts +0 -54
  101. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  102. package/dist/types-cjs/core/owner.d.cts +0 -124
  103. package/dist/types-cjs/core/scheduler.d.cts +0 -236
  104. package/dist/types-cjs/core/types.d.cts +0 -204
  105. package/dist/types-cjs/core/verdict.d.cts +0 -2
  106. package/dist/types-cjs/index.d.cts +0 -10
  107. package/dist/types-cjs/map.d.cts +0 -69
  108. package/dist/types-cjs/package.json +0 -3
  109. package/dist/types-cjs/store/index.d.cts +0 -18
  110. package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
  111. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  112. package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
  113. package/dist/types-cjs/store/next/store.d.cts +0 -121
  114. package/dist/types-cjs/store/next/target.d.cts +0 -166
  115. package/dist/types-cjs/store/store.d.cts +0 -143
  116. package/dist/types-cjs/store/storePath.d.cts +0 -58
  117. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,136 +0,0 @@
1
- import { type Attribution } from "./attribution.cjs";
2
- import type { Computed, Link, Owner, Signal } from "./types.cjs";
3
- export interface DevHooks {
4
- onOwner?: (owner: Owner) => void;
5
- onGraph?: (value: any, owner: Owner | null) => void;
6
- onUpdate?: () => void;
7
- onStoreNodeUpdate?: (state: any, property: PropertyKey, value: any, prev: any) => void;
8
- }
9
- /**
10
- * `info` is the advisory tier: a structural fact worth surfacing that is not
11
- * presumptively a bug (e.g. a 2-deep sequential fetch chain, which may be an
12
- * intrinsic data dependency). Budget/assertion consumers should treat only
13
- * `warn`/`error` as failures unless they opt in to `info`.
14
- */
15
- export type DiagnosticSeverity = "info" | "warn" | "error";
16
- 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" | "SETTLE_WALK_UNINITIALIZED_SOURCE" | "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" | "HUGE_FAN_OUT" | "HUGE_FAN_IN" | "HOT_SCOPE_RERUNS" | "HOT_SCOPE_TIME" | "WIDE_SCOPE_DEPS" | "UNSTABLE_MEMO_OUTPUT" | "WIDE_WRITE" | "ASYNC_WATERFALL" | "HOT_SCOPE_FANOUT" | "SILENT_HOLD" | "LONG_HOLD" | "EFFECT_WRITES_OWN_SOURCE" | "EFFECT_RELAY_TEAR" | "IMMUTABLE_UPDATE_IN_STORE" | "UNSTABLE_LIST_IDENTITY";
17
- export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner" | "error" | "perf" | "graph"
18
- /** Perceived responsiveness: the runtime behaved correctly but the user saw no feedback. */
19
- | "responsiveness";
20
- /** First warning when a node's live edge count reaches this size. */
21
- export declare const GRAPH_SIZE_WARN_AT = 2000;
22
- /** Repeat the warning at this interval after the first. */
23
- export declare const GRAPH_SIZE_WARN_EVERY = 500;
24
- export interface DiagnosticEvent {
25
- sequence: number;
26
- code: DiagnosticCode;
27
- kind: DiagnosticKind;
28
- severity: DiagnosticSeverity;
29
- message: string;
30
- ownerId?: string;
31
- ownerName?: string;
32
- nodeName?: string;
33
- /**
34
- * Root-first chain of named owners enclosing the subject of the event —
35
- * component roots as `<Name>`, computations by their `name` option (or
36
- * the `effect`/`computed` default) — e.g. `["<App>", "<TodoRow>", "effect"]`.
37
- * Unnamed owners (plain roots) are skipped. Absent when the subject has no
38
- * named owner at all (a top-level scope, or an unowned primitive — which
39
- * is usually the finding itself).
40
- */
41
- ownerPath?: string[];
42
- data?: Record<string, unknown>;
43
- }
44
- export type DiagnosticListener = (event: DiagnosticEvent) => void;
45
- export interface DiagnosticCapture {
46
- readonly events: readonly DiagnosticEvent[];
47
- clear(): void;
48
- stop(): DiagnosticEvent[];
49
- }
50
- export interface Diagnostics {
51
- subscribe(listener: DiagnosticListener): () => void;
52
- capture(): DiagnosticCapture;
53
- /**
54
- * Registers a console footer appended to the first console report of
55
- * each diagnostic code — a discovery pointer to deeper guidance (e.g.
56
- * solid-js registers its shipped repair skill). Reported events carry
57
- * it as trailing lines of the same console entry; events that surface as
58
- * a thrown error instead get it as a follow-up line. Returning undefined
59
- * for an event suppresses the footer. Passing undefined unregisters and
60
- * resets the once-per-code memory.
61
- */
62
- setConsoleFooter(footer: ((event: DiagnosticEvent) => string | undefined) | undefined): void;
63
- }
64
- export interface Dev {
65
- hooks: DevHooks;
66
- diagnostics: Diagnostics;
67
- /** "Why did this run" re-run attribution — see attribution.ts. */
68
- attribution: Attribution;
69
- getChildren: typeof getChildren;
70
- getSignals: typeof getSignals;
71
- getParent: typeof getParent;
72
- getSources: typeof getSources;
73
- getObservers: typeof getObservers;
74
- }
75
- export declare const DEV: Dev;
76
- /**
77
- * Dev-mode internal consistency check. A failure means the reactive system
78
- * contradicted itself (not that user code misbehaved) — see
79
- * INTERNALS-ASYNC-STATE.md for the invariant catalog. Throws under __TEST__
80
- * so the suite (and fuzzing) treats any violation as a hard failure; logs in
81
- * dev builds so user apps degrade instead of crashing.
82
- */
83
- export declare function assertInvariant(condition: boolean, name: string, message: string): void;
84
- /** Anything a diagnostic can be about: an owner (root, computed, effect) or a signal. */
85
- export type DiagnosticSubject = Owner | Signal<any> | Computed<any>;
86
- /**
87
- * Root-first names of the owners enclosing `subject` (inclusive when the
88
- * subject is itself a named owner). Signals hop to their registering owner
89
- * (`_owner`, set by registerGraph). Unnamed owners are skipped so the path
90
- * reads as the component tree plus the scope: `<App> › <TodoRow> › effect`.
91
- */
92
- export declare function ownerPath(subject: DiagnosticSubject | null | undefined): string[] | undefined;
93
- /**
94
- * Records a diagnostic on the structured channel (listeners, captures) and
95
- * returns the entry. `subject` locates it: the current reactive `context` by
96
- * default (right for the synchronous rule checks — they fire inside the
97
- * scope that misbehaved); pass the node for scheduler-time findings whose
98
- * ambient context is the flush, or `null` for events that have no location
99
- * by nature. Console output is a separate step — see `reportDiagnostic`.
100
- */
101
- export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence" | "ownerPath">, subject?: DiagnosticSubject | null | undefined): DiagnosticEvent;
102
- /**
103
- * The console face of a diagnostic — ONE entry per finding: the message, the
104
- * owner path (`in <App> › <TodoRow> › effect`) so a human can locate it, the
105
- * once-per-code footer as trailing lines, and — when the subject is a
106
- * binding effect the rendering runtime tagged — the element it writes, as a
107
- * second console argument (hover highlights it, click jumps to Elements).
108
- * Severity picks the console method. Call sites report the entry
109
- * `emitDiagnostic` returned so the structured and console channels never
110
- * disagree.
111
- */
112
- export declare function reportDiagnostic(entry: DiagnosticEvent): void;
113
- /**
114
- * Shared strict-read diagnostics for core read() and the store proxy traps.
115
- * Single source for the message text — the #2897 safeguard parity between
116
- * memos and stores is exactly these firing identically from both paths.
117
- */
118
- export declare function throwPendingUntrackedRead(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "data" | "ownerPath">>): never;
119
- export declare function warnStrictReadUntracked(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "ownerPath">>): void;
120
- export declare function registerGraph(value: any, owner: Owner | null): void;
121
- export declare function clearSignals(node: Owner): void;
122
- export declare function getChildren(owner: Owner): Owner[];
123
- export declare function getSignals(owner: Owner): any[];
124
- export declare function getParent(owner: Owner): Owner | null;
125
- export declare function getSources(computation: Computed<any>): (Signal<any> | Computed<any>)[];
126
- export declare function getObservers(node: Signal<any> | Computed<any>): Computed<any>[];
127
- /**
128
- * DEV-only: bump live edge counts after a new graph link and warn when a
129
- * node grows an unusually large fan-out (many subscribers on one source) or
130
- * fan-in (many sources on one computation). Repeat-reads that `link()`
131
- * dedupes never reach here. Always-on in dev — unlike the opt-in attribution
132
- * engine, a graph-size pathology should surface without asking.
133
- */
134
- export declare function noteGraphLink(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
135
- /** DEV-only: drop live edge counts when a link is removed. */
136
- export declare function unnoteGraphLink(link: Link): void;
@@ -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,56 +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
- /**
43
- * Rejection value of `until(fn, { timeout })` when the predicate does not turn
44
- * truthy within the window. Inside an `action()`, the rejection is thrown back
45
- * in at the `yield` point — catchable there, or the action fails and its
46
- * optimistic state reverts.
47
- */
48
- export declare class TimeoutError extends Error {
49
- constructor(message?: string);
50
- }
51
- export declare class NoOwnerError extends Error {
52
- constructor();
53
- }
54
- export declare class ContextNotFoundError extends Error {
55
- constructor();
56
- }
@@ -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,28 +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 clearDeps(el: Computed<unknown>): void;
5
- export declare function unobserved(el: Computed<unknown>): void;
6
- /**
7
- * Deferred dormancy for never-observed auto-dispose computeds (#3078).
8
- *
9
- * An untracked top-level read of a subscriber-less observation-lifecycle memo
10
- * used to call unobserved() inline at the end of read(). That kept the leak
11
- * closed (the compute links the memo into its deps' sub lists — without a
12
- * teardown point a never-observed memo is retained by its sources forever;
13
- * upstream alien-signals has exactly this retention), but it made reads
14
- * destructive: each read disposed the node, the next read revived it with a
15
- * full recompute in whatever ambient transition/lane context happened to be
16
- * current, so consecutive reads could return different answers with no write
17
- * in between.
18
- *
19
- * Instead, reads queue the node here and the scheduler sweeps at the top of
20
- * the next flush (before runHeap, so a same-tick dirtying is reclaimed
21
- * instead of recomputed). Reads become idempotent within a tick (the node
22
- * stays alive and serves its cache, uniform with observed memos) while
23
- * reclamation still happens within one microtask — the enqueue site arms
24
- * schedule(), so a flush is guaranteed even when no other work is queued.
25
- */
26
- export declare const dormantNodes: Set<Computed<unknown>>;
27
- export declare function sweepDormant(): void;
28
- export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>, pendingObserver?: boolean): void;
@@ -1,24 +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: inserted into its own
6
- * (zombie-flag-routed) heap with the `_min` cursor pulled down. Tracked
7
- * effects ride the heap too — the heap visit is their (empty) compute phase,
8
- * which hands the callback to the user queue once the pass has committed
9
- * (see GlobalQueue._update, #3291).
10
- */
11
- export declare function enqueueSub(node: Computed<any>): void;
12
- export interface Heap {
13
- _heap: (Computed<unknown> | undefined)[];
14
- _marked: boolean;
15
- _min: number;
16
- _max: number;
17
- }
18
- export declare function increaseHeapSize(n: number, heap: Heap): void;
19
- export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
20
- export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
21
- export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
22
- export declare function markHeap(heap: Heap): void;
23
- export declare function markNode(el: Computed<unknown>, newState?: number): void;
24
- export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;
@@ -1,13 +0,0 @@
1
- export { ContextNotFoundError, NoOwnerError, NotReadyError, TimeoutError } from "./error.cjs";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, installAuthoritativeRead, markRefresh, 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/signals/docs/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,54 +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
- * Is the lane held? `_pendingAsync` records the async the lane OWNS (derived
29
- * under it); the transaction's reporter map records the async a render effect
30
- * OBSERVED pending with no boundary taking it (INV-3, the one registration
31
- * site). A hold needs both — the same rule the transaction itself uses, so a
32
- * memo nobody renders, or one a fallback-showing boundary caught, cannot tear
33
- * a frame and holds nothing (#3289). An orphan lane has no observation record
34
- * and never holds.
35
- */
36
- export declare function laneHeld(lane: OptimisticLane): boolean;
37
- /**
38
- * Merge two lanes when their dependency graphs overlap.
39
- */
40
- export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
41
- /**
42
- * Resolve a node's lane: follow union-find chain, verify active, clear if stale.
43
- */
44
- export declare function resolveLane(el: Signal<any> | Computed<any>): OptimisticLane | undefined;
45
- export declare function resolveTransition(el: Signal<any> | Computed<any>): Transition | null | undefined;
46
- /**
47
- * Check if a node has an active optimistic override.
48
- */
49
- export declare function hasActiveOverride(el: Signal<any> | Computed<any>): boolean;
50
- /**
51
- * Assign or merge a lane onto a node. At convergence points (node already has
52
- * a different active lane), merge unless the node has an active override.
53
- */
54
- export declare function assignOrMergeLane(el: Signal<any> | Computed<any>, 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;