@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
@@ -0,0 +1,14 @@
1
+ import type { Computed, Signal } from "./core/types.js";
2
+ export type Marked = Signal<any> | Computed<any>;
3
+ /** The verdict readers downstream of `node` — through derivations, stopping
4
+ * at effects — re-derive: the mark's one notification (a probe's answer
5
+ * changed with no value notifying anyone). Truth readers (`until`, the
6
+ * `refresh` waiter) too, which a lagging flight parked (deferred.ts) — but
7
+ * not through a derived store, whose leaves change only once its derive
8
+ * re-runs: they re-derive at that write. */
9
+ export declare function repoll(node: Marked, seen?: Set<Computed<any>>, readers?: number): void;
10
+ /** One mark on `node`. The declarer repolls once its bookkeeping is done. */
11
+ export declare function mark(node: Marked): void;
12
+ /** Drops one mark from `node`: true when it was the last — the node's
13
+ * verdict readers have re-derived. */
14
+ export declare function unmark(node: Marked): boolean;
@@ -1,28 +1,16 @@
1
1
  import type { Accessor } from "./signals.js";
2
- import { type Store } from "./store/store.js";
2
+ import { type Store } from "./store/types.js";
3
3
  /**
4
- * Declares that in-flight work will change the targeted data: the named
5
- * slot(s) — and everything DERIVED from them — read as pending
6
- * (`isPending` → `true`) from the declaration until the surrounding
7
- * transaction settles or reverts. A mark lives on its own channel — a
8
- * refcount on the marked node plus dep-graph reachability in the verdict
9
- * layer — so the marked values themselves stay readable (a mark is a promise
10
- * of change, not an absence of value), no reader ever suspends on one, and
11
- * completion/settlement accounting never sees one. This is the declaration
12
- * verb of the pending model — additive only. A mark can turn pending ON for
13
- * data the graph can't see changing yet; nothing can turn pending OFF while
14
- * a real change is in flight — a quiet `refresh()` re-ask under a mark still
15
- * reads pending (declaring the reload is what makes it a real question).
16
- *
17
- * Targets:
18
- * - `affects(store)` — a store proxy (any record, root or nested): every
19
- * record reachable from it at declaration time reads pending, including
20
- * through captured child proxies (e.g. `<For>` rows). Siblings are
21
- * untouched; records added after the declaration are not covered.
22
- * - `affects(record, key)` — exactly the named slot of the record. One key
23
- * per call (keys do NOT form a path — target the owning record directly).
24
- * - `affects(accessor)` — a source accessor (signal or memo): the source
25
- * reads pending.
4
+ * Declares that in-flight work will change the targeted data: the source —
5
+ * and everything derived from it — reads as pending (`isPending` → `true`)
6
+ * from the declaration until the surrounding transaction settles — or, if
7
+ * the source's own fetch is still in flight then (a declared reload's
8
+ * `refresh()`), until that fetch lands. A mark is a promise of change, not an absence of value: the marked values stay
9
+ * readable, no reader suspends on one, and it holds nothing — the
10
+ * transaction's completion never waits on a mark. Pendingness is additive:
11
+ * a mark can turn pending on for data the graph cannot see changing yet
12
+ * (a declared reload's `refresh()` is a quiet re-ask on its own); nothing
13
+ * turns it off while the mark is live.
26
14
  *
27
15
  * Typically called at the top of an `action` alongside optimistic writes —
28
16
  * both are up-front declarations about the same mutation. Outside any
@@ -30,14 +18,8 @@ import { type Store } from "./store/store.js";
30
18
  *
31
19
  * @example
32
20
  * ```ts
33
- * const send = action(function* (text: string) {
34
- * setState(s => { s.messages.push({ text, status: "sending" }); });
35
- * affects(state.messages.at(-1)!, "status"); // this slot pends until settle
36
- * yield api.send(text);
37
- * });
38
- *
39
21
  * const reload = action(function* () {
40
- * affects(thing); // the whole store pends…
22
+ * affects(thing); // `thing` and its derivations pend…
41
23
  * refresh(thing); // …over this otherwise-quiet re-ask
42
24
  * yield api.done();
43
25
  * });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@solidjs/signals/attribution` — the "why did this run" engine.
3
+ *
4
+ * A separate entry on purpose: the core ships only the hook slot
5
+ * (`OBSERVE.attribution`, which `enable()` installs into) and the declared
6
+ * frames (`withInteraction`, `withOrigin`); the engine that turns hook facts
7
+ * into re-run explanations, cost tables, holds and feedback lives here, so an
8
+ * observe build carries it only when something imports this module. The dev
9
+ * and observe tiers resolve to this file; the prod tier resolves to
10
+ * `attribution.prod.ts`, an inert engine with the same surface, so app code
11
+ * can import it unconditionally.
12
+ */
13
+ export { attribution, formatOrigin, formatRerun, graphSize } from "./core/attribution.js";
14
+ export { costs } from "./core/attribution-costs.js";
15
+ export { feedback } from "./core/attribution-feedback.js";
16
+ export { subscriptions, why } from "./core/attribution-queries.js";
17
+ export type { Acknowledgement, Attribution, AttributionOptions, AttributionValues, ChangeKind, ChangeOrigin, ChangeRecord, CreateEvent, EffectRunEvent, FallbackEvent, FlightEvent, FlightLink, FlushEvent, GraphEvent, GraphSize, HeldWrite, HistoryRecords, HistoryType, HoldEvent, InteractionEvent, NavigationEvent, NavigationHop, RerunEvent, WaterfallRecord } from "./core/attribution.js";
18
+ export type { AttributionCostTables, ScopeCost, WriteCost } from "./core/attribution-costs.js";
19
+ export type { AttributionFeedbackTables, FallbackStats, FeedbackInteraction, FeedbackNavigation, FeedbackSource, FlightStats } from "./core/attribution-feedback.js";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `@solidjs/signals/attribution` as the prod tier resolves it.
3
+ *
4
+ * A prod build has no hook sites — `__OBSERVE__` folded every one out — so an
5
+ * engine installed there would never hear a fact. Rather than make apps guard
6
+ * the import per tier, prod resolves this inert twin: the same `Attribution`
7
+ * surface, every query empty, `enable()` a no-op. Type-checked against the
8
+ * real engine's interface so the two cannot drift.
9
+ */
10
+ import type { Attribution } from "./core/attribution.js";
11
+ import type * as Engine from "./attribution.js";
12
+ export declare const attribution: Attribution;
13
+ export declare const costs: typeof Engine.costs;
14
+ export declare const feedback: typeof Engine.feedback;
15
+ export declare const why: typeof Engine.why;
16
+ export declare const subscriptions: typeof Engine.subscriptions;
17
+ export declare const formatRerun: typeof Engine.formatRerun;
18
+ export declare const formatOrigin: typeof Engine.formatOrigin;
19
+ export declare const graphSize: typeof Engine.graphSize;
20
+ export type { Acknowledgement, Attribution, AttributionOptions, AttributionValues, ChangeKind, ChangeOrigin, ChangeRecord, CreateEvent, EffectRunEvent, FallbackEvent, FlightEvent, FlightLink, FlushEvent, GraphEvent, GraphSize, HeldWrite, HistoryRecords, HistoryType, HoldEvent, InteractionEvent, NavigationEvent, NavigationHop, RerunEvent, WaterfallRecord } from "./core/attribution.js";
21
+ export type { AttributionCostTables, ScopeCost, WriteCost } from "./core/attribution-costs.js";
22
+ export type { AttributionFeedbackTables, FallbackStats, FeedbackInteraction, FeedbackNavigation, FeedbackSource, FlightStats } from "./core/attribution-feedback.js";
@@ -1,55 +1,84 @@
1
- import { Queue, type Computed, type Effect } from "./core/index.js";
2
- import type { Signal } from "./core/index.js";
1
+ import { type Transaction } from "./core/scheduler.js";
2
+ import type { Computed, Owner, Signal } from "./core/types.js";
3
3
  import { type Accessor } from "./signals.js";
