@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.15

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 (121) hide show
  1. package/dist/dev-shared.js +2059 -3768
  2. package/dist/dev.attribution.js +237 -101
  3. package/dist/dev.js +7466 -8497
  4. package/dist/observe/affects.js +128 -104
  5. package/dist/observe/boundaries.js +492 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +243 -379
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +394 -253
  10. package/dist/observe/core/constants.js +120 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +874 -1440
  13. package/dist/observe/core/dev.js +3 -3
  14. package/dist/observe/core/effect.js +73 -84
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +62 -71
  17. package/dist/observe/core/heap.js +75 -98
  18. package/dist/observe/core/invariants.js +1 -34
  19. package/dist/observe/core/lanes.js +750 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +719 -1356
  22. package/dist/observe/core/verdict.js +314 -621
  23. package/dist/observe/flatten.js +79 -0
  24. package/dist/observe/index.js +15 -13
  25. package/dist/observe/map.js +232 -235
  26. package/dist/observe/reveal.js +212 -0
  27. package/dist/observe/signals.js +144 -216
  28. package/dist/observe/store/affects.js +142 -0
  29. package/dist/observe/store/hooks.js +13 -0
  30. package/dist/observe/store/index.js +27 -24
  31. package/dist/observe/store/optimistic.js +571 -0
  32. package/dist/observe/store/projection.js +308 -0
  33. package/dist/observe/store/reconcile.js +259 -0
  34. package/dist/observe/store/store.js +1988 -277
  35. package/dist/observe/store/storePath.js +1 -1
  36. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  37. package/dist/observe/store/types.js +73 -0
  38. package/dist/observe/store/utils.js +1 -13
  39. package/dist/prod/affects.js +130 -106
  40. package/dist/prod/boundaries.js +476 -654
  41. package/dist/prod/core/action.js +71 -74
  42. package/dist/prod/core/async.js +306 -444
  43. package/dist/prod/core/constants.js +117 -186
  44. package/dist/prod/core/context.js +3 -3
  45. package/dist/prod/core/core.js +888 -1462
  46. package/dist/prod/core/effect.js +88 -99
  47. package/dist/prod/core/external.js +5 -5
  48. package/dist/prod/core/graph.js +62 -71
  49. package/dist/prod/core/heap.js +75 -98
  50. package/dist/prod/core/invariants.js +1 -32
  51. package/dist/prod/core/lanes.js +712 -181
  52. package/dist/prod/core/owner.js +75 -96
  53. package/dist/prod/core/scheduler.js +686 -1335
  54. package/dist/prod/core/verdict.js +309 -621
  55. package/dist/prod/flatten.js +77 -0
  56. package/dist/prod/index.js +15 -13
  57. package/dist/prod/map.js +142 -145
  58. package/dist/prod/reveal.js +212 -0
  59. package/dist/prod/signals.js +155 -227
  60. package/dist/prod/store/affects.js +142 -0
  61. package/dist/prod/store/hooks.js +13 -0
  62. package/dist/prod/store/index.js +26 -19
  63. package/dist/prod/store/optimistic.js +566 -0
  64. package/dist/prod/store/projection.js +301 -0
  65. package/dist/prod/store/reconcile.js +259 -0
  66. package/dist/prod/store/store.js +1883 -272
  67. package/dist/prod/store/storePath.js +1 -1
  68. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  69. package/dist/prod/store/types.js +73 -0
  70. package/dist/prod/store/utils.js +1 -11
  71. package/dist/types/affects.d.ts +11 -30
  72. package/dist/types/boundaries.d.ts +66 -176
  73. package/dist/types/carved.d.ts +1 -0
  74. package/dist/types/core/action.d.ts +5 -6
  75. package/dist/types/core/async.d.ts +10 -5
  76. package/dist/types/core/attribution-hooks.d.ts +20 -1
  77. package/dist/types/core/attribution.d.ts +26 -11
  78. package/dist/types/core/constants.d.ts +130 -180
  79. package/dist/types/core/core.d.ts +134 -264
  80. package/dist/types/core/dev.d.ts +2 -2
  81. package/dist/types/core/effect.d.ts +0 -7
  82. package/dist/types/core/graph.d.ts +7 -1
  83. package/dist/types/core/heap.d.ts +5 -7
  84. package/dist/types/core/index.d.ts +5 -5
  85. package/dist/types/core/invariants.d.ts +0 -29
  86. package/dist/types/core/lanes.d.ts +74 -86
  87. package/dist/types/core/owner.d.ts +3 -3
  88. package/dist/types/core/scheduler.d.ts +255 -331
  89. package/dist/types/core/types.d.ts +45 -85
  90. package/dist/types/core/verdict.d.ts +3 -0
  91. package/dist/types/flatten.d.ts +8 -0
  92. package/dist/types/index.d.ts +6 -4
  93. package/dist/types/reveal.d.ts +19 -0
  94. package/dist/types/signals.d.ts +35 -91
  95. package/dist/types/store/affects.d.ts +12 -0
  96. package/dist/types/store/hooks.d.ts +48 -0
  97. package/dist/types/store/index.d.ts +34 -15
  98. package/dist/types/store/optimistic.d.ts +23 -0
  99. package/dist/types/store/projection.d.ts +18 -0
  100. package/dist/types/store/reconcile.d.ts +3 -0
  101. package/dist/types/store/store.d.ts +132 -145
  102. package/dist/types/store/storePath.d.ts +1 -1
  103. package/dist/types/store/target.d.ts +151 -0
  104. package/dist/types/store/types.d.ts +84 -0
  105. package/package.json +1 -1
  106. package/dist/observe/core/optimistic.js +0 -669
  107. package/dist/observe/store/next/optimistic.js +0 -717
  108. package/dist/observe/store/next/projection.js +0 -266
  109. package/dist/observe/store/next/reconcile.js +0 -375
  110. package/dist/observe/store/next/store.js +0 -2608
  111. package/dist/prod/core/optimistic.js +0 -658
  112. package/dist/prod/store/next/optimistic.js +0 -710
  113. package/dist/prod/store/next/projection.js +0 -257
  114. package/dist/prod/store/next/reconcile.js +0 -373
  115. package/dist/prod/store/next/store.js +0 -2484
  116. package/dist/types/core/optimistic.d.ts +0 -6
  117. package/dist/types/store/next/optimistic.d.ts +0 -25
  118. package/dist/types/store/next/projection.d.ts +0 -27
  119. package/dist/types/store/next/reconcile.d.ts +0 -10
  120. package/dist/types/store/next/store.d.ts +0 -145
  121. package/dist/types/store/next/target.d.ts +0 -196
