@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.20

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 (198) hide show
  1. package/dist/dev-shared.js +6505 -0
  2. package/dist/dev.attribution.js +3484 -0
  3. package/dist/dev.js +10227 -9508
  4. package/dist/observe/affects-marks.js +86 -0
  5. package/dist/observe/affects.js +112 -0
  6. package/dist/observe/attribution.js +7 -0
  7. package/dist/observe/boundaries.js +696 -0
  8. package/dist/observe/core/action.js +182 -0
  9. package/dist/observe/core/async.js +824 -0
  10. package/dist/observe/core/attribution-costs.js +66 -0
  11. package/dist/observe/core/attribution-feedback.js +280 -0
  12. package/dist/observe/core/attribution-hooks.js +83 -0
  13. package/dist/observe/core/attribution-queries.js +43 -0
  14. package/dist/observe/core/attribution.js +3079 -0
  15. package/dist/observe/core/constants.js +269 -0
  16. package/dist/observe/core/context.js +63 -0
  17. package/dist/observe/core/copies.js +10 -0
  18. package/dist/observe/core/core.js +1707 -0
  19. package/dist/observe/core/dev.js +394 -0
  20. package/dist/observe/core/effect.js +193 -0
  21. package/dist/observe/core/error-hooks.js +71 -0
  22. package/dist/observe/core/error.js +82 -0
  23. package/dist/observe/core/external.js +97 -0
  24. package/dist/observe/core/graph.js +162 -0
  25. package/dist/observe/core/heap.js +124 -0
  26. package/dist/observe/core/identities.js +62 -0
  27. package/dist/observe/core/invariants.js +12 -0
  28. package/dist/observe/core/lanes.js +972 -0
  29. package/dist/observe/core/owner.js +371 -0
  30. package/dist/observe/core/scheduler.js +1157 -0
  31. package/dist/observe/core/truth.js +47 -0
  32. package/dist/observe/core/verdict.js +470 -0
  33. package/dist/observe/deferred.js +186 -0
  34. package/dist/observe/flatten.js +79 -0
  35. package/dist/observe/from.js +248 -0
  36. package/dist/observe/index.js +71 -0
  37. package/dist/observe/map.js +593 -0
  38. package/dist/observe/reveal.js +212 -0
  39. package/dist/observe/signals.js +717 -0
  40. package/dist/observe/store/affects.js +142 -0
  41. package/dist/observe/store/edges.js +39 -0
  42. package/dist/observe/store/hooks.js +16 -0
  43. package/dist/observe/store/index.js +47 -0
  44. package/dist/observe/store/optimistic.js +713 -0
  45. package/dist/observe/store/projection.js +345 -0
  46. package/dist/observe/store/reconcile.js +281 -0
  47. package/dist/observe/store/store.js +2127 -0
  48. package/dist/observe/store/storePath.js +103 -0
  49. package/dist/observe/store/target.js +46 -0
  50. package/dist/observe/store/types.js +83 -0
  51. package/dist/observe/store/utils.js +1063 -0
  52. package/dist/prod/affects-marks.js +86 -0
  53. package/dist/prod/affects.js +98 -112
  54. package/dist/prod/attribution.js +45 -0
  55. package/dist/prod/boundaries.js +578 -468
  56. package/dist/prod/core/action.js +92 -59
  57. package/dist/prod/core/async.js +522 -336
  58. package/dist/prod/core/attribution-hooks.js +3 -0
  59. package/dist/prod/core/constants.js +168 -44
  60. package/dist/prod/core/context.js +12 -16
  61. package/dist/prod/core/copies.js +10 -0
  62. package/dist/prod/core/core.js +1345 -627
  63. package/dist/prod/core/dev.js +123 -1
  64. package/dist/prod/core/effect.js +113 -80
  65. package/dist/prod/core/error-hooks.js +71 -0
  66. package/dist/prod/core/error.js +18 -4
  67. package/dist/prod/core/external.js +6 -7
  68. package/dist/prod/core/graph.js +119 -72
  69. package/dist/prod/core/heap.js +85 -109
  70. package/dist/prod/core/identities.js +62 -0
  71. package/dist/prod/core/invariants.js +1 -32
  72. package/dist/prod/core/lanes.js +931 -132
  73. package/dist/prod/core/owner.js +192 -129
  74. package/dist/prod/core/scheduler.js +948 -642
  75. package/dist/prod/core/truth.js +47 -0
  76. package/dist/prod/core/verdict.js +409 -420
  77. package/dist/prod/deferred.js +184 -0
  78. package/dist/prod/flatten.js +77 -0
  79. package/dist/prod/from.js +248 -0
  80. package/dist/prod/index.js +40 -16
  81. package/dist/prod/map.js +481 -211
  82. package/dist/prod/reveal.js +212 -0
  83. package/dist/prod/signals.js +401 -84
  84. package/dist/prod/store/affects.js +142 -0
  85. package/dist/prod/store/edges.js +39 -0
  86. package/dist/prod/store/hooks.js +16 -0
  87. package/dist/prod/store/index.js +27 -18
  88. package/dist/prod/store/optimistic.js +707 -0
  89. package/dist/prod/store/projection.js +331 -0
  90. package/dist/prod/store/reconcile.js +281 -0
  91. package/dist/prod/store/store.js +1952 -267
  92. package/dist/prod/store/storePath.js +1 -1
  93. package/dist/prod/store/target.js +43 -0
  94. package/dist/prod/store/types.js +83 -0
  95. package/dist/prod/store/utils.js +997 -138
  96. package/dist/types/affects-marks.d.ts +14 -0
  97. package/dist/types/affects.d.ts +12 -30
  98. package/dist/types/attribution.d.ts +19 -0
  99. package/dist/types/attribution.prod.d.ts +22 -0
  100. package/dist/types/boundaries.d.ts +99 -124
  101. package/dist/types/carved.d.ts +1 -0
  102. package/dist/types/core/action.d.ts +23 -9
  103. package/dist/types/core/async.d.ts +34 -6
  104. package/dist/types/core/attribution-costs.d.ts +35 -0
  105. package/dist/types/core/attribution-feedback.d.ts +133 -0
  106. package/dist/types/core/attribution-hooks.d.ts +307 -8
  107. package/dist/types/core/attribution-queries.d.ts +24 -0
  108. package/dist/types/core/attribution.d.ts +802 -72
  109. package/dist/types/core/constants.d.ts +195 -38
  110. package/dist/types/core/copies.d.ts +54 -0
  111. package/dist/types/core/core.d.ts +295 -65
  112. package/dist/types/core/dev.d.ts +509 -22
  113. package/dist/types/core/effect.d.ts +1 -1
  114. package/dist/types/core/error-hooks.d.ts +71 -0
  115. package/dist/types/core/error.d.ts +18 -1
  116. package/dist/types/core/graph.d.ts +40 -1
  117. package/dist/types/core/heap.d.ts +5 -5
  118. package/dist/types/core/identities.d.ts +17 -0
  119. package/dist/types/core/index.d.ts +11 -7
  120. package/dist/types/core/invariants.d.ts +1 -26
  121. package/dist/types/core/lanes.d.ts +74 -43
  122. package/dist/types/core/owner.d.ts +27 -9
  123. package/dist/types/core/scheduler.d.ts +353 -102
  124. package/dist/types/core/truth.d.ts +18 -0
  125. package/dist/types/core/types.d.ts +97 -71
  126. package/dist/types/core/verdict.d.ts +35 -0
  127. package/dist/types/deferred.d.ts +28 -0
  128. package/dist/types/flatten.d.ts +8 -0
  129. package/dist/types/from.d.ts +47 -0
  130. package/dist/types/index.d.ts +33 -7
  131. package/dist/types/map.d.ts +4 -2
  132. package/dist/types/reveal.d.ts +19 -0
  133. package/dist/types/signals.d.ts +196 -45
  134. package/dist/types/store/affects.d.ts +12 -0
  135. package/dist/types/store/edges.d.ts +9 -0
  136. package/dist/types/store/hooks.d.ts +62 -0
  137. package/dist/types/store/index.d.ts +42 -15
  138. package/dist/types/store/optimistic.d.ts +24 -45
  139. package/dist/types/store/projection.d.ts +17 -68
  140. package/dist/types/store/reconcile.d.ts +3 -46
  141. package/dist/types/store/store.d.ts +133 -136
  142. package/dist/types/store/storePath.d.ts +1 -1
  143. package/dist/types/store/target.d.ts +166 -0
  144. package/dist/types/store/types.d.ts +105 -0
  145. package/dist/types/store/utils.d.ts +188 -0
  146. package/package.json +31 -26
  147. package/dist/node.cjs +0 -8745
  148. package/dist/prod/core/optimistic.js +0 -265
  149. package/dist/prod/store/next/optimistic.js +0 -385
  150. package/dist/prod/store/next/projection.js +0 -172
  151. package/dist/prod/store/next/reconcile.js +0 -331
  152. package/dist/prod/store/next/store.js +0 -1499
  153. package/dist/prod/store/next/target.js +0 -20
  154. package/dist/types/core/optimistic.d.ts +0 -6
  155. package/dist/types/store/next/optimistic.d.ts +0 -20
  156. package/dist/types/store/next/projection.d.ts +0 -8
  157. package/dist/types/store/next/reconcile.d.ts +0 -3
  158. package/dist/types/store/next/store.d.ts +0 -77
  159. package/dist/types/store/next/target.d.ts +0 -117
  160. package/dist/types-cjs/affects.d.cts +0 -47
  161. package/dist/types-cjs/boundaries.d.cts +0 -175
  162. package/dist/types-cjs/core/action.d.cts +0 -64
  163. package/dist/types-cjs/core/async.d.cts +0 -21
  164. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -52
  165. package/dist/types-cjs/core/attribution.d.cts +0 -186
  166. package/dist/types-cjs/core/constants.d.cts +0 -97
  167. package/dist/types-cjs/core/context.d.cts +0 -36
  168. package/dist/types-cjs/core/core.d.cts +0 -163
  169. package/dist/types-cjs/core/dev.d.cts +0 -81
  170. package/dist/types-cjs/core/effect.d.cts +0 -30
  171. package/dist/types-cjs/core/error.d.cts +0 -47
  172. package/dist/types-cjs/core/external.d.cts +0 -15
  173. package/dist/types-cjs/core/graph.d.cts +0 -6
  174. package/dist/types-cjs/core/heap.d.cts +0 -22
  175. package/dist/types-cjs/core/index.d.cts +0 -13
  176. package/dist/types-cjs/core/invariants.d.cts +0 -59
  177. package/dist/types-cjs/core/lanes.d.cts +0 -44
  178. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  179. package/dist/types-cjs/core/owner.d.cts +0 -124
  180. package/dist/types-cjs/core/scheduler.d.cts +0 -180
  181. package/dist/types-cjs/core/types.d.cts +0 -192
  182. package/dist/types-cjs/core/verdict.d.cts +0 -2
  183. package/dist/types-cjs/index.d.cts +0 -10
  184. package/dist/types-cjs/map.d.cts +0 -69
  185. package/dist/types-cjs/package.json +0 -3
  186. package/dist/types-cjs/signals.d.cts +0 -624
  187. package/dist/types-cjs/store/index.d.cts +0 -19
  188. package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
  189. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  190. package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
  191. package/dist/types-cjs/store/next/store.d.cts +0 -77
  192. package/dist/types-cjs/store/next/target.d.cts +0 -117
  193. package/dist/types-cjs/store/optimistic.d.cts +0 -45
  194. package/dist/types-cjs/store/projection.d.cts +0 -70
  195. package/dist/types-cjs/store/reconcile.d.cts +0 -46
  196. package/dist/types-cjs/store/store.d.cts +0 -138
  197. package/dist/types-cjs/store/storePath.d.cts +0 -58
  198. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,186 +0,0 @@