4
- export interface BoundaryComputed<T> extends Computed<T> {
5
- _propagationMask: number;
6
- }
7
- type RevealSlot = CollectionQueue | RevealController;
8
- type BoolAccessor = () => boolean;
9
- export type RevealOrder = "sequential" | "together" | "natural";
10
- type OrderAccessor = () => RevealOrder;
11
- export declare class RevealController {
12
- _orderAccessor: OrderAccessor;
13
- _collapsedAccessor: BoolAccessor;
14
- _slots: RevealSlot[];
15
- _parentController?: RevealController;
16
- _disabled: Signal<boolean>;
17
- _collapsed: Signal<boolean>;
18
- _ready: boolean;
19
- _minimallyReady: boolean;
20
- _evaluating: boolean;
21
- constructor(order: OrderAccessor, collapsed: BoolAccessor);
22
- _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
23
- _isReady(): boolean;
24
- /**
25
- * "Minimally ready" = this group has something visible to show under its own policy.
26
- * Used by an enclosing `together` group to decide when it can release.
27
- * - `together`: every direct slot is minimally ready.
28
- * - `sequential`: the first owned slot is minimally ready (frontier can advance).
29
- * - `natural`: any owned slot is minimally ready.
30
- */
31
- _isMinimallyReady(): boolean;
32
- _register(slot: RevealSlot): void;
33
- _unregister(slot: RevealSlot): void;
34
- _evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
35
- }
36
- export declare class CollectionQueue extends Queue {
37
- _collectionType: number;
38
- _sources: Set<Computed<any>>;
39
- _tree?: BoundaryComputed<any>;
40
- _pending: boolean;
41
- _disabled: Signal<boolean>;
42
- _error?: Signal<unknown>;
43
- _collapsed: Signal<boolean>;
44
- _revealController?: RevealController;
4
+ interface Boundary {
5
+ /** STATUS_PENDING (loading) or STATUS_ERROR. */
6
+ _type: number;
7
+ _parent: Boundary | null;
8
+ _owner: Owner;
9
+ _tree: Computed<any>;
10
+ /** Null during the output's first pass (its post-check decides then). */
11
+ _output: Computed<any> | null;
12
+ /** Frame readers under it carrying its status: caught, or (loading,
13
+ * showing content) forwarded — the `on` re-arm collects those. Each maps
14
+ * to what it waits on: itself, or (error) the source that threw. */
15
+ _readers: Map<Computed<any>, Computed<any>>;
16
+ /** Loading: has shown content. Fresh again after an `on` re-arm found
17
+ * something pending. */
45
18
  _initialized: boolean;
46
- _onFn: (() => any) | undefined;
47
- _prevOn: any;
48
- constructor(type: number);
49
- run(type: number): void;
50
- notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
51
- _checkSources(): void;
19
+ /** Loading: `on` changed this flush — collecting until the seam. */
20
+ _armed: boolean;
21
+ /** The lane the arming pass was work of (a display-ahead read in `on`:
22
+ * `latest`, `isPending`): the swap it causes is that lane's — shown now,
23
+ * beside the held frame — not the frame's. `_lane` is set when the arm
24
+ * flips the boundary and consumed by the swap pass. */
25
+ _armLane: Transaction | null;
26
+ _lane: Transaction | null;
27
+ /** DEV: the arm was display-ahead (a lane) — the fallback shows now,
28
+ * whatever holds the frame; no LOADING_ON_OUTSIDE_HOLD report. */
29
+ _ahead?: boolean;
30
+ /** The output's last pass chose the fallback: readers under it are off
31
+ * screen (`hiddenBy`). */
32
+ _fallback: boolean;
33
+ /** User effects whose run came due behind the fallback: re-queued at the
34
+ * reveal (`heldRun`). */
35
+ _runs: Set<Computed<any>> | null;
36
+ /** Reveal order (reveal.ts): the controller that owns this slot until it
37
+ * has shown content, and the state it forces — the fallback (`_gated`),
38
+ * or nothing at all (`_collapsed`). */
39
+ _reveal: object | null;
40
+ _gated: boolean;
41
+ _collapsed: boolean;
42
+ _error: Signal<unknown> | null;
43
+ _show: (b: Boundary) => unknown;
44
+ /** The fallback's own computed, in its own scope like `Show`'s function
45
+ * child: instantiated once per show and kept across the output's
46
+ * re-derives while it shows (#3991). */
47
+ _fb: Computed<unknown> | null;
48
+ }
49
+ /** Context key: the reveal controller a Loading boundary created here is a
50
+ * slot of (reveal.ts); a boundary clears it for its content — only direct
51
+ * children are slots. */
52
+ export declare const REVEAL: unique symbol;
53
+ /** Reveal order (reveal.ts), installed when something imports
54
+ * `createRevealOrder`: a Loading boundary registers as a slot of the
55
+ * controller in its context, tells it when its readiness changed, and
56
+ * leaves it when it has shown content. */
57
+ export interface RevealHooks {
58
+ _register(controller: object, b: Boundary): void;
59
+ _unregister(controller: object, b: Boundary): void;
60
+ _changed(controller: object): void;
52
61
  }
62
+ export declare let revealHooks: RevealHooks | null;
63
+ export declare function setRevealHooks(h: RevealHooks): void;
64
+ export type { Boundary };
65
+ export declare function redraw(b: Boundary): void;
66
+ /** Drop the readers that settled or died. Settled: a loading reader no
67
+ * longer pending; an error's source neither errored nor in flight. A reader
68
+ * that landed but is held (its value staged in a transaction) is not: the
69
+ * content reveals at the commit, with its run. The tree is: the output reads
70
+ * it and enters the transaction itself (its committed value shows until the
71
+ * landing). The statuses that keep a reader: pending — and its error, for an
72
+ * error boundary (`_type` is the status it catches) — on the reader or its
73
+ * source. A reader pending again after the source that threw answered (it
74
+ * re-asks through a memo that carried the error) has no new answer yet: the
75
+ * error stays the display (D-39: a pending is not a value; async-gen 91501
76
+ * #1831). */
77
+ export declare function prune(b: Boundary, pass: boolean): number;
78
+ /** Reveal order: a slot is ready when its content can show — it has shown
79
+ * content, or nothing under it is unready (the tree neither pending nor
80
+ * born held, no reader waited on). */
81
+ export declare function ready(b: Boundary): boolean;
53
82
  /**
54
83
  * Lower-level primitive that backs the `<Loading>` flow control. Catches
55
84
  * pending async reads inside `fn` and renders `fallback` until they settle.
@@ -59,8 +88,27 @@ export declare class CollectionQueue extends Queue {
59
88
  *
60
89
  * @param fn the tracked subtree
61
90
  * @param fallback the fallback shown while async reads in `fn` are unresolved
62
- * @param options `on` — accessor whose value scopes the boundary; when set,
63
- * transitions caused by writes to other reactive sources are *not* caught
91
+ * @param options `on` — a dependency list: a tracked function whose reads
92
+ * re-arm the boundary. Its return value is irrelevant (never compared);
93
+ * what matters is what it reads. Without `on`, a boundary that has shown
94
+ * content keeps it through a refetch (the pending holds with the
95
+ * transaction). With `on`, a write to anything it reads makes the boundary
96
+ * fresh again: it stops waiting on its current content, and if something
97
+ * under it is pending it shows `fallback` until the new content is ready;
98
+ * if nothing is pending, the notification is a no-op. The fallback lands
99
+ * with the same frame as the change that caused it — now, when nothing
100
+ * else holds that frame; together with the rest of the new page during a
101
+ * held navigation, not before it. If the same data is also read outside
102
+ * the boundary, the frame waits on it and the fallback can never be seen
103
+ * (DEV warns `LOADING_ON_OUTSIDE_HOLD`); the fix is structural — move the
104
+ * outside read under the boundary so one hold owns the data. A frame held
105
+ * past the content's landing by something else (the write's action, other
106
+ * pending data) also shows no fallback; that is a race the fallback may
107
+ * lose, a legitimate outcome, and not reported. A display-ahead read in
108
+ * `on` (`latest()`) shows the fallback now, beside the held frame; that
109
+ * is a capability, not the recommended shape. Optimistic writes and a
110
+ * source going pending notify like any other. The children are not
111
+ * re-created — they stay alive behind the fallback.
64
112
  *
65
113
  * @example
66
114
  * ```tsx
@@ -100,76 +148,3 @@ export declare function createLoadingBoundary<T, U>(fn: () => T, fallback: () =>
100
148
  * ```
101
149
  */
102
150
  export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error: Accessor<unknown>, reset: () => void) => U): Accessor<T | U>;
