@solidjs/signals 2.0.0-rc.7 → 2.0.0-rc.8
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 +5243 -0
- package/dist/dev.attribution.js +2333 -0
- package/dist/dev.js +1229 -6834
- package/dist/observe/affects.js +127 -0
- package/dist/observe/attribution.js +1 -0
- package/dist/observe/boundaries.js +586 -0
- package/dist/observe/core/action.js +167 -0
- package/dist/observe/core/async.js +736 -0
- package/dist/observe/core/attribution-hooks.js +60 -0
- package/dist/observe/core/attribution.js +2318 -0
- package/dist/{types-cjs/core/constants.d.cts → observe/core/constants.js} +129 -73
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1289 -0
- package/dist/observe/core/dev.js +232 -0
- package/dist/observe/core/effect.js +179 -0
- package/dist/observe/core/error.js +80 -0
- package/dist/observe/core/external.js +98 -0
- package/dist/observe/core/graph.js +155 -0
- package/dist/observe/core/heap.js +147 -0
- package/dist/observe/core/invariants.js +43 -0
- package/dist/observe/core/lanes.js +168 -0
- package/dist/observe/core/optimistic.js +438 -0
- package/dist/observe/core/owner.js +308 -0
- package/dist/observe/core/scheduler.js +1190 -0
- package/dist/observe/core/verdict.js +551 -0
- package/dist/observe/index.js +55 -0
- package/dist/observe/map.js +482 -0
- package/dist/{types-cjs/signals.d.cts → observe/signals.js} +295 -317
- package/dist/observe/store/index.js +38 -0
- package/dist/observe/store/next/optimistic.js +651 -0
- package/dist/observe/store/next/projection.js +242 -0
- package/dist/observe/store/next/reconcile.js +373 -0
- package/dist/observe/store/next/store.js +2213 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +323 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +210 -0
- package/dist/prod/attribution.js +32 -0
- package/dist/prod/core/action.js +52 -32
- package/dist/prod/core/async.js +171 -127
- package/dist/prod/core/constants.js +24 -1
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +434 -291
- package/dist/prod/core/effect.js +54 -34
- package/dist/prod/core/external.js +2 -2
- package/dist/prod/core/graph.js +32 -32
- package/dist/prod/core/heap.js +49 -44
- package/dist/prod/core/lanes.js +45 -38
- package/dist/prod/core/optimistic.js +207 -73
- package/dist/prod/core/owner.js +43 -39
- package/dist/prod/core/scheduler.js +319 -190
- package/dist/prod/core/verdict.js +67 -67
- package/dist/prod/index.js +9 -3
- package/dist/prod/map.js +292 -141
- package/dist/prod/signals.js +7 -10
- package/dist/prod/store/next/optimistic.js +140 -125
- package/dist/prod/store/next/projection.js +3 -3
- package/dist/prod/store/next/reconcile.js +87 -84
- package/dist/prod/store/next/store.js +524 -280
- package/dist/prod/store/next/target.js +32 -10
- package/dist/prod/store/store.js +12 -14
- package/dist/prod/store/utils.js +36 -27
- package/dist/types/attribution.d.ts +15 -0
- package/dist/types/attribution.prod.d.ts +13 -0
- package/dist/types/core/async.d.ts +1 -1
- package/dist/types/core/attribution-hooks.d.ts +119 -6
- package/dist/types/core/attribution.d.ts +208 -53
- package/dist/types/core/constants.d.ts +23 -0
- package/dist/types/core/core.d.ts +7 -0
- package/dist/types/core/dev.d.ts +124 -26
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/lanes.d.ts +8 -1
- package/dist/types/core/scheduler.d.ts +60 -0
- package/dist/types/core/types.d.ts +29 -9
- package/dist/types/index.d.ts +9 -2
- package/dist/types/map.d.ts +2 -0
- package/dist/types/store/index.d.ts +1 -0
- package/dist/types/store/next/store.d.ts +5 -0
- package/dist/types/store/next/target.d.ts +36 -9
- package/dist/types/store/utils.d.ts +7 -0
- package/package.json +21 -17
- package/dist/node.cjs +0 -10541
- package/dist/node.dev.cjs +0 -13724
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -23
- package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
- package/dist/types-cjs/core/attribution.d.cts +0 -495
- package/dist/types-cjs/core/core.d.cts +0 -185
- package/dist/types-cjs/core/dev.d.cts +0 -136
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -56
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -28
- package/dist/types-cjs/core/heap.d.cts +0 -24
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -54
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -236
- package/dist/types-cjs/core/types.d.cts +0 -204
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/store/index.d.cts +0 -18
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
- package/dist/types-cjs/store/next/store.d.cts +0 -121
- package/dist/types-cjs/store/next/target.d.cts +0 -166
- package/dist/types-cjs/store/store.d.cts +0 -143
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -74
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { Signal } from "../../core/types.cjs";
|
|
2
|
-
import { type StoreNextFamily, type StoreNextTarget } from "./target.cjs";
|
|
3
|
-
export declare function wrapNext<T extends Record<PropertyKey, any>>(value: T, parent?: StoreNextTarget | null, parentKey?: PropertyKey | null, fam?: StoreNextFamily | null): T;
|
|
4
|
-
/** Unwrap our own proxies to their current backing; leave everything else. */
|
|
5
|
-
export declare function unwrapValue(v: any): any;
|
|
6
|
-
export declare function getNode(target: StoreNextTarget, key: PropertyKey, current: any, accKnown?: -1 | 0 | 1): Signal<any>;
|
|
7
|
-
export declare function getHasNode(target: StoreNextTarget, key: PropertyKey, present: boolean): Signal<boolean>;
|
|
8
|
-
export declare function getKeySetNode(target: StoreNextTarget): Signal<number>;
|
|
9
|
-
/** Deep-witness bump: any value/shape change on a record with a live deep()
|
|
10
|
-
* subscriber notifies it. One null check when unused. */
|
|
11
|
-
export declare function bumpDeep(t: StoreNextTarget): void;
|
|
12
|
-
/** Downgrade a prototype-overlay pending backing to the clone path: builds
|
|
13
|
-
* the real container (committed + overlay writes − deletes) that fold will
|
|
14
|
-
* SWAP in as the committed backing, exactly as if the draft had started on
|
|
15
|
-
* the clone path. Consumers that need a complete container (reconcile's
|
|
16
|
-
* diff walks, drafts escaping into other storage) call this. */
|
|
17
|
-
export declare function materializePB(target: StoreNextTarget): void;
|
|
18
|
-
/**
|
|
19
|
-
* Adoption (2026-08-16c): the incoming object becomes the committed backing
|
|
20
|
-
* IMMEDIATELY — reconcile is eagerly visible to every reader (shipped
|
|
21
|
-
* contract; only its notifications batch), unlike setter writes which stay
|
|
22
|
-
* pending until flush. Ownership resets (incoming is unowned/user data). Any
|
|
23
|
-
* staged draft clone folds into the diff and is discarded — next is the
|
|
24
|
-
* authoritative base (R21/R32).
|
|
25
|
-
*/
|
|
26
|
-
export declare function adoptPB(target: StoreNextTarget, incoming: Record<PropertyKey, any>, eager?: boolean): void;
|
|
27
|
-
/** Parked truth-staged pending backings (#3164 fold): a tentative draft that
|
|
28
|
-
* opens while a folded landing's backing is live moves the staged container
|
|
29
|
-
* here (see ensurePB); the tentative discard in notifyOptimisticWrites
|
|
30
|
-
* restores it in place of the usual null. */
|
|
31
|
-
export declare const stagedTruthPB: WeakMap<StoreNextTarget, Record<PropertyKey, any>>;
|
|
32
|
-
/** Same logical slot: both values resolve to one (re-pointed) child target —
|
|
33
|
-
* adoption preserved identity, so the slot did not change (R9). */
|
|
34
|
-
export declare function targetsEqual(ov: any, nv: any): boolean;
|
|
35
|
-
export declare function arrayStructureChanged(old: any[], neu: any[]): boolean;
|
|
36
|
-
export declare function membershipChanged(old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* The fold diff walks SUBSCRIPTION KEYS ONLY (legacy parity: `for key in
|
|
39
|
-
* nodes`): nodes exist exactly where something tracked, so unobserved data
|
|
40
|
-
* costs nothing here regardless of object size. Accessor safety rides the
|
|
41
|
-
* sticky `t.a` flag — a node's key was necessarily read, so the get trap has
|
|
42
|
-
* already seen whether it is an accessor.
|
|
43
|
-
*/
|
|
44
|
-
/** One node's fold notification (shared by notifyFold's walk and the fused
|
|
45
|
-
* adoption walk): accessor-aware compare + equality/identity-gated setSignal. */
|
|
46
|
-
export declare function notifyKeyDiff(node: Signal<any>, key: PropertyKey, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>, probe?: boolean): void;
|
|
47
|
-
/** Accessor-flag probe for the fused walk's early-continue (accessor keys
|
|
48
|
-
* can never identity-skip: their VALUE is the descriptor's product). */
|
|
49
|
-
export declare function hasAccessorFlag(node: Signal<any>): boolean;
|
|
50
|
-
/** Fused-walk per-key notification with values already in hand: the caller
|
|
51
|
-
* fetched both sides and handled the identity skip; this applies the
|
|
52
|
-
* accessor branch (cached flag only — reconcile channel) or the plain
|
|
53
|
-
* equality/identity-gated write. */
|
|
54
|
-
export declare function notifyKeyValue(node: Signal<any>, key: PropertyKey, ov: any, nv: any, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
|
|
55
|
-
/** Presence + membership halves of a fold notification (shared tail). */
|
|
56
|
-
export declare function notifyFoldTail(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
|
|
57
|
-
export declare function notifyFold(t: StoreNextTarget, old: Record<PropertyKey, any>, neu: Record<PropertyKey, any>): void;
|
|
58
|
-
/** Authoritative-write wrapper exported for the optimistic module: sets the
|
|
59
|
-
* scheduler's projectionWriteActive through THIS module's binding (proven to
|
|
60
|
-
* share the instance core reads — cross-module live-binding writes from other
|
|
61
|
-
* store modules were observed not to propagate under the test transform). */
|
|
62
|
-
export declare function runAuthoritative<T>(fn: () => T): T;
|
|
63
|
-
/** Active optimistic override on an armed node (armed slot idles at
|
|
64
|
-
* NOT_PENDING; undefined = unarmed plain node). */
|
|
65
|
-
export declare function hasActiveOverride(node: Signal<any>): boolean;
|
|
66
|
-
/** The reading computation is until()'s authoritative-view predicate — same
|
|
67
|
-
* source of truth as core read()'s A17 carve-out (`context`, which persists
|
|
68
|
-
* under untrack). optimisticView()'s composition gate consults exactly this:
|
|
69
|
-
* write-side machinery (patch emission, tentative re-application) must keep
|
|
70
|
-
* composing even when it runs inside an authoritative-write bracket. */
|
|
71
|
-
export declare function authoritativeRead(): boolean;
|
|
72
|
-
/** Serve-side authoritative gate: until()'s predicate PLUS truth authors —
|
|
73
|
-
* the projection derive's draft (wrapDraft trap brackets, runAuthoritative;
|
|
74
|
-
* the same posture pair ensurePB classifies drafts by). A source computing
|
|
75
|
-
* the next truth must never read its callers' tentative overlays: a derive
|
|
76
|
-
* continuation's `store.push` computing its index from an action's
|
|
77
|
-
* optimistic row landed truth in the wrong slot and corrupted committed
|
|
78
|
-
* state (#3108). Trap-level overlay serves gate on this so values, length,
|
|
79
|
-
* membership, and keys leave the authoritative view together. */
|
|
80
|
-
export declare function authoritativeServe(): boolean;
|
|
81
|
-
export type SetStoreNextFunction<T> = (fn: (draft: T) => T | void) => void;
|
|
82
|
-
/** Low-level setter primitive: opens write mode on a next proxy, runs `fn`,
|
|
83
|
-
* emits write-time notifications at outermost exit, applies returned
|
|
84
|
-
* replacements as adoptions. `guard=false` skips the owned-scope dev guard —
|
|
85
|
-
* projection recomputes legitimately write from inside their computed. */
|
|
86
|
-
export declare function storeSetterNext<T>(proxy: T, fn: (draft: T) => T | void, guard?: boolean): void;
|
|
87
|
-
export declare function createStoreNext<T extends Record<PropertyKey, any>>(initialValue: T, shallow?: boolean): [T, SetStoreNextFunction<T>];
|
|
88
|
-
/** True when `proxy` is a SHALLOW store (children served verbatim, slots
|
|
89
|
-
* replaced by reference — #2932). The list driver uses this to choose the
|
|
90
|
-
* slot-patch channel (collected row bodies) over per-record registration. */
|
|
91
|
-
export declare function storeIsShallow(proxy: any): boolean;
|
|
92
|
-
/** True when `proxy` belongs to a projection/optimistic FAMILY. The list
|
|
93
|
-
* driver must DECLINE family arrays (external audit finding): family
|
|
94
|
-
* structural changes never emit row/slot ops (the setter channel is
|
|
95
|
-
* fam-gated; optimistic writes ride node overrides), and the proxy identity
|
|
96
|
-
* is stable so the each-watch cannot catch the change either — an engaged
|
|
97
|
-
* list would freeze on optimistic/projection structural updates. Record-
|
|
98
|
-
* level family patches are unaffected (they have their own emission). */
|
|
99
|
-
export declare function storeHasFamily(proxy: any): boolean;
|
|
100
|
-
/** True when `proxy` belongs to an OPTIMISTIC family specifically. The list
|
|
101
|
-
* driver declines these (audit finding, narrowed): optimistic user writes
|
|
102
|
-
* ride node-level overrides — they never enter the reconcile walk, so no
|
|
103
|
-
* row/slot ops are emitted and an engaged list would freeze on optimistic
|
|
104
|
-
* structural changes. PROJECTION (non-optimistic) families are drivable:
|
|
105
|
-
* their recomputes go through the reconcile walk, whose emissions are
|
|
106
|
-
* transition-stamped in the apply queue like any other (equivalence-matrix
|
|
107
|
-
* gated). Re-admitting optimistic families requires a lane-timed structural
|
|
108
|
-
* emission mirroring emitPatchOptimistic, plus revert resync. */
|
|
109
|
-
export declare function storeHasOptimisticFamily(proxy: any): boolean;
|
|
110
|
-
/** Tracking deep snapshot (`deep()` for next targets): subscribes to the
|
|
111
|
-
* key-set and deep-witness node at every reachable level, then returns the
|
|
112
|
-
* plain view. Shared references and cycles handled via the visited set. */
|
|
113
|
-
export declare function deepNext<T>(value: T): T;
|
|
114
|
-
/**
|
|
115
|
-
* Snapshot with per-object registration resolution (RUL-12 DAG ruling): every
|
|
116
|
-
* reachable wrappable resolves through its target's CURRENT backing, so
|
|
117
|
-
* privatized subtrees are seen through any parent path. Identity-preserving:
|
|
118
|
-
* a subtree with no substitutions below returns its own object (zero copy for
|
|
119
|
-
* settled, never-diverged graphs).
|
|
120
|
-
*/
|
|
121
|
-
export declare function snapshotNext<T>(value: T): T;
|
|
@@ -1,166 +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.cjs";
|
|
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
|
-
}
|
|
56
|
-
export interface StoreNextTarget {
|
|
57
|
-
/** Committed backing: source object (shared) or owned clone. */
|
|
58
|
-
v: Record<PropertyKey, any>;
|
|
59
|
-
/** Pending backing for the current flush (null when settled). */
|
|
60
|
-
pb: Record<PropertyKey, any> | null;
|
|
61
|
-
/** cached: committed backing is another store's proxy (§7b chained). */
|
|
62
|
-
ch: boolean;
|
|
63
|
-
/** live value-node count (deleted-key sweep fast-out in the fused walk). */
|
|
64
|
-
nc: number;
|
|
65
|
-
/** Lazy per-property subscription nodes (real core signals). */
|
|
66
|
-
n: Record<PropertyKey, Signal<any>> | null;
|
|
67
|
-
/** Lazy per-key presence nodes (`in` tracks presence, not value — R13). */
|
|
68
|
-
h: Record<PropertyKey, Signal<boolean>> | null;
|
|
69
|
-
/** Lazy key-set node: membership/iteration/$TRACK subscriptions (§6). */
|
|
70
|
-
k: Signal<number> | null;
|
|
71
|
-
/** Keys written through the traps since the last fold commit. Bounds the
|
|
72
|
-
* setter notify/hold-check to O(written) instead of O(subscribed nodes) —
|
|
73
|
-
* a record with thousands of per-key subscriptions (selection maps) would
|
|
74
|
-
* otherwise pay a full node scan on every write. null = no trap writes
|
|
75
|
-
* this batch (bulk paths fall back to the full scan); WK_ALL = bound
|
|
76
|
-
* unusable (array length write). LOAD-BEARING SHAPE RULE: array proxy
|
|
77
|
-
* targets carry their fields as named properties on a real array, and V8
|
|
78
|
-
* normalizes an array to dictionary properties as the named count grows
|
|
79
|
-
* (empirically at counts ≡ 0 mod 3 from 18 up on V8 13.x) — every trap
|
|
80
|
-
* field read then becomes a hash lookup (~15% uibench, tree suites
|
|
81
|
-
* worst). Future write-side state MUST ride an extension object, not new
|
|
82
|
-
* named fields. */
|
|
83
|
-
wk: Set<PropertyKey> | null;
|
|
84
|
-
/** Lazy deep-witness node: `deep()` subscribes ONE node per record instead
|
|
85
|
-
* of one per path; write paths bump it only when it exists. Separate from
|
|
86
|
-
* `k` so $TRACK/mapArray never rerun on leaf value changes (R9). */
|
|
87
|
-
dk: Signal<number> | null;
|
|
88
|
-
/** Parent target (path copying walks this at commit). */
|
|
89
|
-
u: StoreNextTarget | null;
|
|
90
|
-
/** Property key of this target in the parent's backing. */
|
|
91
|
-
pk: PropertyKey | null;
|
|
92
|
-
/** The proxy for this target (stable outward identity). */
|
|
93
|
-
px: any;
|
|
94
|
-
/** Sticky descendants flag (§6d). */
|
|
95
|
-
d: boolean;
|
|
96
|
-
/** Sticky accessors-seen flag: an own accessor property was observed on
|
|
97
|
-
* this target (first-read scan, defineProperty, or clone scan). Gates the
|
|
98
|
-
* fold diff's descriptor-safe path and the get trap's descriptor path. */
|
|
99
|
-
a: boolean;
|
|
100
|
-
/** Accessor scan performed (scan-once on first trap read; adopted data is
|
|
101
|
-
* not rescanned — legacy-parity behavior). */
|
|
102
|
-
sc: boolean;
|
|
103
|
-
/** Adoption diff base, non-null when the backing was swapped by adoption
|
|
104
|
-
* this batch: the view the nodes were LAST TOLD — the pre-batch committed
|
|
105
|
-
* backing, or the draft's pending backing when a draft preceded the
|
|
106
|
-
* adoption (its setter-exit notifications already moved the nodes, #3296).
|
|
107
|
-
* The deferred fold diffs incoming against this, never against committed. */
|
|
108
|
-
ab: Record<PropertyKey, any> | null;
|
|
109
|
-
/** Pending backing is a prototype-chain OVERLAY of the committed backing
|
|
110
|
-
* (`Object.create(v)` — own keys are this batch's writes, everything else
|
|
111
|
-
* reads through). O(written) per flush instead of O(container) clones
|
|
112
|
-
* (#3044); commit flattens own keys onto an owned committed backing in
|
|
113
|
-
* place. Only plain-data non-array non-family containers qualify;
|
|
114
|
-
* `materializePB` downgrades to the clone path when a consumer needs a
|
|
115
|
-
* real container (reconcile, draft escape). */
|
|
116
|
-
ovl: boolean;
|
|
117
|
-
/** Keys deleted in the overlay window (a prototype overlay cannot shadow
|
|
118
|
-
* a delete); null when none. */
|
|
119
|
-
del: Set<PropertyKey> | null;
|
|
120
|
-
/** Projection family, null for plain stores (§7b). */
|
|
121
|
-
fam: StoreNextFamily | null;
|
|
122
|
-
/** Shallow store root (values served raw). */
|
|
123
|
-
s: boolean;
|
|
124
|
-
/** Held committed view (#3074/#3075): the pre-hold committed backing,
|
|
125
|
-
* served to committed-visibility readers while `ht` is live. Adoption is
|
|
126
|
-
* eager by contract, but a projection recompute deriving from uncommitted
|
|
127
|
-
* inputs (a transition-held source, or a latest()-pull ahead of the flush)
|
|
128
|
-
* swaps the backing SPECULATIVELY — the old view must stay servable until
|
|
129
|
-
* the hold resolves. */
|
|
130
|
-
hv: Record<PropertyKey, any> | null;
|
|
131
|
-
/** The holder for `hv`: a live transition (cleared lazily when it is done)
|
|
132
|
-
* or the PLAIN_HOLD sentinel (a latest()-pull staging — cleared by the
|
|
133
|
-
* fold commit). null = no hold. */
|
|
134
|
-
ht: any;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Ownership (first cut, decision 2026-08-16d): one WeakSet of store-owned
|
|
138
|
-
* backings serving both the production identity-skip guard and the __TEST__
|
|
139
|
-
* no-mutation oracle.
|
|
140
|
-
*/
|
|
141
|
-
export declare const ownedRaw: WeakSet<object>;
|
|
142
|
-
/** raw → target. The only raw-keyed lookup; boundary mechanism (O8). */
|
|
143
|
-
export declare const storeNextLookup: WeakMap<object, StoreNextTarget>;
|
|
144
|
-
/** __TEST__ oracle: every object ingested from a user (never mutate). */
|
|
145
|
-
export declare const ingestedRaw: WeakSet<object> | null;
|
|
146
|
-
export declare function devAssertNeverUserMutation(target: object): void;
|
|
147
|
-
/** Injection table for optimistic-only store machinery (next/optimistic.ts).
|
|
148
|
-
* Every call site is gated on `fam?.opt`, and optimistic families can only
|
|
149
|
-
* be created by createOptimisticStore — whose install populates this — so
|
|
150
|
-
* the non-null assertions at the sites hold by construction. Keeping the
|
|
151
|
-
* implementations out of next/store.ts lets plain-store bundles tree-shake
|
|
152
|
-
* the optimistic channel entirely. */
|
|
153
|
-
export interface OptStoreHooks {
|
|
154
|
-
notifyOptimisticWrites(t: any, pb: Record<PropertyKey, any>): void;
|
|
155
|
-
optimisticView(t: any, src: Record<PropertyKey, any>): Record<PropertyKey, any>;
|
|
156
|
-
applyTentative(t: any, incoming: any, keyFn: ((item: any) => any) | null): void;
|
|
157
|
-
/** #3164 fold: does this live transaction still retain optimism (armed
|
|
158
|
-
* nodes or tracked stores)? Backs the held-truth masks in next/store.ts so
|
|
159
|
-
* plain-store bundles don't carry the transition-optimism probe. */
|
|
160
|
-
retainsOptimism(t: any): boolean;
|
|
161
|
-
}
|
|
162
|
-
export declare let optHooks: OptStoreHooks | null;
|
|
163
|
-
export declare function setOptHooks(h: OptStoreHooks): void;
|
|
164
|
-
/** Sticky descendants flag walk (§6d): reconcile's keyed pruning descends
|
|
165
|
-
* only where subscriptions exist at/below. Nodes AND patches count. */
|
|
166
|
-
export declare function markDescendants(target: StoreNextTarget): void;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { type Signal } from "../core/index.cjs";
|
|
2
|
-
import type { Refreshable } from "../core/index.cjs";
|
|
3
|
-
/** A reactive view of a store's value. Update it through the paired `StoreSetter`. */
|
|
4
|
-
export type Store<T> = T;
|
|
5
|
-
/**
|
|
6
|
-
* A store setter. The callback receives a writable **draft** of the store.
|
|
7
|
-
*
|
|
8
|
-
* - **Mutate in place (canonical):** `s.foo = 1`, `s.list.push(x)`,
|
|
9
|
-
* `s.list.splice(i, 1)`. This is the default form for most updates.
|
|
10
|
-
* - **Return a new value:** for shapes where mutation is awkward, most
|
|
11
|
-
* commonly removing items (`s => s.list.filter(...)`). Arrays are replaced
|
|
12
|
-
* by index (length adjusted); objects are shallow-diffed at the top level
|
|
13
|
-
* (keys present in the returned value are written, missing keys deleted).
|
|
14
|
-
*
|
|
15
|
-
* The setter does **not** perform keyed reconciliation. If you need surviving
|
|
16
|
-
* items to keep their store identity across full-array replacement, use the
|
|
17
|
-
* projection form — `createStore(fn, seed, { key })` or
|
|
18
|
-
* `createProjection(fn, seed, { key })` — whose derive function reconciles
|
|
19
|
-
* its return by `options.key`.
|
|
20
|
-
*/
|
|
21
|
-
export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
|
|
22
|
-
/** Tuple returned by the plain `createStore(initialValue, options?)` form. */
|
|
23
|
-
export type StoreReturn<T> = [get: Store<T>, set: StoreSetter<T>];
|
|
24
|
-
/** Tuple returned by the derived `createStore(fn, seed, options?)` form. */
|
|
25
|
-
export type ProjectionStoreReturn<T> = [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
26
|
-
/** Options shared by all store primitives. */
|
|
27
|
-
export interface StoreOptions {
|
|
28
|
-
/** Debug name (dev mode only) */
|
|
29
|
-
name?: string;
|
|
30
|
-
/** Single-layer store: root keys reactive, values raw records replaced by reference */
|
|
31
|
-
shallow?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Options for derived/projected stores created with
|
|
35
|
-
* `createStore(fn, seed, options?)`, `createProjection(fn, seed, options?)`,
|
|
36
|
-
* or `createOptimisticStore(fn, seed, options?)`.
|
|
37
|
-
*/
|
|
38
|
-
export interface ProjectionOptions extends StoreOptions {
|
|
39
|
-
/** Key property name or function for reconciliation identity; `null` merges positionally */
|
|
40
|
-
key?: string | ((item: NonNullable<any>) => any) | null;
|
|
41
|
-
/**
|
|
42
|
-
* Treat the seed as commit #0: the store is born committed with the seed's
|
|
43
|
-
* contents, shown until the derive's first real answer lands. While that
|
|
44
|
-
* first answer is in flight, reads serve the seed everywhere — nothing
|
|
45
|
-
* suspends to a `<Loading>` boundary, no transition is held, and
|
|
46
|
-
* `isPending` stays false (the seed answers by declaration; first-load
|
|
47
|
-
* affordances belong to the data, e.g. a `skeleton: true` field in the
|
|
48
|
-
* seed). Once the first answer lands (reconciled into the seed), refetches
|
|
49
|
-
* use normal pending semantics with `isPending` true.
|
|
50
|
-
*
|
|
51
|
-
* The store equivalent of `MemoOptions.loadingValue`; the seed already
|
|
52
|
-
* carries the placeholder shape, so this is just the opt-in.
|
|
53
|
-
*/
|
|
54
|
-
seedLoadingValue?: boolean;
|
|
55
|
-
}
|
|
56
|
-
export type NoFn<T> = T extends Function ? never : T;
|
|
57
|
-
type DataNode = Signal<any>;
|
|
58
|
-
type DataNodes = Record<PropertyKey, DataNode>;
|
|
59
|
-
/**
|
|
60
|
-
* Brand symbols used internally by the store proxy / projection plumbing.
|
|
61
|
-
* Cross-package wiring; not part of the user-facing API.
|
|
62
|
-
*
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol, $AFFECTS: unique symbol;
|
|
66
|
-
export declare const STORE_VALUE = "v", STORE_NODE = "n", STORE_HAS = "h", STORE_PARENT = "u", STORE_DESC = "d", STORE_SHALLOW = "s";
|
|
67
|
-
/** Structural view of a store target as shared machinery sees it (the real
|
|
68
|
-
* shape is `StoreNextTarget` in ./next/target.ts). */
|
|
69
|
-
export type StoreNode = {
|
|
70
|
-
[$PROXY]: any;
|
|
71
|
-
[STORE_VALUE]: Record<PropertyKey, any>;
|
|
72
|
-
[STORE_NODE]?: DataNodes;
|
|
73
|
-
[STORE_HAS]?: DataNodes;
|
|
74
|
-
[STORE_PARENT]?: StoreNode;
|
|
75
|
-
[STORE_SHALLOW]?: boolean;
|
|
76
|
-
[STORE_DESC]?: boolean;
|
|
77
|
-
};
|
|
78
|
-
export declare namespace SolidStore {
|
|
79
|
-
interface Unwrappable {
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
|
|
83
|
-
/**
|
|
84
|
-
* Marks a value as raw: no store will ever wrap it — every store presents it
|
|
85
|
-
* as-is, tracked by reference at whatever slot holds it and updated by
|
|
86
|
-
* replacement. Useful for class instances and external objects (editors,
|
|
87
|
-
* scene graphs, Maps) and for record-shaped data updated wholesale. Sticky
|
|
88
|
-
* for the value's lifetime.
|
|
89
|
-
*/
|
|
90
|
-
export declare let rawValuesUsed: boolean;
|
|
91
|
-
export declare function isRawValue(value: any): boolean;
|
|
92
|
-
export declare function markRaw<T>(value: T): T;
|
|
93
|
-
export declare function markRawOne(v: any): void;
|
|
94
|
-
export declare function markRawIngest(container: any): void;
|
|
95
|
-
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
|
|
96
|
-
export declare function setWriteOverride(value: boolean): void;
|
|
97
|
-
export declare function getWriteOverride(): boolean;
|
|
98
|
-
export declare function ownEnumerableKeys(o: object): (string | symbol)[];
|
|
99
|
-
/**
|
|
100
|
-
* Scope inheritance for late-created nodes: every live mark whose identity
|
|
101
|
-
* scope contains the owning record's raw — and, for keyed marks, whose key
|
|
102
|
-
* is this property — gets counted on the new node. Inherited marks live
|
|
103
|
-
* exactly as long as the scope's carrier — the release hook below drops
|
|
104
|
-
* them with the entry.
|
|
105
|
-
*/
|
|
106
|
-
export declare function inheritAffectsMarks(node: DataNode, raw: object, property: PropertyKey): void;
|
|
107
|
-
/** Next-store node factory for affects carriers/slots: injected by the
|
|
108
|
-
* rewrite module (next targets alias the legacy field names, so everything
|
|
109
|
-
* here EXCEPT node creation works on them structurally). */
|
|
110
|
-
export declare let nextAffectsNodeResolver: ((target: any, key: PropertyKey) => DataNode) | null;
|
|
111
|
-
export declare function setNextAffectsNodeResolver(fn: (target: any, key: PropertyKey) => DataNode): void;
|
|
112
|
-
/** Next-store optimistic view for the declaration walk (optimistic rows
|
|
113
|
-
* pushed before the declaration are in motion too — legacy reads its write
|
|
114
|
-
* overlays; next composes armed-node overrides). */
|
|
115
|
-
export declare let nextOptimisticViewResolver: ((target: any, raw: any) => any) | null;
|
|
116
|
-
export declare function setNextOptimisticViewResolver(fn: (target: any, raw: any) => any): void;
|
|
117
|
-
/** @internal birth inheritance for nodes created inside a live mark window —
|
|
118
|
-
* exported for the rewrite's node factories. */
|
|
119
|
-
export declare function affectsScopesLive(): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Witness live mark coverage of a record into the active isPending() probe.
|
|
122
|
-
* Tracked reads don't need this — they go through real signal nodes, which
|
|
123
|
-
* carry marks directly (declaration walk or birth inheritance). This covers
|
|
124
|
-
* UNTRACKED probes reading through records whose nodes never materialized
|
|
125
|
-
* (no observer ever subscribed, so no node exists to carry the mark).
|
|
126
|
-
* Callers guard on `pendingCheckActive`, so plain reads never pay for this.
|
|
127
|
-
*
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
export declare function witnessAffectsMark(target: StoreNode, property?: PropertyKey): void;
|
|
131
|
-
/**
|
|
132
|
-
* Resolves the store nodes an `affects()` declaration marks: with a `key`,
|
|
133
|
-
* the named slot's leaf node (upserted so the mark has an addressable
|
|
134
|
-
* carrier); without, the record's $AFFECTS carrier plus every LIVE node in
|
|
135
|
-
* its subtree (the edges existing readers subscribed through), with the
|
|
136
|
-
* subtree's identities snapshotted into the mark's scope so nodes created
|
|
137
|
-
* during the window — and untracked probes over captured proxies — resolve
|
|
138
|
-
* against it (#2882).
|
|
139
|
-
*
|
|
140
|
-
* @internal
|
|
141
|
-
*/
|
|
142
|
-
export declare function getStoreAffectsNodes(target: StoreNode, key?: PropertyKey): DataNode[];
|
|
143
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { type NotWrappable } from "./store.cjs";
|
|
2
|
-
type W<T> = Exclude<T, NotWrappable>;
|
|
3
|
-
type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [never] ? never : [T] extends [readonly unknown[]] ? number : keyof T : keyof T;
|
|
4
|
-
export type CustomPartial<T> = T extends readonly unknown[] ? "0" extends keyof T ? {
|
|
5
|
-
[K in Extract<keyof T, `${number}`>]?: T[K];
|
|
6
|
-
} : {
|
|
7
|
-
[x: number]: T[number];
|
|
8
|
-
} : Partial<T>;
|
|
9
|
-
export type StorePathRange = {
|
|
10
|
-
from?: number;
|
|
11
|
-
to?: number;
|
|
12
|
-
by?: number;
|
|
13
|
-
};
|
|
14
|
-
export type ArrayFilterFn<T> = (item: T, index: number) => boolean;
|
|
15
|
-
export type PathSetter<T> = T | CustomPartial<T> | ((prev: T) => T | CustomPartial<T>) | typeof DELETE;
|
|
16
|
-
export type Part<T, K extends KeyOf<T> = KeyOf<T>> = K | ([K] extends [never] ? never : readonly K[]) | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
|
|
17
|
-
declare const DELETE: unique symbol;
|
|
18
|
-
export interface storePath {
|
|
19
|
-
DELETE: typeof DELETE;
|
|
20
|
-
<T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>, K7 extends KeyOf<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, k7: Part<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>, K7>, setter: PathSetter<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>[K7]>): (state: T) => void;
|
|
21
|
-
<T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, setter: PathSetter<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>): (state: T) => void;
|
|
22
|
-
<T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, setter: PathSetter<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>): (state: T) => void;
|
|
23
|
-
<T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, setter: PathSetter<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>): (state: T) => void;
|
|
24
|
-
<T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, setter: PathSetter<W<W<W<T>[K1]>[K2]>[K3]>): (state: T) => void;
|
|
25
|
-
<T, K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, setter: PathSetter<W<W<T>[K1]>[K2]>): (state: T) => void;
|
|
26
|
-
<T, K1 extends KeyOf<W<T>>>(k1: Part<W<T>, K1>, setter: PathSetter<W<T>[K1]>): (state: T) => void;
|
|
27
|
-
<T>(setter: PathSetter<T>): (state: T) => void;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Path-based setter helper for `createStore`. Call `storePath(...path, value)`
|
|
31
|
-
* to produce a draft-mutating function suitable for passing to `setStore`.
|
|
32
|
-
*
|
|
33
|
-
* The canonical setter form in Solid 2.0 is the draft-mutating callback
|
|
34
|
-
* (`setStore(s => { s.user.name = "Ada"; })`). `storePath` is a backwards-
|
|
35
|
-
* compatibility helper for users porting from Solid 1.x's
|
|
36
|
-
* `setStore("user", "name", "Ada")` style — it's optional and you can mix the
|
|
37
|
-
* two styles freely.
|
|
38
|
-
*
|
|
39
|
-
* Path parts can be:
|
|
40
|
-
* - a single key — `"user"`, `0`
|
|
41
|
-
* - an array of keys — `[0, 1, 2]`
|
|
42
|
-
* - a range over an array — `{ from?, to?, by? }`
|
|
43
|
-
* - a filter `(item, index) => boolean` for arrays
|
|
44
|
-
*
|
|
45
|
-
* The final argument is the new value or an updater `(prev) => next`. Use
|
|
46
|
-
* `storePath.DELETE` to remove a property.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* const [state, setState] = createStore({ user: { name: "Ada" }, todos: [] });
|
|
51
|
-
*
|
|
52
|
-
* setState(storePath("user", "name", "Grace"));
|
|
53
|
-
* setState(storePath("todos", t => !t.done, "done", true)); // mark all undone as done
|
|
54
|
-
* setState(storePath("user", "nickname", storePath.DELETE));
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare const storePath: storePath;
|
|
58
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
type DistributeOverride<T, F> = T extends undefined ? F : T;
|
|
2
|
-
type Override<T, U> = T extends any ? U extends any ? {
|
|
3
|
-
[K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
|
|
4
|
-
} & {
|
|
5
|
-
[K in keyof U]: K extends keyof T ? DistributeOverride<U[K], T[K]> : U[K];
|
|
6
|
-
} : T & U : T & U;
|
|
7
|
-
type OverrideSpread<T, U> = T extends any ? {
|
|
8
|
-
[K in keyof ({
|
|
9
|
-
[K in keyof T]: any;
|
|
10
|
-
} & {
|
|
11
|
-
[K in keyof U]?: any;
|
|
12
|
-
} & {
|
|
13
|
-
[K in U extends any ? keyof U : keyof U]?: any;
|
|
14
|
-
})]: K extends keyof T ? Exclude<U extends any ? U[K & keyof U] : never, undefined> | T[K] : U extends any ? U[K & keyof U] : never;
|
|
15
|
-
} : T & U;
|
|
16
|
-
type Simplify<T> = T extends any ? {
|
|
17
|
-
[K in keyof T]: T[K];
|
|
18
|
-
} : T;
|
|
19
|
-
type _Merge<T extends unknown[], Curr = {}> = T extends [
|
|
20
|
-
infer Next | (() => infer Next),
|
|
21
|
-
...infer Rest
|
|
22
|
-
] ? _Merge<Rest, Override<Curr, Next>> : T extends [...infer Rest, infer Next | (() => infer Next)] ? Override<_Merge<Rest, Curr>, Next> : T extends [] ? Curr : T extends (infer I | (() => infer I))[] ? OverrideSpread<Curr, I> : Curr;
|
|
23
|
-
export type Merge<T extends unknown[]> = Simplify<_Merge<T>>;
|
|
24
|
-
/**
|
|
25
|
-
* Merges multiple props-like objects into a single proxy that *preserves
|
|
26
|
-
* reactivity*. Reads are forwarded to the right-most source that defines the
|
|
27
|
-
* property, so later sources override earlier ones (like `Object.assign`).
|
|
28
|
-
*
|
|
29
|
-
* Function arguments are treated as memo-backed sources — useful for passing
|
|
30
|
-
* derived defaults whose computation should track reactively.
|
|
31
|
-
*
|
|
32
|
-
* Use this in component bodies to merge defaults / overrides without losing
|
|
33
|
-
* Solid's per-property tracking.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```tsx
|
|
37
|
-
* function Button(_props: { label: string; type?: string; disabled?: boolean }) {
|
|
38
|
-
* const props = merge({ type: "button", disabled: false }, _props);
|
|
39
|
-
*
|
|
40
|
-
* return <button type={props.type} disabled={props.disabled}>{props.label}</button>;
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function merge<T extends unknown[]>(...sources: T): Merge<T>;
|
|
45
|
-
export type Omit<T, K extends readonly (keyof T)[]> = {
|
|
46
|
-
[P in keyof T as Exclude<P, K[number]>]: T[P];
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Returns a reactive proxy of `props` with the listed keys hidden. Tracking
|
|
50
|
-
* on the remaining keys is preserved.
|
|
51
|
-
*
|
|
52
|
-
* Use it to forward "rest" props to a child element while pulling out the
|
|
53
|
-
* keys your component handles itself — the equivalent of `splitProps(p, ["a","b"])[1]`.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```tsx
|
|
57
|
-
* function Input(props: { label: string; value: string; onInput: (v: string) => void } & JSX.HTMLAttributes<HTMLInputElement>) {
|
|
58
|
-
* const rest = omit(props, "label", "value", "onInput");
|
|
59
|
-
*
|
|
60
|
-
* return (
|
|
61
|
-
* <label>
|
|
62
|
-
* {props.label}
|
|
63
|
-
* <input
|
|
64
|
-
* {...rest}
|
|
65
|
-
* value={props.value}
|
|
66
|
-
* onInput={e => props.onInput(e.currentTarget.value)}
|
|
67
|
-
* />
|
|
68
|
-
* </label>
|
|
69
|
-
* );
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export declare function omit<T extends Record<any, any>, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit<T, K>;
|
|
74
|
-
export {};
|