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

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 (134) hide show
  1. package/dist/dev-shared.js +6357 -0
  2. package/dist/dev.attribution.js +2485 -0
  3. package/dist/dev.js +2851 -7027
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +641 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +846 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +282 -0
  11. package/dist/observe/core/attribution-hooks.js +82 -0
  12. package/dist/observe/core/attribution-queries.js +28 -0
  13. package/dist/observe/core/attribution.js +2095 -0
  14. package/dist/observe/core/constants.js +248 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1789 -0
  17. package/dist/observe/core/dev.js +293 -0
  18. package/dist/observe/core/effect.js +195 -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 +585 -0
  27. package/dist/observe/core/owner.js +322 -0
  28. package/dist/observe/core/scheduler.js +1428 -0
  29. package/dist/observe/core/verdict.js +669 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +311 -317
  33. package/dist/observe/store/index.js +40 -0
  34. package/dist/observe/store/next/optimistic.js +660 -0
  35. package/dist/observe/store/next/projection.js +255 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2327 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +325 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1023 -0
  42. package/dist/prod/attribution.js +41 -0
  43. package/dist/prod/boundaries.js +128 -76
  44. package/dist/prod/core/action.js +65 -37
  45. package/dist/prod/core/async.js +324 -172
  46. package/dist/prod/core/constants.js +57 -1
  47. package/dist/prod/core/context.js +3 -3
  48. package/dist/prod/core/core.js +1003 -364
  49. package/dist/prod/core/dev.js +17 -1
  50. package/dist/prod/core/effect.js +76 -42
  51. package/dist/prod/core/error-hooks.js +71 -0
  52. package/dist/prod/core/external.js +4 -4
  53. package/dist/prod/core/graph.js +37 -37
  54. package/dist/prod/core/heap.js +61 -56
  55. package/dist/prod/core/lanes.js +107 -63
  56. package/dist/prod/core/optimistic.js +374 -93
  57. package/dist/prod/core/owner.js +62 -46
  58. package/dist/prod/core/scheduler.js +653 -286
  59. package/dist/prod/core/verdict.js +245 -127
  60. package/dist/prod/index.js +15 -5
  61. package/dist/prod/map.js +292 -141
  62. package/dist/prod/signals.js +29 -16
  63. package/dist/prod/store/next/optimistic.js +77 -55
  64. package/dist/prod/store/next/projection.js +31 -20
  65. package/dist/prod/store/next/reconcile.js +87 -84
  66. package/dist/prod/store/next/store.js +718 -401
  67. package/dist/prod/store/next/target.js +32 -10
  68. package/dist/prod/store/store.js +12 -14
  69. package/dist/prod/store/utils.js +950 -130
  70. package/dist/types/attribution.d.ts +20 -0
  71. package/dist/types/attribution.prod.d.ts +22 -0
  72. package/dist/types/boundaries.d.ts +10 -1
  73. package/dist/types/core/action.d.ts +12 -5
  74. package/dist/types/core/async.d.ts +1 -1
  75. package/dist/types/core/attribution-costs.d.ts +35 -0
  76. package/dist/types/core/attribution-feedback.d.ts +133 -0
  77. package/dist/types/core/attribution-hooks.d.ts +147 -9
  78. package/dist/types/core/attribution-queries.d.ts +10 -0
  79. package/dist/types/core/attribution.d.ts +216 -182
  80. package/dist/types/core/constants.d.ts +56 -0
  81. package/dist/types/core/core.d.ts +190 -2
  82. package/dist/types/core/dev.d.ts +246 -28
  83. package/dist/types/core/effect.d.ts +8 -1
  84. package/dist/types/core/error-hooks.d.ts +71 -0
  85. package/dist/types/core/index.d.ts +4 -1
  86. package/dist/types/core/invariants.d.ts +4 -0
  87. package/dist/types/core/lanes.d.ts +39 -5
  88. package/dist/types/core/scheduler.d.ts +153 -0
  89. package/dist/types/core/types.d.ts +32 -9
  90. package/dist/types/index.d.ts +10 -3
  91. package/dist/types/map.d.ts +2 -0
  92. package/dist/types/signals.d.ts +8 -0
  93. package/dist/types/store/index.d.ts +2 -0
  94. package/dist/types/store/next/optimistic.d.ts +1 -1
  95. package/dist/types/store/next/store.d.ts +11 -5
  96. package/dist/types/store/next/target.d.ts +37 -10
  97. package/dist/types/store/utils.d.ts +178 -0
  98. package/package.json +21 -17
  99. package/dist/node.cjs +0 -10541
  100. package/dist/node.dev.cjs +0 -13724
  101. package/dist/types-cjs/affects.d.cts +0 -47
  102. package/dist/types-cjs/boundaries.d.cts +0 -175
  103. package/dist/types-cjs/core/action.d.cts +0 -64
  104. package/dist/types-cjs/core/async.d.cts +0 -23
  105. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
  106. package/dist/types-cjs/core/attribution.d.cts +0 -495
  107. package/dist/types-cjs/core/constants.d.cts +0 -159
  108. package/dist/types-cjs/core/core.d.cts +0 -185
  109. package/dist/types-cjs/core/dev.d.cts +0 -136
  110. package/dist/types-cjs/core/effect.d.cts +0 -30
  111. package/dist/types-cjs/core/error.d.cts +0 -56
  112. package/dist/types-cjs/core/external.d.cts +0 -15
  113. package/dist/types-cjs/core/graph.d.cts +0 -28
  114. package/dist/types-cjs/core/heap.d.cts +0 -24
  115. package/dist/types-cjs/core/index.d.cts +0 -13
  116. package/dist/types-cjs/core/invariants.d.cts +0 -59
  117. package/dist/types-cjs/core/lanes.d.cts +0 -54
  118. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  119. package/dist/types-cjs/core/owner.d.cts +0 -124
  120. package/dist/types-cjs/core/scheduler.d.cts +0 -236
  121. package/dist/types-cjs/core/types.d.cts +0 -204
  122. package/dist/types-cjs/core/verdict.d.cts +0 -2
  123. package/dist/types-cjs/index.d.cts +0 -10
  124. package/dist/types-cjs/map.d.cts +0 -69
  125. package/dist/types-cjs/package.json +0 -3
  126. package/dist/types-cjs/store/index.d.cts +0 -18
  127. package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
  128. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  129. package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
  130. package/dist/types-cjs/store/next/store.d.cts +0 -121
  131. package/dist/types-cjs/store/next/target.d.cts +0 -166
  132. package/dist/types-cjs/store/store.d.cts +0 -143
  133. package/dist/types-cjs/store/storePath.d.cts +0 -58
  134. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -1,495 +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