103
- /**
104
- * Coordinate the reveal timing of sibling loading boundaries.
105
- *
106
- * Accepts reactive accessors:
107
- * - `order`: `"sequential"` (default) | `"together"` | `"natural"`.
108
- * - `"sequential"` — classic frontier reveal: siblings reveal in registration order
109
- * as each resolves; later siblings stay hidden until earlier ones complete.
110
- * - `"together"` — every direct slot stays on its fallback until the whole group
111
- * is "minimally ready" (each direct slot has produced its own first visible
112
- * content under its own order), then the whole group releases at once.
113
- * - `"natural"` — children reveal independently (as each resolves). At the top
114
- * level this is a no-op compared to not using `createRevealOrder`; the mode
115
- * exists for nesting, where the group registers as a single composite slot to
116
- * any enclosing `createRevealOrder`.
117
- * - `collapsed`: only meaningful when `order === "sequential"`. When set, tail siblings
118
- * past the frontier suppress their own fallback output. Ignored under `"together"`
119
- * and `"natural"` — those orders have no frontier.
120
- *
121
- * Nested `createRevealOrder` groups compose: the inner controller registers as a
122
- * single slot in the outer controller and is held on its fallbacks until the outer
123
- * releases that slot. Once released, the inner controller runs its own order locally
124
- * over anything still pending. There is no opt-out from an outer hold.
125
- *
126
- * "Minimally ready" is what an order considers its first visible content:
127
- * - `sequential` — frontier-0 is minimally ready (leaf: on resolve; nested: via its
128
- * own minimal signal).
129
- * - `together` — every direct slot is minimally ready.
130
- * - `natural` — any direct slot has visible content (leaves on resolve; nested
131
- * composites via their own minimal signal).
132
- *
133
- * @example
134
- * ```ts
135
- * // Primitive form of `<Reveal>` — coordinate sibling loading boundaries
136
- * // programmatically. App code uses the JSX `<Reveal>` component instead.
137
- * // Both options are accessors so they can react to state changes.
138
- * createRevealOrder(
139
- * () => renderSiblings(),
140
- * { order: () => mode(), collapsed: () => true }
141
- * );
142
- * ```
143
- */
144
- export declare function createRevealOrder<T>(fn: () => T, options?: {
145
- order?: OrderAccessor;
146
- collapsed?: BoolAccessor;
147
- }): T;
148
- /**
149
- * Resolves a children value to its renderable form: unwraps zero-arg functions
150
- * (accessors), recursively flattens arrays, and optionally skips
151
- * non-rendering values (`null`, `undefined`, `true`, `false`, `""`).
152
- *
153
- * Used internally by flow components and by the renderer to walk a children
154
- * tree. App code rarely needs this directly — see `children()` in `solid-js`
155
- * for the user-facing helper that memoizes the result.
156
- *
157
- * @param children value or array of values to flatten
158
- * @param options
159
- * - `skipNonRendered` — drop values that won't render
160
- * - `doNotUnwrap` — leave function children as-is (caller will resolve)
161
- *
162
- * @example
163
- * ```ts
164
- * // Custom renderer walking a children tree manually. Most authors should
165
- * // use `children()` from solid-js, which memoizes the resolved value.
166
- * function renderChildren(value: unknown): unknown {
167
- * return flatten(value, { skipNonRendered: true });
168
- * }
169
- * ```
170
- */
171
- export declare function flatten(children: any, options?: {
172
- skipNonRendered?: boolean;
173
- doNotUnwrap?: boolean;
174
- }): any;
175
- export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -16,26 +16,40 @@
16
16
  * submission tracking layered on top. The shared name is deliberate.
