@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.14
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.
- package/dist/dev-shared.js +2000 -3768
- package/dist/dev.attribution.js +132 -79
- package/dist/dev.js +7226 -8488
- package/dist/observe/affects.js +125 -104
- package/dist/observe/boundaries.js +458 -665
- package/dist/observe/core/action.js +63 -66
- package/dist/observe/core/async.js +240 -383
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +240 -183
- package/dist/observe/core/constants.js +115 -187
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +840 -1438
- package/dist/observe/core/dev.js +3 -3
- package/dist/observe/core/effect.js +75 -86
- package/dist/observe/core/external.js +5 -5
- package/dist/observe/core/graph.js +61 -70
- package/dist/observe/core/heap.js +75 -98
- package/dist/observe/core/invariants.js +1 -34
- package/dist/observe/core/lanes.js +704 -181
- package/dist/observe/core/owner.js +80 -101
- package/dist/observe/core/scheduler.js +708 -1351
- package/dist/observe/core/verdict.js +302 -621
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/index.js +15 -13
- package/dist/observe/map.js +232 -235
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +133 -215
- package/dist/observe/store/affects.js +135 -0
- package/dist/observe/store/index.js +29 -24
- package/dist/observe/store/optimistic.js +538 -0
- package/dist/observe/store/projection.js +302 -0
- package/dist/observe/store/reconcile.js +257 -0
- package/dist/observe/store/store.js +1945 -277
- package/dist/observe/store/storePath.js +1 -1
- package/dist/{prod/store/next → observe/store}/target.js +17 -18
- package/dist/observe/store/types.js +73 -0
- package/dist/observe/store/utils.js +1 -13
- package/dist/prod/affects.js +127 -106
- package/dist/prod/boundaries.js +442 -654
- package/dist/prod/core/action.js +71 -74
- package/dist/prod/core/async.js +307 -442
- package/dist/prod/core/constants.js +112 -186
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +852 -1458
- package/dist/prod/core/effect.js +88 -99
- package/dist/prod/core/external.js +5 -5
- package/dist/prod/core/graph.js +61 -70
- package/dist/prod/core/heap.js +75 -98
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +666 -181
- package/dist/prod/core/owner.js +75 -96
- package/dist/prod/core/scheduler.js +677 -1332
- package/dist/prod/core/verdict.js +297 -621
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/index.js +15 -13
- package/dist/prod/map.js +143 -146
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +144 -226
- package/dist/prod/store/affects.js +135 -0
- package/dist/prod/store/index.js +28 -19
- package/dist/prod/store/optimistic.js +533 -0
- package/dist/prod/store/projection.js +295 -0
- package/dist/prod/store/reconcile.js +257 -0
- package/dist/prod/store/store.js +1840 -272
- package/dist/prod/store/storePath.js +1 -1
- package/dist/{observe/store/next → prod/store}/target.js +13 -17
- package/dist/prod/store/types.js +73 -0
- package/dist/prod/store/utils.js +1 -11
- package/dist/types/affects.d.ts +11 -30
- package/dist/types/boundaries.d.ts +62 -176
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +5 -6
- package/dist/types/core/async.d.ts +10 -5
- package/dist/types/core/attribution-hooks.d.ts +20 -1
- package/dist/types/core/attribution.d.ts +20 -9
- package/dist/types/core/constants.d.ts +125 -180
- package/dist/types/core/core.d.ts +104 -264
- package/dist/types/core/dev.d.ts +2 -2
- package/dist/types/core/effect.d.ts +0 -7
- package/dist/types/core/graph.d.ts +7 -1
- package/dist/types/core/heap.d.ts +5 -7
- package/dist/types/core/index.d.ts +5 -5
- package/dist/types/core/invariants.d.ts +0 -29
- package/dist/types/core/lanes.d.ts +65 -87
- package/dist/types/core/owner.d.ts +3 -3
- package/dist/types/core/scheduler.d.ts +249 -331
- package/dist/types/core/types.d.ts +51 -85
- package/dist/types/core/verdict.d.ts +3 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +35 -91
- package/dist/types/store/affects.d.ts +1 -0
- package/dist/types/store/index.d.ts +35 -15
- package/dist/types/store/optimistic.d.ts +23 -0
- package/dist/types/store/projection.d.ts +18 -0
- package/dist/types/store/reconcile.d.ts +3 -0
- package/dist/types/store/store.d.ts +165 -143
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +151 -0
- package/dist/types/store/types.d.ts +84 -0
- package/package.json +1 -1
- package/dist/observe/core/optimistic.js +0 -669
- package/dist/observe/store/next/optimistic.js +0 -717
- package/dist/observe/store/next/projection.js +0 -266
- package/dist/observe/store/next/reconcile.js +0 -375
- package/dist/observe/store/next/store.js +0 -2608
- package/dist/prod/core/optimistic.js +0 -658
- package/dist/prod/store/next/optimistic.js +0 -710
- package/dist/prod/store/next/projection.js +0 -257
- package/dist/prod/store/next/reconcile.js +0 -373
- package/dist/prod/store/next/store.js +0 -2484
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -25
- package/dist/types/store/next/projection.d.ts +0 -27
- package/dist/types/store/next/reconcile.d.ts +0 -10
- package/dist/types/store/next/store.d.ts +0 -145
- package/dist/types/store/next/target.d.ts +0 -196
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Refreshable } from "../../core/index.js";
|
|
2
|
-
import { type Transition } from "../../core/scheduler.js";
|
|
3
|
-
import { type NoFn, type ProjectionOptions, type Store, type StoreOptions, type StoreSetter } from "../store.js";
|
|
4
|
-
import type { StoreNextTarget } from "./target.js";
|
|
5
|
-
/** #3164 fold: a stamped truth is HELD (masked from ordinary readers until
|
|
6
|
-
* the reveal) only while its transition is live AND retaining optimism —
|
|
7
|
-
* overrides are what make partial-coverage composition a tear. A plain
|
|
8
|
-
* async transition carries no overrides, so downstream computes must see
|
|
9
|
-
* staged values to converge (normal speculation). Resolves merges first:
|
|
10
|
-
* merge unions optimistic nodes/stores into the target. */
|
|
11
|
-
export declare function transitionHoldsOptimism(transition: Transition): boolean;
|
|
12
|
-
export declare function createOptimisticStoreNext<T extends object = {}>(initialValue: NoFn<T> | Store<NoFn<T>>, options?: StoreOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
13
|
-
export declare function createOptimisticStoreNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
14
|
-
/** Diff the draft against the current OPTIMISTIC VIEW (committed + active
|
|
15
|
-
* overrides — the same view the draft was seeded from) and emit engine writes
|
|
16
|
-
* for exactly the changed keys. Visible-view diffing keeps no-op writes from
|
|
17
|
-
* entangling lanes (RUL-10 / opt R38). */
|
|
18
|
-
export declare function notifyOptimisticWrites(t: StoreNextTarget, pb: Record<PropertyKey, any>): void;
|
|
19
|
-
/** Optimistic-view composition for snapshot/deep (O1: snapshot is the CURRENT
|
|
20
|
-
* view, lane values included; a fresh copy per call during pending windows —
|
|
21
|
-
* RUL-12). Returns `src` untouched when no override is active on `t`.
|
|
22
|
-
* Authoritative-view reads (until()'s predicate) skip composition entirely:
|
|
23
|
-
* the predicate observes authoritative truth, never the caller's tentative
|
|
24
|
-
* overlay. (Write-side emission callers never run under such a compute.) */
|
|
25
|
-
export declare function optimisticView(t: StoreNextTarget, src: Record<PropertyKey, any>, draft?: boolean): Record<PropertyKey, any>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store rewrite — projections (§7/§7b): a projection is a computed store.
|
|
3
|
-
* The derive runs inside a computed whose recompute merges its output into
|
|
4
|
-
* the projection's backing through the adoption channel (replace-mode root:
|
|
5
|
-
* entity changes merge in place, the root proxy is stable for life). Children
|
|
6
|
-
* wrap into the projection's own FAMILY (writes land here, never in a source
|
|
7
|
-
* family), and every family node carries the projection computed as its
|
|
8
|
-
* firewall — reads link the derive's status and lifecycle natively. The §6c
|
|
9
|
-
* status gate in the traps makes an uninitialized async derive's seed
|
|
10
|
-
* unobservable through every read surface.
|
|
11
|
-
*
|
|
12
|
-
* Mirrors the legacy runProjectionComputed shape (shadow runs for open
|
|
13
|
-
* loading windows, handleAsync landings, commit-through-setter) on next
|
|
14
|
-
* primitives; the generic draft write-traps are reused from the legacy
|
|
15
|
-
* module unchanged.
|
|
16
|
-
*/
|
|
17
|
-
import { type Computed, type Refreshable } from "../../core/index.js";
|
|
18
|
-
import { type NoFn, type ProjectionOptions, type Store } from "../store.js";
|
|
19
|
-
export declare function createProjectionNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): Refreshable<Store<T>>;
|
|
20
|
-
/** Derived writable store (legacy parity): a projection whose public setter
|
|
21
|
-
* masks the recompute for the tick (core R31 — the manual write wins over a
|
|
22
|
-
* same-flush dependency change). Across a hold the write is not a proposal:
|
|
23
|
-
* a leaf another transaction holds as the fold's result re-runs the fold
|
|
24
|
-
* under it, the write being the draft's prior state (A34 amendment, #3612;
|
|
25
|
-
* core derivedWrite). */
|
|
26
|
-
export declare function createStoreDerivedNext<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [Refreshable<Store<T>>, (f: (draft: T) => T | void) => void];
|
|
27
|
-
export declare function runProjectionComputedNext<T extends object>(wrappedStore: Store<T>, fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, key: string | ((item: NonNullable<any>) => any) | null, wrapCommit?: (write: () => void, value: T) => void, aroundDraftWrite?: (op: () => void) => void): Computed<void | T>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type KeyFn = (item: any) => any;
|
|
2
|
-
export declare function reconcileNextState(value: any, state: any, key: string | KeyFn | null | undefined, replace?: boolean): void;
|
|
3
|
-
/** Setter-channel row ops (the fold site calls this for array targets with
|
|
4
|
-
* ops consumers): structural mutation through the setter — push/splice/index
|
|
5
|
-
/** Key equality for EVERY key comparison in this module (re-audit 2, P1-5):
|
|
6
|
-
* SameValueZero, matching the adoption window's Map-based matcher — NaN keys
|
|
7
|
-
* are equal to themselves, so aligned NaN rows stay aligned in the prefix
|
|
8
|
-
* walk instead of forever misaligning. */
|
|
9
|
-
export declare function sameKey(a: any, b: any): boolean;
|
|
10
|
-
export {};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { hasActiveOverride, visibleOverride } from "../../core/core.js";
|
|
2
|
-
import type { Computed, Signal } from "../../core/types.js";
|
|
3
|
-
import { type StoreNextFamily, type StoreNextTarget } from "./target.js";
|
|
4
|
-
export declare function wrapNext<T extends Record<PropertyKey, any>>(value: T, parent?: StoreNextTarget | null, parentKey?: PropertyKey | null, fam?: StoreNextFamily | null): T;
|
|
5
|
-
/** Unwrap our own proxies to their current backing; leave everything else. */
|
|
6
|
-
export declare function unwrapValue(v: any): any;
|
|
7
|
-
export declare function getNode(target: StoreNextTarget, key: PropertyKey, current: any, accKnown?: -1 | 0 | 1): Signal<any>;
|
|
8
|
-
/** Record a store proxy's declared name for attribution labels (observe tiers). */
|
|
9
|
-
export declare function nameStore(proxy: any, name: string | undefined): void;
|
|
10
|
-
export declare function getHasNode(target: StoreNextTarget, key: PropertyKey, present: boolean): Signal<boolean>;
|
|
11
|
-
export declare function getKeySetNode(target: StoreNextTarget): Signal<number>;
|
|
12
|
-
/** Deep-witness bump: any value/shape change on a record with a live deep()
|
|
13
|
-
* subscriber notifies it. One null check when unused. */
|
|
14
|
-
export declare function bumpDeep(t: StoreNextTarget): void;
|
|
15
|
-
/** Downgrade a prototype-overlay pending backing to the clone path: builds
|
|
16
|
-
* the real container (committed + overlay writes − deletes) that fold will
|
|
17
|
-
* SWAP in as the committed backing, exactly as if the draft had started on
|
|
18
|
-
* the clone path. Consumers that need a complete container (reconcile's
|
|
19
|
-
* diff walks, drafts escaping into other storage) call this, and so does the
|
|
20
|
-
* commit itself when the fold changed the key set (overlayRebuilds). Returns
|
|
21
|
-
* the pending backing (the clone, or the pb as-is when not an overlay). */
|
|
22
|
-
export declare function materializePB(target: StoreNextTarget): Record<PropertyKey, any>;
|
|
23
|
-
/** Resolve the held committed view (#3074): answers the masked old backing
|
|
24
|
-
* while the hold is live, and lazily clears a hold whose transition has
|
|
25
|
-
* committed (transitions merge — resolve through currentTransition, same as
|
|
26
|
-
* foldHeld's node stamps). */
|
|
27
|
-
export declare function heldMaskView(t: StoreNextTarget): Record<PropertyKey, any> | null;
|
|
28
|
-
/**
|
|
29
|
-
* Adoption (2026-08-16c): the incoming object becomes the committed backing
|
|
30
|
-
* IMMEDIATELY — reconcile is eagerly visible to every reader (shipped
|
|
31
|
-
* contract; only its notifications batch), unlike setter writes which stay
|
|
32
|
-
* pending until flush. Ownership resets (incoming is unowned/user data). Any
|
|
33
|
-
* staged draft clone folds into the diff and is discarded — next is the
|
|
34
|
-
* authoritative base (R21/R32).
|
|
35
|
-
*/
|
|
36
|
-
export declare function adoptPB(target: StoreNextTarget, incoming: Record<PropertyKey, any>, eager?: boolean): void;
|
|
37
|
-
/** Parked truth-staged pending backings (#3164 fold): a tentative draft that
|
|
38
|
-
* opens while a folded landing's backing is live moves the staged container
|
|
39
|
-
* here (see ensurePB); the tentative discard in notifyOptimisticWrites
|
|
40
|
-
* restores it in place of the usual null. */
|
|
41
|
-
export declare const stagedTruthPB: WeakMap<StoreNextTarget, Record<PropertyKey, any>>;
|
|
42
|
-
/** Same logical slot: both values resolve to one (re-pointed) child target —
|
|
43
|
-
* adoption preserved identity, so the slot did not change (R9). */
|
|
44
|
-
export declare function targetsEqual(ov: any, nv: any): boolean;
|
|
45
|
-
export declare function arrayStructureChanged(old: any[], neu: any[]): boolean;
|
|
46
|
-
export declare function membershipChanged(old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* The fold diff walks SUBSCRIPTION KEYS ONLY (legacy parity: `for key in
|
|
49
|
-
* nodes`): nodes exist exactly where something tracked, so unobserved data
|
|
50
|
-
* costs nothing here regardless of object size. Accessor safety rides the
|
|
51
|
-
* sticky `t.a` flag — a node's key was necessarily read, so the get trap has
|
|
52
|
-
* already seen whether it is an accessor.
|
|
53
|
-
*/
|
|
54
|
-
/** One node's fold notification (shared by notifyFold's walk and the fused
|
|
55
|
-
* adoption walk): accessor-aware compare + equality/identity-gated setSignal. */
|
|
56
|
-
export declare function notifyKeyDiff(node: Signal<any>, key: PropertyKey, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>, probe?: boolean): void;
|
|
57
|
-
/** Accessor-flag probe for the fused walk's early-continue (accessor keys
|
|
58
|
-
* can never identity-skip: their VALUE is the descriptor's product). */
|
|
59
|
-
export declare function hasAccessorFlag(node: Signal<any>): boolean;
|
|
60
|
-
/** Fused-walk per-key notification with values already in hand: the caller
|
|
61
|
-
* fetched both sides and handled the identity skip; this applies the
|
|
62
|
-
* accessor branch (cached flag only — reconcile channel) or the plain
|
|
63
|
-
* equality/identity-gated write. */
|
|
64
|
-
export declare function notifyKeyValue(node: Signal<any>, key: PropertyKey, ov: any, nv: any, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
|
|
65
|
-
/** Presence + membership halves of a fold notification (shared tail). */
|
|
66
|
-
export declare function notifyFoldTail(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
|
|
67
|
-
export declare function notifyFold(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
|
|
68
|
-
/** Authoritative-write wrapper exported for the optimistic module: sets the
|
|
69
|
-
* scheduler's projectionWriteActive through THIS module's binding (proven to
|
|
70
|
-
* share the instance core reads — cross-module live-binding writes from other
|
|
71
|
-
* store modules were observed not to propagate under the test transform). */
|
|
72
|
-
export declare function runAuthoritative<T>(fn: () => T): T;
|
|
73
|
-
export { hasActiveOverride, visibleOverride };
|
|
74
|
-
/** The reading computation is until()'s authoritative-view predicate — same
|
|
75
|
-
* source of truth as core read()'s A17 carve-out (`context`, which persists
|
|
76
|
-
* under untrack). optimisticView()'s composition gate consults exactly this:
|
|
77
|
-
* write-side machinery (patch emission, tentative re-application) must keep
|
|
78
|
-
* composing even when it runs inside an authoritative-write bracket. */
|
|
79
|
-
export declare function authoritativeRead(): boolean;
|
|
80
|
-
/** Serve-side authoritative gate: until()'s predicate PLUS truth authors —
|
|
81
|
-
* the projection derive's draft (wrapDraft trap brackets, runAuthoritative;
|
|
82
|
-
* the same posture pair ensurePB classifies drafts by). A source computing
|
|
83
|
-
* the next truth must never read its callers' tentative overlays: a derive
|
|
84
|
-
* continuation's `store.push` computing its index from an action's
|
|
85
|
-
* optimistic row landed truth in the wrong slot and corrupted committed
|
|
86
|
-
* state (#3108). Trap-level overlay serves gate on this so values, length,
|
|
87
|
-
* membership, and keys leave the authoritative view together. */
|
|
88
|
-
export declare function authoritativeServe(): boolean;
|
|
89
|
-
/** The override a composed READER view (keys, descriptors, snapshot/deep,
|
|
90
|
-
* optimisticView) takes from an armed node whose override is active — the
|
|
91
|
-
* override itself, unless the node's own source superseded it (#3331,
|
|
92
|
-
* CONFIG_OVERRIDE_SUPERSEDED): then the reader-aware selection `serve`
|
|
93
|
-
* makes through nodeValue, so the composed view agrees with what `get`,
|
|
94
|
-
* `in` and `length` serve the same reader (a deriving pass: the staged
|
|
95
|
-
* truth; a lane pass or a context-free read: the override, A18). Composing
|
|
96
|
-
* the raw override left Object.keys / snapshot() / deep() one row behind the
|
|
97
|
-
* traps at a landing whose shape differed from the optimistic frame (F5
|
|
98
|
-
* parity cases). Draft and authoritative callers never reach here — the
|
|
99
|
-
* writer composes on hasActiveOverride, truth authors on the backing. */
|
|
100
|
-
export declare function readerOverride(node: Signal<any>, committed: any): any;
|
|
101
|
-
export type SetStoreNextFunction<T> = (fn: (draft: T) => T | void) => void;
|
|
102
|
-
/** The derived store's setter (CS-R31): within a synchronous frame the manual
|
|
103
|
-
* write wins — the projection's recompute is masked for the tick. Across a
|
|
104
|
-
* hold the write is not a proposal: a leaf the fold staged under another
|
|
105
|
-
* transaction re-runs the fold under it, the write being the draft's prior
|
|
106
|
-
* state (#3612). Decided from the leaf notifications, so the mask lands
|
|
107
|
-
* after them (in the `finally`: a throwing setter's writes before the throw
|
|
108
|
-
* were notified, and are masked as before). */
|
|
109
|
-
export declare function derivedStoreWrite<T>(node: Computed<unknown>, proxy: T, fn: (draft: T) => T | void): void;
|
|
110
|
-
export declare function storeSetterNext<T>(proxy: T, fn: (draft: T) => T | void, guard?: boolean): void;
|
|
111
|
-
export declare function createStoreNext<T extends Record<PropertyKey, any>>(initialValue: T, shallow?: boolean): [T, SetStoreNextFunction<T>];
|
|
112
|
-
/** True when `proxy` is a SHALLOW store (children served verbatim, slots
|
|
113
|
-
* replaced by reference — #2932). The list driver uses this to choose the
|
|
114
|
-
* slot-patch channel (collected row bodies) over per-record registration. */
|
|
115
|
-
export declare function storeIsShallow(proxy: any): boolean;
|
|
116
|
-
/** True when `proxy` belongs to a projection/optimistic FAMILY. The list
|
|
117
|
-
* driver must DECLINE family arrays (external audit finding): family
|
|
118
|
-
* structural changes never emit row/slot ops (the setter channel is
|
|
119
|
-
* fam-gated; optimistic writes ride node overrides), and the proxy identity
|
|
120
|
-
* is stable so the each-watch cannot catch the change either — an engaged
|
|
121
|
-
* list would freeze on optimistic/projection structural updates. Record-
|
|
122
|
-
* level family patches are unaffected (they have their own emission). */
|
|
123
|
-
export declare function storeHasFamily(proxy: any): boolean;
|
|
124
|
-
/** True when `proxy` belongs to an OPTIMISTIC family specifically. The list
|
|
125
|
-
* driver declines these (audit finding, narrowed): optimistic user writes
|
|
126
|
-
* ride node-level overrides — they never enter the reconcile walk, so no
|
|
127
|
-
* row/slot ops are emitted and an engaged list would freeze on optimistic
|
|
128
|
-
* structural changes. PROJECTION (non-optimistic) families are drivable:
|
|
129
|
-
* their recomputes go through the reconcile walk, whose emissions are
|
|
130
|
-
* transition-stamped in the apply queue like any other (equivalence-matrix
|
|
131
|
-
* gated). Re-admitting optimistic families requires a lane-timed structural
|
|
132
|
-
* emission mirroring emitPatchOptimistic, plus revert resync. */
|
|
133
|
-
export declare function storeHasOptimisticFamily(proxy: any): boolean;
|
|
134
|
-
/** Tracking deep snapshot (`deep()` for next targets): subscribes to the
|
|
135
|
-
* key-set and deep-witness node at every reachable level, then returns the
|
|
136
|
-
* plain view. Shared references and cycles handled via the visited set. */
|
|
137
|
-
export declare function deepNext<T>(value: T): T;
|
|
138
|
-
/**
|
|
139
|
-
* Snapshot with per-object registration resolution (RUL-12 DAG ruling): every
|
|
140
|
-
* reachable wrappable resolves through its target's CURRENT backing, so
|
|
141
|
-
* privatized subtrees are seen through any parent path. Identity-preserving:
|
|
142
|
-
* a subtree with no substitutions below returns its own object (zero copy for
|
|
143
|
-
* settled, never-diverged graphs).
|
|
144
|
-
*/
|
|
145
|
-
export declare function snapshotNext<T>(value: T): T;
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store rewrite — target & ownership (INTERNALS-STORE-STATE.md §1, §5b).
|
|
3
|
-
*
|
|
4
|
-
* The proxy wraps this internal target, never the raw (proxy-target
|
|
5
|
-
* indirection, decision 2026-08-16d). `b` is the single committed home; `pb`
|
|
6
|
-
* is the per-target pending backing (RUL-1's pending home): the CoW clone
|
|
7
|
-
* created at first draft write, mutated natively by the draft, folded into
|
|
8
|
-
* `b` at flush commit. Adoption (setter replacement / reconcile) parks an
|
|
9
|
-
* UNOWNED incoming object in `pb` — fold swaps it in and ownership resets.
|
|
10
|
-
*
|
|
11
|
-
* Creation budget (§5b): one minimal target + one proxy + one storeLookup
|
|
12
|
-
* entry per read-through object; zero layer slots; nodes, has-nodes, and the
|
|
13
|
-
* key-set node are lazy, materialized only by subscription.
|
|
14
|
-
*/
|
|
15
|
-
import type { Computed, Signal } from "../../core/types.js";
|
|
16
|
-
/** Projection family (§7b): children wrap into the family's own map (writes
|
|
17
|
-
* land in the projection, never the source family), and every node created
|
|
18
|
-
* under the family carries the projection computed as its firewall. */
|
|
19
|
-
export interface StoreNextFamily {
|
|
20
|
-
/** Optimistic family: nodes are born armed (`_overrideValue` slot) so every
|
|
21
|
-
* write rides the core optimistic engine — lanes, per-transaction ownership,
|
|
22
|
-
* reverts all core-native (§3, RUL-3). */
|
|
23
|
-
opt?: boolean;
|
|
24
|
-
/** Root proxy (registered with the scheduler's optimistic-store set for the
|
|
25
|
-
* transitionBlocked store-half, #2951). */
|
|
26
|
-
px?: any;
|
|
27
|
-
/** Targets currently carrying active node overrides (landing-consumption
|
|
28
|
-
* walk, RUL-2: visible landed truth replaces optimism). */
|
|
29
|
-
overlaid?: Set<any>;
|
|
30
|
-
/** Retaining transactions (#3164 fold ruling): every transaction that made
|
|
31
|
-
* an optimistic setter call on this family and may still be open. While
|
|
32
|
-
* any member is live, truth landings FOLD — they stage into the retaining
|
|
33
|
-
* transaction and reveal atomically at its settle, exactly like a signal
|
|
34
|
-
* landing under an active override. Dead members prune lazily at each
|
|
35
|
-
* landing (retainingTransition). */
|
|
36
|
-
rt?: Set<any>;
|
|
37
|
-
/** Flight-owned transaction (#3146): declared when a truth-flight
|
|
38
|
-
* registers (the ask's transaction — created by the flight's own pending
|
|
39
|
-
* throw when none was ambient, the causing write's when one was), renewed
|
|
40
|
-
* per settle event once the previous reveal committed. Bare optimistic
|
|
41
|
-
* writes and landings route into it BY DECLARATION; the transitionBlocked
|
|
42
|
-
* store-half checks it for ownership instead of reconstructing it from
|
|
43
|
-
* `_optimisticStores` membership. null = no flight declared one (sync
|
|
44
|
-
* derive, or a loading-window flight — the loading rail is
|
|
45
|
-
* transaction-invisible, #2933). */
|
|
46
|
-
ft?: any;
|
|
47
|
-
/** Normalized row-key fn (same resolution as the projection channels:
|
|
48
|
-
* `options.key`, "id" default, null = unkeyed). The staged-landing walk
|
|
49
|
-
* reads it: key-matched rows keep their proxy identity across a fold. */
|
|
50
|
-
key?: ((item: any) => any) | null;
|
|
51
|
-
map: WeakMap<object, StoreNextTarget>;
|
|
52
|
-
/** The projection computed — assigned after creation (accessor pattern). */
|
|
53
|
-
node: Computed<any> | null;
|
|
54
|
-
shallow?: boolean;
|
|
55
|
-
/** Derive run counter (proj R37): the run whose draft is live. A draft
|
|
56
|
-
* compares its own run against this — the next run's start supersedes it. */
|
|
57
|
-
run?: number;
|
|
58
|
-
}
|
|
59
|
-
export interface StoreNextTarget {
|
|
60
|
-
/** Committed backing: source object (shared) or owned clone. */
|
|
61
|
-
v: Record<PropertyKey, any>;
|
|
62
|
-
/** Pending backing for the current flush (null when settled). */
|
|
63
|
-
pb: Record<PropertyKey, any> | null;
|
|
64
|
-
/** cached: committed backing is another store's proxy (§7b chained). */
|
|
65
|
-
ch: boolean;
|
|
66
|
-
/** live value-node count (deleted-key sweep fast-out in the fused walk). */
|
|
67
|
-
nc: number;
|
|
68
|
-
/** Lazy per-property subscription nodes (real core signals). */
|
|
69
|
-
n: Record<PropertyKey, Signal<any>> | null;
|
|
70
|
-
/** Lazy per-key presence nodes (`in` tracks presence, not value — R13). */
|
|
71
|
-
h: Record<PropertyKey, Signal<boolean>> | null;
|
|
72
|
-
/** Lazy key-set node: membership/iteration/$TRACK subscriptions (§6). */
|
|
73
|
-
k: Signal<number> | null;
|
|
74
|
-
/** Keys written through the traps since the last fold commit. Bounds the
|
|
75
|
-
* setter notify/hold-check to O(written) instead of O(subscribed nodes) —
|
|
76
|
-
* a record with thousands of per-key subscriptions (selection maps) would
|
|
77
|
-
* otherwise pay a full node scan on every write. null = no trap writes
|
|
78
|
-
* this batch (bulk paths fall back to the full scan); WK_ALL = bound
|
|
79
|
-
* unusable (array length write). LOAD-BEARING SHAPE RULE: array proxy
|
|
80
|
-
* targets carry their fields as named properties on a real array, and V8
|
|
81
|
-
* normalizes an array to dictionary properties as the named count grows
|
|
82
|
-
* (empirically at counts ≡ 0 mod 3 from 18 up on V8 13.x) — every trap
|
|
83
|
-
* field read then becomes a hash lookup (~15% uibench, tree suites
|
|
84
|
-
* worst). Future write-side state MUST ride an extension object, not new
|
|
85
|
-
* named fields. */
|
|
86
|
-
wk: Set<PropertyKey> | null;
|
|
87
|
-
/** Lazy deep-witness node: `deep()` subscribes ONE node per record instead
|
|
88
|
-
* of one per path; write paths bump it only when it exists. Separate from
|
|
89
|
-
* `k` so $TRACK/mapArray never rerun on leaf value changes (R9). */
|
|
90
|
-
dk: Signal<number> | null;
|
|
91
|
-
/** Parent target (path copying walks this at commit). */
|
|
92
|
-
u: StoreNextTarget | null;
|
|
93
|
-
/** Property key of this target in the parent's backing. */
|
|
94
|
-
pk: PropertyKey | null;
|
|
95
|
-
/** The proxy for this target (stable outward identity). */
|
|
96
|
-
px: any;
|
|
97
|
-
/** Sticky descendants flag (§6d). */
|
|
98
|
-
d: boolean;
|
|
99
|
-
/** Sticky accessors-seen flag: an own accessor property was observed on
|
|
100
|
-
* this target (first-read scan, defineProperty, or clone scan). Gates the
|
|
101
|
-
* fold diff's descriptor-safe path and the get trap's descriptor path. */
|
|
102
|
-
a: boolean;
|
|
103
|
-
/** Accessor scan grade: 0 = not yet scanned (adoption resets — adopted data
|
|
104
|
-
* is not rescanned until the next draft), 1 = scanned, 2 = scanned and
|
|
105
|
-
* PLAIN DATA — `Object.prototype` with every own key an enumerable data
|
|
106
|
-
* property. Grade 2 unlocks the spread clone (cloneRaw), bare-assignment
|
|
107
|
-
* overlay writes and flatten (#3360); a non-plain defineProperty through
|
|
108
|
-
* the draft downgrades it to 1. */
|
|
109
|
-
sc: 0 | 1 | 2;
|
|
110
|
-
/** Own-key count: exact at scan, then bumped by set-trap writes of keys new
|
|
111
|
-
* to the container (never decremented — an estimate for the overlay/clone
|
|
112
|
-
* choice only, #3360). */
|
|
113
|
-
kc: number;
|
|
114
|
-
/** Adoption diff base, non-null when the backing was swapped by adoption
|
|
115
|
-
* this batch: the view the nodes were LAST TOLD — the pre-batch committed
|
|
116
|
-
* backing, or the draft's pending backing when a draft preceded the
|
|
117
|
-
* adoption (its setter-exit notifications already moved the nodes, #3296).
|
|
118
|
-
* The deferred fold diffs incoming against this, never against committed. */
|
|
119
|
-
ab: Record<PropertyKey, any> | null;
|
|
120
|
-
/** Pending backing is a prototype-chain OVERLAY of the committed backing
|
|
121
|
-
* (`Object.create(v)` — own keys are this batch's writes, everything else
|
|
122
|
-
* reads through). O(written) per flush instead of O(container) clones
|
|
123
|
-
* (#3044); commit flattens own keys onto an owned committed backing in
|
|
124
|
-
* place. Plain-data non-array containers qualify, including projection
|
|
125
|
-
* and derived-store families (#3352); optimistic families, chained
|
|
126
|
-
* backings, and accessor containers keep the descriptor clone.
|
|
127
|
-
* `materializePB` downgrades to the clone path when a consumer needs a
|
|
128
|
-
* real container (reconcile, draft escape). */
|
|
129
|
-
ovl: boolean;
|
|
130
|
-
/** Keys deleted in the overlay window (a prototype overlay cannot shadow
|
|
131
|
-
* a delete); null when none. */
|
|
132
|
-
del: Set<PropertyKey> | null;
|
|
133
|
-
/** Projection family, null for plain stores (§7b). */
|
|
134
|
-
fam: StoreNextFamily | null;
|
|
135
|
-
/** Shallow store root (values served raw). */
|
|
136
|
-
s: boolean;
|
|
137
|
-
/** Held committed view (#3074/#3075): the pre-hold committed backing,
|
|
138
|
-
* served to committed-visibility readers while `ht` is live. Adoption is
|
|
139
|
-
* eager by contract, but a projection recompute deriving from uncommitted
|
|
140
|
-
* inputs (a transition-held source, or a latest()-pull ahead of the flush)
|
|
141
|
-
* swaps the backing SPECULATIVELY — the old view must stay servable until
|
|
142
|
-
* the hold resolves. */
|
|
143
|
-
hv: Record<PropertyKey, any> | null;
|
|
144
|
-
/** The holder for `hv`: a live transition (cleared lazily when it is done)
|
|
145
|
-
* or the PLAIN_HOLD sentinel (a latest()-pull staging — cleared by the
|
|
146
|
-
* fold commit). null = no hold. */
|
|
147
|
-
ht: any;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Ownership stamp (#3360): every backing the store ALLOCATES (CoW clones,
|
|
151
|
-
* privatized committed backings) carries its owning target under this
|
|
152
|
-
* enumerable symbol. One property write replaces the two weak-collection
|
|
153
|
-
* registrations (ownership set + raw→target map) a fresh object used to pay
|
|
154
|
-
* per draft — V8's identity-hash + ephemeron cost dominated the one-key
|
|
155
|
-
* write floor. Enumerable so a spread copy (the plain-data clone path) stays
|
|
156
|
-
* on the fast path and carries the stamp along.
|
|
157
|
-
*
|
|
158
|
-
* Owned backings are never user-reachable (`snapshot` copies them, the traps
|
|
159
|
-
* hide the key), so every raw key walk in the store must skip `$OWNER`, and
|
|
160
|
-
* ownership is answered by `isOwned` — a user object never carries it.
|
|
161
|
-
* Overlay drafts (`Object.create(v)` over an owned `v`) inherit the stamp.
|
|
162
|
-
*/
|
|
163
|
-
export declare const $OWNER: unique symbol;
|
|
164
|
-
/** raw → target for UNOWNED backings (user-ingested, adopted); owned
|
|
165
|
-
* backings resolve through their `$OWNER` stamp. Boundary mechanism (O8). */
|
|
166
|
-
export declare const storeNextLookup: WeakMap<object, StoreNextTarget>;
|
|
167
|
-
/** A backing the store allocated and may mutate in place. */
|
|
168
|
-
export declare function isOwned(raw: object): boolean;
|
|
169
|
-
/** raw → target within a family (`null` = plain stores / the global map).
|
|
170
|
-
* The stamp answers for backings owned by a target OF THAT FAMILY; anything
|
|
171
|
-
* else (user objects, adoptees, another family's backings the family
|
|
172
|
-
* re-registered for its own wrapper) resolves through the family's map. */
|
|
173
|
-
export declare function lookupTarget(raw: object, fam: StoreNextFamily | null): StoreNextTarget | undefined;
|
|
174
|
-
/** __TEST__ oracle: every object ingested from a user (never mutate). */
|
|
175
|
-
export declare const ingestedRaw: WeakSet<object> | null;
|
|
176
|
-
export declare function devAssertNeverUserMutation(target: object): void;
|
|
177
|
-
/** Injection table for optimistic-only store machinery (next/optimistic.ts).
|
|
178
|
-
* Every call site is gated on `fam?.opt`, and optimistic families can only
|
|
179
|
-
* be created by createOptimisticStore — whose install populates this — so
|
|
180
|
-
* the non-null assertions at the sites hold by construction. Keeping the
|
|
181
|
-
* implementations out of next/store.ts lets plain-store bundles tree-shake
|
|
182
|
-
* the optimistic channel entirely. */
|
|
183
|
-
export interface OptStoreHooks {
|
|
184
|
-
notifyOptimisticWrites(t: any, pb: Record<PropertyKey, any>): void;
|
|
185
|
-
optimisticView(t: any, src: Record<PropertyKey, any>, draft?: boolean): Record<PropertyKey, any>;
|
|
186
|
-
applyTentative(t: any, incoming: any, keyFn: ((item: any) => any) | null): void;
|
|
187
|
-
/** #3164 fold: does this live transaction still retain optimism (armed
|
|
188
|
-
* nodes or tracked stores)? Backs the held-truth masks in next/store.ts so
|
|
189
|
-
* plain-store bundles don't carry the transition-optimism probe. */
|
|
190
|
-
retainsOptimism(t: any): boolean;
|
|
191
|
-
}
|
|
192
|
-
export declare let optHooks: OptStoreHooks | null;
|
|
193
|
-
export declare function setOptHooks(h: OptStoreHooks): void;
|
|
194
|
-
/** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
|
|
195
|
-
* only where subscriptions exist at/below. Nodes AND patches count. */
|
|
196
|
-
export declare function markDescendants(target: StoreNextTarget): void;
|