@@ -1,4 +1,3 @@
1
- import type { OptimisticLane } from "./lanes.js";
2
1
  import type { Computed, Signal } from "./types.js";
3
2
  /**
4
3
  * Test-mode invariant checks for the async/transition/lane machinery.
@@ -17,20 +16,7 @@ import type { Computed, Signal } from "./types.js";
17
16
  * defines `__TEST__: false`.
18
17
  */
19
18
  type AnyNode = Signal<any> | Computed<any>;
20
- /** Wired by core.ts at module init to avoid import cycles. */
21
- export declare const InvariantHooks: {
22
- pendingProbeActive: (() => boolean) | null;
23
- /** Fresh oracle for what an isPending companion SHOULD read right now. */
24
- computePendingState: ((node: AnyNode) => boolean) | null;
25
- };
26
19
  export declare function devTrackHeldPending(node: AnyNode): void;
27
- export declare function devTrackCompanionOwner(node: AnyNode): void;
28
- /** #3503: a firewall child the store released (unobserved sweep) leaves the
29
- * registry with it — the runtime drops it from `_companionChildren` so the
30
- * projection stops retaining it; the test-only set must not either. */
31
- export declare function devUntrackCompanionOwner(node: AnyNode): void;
32
- export declare function devTrackOptimistic(node: AnyNode): void;
33
- export declare function devTrackAffects(node: AnyNode): void;
34
20
  /**
35
21
  * Open/close the sanctioned registration window. Call sites are `__DEV__`
36
22
  * guarded (no prod cost); the code inside the window must not throw.
@@ -38,21 +24,6 @@ export declare function devTrackAffects(node: AnyNode): void;
38
24
  export declare function beginAsyncReporterWrites(): void;
39
25
  export declare function endAsyncReporterWrites(): void;
40
26
  export declare function createAsyncReporters(): Map<Computed<any>, Set<Computed<any>>>;
41
- /**
42
- * INV-2: a node with an *active* override must be registered for reversion in
43
- * the queue's or a transition's `_optimisticNodes`. An unregistered active
44
- * override would survive transition completion forever. Runs at the end of
45
- * every flush (not just quiescence — the invariant holds mid-transition).
46
- * (There is no revert-target requirement: authoritative values commit
47
- * silently into `_value` under the override mask — A17 — so reverting is
48
- * just dropping the override.)
49
- */
50
- export declare function devCheckActiveOverrides(isRegisteredForRevert: (node: AnyNode) => boolean): void;
51
- /** INV-1: an isPending() probe must never leak past its own call. */
52
- export declare function devCheckFlushStart(): void;
53
- /** INV-5: a merged lane's work moved to its root on merge and must stay empty. */
54
- export declare function devCheckMergedLaneEmpty(lane: OptimisticLane): void;
55
- export declare function devCensusCompanions(isQueuedForCommit?: (node: AnyNode) => boolean): void;
56
27
  /**
57
28
  * Quiescence checks. Run only when the system is fully drained: nothing
58
29
  * scheduled, no active/stashed transitions, no live lanes. At that point no
@@ -1,88 +1,76 @@
1
- import { hasActiveOverride } from "./core.js";
2
- export { hasActiveOverride };
3
- import { type QueueCallback, type Transition } from "./scheduler.js";
1
+ import { type Transaction } from "./scheduler.js";
4
2
  import type { Computed, Signal } from "./types.js";
5
- /**
6
- * OptimisticLane represents the context for a single optimistic write.
7
- * Each optimistic signal creates its own lane. Lanes merge when their
8
- * dependency graphs overlap.
9
- */
10
- export interface OptimisticLane {
11
- _source: Signal<any>;
12
- _pendingAsync: Set<Computed<any>>;
13
- _effectQueues: [QueueCallback[], QueueCallback[]];
14
- _mergedInto: OptimisticLane | null;
15
- _transition: Transition | null;
16
- _parentLane: OptimisticLane | null;
17
- }
18
- export declare const signalLanes: WeakMap<Signal<any>, OptimisticLane>;
19
- export declare const activeLanes: Set<OptimisticLane>;
20
- /**
21
- * Get an existing lane for a signal or create a new one.
22
- * Reuses lane for multiple writes to the same signal.
23
- */
24
- export declare function getOrCreateLane(signal: Signal<any>): OptimisticLane;
25
- /**
26
- * Union-find: find the root lane.
27
- */
28
- export declare function findLane(lane: OptimisticLane): OptimisticLane;
29
- /**
30
- * Is the lane held? `_pendingAsync` records the async the lane OWNS (derived
31
- * under it); a transaction's reporter map records the async a render effect
32
- * OBSERVED pending with no boundary taking it (INV-3, the one registration
33
- * site). A hold needs both — the same rule the transaction itself uses, so a
34
- * memo nobody renders, or one a fallback-showing boundary caught, cannot tear
35
- * a frame and holds nothing (#3289). An orphan lane has no observation record
36
- * and never holds.
3
+ /** A lane node's current value: its guess, or the latest it derived — the
4
+ * staging a shown lane holds for its next reveal, else its slot; the
5
+ * committed value while it has none (its first lane pass in flight). */
6
+ export declare function laneValueOf(el: Signal<any> | Computed<any>): unknown;
7
+ /** What the screen shows for a lane's node: the lane's value once the lane
8
+ * has revealed, the committed truth before. */
9
+ export declare function display(el: Signal<any> | Computed<any>): unknown;
10
+ /** What the writer sees of a node: an unflushed guess to it, else the
11
+ * lane's value or the committed one — what an optimistic updater composes
12
+ * on (a store setter's draft too, store/optimistic.ts). */
13
+ export declare function guessedValueOf<T>(n: Signal<T> | Computed<T>): T;
14
+ /** The unflushed guess to `n`, else NOT_PENDING. */
15
+ export declare function pendingGuessOf(n: Signal<any> | Computed<any>): unknown;
16
+ export declare function optimisticWrite<T>(n: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
17
+ /** The running pass read lane `l`'s work as a derivation: it is `l`'s — or,
18
+ * already another lane's, the frame it computes derives from both guesses
19
+ * and cannot show one without the other (#3335, A15 for lanes): the two
20
+ * lanes are linked — one reveal unit, each blocked while any is — while
21
+ * their lifetimes stay their own (#2912: a guess reverts with its own
22
+ * action, not with the one it shares a reader with). A nested lane reading
23
+ * through an ancestor's guess stays its own (the screen plus its own
24
+ * guesses). */
25
+ export declare function enterLane(l: Transaction, c: Computed<any>): void;
26
+ /** Verdicts (maintainer, 2026-10-01): `isPending` and `latest` are
27
+ * optimistic state the system supplies — a verdict is a guess ("pending,
28
+ * until this lands"; "the proposal is the value") decided at the seam like
29
+ * a user's, and its readers break out of the hold the same way: work of a
30
+ * lane under the holder, shown now, re-derived at the landing, ending with
31
+ * it. Judged at the seam like any lane: blocked while a verdict reader's
32
+ * own derivation is in flight (lane rule 3), shown otherwise. */
33
+ export declare function verdictLane(t: Transaction): Transaction;
34
+ /** A lane pass's node (core.ts `recompute`, before its staging; a pending
35
+ * propagation under a lane pass, async.ts): listed, carrying the lane's
36
+ * value from now (a derivation of a guess — its readers become lane work).
37
+ * Entering the lane supersedes a frame staging the node carried: this
38
+ * pass's answer replaces it, and the frame's hold on it is over. An
39
+ * effect's value slot is private (no lane value). A pass in a lane's seat
40
+ * that read none of the lane's world has left it (false): its result is the
41
+ * frame's — a derivation whose branch no longer reaches the guess — and no
42
+ * hold the lane took over from a transaction stays on it (#3698: lane work
43
+ * never makes its node transaction work; a born-held effect's hold went to
44
+ * the lane). A pass interrupted before it got there (pending, errored) did
45
+ * not leave (A30: it never got there). A first pass under a lane is the
46
+ * lane's (ruling A); a guess is written, not derived — it never leaves this
47
+ * way. `errored`: the pass has no answer — or, a lane pass's pending
48
+ * propagation (async.ts `propagateStatus`), the node gone pending. */
49
+ export declare function laneStage(el: Computed<any>, l: Transaction, create: boolean, errored: boolean | Computed<any>): boolean;
50
+ export declare function supersede(n: Signal<any> | Computed<any>, value: unknown, changed: boolean): void;
51
+ /** Truth readers (`until`, `refresh`; CONFIG_AUTHORITATIVE) — pay-for-use:
52
+ * the first one installs these on GlobalQueue (signals.ts `watch`).
37
53
  *
38
- * The observation is looked up per NODE, in whichever live transaction
39
- * recorded it — not in this lane's transaction. Lanes merge across
40
- * transactions (#2912: ownership never travels through lanes), so after a
41
- * merge the root's transaction holds the observations of only one member;
42
- * the async the other member's transaction observed must hold the merged
43
- * reveal just the same (A15 for lanes, #3335).
44
- */
45
- export declare function laneHeld(lane: OptimisticLane): boolean;
46
- /**
47
- * Lanes mirror transitions (#3460): a render effect OFF a HELD lane that reads
48
- * a value the lane is revealing — an override, a `latest()` shadow — sees the
49
- * committed value, exactly as a stale reader of a held transaction does
50
- * (A15 reveal corollary): it publishes now, with the frame that is on screen
51
- * (the lane defers its own readers' runs, so the committed value is what is
52
- * visible), entangles nothing — a sync write is never held by a lane — and
53
- * re-derives at the release. The release re-run rides the lane's own render
54
- * queue, which runs when the lane reveals (runLaneEffects) or its transaction
55
- * commits (cleanupCompletedLanes). A reader ON the lane computes the lane's
56
- * reveal and takes the value as before.
57
- *
58
- * OFF the lane is provenance, not membership — the transaction mirror
59
- * exactly: a stale reader of a transaction is a pass that runs outside it. A
60
- * pass under the lane's own transaction is the lane's work — its write (lane
61
- * posture), or the landing of its async, which re-enters the transaction
62
- * (#3334) and runs a member with no ambient lane. Read as an outsider, that
63
- * pass published the committed view and queued a replay that revealed the
64
- * override beside its unready derivation at the release (`1:0` for an
65
- * optimistic frame that never became ready; #3479 review). Membership is the
66
- * wrong test the other way: a member re-run by a sibling's sync write is a
67
- * mainline pass and shows the committed view.
68
- */
69
- export declare function readsHeldCommitted(owner: Computed<any>, c: Computed<any>): boolean;
70
- /** The ownership relation for a lane hold (core `ownsHold`, §6 ruling 2): the
71
- * running pass owns `lane`'s hold if it runs under the transition that owns
72
- * the lane (the node's, resolved through override ownership and merges) or
73
- * inside the lane itself. */
74
- export declare function ownsLane(lane: OptimisticLane, owner: Computed<any>): boolean;
75
- /**
76
- * Merge two lanes when their dependency graphs overlap.
77
- */
78
- export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
79
- /**
80
- * Resolve a node's lane: follow union-find chain, verify active, clear if stale.
81
- */
82
- export declare function resolveLane(el: Signal<any> | Computed<any>): OptimisticLane | undefined;
83
- export declare function resolveTransition(el: Signal<any> | Computed<any>): Transition | null | undefined;
84
- /**
85
- * Assign or merge a lane onto a node. At convergence points (node already has
86
- * a different active lane), merge unless the node has an active override.
87
- */
88
- export declare function assignOrMergeLane(el: Signal<any> | Computed<any>, sourceLane: OptimisticLane): void;
54
+ * A truth reader's read of a lane node: the lane's value when it is the
55
+ * truth (#3943), else the truth staged beneath a guess, else the committed
56
+ * value. */
57
+ export declare function truthRead(el: Signal<any> | Computed<any>): unknown;
58
+ /** A guess confirmed: its lane's truth readers re-read — of the lane's
59
+ * derivations too, which may be the truth now (#3943). */
60
+ export declare function truthConfirmed(l: Transaction): void;
61
+ /** Lanes. A lane's node is read by its reader's kind: an authoritative
62
+ * reader (`until`) sees the truth — staged beneath a guess, else committed
63
+ * — and is no lane's; an untracked read sees the lane's latest value (A17:
64
+ * "direct read shows optimistic"; A28); a children-forbidden reader sees
65
+ * the frame (A32). A render effect in the frame's seat reading a lane the
66
+ * seam found blocked, or a member whose own flight is up (held or not — the
67
+ * lane-membership ruling, 2026-10-05), sees the screen, re-derived at the
68
+ * reveal (#3460's stale reader) — or, the node a
69
+ * flight that has never shown (nothing to show), waits on it: its own frame
70
+ * holds (A15, #3334), not the lane's parent. Any other tracked reader is
71
+ * the lane's work from this read — a derivation; a leaf reading a lane that
72
+ * has shown, or one the seam has not judged yet (its run waits on the
73
+ * verdict: released if the lane shows, held if it blocks) — and sees the
74
+ * lane's latest. NOT_PENDING falls through: lane work's read of a pending
75
+ * member throws like any. */
76
+ export declare function laneRead(c: Computed<any> | null, el: Signal<any> | Computed<any>): unknown;
@@ -67,9 +67,9 @@ export declare function getOwner(): Owner | null;
67
67
  */
68
68
  export declare function cleanup(fn: Disposable): Disposable;
69
69
  /**
70
- * Returns `true` if the owner has been disposed (or marked zombie pending
71
- * disposal). Pair with a captured owner to bail out of late callbacks whose
72
- * surrounding component already unmounted.
70
+ * Returns `true` if the owner has been disposed. Pair with a captured owner
71
+ * to bail out of late callbacks whose surrounding component already
72
+ * unmounted.
73
73
  *
74
74
  * @example
75
75
  * ```ts