17
17
  *
18
18
  * Wraps a generator function so each invocation runs as a single transaction
19
- * (a "transition") that batches every signal/store write between yields. The
20
- * surrounding UI sees one atomic update per yielded step; nothing is committed
21
- * until the action either completes or the next `yield` resolves.
19
+ * that holds every signal/store write between yields. The surrounding UI sees
20
+ * one atomic update when the action completes; nothing is committed until
21
+ * every action in the transaction has returned.
22
22
  *
23
23
  * `yield` is the transaction-safe suspension point: the action waits for a
24
24
  * yielded promise and re-enters the transaction before running the code after
25
25
  * it. A plain `await` does NOT — the runtime has no hook into an async
26
- * generator's internal await continuations, so writes to fresh signals
27
- * between an `await` and the next `yield` escape the transaction and commit
28
- * immediately. `await` is still the ergonomic choice for typed results; just
29
- * put a bare `yield` before any writes that follow it:
26
+ * generator's internal await continuations, so code between an `await` and
27
+ * the next `yield` runs OUTSIDE the transaction: writes to fresh signals
28
+ * commit immediately, and anything that creates a reader there — `until()`,
29
+ * `latest()`, a memo or effect, a mount — is created mainline, where a read of
30
+ * this action's held state makes it born held (A29): staged with the
31
+ * transaction and replayed at its commit. `await` is still the ergonomic
32
+ * choice for typed results; just put a bare `yield` before any write or
33
+ * reader creation that follows it — including the expression of the next
34
+ * `yield`, which is evaluated before the step re-enters:
30
35
  *
