@solidjs/signals 2.0.0-beta.21 → 2.0.0-beta.23
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 +210 -301
- package/dist/node.cjs +1106 -1196
- package/dist/prod/affects.js +71 -163
- package/dist/prod/boundaries.js +141 -137
- package/dist/prod/core/action.js +3 -3
- package/dist/prod/core/async.js +103 -103
- package/dist/prod/core/core.js +254 -297
- package/dist/prod/core/effect.js +46 -46
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +60 -47
- package/dist/prod/core/heap.js +50 -50
- package/dist/prod/core/lanes.js +34 -34
- package/dist/prod/core/optimistic.js +64 -106
- package/dist/prod/core/owner.js +52 -52
- package/dist/prod/core/scheduler.js +210 -211
- package/dist/prod/core/verdict.js +129 -78
- package/dist/prod/map.js +101 -101
- package/dist/prod/signals.js +23 -5
- package/dist/prod/store/optimistic.js +11 -11
- package/dist/prod/store/projection.js +2 -2
- package/dist/prod/store/store.js +14 -14
- package/dist/types/affects.d.ts +9 -9
- package/dist/types/core/async.d.ts +1 -1
- package/dist/types/core/error.d.ts +7 -0
- package/dist/types/core/scheduler.d.ts +1 -6
- package/dist/types/core/types.d.ts +6 -11
- package/dist/types-cjs/affects.d.cts +9 -9
- package/dist/types-cjs/core/async.d.cts +1 -1
- package/dist/types-cjs/core/error.d.cts +7 -0
- package/dist/types-cjs/core/scheduler.d.cts +1 -6
- package/dist/types-cjs/core/types.d.cts +6 -11
- package/package.json +1 -1
package/dist/prod/core/effect.js
CHANGED
|
@@ -14,16 +14,16 @@ import { GlobalQueue, haltReactivity } from "./scheduler.js";
|
|
|
14
14
|
const r = !!R?.user;
|
|
15
15
|
const f = createEffectNode(t, E, e, r ? EFFECT_USER : EFFECT_RENDER, notifyEffectStatus, R);
|
|
16
16
|
recompute(f, true);
|
|
17
|
-
!R?.defer && (f.
|
|
17
|
+
!R?.defer && (f.Ae === EFFECT_USER || R?.schedule ? f.C.enqueue(f.Ae, runEffect.bind(null, f)) : runEffect(f));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function notifyEffectStatus(t, E) {
|
|
21
21
|
// Use passed values if provided, otherwise read from node
|
|
22
|
-
const e = t !== undefined ? t : this.
|
|
23
|
-
const R = E !== undefined ? E : this.
|
|
22
|
+
const e = t !== undefined ? t : this.S;
|
|
23
|
+
const R = E !== undefined ? E : this._;
|
|
24
24
|
if (e & STATUS_ERROR) {
|
|
25
|
-
this.
|
|
26
|
-
if (this.
|
|
25
|
+
this.C.notify(this, STATUS_PENDING, 0);
|
|
26
|
+
if (this.Ae === EFFECT_USER) {
|
|
27
27
|
// The error handler is the error arm of the effect phase (#2840 ruling):
|
|
28
28
|
// queue it like the effect function. It runs in the same imperative,
|
|
29
29
|
// writable scope, throws escalate the same way, and a held transition
|
|
@@ -33,23 +33,23 @@ function notifyEffectStatus(t, E) {
|
|
|
33
33
|
// phase takes the success arm instead. Blocked forwards (explicit
|
|
34
34
|
// `status` arg without node-state writes) don't queue: the status
|
|
35
35
|
// re-propagates unblocked at commit.
|
|
36
|
-
if (this.
|
|
37
|
-
this
|
|
38
|
-
this.
|
|
36
|
+
if (this.S & STATUS_ERROR) {
|
|
37
|
+
this.$e = true;
|
|
38
|
+
this.C.enqueue(this.Ae, this.Be ??= runEffect.bind(null, this));
|
|
39
39
|
}
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
if (!this.
|
|
42
|
+
if (!this.C.notify(this, STATUS_ERROR, STATUS_ERROR)) {
|
|
43
43
|
haltReactivity(unwrapStatusError(R));
|
|
44
44
|
throw R;
|
|
45
45
|
}
|
|
46
|
-
} else if (this.
|
|
47
|
-
this.
|
|
46
|
+
} else if (this.Ae === EFFECT_RENDER) {
|
|
47
|
+
this.C.notify(this, STATUS_PENDING | STATUS_ERROR, e, R);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function runEffect(t) {
|
|
52
|
-
if (!t
|
|
52
|
+
if (!t.$e || t.se & REACTIVE_DISPOSED) return;
|
|
53
53
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
54
54
|
// the node's settled state at effect time runs the bundle's error handler in
|
|
55
55
|
// this same imperative, writable scope. Unwrap the StatusError used for
|
|
@@ -60,46 +60,46 @@ function runEffect(t) {
|
|
|
60
60
|
// Render effects bypass: their errors route to boundaries synchronously in
|
|
61
61
|
// notifyEffectStatus, and a runner queued by an earlier valueChanged in the
|
|
62
62
|
// same flush must not be hijacked by a later-arriving error status.
|
|
63
|
-
if (t.
|
|
64
|
-
const E = unwrapStatusError(t.
|
|
65
|
-
t.
|
|
66
|
-
t
|
|
63
|
+
if (t.S & STATUS_ERROR && t.Ae === EFFECT_USER) {
|
|
64
|
+
const E = unwrapStatusError(t._);
|
|
65
|
+
t.rt = t.Pe;
|
|
66
|
+
t.$e = false;
|
|
67
67
|
try {
|
|
68
|
-
t.
|
|
69
|
-
const E = t.
|
|
70
|
-
t.
|
|
68
|
+
t._t ? t._t(E, () => {
|
|
69
|
+
const E = t.Et;
|
|
70
|
+
t.Et = undefined;
|
|
71
71
|
E?.();
|
|
72
72
|
}) : console.error(E);
|
|
73
73
|
} catch (E) {
|
|
74
|
-
if (!t.
|
|
74
|
+
if (!t.C.notify(t, STATUS_ERROR, STATUS_ERROR)) {
|
|
75
75
|
haltReactivity(E);
|
|
76
76
|
throw E;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
const E = t.
|
|
82
|
-
t.
|
|
81
|
+
const E = t.Et;
|
|
82
|
+
t.Et = undefined;
|
|
83
83
|
try {
|
|
84
84
|
E?.();
|
|
85
|
-
const e = t.
|
|
85
|
+
const e = t.ct(t.Pe, t.rt);
|
|
86
86
|
if (false && e !== undefined && typeof e !== "function") ;
|
|
87
87
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
88
|
-
t.
|
|
88
|
+
t.Et = e;
|
|
89
89
|
} catch (E) {
|
|
90
|
-
t.
|
|
91
|
-
t.
|
|
92
|
-
if (!t.
|
|
90
|
+
t._ = new StatusError(t, E);
|
|
91
|
+
t.S |= STATUS_ERROR;
|
|
92
|
+
if (!t.C.notify(t, STATUS_ERROR, STATUS_ERROR)) {
|
|
93
93
|
haltReactivity(E);
|
|
94
94
|
throw E;
|
|
95
95
|
}
|
|
96
96
|
} finally {
|
|
97
|
-
t.
|
|
98
|
-
t
|
|
97
|
+
t.rt = t.Pe;
|
|
98
|
+
t.$e = false;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
GlobalQueue.
|
|
102
|
+
GlobalQueue.Je = runEffect;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
@@ -107,39 +107,39 @@ GlobalQueue.ut = runEffect;
|
|
|
107
107
|
* Uses stale reads.
|
|
108
108
|
*/ function trackedEffect(t, E) {
|
|
109
109
|
const run = () => {
|
|
110
|
-
if (!e
|
|
110
|
+
if (!e.$e || e.se & REACTIVE_DISPOSED) return;
|
|
111
111
|
try {
|
|
112
|
-
e
|
|
112
|
+
e.$e = false;
|
|
113
113
|
recompute(e);
|
|
114
114
|
} finally {}
|
|
115
115
|
};
|
|
116
116
|
const e = computed(() => {
|
|
117
|
-
const E = e.
|
|
118
|
-
e.
|
|
117
|
+
const E = e.Et;
|
|
118
|
+
e.Et = undefined;
|
|
119
119
|
E?.();
|
|
120
120
|
const R = staleValues(t);
|
|
121
|
-
e.
|
|
121
|
+
e.Et = R;
|
|
122
122
|
}, {
|
|
123
123
|
...E,
|
|
124
124
|
lazy: true
|
|
125
125
|
});
|
|
126
|
-
e.
|
|
127
|
-
e.
|
|
128
|
-
e
|
|
129
|
-
e.
|
|
130
|
-
e.
|
|
131
|
-
const R = t !== undefined ? t : e.
|
|
126
|
+
e.Et = undefined;
|
|
127
|
+
e.T = e.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
128
|
+
e.$e = true;
|
|
129
|
+
e.Ae = EFFECT_TRACKED;
|
|
130
|
+
e.i = (t, E) => {
|
|
131
|
+
const R = t !== undefined ? t : e.S;
|
|
132
132
|
if (R & STATUS_ERROR) {
|
|
133
|
-
e.
|
|
134
|
-
const t = E !== undefined ? E : e.
|
|
135
|
-
if (!e.
|
|
133
|
+
e.C.notify(e, STATUS_PENDING, 0);
|
|
134
|
+
const t = E !== undefined ? E : e._;
|
|
135
|
+
if (!e.C.notify(e, STATUS_ERROR, STATUS_ERROR)) {
|
|
136
136
|
haltReactivity(unwrapStatusError(t));
|
|
137
137
|
throw t;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
|
-
e.
|
|
142
|
-
e.
|
|
141
|
+
e.ht = run;
|
|
142
|
+
e.C.enqueue(EFFECT_USER, run);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
export { effect, trackedEffect };
|
|
@@ -46,11 +46,11 @@ function wireExternalSource(e) {
|
|
|
46
46
|
equals: false,
|
|
47
47
|
ownedWrite: true
|
|
48
48
|
});
|
|
49
|
-
const r = externalSourceConfig.factory(e.
|
|
49
|
+
const r = externalSourceConfig.factory(e.ke, () => {
|
|
50
50
|
setSignal(n, undefined);
|
|
51
51
|
});
|
|
52
52
|
cleanup(() => r.dispose());
|
|
53
|
-
e.
|
|
53
|
+
e.ke = e => {
|
|
54
54
|
read(n);
|
|
55
55
|
return r.track(e);
|
|
56
56
|
};
|
|
@@ -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.Tt = externalSourceConfig ? wireExternalSource : null;
|
|
68
|
+
GlobalQueue.It = externalSourceConfig ? externalUntrack : null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
package/dist/prod/core/graph.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
|
|
1
|
+
import { CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, STATUS_PENDING, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
|
|
2
2
|
|
|
3
3
|
import { deleteFromHeap, queueFor } from "./heap.js";
|
|
4
4
|
|
|
@@ -7,61 +7,72 @@ import { disposeChildren } from "./owner.js";
|
|
|
7
7
|
import "./scheduler.js";
|
|
8
8
|
|
|
9
9
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
10
|
-
function unlinkSubs(
|
|
11
|
-
const
|
|
12
|
-
const e =
|
|
13
|
-
const u =
|
|
14
|
-
const s =
|
|
15
|
-
if (u !== null) u.
|
|
16
|
-
if (s !== null) s.
|
|
17
|
-
|
|
10
|
+
function unlinkSubs(l) {
|
|
11
|
+
const n = l.tt;
|
|
12
|
+
const e = l.et;
|
|
13
|
+
const u = l.ue;
|
|
14
|
+
const s = l.ll;
|
|
15
|
+
if (u !== null) u.ll = s; else n.ot = s;
|
|
16
|
+
if (s !== null) s.ue = u; else {
|
|
17
|
+
n.o = u;
|
|
18
18
|
if (u === null) {
|
|
19
|
-
|
|
19
|
+
n.it?.();
|
|
20
20
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// A pending node is exempt: its in-flight async work (or the
|
|
22
|
+
// transition holding it) is an observer — tearing down would orphan
|
|
23
|
+
// the work and re-execute it on the next read. The settle path runs
|
|
24
|
+
// this same last-one-out check when that observer releases (the
|
|
25
|
+
// untracked-read dispose in core.ts guards on pending identically).
|
|
26
|
+
const l = n;
|
|
27
|
+
l.ke && l.T & CONFIG_AUTO_DISPOSE && !(l.se & REACTIVE_ZOMBIE) && !(l.S & STATUS_PENDING) && unobserved(l);
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
return e;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
function trimStaleDeps(
|
|
29
|
-
const
|
|
30
|
-
let e =
|
|
33
|
+
function trimStaleDeps(l) {
|
|
34
|
+
const n = l.qe;
|
|
35
|
+
let e = n !== null ? n.et : l.Xe;
|
|
31
36
|
if (e !== null) {
|
|
32
37
|
do {
|
|
33
38
|
e = unlinkSubs(e);
|
|
34
39
|
} while (e !== null);
|
|
35
|
-
if (
|
|
40
|
+
if (n !== null) n.et = null; else l.Xe = null;
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
function unobserved(
|
|
40
|
-
deleteFromHeap(
|
|
41
|
-
let
|
|
42
|
-
while (
|
|
43
|
-
|
|
44
|
+
function unobserved(l) {
|
|
45
|
+
deleteFromHeap(l, queueFor(l));
|
|
46
|
+
let n = l.Xe;
|
|
47
|
+
while (n !== null) {
|
|
48
|
+
n = unlinkSubs(n);
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
disposeChildren(
|
|
50
|
+
l.Xe = null;
|
|
51
|
+
l.qe = null;
|
|
52
|
+
disposeChildren(l, true);
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L52
|
|
51
|
-
function link(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
function link(l, n, e = false) {
|
|
57
|
+
// Repeat touches within one pass AND-combine `_pendingObserver`: a probe
|
|
58
|
+
// read (`isPending(() => x())`) beside a value read of the same dep must
|
|
59
|
+
// not relabel the value dependency as probe-only — the value read is what
|
|
60
|
+
// real-error propagation and affects() coverage key off, regardless of
|
|
61
|
+
// read order within the computation.
|
|
62
|
+
const u = n.qe;
|
|
63
|
+
if (u !== null && u.tt === l) {
|
|
64
|
+
u.De &&= e;
|
|
55
65
|
return;
|
|
56
66
|
}
|
|
57
67
|
let s = null;
|
|
58
|
-
const t =
|
|
68
|
+
const t = n.se & REACTIVE_RECOMPUTING_DEPS;
|
|
59
69
|
if (t) {
|
|
60
|
-
s = u !== null ? u.
|
|
61
|
-
if (s !== null && s.
|
|
62
|
-
s.
|
|
63
|
-
|
|
64
|
-
s
|
|
70
|
+
s = u !== null ? u.et : n.Xe;
|
|
71
|
+
if (s !== null && s.tt === l) {
|
|
72
|
+
s.nl = n.Ye;
|
|
73
|
+
n.qe = s;
|
|
74
|
+
// First touch of this pass: the previous pass's label is stale.
|
|
75
|
+
s.De = e;
|
|
65
76
|
return;
|
|
66
77
|
}
|
|
67
78
|
}
|
|
@@ -70,22 +81,24 @@ function link(n, l, e = false) {
|
|
|
70
81
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
71
82
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
72
83
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
73
|
-
const i =
|
|
74
|
-
if (i !== null && i.
|
|
75
|
-
|
|
84
|
+
const i = l.ot;
|
|
85
|
+
if (i !== null && i.le === n && (!t || i.nl === n.Ye)) {
|
|
86
|
+
// Gen-matched during a recompute = repeat touch this pass (AND); outside
|
|
87
|
+
// a recompute there is no pass boundary, so the latest read labels it.
|
|
88
|
+
if (t) i.De &&= e; else i.De = e;
|
|
76
89
|
return;
|
|
77
90
|
}
|
|
78
|
-
const o =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
const o = n.qe = l.ot = {
|
|
92
|
+
tt: l,
|
|
93
|
+
le: n,
|
|
94
|
+
et: s,
|
|
95
|
+
ll: i,
|
|
96
|
+
ue: null,
|
|
97
|
+
nl: n.Ye,
|
|
98
|
+
De: e
|
|
86
99
|
};
|
|
87
|
-
if (u !== null) u.
|
|
88
|
-
if (i !== null) i.
|
|
100
|
+
if (u !== null) u.et = o; else n.Xe = o;
|
|
101
|
+
if (i !== null) i.ue = o; else l.o = o;
|
|
89
102
|
}
|
|
90
103
|
|
|
91
104
|
export { link, trimStaleDeps, unlinkSubs, unobserved };
|
package/dist/prod/core/heap.js
CHANGED
|
@@ -3,7 +3,7 @@ import { REACTIVE_IN_HEAP, EFFECT_TRACKED, EFFECT_USER, REACTIVE_IN_HEAP_HEIGHT,
|
|
|
3
3
|
import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
4
4
|
|
|
5
5
|
/** The queue a node belongs to, picked from its own zombie flag. */ function queueFor(e) {
|
|
6
|
-
return e.
|
|
6
|
+
return e.se & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -11,40 +11,40 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
|
11
11
|
* the heap and go directly to their effect queue; everything else is inserted
|
|
12
12
|
* into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
|
|
13
13
|
*/ function enqueueSub(e) {
|
|
14
|
-
if (e.
|
|
14
|
+
if (e.Ae === EFFECT_TRACKED) {
|
|
15
15
|
const E = e;
|
|
16
|
-
if (!E
|
|
17
|
-
E
|
|
18
|
-
E.
|
|
16
|
+
if (!E.$e) {
|
|
17
|
+
E.$e = true;
|
|
18
|
+
E.C.enqueue(EFFECT_USER, E.ht);
|
|
19
19
|
}
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
const E = queueFor(e);
|
|
23
|
-
if (E.
|
|
23
|
+
if (E.Fe > e.He) E.Fe = e.He;
|
|
24
24
|
insertIntoHeap(e, E);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function actualInsertIntoHeap(e, E) {
|
|
28
|
-
const t = (e.
|
|
29
|
-
if (t >= e.
|
|
30
|
-
const n = e.
|
|
28
|
+
const t = (e.Ge?.ft ? e.Ge.Nt?.He : e.Ge?.He) ?? -1;
|
|
29
|
+
if (t >= e.He) e.He = t + 1;
|
|
30
|
+
const n = e.He;
|
|
31
31
|
const I = E.eE[n];
|
|
32
32
|
if (I === undefined) E.eE[n] = e; else {
|
|
33
|
-
const E = I.
|
|
34
|
-
E.
|
|
35
|
-
e.
|
|
36
|
-
I.
|
|
33
|
+
const E = I.ut;
|
|
34
|
+
E.lt = e;
|
|
35
|
+
e.ut = E;
|
|
36
|
+
I.ut = e;
|
|
37
37
|
}
|
|
38
38
|
if (n > E.EE) E.EE = n;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function insertIntoHeap(e, E) {
|
|
42
|
-
let t = e.
|
|
42
|
+
let t = e.se;
|
|
43
43
|
if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
|
|
44
44
|
if (t & REACTIVE_CHECK) {
|
|
45
|
-
e.
|
|
45
|
+
e.se = t & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
46
46
|
} else {
|
|
47
|
-
e.
|
|
47
|
+
e.se = t | REACTIVE_IN_HEAP;
|
|
48
48
|
// An unmarked node entering a marked heap invalidates the markHeap memo:
|
|
49
49
|
// `_marked` is only reset by runHeap, so a write between two mid-tick
|
|
50
50
|
// pulls (read-time markHeap + updateIfNecessary) would otherwise leave
|
|
@@ -56,49 +56,49 @@ function insertIntoHeap(e, E) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function insertIntoHeapHeight(e, E) {
|
|
59
|
-
let t = e.
|
|
59
|
+
let t = e.se;
|
|
60
60
|
if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)) return;
|
|
61
|
-
e.
|
|
61
|
+
e.se = t | REACTIVE_IN_HEAP_HEIGHT;
|
|
62
62
|
actualInsertIntoHeap(e, E);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function deleteFromHeap(e, E) {
|
|
66
|
-
const t = e.
|
|
66
|
+
const t = e.se;
|
|
67
67
|
if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
68
|
-
e.
|
|
69
|
-
const n = e.
|
|
70
|
-
if (e.
|
|
71
|
-
const t = e.
|
|
68
|
+
e.se = t & -25;
|
|
69
|
+
const n = e.He;
|
|
70
|
+
if (e.ut === e) E.eE[n] = undefined; else {
|
|
71
|
+
const t = e.lt;
|
|
72
72
|
const I = E.eE[n];
|
|
73
73
|
const o = t ?? I;
|
|
74
|
-
if (e === I) E.eE[n] = t; else e.
|
|
75
|
-
o.
|
|
74
|
+
if (e === I) E.eE[n] = t; else e.ut.lt = t;
|
|
75
|
+
o.ut = e.ut;
|
|
76
76
|
}
|
|
77
|
-
e.
|
|
78
|
-
e.
|
|
77
|
+
e.ut = e;
|
|
78
|
+
e.lt = undefined;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function markHeap(e) {
|
|
82
82
|
if (e.tE) return;
|
|
83
83
|
e.tE = true;
|
|
84
84
|
for (let E = 0; E <= e.EE; E++) {
|
|
85
|
-
for (let t = e.eE[E]; t !== undefined; t = t.
|
|
86
|
-
if (t.
|
|
85
|
+
for (let t = e.eE[E]; t !== undefined; t = t.lt) {
|
|
86
|
+
if (t.se & REACTIVE_IN_HEAP) markNode(t);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function markNode(e, E = REACTIVE_DIRTY) {
|
|
92
|
-
const t = e.
|
|
92
|
+
const t = e.se;
|
|
93
93
|
if ((t & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= E) return;
|
|
94
|
-
e.
|
|
95
|
-
for (let E = e.
|
|
96
|
-
markNode(E.
|
|
94
|
+
e.se = t & -4 | E;
|
|
95
|
+
for (let E = e.o; E !== null; E = E.ue) {
|
|
96
|
+
markNode(E.le, REACTIVE_CHECK);
|
|
97
97
|
}
|
|
98
|
-
if (e.
|
|
99
|
-
for (let E = e.
|
|
100
|
-
for (let e = E.
|
|
101
|
-
markNode(e.
|
|
98
|
+
if (e.u !== null) {
|
|
99
|
+
for (let E = e.u; E !== null; E = E.fe) {
|
|
100
|
+
for (let e = E.o; e !== null; e = e.ue) {
|
|
101
|
+
markNode(e.le, REACTIVE_CHECK);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -106,11 +106,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
|
|
|
106
106
|
|
|
107
107
|
function runHeap(e, E) {
|
|
108
108
|
e.tE = false;
|
|
109
|
-
for (e.
|
|
110
|
-
let t = e.eE[e.
|
|
109
|
+
for (e.Fe = 0; e.Fe <= e.EE; e.Fe++) {
|
|
110
|
+
let t = e.eE[e.Fe];
|
|
111
111
|
while (t !== undefined) {
|
|
112
|
-
if (t.
|
|
113
|
-
t = e.eE[e.
|
|
112
|
+
if (t.se & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
|
|
113
|
+
t = e.eE[e.Fe];
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
e.EE = 0;
|
|
@@ -118,21 +118,21 @@ function runHeap(e, E) {
|
|
|
118
118
|
|
|
119
119
|
function adjustHeight(e, E) {
|
|
120
120
|
deleteFromHeap(e, E);
|
|
121
|
-
let t = e.
|
|
122
|
-
for (let E = e.
|
|
123
|
-
const e = E.
|
|
124
|
-
const n = e.
|
|
125
|
-
if (n.
|
|
121
|
+
let t = e.He;
|
|
122
|
+
for (let E = e.Xe; E; E = E.et) {
|
|
123
|
+
const e = E.tt;
|
|
124
|
+
const n = e.nt || e;
|
|
125
|
+
if (n.ke && n.He >= t) t = n.He + 1;
|
|
126
126
|
}
|
|
127
|
-
if (e.
|
|
128
|
-
e.
|
|
129
|
-
for (let E = e.
|
|
127
|
+
if (e.He !== t) {
|
|
128
|
+
e.He = t;
|
|
129
|
+
for (let E = e.o; E !== null; E = E.ue) {
|
|
130
130
|
// Route each subscriber by its own zombie flag, mirroring the
|
|
131
131
|
// post-recompute height-adjust path. Inserting into the running `heap`
|
|
132
132
|
// unconditionally can park a zombie in `dirtyQueue` (or a live node in
|
|
133
133
|
// `zombieQueue`), breaking the flag/queue invariant `deleteFromHeap`
|
|
134
134
|
// relies on — the same corruption class as #2759.
|
|
135
|
-
insertIntoHeapHeight(E.
|
|
135
|
+
insertIntoHeapHeight(E.le, queueFor(E.le));
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|