@solidjs/signals 2.0.0-beta.17 → 2.0.0-beta.19

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 (69) hide show
  1. package/README.md +4 -3
  2. package/dist/dev.js +2956 -646
  3. package/dist/node.cjs +6396 -3974
  4. package/dist/prod/affects.js +222 -0
  5. package/dist/prod/boundaries.js +568 -0
  6. package/dist/prod/core/action.js +83 -0
  7. package/dist/prod/core/async.js +394 -0
  8. package/dist/prod/core/constants.js +78 -0
  9. package/dist/prod/core/context.js +67 -0
  10. package/dist/prod/core/core.js +772 -0
  11. package/dist/prod/core/dev.js +3 -0
  12. package/dist/prod/core/effect.js +145 -0
  13. package/dist/prod/core/error.js +59 -0
  14. package/dist/prod/core/external.js +98 -0
  15. package/dist/prod/core/graph.js +91 -0
  16. package/dist/prod/core/heap.js +132 -0
  17. package/dist/prod/core/invariants.js +42 -0
  18. package/dist/prod/core/lanes.js +130 -0
  19. package/dist/prod/core/optimistic.js +265 -0
  20. package/dist/prod/core/owner.js +293 -0
  21. package/dist/prod/core/scheduler.js +689 -0
  22. package/dist/prod/core/verdict.js +293 -0
  23. package/dist/prod/index.js +45 -0
  24. package/dist/prod/map.js +264 -0
  25. package/dist/prod/signals.js +389 -0
  26. package/dist/prod/store/optimistic.js +149 -0
  27. package/dist/prod/store/projection.js +184 -0
  28. package/dist/prod/store/reconcile.js +392 -0
  29. package/dist/prod/store/store.js +739 -0
  30. package/dist/prod/store/storePath.js +103 -0
  31. package/dist/prod/store/utils.js +297 -0
  32. package/dist/types/affects.d.ts +47 -0
  33. package/dist/types/boundaries.d.ts +8 -8
  34. package/dist/types/core/async.d.ts +5 -2
  35. package/dist/types/core/constants.d.ts +8 -0
  36. package/dist/types/core/core.d.ts +12 -69
  37. package/dist/types/core/dev.d.ts +1 -1
  38. package/dist/types/core/external.d.ts +0 -30
  39. package/dist/types/core/heap.d.ts +8 -0
  40. package/dist/types/core/index.d.ts +3 -2
  41. package/dist/types/core/invariants.d.ts +10 -0
  42. package/dist/types/core/optimistic.d.ts +6 -0
  43. package/dist/types/core/owner.d.ts +8 -0
  44. package/dist/types/core/scheduler.d.ts +53 -5
  45. package/dist/types/core/types.d.ts +22 -5
  46. package/dist/types/core/verdict.d.ts +2 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/store/projection.d.ts +0 -1
  49. package/dist/types/store/store.d.ts +32 -14
  50. package/dist/types-cjs/affects.d.cts +47 -0
  51. package/dist/types-cjs/boundaries.d.cts +8 -8
  52. package/dist/types-cjs/core/async.d.cts +5 -2
  53. package/dist/types-cjs/core/constants.d.cts +8 -0
  54. package/dist/types-cjs/core/core.d.cts +12 -69
  55. package/dist/types-cjs/core/dev.d.cts +1 -1
  56. package/dist/types-cjs/core/external.d.cts +0 -30
  57. package/dist/types-cjs/core/heap.d.cts +8 -0
  58. package/dist/types-cjs/core/index.d.cts +3 -2
  59. package/dist/types-cjs/core/invariants.d.cts +10 -0
  60. package/dist/types-cjs/core/optimistic.d.cts +6 -0
  61. package/dist/types-cjs/core/owner.d.cts +8 -0
  62. package/dist/types-cjs/core/scheduler.d.cts +53 -5
  63. package/dist/types-cjs/core/types.d.cts +22 -5
  64. package/dist/types-cjs/core/verdict.d.cts +2 -0
  65. package/dist/types-cjs/index.d.cts +1 -0
  66. package/dist/types-cjs/store/projection.d.cts +0 -1
  67. package/dist/types-cjs/store/store.d.cts +32 -14
  68. package/package.json +8 -6
  69. package/dist/prod.js +0 -4406
@@ -1,12 +1,13 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, isPending, latest, updatePendingSignal, updateChildCompanions, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.js";
2
+ export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.js";
3
3
  export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.js";
4
4
  export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.js";
5
5
  export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
6
6
  export { handleAsync } from "./async.js";
7
+ export { isPending, latest } from "./verdict.js";
7
8
  export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.js";
8
9
  export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.js";