31
36
  * ```ts
32
37
  * const saved = await api.createTodo(text); // typed result
33
- * yield; // re-enter the transaction before writing
38
+ * yield; // re-enter the transaction before writing or reading
34
39
  * setTodos(t => { ... });
40
+ * yield until(() => todos.some(t => t.id === saved.id));
35
41
  * ```
36
42
  *
43
+ * The same holds inside an async helper the action yields
44
+ * (`yield (async () => { ... })()`): everything after its first `await` runs
45
+ * outside the transaction. An `await refresh(x)` or `await until(...)` there
46
+ * waits for this action's commit, which waits on the helper, so it hangs
47
+ * whenever `x` re-ran during the action (#4263) and works otherwise. Call
48
+ * `refresh(x)` in the generator once the helper returns; `yield` it only when
49
+ * the action needs the fresh value.
50
+ *
37
51
  * (For the same reason, don't call `flush()` inside an action body — it
38
- * drains the transaction mid-step.)
52
+ * cannot reveal the held writes and is refused.)
39
53
  *
40
54
  * Each call returns a `Promise` that resolves with the generator's return
41
55
  * value, or rejects if it throws. Pair with `createOptimistic` /
@@ -1,21 +1,49 @@
1
1
  import { NotReadyError } from "./error.js";