- /**
26
- * Provenance of a root change: the imperative frame that performed it.
27
- *
28
- * - `interaction` — a user event handler (the web runtime marks dispatch via
29
- * `withInteraction`). `name` is the event type, `target` the element hit
30
- * (`button#next "Next →"`), `at` the dispatch time on the `performance.now()`
31
- * clock — the base every feedback-latency number is measured from.
32
- * - `effect` — an effect callback (`name` = the effect's name; `run` = the
33
- * compute run whose effect phase performed the write, when that run was
34
- * recorded — so a write can be joined to the re-run that produced it).
35
- * - `action` — a step of an `action()` generator (`name` = the generator's
36
- * name, when it has one). Writes after an `await` (not a `yield`) run in a
37
- * bare microtask and stamp `external` — the documented escape.
38
- * - `async` — an async landing (`name` = the node whose flight landed).
39
- * - `external` — none of the above: timers, sockets, promise callbacks, setup.
40
- *
41
- * `interaction` on a non-interaction frame is the user event the frame runs
42
- * under — an action started by a click, an effect whose run was caused by a
43
- * click's write, a landing whose flight a click started. It is what lets
44
- * every downstream cost be keyed by the interaction that paid for it.
45
- */
46
- export interface ChangeOrigin {
47
- kind: "interaction" | "effect" | "action" | "async" | "external";
48
- name?: string;
49
- target?: string;
50
- at?: number;
51
- interaction?: ChangeOrigin;
52
- /** `effect` only: the `RerunEvent.run` of the compute run this callback belongs to. */
53
- run?: number;
54
- }
55
- /** A user interaction, as the web runtime describes it to `withInteraction`. */
56
- export interface InteractionRef {
57
- /** Event type — `click`, `keydown`, `input`… */
58
- type: string;
59
- /** The element hit, e.g. `button#next "Next →"`. */
60
- target?: string;
61
- /** Dispatch time on the `performance.now()` clock; defaults to now. */
62
- at?: number;
63
- }
64
- export interface ChangeRecord {
65
- /** Global monotonic change sequence — orders causes across the app. */
66
- seq: number;
67
- kind: ChangeKind;
68
- name: string;
69
- /** Short previews of the value transition (writes only). */
70
- prev?: string;
71
- value?: string;
72
- /** First user frames of the triggering write's stack (opt-in). */
73
- stack?: string[];
74
- /** For derived changes: the upstream changes that produced this one. */
75
- causes?: ChangeRecord[];
76
- /** Root changes only: who performed the write. */
77
- origin?: ChangeOrigin;
78
- /** Root changes only: when the write was stamped (`performance.now()` clock). */
79
- at?: number;
80
- }
81
- export interface RerunEvent {
82
- /** Global monotonic run sequence. */
83
- run: number;
84
- /** How many times this node has re-run since attribution was enabled. */
85
- nodeRuns: number;
86
- nodeKind: "effect" | "memo";
87
- nodeName: string;
88
- node: Computed<any>;
89
- /**
90
- * The deps that changed since this node's previous run. Empty means the
91
- * re-run was not triggered by a tracked value change (creation-adjacent
92
- * pull, error retry, or a cause this prototype does not stamp yet).
93
- */
94
- causes: ChangeRecord[];
95
- /** Dependency count after this run. */
96
- depCount: number;
97
- /** Names of deps this run subscribed to that the previous run did not. */
98
- depsAdded: string[];
99
- /** Names of deps the previous run had that this run dropped. */
100
- depsRemoved: string[];
101
- /** Wall time of this run excluding nested recomputes (ms). */
102
- selfMs: number;
103
- /** Wall time of this run including nested recomputes (ms). */
104
- totalMs: number;
105
- /**
106
- * Whether the run produced a changed value. A PLAIN memo run with
107
- * `changed: false` was pure waste — the equality cutoff stopped it from
108
- * notifying anyone. Effects run with `_equals: false` in core (their
109
- * effect phase re-fires on every recompute), so the engine derives this
110
- * fact itself: an effect run whose compute output is identical to the
111
- * previous run's reports `changed: false` — the phase re-fired with the
112
- * same input, pure waste. Side-effect-only computes (`undefined` output)
113
- * are exempt: identity of `undefined` proves nothing about their work.
114
- * Summed as `wastedMs` in costs() (plain, non-held runs only — see
115
- * `phase`).
116
- */
117
- changed: boolean;
118
- /**
119
- * Which posture this run executed under. "optimistic" = under an
120
- * optimistic lane (overlay recompute); "held" = a hold was open or owns
121
- * the node (the run may be replayed/settled later); "plain" = an ordinary
122
- * committed run. Overlay runs are real work (they count toward time
123
- * budgets) but are never blamed as waste, and costs() reports their time
124
- * separately as `overlayMs`.
125
- */
126
- phase: "plain" | "held" | "optimistic";
127
- /**
128
- * The changed value was parked in `_pendingValue` (held) rather than
129
- * committed directly; its reveal happens on the hold's own schedule. Held
130
- * runs are excluded from waste accounting.
131
- */
132
- held: boolean;
133
- /** The user interaction this run traces back to through its causes, if any. */
134
- interaction?: ChangeOrigin;
135
- }
136
- export interface AttributionOptions {
137
- /** Pretty-print each re-run to the console (default true). */
138
- log?: boolean;
139
- /** Capture the user stack frame of each write — slow (default false). */
140
- stacks?: boolean;
141
- /** Ring-buffer size for `history()` (default 200). */
142
- historyLimit?: number;
143
- /**
144
- * Hot-scope warning: emit a diagnostic when one scope re-runs `count`
145
- * times within `windowMs` (default 120 runs / 1000ms — deliberately above
146
- * animation-frame cadence, so a legitimate rAF-driven scope at 60/s does
147
- * not cry wolf). `false` disables.
148
- */
149
- hotRuns?: {
150
- count: number;
151
- windowMs: number;
152
- } | false;
153
- /**
154
- * Wide-scope warning: emit a diagnostic when a scope's dependency count
155
- * reaches this (default 30) — the coarse-read / helper-leak signature.
156
- * Re-warns only if the count then grows by another 50%. `false` disables.
157
- */
158
- wideDeps?: number | false;
159
- /**
160
- * Time-budget warning: emit a diagnostic when one scope's summed self-time
161
- * inside `windowMs` exceeds `budgetMs` (default 8ms / 1000ms — half a frame
162
- * spent in one scope). Unlike `hotRuns` this catches the few-but-expensive
163
- * scope that run counts miss. `false` disables.
164
- */
165
- hotTime?: {
166
- budgetMs: number;
167
- windowMs: number;
168
- } | false;
169
- /**
170
- * Unstable-output warning: emit a diagnostic when a memo commits a
171
- * referentially-new but shallowly-equivalent plain object/array on this
172
- * many consecutive runs (default 4). Such a memo's equality gate never
173
- * closes — every subscriber re-runs on every upstream change — which makes
174
- * it a fan-out amplifier that is otherwise only findable by profiling.
175
- * `false` disables.
176
- */
177
- unstableMemos?: number | false;
178
- /**
179
- * Written-fan-out warning: emit a diagnostic when a committed root
180
- * invalidation (write, refresh, async landing) reaches a node with at
181
- * least this many subscribers (default 250). Complements the always-on
182
- * HUGE_FAN_OUT graph-size warning, specced against it deliberately:
183
- * HUGE_FAN_OUT fires at LINK time from GRAPH_SIZE_WARN_AT (2000) up —
184
- * static structure so large it warns even if never written — while this
185
- * fires at WRITE time from a much lower bar, because fan-out only costs
186
- * anything when the node actually changes. Once per node, re-warning only
187
- * on 2x subscriber growth, so the two never spam the same node. `false`
188
- * disables.
189
- */
190
- wideWrites?: number | false;
191
- /**
192
- * Async-waterfall warning: emit a diagnostic when an async flight that
193
- * could only start after an upstream flight resolved (its recompute's
194
- * cause chain reaches the upstream's async landing, and its origin
195
- * post-dates that landing) forms a sequential chain of 2+ flights, each
196
- * of which took at least `minFlightMs` (default 50ms). The duration gate
197
- * is one safety valve for what the graph cannot see: a settled
198
- * preload/cache hit resolves fast and never warns. In-flight preloads are
199
- * absolved by origin: `markFlight()` stamps (and first-seen identity)
200
- * prove work predated the upstream landing — parallel, not sequential.
201
- * Chains of 2 emit at `info` severity, structured channel only (a
202
- * dependent fetch is sometimes intrinsic, and unmarked external preloads
203
- * are invisible); 3+ escalate to `warn` with console output. `false`
204
- * disables.
205
- */
206
- waterfalls?: {
207
- minFlightMs: number;
208
- } | false;
209
- /**
210
- * Silent-hold warning: emit a diagnostic when a user's writes were held
211
- * behind async work for at least `infoMs` (default 100ms — RAIL's "feels
212
- * instant" ceiling) and the screen never acknowledged the wait — no
213
- * `isPending()`/`latest()` reader downstream of the held writes or their
214
- * blockers, no optimistic value, no `affects()` mark, and no lane effect
215
- * painted while held. Below `warnMs`
216
- * (default 200ms — the INP "good" ceiling) the event is advisory
217
- * (structured channel only); at or above it the console gets the finding.
218
- * The engine measures to the commit, not the paint, so every number is a
219
- * floor on what the user saw; the thresholds sit at the strict end of the
220
- * band on purpose. Holds that staged no root write (initial loads, bare
221
- * `refresh()`) are never judged: nothing the user did went unanswered.
222
- * `false` disables hold tracking altogether (`longHolds` included).
223
- */
224
- holds?: {
225
- infoMs: number;
226
- warnMs: number;
227
- } | false;
228
- /**
229
- * Long-hold warning: emit a diagnostic when a hold's quiescent tail — the
230
- * time from the LAST write to join it until it committed — reached
231
- * `infoMs` (default 500ms), `warn` from `warnMs` (default 1000ms, where
232
- * RAIL says the user loses the thread). Measured from the last join so a
233
- * hold that keeps taking input (typing) is judged by each wait, not by its
234
- * lifetime. A hold this long is past what a stale screen should carry,
235
- * acknowledged or not: the honest UI is a fallback, which a `Loading`
236
- * boundary gives only when it has not revealed yet or its `on` prop
237
- * changed. Reported as LONG_HOLD when the hold was acknowledged; a silent
238
- * long hold stays one SILENT_HOLD with the boundary repair appended.
239
- * `false` disables.
240
- */
241
- longHolds?: {
242
- infoMs: number;
243
- warnMs: number;
244
- } | false;
245
- }
246
- export interface ScopeCost {
247
- name: string;
248
- kind: "effect" | "memo";
249
- runs: number;
250
- selfMs: number;
251
- /**
252
- * Self-time of PLAIN, non-held runs that produced an unchanged value —
253
- * the recoverable number. Overlay runs (optimistic/transition) are never
254
- * counted here: an optimistic recompute landing back on the committed
255
- * value is the mechanism working, not waste.
256
- */
257
- wastedMs: number;
258
- /** Self-time spent in optimistic/transition (overlay) runs. */
259
- overlayMs: number;
260
- }
261
- export interface WriteCost {
262
- /** Root cause name (a signal write, async landing, or refresh target). */
263
- name: string;
264
- /** Number of downstream re-runs this root triggered. */
265
- runs: number;
266
- /** Summed self-time of every downstream re-run it caused. */
267
- downstreamMs: number;
268
- }
269
- /**
270
- * Run `fn` as the handler of a user interaction: every root write it performs
271
- * (and every action step or effect the write causes) carries the interaction
272
- * as provenance. The web runtime wraps event dispatch in this; it is dev-only
273
- * and safe to call with no engine enabled.
274
- */
275
- export declare function withInteraction<T>(ref: InteractionRef, fn: () => T): T;
276
- /** `click on button#next "Next →"`, `effect "syncTitle"`, `action "save"`, … */
277
- export declare function formatOrigin(origin: ChangeOrigin): string;
278
- export declare function formatRerun(event: RerunEvent): string;
279
- export interface Attribution {
280
- enable(opts?: AttributionOptions): void;
281
- disable(): void;
282
- subscribe(listener: (event: RerunEvent) => void): () => void;
283
- history(): readonly RerunEvent[];
284
- /** Re-run history for one node — pass a memo/effect accessor or raw node. */
285
- why(target: unknown): RerunEvent[];
286
- /** Current dependency names of one scope — the devtools subscription view. */
287
- subscriptions(target: unknown): string[];
288
- /**
289
- * Aggregated cost tables since enable(): `scopes` ranked by self-time
290
- * (with `wastedMs` = time spent on unchanged-value runs), `writes` ranked
291
- * by total downstream re-run time each root write caused.
292
- */
293
- costs(): {
294
- scopes: ScopeCost[];
295
- writes: WriteCost[];
296
- };
297
- /**
298
- * Every graph-provable sequential flight chain observed since enable()
299
- * (ring-buffered like history()). Facts, not verdicts: chains are recorded
300
- * regardless of the duration gate — the ASYNC_WATERFALL diagnostic is the
301
- * thresholded view of the same data.
302
- */
303
- waterfalls(): readonly WaterfallRecord[];
304
- /**
305
- * Every settled transition hold that staged at least one root write since
306
- * enable() (ring-buffered like history()). Facts, not verdicts: recorded
307
- * regardless of duration or acknowledgment — the SILENT_HOLD diagnostic is
308
- * the thresholded, unacknowledged subset.
309
- */
310
- holds(): readonly HoldEvent[];
311
- /**
312
- * What the user waited on, folded from holds() and the interaction on each
313
- * re-run: `sources` ranks async sources by the silent time writes spent
314
- * held behind them (with which affordances answered, how often, and which
315
- * interactions were held); `interactions` ranks user events by the total
316
- * time they cost — re-run work caused (long-flush hazard) beside time held
317
- * (silent-hold hazard). Facts at every duration; SILENT_HOLD is the
318
- * thresholded verdict. Two more tables round out the picture: `flights`
319
- * counts each async source's flights and how many were abandoned before
320
- * landing (the re-ask storm), and `fallbacks` measures how long each
321
- * loading boundary showed its fallback and how often that was a flash.
322
- */
323
- feedback(): AttributionFeedbackTables;
324
- /**
325
- * Cooperative preload declaration: stamp a flight object (promise or async
326
- * iterable) with its true kickoff time BEFORE the reactive graph sees it.
327
- * A route preloader or query cache calls this on the promise it hands out
328
- * (on the WRAPPER it mints, with the original kickoff time — wrapping
329
- * defeats identity tracking otherwise); any dependent that later awaits it
330
- * is then judged against the real start — work already in the air when its
331
- * upstream landed is parallel, never a waterfall link. Callable while
332
- * attribution is disabled (marks made at navigation time must survive a
333
- * later enable()). Dev-only, like the whole DEV surface.
334
- */
335
- markFlight(flight: object, startedAt?: number): void;
336
- /**
337
- * Run `fn` as a user interaction's handler: root writes inside stamp it as
338
- * their origin, and actions/effects/flights it causes carry it. The web
339
- * runtime wraps every event dispatch in this; custom renderers and test
340
- * harnesses call it themselves. Callable while attribution is disabled.
341
- */
342
- withInteraction: typeof withInteraction;
343
- format: typeof formatRerun;
344
- formatOrigin: typeof formatOrigin;
345
- }
346
- /** One landed flight: its node name, wall duration, and upstream chain. */
347
- export interface FlightLink {
348
- name: string;
349
- ms: number;
350
- }
351
- export interface WaterfallRecord {
352
- /** Sequential flights, oldest first, ending at the flight that landed. */
353
- chain: FlightLink[];
354
- /** Summed wall time of the chain — the serialized cost. */
355
- sequentialMs: number;
356
- }
357
- export interface HeldWrite {
358
- name: string;
359
- prev?: string;
360
- value?: string;
361
- origin?: ChangeOrigin;
362
- }
363
- export interface HoldEvent {
364
- /**
365
- * Wall time the user waited: from the interaction that performed the held
366
- * writes when one is known (`interaction.at`) or the first flush that
367
- * parked them, whichever is earlier, to the commit.
368
- */
369
- holdMs: number;
370
- /**
371
- * The quiescent tail: from the LAST held write to join (the user's final
372
- * input) to the commit. Equal to `holdMs` for a single write; shorter when
373
- * the hold kept taking input. The LONG_HOLD measure.
374
- */
375
- tailMs: number;
376
- /** The user interaction whose writes were held, when the stamp is known. */
377
- interaction?: ChangeOrigin;
378
- /** Flushes that ended with the hold still open. */
379
- flushes: number;
380
- /** Root signal writes staged behind the hold (the user's unanswered input). */
381
- heldWrites: HeldWrite[];
382
- /** Async nodes the hold waited on (union across its parked flushes). */
383
- blockers: string[];
384
- /**
385
- * Feedback the graph provably rendered for this hold, as `"<kind>:<node>"`
386
- * — `isPending:posts`, `latest:page`, `optimistic:todos`, `affects:list`.
387
- * Empty and `paintedDuringHold === 0` is the SILENT_HOLD signature.
388
- */
389
- acknowledgedBy: string[];
390
- /**
391
- * Effect callbacks that ran inside the hold's parked flushes. Mainline
392
- * effects are stashed while a hold is open, so these are lane effects —
393
- * readers of optimistic values and of `isPending()`/`latest()` companions,
394
- * i.e. the screen changing in response to the hold. An unrelated effect
395
- * cannot land here: it waits with everything else.
396
- */
397
- paintedDuringHold: number;
398
- /** The hold was opened (or joined) by an `action()`. */
399
- action: boolean;
400
- }
401
- export interface FeedbackSource {
402
- /** The async nodes the holds waited on; empty when an action alone kept them open. */
403
- sources: string[];
404
- holds: number;
405
- /** Summed wait across the holds (ms). */
406
- heldMs: number;
407
- worstMs: number;
408
- /** Holds with no acknowledgment at all — the SILENT_HOLD signature, at any duration. */
409
- silent: number;
410
- silentMs: number;
411
- /** Holds whose only acknowledgment was a `latest()` shadow: the input showed, nothing said "loading". */
412
- latestOnly: number;
413
- /**
414
- * Holds whose quiescent tail (last write to join → commit) reached
415
- * `longHolds.infoMs`, acknowledged or not — the LONG_HOLD signature at the
416
- * table level. The affordance is not the whole answer there: a fallback
417
- * (`Loading` keyed with `on`), a preload, a cache, or a faster source is.
418
- * `longMs` sums the tails.
419
- */
420
- long: number;
421
- longMs: number;
422
- /** Which affordances answered, and in how many holds — ranked. */
423
- acknowledgedBy: {
424
- by: string;
425
- holds: number;
426
- }[];
427
- /** Interactions whose writes were held here, ranked by holds. */
428
- interactions: {
429
- interaction: string;
430
- holds: number;
431
- }[];
432
- /** Distinct root writes that were held. */
433
- writes: string[];
434
- /** Holds an action opened or joined. */
435
- actions: number;
436
- }
437
- export interface FeedbackInteraction {
438
- /** `click on button#next "Next →"` — type and target; repeated dispatches fold together. */
439
- interaction: string;
440
- /** Distinct dispatches seen (by dispatch time). */
441
- dispatches: number;
442
- /** Re-runs traced back to this interaction, and their summed self-time. */
443
- runs: number;
444
- selfMs: number;
445
- /** The most re-run self-time a single dispatch caused — the long-flush hazard. */
446
- worstDispatchMs: number;
447
- /** Holds this interaction's writes waited in — the silent-hold hazard. */
448
- holds: number;
449
- heldMs: number;
450
- silentMs: number;
451
- worstHoldMs: number;
452
- }
453
- /** Per async source: how many flights it started, and how many it threw away. */
454
- export interface FlightStats {
455
- source: string;
456
- /** Flights registered (a recompute that produced a new promise/iterable). */
457
- flights: number;
458
- /** Flights that landed (whether or not the value changed). */
459
- landed: number;
460
- /**
461
- * Flights superseded by a newer one before landing — the search-as-you-type
462
- * signature when large: every keystroke asked, most answers were discarded.
463
- * A debounced/equality-gated derivation between input and fetch is the repair.
464
- */
465
- abandoned: number;
466
- /** Summed and worst wall time of landed flights (ms). */
467
- landedMs: number;
468
- worstMs: number;
469
- }
470
- /** Per loading boundary: how long, and how briefly, it showed its fallback. */
471
- export interface FallbackStats {
472
- /** The boundary's owner path (`<App> › <Feed>`), or `boundary` when unnamed. */
473
- boundary: string;
474
- /** Times the fallback was shown. */
475
- shows: number;
476
- /** Summed and worst fallback duration (ms) across completed shows. */
477
- shownMs: number;
478
- worstMs: number;
479
- /**
480
- * Shows shorter than the flash window (default 150ms): a spinner that
481
- * appeared and vanished — the other end of the SILENT_HOLD spectrum, too
482
- * much feedback for too little wait. A preload, a cache, or lifting the
483
- * fetch above the boundary removes the flash.
484
- */
485
- flashes: number;
486
- }
487
- export interface AttributionFeedbackTables {
488
- sources: FeedbackSource[];
489
- interactions: FeedbackInteraction[];
490
- /** Async sources ranked by abandoned flights, then by flights. */
491
- flights: FlightStats[];
492
- /** Loading boundaries ranked by flashes, then by time shown. */
493
- fallbacks: FallbackStats[];
494
- }
495
- export declare const attribution: Attribution;
@@ -1,159 +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
- /** Authoritative-view reader (`until()`): while this node computes, reads
55
- * dodge active optimistic OVERRIDES only — the predicate must observe
56
- * arriving truth, never the caller's own tentative writes (which would
57
- * trivially satisfy it). Everything else reads normally, INCLUDING
58
- * transition-staged `_pendingValue`: staged data is authoritative (optimism
59
- * lives only in override slots), and a hold that refused staged reads would
60
- * deadlock on data the open transaction itself is holding (a refresh the
61
- * action issued lands staged and cannot commit until the hold releases).
62
- * read() checks the bit on the reading computation (`context`) directly — no
63
- * ambient flag — so a shared computed the predicate pulls recomputes as
64
- * itself (no bit) under the normal view, and its cache never forks. */
65
- export declare const CONFIG_AUTHORITATIVE_READ: number;
66
- /** Sticky mark: an authoritative-view reader read this node PAST an active
67
- * override. The ack shape — an authoritative arrival EQUAL to the override —
68
- * rides paths that are deliberately silent under A17 (every ordinary reader
69
- * sees the override, so an equal landing changes nothing for them). A marked
70
- * node notifies those readers on such paths anyway, so the landed truth is
71
- * seen without re-firing ordinary subscribers. Never cleared — only nodes an
72
- * until() predicate observed mid-override pay. */
73
- export declare const CONFIG_AUTHORITATIVE_OBSERVED: number;
74
- /** Promise-delivery effect (resolve()/until()): commits its computed value
75
- * directly even when recomputing under its own held transition. These
76
- * effects deliver applies on a microtask (#2930) instead of the stashed
77
- * effect queues, so the value must ride the same immediate schedule — a
78
- * staged value with an immediate apply delivers stale state (resolve) or
79
- * deadlocks the hold (until). Safe because the node is a private leaf: no
80
- * subscriber reads an effect's value, only its own apply does. */
81
- export declare const CONFIG_DIRECT_COMMIT: number;
82
- /** Fresh-pull reader (awaitable `refresh()`'s waiter effect): a read of a
83
- * dirty source recomputes it inline even when the height gate defers to the
84
- * flush. Closes the same-flush ordering race where a waiter created
85
- * alongside a refresh() mark read the PRE-re-ask value as settled and
86
- * delivered stale; with the pull, the waiter either parks on the re-ask's
87
- * pending window (async — woken by the settle walk, which runs on every
88
- * landing including equal-value ones) or serves its sync answer. resolve()
89
- * deliberately keeps that race — its contract is "first settled value"
90
- * (#2930), not "next quiescent state". */
91
- export declare const CONFIG_FRESH_READ: number;
92
- /** HELD truth (#3164): this node's staged `_pendingValue` is confirming
93
- * truth riding a transaction that retains optimism, revealed only at that
94
- * transaction's settle. Two arming sites, one meaning: the store fold
95
- * (a landing staged into the retaining transaction) and until()'s
96
- * flip-entanglement (a foreign carrier's staged write, stolen when it
97
- * flipped the awaited predicate truthy). Until the reveal, ordinary
98
- * readers — lane and speculative recomputes included — keep committed:
99
- * the staging notified subscribers as a plain write, so without the mask
100
- * a mid-hold recompute composes live optimism with the confirming truth,
101
- * a frame no timeline contains (GabbeV's union tear). Authoritative
102
- * readers (until()'s predicate) and latest() tunnel through — the
103
- * exemption that keeps holds deadlock-free. Override-covered nodes never
104
- * arm: the override is their display and its revert their notification
105
- * (A17). Cleared at commit (the commit IS the reveal); subscribers masked
106
- * during the hold are woken by finalizePureQueue's post-revert pass. */
107
- export declare const CONFIG_HELD_TRUTH: number;
108
- /** SLOT node (store leaf): created through `slotSignal` with `_host`/`_key`
109
- * backrefs baked into the literal. The unobserved sweep dispatches these to
110
- * the ONE shared hook (`setSlotUnobserved`) instead of a per-node closure
111
- * held in a per-node extension — store mounts materialize one signal per
112
- * touched leaf, so per-node allocations (options object, equals closure,
113
- * unobserved closure, NodeExtension) were the measured create-floor bytes
114
- * (warm dbmon profile: store node machinery ~36% + GC ~29%). */
115
- export declare const CONFIG_SLOT_NODE: number;
116
- export declare const STATUS_NONE = 0;
117
- export declare const STATUS_PENDING: number;
118
- export declare const STATUS_ERROR: number;
119
- export declare const STATUS_UNINITIALIZED: number;
120
- export declare const EFFECT_PURE = 0;
121
- export declare const EFFECT_RENDER = 1;
122
- export declare const EFFECT_USER = 2;
123
- export declare const EFFECT_TRACKED = 3;
124
- export declare const NOT_PENDING: {};
125
- export declare const NO_SNAPSHOT: {};
126
- /**
127
- * Stand-in stored in `_overrideValue` for an optimistic write of literal
128
- * `undefined` (#2898). The slot doubles as the optimistic-node brand
129
- * (`undefined` = not optimistic, `NOT_PENDING` = at rest), so the raw value
130
- * would erase the node's optimistic identity: the write turns invisible and
131
- * follow-up writes route off the optimistic path and commit permanently.
132
- * Same shape as NO_SNAPSHOT. Sites that surface the override VALUE unwrap
133
- * via `visibleOverrideValue`; slot identity tests stay raw.
134
- */
135
- export declare const OVERRIDE_UNDEFINED: {};
136
- /** Unwrap an active override's stored value for surfacing to readers (#2898). */
137
- export declare function unwrapOverride<T = any>(v: unknown): T;
138
- export declare const STORE_SNAPSHOT_PROPS = "sp";
139
- export declare const SUPPORTS_PROXY: boolean;
140
- export declare const defaultContext: {};
141
- /**
142
- * Brand symbol used by `Refreshable<T>` values (projection stores, async
143
- * memos) to expose their underlying computation to `refresh()`. Not part of
144
- * the user-facing API.
145
- *
146
- * @internal
147
- */
148
- export declare const $REFRESH: unique symbol;
149
- /**
150
- * Brand applied to values that participate in the `refresh()` re-run protocol.
151
- * Accessors receive this handle internally; projected stores expose it through
152
- * their public return type so user-defined hooks that wrap `createOptimisticStore`
153
- * / `createProjection` / projection-form `createStore` can have their return
154
- * types inferred without leaking the internal `$REFRESH` symbol into public type
155
- * signatures (TS4058).
156
- */
157
- export type Refreshable<T> = T & {
158
- readonly [$REFRESH]: any;
159
- };