9
10
  export { action } from "./action.js";
10
- export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.js";
11
+ export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.js";
11
12
  export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.js";
12
13
  export * from "./constants.js";
@@ -26,6 +26,7 @@ export declare const InvariantHooks: {
26
26
  export declare function devTrackHeldPending(node: AnyNode): void;
27
27
  export declare function devTrackCompanionOwner(node: AnyNode): void;
28
28
  export declare function devTrackOptimistic(node: AnyNode): void;
29
+ export declare function devTrackAffects(node: AnyNode): void;
29
30
  /**
30
31
  * Open/close the sanctioned registration window. Call sites are `__DEV__`
31
32
  * guarded (no prod cost); the code inside the window must not throw.
@@ -33,6 +34,15 @@ export declare function devTrackOptimistic(node: AnyNode): void;
33
34
  export declare function beginAsyncReporterWrites(): void;
34
35
  export declare function endAsyncReporterWrites(): void;
35
36
  export declare function createAsyncReporters(): Map<Computed<any>, Set<Computed<any>>>;
37
+ /**
38
+ * INV-2: a node with an *active* override must be registered for reversion in
39
+ * the queue's or a transition's `_optimisticNodes`. An unregistered active
40
+ * override would survive transition completion forever. Runs at the end of
41
+ * every flush (not just quiescence — the invariant holds mid-transition).
42
+ * (There is no revert-target requirement: authoritative values commit
43
+ * silently into `_value` under the override mask — A17 — so reverting is
44
+ * just dropping the override.)
45
+ */
36
46
  export declare function devCheckActiveOverrides(isRegisteredForRevert: (node: AnyNode) => boolean): void;
37
47
  /** INV-1: an isPending() probe must never leak past its own call. */
38
48
  export declare function devCheckFlushStart(): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Installs the engine's hooks. Idempotent; called by every module that can
3
+ * create optimistic state (verdict.ts at module top level, createOptimistic
4
+ * and createOptimisticStore at first call) BEFORE any optimistic node exists.
5
+ */
6
+ export declare function installOptimisticEngine(): void;
@@ -9,6 +9,14 @@ export declare function disposeChildren(node: Owner, self?: boolean, zombie?: bo
9
9
  * @internal
10
10
  */
11
11
  export declare function getNextChildId(owner: Owner): string;
12
+ /**
13
+ * The id a freshly-created node inherits: an explicit `options.id` wins;
14
+ * transparent nodes share their parent's id; otherwise the parent's next
15
+ * child id is consumed (or `undefined` outside an id-carrying tree).
16
+ */
17
+ export declare function inheritId(options: {
18
+ id?: string;
19
+ } | undefined, transparent: boolean, parent: Owner | null | undefined): string | undefined;
12
20
  /**
13
21
  * Returns the *next* child id for `owner` without consuming it. Used by
14
22
  * hydration plumbing to peek at the id a future child will receive.
@@ -1,5 +1,5 @@
1
1
  import { type Heap } from "./heap.js";
2
- import { activeLanes, assignOrMergeLane, findLane } from "./lanes.js";
2
+ import { activeLanes, assignOrMergeLane, findLane, type OptimisticLane } from "./lanes.js";
3
3
  import type { Computed, Signal } from "./types.js";
4
4
  export { activeLanes, assignOrMergeLane, findLane };
5
5
  export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.js";
@@ -20,7 +20,6 @@ export declare function resetUnhandledAsync(): void;
20
20
  * @internal
21
21
  */
22
22
  export declare function enforceLoadingBoundary(enabled: boolean): void;
23
- export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
24
23
  export declare function setProjectionWriteActive(value: boolean): void;
25
24
  export declare function setTrackedQueueCallback(value: boolean): void;
26
25
  export type QueueCallback = (type: number) => void;
@@ -34,6 +33,7 @@ export interface Transition {
34
33
  _asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
35
34
  _pendingNodes: Signal<any>[];
36
35
  _optimisticNodes: OptimisticNode[];
36
+ _affectsNodes: OptimisticNode[];
37
37
  _optimisticStores: Set<any>;
38
38
  _actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
39
39
  _queueStash: QueueStub;
@@ -46,7 +46,7 @@ export declare function schedule(): void;
46
46
  * every boundary — app state is undefined at that point, so scheduling stops
47
47
  * entirely rather than limping along with a half-applied update.
48
48
  */
49
- export declare function haltReactivity(): void;
49
+ export declare function haltReactivity(cause?: unknown): void;
50
50
  /** @internal Test/dev-reload hook. Revives scheduling after a halt. */
51
51
  export declare function resetErrorHalt(): void;
52
52
  export interface IQueue {
@@ -78,19 +78,67 @@ export declare class GlobalQueue extends Queue {
78
78
  _pendingNode: Signal<any> | null;
79
79
  _pendingNodes: Signal<any>[];
80
80
  _optimisticNodes: OptimisticNode[];
81
+ _affectsNodes: OptimisticNode[];
81
82
  _optimisticStores: Set<any>;
82
83
  static _update: (el: Computed<unknown>) => void;
83
84
  static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
84
85
  static _runEffect: (el: Computed<unknown>) => void;
85
- static _clearOptimisticStore: ((store: any) => void) | null;
86
+ static _clearOptimisticStores: ((stores: Set<any>) => void) | null;
87
+ static _releaseAffectsScope: ((node: OptimisticNode) => void) | null;
88
+ static _applyAffectsReads: ((el: Computed<any>, sources: (Signal<any> | Computed<any>)[]) => void) | null;
89
+ static _releaseAffectsMarks: ((nodes: OptimisticNode[]) => void) | null;
90
+ static _markAffects: ((node: OptimisticNode) => void) | null;
91
+ static _releaseAffectsMark: ((node: OptimisticNode) => void) | null;
92
+ static _onlyMarkPending: ((el: Computed<any>) => boolean) | null;
93
+ static _collectMarkSources: ((el: Computed<any>, into: OptimisticNode[]) => void) | null;
94
+ static _wireExternalSource: ((self: Computed<any>) => void) | null;
95
+ static _externalUntrack: (<T>(fn: () => T) => T) | null;
96
+ static _syncCompanions: (<T>(el: Signal<T> | Computed<T>, value: T) => void) | null;
97
+ static _updatePendingSignal: ((el: OptimisticNode) => void) | null;
98
+ static _updateChildCompanions: ((el: Computed<any>) => void) | null;
99
+ static _snapCompanions: ((el: OptimisticNode) => void) | null;
100
+ static _latestRead: (<T>(el: Signal<T> | Computed<T>) => T) | null;
101
+ static _pendingCheck: ((el: OptimisticNode, c: Computed<any> | null, owner: OptimisticNode, firewall: Computed<any> | null) => void) | null;
102
+ static _recordFresh: ((el: OptimisticNode, value: any) => void) | null;
103
+ static _applyReask: ((el: Computed<any>, hadReask: boolean) => boolean) | null;
104
+ static _repollVerdicts: ((el: Computed<any>) => void) | null;
105
+ static _witnessAffects: ((node: OptimisticNode) => void) | null;
106
+ static _optimisticWrite: (<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)) => T) | null;
107
+ static _resolveOptimistic: ((nodes: OptimisticNode[]) => void) | null;
108
+ static _stashOptimistic: ((stashedTransition: Transition) => void) | null;
109
+ static _transitionBlocked: ((transition: Transition) => boolean) | null;
110
+ static _cleanupLanes: ((completingTransition: Transition | null) => void) | null;
111
+ static _runLaneEffects: ((type: number) => void) | null;
112
+ static _readStashed: ((el: Signal<any>) => boolean) | null;
113
+ static _gatedRead: ((el: Signal<any>, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
114
+ static _laneSuspends: ((owner: OptimisticNode) => boolean) | null;
115
+ static _laneReadsCommitted: ((el: OptimisticNode, owner: OptimisticNode, c: Computed<any>) => boolean) | null;
116
+ static _recomputeLane: ((el: Computed<any>, own: boolean) => OptimisticLane | null) | null;
117
+ static _laneAsyncPending: ((el: Computed<any>) => void) | null;
118
+ static _laneAsyncSettled: ((el: Computed<any>) => void) | null;
119
+ static _trackOptimisticStore: ((store: any) => void) | null;
86
120
  flush(): void;
87
121
  notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
88
122
  initTransition(transition?: Transition | null): void;
89
123
  }
90
124
  export declare function queuePendingNode(node: Signal<any>): void;
125
+ export declare function armReaskClear(): void;
91
126
  export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
92
127
  export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
93
- export declare function trackOptimisticStore(store: any): void;
128
+ /**
129
+ * Count of live `affects()` registrations across the system (including
130
+ * store-scope inherited marks). Gates the read-path mark check in `read()` so
131
+ * graphs that never use the feature pay one integer compare.
132
+ */
133
+ export declare let activeAffectsMarks: number;
134
+ /**
135
+ * Counter mutation seam for the mark engine in affects.ts: an imported `let`
136
+ * binding is read-only, and the read-path gate above must stay a plain module
137
+ * variable so `read()` pays one integer compare, not a function call.
138
+ *
139
+ * @internal
140
+ */
141
+ export declare function shiftAffectsMarks(delta: 1 | -1): void;
94
142
  export declare const globalQueue: GlobalQueue;
95
143
  /**
96
144
  * Synchronously processes the pending reactive queue, or runs `fn` in a synchronous
@@ -48,6 +48,21 @@ export interface RawSignal<T> {
48
48
  _pendingSignal?: Signal<boolean>;
49
49
  _latestValueComputed?: Computed<T>;
50
50
  _parentSource?: Signal<any> | Computed<any>;
51
+ /**
52
+ * Live `affects()` marks on this node (refcount). Non-zero is declared
53
+ * motion: the node reads pending regardless of graph state, until every
54
+ * declaring transaction settles/reverts and releases its mark.
55
+ */
56
+ _affectsCount?: number;
57
+ /**
58
+ * The mark's identity on the pending-source rails (lazy, see
59
+ * `getAffectsSentinel`). Downstream subscribers hold it in
60
+ * `_pendingSources` exactly like a real in-flight source, but with its own
61
+ * identity so a landing or quiet re-ask on the node itself can't clear it.
62
+ */
63
+ _affectsSentinel?: Computed<any>;
64
+ /** Set only on sentinels: the marked node this sentinel stands for. */
65
+ _affectsFor?: Signal<any> | Computed<any>;
51
66
  }
52
67
  export interface FirewallSignal<T> extends RawSignal<T> {
53
68
  _firewall: Computed<any>;
@@ -90,12 +105,14 @@ export interface Computed<T> extends RawSignal<T>, Owner {
90
105
  _child: FirewallSignal<any> | null;
91
106
  _notifyStatus?: (status?: number, error?: any) => void;
92
107
  /**
93
- * Store-wide optimistic mask (count of this firewall's store targets with
94
- * live optimistic writes). Non-zero decrees the whole store settled for
95
- * `isPending`the store is the primitive the mask covers (A20 re-rule
96
- * 2026-07-07c).
108
+ * Question-scoped pending classification of the node's CURRENT pending
109
+ * window: `true` means the in-flight recompute is a re-ask of the same
110
+ * question (refresh/poll/confirm no tracked input changed value), so the
111
+ * shown answer still answers the question and the node reads NOT pending.
112
+ * Set by `recompute` from `REACTIVE_REASK`, cleared on landing
113
+ * (`clearStatus`). Meaningless while not STATUS_PENDING.
97
114
  */
98
- _optimisticMask?: number;
115
+ _reask: boolean;
99
116
  }
100
117
  export interface Root extends Owner {
101
118
  _root: true;
@@ -0,0 +1,2 @@
1
+ export declare function latest<T>(fn: () => T): T;
2
+ export declare function isPending(fn: () => any): boolean;
@@ -4,6 +4,7 @@ export declare const DEV: Dev | undefined;
4
4
  export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Refreshable, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.js";
5
5
  export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled, onCleanup } from "./signals.js";
6
6
  export type { Accessor, SourceAccessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
7
+ export { affects } from "./affects.js";
7
8
  export { mapArray, repeat, type Maybe } from "./map.js";
8
9
  export * from "./store/index.js";
9
10
  export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten, type RevealOrder } from "./boundaries.js";
@@ -63,4 +63,3 @@ export declare function createProjection<T extends object = {}>(fn: (draft: T) =
63
63
  */
64
64
  export declare function runProjectionComputed<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any), wrapCommit?: (write: () => void) => void, onDraftWrite?: () => void): Computed<void | T>;
65
65
  export declare function createWriteTraps(isActive?: () => boolean, onDraftWrite?: () => void): ProxyHandler<any>;
66
- export declare const writeTraps: ProxyHandler<any>;
@@ -40,8 +40,8 @@ type DataNodes = Record<PropertyKey, DataNode>;
40
40
  *
41
41
  * @internal
42
42
  */
43
- export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
44
- export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p", STORE_MASKED = "m";
43
+ export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
44
+ export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_CUSTOM_PROTO = "c", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p";
45
45
  export type StoreNode = {
46
46
  [$PROXY]: any;
47
47
  [STORE_VALUE]: Record<PropertyKey, any>;
@@ -54,8 +54,6 @@ export type StoreNode = {
54
54
  [STORE_LOOKUP]?: WeakMap<any, any>;
55
55
  [STORE_FIREWALL]?: Computed<any>;
56
56
  [STORE_OPTIMISTIC]?: boolean;
57
- /** This target currently contributes to its firewall's store-wide mask. */
58
- [STORE_MASKED]?: boolean;
59
57
  [STORE_SNAPSHOT_PROPS]?: Record<PropertyKey, any>;
60
58
  };
61
59
  export declare namespace SolidStore {
@@ -83,20 +81,40 @@ export declare function getOverlayLayer(target: StoreNode, property: PropertyKey
83
81
  * override, else held pending value, else committed value.
84
82
  */
85
83
  export declare function visibleNodeValue(node: DataNode): any;
84
+ /**
85
+ * Witness live mark coverage of a record into the active isPending() probe.
86
+ * Tracked reads don't need this — they go through real signal nodes, which
87
+ * carry marks directly (declaration walk or birth inheritance). This covers
88
+ * UNTRACKED probes reading through records whose nodes never materialized
89
+ * (no observer ever subscribed, so no node exists to carry the mark).
90
+ * Callers guard on `pendingCheckActive`, so plain reads never pay for this.
91
+ *
92
+ * @internal
93
+ */
94
+ export declare function witnessAffectsMark(target: StoreNode): void;
95
+ /**
96
+ * Resolves the store nodes an `affects()` declaration marks: with a `key`,
97
+ * the named slot's leaf node (upserted so the mark has an addressable
98
+ * carrier); without, the record's $AFFECTS carrier plus every LIVE node in
99
+ * its subtree (the edges existing readers subscribed through), with the
100
+ * subtree's identities snapshotted into the mark's scope so nodes created
101
+ * during the window — and untracked probes over captured proxies — resolve
102
+ * against it (#2882).
103
+ *
104
+ * @internal
105
+ */
106
+ export declare function getStoreAffectsNodes(target: StoreNode, key?: PropertyKey): DataNode[];
86
107
  export declare function trackSelf(target: StoreNode, symbol?: symbol): void;
87
108
  export declare function notifySelf(target: StoreNode): void;
88
- export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
89
- export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
90
109
  /**
91
- * Store-wide mask bookkeeping (A20 re-rule 2026-07-07c): the store is the
92
- * primitive, so an optimistic write decrees the WHOLE store settled for
93
- * `isPending` firewall, written leaves, untouched siblings, structural
94
- * reads for the lifetime of the override/transition. The firewall carries a
95
- * count of masked targets (nested objects mask independently); companions of
96
- * the firewall and its probed leaves are poked on 0↔1 transitions so an
97
- * already-materialized verdict flips without waiting for another write.
110
+ * The write overlay a walk must read through: optimistic writes shadow
111
+ * regular pending writes, the same resolution order as every proxy trap and
112
+ * `reconcile` (#2850). Merging allocates only in the rare both-present case
113
+ * (a derived optimistic store with an in-flight projection commit).
98
114
  */
99
- export declare function maskStoreTarget(target: StoreNode, on: boolean): void;
115
+ export declare function mergedOverlay(target: StoreNode): Record<PropertyKey, any> | undefined;
116
+ export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
117
+ export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
100
118
  export declare const storeTraps: ProxyHandler<StoreNode>;
101
119
  export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
102
120
  /**
@@ -0,0 +1,47 @@
1
+ import type { Accessor } from "./signals.cjs";
2
+ import { type Store } from "./store/store.cjs";
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. Marks ride the same status rails as real
8
+ * in-flight async, so pendingness flows through memos and effects like any
9
+ * other pending source, while the marked values themselves stay readable
10
+ * (a mark is a promise of change, not an absence of value). This is the
11
+ * declaration verb of the pending model — additive only. A mark can turn
12
+ * pending ON for data the graph can't see changing yet; nothing can turn
13
+ * pending OFF while a real change is in flight — a quiet `refresh()`
14
+ * re-ask under a mark still reads pending (declaring the reload is what
15
+ * 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.
26
+ *
27
+ * Typically called at the top of an `action` alongside optimistic writes —
28
+ * both are up-front declarations about the same mutation. Outside any
29
+ * transaction the mark is released at the end of the current flush.
30
+ *
31
+ * @example
32
+ * ```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
+ * const reload = action(function* () {
40
+ * affects(thing); // the whole store pends…
41
+ * refresh(thing); // …over this otherwise-quiet re-ask
42
+ * yield api.done();
43
+ * });
44
+ * ```
45
+ */
46
+ export declare function affects(target: Accessor<unknown> | Store<object>): void;
47
+ export declare function affects<T extends object>(target: Store<T>, key: keyof T): void;
@@ -20,18 +20,18 @@ export declare class RevealController {
20
20
  _evaluating: boolean;
21
21
  constructor(order: OrderAccessor, collapsed: BoolAccessor);
22
22
  _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
23
- isReady(): boolean;
23
+ _isReady(): boolean;
24
24
  /**
25
25
  * "Minimally ready" = this group has something visible to show under its own policy.
26
26
  * Used by an enclosing `together` group to decide when it can release.
27
- * - `together`: fully ready (atomic).
27
+ * - `together`: every direct slot is minimally ready.
28
28
  * - `sequential`: the first owned slot is minimally ready (frontier can advance).
29
29
  * - `natural`: any owned slot is minimally ready.
30
30
  */
31
- isMinimallyReady(): boolean;
32
- register(slot: RevealSlot): void;
33
- unregister(slot: RevealSlot): void;
34
- evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
31
+ _isMinimallyReady(): boolean;
32
+ _register(slot: RevealSlot): void;
33
+ _unregister(slot: RevealSlot): void;
34
+ _evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
35
35
  }
36
36
  export declare class CollectionQueue extends Queue {
37
37
  _collectionType: number;
@@ -48,7 +48,7 @@ export declare class CollectionQueue extends Queue {
48
48
  constructor(type: number);
49
49
  run(type: number): void;
50
50
  notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
51
- checkSources(): void;
51
+ _checkSources(): void;
52
52
  }
53
53
  /**
54
54
  * Lower-level primitive that backs the `<Loading>` flow control. Catches
@@ -128,7 +128,7 @@ export declare function createErrorBoundary<T, U>(fn: () => T, fallback: (error:
128
128
  * own minimal signal).
129
129
  * - `together` — every direct slot is minimally ready.
130
130
  * - `natural` — any direct slot has visible content (leaves on resolve; nested
131
- * composites when fully ready, since natural treats composites as atomic).
131
+ * composites via their own minimal signal).
132
132
  *
133
133
  * @example
134
134
  * ```ts
@@ -1,6 +1,9 @@
1
1
  import { type OptimisticLane } from "./lanes.cjs";
2
- import type { Computed } from "./types.cjs";
3
- export declare function settlePendingSource(el: Computed<any>): void;
2
+ import type { Computed, Link } from "./types.cjs";
3
+ export declare function addPendingSource(el: Computed<any>, source: Computed<any>): boolean;
4
+ export declare function setPendingError(el: Computed<any>, source?: Computed<any>, error?: any): void;
5
+ export declare function forEachDependent(el: Computed<any>, fn: (node: Computed<any>, link: Link) => void): void;
6
+ export declare function settlePendingSource(el: Computed<any>, source?: Computed<any>, snap?: boolean): void;
4
7
  export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
5
8
  export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
6
9
  export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
@@ -10,6 +10,14 @@ export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
10
10
  export declare const REACTIVE_SNAPSHOT_STALE: number;
11
11
  export declare const REACTIVE_LAZY: number;
12
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;
13
21
  export declare const CONFIG_OWNED_WRITE: number;
14
22
  export declare const CONFIG_NO_SNAPSHOT: number;
15
23
  export declare const CONFIG_TRANSPARENT: number;
@@ -5,6 +5,12 @@ export declare const PRIMITIVE_IN_FORBIDDEN_SCOPE_MESSAGE = "[PRIMITIVE_IN_FORBI
5
5
  export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_SIGNAL_MESSAGE: string;
6
6
  export declare const REACTIVE_WRITE_IN_OWNED_SCOPE_REFRESH_MESSAGE: string;
7
7
  export declare let tracking: boolean;
8
+ /** @internal verdict-module glue */
9
+ export declare function setPendingCheckActive(v: boolean): void;
10
+ /** @internal verdict-module glue */
11
+ export declare function setLatestReadActive(v: boolean): void;
12
+ /** @internal verdict-module glue */
13
+ export declare function setContextInternal(v: Owner | null): void;
8
14
  export declare let stale: boolean;
9
15
  export declare let pendingCheckActive: boolean;
10
16
  export declare let latestReadActive: boolean;
@@ -60,6 +66,12 @@ export declare function setStrictRead(v: string | false): string | false;
60
66
  * ```
61
67
  */
62
68
  export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
69
+ /**
70
+ * Bring a computed to a readable state: lazy/disposed nodes are (re)computed;
71
+ * an isPending() probe (`refresh`) additionally pulls the node fully up to
72
+ * date so its status flags reflect the current graph.
73
+ */
74
+ export declare function prepareComputed(comp: Computed<unknown>, refresh: boolean): void;
63
75
  export declare function read<T>(el: Signal<T> | Computed<T>): T;
64
76
  export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
65
77
  /**
@@ -97,76 +109,7 @@ export declare function setMemo<T>(el: Computed<T>, v: T | ((prev: T) => T)): T;
97
109
  * ```
98
110
  */
99
111
  export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
100
- /**
101
- * Keep the lazily-created isPending()/latest() companion nodes in sync with a
102
- * new value. Every path that produces a value for `el` — direct set, async
103
- * resolution, transition-held sync recompute — must route through here so a
104
- * new write path can't silently skip the companions (#2831).
105
- */
106
- export declare function syncCompanions<T>(el: Signal<T> | Computed<T>, value: T): void;
107
- /**
108
- * Update _pendingSignal when pending state changes. When the override clears
109
- * (pending -> not pending), merge the sub-lane into the source's lane so
110
- * isPending effects are blocked until the full scope resolves.
111
- */
112
- export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
113
- /**
114
- * A firewall's status change re-derives the verdicts of its probed leaves:
115
- * leaf companions consult the firewall (broad inheritance), so async
116
- * starting/settling on the firewall must poke them or they keep a stale
117
- * verdict forever (V4 stuck-companion class, #2838).
118
- */
119
- export declare function updateChildCompanions(el: Computed<any>): void;
120
- /**
121
- * Settlement checkpoint (#2838): re-derive a node's companions directly from
122
- * its committed state. Called when the transition machinery for the node is
123
- * done with it — a pending commit or an optimistic revert. Verdicts are
124
- * written committed (not through setSignal) because a transition-scoped
125
- * override window opened here would itself need a settlement, re-scheduling
126
- * forever while async is still in flight. This is what keeps companions
127
- * coherent past transition completion: a verdict is a property of the data
128
- * (A19), so it must survive the transition that happened to produce it.
129
- */
130
- export declare function snapCompanionsToState(owner: Signal<any> | Computed<any>): void;
131
112
  export declare function staleValues<T>(fn: () => T, set?: boolean): T;
132
- /**
133
- * Reads reactive expressions while bypassing any pending async overlay — i.e.
134
- * always returns the most-recently-committed value, even when newer reads
135
- * inside `fn` are still in flight.
136
- *
137
- * Useful inside a `<Loading>` boundary's children when you want to keep
138
- * showing the previous resolved data instead of the fallback while the next
139
- * value loads.
140
- *
141
- * @example
142
- * ```tsx
143
- * <Loading fallback={<Skeleton />}>
144
- * {/* During a transition, render the previous user instead of skeleton: *\/}
145
- * <UserCard user={latest(() => user())} />
146
- * </Loading>
147
- * ```
148
- */
149
- export declare function latest<T>(fn: () => T): T;
150
- /**
151
- * Returns `true` if any reactive read inside `fn` is showing a stale value
152
- * while newer async work is pending. Does not subscribe — pair with a tracked
153
- * memo if you want to react to pending status changes.
154
- *
155
- * Useful for showing inline transition indicators alongside the previous
156
- * value (rather than swapping to a `<Loading>` fallback).
157
- * Because `fn` is read normally, `isPending` participates in Loading/SSR
158
- * readiness the same way the read itself would.
159
- *
160
- * @example
161
- * ```tsx
162
- * const pending = createMemo(() => isPending(() => user()));
163
- *
164
- * <button disabled={pending()}>{pending() ? "Saving…" : "Save"}</button>
165
- *
166
- * <button disabled={isPending(() => user())}>Save</button>
167
- * ```
168
- */
169
- export declare function isPending(fn: () => any): boolean;
170
113
  /**
171
114
  * Invalidates one reactive source, forcing it to re-execute even if its inputs
172
115
  * haven't changed.
@@ -6,7 +6,7 @@ export interface DevHooks {
6
6
  onStoreNodeUpdate?: (state: any, property: PropertyKey, value: any, prev: any) => void;
7
7
  }
8
8
  export type DiagnosticSeverity = "warn" | "error";
9
- export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "REACTIVE_WRITE_IN_OWNED_SCOPE" | "ACTION_CALLED_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "SETTLED_CLEANUP_UNOWNED" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "INVALID_REFRESH_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC" | "REACTIVITY_HALTED" | "INVARIANT_VIOLATION";
9
+ export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "REACTIVE_WRITE_IN_OWNED_SCOPE" | "ACTION_CALLED_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "SETTLED_CLEANUP_UNOWNED" | "PRIMITIVE_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY" | "INVALID_REFRESH_TARGET" | "INVALID_AFFECTS_TARGET" | "MISSING_EFFECT_FN" | "SYNC_NODE_RECEIVED_ASYNC" | "REACTIVITY_HALTED" | "INVARIANT_VIOLATION";
10
10
  export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner" | "error";
11
11
  export interface DiagnosticEvent {
12
12
  sequence: number;
@@ -11,35 +11,5 @@ export declare let externalSourceConfig: {
11
11
  factory: ExternalSourceFactory;
12
12
  untrack: <T>(fn: () => T) => T;
13
13
  } | null;
14
- /**
15
- * Registers a factory that bridges external reactive systems (e.g. MobX, Vue refs)
16
- * into Solid's tracking graph. Every computation will be wrapped so that the
17
- * external library can track its own dependencies alongside Solid's.
18
- *
19
- * Multiple calls pipe together: each new factory wraps the previous one.
20
- *
21
- * @param config.factory receives `(fn, trigger)` — wrap fn execution in external tracking,
22
- * call trigger when external deps change. Return `{ track, dispose }`.
23
- * @param config.untrack optional wrapper for `untrack` — disables external tracking too.
24
- *
25
- * @example
26
- * ```ts
27
- * // Bridge an external "subscribe / notify" library into Solid's graph.
28
- * // `factory` wraps every Solid compute so the external library can attach
29
- * // its own dependency tracker; `trigger` re-runs the compute on external
30
- * // change. `untrack` mirrors Solid's `untrack()` into the external library
31
- * // so that reads inside `untrack(...)` don't get tracked twice.
32
- * enableExternalSource({
33
- * factory: (compute, trigger) => {
34
- * const sub = externalLib.subscribe(trigger);
35
- * return {
36
- * track: prev => externalLib.run(() => compute(prev)),
37
- * dispose: () => sub.unsubscribe()
38
- * };
39
- * },
40
- * untrack: fn => externalLib.untracked(fn)
41
- * });
42
- * ```
43
- */
44
14
  export declare function enableExternalSource(config: ExternalSourceConfig): void;
45
15
  export declare function _resetExternalSourceConfig(): void;
@@ -1,4 +1,12 @@
1
1
  import type { Computed } from "./types.cjs";
2
+ /** The queue a node belongs to, picked from its own zombie flag. */
3
+ export declare function queueFor(n: Computed<any>): Heap;
4
+ /**
5
+ * Schedule one subscriber to re-run on the next flush: tracked effects bypass
6
+ * the heap and go directly to their effect queue; everything else is inserted
7
+ * into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
8
+ */
9
+ export declare function enqueueSub(node: Computed<any>): void;
2
10
  export interface Heap {
3
11
  _heap: (Computed<unknown> | undefined)[];
4
12
  _marked: boolean;
@@ -1,12 +1,13 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.cjs";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, isPending, latest, updatePendingSignal, updateChildCompanions, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
2
+ export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, setMemo, suppressComputedRecompute, optimisticSignal, optimisticComputed, refresh, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
3
3
  export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.cjs";
4
4
  export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.cjs";
5
5
  export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.cjs";
6
6
  export { handleAsync } from "./async.cjs";
7
+ export { isPending, latest } from "./verdict.cjs";
7
8
  export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.cjs";
8
9
  export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.cjs";
9
10
  export { action } from "./action.cjs";
10
- export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.cjs";
11
+ export { flush, Queue, GlobalQueue, enforceLoadingBoundary, resetErrorHalt, type IQueue, type QueueCallback } from "./scheduler.cjs";
11
12
  export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.cjs";
12
13
  export * from "./constants.cjs";
@@ -26,6 +26,7 @@ export declare const InvariantHooks: {
26
26
  export declare function devTrackHeldPending(node: AnyNode): void;
27
27
  export declare function devTrackCompanionOwner(node: AnyNode): void;
28
28
  export declare function devTrackOptimistic(node: AnyNode): void;
29
+ export declare function devTrackAffects(node: AnyNode): void;
29
30
  /**
30
31
  * Open/close the sanctioned registration window. Call sites are `__DEV__`
31
32
  * guarded (no prod cost); the code inside the window must not throw.
@@ -33,6 +34,15 @@ export declare function devTrackOptimistic(node: AnyNode): void;
33
34
  export declare function beginAsyncReporterWrites(): void;
34
35
  export declare function endAsyncReporterWrites(): void;
35
36
  export declare function createAsyncReporters(): Map<Computed<any>, Set<Computed<any>>>;
37
+ /**
38
+ * INV-2: a node with an *active* override must be registered for reversion in
39
+ * the queue's or a transition's `_optimisticNodes`. An unregistered active
40
+ * override would survive transition completion forever. Runs at the end of
41
+ * every flush (not just quiescence — the invariant holds mid-transition).
42
+ * (There is no revert-target requirement: authoritative values commit
43
+ * silently into `_value` under the override mask — A17 — so reverting is
44
+ * just dropping the override.)
45
+ */
36
46
  export declare function devCheckActiveOverrides(isRegisteredForRevert: (node: AnyNode) => boolean): void;
37
47
  /** INV-1: an isPending() probe must never leak past its own call. */
38
48
  export declare function devCheckFlushStart(): void;