2
- import { type OptimisticLane } from "./lanes.js";
3
2
  import type { Computed, Link } from "./types.js";
4
3
  export declare function addPendingSource(el: Computed<any>, source: Computed<any>): boolean;
4
+ export declare function removePendingSource(el: Computed<any>, source: Computed<any>): boolean;
5
5
  /**
6
6
  * A loading-window node hit an unready source (sync throw in recompute, or a
7
7
  * NotReadyError-rejected flight): register for the source's settle — the
8
8
  * settlePendingSource walk runs off `_pendingSources` + `_blocked` alone —
9
- * with NO read-visible pending status, no downstream propagation, no
10
- * transition, no lane registration. Commit #0 keeps serving.
9
+ * with NO read-visible pending status and no downstream propagation. Commit
10
+ * #0 keeps serving.
11
11
  */
12
12
  export declare function parkLoadingWindow(el: Computed<any>, e: NotReadyError): void;
13
13
  export declare function setPendingError(el: Computed<any>, source?: Computed<any>, error?: any): void;
14
14
  export declare function forEachDependent(el: Computed<any>, fn: (node: Computed<any>, link: Link) => void): void;
15
+ export declare function releaseIfSettledUnobserved(node: Computed<any>): void;
15
16
  export declare function releaseSettledDependents(el: Computed<any>): void;
17
+ /** D-41: an error a pass of a held node found is an answer of
18
+ * that frame — it ends the wait like a value and shows when a value would.
19
+ * Staged like one: `_pendingValue` carries it (CONFIG_STAGED_ERROR), readers
20
+ * in the hold derive from it (`serve` throws it), and the commit publishes
21
+ * it through the ordinary error path (`commitPendingNode` → `notifyStatus`),
22
+ * dependents included. Not for a lane pass, nor a node with no shown value
23
+ * (born held — its error has no frame to wait behind): those publish now,
24
+ * as before. Returns whether the error was staged. */
25
+ export declare function stageError(el: Computed<any>, error: any, inPass?: boolean): boolean;
16
26
  export declare function settleErroredDependents(el: Computed<any>, error: any): void;
17
- export declare function settlePendingSource(el: Computed<any>): void;
27
+ export declare function settlePendingSource(el: Computed<any>, source?: Computed<any>): void;
18
28
  export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
19
- export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
29
+ /** Fire and clear a node's iterator-flight cancellation hook (#3122). */
30
+ export declare function releaseFlightTeardown(el: Computed<any>): void;
31
+ /**
32
+ * Internal (not a package export): run `fn` when the current pass's flight
33
+ * is superseded, at the same instant as the iterator close above, instead of
34
+ * when the replacing pass commits (owner cleanups wait for that). Chains onto
35
+ * the node's teardown slot; fires once with it. A no-op unless the ambient
36
+ * owner is a computed in its own pass. `consumeIterator` fills the slot
37
+ * before its first pull, so a source opened in an async generator's body
38
+ * (`for await`) composes after the generator's close.
39
+ */
40
+ export declare function onSupersede(fn: () => void): void;
41
+ export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void, onError?: (error: unknown, pending: boolean) => void): T;
20
42
  export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