1
- import type { Computed } from "./types.cjs";
2
- /**
3
- * Dev-mode "why did this run" attribution.
4
- *
5
- * The runtime already knows the full dependency set of every scope; this
6
- * module surfaces it. Every value commit stamps its node with a ChangeRecord
7
- * (a write, an async landing, a refresh() invalidation, or a derived change
8
- * whose `causes` chain back to root writes). When a computation re-executes,
9
- * the deps whose stamp is newer than the node's last run are its causes, so
10
- * each re-run can be explained as a chain down to the originating write:
11
- *
12
- * [why-run] effect "docTitle" ran (run 4)
13
- * ← memo "userLabel" changed (#6)
14
- * ← signal "notifications" write (#5) 2 → 3
15
- *
16
- * This module is the attribution ENGINE: all semantics live here, and it is
17
- * decoupled from the core. `enable()` installs it into the core's narrow
18
- * dev-only hook points (attribution-hooks.ts); core's only obligation is to
19
- * call those hooks with true facts. Disabled cost is one null check per hook
20
- * site; prod builds fold the sites out entirely. The same hook surface is the
21
- * intended substrate for external consumers (devtools) — one mechanism, two
22
- * front-ends.
23
- */
24
- export type ChangeKind = "write" | "derived" | "async" | "refresh";
25
- export interface ChangeRecord {
26
- /** Global monotonic change sequence — orders causes across the app. */
27
- seq: number;
28
- kind: ChangeKind;
29
- name: string;
30
- /** Short previews of the value transition (writes only). */
31
- prev?: string;
32
- value?: string;
33
- /** First user frames of the triggering write's stack (opt-in). */
34
- stack?: string[];
35
- /** For derived changes: the upstream changes that produced this one. */
36
- causes?: ChangeRecord[];
37
- }
38
- export interface RerunEvent {
39
- /** Global monotonic run sequence. */
40
- run: number;
41
- /** How many times this node has re-run since attribution was enabled. */
42
- nodeRuns: number;
43
- nodeKind: "effect" | "memo";
44
- nodeName: string;
45
- node: Computed<any>;
46
- /**
47
- * The deps that changed since this node's previous run. Empty means the
48
- * re-run was not triggered by a tracked value change (creation-adjacent
49
- * pull, error retry, or a cause this prototype does not stamp yet).
50
- */
51
- causes: ChangeRecord[];
52
- /** Dependency count after this run. */
53
- depCount: number;
54
- /** Names of deps this run subscribed to that the previous run did not. */
55
- depsAdded: string[];
56
- /** Names of deps the previous run had that this run dropped. */
57
- depsRemoved: string[];
58
- /** Wall time of this run excluding nested recomputes (ms). */
59
- selfMs: number;
60
- /** Wall time of this run including nested recomputes (ms). */
61
- totalMs: number;
62
- /**
63
- * Whether the run committed a changed value. A PLAIN memo run with
64
- * `changed: false` was pure waste — the equality cutoff stopped it from
65
- * notifying anyone; an effect run with `changed: false` computed without
66
- * firing its effect phase. Summed as `wastedMs` in costs() (plain,
67
- * non-held runs only — see `phase`).
68
- */
69
- changed: boolean;
70
- /**
71
- * Which posture this run executed under. "optimistic" = under an
72
- * optimistic lane (overlay recompute); "transition" = a transition was
73
- * active or owns the node (the run may be replayed/settled later);
74
- * "plain" = an ordinary committed run. Overlay runs are real work (they
75
- * count toward time budgets) but are never blamed as waste, and costs()
76
- * reports their time separately as `overlayMs`.
77
- */
78
- phase: "plain" | "transition" | "optimistic";
79
- /**
80
- * The changed value was held in `_pendingValue` (a transition hold) rather
81
- * than committed directly; its reveal happens on the transition's own
82
- * schedule. Held runs are excluded from waste accounting.
83
- */
84
- held: boolean;
85
- }
86
- export interface AttributionOptions {
87
- /** Pretty-print each re-run to the console (default true). */
88
- log?: boolean;
89
- /** Capture the user stack frame of each write — slow (default false). */
90
- stacks?: boolean;
91
- /** Ring-buffer size for `history()` (default 200). */
92
- historyLimit?: number;
93
- /**
94
- * Hot-scope warning: emit a diagnostic when one scope re-runs `count`
95
- * times within `windowMs` (default 120 runs / 1000ms — deliberately above
96
- * animation-frame cadence, so a legitimate rAF-driven scope at 60/s does
97
- * not cry wolf). `false` disables.
98
- */
99
- hotRuns?: {
100
- count: number;
101
- windowMs: number;
102
- } | false;
103
- /**
104
- * Wide-scope warning: emit a diagnostic when a scope's dependency count
105
- * reaches this (default 30) — the coarse-read / helper-leak signature.
106
- * Re-warns only if the count then grows by another 50%. `false` disables.
107
- */
108
- wideDeps?: number | false;
109
- /**
110
- * Time-budget warning: emit a diagnostic when one scope's summed self-time
111
- * inside `windowMs` exceeds `budgetMs` (default 8ms / 1000ms — half a frame
112
- * spent in one scope). Unlike `hotRuns` this catches the few-but-expensive
113
- * scope that run counts miss. `false` disables.
114
- */
115
- hotTime?: {
116
- budgetMs: number;
117
- windowMs: number;
118
- } | false;
119
- /**
120
- * Unstable-output warning: emit a diagnostic when a memo commits a
121
- * referentially-new but shallowly-equivalent plain object/array on this
122
- * many consecutive runs (default 4). Such a memo's equality gate never
123
- * closes — every subscriber re-runs on every upstream change — which makes
124
- * it a fan-out amplifier that is otherwise only findable by profiling.
125
- * `false` disables.
126
- */
127
- unstableMemos?: number | false;
128
- /**
129
- * Written-fan-out warning: emit a diagnostic when a committed root
130
- * invalidation (write, refresh, async landing) reaches a node with at
131
- * least this many subscribers (default 250). Complements the always-on
132
- * HUGE_FAN_OUT graph-size warning, specced against it deliberately:
133
- * HUGE_FAN_OUT fires at LINK time from GRAPH_SIZE_WARN_AT (2000) up —
134
- * static structure so large it warns even if never written — while this
135
- * fires at WRITE time from a much lower bar, because fan-out only costs
136
- * anything when the node actually changes. Once per node, re-warning only
137
- * on 2x subscriber growth, so the two never spam the same node. `false`
138
- * disables.
139
- */
140
- wideWrites?: number | false;
141
- }
142
- export interface ScopeCost {
143
- name: string;
144
- kind: "effect" | "memo";
145
- runs: number;
146
- selfMs: number;
147
- /**
148
- * Self-time of PLAIN, non-held runs that produced an unchanged value —
149
- * the recoverable number. Overlay runs (optimistic/transition) are never
150
- * counted here: an optimistic recompute landing back on the committed
151
- * value is the mechanism working, not waste.
152
- */
153
- wastedMs: number;
154
- /** Self-time spent in optimistic/transition (overlay) runs. */
155
- overlayMs: number;
156
- }
157
- export interface WriteCost {
158
- /** Root cause name (a signal write, async landing, or refresh target). */
159
- name: string;
160
- /** Number of downstream re-runs this root triggered. */
161
- runs: number;
162
- /** Summed self-time of every downstream re-run it caused. */
163
- downstreamMs: number;
164
- }
165
- export declare function formatRerun(event: RerunEvent): string;
166
- export interface Attribution {
167
- enable(opts?: AttributionOptions): void;
168
- disable(): void;
169
- subscribe(listener: (event: RerunEvent) => void): () => void;
170
- history(): readonly RerunEvent[];
171
- /** Re-run history for one node — pass a memo/effect accessor or raw node. */
172
- why(target: unknown): RerunEvent[];
173
- /** Current dependency names of one scope — the devtools subscription view. */
174
- subscriptions(target: unknown): string[];
175
- /**
176
- * Aggregated cost tables since enable(): `scopes` ranked by self-time
177
- * (with `wastedMs` = time spent on unchanged-value runs), `writes` ranked
178
- * by total downstream re-run time each root write caused.
179
- */
180
- costs(): {
181
- scopes: ScopeCost[];
182
- writes: WriteCost[];
183
- };
184
- format: typeof formatRerun;
185
- }
186
- export declare const attribution: Attribution;
@@ -1,97 +0,0 @@
1
- export declare const REACTIVE_NONE = 0;
2
- export declare const REACTIVE_CHECK: number;
3
- export declare const REACTIVE_DIRTY: number;
4
- export declare const REACTIVE_RECOMPUTING_DEPS: number;
5
- export declare const REACTIVE_IN_HEAP: number;
6
- export declare const REACTIVE_IN_HEAP_HEIGHT: number;
7
- export declare const REACTIVE_ZOMBIE: number;
8
- export declare const REACTIVE_DISPOSED: number;
9
- export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
10
- export declare const REACTIVE_SNAPSHOT_STALE: number;
11
- export declare const REACTIVE_LAZY: number;
12
- export declare const REACTIVE_MANUAL_WRITE: number;
13
- /**
14
- * The pending recompute is a re-ask of the same question: `refresh()` dirtied
15
- * the node while no tracked input changed value. Cleared whenever a real
16
- * value-change notification arrives (`insertSubs`), and consumed by
17
- * `recompute` into the node's `_reask` classification — a quiet (re-ask)
18
- * pending window does not read as pending (question-scoped pending model).
19
- */
20
- export declare const REACTIVE_REASK: number;
21
- /**
22
- * A dependency write landed while this subscriber was mid-recompute — a
23
- * nested pull committed beneath one of its reads (#3037). The heap refuses
24
- * RECOMPUTING nodes, so recompute's tail consumes this latch and reschedules:
25
- * values the pass read before the nested commit are stale. Only set for
26
- * links validated this pass (gen-current): a write to an untouched link is
27
- * either re-read later in the pass (fresh) or trimmed with it (not a dep).
28
- */
29
- export declare const REACTIVE_MISSED_WAKE: number;
30
- export declare const CONFIG_OWNED_WRITE: number;
31
- export declare const CONFIG_NO_SNAPSHOT: number;
32
- export declare const CONFIG_TRANSPARENT: number;
33
- export declare const CONFIG_IN_SNAPSHOT_SCOPE: number;
34
- export declare const CONFIG_CHILDREN_FORBIDDEN: number;
35
- export declare const CONFIG_AUTO_DISPOSE: number;
36
- export declare const CONFIG_SYNC: number;
37
- export declare const CONFIG_OPTIMISTIC: number;
38
- export declare const CONFIG_HAS_COMPANIONS: number;
39
- export declare const CONFIG_HAS_SNAPSHOT: number;
40
- export declare const CONFIG_HAS_LANE: number;
41
- /** Set on a FIREWALL computed when any of its child signals creates an
42
- * isPending()/latest() companion. Gates the post-recompute child-companion
43
- * walk (#3038): a store computed's `_child` chain holds one node per
44
- * materialized leaf, so walking it unconditionally makes every update cost
45
- * O(all leaves ever read). Sticky — set at companion creation, never
46
- * cleared; sync-only apps never set it and never pay the walk. */
47
- export declare const CONFIG_CHILD_COMPANIONS: number;
48
- /** Set on a computed when its first firewall child signal is installed
49
- * (projection machinery). Gates markNode's firewall-children walk with one
50
- * masked read of the always-present _config — the walk's old `_child` read
51
- * moved into the cold extension (§12), and an unconditional `_x` deref per
52
- * marked node measurably taxed the propagation hot path (diamond -22%). */
53
- export declare const CONFIG_FW_CHILDREN: number;
54
- export declare const STATUS_NONE = 0;
55
- export declare const STATUS_PENDING: number;
56
- export declare const STATUS_ERROR: number;
57
- export declare const STATUS_UNINITIALIZED: number;
58
- export declare const EFFECT_PURE = 0;
59
- export declare const EFFECT_RENDER = 1;
60
- export declare const EFFECT_USER = 2;
61
- export declare const EFFECT_TRACKED = 3;
62
- export declare const NOT_PENDING: {};
63
- export declare const NO_SNAPSHOT: {};
64
- /**
65
- * Stand-in stored in `_overrideValue` for an optimistic write of literal
66
- * `undefined` (#2898). The slot doubles as the optimistic-node brand
67
- * (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
68
- * would erase the node's optimistic identity: the write turns invisible and
69
- * follow-up writes route off the optimistic path and commit permanently.
70
- * Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
71
- * via `visibleOverrideValue`; slot identity tests stay raw.
72
- */
73
- export declare const OVERRIDE_UNDEFINED: {};
74
- /** Unwrap an active override's stored value for surfacing to readers (#2898). */
75
- export declare function unwrapOverride<T = any>(v: unknown): T;
76
- export declare const STORE_SNAPSHOT_PROPS = "sp";
77
- export declare const SUPPORTS_PROXY: boolean;
78
- export declare const defaultContext: {};
79
- /**
80
- * Brand symbol used by `Refreshable<T>` values (projection stores, async
81
- * memos) to expose their underlying computation to `refresh()`. Not part of
82
- * the user-facing API.
83
- *
84
- * @internal
85
- */
86
- export declare const $REFRESH: unique symbol;
87
- /**
88
- * Brand applied to values that participate in the `refresh()` re-run protocol.
89
- * Accessors receive this handle internally; projected stores expose it through
90
- * their public return type so user-defined hooks that wrap `createOptimisticStore`
91
- * / `createProjection` / projection-form `createStore` can have their return
92
- * types inferred without leaking the internal `$REFRESH` symbol into public type
93
- * signatures (TS4058).
94
- */
95
- export type Refreshable<T> = T & {
96
- readonly [$REFRESH]: any;
97
- };
@@ -1,36 +0,0 @@
1
- import type { Owner } from "./types.cjs";
2
- export interface Context<T> {
3
- readonly id: symbol;
4
- readonly defaultValue: T | undefined;
5
- }
6
- export type ContextRecord = Record<string | symbol, unknown>;
7
- /**
8
- * Context provides a form of dependency injection. It is used to save from needing to pass
9
- * data as props through intermediate components. This function creates a new context object
10
- * that can be used with `getContext` and `setContext`.
11
- *
12
- * A default value can be provided here which will be used when a specific value is not provided
13
- * via a `setContext` call.
14
- */
15
- export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
16
- /**
17
- * Low-level owner-targeted context read. The user-facing read API is
18
- * `useContext` (in `solid-js`), which wraps this primitive. Exposed here for
19
- * cross-package wiring (e.g. hydration-aware context plumbing).
20
- *
21
- * @throws `NoOwnerError` if there's no owner at the time of call.
22
- * @throws `ContextNotFoundError` if a context value has not been set yet.
23
- *
24
- * @internal
25
- */
26
- export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
27
- /**
28
- * Low-level owner-targeted context write. The user-facing API is
29
- * `createContext` (in `solid-js`); its provider component wraps this
30
- * primitive. Exposed here for cross-package wiring.
31
- *
32
- * @throws `NoOwnerError` if there's no owner at the time of call.
33
- *
34
- * @internal
35
- */
36
- export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
@@ -1,163 +0,0 @@
1
- import { type Refreshable } from "./constants.cjs";
2
- import { type OptimisticLane } from "./lanes.cjs";
3
- import type { Computed, FirewallSignal, NodeExtension, 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
- /** Lazily allocate a node's cold extension (ONE shape for signals and
29
- * computeds — `_x` access stays monomorphic). Installers write through
30
- * this; hot paths read `el._x?._field` gated by the _config presence bits.
31
- * Never call ext() just to store a field's default. */
32
- export declare function ext(el: {
33
- _x: NodeExtension | null;
34
- }): NodeExtension;
35
- /**
36
- * Build an Effect node with all effect-specific fields baked into a single object literal,
37
- * so V8 sees the full hidden class shape at construction time. Effects always run in lazy
38
- * mode (recompute is called explicitly by `effect()`), so we hardcode the lazy bits and skip
39
- * the auto-dispose CONFIG bit (effect() previously cleared it post-construction).
40
- */
41
- 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;
42
- export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
43
- export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
44
- export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
45
- export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, options?: NodeOptions<T>): Computed<T>;
46
- export declare function isEqual<T>(a: T, b: T): boolean;
47
- /**
48
- * When set to a component name string, any reactive read that is not inside a nested tracking
49
- * scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
50
- */
51
- export declare let strictRead: string | false;
52
- export declare function setStrictRead(v: string | false): string | false;
53
- /**
54
- * Runs `fn` outside of any reactive tracking — reads inside `fn` will not
55
- * subscribe the current scope. Returns whatever `fn` returns.
56
- *
57
- * Use `untrack` inside a memo or effect when you need to read a signal once
58
- * without making the surrounding computation depend on its future changes.
59
- *
60
- * Pass a `strictReadLabel` string to enable a dev-mode warning: any reactive
61
- * read inside `fn` that isn't inside a nested tracking scope will log a
62
- * warning naming the label.
63
- *
64
- * @example
65
- * ```ts
66
- * createEffect(
67
- * () => trigger(), // tracks `trigger` only
68
- * () => {
69
- * const snapshot = untrack(() => state); // read once, untracked
70
- * log(snapshot);
71
- * }
72
- * );
73
- * ```
74
- */
75
- export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
76
- /**
77
- * Bring a computed to a readable state: lazy/disposed nodes are (re)computed;
78
- * an isPending() probe (`refresh`) additionally pulls the node fully up to
79
- * date so its status flags reflect the current graph.
80
- */
81
- export declare function prepareComputed(comp: Computed<unknown>, refresh: boolean): void;
82
- /**
83
- * Sentinel returned by readNodeFast when the plain-signal fast path does not
84
- * apply and the caller must fall back to the full read().
85
- */
86
- export declare const READ_SLOW: unique symbol;
87
- /**
88
- * read()'s plain-signal fast path as a standalone entry for hot callers
89
- * (store traps). Safe to substitute for read() only because the bail
90
- * conditions mirror read()'s prelude and fast-path guard exactly: the
91
- * latestRead and pendingCheck windows run side-effectful hooks before the
92
- * fast path, `_fn` nodes need prepareComputed, and firewall / override /
93
- * snapshot / transition / lane / dev-strictRead state all take the full
94
- * resolution. Anything slow returns READ_SLOW; the caller then calls read().
95
- */
96
- export declare function readNodeFast<T>(el: Signal<T>): T | typeof READ_SLOW;
97
- export declare function read<T>(el: Signal<T> | Computed<T>): T;
98
- /**
99
- * Store-rewrite setter guard: the rewrite parks writes in a pending backing
100
- * (no setSignal at write time), so the owned-scope write protection must
101
- * fire at the setter entry instead. Mirrors setSignal's guard condition
102
- * minus the node-specific exemptions (ownedWrite/firewall), which don't
103
- * apply to plain store setters.
104
- */
105
- export declare function devGuardStoreSetterWrite(): void;
106
- export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
107
- /**
108
- * Suppresses automatic recomputation of `el` until the scheduler drains. Used
109
- * when a manual write should win over dependency changes queued in the same
110
- * tick. The MANUAL_WRITE flag is cleared by the pending-node drain; projection
111
- * computeds don't commit values, but they still need the same end-of-tick
112
- * cleanup point.
113
- */
114
- export declare function suppressComputedRecompute(el: Computed<unknown>): void;
115
- /**
116
- * User-facing setter for the memo form of `createSignal(fn)`. Behaves like
117
- * `setSignal`, but also cancels any pending recompute of the memo so the
118
- * manual value wins over a value that would otherwise be produced by an
119
- * upstream change in the same tick.
120
- */
121
- export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
122
- /**
123
- * Executes `fn` with the given `owner` set as the current owner. Any reactive
124
- * primitives (`createSignal`, `createMemo`, `createEffect`, `onCleanup`,
125
- * `cleanup`, etc.) created inside `fn` are attached to that owner, so they
126
- * are disposed when the owner is disposed.
127
- *
128
- * The classic pattern: capture the current owner with `getOwner()` inside a
129
- * component, then re-enter it from a callback (event handler, async resolve,
130
- * setTimeout) so disposables created in the callback get cleaned up with the
131
- * component.
132
- *
133
- * @example
134
- * ```ts
135
- * function delayed<T>(ms: number, fn: () => T) {
136
- * const owner = getOwner();
137
- * setTimeout(() => runWithOwner(owner, fn), ms);
138
- * }
139
- * ```
140
- */
141
- export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
142
- export declare function staleValues<T>(fn: () => T, set?: boolean): T;
143
- /**
144
- * Invalidates one reactive source, forcing it to re-execute even if its inputs
145
- * haven't changed.
146
- *
147
- * Pass either a Solid-created accessor or a projected store created from
148
- * `createStore(fn, ...)` / `createProjection(...)`. `refresh()` is a
149
- * write-like invalidation operation: it does not read the target's value, and
150
- * refreshing a plain signal accessor is a no-op.
151
- *
152
- * Use it to invalidate cached async values (e.g. force a re-fetch) without
153
- * tearing the consumer down.
154
- *
155
- * @example
156
- * ```ts
157
- * const user = createMemo(async () => fetch(`/users/${id()}`).then(r => r.json()));
158
- *
159
- * // Re-fetch on demand
160
- * <button onClick={() => refresh(user)}>Reload</button>
161
- * ```
162
- */
163
- export declare function refresh<T>(target: Refreshable<T>): void;
@@ -1,81 +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
- export type DiagnosticSeverity = "warn" | "error";
10
- 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" | "HUGE_FAN_OUT" | "HUGE_FAN_IN" | "HOT_SCOPE_RERUNS" | "HOT_SCOPE_TIME" | "WIDE_SCOPE_DEPS" | "UNSTABLE_MEMO_OUTPUT" | "WIDE_WRITE";
11
- export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner" | "error" | "perf" | "graph";
12
- /** First warning when a node's live edge count reaches this size. */
13
- export declare const GRAPH_SIZE_WARN_AT = 2000;
14
- /** Repeat the warning at this interval after the first. */
15
- export declare const GRAPH_SIZE_WARN_EVERY = 500;
16
- export interface DiagnosticEvent {
17
- sequence: number;
18
- code: DiagnosticCode;
19
- kind: DiagnosticKind;
20
- severity: DiagnosticSeverity;
21
- message: string;
22
- ownerId?: string;
23
- ownerName?: string;
24
- nodeName?: string;
25
- data?: Record<string, unknown>;
26
- }
27
- export type DiagnosticListener = (event: DiagnosticEvent) => void;
28
- export interface DiagnosticCapture {
29
- readonly events: readonly DiagnosticEvent[];
30
- clear(): void;
31
- stop(): DiagnosticEvent[];
32
- }
33
- export interface Diagnostics {
34
- subscribe(listener: DiagnosticListener): () => void;
35
- capture(): DiagnosticCapture;
36
- }
37
- export interface Dev {
38
- hooks: DevHooks;
39
- diagnostics: Diagnostics;
40
- /** "Why did this run" re-run attribution — see attribution.ts. */
41
- attribution: Attribution;
42
- getChildren: typeof getChildren;
43
- getSignals: typeof getSignals;
44
- getParent: typeof getParent;
45
- getSources: typeof getSources;
46
- getObservers: typeof getObservers;
47
- }
48
- export declare const DEV: Dev;
49
- /**
50
- * Dev-mode internal consistency check. A failure means the reactive system
51
- * contradicted itself (not that user code misbehaved) — see
52
- * INTERNALS-ASYNC-STATE.md for the invariant catalog. Throws under __TEST__
53
- * so the suite (and fuzzing) treats any violation as a hard failure; logs in
54
- * dev builds so user apps degrade instead of crashing.
55
- */
56
- export declare function assertInvariant(condition: boolean, name: string, message: string): void;
57
- export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
58
- /**
59
- * Shared strict-read diagnostics for core read() and the store proxy traps.
60
- * Single source for the message text — the #2897 safeguard parity between
61
- * memos and stores is exactly these firing identically from both paths.
62
- */
63
- export declare function throwPendingUntrackedRead(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence" | "data">>): never;
64
- export declare function warnStrictReadUntracked(strictReadLabel: string, fields?: Partial<Omit<DiagnosticEvent, "sequence">>): void;
65
- export declare function registerGraph(value: any, owner: Owner | null): void;
66
- export declare function clearSignals(node: Owner): void;
67
- export declare function getChildren(owner: Owner): Owner[];
68
- export declare function getSignals(owner: Owner): any[];
69
- export declare function getParent(owner: Owner): Owner | null;
70
- export declare function getSources(computation: Computed<any>): (Signal<any> | Computed<any>)[];
71
- export declare function getObservers(node: Signal<any> | Computed<any>): Computed<any>[];
72
- /**
73
- * DEV-only: bump live edge counts after a new graph link and warn when a
74
- * node grows an unusually large fan-out (many subscribers on one source) or
75
- * fan-in (many sources on one computation). Repeat-reads that `link()`
76
- * dedupes never reach here. Always-on in dev — unlike the opt-in attribution
77
- * engine, a graph-size pathology should surface without asking.
78
- */
79
- export declare function noteGraphLink(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
80
- /** DEV-only: drop live edge counts when a link is removed. */
81
- 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,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,6 +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
- export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>, pendingObserver?: boolean): void;