@solidjs/signals 2.0.0-beta.9 → 2.0.0-rc.1
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/README.md +14 -10
- package/dist/dev.js +6740 -2011
- package/dist/node.cjs +7927 -3340
- package/dist/prod/affects.js +126 -0
- package/dist/prod/boundaries.js +572 -0
- package/dist/prod/core/action.js +139 -0
- package/dist/prod/core/async.js +607 -0
- package/dist/prod/core/constants.js +92 -0
- package/dist/prod/core/context.js +67 -0
- package/dist/prod/core/core.js +828 -0
- package/dist/prod/core/dev.js +3 -0
- package/dist/prod/core/effect.js +145 -0
- package/dist/prod/core/error.js +68 -0
- package/dist/prod/core/external.js +98 -0
- package/dist/prod/core/graph.js +104 -0
- package/dist/prod/core/heap.js +140 -0
- package/dist/prod/core/invariants.js +42 -0
- package/dist/prod/core/lanes.js +140 -0
- package/dist/prod/core/optimistic.js +262 -0
- package/dist/prod/core/owner.js +302 -0
- package/dist/prod/core/scheduler.js +757 -0
- package/dist/prod/core/verdict.js +369 -0
- package/dist/prod/index.js +45 -0
- package/dist/prod/map.js +319 -0
- package/dist/prod/signals.js +394 -0
- package/dist/prod/store/index.js +36 -0
- package/dist/prod/store/next/optimistic.js +377 -0
- package/dist/prod/store/next/projection.js +172 -0
- package/dist/prod/store/next/reconcile.js +327 -0
- package/dist/prod/store/next/store.js +1232 -0
- package/dist/prod/store/next/target.js +20 -0
- package/dist/prod/store/store.js +325 -0
- package/dist/prod/store/storePath.js +103 -0
- package/dist/prod/store/utils.js +201 -0
- package/dist/types/affects.d.ts +47 -0
- package/dist/types/boundaries.d.ts +60 -13
- package/dist/types/core/action.d.ts +35 -6
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +35 -6
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +66 -63
- package/dist/types/core/dev.d.ts +17 -2
- package/dist/types/core/effect.d.ts +1 -2
- package/dist/types/core/error.d.ts +33 -0
- package/dist/types/core/external.d.ts +0 -11
- package/dist/types/core/graph.d.ts +2 -1
- package/dist/types/core/heap.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/invariants.d.ts +59 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/optimistic.d.ts +6 -0
- package/dist/types/core/owner.d.ts +50 -3
- package/dist/types/core/scheduler.d.ts +85 -11
- package/dist/types/core/types.d.ts +66 -1
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/map.d.ts +21 -5
- package/dist/types/signals.d.ts +183 -12
- package/dist/types/store/index.d.ts +16 -6
- package/dist/types/store/next/optimistic.d.ts +20 -0
- package/dist/types/store/next/projection.d.ts +24 -0
- package/dist/types/store/next/reconcile.d.ts +3 -0
- package/dist/types/store/next/store.d.ts +71 -0
- package/dist/types/store/next/target.d.ts +99 -0
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +10 -6
- package/dist/types/store/reconcile.d.ts +31 -8
- package/dist/types/store/store.d.ts +91 -71
- package/dist/types/store/utils.d.ts +0 -40
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +60 -13
- package/dist/types-cjs/core/action.d.cts +35 -6
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +35 -6
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +66 -63
- package/dist/types-cjs/core/dev.d.cts +17 -2
- package/dist/types-cjs/core/effect.d.cts +1 -2
- package/dist/types-cjs/core/error.d.cts +33 -0
- package/dist/types-cjs/core/external.d.cts +0 -11
- package/dist/types-cjs/core/graph.d.cts +2 -1
- package/dist/types-cjs/core/heap.d.cts +8 -0
- package/dist/types-cjs/core/index.d.cts +3 -2
- package/dist/types-cjs/core/invariants.d.cts +59 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/optimistic.d.cts +6 -0
- package/dist/types-cjs/core/owner.d.cts +50 -3
- package/dist/types-cjs/core/scheduler.d.cts +85 -11
- package/dist/types-cjs/core/types.d.cts +66 -1
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +3 -2
- package/dist/types-cjs/map.d.cts +21 -5
- package/dist/types-cjs/signals.d.cts +183 -12
- package/dist/types-cjs/store/index.d.cts +16 -6
- package/dist/types-cjs/store/next/optimistic.d.cts +20 -0
- package/dist/types-cjs/store/next/projection.d.cts +24 -0
- package/dist/types-cjs/store/next/reconcile.d.cts +3 -0
- package/dist/types-cjs/store/next/store.d.cts +71 -0
- package/dist/types-cjs/store/next/target.d.cts +99 -0
- package/dist/types-cjs/store/optimistic.d.cts +3 -3
- package/dist/types-cjs/store/projection.d.cts +10 -6
- package/dist/types-cjs/store/reconcile.d.cts +31 -8
- package/dist/types-cjs/store/store.d.cts +91 -71
- package/dist/types-cjs/store/utils.d.cts +0 -40
- package/package.json +12 -9
- package/dist/prod.js +0 -3627
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { isEqual } from "../../core/core.js";
|
|
2
|
+
|
|
3
|
+
import { projectionWriteActive } from "../../core/scheduler.js";
|
|
4
|
+
|
|
5
|
+
import "../../core/invariants.js";
|
|
6
|
+
|
|
7
|
+
import "../../core/verdict.js";
|
|
8
|
+
|
|
9
|
+
import "../../core/effect.js";
|
|
10
|
+
|
|
11
|
+
import { $TARGET, markRawIngest, isWrappable, rawValuesUsed, isRawValue, getWriteOverride } from "../store.js";
|
|
12
|
+
|
|
13
|
+
import { adoptPB, unwrapValue, notifyFold, targetsEqual, bumpDeep, notifyKeyValue, notifyKeyDiff, notifyFoldTail, hasAccessorFlag } from "./store.js";
|
|
14
|
+
|
|
15
|
+
import { storeNextLookup, optHooks, ownedRaw } from "./target.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Store rewrite — reconcile, the adoption channel (INTERNALS-STORE-STATE.md
|
|
19
|
+
* §3, decision 2026-08-16c). Reconcile never merge-writes: it adopts `next`
|
|
20
|
+
* as the authoritative pending backing at every proxied level (pointer swap
|
|
21
|
+
* folded at flush commit), notification riding the fold's descriptor diff.
|
|
22
|
+
*
|
|
23
|
+
* Structural optimizations (all kept, per 2026-08-17 morning ruling):
|
|
24
|
+
* - Identity skip with completed proof: `incoming === backing && !owned` —
|
|
25
|
+
* sound because input is immutable by convention (R2a) and ownership marks
|
|
26
|
+
* the only writer the convention doesn't cover (us). Fixes FINDING-1.
|
|
27
|
+
* - Reachability pruning: descent happens only where a child TARGET exists
|
|
28
|
+
* (proxies exist only where read) — never-subscribed subtrees are never
|
|
29
|
+
* walked (recon-snap R17), while a subscriber deep below an untracked path
|
|
30
|
+
* keeps its chain walkable because wrapping created the intermediate
|
|
31
|
+
* targets (recon-snap R16).
|
|
32
|
+
* - Keyed matching ported semantics: key-matched rows keep proxy identity;
|
|
33
|
+
* key mismatch detaches (fresh proxy on next read, recon-snap R18);
|
|
34
|
+
* keyless items fall back positional; null/primitive slots are legal
|
|
35
|
+
* members (R11). Kind changes replace wholesale (R10).
|
|
36
|
+
*/ function reconcileNextState(e, t, n, o = false) {
|
|
37
|
+
if (t == null) throw new Error("");
|
|
38
|
+
const f = t?.[$TARGET];
|
|
39
|
+
if (f === undefined || f.px !== t) throw new Error("");
|
|
40
|
+
let l = n === null ? null : typeof n === "string" ? e => e?.[n] : n;
|
|
41
|
+
// §7b chained backing: a projection derive returning a LIVE store proxy
|
|
42
|
+
// adopts the proxy itself as the backing — reads flow through the inner
|
|
43
|
+
// store's traps, so consumers subscribe to the inner graph and updates
|
|
44
|
+
// flow with no re-derive (#2941). The adoption diff still notifies THIS
|
|
45
|
+
// store's existing subscribers of the swap.
|
|
46
|
+
if (o && e !== t && e?.[$TARGET] !== undefined) {
|
|
47
|
+
const t = f.pb ?? f.v;
|
|
48
|
+
if (t === e) return;
|
|
49
|
+
// already chained to this store
|
|
50
|
+
adoptPB(f, e);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const i = unwrapValue(e);
|
|
54
|
+
if (l) {
|
|
55
|
+
// Root identity precondition — checked before ANY mutation, so a throwing
|
|
56
|
+
// reconcile is atomic by construction (RUL-12 ruling). Projections
|
|
57
|
+
// (replace=true) relax it: a root entity change merges in place — the
|
|
58
|
+
// root proxy is stable for life (proj R5/R11) — and children are NOT
|
|
59
|
+
// key-matched across the entity change (proj R7: keyFn drops to
|
|
60
|
+
// positional so old-entity subtrees never merge into the new entity's).
|
|
61
|
+
const e = f.pb ?? f.v;
|
|
62
|
+
const t = l(e);
|
|
63
|
+
if (t !== undefined && l(i) !== t) {
|
|
64
|
+
if (!o) throw new Error("");
|
|
65
|
+
// Entity change: wholesale swap. The root proxy is stable for life
|
|
66
|
+
// (proj R5) but NOTHING below survives — children are never matched
|
|
67
|
+
// across an entity change even when their own keys align (proj R7).
|
|
68
|
+
// Displaced-raw unregistration (proj R10): the outgoing raw stops
|
|
69
|
+
// resolving to this proxy; re-handed later it wraps fresh.
|
|
70
|
+
(f.fam?.map ?? storeNextLookup).delete(f.pb ?? f.v);
|
|
71
|
+
adoptPB(f, i);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Tentative channel (§6b, RUL-5): a user-context reconcile on an optimistic
|
|
76
|
+
// family parks as engine overrides — values, membership, and length ride
|
|
77
|
+
// armed nodes (reverting with their transaction); committed raw is never
|
|
78
|
+
// touched. Key-matched rows keep proxy identity by descending into the
|
|
79
|
+
// existing child targets instead of overriding their parent slots.
|
|
80
|
+
if (f.fam?.opt === true && !projectionWriteActive && !getWriteOverride()) {
|
|
81
|
+
optHooks.applyTentative(f, i, l);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
applyAdopt(f, i, l, o);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function applyAdopt(e, t, n, o = false) {
|
|
88
|
+
const f = e.pb ?? e.v;
|
|
89
|
+
// The sound identity skip (O7): same reference AND we never diverged it.
|
|
90
|
+
if (t === f && !ownedRaw.has(f)) return;
|
|
91
|
+
const l = e.fam;
|
|
92
|
+
// §6b (R28): the diff's previous-arrangement baseline is the LANE VIEW —
|
|
93
|
+
// optimistic rows must be visible to key matching so a landing carrying the
|
|
94
|
+
// same key recycles their proxies. Raw `prev` keeps the identity/ownership
|
|
95
|
+
// roles above; only matching reads the view.
|
|
96
|
+
const i = l?.opt === true ? optHooks.optimisticView(e, f) : f;
|
|
97
|
+
const r = Array.isArray(t);
|
|
98
|
+
// Plain stores notify inline AFTER the descent (child registrations feed
|
|
99
|
+
// the fold diff's identity-preservation check); projections keep deferred
|
|
100
|
+
// folds (downstream holds can form later in the flush).
|
|
101
|
+
const u = l === null;
|
|
102
|
+
const s = e.s === true;
|
|
103
|
+
const c = e.v;
|
|
104
|
+
adoptPB(e, t, u);
|
|
105
|
+
// Shallow adoption: records are slot values — sticky raw-mark the incoming
|
|
106
|
+
// set (R41) and never descend; slot notification is the positional diff.
|
|
107
|
+
if (s) markRawIngest(t);
|
|
108
|
+
if (Array.isArray(i) !== r) {
|
|
109
|
+
if (u) notifyFold(e, c, t);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (r) {
|
|
113
|
+
const f = i;
|
|
114
|
+
const r = t;
|
|
115
|
+
// Fused array walk (eager mode): per-index notification rides the same
|
|
116
|
+
// loop as the descent (descend first — targetsEqual needs the child's
|
|
117
|
+
// re-registration, R9). Length, trailing removed indexes, and any other
|
|
118
|
+
// unvisited node keys land in the counted sweep below.
|
|
119
|
+
const a = u ? e.n : null;
|
|
120
|
+
let p = 0;
|
|
121
|
+
if (n && !s) {
|
|
122
|
+
// Positional-prefix fast path (legacy keyedMatch-walk parity): while
|
|
123
|
+
// rows key-match in place — the steady-state polling shape — descend
|
|
124
|
+
// directly with zero staging. The prevByKey map is built only for the
|
|
125
|
+
// misaligned remainder, and never at all on aligned ticks.
|
|
126
|
+
const i = f.length;
|
|
127
|
+
const u = r.length;
|
|
128
|
+
let s = false;
|
|
129
|
+
let d = 0;
|
|
130
|
+
for (const y = Math.min(i, u); d < y; d++) {
|
|
131
|
+
const i = r[d];
|
|
132
|
+
const u = f[d];
|
|
133
|
+
// Routing heuristic only (aligned vs keyed remainder) — both routes
|
|
134
|
+
// notify identically and descend() is the one authoritative
|
|
135
|
+
// validator, so bare typeof gates suffice here; full isWrappable
|
|
136
|
+
// per row was the walk's dominant residual cost.
|
|
137
|
+
if (u !== i && !(u !== null && typeof u === "object" && i !== null && typeof i === "object" && n(u) === n(i))) break;
|
|
138
|
+
// misaligned: fall to the keyed remainder below
|
|
139
|
+
// Identity skip inline (FINDING-1 guard), then descend the pair.
|
|
140
|
+
if ((u !== i || i !== null && typeof i === "object" && ownedRaw.has(i)) && i !== null && typeof i === "object") descend(unwrapValue(u), i, n, l, o);
|
|
141
|
+
if (e.dk !== null && !s && !(i !== null && typeof i === "object" ? targetsEqual(u, i) : isEqual(u, i))) {
|
|
142
|
+
bumpDeep(e);
|
|
143
|
+
s = true;
|
|
144
|
+
}
|
|
145
|
+
if (a !== null) {
|
|
146
|
+
const e = a[d];
|
|
147
|
+
if (e !== undefined) {
|
|
148
|
+
p++;
|
|
149
|
+
notifyKeyValue(e, d, c[d], i, c, t);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (e.dk !== null && !s && d < r.length) bumpDeep(e);
|
|
154
|
+
let y = null;
|
|
155
|
+
for (;d < r.length; d++) {
|
|
156
|
+
const e = r[d];
|
|
157
|
+
// typeof gates route; descend validates (same contract as the prefix).
|
|
158
|
+
if (e !== null && typeof e === "object") {
|
|
159
|
+
const t = n(e);
|
|
160
|
+
let i;
|
|
161
|
+
if (t !== undefined) {
|
|
162
|
+
if (y === null) {
|
|
163
|
+
y = new Map;
|
|
164
|
+
for (let e = 0; e < f.length; e++) {
|
|
165
|
+
const t = unwrapValue(f[e]);
|
|
166
|
+
if (t !== null && typeof t === "object") {
|
|
167
|
+
const e = n(t);
|
|
168
|
+
if (e !== undefined && !y.has(e)) y.set(e, t);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
i = y.get(t);
|
|
173
|
+
} else {
|
|
174
|
+
i = unwrapValue(f[d]);
|
|
175
|
+
// keyless item: positional fallback
|
|
176
|
+
}
|
|
177
|
+
descend(i, e, n, l, o);
|
|
178
|
+
}
|
|
179
|
+
if (a !== null) {
|
|
180
|
+
const e = a[d];
|
|
181
|
+
if (e !== undefined) {
|
|
182
|
+
p++;
|
|
183
|
+
notifyKeyDiff(e, d, c, t, false);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
const i = Math.min(f.length, r.length);
|
|
189
|
+
const u = r.length;
|
|
190
|
+
let d = false;
|
|
191
|
+
for (let y = 0; y < u; y++) {
|
|
192
|
+
const u = r[y];
|
|
193
|
+
if (!s && y < i && u !== null && typeof u === "object") descend(unwrapValue(f[y]), u, n, l, o);
|
|
194
|
+
if (e.dk !== null && !d && !(u !== null && typeof u === "object" ? targetsEqual(f[y], u) : isEqual(f[y], u))) {
|
|
195
|
+
bumpDeep(e);
|
|
196
|
+
d = true;
|
|
197
|
+
}
|
|
198
|
+
if (a !== null) {
|
|
199
|
+
const e = a[y];
|
|
200
|
+
if (e !== undefined) {
|
|
201
|
+
p++;
|
|
202
|
+
notifyKeyDiff(e, y, c, t, false);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (u) {
|
|
208
|
+
if (a !== null && p < e.nc) {
|
|
209
|
+
for (const e of Reflect.ownKeys(a)) {
|
|
210
|
+
// visited indexes are < nextRows.length; everything else sweeps
|
|
211
|
+
const n = typeof e === "string" ? +e : NaN;
|
|
212
|
+
if (!(n >= 0 && n < r.length)) notifyKeyDiff(a[e], e, c, t, false);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
notifyFoldTail(e, c, t);
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
} else {
|
|
219
|
+
// FUSED adoption walk (eager mode): one pass fetches each key's pair,
|
|
220
|
+
// descends, then notifies its node inline — descend runs FIRST so the
|
|
221
|
+
// child's re-registration is visible to targetsEqual (identity-preserved
|
|
222
|
+
// slots must not notify, R9). This replaces the notifyFold re-walk that
|
|
223
|
+
// doubled dbmon's diff cost. for-in covers own enumerable string keys
|
|
224
|
+
// with no key-array allocation; symbols get a pass only when present.
|
|
225
|
+
const f = u ? e.n : null;
|
|
226
|
+
let r = 0;
|
|
227
|
+
let a = false;
|
|
228
|
+
// The per-key body is inlined on purpose (legacy applyStateFast parity:
|
|
229
|
+
// an extracted helper costs a call per key on the hottest object-diff
|
|
230
|
+
// site). Reference-identical values early-continue BEFORE any other
|
|
231
|
+
// work — sound only with the ownership guard (FINDING-1: an owned
|
|
232
|
+
// backing is setter-diverged and must still diff).
|
|
233
|
+
for (const u in t) {
|
|
234
|
+
const p = t[u];
|
|
235
|
+
const d = c[u];
|
|
236
|
+
const y = p !== null && typeof p === "object";
|
|
237
|
+
if (d === p && (!y || !ownedRaw.has(p)) && (f === null || f[u] === undefined || !hasAccessorFlag(f[u]))) {
|
|
238
|
+
if (f !== null && f[u] !== undefined) r++;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (y && !s) descend(unwrapValue(i[u]), p, n, l, o);
|
|
242
|
+
// Deep-witness (dk): value changes must notify even with NO per-key
|
|
243
|
+
// node — deep() subscribes one node per record. Checked after descend
|
|
244
|
+
// so in-place adoptions (same logical slot) don't bump; child records
|
|
245
|
+
// carry their own witness. One flag + null check when unused.
|
|
246
|
+
if (e.dk !== null && !a && !(y ? targetsEqual(d, p) : isEqual(d, p))) {
|
|
247
|
+
bumpDeep(e);
|
|
248
|
+
a = true;
|
|
249
|
+
}
|
|
250
|
+
if (f !== null) {
|
|
251
|
+
const e = f[u];
|
|
252
|
+
if (e !== undefined) {
|
|
253
|
+
r++;
|
|
254
|
+
notifyKeyValue(e, u, d, p, c, t);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const p = Object.getOwnPropertySymbols(t);
|
|
259
|
+
for (let e = 0; e < p.length; e++) {
|
|
260
|
+
const u = p[e];
|
|
261
|
+
const a = t[u];
|
|
262
|
+
if (!s && a !== null && typeof a === "object") descend(unwrapValue(i[u]), a, n, l, o);
|
|
263
|
+
if (f !== null) {
|
|
264
|
+
const e = f[u];
|
|
265
|
+
if (e !== undefined) {
|
|
266
|
+
r++;
|
|
267
|
+
notifyKeyValue(e, u, c[u], a, c, t);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (u) {
|
|
272
|
+
// Deleted-key nodes (in the map but absent from incoming) — counted
|
|
273
|
+
// fast-out: when every node was visited, skip the sweep entirely.
|
|
274
|
+
if (f !== null && r < e.nc) {
|
|
275
|
+
for (const e of Reflect.ownKeys(f)) {
|
|
276
|
+
if (!hasOwnP.call(t, e)) notifyKeyDiff(f[e], e, c, t, false);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
notifyFoldTail(e, c, t);
|
|
280
|
+
}
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const hasOwnP = Object.prototype.hasOwnProperty;
|
|
286
|
+
|
|
287
|
+
function descend(e, t, n, o, f = false) {
|
|
288
|
+
if (e === null || typeof e !== "object" || t === null || typeof t !== "object") return;
|
|
289
|
+
// Lookup FIRST: a hit implies pv was wrappable and never raw-marked (only
|
|
290
|
+
// wrappables acquire targets; rawValues never wrap) — one WeakMap get
|
|
291
|
+
// replaces isWrappable(pv) + isRawValue(pv), and a miss prunes untracked
|
|
292
|
+
// subtrees before any further checks.
|
|
293
|
+
const l = (o?.map ?? storeNextLookup).get(e);
|
|
294
|
+
if (l === undefined) return;
|
|
295
|
+
// nothing proxied below this pair
|
|
296
|
+
// The NEW side still validates fully: a frozen/platform/markRaw'd incoming
|
|
297
|
+
// value is a leaf for reconcile — replaced by reference, never recursed
|
|
298
|
+
// into (R42); the parent's slot notification covers the change.
|
|
299
|
+
if (!isWrappable(t)) return;
|
|
300
|
+
if (rawValuesUsed && isRawValue(t)) return;
|
|
301
|
+
t = unwrapValue(t);
|
|
302
|
+
// Kind change replaces wholesale, never merges (R10): a target's carrier
|
|
303
|
+
// class (array vs object) is fixed at creation, so the slot detaches and a
|
|
304
|
+
// fresh proxy of the right kind wraps the incoming value on next read.
|
|
305
|
+
if (Array.isArray(e) !== Array.isArray(t)) return;
|
|
306
|
+
if (n) {
|
|
307
|
+
const o = n(e);
|
|
308
|
+
const f = n(t);
|
|
309
|
+
// Key mismatch detaches: the slot takes the new entity; the old proxy
|
|
310
|
+
// keeps its (old) backing and a fresh proxy wraps the new value on read.
|
|
311
|
+
if (o !== undefined && f !== undefined && o !== f) return;
|
|
312
|
+
}
|
|
313
|
+
// Reachability pruning (§6d) is MODE-dependent, both pinned:
|
|
314
|
+
// - keyed matching descends only where subscriptions exist at/below (`d`) —
|
|
315
|
+
// captured-but-unobserved proxies deliberately detach and go stale
|
|
316
|
+
// (recon-snap R18; subscribing is what buys liveness);
|
|
317
|
+
// - positional (key: null) pairing preserves slot identity unconditionally
|
|
318
|
+
// (recon-snap R8 — the fixed-shape dashboard pattern).
|
|
319
|
+
// Projection merges (replace mode) preserve key-matched identity
|
|
320
|
+
// UNCONDITIONALLY (proj R6: the slot keeps its proxy without needing a
|
|
321
|
+
// subscriber below); plain keyed reconcile detaches unobserved captures
|
|
322
|
+
// (recon-snap R18 — staleness is the pinned pruning contract).
|
|
323
|
+
if (!f && n !== null && !l.d) return;
|
|
324
|
+
applyAdopt(l, t, n, f);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export { reconcileNextState };
|