@solidjs/signals 2.0.0-rc.4 → 2.0.0-rc.6
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 +1618 -232
- package/dist/node.cjs +2262 -1199
- package/dist/prod/boundaries.js +4 -1
- package/dist/prod/core/async.js +152 -101
- package/dist/prod/core/constants.js +55 -1
- package/dist/prod/core/core.js +305 -234
- package/dist/prod/core/effect.js +28 -28
- package/dist/prod/core/error.js +13 -1
- package/dist/prod/core/external.js +2 -2
- package/dist/prod/core/graph.js +27 -27
- package/dist/prod/core/heap.js +30 -30
- package/dist/prod/core/lanes.js +32 -32
- package/dist/prod/core/optimistic.js +57 -57
- package/dist/prod/core/owner.js +34 -34
- package/dist/prod/core/scheduler.js +346 -152
- package/dist/prod/core/verdict.js +122 -65
- package/dist/prod/index.js +3 -3
- package/dist/prod/map.js +106 -106
- package/dist/prod/signals.js +321 -26
- package/dist/prod/store/next/optimistic.js +363 -151
- package/dist/prod/store/next/patch.js +6 -6
- package/dist/prod/store/next/projection.js +25 -21
- package/dist/prod/store/next/store.js +223 -113
- package/dist/prod/store/store.js +2 -2
- package/dist/types/core/async.d.ts +2 -0
- package/dist/types/core/attribution-hooks.d.ts +11 -0
- package/dist/types/core/attribution.d.ts +57 -4
- package/dist/types/core/constants.d.ts +54 -0
- package/dist/types/core/core.d.ts +19 -20
- package/dist/types/core/dev.d.ts +8 -2
- package/dist/types/core/error.d.ts +9 -0
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/scheduler.d.ts +39 -0
- package/dist/types/core/types.d.ts +12 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/signals.d.ts +108 -11
- package/dist/types/store/next/optimistic.d.ts +13 -10
- package/dist/types/store/next/projection.d.ts +1 -1
- package/dist/types/store/next/store.d.ts +22 -0
- package/dist/types/store/next/target.d.ts +25 -0
- package/dist/types-cjs/core/async.d.cts +2 -0
- package/dist/types-cjs/core/attribution-hooks.d.cts +11 -0
- package/dist/types-cjs/core/attribution.d.cts +57 -4
- package/dist/types-cjs/core/constants.d.cts +54 -0
- package/dist/types-cjs/core/core.d.cts +19 -20
- package/dist/types-cjs/core/dev.d.cts +8 -2
- package/dist/types-cjs/core/error.d.cts +9 -0
- package/dist/types-cjs/core/index.d.cts +2 -2
- package/dist/types-cjs/core/scheduler.d.cts +39 -0
- package/dist/types-cjs/core/types.d.cts +12 -0
- package/dist/types-cjs/index.d.cts +3 -3
- package/dist/types-cjs/signals.d.cts +108 -11
- package/dist/types-cjs/store/next/optimistic.d.cts +13 -10
- package/dist/types-cjs/store/next/projection.d.cts +1 -1
- package/dist/types-cjs/store/next/store.d.cts +22 -0
- package/dist/types-cjs/store/next/target.d.cts +25 -0
- package/package.json +1 -1
package/dist/prod/core/effect.js
CHANGED
|
@@ -14,7 +14,7 @@ import { GlobalQueue, haltReactivity } from "./scheduler.js";
|
|
|
14
14
|
const r = !!f?.user;
|
|
15
15
|
const R = createEffectNode(t, e, E, r ? EFFECT_USER : EFFECT_RENDER, f);
|
|
16
16
|
recompute(R, true);
|
|
17
|
-
!f?.defer && (R.
|
|
17
|
+
!f?.defer && (R.ge === EFFECT_USER || f?.schedule ? R.C.enqueue(R.ge, runEffect.bind(null, R)) : runEffect(R));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function notifyEffectStatus(t, e) {
|
|
@@ -23,7 +23,7 @@ function notifyEffectStatus(t, e) {
|
|
|
23
23
|
const f = e !== undefined ? e : this.o?._;
|
|
24
24
|
if (E & STATUS_ERROR) {
|
|
25
25
|
this.C.notify(this, STATUS_PENDING, 0);
|
|
26
|
-
if (this.
|
|
26
|
+
if (this.ge === 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
|
|
@@ -34,8 +34,8 @@ function notifyEffectStatus(t, e) {
|
|
|
34
34
|
// `status` arg without node-state writes) don't queue: the status
|
|
35
35
|
// re-propagates unblocked at commit.
|
|
36
36
|
if (this.S & STATUS_ERROR) {
|
|
37
|
-
this.
|
|
38
|
-
this.C.enqueue(this.
|
|
37
|
+
this.tt = true;
|
|
38
|
+
this.C.enqueue(this.ge, this.nt ??= runEffect.bind(null, this));
|
|
39
39
|
}
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -43,13 +43,13 @@ function notifyEffectStatus(t, e) {
|
|
|
43
43
|
haltReactivity(unwrapStatusError(f));
|
|
44
44
|
throw f;
|
|
45
45
|
}
|
|
46
|
-
} else if (this.
|
|
46
|
+
} else if (this.ge === EFFECT_RENDER) {
|
|
47
47
|
this.C.notify(this, STATUS_PENDING | STATUS_ERROR, E, f);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function runEffect(t) {
|
|
52
|
-
if (!t.
|
|
52
|
+
if (!t.tt || t.ie & 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,14 +60,14 @@ 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.S & STATUS_ERROR && t.
|
|
63
|
+
if (t.S & STATUS_ERROR && t.ge === EFFECT_USER) {
|
|
64
64
|
const e = unwrapStatusError(t.o?._);
|
|
65
|
-
t.
|
|
66
|
-
t.
|
|
65
|
+
t.At = t.be;
|
|
66
|
+
t.tt = false;
|
|
67
67
|
try {
|
|
68
|
-
t.
|
|
69
|
-
const e = t.
|
|
70
|
-
t.
|
|
68
|
+
t.Ct ? t.Ct(e, () => {
|
|
69
|
+
const e = t.Rt;
|
|
70
|
+
t.Rt = undefined;
|
|
71
71
|
e?.();
|
|
72
72
|
}) : console.error(e);
|
|
73
73
|
} catch (e) {
|
|
@@ -78,14 +78,14 @@ function runEffect(t) {
|
|
|
78
78
|
}
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
const e = t.
|
|
82
|
-
t.
|
|
81
|
+
const e = t.Rt;
|
|
82
|
+
t.Rt = undefined;
|
|
83
83
|
try {
|
|
84
84
|
e?.();
|
|
85
|
-
const E = t.
|
|
85
|
+
const E = t.Ot(t.be, t.At);
|
|
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.Rt = E;
|
|
89
89
|
} catch (e) {
|
|
90
90
|
ext(t)._ = new StatusError(t, e);
|
|
91
91
|
t.S |= STATUS_ERROR;
|
|
@@ -94,12 +94,12 @@ function runEffect(t) {
|
|
|
94
94
|
throw e;
|
|
95
95
|
}
|
|
96
96
|
} finally {
|
|
97
|
-
t.
|
|
98
|
-
t.
|
|
97
|
+
t.At = t.be;
|
|
98
|
+
t.tt = false;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
GlobalQueue.
|
|
102
|
+
GlobalQueue.it = runEffect;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
@@ -107,30 +107,30 @@ GlobalQueue.tt = runEffect;
|
|
|
107
107
|
* Uses stale reads.
|
|
108
108
|
*/ function trackedEffect(t, e) {
|
|
109
109
|
const run = () => {
|
|
110
|
-
if (!E.
|
|
110
|
+
if (!E.tt || E.ie & REACTIVE_DISPOSED) return;
|
|
111
111
|
try {
|
|
112
|
-
E.
|
|
112
|
+
E.tt = 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.Rt;
|
|
118
|
+
E.Rt = undefined;
|
|
119
119
|
e?.();
|
|
120
120
|
const f = staleValues(t);
|
|
121
|
-
E.
|
|
121
|
+
E.Rt = f;
|
|
122
122
|
}, {
|
|
123
123
|
...e,
|
|
124
124
|
lazy: true
|
|
125
125
|
});
|
|
126
|
-
E.
|
|
126
|
+
E.Rt = undefined;
|
|
127
127
|
E.T = E.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
128
|
-
E.
|
|
129
|
-
E.
|
|
128
|
+
E.tt = true;
|
|
129
|
+
E.ge = EFFECT_TRACKED;
|
|
130
130
|
// Status dispatch rides the SHARED notifier (statusNotifierOf keys off
|
|
131
131
|
// _type): its error arm is behavior-identical to the closure that used to
|
|
132
132
|
// live here, without the per-node NodeExtension allocation.
|
|
133
|
-
E.
|
|
133
|
+
E.yt = run;
|
|
134
134
|
E.C.enqueue(EFFECT_USER, run);
|
|
135
135
|
}
|
|
136
136
|
|
package/dist/prod/core/error.js
CHANGED
|
@@ -53,6 +53,18 @@ class StatusError extends Error {
|
|
|
53
53
|
return r instanceof StatusError ? r.cause : r;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Rejection value of `until(fn, { timeout })` when the predicate does not turn
|
|
58
|
+
* truthy within the window. Inside an `action()`, the rejection is thrown back
|
|
59
|
+
* in at the `yield` point — catchable there, or the action fails and its
|
|
60
|
+
* optimistic state reverts.
|
|
61
|
+
*/ class TimeoutError extends Error {
|
|
62
|
+
constructor(r = "Timed out waiting for condition") {
|
|
63
|
+
super(r);
|
|
64
|
+
this.name = "TimeoutError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
56
68
|
class NoOwnerError extends Error {
|
|
57
69
|
constructor() {
|
|
58
70
|
super("");
|
|
@@ -65,4 +77,4 @@ class ContextNotFoundError extends Error {
|
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
|
|
68
|
-
export { ContextNotFoundError, NoOwnerError, NotReadyError, StatusError, unwrapStatusError };
|
|
80
|
+
export { ContextNotFoundError, NoOwnerError, NotReadyError, StatusError, TimeoutError, unwrapStatusError };
|
|
@@ -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.Pt = externalSourceConfig ? wireExternalSource : null;
|
|
68
|
+
GlobalQueue.ht = externalSourceConfig ? externalUntrack : null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
package/dist/prod/core/graph.js
CHANGED
|
@@ -8,15 +8,15 @@ import { bumpNotifyEpoch } from "./scheduler.js";
|
|
|
8
8
|
|
|
9
9
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
10
10
|
function unlinkSubs(e) {
|
|
11
|
-
const n = e.
|
|
12
|
-
const l = e.
|
|
11
|
+
const n = e.ot;
|
|
12
|
+
const l = e.lt;
|
|
13
13
|
const o = e.ae;
|
|
14
14
|
const u = e.en;
|
|
15
|
-
if (o !== null) o.en = u; else n.
|
|
15
|
+
if (o !== null) o.en = u; else n._t = u;
|
|
16
16
|
if (u !== null) u.ae = o; else {
|
|
17
17
|
n.u = o;
|
|
18
18
|
if (o === null) {
|
|
19
|
-
n.o?.
|
|
19
|
+
n.o?.Et?.();
|
|
20
20
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
21
21
|
// A pending node is exempt: its in-flight async work (or the
|
|
22
22
|
// transition holding it) is an observer — tearing down would orphan
|
|
@@ -31,13 +31,13 @@ function unlinkSubs(e) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function trimStaleDeps(e) {
|
|
34
|
-
const n = e.
|
|
35
|
-
let l = n !== null ? n.
|
|
34
|
+
const n = e.je;
|
|
35
|
+
let l = n !== null ? n.lt : e.ut;
|
|
36
36
|
if (l !== null) {
|
|
37
37
|
do {
|
|
38
38
|
l = unlinkSubs(l);
|
|
39
39
|
} while (l !== null);
|
|
40
|
-
if (n !== null) n.
|
|
40
|
+
if (n !== null) n.lt = null; else e.ut = null;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -46,13 +46,13 @@ function trimStaleDeps(e) {
|
|
|
46
46
|
// and skipping early also avoids adding one (hidden-class churn) via the
|
|
47
47
|
// null-out below.
|
|
48
48
|
function clearDeps(e) {
|
|
49
|
-
let n = e.
|
|
49
|
+
let n = e.ut;
|
|
50
50
|
if (!n) return;
|
|
51
51
|
do {
|
|
52
52
|
n = unlinkSubs(n);
|
|
53
53
|
} while (n !== null);
|
|
54
|
-
e.
|
|
55
|
-
e.
|
|
54
|
+
e.ut = null;
|
|
55
|
+
e.je = null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function unobserved(e) {
|
|
@@ -104,20 +104,20 @@ function link(e, n, l = false) {
|
|
|
104
104
|
// not relabel the value dependency as probe-only — the value read is what
|
|
105
105
|
// real-error propagation and affects() coverage key off, regardless of
|
|
106
106
|
// read order within the computation.
|
|
107
|
-
const o = n.
|
|
108
|
-
if (o !== null && o.
|
|
109
|
-
o.
|
|
107
|
+
const o = n.je;
|
|
108
|
+
if (o !== null && o.ot === e) {
|
|
109
|
+
o.ve &&= l;
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
let u = null;
|
|
113
113
|
const t = n.ie & REACTIVE_RECOMPUTING_DEPS;
|
|
114
114
|
if (t) {
|
|
115
|
-
u = o !== null ? o.
|
|
116
|
-
if (u !== null && u.
|
|
117
|
-
u.
|
|
118
|
-
n.
|
|
115
|
+
u = o !== null ? o.lt : n.ut;
|
|
116
|
+
if (u !== null && u.ot === e) {
|
|
117
|
+
u.Ft = n.Ke;
|
|
118
|
+
n.je = u;
|
|
119
119
|
// First touch of this pass: the previous pass's label is stale.
|
|
120
|
-
u.
|
|
120
|
+
u.ve = l;
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -126,23 +126,23 @@ function link(e, n, l = false) {
|
|
|
126
126
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
127
127
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
128
128
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
129
|
-
const s = e.
|
|
130
|
-
if (s !== null && s.ce === n && (!t || s.
|
|
129
|
+
const s = e._t;
|
|
130
|
+
if (s !== null && s.ce === n && (!t || s.Ft === n.Ke)) {
|
|
131
131
|
// Gen-matched during a recompute = repeat touch this pass (AND); outside
|
|
132
132
|
// a recompute there is no pass boundary, so the latest read labels it.
|
|
133
|
-
if (t) s.
|
|
133
|
+
if (t) s.ve &&= l; else s.ve = l;
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
const r = n.
|
|
137
|
-
|
|
136
|
+
const r = n.je = e._t = {
|
|
137
|
+
ot: e,
|
|
138
138
|
ce: n,
|
|
139
|
-
|
|
139
|
+
lt: u,
|
|
140
140
|
en: s,
|
|
141
141
|
ae: null,
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
Ft: n.Ke,
|
|
143
|
+
ve: l
|
|
144
144
|
};
|
|
145
|
-
if (o !== null) o.
|
|
145
|
+
if (o !== null) o.lt = r; else n.ut = r;
|
|
146
146
|
if (s !== null) s.ae = r; else e.u = r;
|
|
147
147
|
// New subscriber edge: staged-rewrite skips (§12d) must not miss it.
|
|
148
148
|
bumpNotifyEpoch();
|
package/dist/prod/core/heap.js
CHANGED
|
@@ -13,29 +13,29 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
|
13
13
|
* the heap and go directly to their effect queue; everything else is inserted
|
|
14
14
|
* into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
|
|
15
15
|
*/ function enqueueSub(e) {
|
|
16
|
-
if (e.
|
|
16
|
+
if (e.ge === EFFECT_TRACKED) {
|
|
17
17
|
const E = e;
|
|
18
|
-
if (!E.
|
|
19
|
-
E.
|
|
20
|
-
E.C.enqueue(EFFECT_USER, E.
|
|
18
|
+
if (!E.tt) {
|
|
19
|
+
E.tt = true;
|
|
20
|
+
E.C.enqueue(EFFECT_USER, E.yt);
|
|
21
21
|
}
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
const E = queueFor(e);
|
|
25
|
-
if (E.
|
|
25
|
+
if (E.Qe > e.Me) E.Qe = e.Me;
|
|
26
26
|
insertIntoHeap(e, E);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function actualInsertIntoHeap(e, E) {
|
|
30
|
-
const t = (e.ke?.
|
|
31
|
-
if (t >= e.
|
|
32
|
-
const n = e.
|
|
30
|
+
const t = (e.ke?.Gt ? e.ke.Dt?.Me : e.ke?.Me) ?? -1;
|
|
31
|
+
if (t >= e.Me) e.Me = t + 1;
|
|
32
|
+
const n = e.Me;
|
|
33
33
|
const I = E.eE[n];
|
|
34
34
|
if (I === undefined) E.eE[n] = e; else {
|
|
35
|
-
const E = I.
|
|
36
|
-
E.
|
|
37
|
-
e.
|
|
38
|
-
I.
|
|
35
|
+
const E = I.ct;
|
|
36
|
+
E.rt = e;
|
|
37
|
+
e.ct = E;
|
|
38
|
+
I.ct = e;
|
|
39
39
|
}
|
|
40
40
|
if (n > E.EE) E.EE = n;
|
|
41
41
|
}
|
|
@@ -71,23 +71,23 @@ function deleteFromHeap(e, E) {
|
|
|
71
71
|
const t = e.ie;
|
|
72
72
|
if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
73
73
|
e.ie = t & -25;
|
|
74
|
-
const n = e.
|
|
75
|
-
if (e.
|
|
76
|
-
const t = e.
|
|
74
|
+
const n = e.Me;
|
|
75
|
+
if (e.ct === e) E.eE[n] = undefined; else {
|
|
76
|
+
const t = e.rt;
|
|
77
77
|
const I = E.eE[n];
|
|
78
78
|
const o = t ?? I;
|
|
79
|
-
if (e === I) E.eE[n] = t; else e.
|
|
80
|
-
o.
|
|
79
|
+
if (e === I) E.eE[n] = t; else e.ct.rt = t;
|
|
80
|
+
o.ct = e.ct;
|
|
81
81
|
}
|
|
82
|
-
e.
|
|
83
|
-
e.
|
|
82
|
+
e.ct = e;
|
|
83
|
+
e.rt = undefined;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function markHeap(e) {
|
|
87
87
|
if (e.tE) return;
|
|
88
88
|
e.tE = true;
|
|
89
89
|
for (let E = 0; E <= e.EE; E++) {
|
|
90
|
-
for (let t = e.eE[E]; t !== undefined; t = t.
|
|
90
|
+
for (let t = e.eE[E]; t !== undefined; t = t.rt) {
|
|
91
91
|
if (t.ie & REACTIVE_IN_HEAP) markNode(t);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -114,11 +114,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
|
|
|
114
114
|
|
|
115
115
|
function runHeap(e, E) {
|
|
116
116
|
e.tE = false;
|
|
117
|
-
for (e.
|
|
118
|
-
let t = e.eE[e.
|
|
117
|
+
for (e.Qe = 0; e.Qe <= e.EE; e.Qe++) {
|
|
118
|
+
let t = e.eE[e.Qe];
|
|
119
119
|
while (t !== undefined) {
|
|
120
120
|
if (t.ie & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
|
|
121
|
-
t = e.eE[e.
|
|
121
|
+
t = e.eE[e.Qe];
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
e.EE = 0;
|
|
@@ -126,14 +126,14 @@ function runHeap(e, E) {
|
|
|
126
126
|
|
|
127
127
|
function adjustHeight(e, E) {
|
|
128
128
|
deleteFromHeap(e, E);
|
|
129
|
-
let t = e.
|
|
130
|
-
for (let E = e.
|
|
131
|
-
const e = E.
|
|
132
|
-
const n = e.
|
|
133
|
-
if (n.oe && n.
|
|
129
|
+
let t = e.Me;
|
|
130
|
+
for (let E = e.ut; E; E = E.lt) {
|
|
131
|
+
const e = E.ot;
|
|
132
|
+
const n = e.st || e;
|
|
133
|
+
if (n.oe && n.Me >= t) t = n.Me + 1;
|
|
134
134
|
}
|
|
135
|
-
if (e.
|
|
136
|
-
e.
|
|
135
|
+
if (e.Me !== t) {
|
|
136
|
+
e.Me = t;
|
|
137
137
|
for (let E = e.u; E !== null; E = E.ae) {
|
|
138
138
|
// Route each subscriber by its own zombie flag, mirroring the
|
|
139
139
|
// post-recompute height-adjust path. Inserting into the running `heap`
|
package/dist/prod/core/lanes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONFIG_HAS_LANE, NOT_PENDING } from "./constants.js";
|
|
2
2
|
|
|
3
3
|
import { ext } from "./core.js";
|
|
4
4
|
|
|
@@ -20,16 +20,16 @@ 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 i = n.o?.
|
|
24
|
-
const t = i?.o?.
|
|
23
|
+
const i = n.o?.Tt;
|
|
24
|
+
const t = i?.o?.Je;
|
|
25
25
|
const r = t ? findLane(t) : null;
|
|
26
26
|
e = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
nn: n,
|
|
28
|
+
Oe: new Set,
|
|
29
|
+
tn: [ [], [] ],
|
|
30
|
+
rn: null,
|
|
31
|
+
Ae: activeTransition,
|
|
32
|
+
an: r
|
|
33
33
|
};
|
|
34
34
|
signalLanes.set(n, e);
|
|
35
35
|
activeLanes.add(e);
|
|
@@ -39,8 +39,8 @@ const activeLanes = new Set;
|
|
|
39
39
|
// parent-child is a property of the nodes, not of write order — otherwise
|
|
40
40
|
// the owner's write merges the companion's subscribers into this lane and
|
|
41
41
|
// their effects wait on its async instead of flushing immediately.
|
|
42
|
-
adoptCompanionLane(n.o?.
|
|
43
|
-
adoptCompanionLane(n.o?.
|
|
42
|
+
adoptCompanionLane(n.o?.ye, e);
|
|
43
|
+
adoptCompanionLane(n.o?.Ce, e);
|
|
44
44
|
return e;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -51,13 +51,13 @@ function adoptCompanionLane(n, e) {
|
|
|
51
51
|
const t = findLane(i);
|
|
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 (t !== e && t.
|
|
54
|
+
if (t !== e && t.nn === n && !t.an) t.an = e;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Union-find: find the root lane.
|
|
59
59
|
*/ function findLane(n) {
|
|
60
|
-
while (n.
|
|
60
|
+
while (n.rn) n = n.rn;
|
|
61
61
|
return n;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -67,27 +67,27 @@ function adoptCompanionLane(n, e) {
|
|
|
67
67
|
n = findLane(n);
|
|
68
68
|
e = findLane(e);
|
|
69
69
|
if (n === e) return n;
|
|
70
|
-
e.
|
|
70
|
+
e.rn = n;
|
|
71
71
|
// Move (not copy) the merged lane's work: after the merge all routing goes
|
|
72
72
|
// through findLane() to the root, so anything left behind here is dead —
|
|
73
73
|
// and anything *added* here later is a routing bug (INV-5).
|
|
74
|
-
for (const i of e.
|
|
75
|
-
e.
|
|
76
|
-
n.
|
|
77
|
-
n.
|
|
78
|
-
e.
|
|
79
|
-
e.
|
|
74
|
+
for (const i of e.Oe) n.Oe.add(i);
|
|
75
|
+
e.Oe.clear();
|
|
76
|
+
n.tn[0].push(...e.tn[0]);
|
|
77
|
+
n.tn[1].push(...e.tn[1]);
|
|
78
|
+
e.tn[0].length = 0;
|
|
79
|
+
e.tn[1].length = 0;
|
|
80
80
|
return n;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
85
85
|
*/ function resolveLane(n) {
|
|
86
|
-
const e = n.o?.
|
|
86
|
+
const e = n.o?.Je;
|
|
87
87
|
if (!e) return undefined;
|
|
88
88
|
const i = findLane(e);
|
|
89
89
|
if (activeLanes.has(i)) return i;
|
|
90
|
-
if (n.o !== null) n.o.
|
|
90
|
+
if (n.o !== null) n.o.Je = undefined;
|
|
91
91
|
return undefined;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -99,17 +99,17 @@ function resolveTransition(n) {
|
|
|
99
99
|
// reader. Chase merge chains; a dead owner settled through another path.
|
|
100
100
|
if (hasActiveOverride(n) && n.o?.Nt) {
|
|
101
101
|
const e = ext(n).Nt = currentTransition(n.o?.Nt);
|
|
102
|
-
if (e.
|
|
102
|
+
if (e.sn !== true) return e;
|
|
103
103
|
if (n.o !== null) n.o.Nt = null;
|
|
104
104
|
}
|
|
105
|
-
return resolveLane(n)?.
|
|
105
|
+
return resolveLane(n)?.Ae ?? n.Ae;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Check if a node has an active optimistic override.
|
|
110
110
|
*/ function hasActiveOverride(n) {
|
|
111
111
|
const e = n.o;
|
|
112
|
-
return e !== null && e.
|
|
112
|
+
return e !== null && e.Pe !== undefined && e.Pe !== NOT_PENDING;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -117,13 +117,13 @@ function resolveTransition(n) {
|
|
|
117
117
|
* a different active lane), merge unless the node has an active override.
|
|
118
118
|
*/ function assignOrMergeLane(n, e) {
|
|
119
119
|
const i = findLane(e);
|
|
120
|
-
const t = n.o?.
|
|
120
|
+
const t = n.o?.Je;
|
|
121
121
|
if (t) {
|
|
122
122
|
// If the subscriber's lane was merged into another lane, it's stale —
|
|
123
123
|
// replace it with the new source lane instead of following the merge chain
|
|
124
124
|
// (which would incorrectly merge the new lane into the old group)
|
|
125
|
-
if (t.
|
|
126
|
-
ext(n).
|
|
125
|
+
if (t.rn) {
|
|
126
|
+
ext(n).Je = e;
|
|
127
127
|
n.T |= CONFIG_HAS_LANE;
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
@@ -132,15 +132,15 @@ function resolveTransition(n) {
|
|
|
132
132
|
if (r !== i && !hasActiveOverride(n)) {
|
|
133
133
|
// Parent-child lanes stay independent so isPending resolves without
|
|
134
134
|
// waiting for the parent's async. The child keeps ownership.
|
|
135
|
-
if (i.
|
|
136
|
-
ext(n).
|
|
135
|
+
if (i.an && findLane(i.an) === r) {
|
|
136
|
+
ext(n).Je = e;
|
|
137
137
|
n.T |= CONFIG_HAS_LANE;
|
|
138
|
-
} else if (r.
|
|
138
|
+
} else if (r.an && findLane(r.an) === i) ; else mergeLanes(i, r);
|
|
139
139
|
}
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
ext(n).
|
|
143
|
+
ext(n).Je = e;
|
|
144
144
|
n.T |= CONFIG_HAS_LANE;
|
|
145
145
|
}
|
|
146
146
|
|