21
- export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
43
+ export declare function notifyStatus(el: Computed<any>, status: number, error?: any): void;
44
+ /** The dependents' half of `notifyStatus`: `el`'s status reaches each
45
+ * subscriber as a propagated mark (or a re-derive). On its own for a store
46
+ * family's leaves, which are not the derive's dependents — the family
47
+ * propagates the derive's status from each leaf to the leaf's readers
48
+ * (store/projection.ts `wakeFamily`), exactly as a memo's would reach its. */
49
+ export declare function propagateStatus(el: Computed<any>, status: number, error: any): void;
@@ -0,0 +1,35 @@
1
+ export interface ScopeCost {
2
+ name: string;
3
+ kind: "effect" | "memo";
4
+ runs: number;
5
+ selfMs: number;
6
+ /**
7
+ * Self-time of PLAIN, non-held runs that produced an unchanged value —
8
+ * the recoverable number. Overlay runs (optimistic/transition) are never
9
+ * counted here: an optimistic recompute landing back on the committed
10
+ * value is the mechanism working, not waste.
11
+ */
12
+ wastedMs: number;
13
+ /** Self-time spent in optimistic/transition (overlay) runs. */
14
+ overlayMs: number;
15
+ }
16
+ export interface WriteCost {
17
+ /** Root cause name (a signal write, async landing, or refresh target). */
18
+ name: string;
19
+ /** Number of downstream re-runs this root triggered. */
20
+ runs: number;
21
+ /** Summed self-time of every downstream re-run it caused. */
22
+ downstreamMs: number;
23
+ }
24
+ export interface AttributionCostTables {
25
+ /** Ranked by self-time. */
26
+ scopes: ScopeCost[];
27
+ /** Ranked by the total downstream re-run time each root write caused. */
28
+ writes: WriteCost[];
29
+ }
30
+ /**
31
+ * Aggregated cost tables since `enable()`: `scopes` ranked by self-time
32
+ * (with `wastedMs` = time spent on unchanged-value runs), `writes` ranked by
33
+ * total downstream re-run time each root write caused.
34
+ */
35
+ export declare function costs(): AttributionCostTables;
@@ -0,0 +1,133 @@
1
+ export interface FeedbackSource {
2
+ /** The async nodes the holds waited on; empty when an action alone kept them open. */
3
+ sources: string[];
4
+ holds: number;
5
+ /** Summed wait across the holds (ms). */
6
+ heldMs: number;
7
+ worstMs: number;
8
+ /** Holds with no acknowledgment at all — the SILENT_HOLD signature, at any duration. */
9
+ silent: number;
10
+ silentMs: number;
11
+ /** Holds whose only acknowledgment was a `latest()` shadow: the input showed, nothing said "loading". */
12
+ latestOnly: number;
13
+ /**
14
+ * Holds whose quiescent tail (last write to join → commit) reached
15
+ * `longHolds.infoMs`, acknowledged or not — the LONG_HOLD signature at the
16
+ * table level. The affordance is not the whole answer there: a fallback
17
+ * (`Loading` keyed with `on`), a preload, a cache, or a faster source is.
18
+ * `longMs` sums the tails.
19
+ */
20
+ long: number;
21
+ longMs: number;
22
+ /** Which affordances answered, and in how many holds — ranked. */
23
+ acknowledgedBy: {
24
+ by: string;
25
+ holds: number;
26
+ }[];
27
+ /** Interactions whose writes were held here, ranked by holds. */
28
+ interactions: {
29
+ interaction: string;
30
+ holds: number;
31
+ }[];
32
+ /** Distinct root writes that were held. */
33
+ writes: string[];
34
+ /** Holds an action opened or joined. */
35
+ actions: number;
36
+ }
37
+ export interface FeedbackInteraction {
38
+ /** `click on button#next "Next →"` — type and target; repeated dispatches fold together. */
39
+ interaction: string;
40
+ /** Distinct dispatches seen (by dispatch time). */
41
+ dispatches: number;
42
+ /** Re-runs traced back to this interaction, and their summed self-time. */
43
+ runs: number;
44
+ selfMs: number;
45
+ /** The most re-run self-time a single dispatch caused — the long-flush hazard. */
46
+ worstDispatchMs: number;
47
+ /** Holds this interaction's writes waited in — the silent-hold hazard. */
48
+ holds: number;
49
+ heldMs: number;
50
+ silentMs: number;
51
+ worstHoldMs: number;
52
+ }
53
+ /** Per async source: how many flights it started, and how many it threw away. */
54
+ export interface FlightStats {
55
+ source: string;
56
+ /** Flights registered (a recompute that produced a new promise/iterable). */
57
+ flights: number;
58
+ /** Flights that landed (whether or not the value changed). */
59
+ landed: number;
60
+ /**
61
+ * Flights superseded by a newer one before landing — the search-as-you-type
62
+ * signature when large: every keystroke asked, most answers were discarded.
63
+ * A debounced/equality-gated derivation between input and fetch is the repair.
64
+ */
65
+ abandoned: number;
66
+ /** Summed and worst wall time of landed flights (ms). */
67
+ landedMs: number;
68
+ worstMs: number;
69
+ }
70
+ /** Per loading boundary: how long, and how briefly, it showed its fallback. */
71
+ export interface FallbackStats {
72
+ /** The boundary's owner path (`<App> › <Feed>`), or `boundary` when unnamed. */
73
+ boundary: string;
74
+ /** Times the fallback was shown. */
75
+ shows: number;
76
+ /** Summed and worst fallback duration (ms) across completed shows. */
77
+ shownMs: number;
78
+ worstMs: number;
79
+ /**
80
+ * Shows shorter than the flash window (default 150ms): a spinner that
81
+ * appeared and vanished — the other end of the SILENT_HOLD spectrum, too
82
+ * much feedback for too little wait. A preload, a cache, or lifting the
83
+ * fetch above the boundary removes the flash.
84
+ */
85
+ flashes: number;
86
+ }
87
+ /**
88
+ * Per route: what navigating to it cost, folded from settled
89
+ * `NavigationEvent`s — the route-level view a router integration used to
90
+ * have to build itself, from the runtime's own facts.
91
+ */
92
+ export interface FeedbackNavigation {
93
+ /** The route pattern (`/users/:id`), or the concrete `to` when the router gave no pattern. */
94
+ name: string;
95
+ navigations: number;
96
+ /** Summed and worst request-to-settle time (ms) across settled navigations. */
97
+ settledMs: number;
98
+ worstMs: number;
99
+ /** Navigations whose writes waited in a hold, and the time they waited. */
100
+ held: number;
101
+ heldMs: number;
102
+ /** Held navigations the screen acknowledged nothing for — the SILENT_HOLD signature. */
103
+ silent: number;
104
+ /** Navigations overwritten by a later one before they landed. */
105
+ superseded: number;
106
+ /** Navigations a redirect sent elsewhere on the way (keyed by where they ended up). */
107
+ redirected: number;
108
+ }
109
+ export interface AttributionFeedbackTables {
110
+ sources: FeedbackSource[];
111
+ interactions: FeedbackInteraction[];
112
+ /** Routes ranked by the time spent held navigating to them, then by total settle time. */
113
+ navigations: FeedbackNavigation[];
114
+ /** Async sources ranked by abandoned flights, then by flights. */
115
+ flights: FlightStats[];
116
+ /** Loading boundaries ranked by flashes, then by time shown. */
117
+ fallbacks: FallbackStats[];
118
+ }
119
+ /**
120
+ * What the user waited on, folded from holds and the interaction on each
121
+ * re-run: `sources` ranks async sources by the silent time writes spent held
122
+ * behind them (with which affordances answered, how often, and which
123
+ * interactions were held); `interactions` ranks user events by the total time
124
+ * they cost — re-run work caused (long-flush hazard) beside time held
125
+ * (silent-hold hazard). Facts at every duration; SILENT_HOLD is the
126
+ * thresholded verdict. Three more tables round out the picture: `navigations`
127
+ * ranks routes by the time spent held navigating to them (folded from settled
128
+ * navigations), `flights` counts each async source's flights and how many
129
+ * were abandoned before landing (the re-ask storm), and `fallbacks` measures
130
+ * how long each loading boundary showed its fallback and how often that was a
131
+ * flash.
132
+ */
133
+ export declare function feedback(): AttributionFeedbackTables;