@solidjs/signals 2.0.0-rc.6 → 2.0.0-rc.7
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.js +2033 -1291
- package/dist/node.cjs +1821 -2401
- package/dist/node.dev.cjs +13724 -0
- package/dist/prod/boundaries.js +3 -1
- package/dist/prod/core/async.js +6 -1
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +9 -1
- package/dist/prod/core/context.js +10 -16
- package/dist/prod/core/core.js +215 -139
- package/dist/prod/core/dev.js +2 -0
- package/dist/prod/core/effect.js +37 -28
- package/dist/prod/core/external.js +2 -2
- package/dist/prod/core/graph.js +35 -31
- package/dist/prod/core/heap.js +34 -40
- package/dist/prod/core/lanes.js +41 -27
- package/dist/prod/core/optimistic.js +42 -32
- package/dist/prod/core/owner.js +32 -32
- package/dist/prod/core/scheduler.js +140 -154
- package/dist/prod/core/verdict.js +31 -34
- package/dist/prod/index.js +0 -2
- package/dist/prod/map.js +104 -94
- package/dist/prod/signals.js +51 -34
- package/dist/prod/store/next/optimistic.js +153 -172
- package/dist/prod/store/next/reconcile.js +140 -288
- package/dist/prod/store/next/store.js +307 -237
- package/dist/prod/store/store.js +2 -2
- package/dist/types/core/attribution-hooks.d.ts +64 -0
- package/dist/types/core/attribution.d.ts +265 -9
- package/dist/types/core/constants.d.ts +8 -0
- package/dist/types/core/core.d.ts +12 -3
- package/dist/types/core/dev.d.ts +49 -8
- package/dist/types/core/heap.d.ts +5 -3
- package/dist/types/core/invariants.d.ts +1 -1
- package/dist/types/core/lanes.d.ts +10 -0
- package/dist/types/core/scheduler.d.ts +9 -4
- package/dist/types/signals.d.ts +10 -0
- package/dist/types/store/index.d.ts +3 -6
- package/dist/types/store/next/optimistic.d.ts +4 -2
- package/dist/types/store/next/reconcile.d.ts +5 -12
- package/dist/types/store/next/store.d.ts +3 -9
- package/dist/types/store/next/target.d.ts +20 -46
- package/dist/types/store/store.d.ts +14 -9
- package/dist/types-cjs/core/attribution-hooks.d.cts +64 -0
- package/dist/types-cjs/core/attribution.d.cts +265 -9
- package/dist/types-cjs/core/constants.d.cts +8 -0
- package/dist/types-cjs/core/core.d.cts +12 -3
- package/dist/types-cjs/core/dev.d.cts +49 -8
- package/dist/types-cjs/core/heap.d.cts +5 -3
- package/dist/types-cjs/core/invariants.d.cts +1 -1
- package/dist/types-cjs/core/lanes.d.cts +10 -0
- package/dist/types-cjs/core/scheduler.d.cts +9 -4
- package/dist/types-cjs/signals.d.cts +10 -0
- package/dist/types-cjs/store/index.d.cts +3 -6
- package/dist/types-cjs/store/next/optimistic.d.cts +4 -2
- package/dist/types-cjs/store/next/reconcile.d.cts +5 -12
- package/dist/types-cjs/store/next/store.d.cts +3 -9
- package/dist/types-cjs/store/next/target.d.cts +20 -46
- package/dist/types-cjs/store/store.d.cts +14 -9
- package/package.json +3 -2
- package/dist/prod/store/next/patch-hooks.js +0 -13
- package/dist/prod/store/next/patch.js +0 -614
- package/dist/types/store/next/patch-hooks.d.ts +0 -41
- package/dist/types/store/next/patch.d.ts +0 -91
- package/dist/types-cjs/store/next/patch-hooks.d.cts +0 -41
- package/dist/types-cjs/store/next/patch.d.cts +0 -91
package/dist/prod/core/dev.js
CHANGED
package/dist/prod/core/effect.js
CHANGED
|
@@ -4,7 +4,9 @@ import { setEffectStatusNotify, ext, createEffectNode, recompute, computed, stal
|
|
|
4
4
|
|
|
5
5
|
import { unwrapStatusError, StatusError } from "./error.js";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { enqueueSub } from "./heap.js";
|
|
8
|
+
|
|
9
|
+
import { GlobalQueue, haltReactivity, schedule } from "./scheduler.js";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
|
|
@@ -12,9 +14,9 @@ import { GlobalQueue, haltReactivity } from "./scheduler.js";
|
|
|
12
14
|
* sources and recompute
|
|
13
15
|
*/ function effect(t, e, E, f) {
|
|
14
16
|
const r = !!f?.user;
|
|
15
|
-
const
|
|
16
|
-
recompute(
|
|
17
|
-
!f?.defer && (
|
|
17
|
+
const n = createEffectNode(t, e, E, r ? EFFECT_USER : EFFECT_RENDER, f);
|
|
18
|
+
recompute(n, true);
|
|
19
|
+
!f?.defer && (n.ge === EFFECT_USER || f?.schedule ? n.C.enqueue(n.ge, runEffect.bind(null, n)) : runEffect(n));
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
function notifyEffectStatus(t, e) {
|
|
@@ -34,8 +36,8 @@ function notifyEffectStatus(t, e) {
|
|
|
34
36
|
// `status` arg without node-state writes) don't queue: the status
|
|
35
37
|
// re-propagates unblocked at commit.
|
|
36
38
|
if (this.S & STATUS_ERROR) {
|
|
37
|
-
this.
|
|
38
|
-
this.C.enqueue(this.ge, this.
|
|
39
|
+
this.He = true;
|
|
40
|
+
this.C.enqueue(this.ge, this.it ??= runEffect.bind(null, this));
|
|
39
41
|
}
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
@@ -49,7 +51,7 @@ function notifyEffectStatus(t, e) {
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
function runEffect(t) {
|
|
52
|
-
if (!t.
|
|
54
|
+
if (!t.He || t.ie & REACTIVE_DISPOSED) return;
|
|
53
55
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
54
56
|
// the node's settled state at effect time runs the bundle's error handler in
|
|
55
57
|
// this same imperative, writable scope. Unwrap the StatusError used for
|
|
@@ -62,12 +64,12 @@ function runEffect(t) {
|
|
|
62
64
|
// same flush must not be hijacked by a later-arriving error status.
|
|
63
65
|
if (t.S & STATUS_ERROR && t.ge === EFFECT_USER) {
|
|
64
66
|
const e = unwrapStatusError(t.o?._);
|
|
65
|
-
t.
|
|
66
|
-
t.
|
|
67
|
+
t.Ot = t.be;
|
|
68
|
+
t.He = false;
|
|
67
69
|
try {
|
|
68
|
-
t.
|
|
69
|
-
const e = t.
|
|
70
|
-
t.
|
|
70
|
+
t.Rt ? t.Rt(e, () => {
|
|
71
|
+
const e = t.Gt;
|
|
72
|
+
t.Gt = undefined;
|
|
71
73
|
e?.();
|
|
72
74
|
}) : console.error(e);
|
|
73
75
|
} catch (e) {
|
|
@@ -78,14 +80,14 @@ function runEffect(t) {
|
|
|
78
80
|
}
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
|
-
const e = t.
|
|
82
|
-
t.
|
|
83
|
+
const e = t.Gt;
|
|
84
|
+
t.Gt = undefined;
|
|
83
85
|
try {
|
|
84
86
|
e?.();
|
|
85
|
-
const E = t.
|
|
87
|
+
const E = t.Ct(t.be, t.Ot);
|
|
86
88
|
if (false && E !== undefined && typeof E !== "function") ;
|
|
87
89
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
88
|
-
t.
|
|
90
|
+
t.Gt = E;
|
|
89
91
|
} catch (e) {
|
|
90
92
|
ext(t)._ = new StatusError(t, e);
|
|
91
93
|
t.S |= STATUS_ERROR;
|
|
@@ -94,12 +96,12 @@ function runEffect(t) {
|
|
|
94
96
|
throw e;
|
|
95
97
|
}
|
|
96
98
|
} finally {
|
|
97
|
-
t.
|
|
98
|
-
t.
|
|
99
|
+
t.Ot = t.be;
|
|
100
|
+
t.He = false;
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
GlobalQueue.
|
|
104
|
+
GlobalQueue.ut = runEffect;
|
|
103
105
|
|
|
104
106
|
/**
|
|
105
107
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
@@ -107,31 +109,38 @@ GlobalQueue.it = runEffect;
|
|
|
107
109
|
* Uses stale reads.
|
|
108
110
|
*/ function trackedEffect(t, e) {
|
|
109
111
|
const run = () => {
|
|
110
|
-
|
|
112
|
+
// `_modified` is NOT redundant with the heap: the heap dedups within a
|
|
113
|
+
// pass, but a held transition's passes each enqueue `_run` into the same
|
|
114
|
+
// user queue, and this gate is what collapses them into one run at commit.
|
|
115
|
+
if (!E.He || E.ie & REACTIVE_DISPOSED) return;
|
|
111
116
|
try {
|
|
112
|
-
E.
|
|
117
|
+
E.He = false;
|
|
113
118
|
recompute(E);
|
|
114
119
|
} finally {}
|
|
115
120
|
};
|
|
116
121
|
const E = computed(() => {
|
|
117
|
-
const e = E.
|
|
118
|
-
E.
|
|
122
|
+
const e = E.Gt;
|
|
123
|
+
E.Gt = undefined;
|
|
119
124
|
e?.();
|
|
120
125
|
const f = staleValues(t);
|
|
121
|
-
E.
|
|
126
|
+
E.Gt = f;
|
|
122
127
|
}, {
|
|
123
128
|
...e,
|
|
124
129
|
lazy: true
|
|
125
130
|
});
|
|
126
|
-
E.
|
|
131
|
+
E.Gt = undefined;
|
|
127
132
|
E.T = E.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
128
|
-
E.
|
|
133
|
+
E.He = true;
|
|
129
134
|
E.ge = EFFECT_TRACKED;
|
|
130
135
|
// Status dispatch rides the SHARED notifier (statusNotifierOf keys off
|
|
131
136
|
// _type): its error arm is behavior-identical to the closure that used to
|
|
132
137
|
// live here, without the per-node NodeExtension allocation.
|
|
133
|
-
E.
|
|
134
|
-
|
|
138
|
+
E.Ve = run;
|
|
139
|
+
// The first run rides the heap like every wake (GlobalQueue._update), so a
|
|
140
|
+
// tracked effect created inside a render-effect callback runs after that
|
|
141
|
+
// pass's staged writes commit, not before.
|
|
142
|
+
enqueueSub(E);
|
|
143
|
+
schedule();
|
|
135
144
|
}
|
|
136
145
|
|
|
137
146
|
// Install the shared effect status notifier (statusNotifierOf serves it to
|
|
@@ -64,8 +64,8 @@ function externalUntrack(e) {
|
|
|
64
64
|
// removed on reset) so core's null checks stay equivalent to the old
|
|
65
65
|
// `externalSourceConfig` truthiness checks.
|
|
66
66
|
function syncExternalHooks() {
|
|
67
|
-
GlobalQueue.
|
|
68
|
-
GlobalQueue.
|
|
67
|
+
GlobalQueue.Ft = externalSourceConfig ? wireExternalSource : null;
|
|
68
|
+
GlobalQueue.gt = externalSourceConfig ? externalUntrack : null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
package/dist/prod/core/graph.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
|
|
1
|
+
import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, CONFIG_SLOT_NODE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
|
|
2
|
+
|
|
3
|
+
import { slotUnobservedHook } from "./core.js";
|
|
2
4
|
|
|
3
5
|
import { deleteFromHeap, queueFor } from "./heap.js";
|
|
4
6
|
|
|
@@ -8,15 +10,17 @@ import { bumpNotifyEpoch } from "./scheduler.js";
|
|
|
8
10
|
|
|
9
11
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
10
12
|
function unlinkSubs(e) {
|
|
11
|
-
const n = e.
|
|
12
|
-
const l = e.
|
|
13
|
+
const n = e.st;
|
|
14
|
+
const l = e.ot;
|
|
13
15
|
const o = e.ae;
|
|
14
|
-
const
|
|
15
|
-
if (o !== null) o.en =
|
|
16
|
-
if (
|
|
16
|
+
const s = e.en;
|
|
17
|
+
if (o !== null) o.en = s; else n.ft = s;
|
|
18
|
+
if (s !== null) s.ae = o; else {
|
|
17
19
|
n.u = o;
|
|
18
20
|
if (o === null) {
|
|
19
|
-
|
|
21
|
+
// Slot nodes (store leaves) dispatch to the ONE shared hook — no
|
|
22
|
+
// per-node unobserved closure, no NodeExtension to hold it.
|
|
23
|
+
if (n.T & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.Nt?.();
|
|
20
24
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
21
25
|
// A pending node is exempt: its in-flight async work (or the
|
|
22
26
|
// transition holding it) is an observer — tearing down would orphan
|
|
@@ -31,13 +35,13 @@ function unlinkSubs(e) {
|
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
function trimStaleDeps(e) {
|
|
34
|
-
const n = e.
|
|
35
|
-
let l = n !== null ? n.
|
|
38
|
+
const n = e.Be;
|
|
39
|
+
let l = n !== null ? n.ot : e.lt;
|
|
36
40
|
if (l !== null) {
|
|
37
41
|
do {
|
|
38
42
|
l = unlinkSubs(l);
|
|
39
43
|
} while (l !== null);
|
|
40
|
-
if (n !== null) n.
|
|
44
|
+
if (n !== null) n.ot = null; else e.lt = null;
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -46,13 +50,13 @@ function trimStaleDeps(e) {
|
|
|
46
50
|
// and skipping early also avoids adding one (hidden-class churn) via the
|
|
47
51
|
// null-out below.
|
|
48
52
|
function clearDeps(e) {
|
|
49
|
-
let n = e.
|
|
53
|
+
let n = e.lt;
|
|
50
54
|
if (!n) return;
|
|
51
55
|
do {
|
|
52
56
|
n = unlinkSubs(n);
|
|
53
57
|
} while (n !== null);
|
|
54
|
-
e.
|
|
55
|
-
e.
|
|
58
|
+
e.lt = null;
|
|
59
|
+
e.Be = null;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
function unobserved(e) {
|
|
@@ -104,20 +108,20 @@ function link(e, n, l = false) {
|
|
|
104
108
|
// not relabel the value dependency as probe-only — the value read is what
|
|
105
109
|
// real-error propagation and affects() coverage key off, regardless of
|
|
106
110
|
// read order within the computation.
|
|
107
|
-
const o = n.
|
|
108
|
-
if (o !== null && o.
|
|
111
|
+
const o = n.Be;
|
|
112
|
+
if (o !== null && o.st === e) {
|
|
109
113
|
o.ve &&= l;
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
|
-
let
|
|
116
|
+
let s = null;
|
|
113
117
|
const t = n.ie & REACTIVE_RECOMPUTING_DEPS;
|
|
114
118
|
if (t) {
|
|
115
|
-
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
n.
|
|
119
|
+
s = o !== null ? o.ot : n.lt;
|
|
120
|
+
if (s !== null && s.st === e) {
|
|
121
|
+
s.vt = n.ze;
|
|
122
|
+
n.Be = s;
|
|
119
123
|
// First touch of this pass: the previous pass's label is stale.
|
|
120
|
-
|
|
124
|
+
s.ve = l;
|
|
121
125
|
return;
|
|
122
126
|
}
|
|
123
127
|
}
|
|
@@ -126,24 +130,24 @@ function link(e, n, l = false) {
|
|
|
126
130
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
127
131
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
128
132
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
133
|
+
const r = e.ft;
|
|
134
|
+
if (r !== null && r.ce === n && (!t || r.vt === n.ze)) {
|
|
131
135
|
// Gen-matched during a recompute = repeat touch this pass (AND); outside
|
|
132
136
|
// a recompute there is no pass boundary, so the latest read labels it.
|
|
133
|
-
if (t)
|
|
137
|
+
if (t) r.ve &&= l; else r.ve = l;
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
136
|
-
const
|
|
137
|
-
|
|
140
|
+
const u = n.Be = e.ft = {
|
|
141
|
+
st: e,
|
|
138
142
|
ce: n,
|
|
139
|
-
|
|
140
|
-
en:
|
|
143
|
+
ot: s,
|
|
144
|
+
en: r,
|
|
141
145
|
ae: null,
|
|
142
|
-
|
|
146
|
+
vt: n.ze,
|
|
143
147
|
ve: l
|
|
144
148
|
};
|
|
145
|
-
if (o !== null) o.
|
|
146
|
-
if (
|
|
149
|
+
if (o !== null) o.ot = u; else n.lt = u;
|
|
150
|
+
if (r !== null) r.ae = u; else e.u = u;
|
|
147
151
|
// New subscriber edge: staged-rewrite skips (§12d) must not miss it.
|
|
148
152
|
bumpNotifyEpoch();
|
|
149
153
|
}
|
package/dist/prod/core/heap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./core.js";
|
|
2
2
|
|
|
3
|
-
import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT,
|
|
3
|
+
import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS, REACTIVE_MANUAL_WRITE, REACTIVE_CHECK, REACTIVE_DIRTY, CONFIG_FW_CHILDREN } from "./constants.js";
|
|
4
4
|
|
|
5
5
|
import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
6
6
|
|
|
@@ -9,35 +9,29 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Schedule one subscriber to re-run on the next flush:
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Schedule one subscriber to re-run on the next flush: inserted into its own
|
|
13
|
+
* (zombie-flag-routed) heap with the `_min` cursor pulled down. Tracked
|
|
14
|
+
* effects ride the heap too — the heap visit is their (empty) compute phase,
|
|
15
|
+
* which hands the callback to the user queue once the pass has committed
|
|
16
|
+
* (see GlobalQueue._update, #3291).
|
|
15
17
|
*/ function enqueueSub(e) {
|
|
16
|
-
if (e.ge === EFFECT_TRACKED) {
|
|
17
|
-
const E = e;
|
|
18
|
-
if (!E.tt) {
|
|
19
|
-
E.tt = true;
|
|
20
|
-
E.C.enqueue(EFFECT_USER, E.yt);
|
|
21
|
-
}
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
18
|
const E = queueFor(e);
|
|
25
|
-
if (E.
|
|
19
|
+
if (E.Me > e.qe) E.Me = e.qe;
|
|
26
20
|
insertIntoHeap(e, E);
|
|
27
21
|
}
|
|
28
22
|
|
|
29
23
|
function actualInsertIntoHeap(e, E) {
|
|
30
|
-
const t = (e.
|
|
31
|
-
if (t >= e.
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const E =
|
|
36
|
-
E.
|
|
24
|
+
const t = (e.Le?.Dt ? e.Le.Pt?.qe : e.Le?.qe) ?? -1;
|
|
25
|
+
if (t >= e.qe) e.qe = t + 1;
|
|
26
|
+
const I = e.qe;
|
|
27
|
+
const n = E.eE[I];
|
|
28
|
+
if (n === undefined) E.eE[I] = e; else {
|
|
29
|
+
const E = n.ct;
|
|
30
|
+
E._t = e;
|
|
37
31
|
e.ct = E;
|
|
38
|
-
|
|
32
|
+
n.ct = e;
|
|
39
33
|
}
|
|
40
|
-
if (
|
|
34
|
+
if (I > E.EE) E.EE = I;
|
|
41
35
|
}
|
|
42
36
|
|
|
43
37
|
function insertIntoHeap(e, E) {
|
|
@@ -71,23 +65,23 @@ function deleteFromHeap(e, E) {
|
|
|
71
65
|
const t = e.ie;
|
|
72
66
|
if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
73
67
|
e.ie = t & -25;
|
|
74
|
-
const
|
|
75
|
-
if (e.ct === e) E.eE[
|
|
76
|
-
const t = e.
|
|
77
|
-
const
|
|
78
|
-
const o = t ??
|
|
79
|
-
if (e ===
|
|
68
|
+
const I = e.qe;
|
|
69
|
+
if (e.ct === e) E.eE[I] = undefined; else {
|
|
70
|
+
const t = e._t;
|
|
71
|
+
const n = E.eE[I];
|
|
72
|
+
const o = t ?? n;
|
|
73
|
+
if (e === n) E.eE[I] = t; else e.ct._t = t;
|
|
80
74
|
o.ct = e.ct;
|
|
81
75
|
}
|
|
82
76
|
e.ct = e;
|
|
83
|
-
e.
|
|
77
|
+
e._t = undefined;
|
|
84
78
|
}
|
|
85
79
|
|
|
86
80
|
function markHeap(e) {
|
|
87
81
|
if (e.tE) return;
|
|
88
82
|
e.tE = true;
|
|
89
83
|
for (let E = 0; E <= e.EE; E++) {
|
|
90
|
-
for (let t = e.eE[E]; t !== undefined; t = t.
|
|
84
|
+
for (let t = e.eE[E]; t !== undefined; t = t._t) {
|
|
91
85
|
if (t.ie & REACTIVE_IN_HEAP) markNode(t);
|
|
92
86
|
}
|
|
93
87
|
}
|
|
@@ -114,11 +108,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
|
|
|
114
108
|
|
|
115
109
|
function runHeap(e, E) {
|
|
116
110
|
e.tE = false;
|
|
117
|
-
for (e.
|
|
118
|
-
let t = e.eE[e.
|
|
111
|
+
for (e.Me = 0; e.Me <= e.EE; e.Me++) {
|
|
112
|
+
let t = e.eE[e.Me];
|
|
119
113
|
while (t !== undefined) {
|
|
120
114
|
if (t.ie & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
|
|
121
|
-
t = e.eE[e.
|
|
115
|
+
t = e.eE[e.Me];
|
|
122
116
|
}
|
|
123
117
|
}
|
|
124
118
|
e.EE = 0;
|
|
@@ -126,14 +120,14 @@ function runHeap(e, E) {
|
|
|
126
120
|
|
|
127
121
|
function adjustHeight(e, E) {
|
|
128
122
|
deleteFromHeap(e, E);
|
|
129
|
-
let t = e.
|
|
130
|
-
for (let E = e.
|
|
131
|
-
const e = E.
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
123
|
+
let t = e.qe;
|
|
124
|
+
for (let E = e.lt; E; E = E.ot) {
|
|
125
|
+
const e = E.st;
|
|
126
|
+
const I = e.rt || e;
|
|
127
|
+
if (I.oe && I.qe >= t) t = I.qe + 1;
|
|
134
128
|
}
|
|
135
|
-
if (e.
|
|
136
|
-
e.
|
|
129
|
+
if (e.qe !== t) {
|
|
130
|
+
e.qe = t;
|
|
137
131
|
for (let E = e.u; E !== null; E = E.ae) {
|
|
138
132
|
// Route each subscriber by its own zombie flag, mirroring the
|
|
139
133
|
// post-recompute height-adjust path. Inserting into the running `heap`
|
package/dist/prod/core/lanes.js
CHANGED
|
@@ -20,9 +20,9 @@ const activeLanes = new Set;
|
|
|
20
20
|
}
|
|
21
21
|
// Detect parent lane: _parentSource chains from pendingSignal → pendingValueComputed → original.
|
|
22
22
|
// The child lane should not merge with the parent lane.
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const r =
|
|
23
|
+
const t = n.o?.St;
|
|
24
|
+
const i = t?.o?.$e;
|
|
25
|
+
const r = i ? findLane(i) : null;
|
|
26
26
|
e = {
|
|
27
27
|
nn: n,
|
|
28
28
|
Oe: new Set,
|
|
@@ -46,12 +46,12 @@ const activeLanes = new Set;
|
|
|
46
46
|
|
|
47
47
|
function adoptCompanionLane(n, e) {
|
|
48
48
|
if (!n) return;
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
49
|
+
const t = signalLanes.get(n);
|
|
50
|
+
if (!t) return;
|
|
51
|
+
const i = findLane(t);
|
|
52
52
|
// Only the companion's own unmerged root is safely re-parentable: a root
|
|
53
53
|
// that absorbed other lanes carries work that is not a child of this owner.
|
|
54
|
-
if (
|
|
54
|
+
if (i !== e && i.nn === n && !i.an) i.an = e;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -61,6 +61,20 @@ function adoptCompanionLane(n, e) {
|
|
|
61
61
|
return n;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Is the lane held? `_pendingAsync` records the async the lane OWNS (derived
|
|
66
|
+
* under it); the transaction's reporter map records the async a render effect
|
|
67
|
+
* OBSERVED pending with no boundary taking it (INV-3, the one registration
|
|
68
|
+
* site). A hold needs both — the same rule the transaction itself uses, so a
|
|
69
|
+
* memo nobody renders, or one a fallback-showing boundary caught, cannot tear
|
|
70
|
+
* a frame and holds nothing (#3289). An orphan lane has no observation record
|
|
71
|
+
* and never holds.
|
|
72
|
+
*/ function laneHeld(n) {
|
|
73
|
+
const e = n.Ae;
|
|
74
|
+
if (e) for (const t of n.Oe) if (currentTransition(e)._e.has(t)) return true;
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
64
78
|
/**
|
|
65
79
|
* Merge two lanes when their dependency graphs overlap.
|
|
66
80
|
*/ function mergeLanes(n, e) {
|
|
@@ -71,7 +85,7 @@ function adoptCompanionLane(n, e) {
|
|
|
71
85
|
// Move (not copy) the merged lane's work: after the merge all routing goes
|
|
72
86
|
// through findLane() to the root, so anything left behind here is dead —
|
|
73
87
|
// and anything *added* here later is a routing bug (INV-5).
|
|
74
|
-
for (const
|
|
88
|
+
for (const t of e.Oe) n.Oe.add(t);
|
|
75
89
|
e.Oe.clear();
|
|
76
90
|
n.tn[0].push(...e.tn[0]);
|
|
77
91
|
n.tn[1].push(...e.tn[1]);
|
|
@@ -83,11 +97,11 @@ function adoptCompanionLane(n, e) {
|
|
|
83
97
|
/**
|
|
84
98
|
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
85
99
|
*/ function resolveLane(n) {
|
|
86
|
-
const e = n.o
|
|
100
|
+
const e = n.o?.$e;
|
|
87
101
|
if (!e) return undefined;
|
|
88
|
-
const
|
|
89
|
-
if (activeLanes.has(
|
|
90
|
-
if (n.o !== null) n.o
|
|
102
|
+
const t = findLane(e);
|
|
103
|
+
if (activeLanes.has(t)) return t;
|
|
104
|
+
if (n.o !== null) n.o.$e = undefined;
|
|
91
105
|
return undefined;
|
|
92
106
|
}
|
|
93
107
|
|
|
@@ -97,10 +111,10 @@ function resolveTransition(n) {
|
|
|
97
111
|
// transactions (#2912) — the merged root's _transition would hand this
|
|
98
112
|
// node's override to whichever action wrote last through the shared
|
|
99
113
|
// reader. Chase merge chains; a dead owner settled through another path.
|
|
100
|
-
if (hasActiveOverride(n) && n.o?.
|
|
101
|
-
const e = ext(n).
|
|
114
|
+
if (hasActiveOverride(n) && n.o?.Tt) {
|
|
115
|
+
const e = ext(n).Tt = currentTransition(n.o?.Tt);
|
|
102
116
|
if (e.sn !== true) return e;
|
|
103
|
-
if (n.o !== null) n.o.
|
|
117
|
+
if (n.o !== null) n.o.Tt = null;
|
|
104
118
|
}
|
|
105
119
|
return resolveLane(n)?.Ae ?? n.Ae;
|
|
106
120
|
}
|
|
@@ -116,32 +130,32 @@ function resolveTransition(n) {
|
|
|
116
130
|
* Assign or merge a lane onto a node. At convergence points (node already has
|
|
117
131
|
* a different active lane), merge unless the node has an active override.
|
|
118
132
|
*/ function assignOrMergeLane(n, e) {
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
133
|
+
const t = findLane(e);
|
|
134
|
+
const i = n.o?.$e;
|
|
135
|
+
if (i) {
|
|
122
136
|
// If the subscriber's lane was merged into another lane, it's stale —
|
|
123
137
|
// replace it with the new source lane instead of following the merge chain
|
|
124
138
|
// (which would incorrectly merge the new lane into the old group)
|
|
125
|
-
if (
|
|
126
|
-
ext(n)
|
|
139
|
+
if (i.rn) {
|
|
140
|
+
ext(n).$e = e;
|
|
127
141
|
n.T |= CONFIG_HAS_LANE;
|
|
128
142
|
return;
|
|
129
143
|
}
|
|
130
|
-
const r = findLane(
|
|
144
|
+
const r = findLane(i);
|
|
131
145
|
if (activeLanes.has(r)) {
|
|
132
|
-
if (r !==
|
|
146
|
+
if (r !== t && !hasActiveOverride(n)) {
|
|
133
147
|
// Parent-child lanes stay independent so isPending resolves without
|
|
134
148
|
// waiting for the parent's async. The child keeps ownership.
|
|
135
|
-
if (
|
|
136
|
-
ext(n)
|
|
149
|
+
if (t.an && findLane(t.an) === r) {
|
|
150
|
+
ext(n).$e = e;
|
|
137
151
|
n.T |= CONFIG_HAS_LANE;
|
|
138
|
-
} else if (r.an && findLane(r.an) ===
|
|
152
|
+
} else if (r.an && findLane(r.an) === t) ; else mergeLanes(t, r);
|
|
139
153
|
}
|
|
140
154
|
return;
|
|
141
155
|
}
|
|
142
156
|
}
|
|
143
|
-
ext(n)
|
|
157
|
+
ext(n).$e = e;
|
|
144
158
|
n.T |= CONFIG_HAS_LANE;
|
|
145
159
|
}
|
|
146
160
|
|
|
147
|
-
export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane, resolveTransition, signalLanes };
|
|
161
|
+
export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, laneHeld, mergeLanes, resolveLane, resolveTransition, signalLanes };
|