@solidjs/signals 2.0.0-rc.8 → 2.0.0-rc.9
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 +1399 -285
- package/dist/dev.attribution.js +459 -307
- package/dist/dev.js +1864 -435
- package/dist/observe/affects.js +3 -1
- package/dist/observe/attribution.js +7 -1
- package/dist/observe/boundaries.js +209 -154
- package/dist/observe/core/action.js +18 -8
- package/dist/observe/core/async.js +220 -110
- package/dist/observe/core/attribution-costs.js +66 -0
- package/dist/observe/core/attribution-feedback.js +282 -0
- package/dist/observe/core/attribution-hooks.js +23 -1
- package/dist/observe/core/attribution-queries.js +28 -0
- package/dist/observe/core/attribution.js +262 -485
- package/dist/observe/core/constants.js +34 -1
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +867 -367
- package/dist/observe/core/dev.js +78 -17
- package/dist/observe/core/effect.js +67 -51
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/external.js +4 -4
- package/dist/observe/core/graph.js +37 -37
- package/dist/observe/core/heap.js +45 -45
- package/dist/observe/core/invariants.js +2 -0
- package/dist/observe/core/lanes.js +86 -49
- package/dist/observe/core/optimistic.js +242 -95
- package/dist/observe/core/owner.js +98 -84
- package/dist/observe/core/scheduler.js +543 -305
- package/dist/observe/core/verdict.js +247 -129
- package/dist/observe/index.js +7 -3
- package/dist/observe/map.js +126 -124
- package/dist/observe/signals.js +33 -17
- package/dist/observe/store/index.js +2 -0
- package/dist/observe/store/next/optimistic.js +141 -132
- package/dist/observe/store/next/projection.js +34 -21
- package/dist/observe/store/next/reconcile.js +58 -56
- package/dist/observe/store/next/store.js +260 -146
- package/dist/observe/store/store.js +5 -3
- package/dist/observe/store/utils.js +948 -135
- package/dist/prod/attribution.js +26 -17
- package/dist/prod/boundaries.js +128 -76
- package/dist/prod/core/action.js +16 -8
- package/dist/prod/core/async.js +251 -143
- package/dist/prod/core/constants.js +34 -1
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +843 -347
- package/dist/prod/core/dev.js +17 -1
- package/dist/prod/core/effect.js +48 -34
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +37 -37
- package/dist/prod/core/heap.js +45 -45
- package/dist/prod/core/lanes.js +90 -53
- package/dist/prod/core/optimistic.js +247 -100
- package/dist/prod/core/owner.js +57 -45
- package/dist/prod/core/scheduler.js +543 -305
- package/dist/prod/core/verdict.js +245 -127
- package/dist/prod/index.js +7 -3
- package/dist/prod/map.js +112 -112
- package/dist/prod/signals.js +28 -12
- package/dist/prod/store/next/optimistic.js +135 -128
- package/dist/prod/store/next/projection.js +31 -20
- package/dist/prod/store/next/store.js +325 -252
- package/dist/prod/store/store.js +2 -2
- package/dist/prod/store/utils.js +946 -135
- package/dist/types/attribution.d.ts +7 -2
- package/dist/types/attribution.prod.d.ts +10 -1
- package/dist/types/boundaries.d.ts +10 -1
- package/dist/types/core/action.d.ts +12 -5
- package/dist/types/core/attribution-costs.d.ts +35 -0
- package/dist/types/core/attribution-feedback.d.ts +133 -0
- package/dist/types/core/attribution-hooks.d.ts +28 -3
- package/dist/types/core/attribution-queries.d.ts +10 -0
- package/dist/types/core/attribution.d.ts +51 -172
- package/dist/types/core/constants.d.ts +33 -0
- package/dist/types/core/core.d.ts +186 -5
- package/dist/types/core/dev.d.ts +129 -9
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/index.d.ts +3 -1
- package/dist/types/core/invariants.d.ts +4 -0
- package/dist/types/core/lanes.d.ts +31 -4
- package/dist/types/core/scheduler.d.ts +95 -2
- package/dist/types/core/types.d.ts +3 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/signals.d.ts +8 -0
- package/dist/types/store/index.d.ts +2 -1
- package/dist/types/store/next/optimistic.d.ts +1 -1
- package/dist/types/store/next/store.d.ts +6 -5
- package/dist/types/store/next/target.d.ts +1 -1
- package/dist/types/store/utils.d.ts +177 -6
- package/package.json +1 -1
package/dist/prod/core/dev.js
CHANGED
|
@@ -2,4 +2,20 @@ import "./core.js";
|
|
|
2
2
|
|
|
3
3
|
const DEV = undefined;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Root-first names of the owners enclosing `subject` (inclusive when the
|
|
7
|
+
* subject is itself a named owner). Signals hop to their registering owner
|
|
8
|
+
* (`_owner`, set by registerGraph). Unnamed owners are skipped so the path
|
|
9
|
+
* reads as the component tree plus the scope: `<App> › <TodoRow> › effect`.
|
|
10
|
+
*/ function ownerPath(n) {
|
|
11
|
+
if (!n) return undefined;
|
|
12
|
+
let e = "_parent" in n ? n : n.se ?? null;
|
|
13
|
+
const t = [];
|
|
14
|
+
for (;e !== null; e = e._parent) {
|
|
15
|
+
const n = e._name;
|
|
16
|
+
if (typeof n === "string" && n.length) t.push(n);
|
|
17
|
+
}
|
|
18
|
+
return t.length ? t.reverse() : undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { DEV, ownerPath };
|
package/dist/prod/core/effect.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { REACTIVE_DISPOSED, LANE_RUN, STATUS_ERROR, EFFECT_USER, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, STATUS_PENDING } from "./constants.js";
|
|
1
|
+
import { REACTIVE_DISPOSED, LANE_RUN, STATUS_ERROR, EFFECT_USER, NOT_PENDING, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, STATUS_PENDING } from "./constants.js";
|
|
2
2
|
|
|
3
3
|
import { setEffectStatusNotify, ext, createEffectNode, recompute, computed, staleValues } from "./core.js";
|
|
4
4
|
|
|
5
5
|
import { unwrapStatusError, StatusError } from "./error.js";
|
|
6
6
|
|
|
7
|
+
import { trimStaleDeps } from "./graph.js";
|
|
8
|
+
|
|
7
9
|
import { enqueueSub } from "./heap.js";
|
|
8
10
|
|
|
9
11
|
import { GlobalQueue, currentTransition, activeTransition, haltReactivity, schedule } from "./scheduler.js";
|
|
@@ -14,9 +16,12 @@ import { GlobalQueue, currentTransition, activeTransition, haltReactivity, sched
|
|
|
14
16
|
* sources and recompute
|
|
15
17
|
*/ function effect(t, e, E, r) {
|
|
16
18
|
const n = !!r?.user;
|
|
17
|
-
const
|
|
18
|
-
recompute(
|
|
19
|
-
|
|
19
|
+
const i = createEffectNode(t, e, E, n ? EFFECT_USER : EFFECT_RENDER, r);
|
|
20
|
+
recompute(i, true);
|
|
21
|
+
// A first pass that derived from a live transaction's staged world was
|
|
22
|
+
// staged into that transaction (recompute: born held); the transaction's
|
|
23
|
+
// commit replays this effect. Its first run is not this creation's (A29).
|
|
24
|
+
!r?.defer && i.ve === NOT_PENDING && (i.Le === EFFECT_USER || r?.schedule ? i.C.enqueue(i.Le, runEffect.bind(null, i)) : runEffect(i, LANE_RUN));
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
function notifyEffectStatus(t, e) {
|
|
@@ -25,7 +30,7 @@ function notifyEffectStatus(t, e) {
|
|
|
25
30
|
const r = e !== undefined ? e : this.o?._;
|
|
26
31
|
if (E & STATUS_ERROR) {
|
|
27
32
|
this.C.notify(this, STATUS_PENDING, 0);
|
|
28
|
-
if (this.
|
|
33
|
+
if (this.Le === EFFECT_USER) {
|
|
29
34
|
// The error handler is the error arm of the effect phase (#2840 ruling):
|
|
30
35
|
// queue it like the effect function. It runs in the same imperative,
|
|
31
36
|
// writable scope, throws escalate the same way, and a held transition
|
|
@@ -36,8 +41,8 @@ function notifyEffectStatus(t, e) {
|
|
|
36
41
|
// `status` arg without node-state writes) don't queue: the status
|
|
37
42
|
// re-propagates unblocked at commit.
|
|
38
43
|
if (this.S & STATUS_ERROR) {
|
|
39
|
-
this.
|
|
40
|
-
this.C.enqueue(this.
|
|
44
|
+
this.Ye = true;
|
|
45
|
+
this.C.enqueue(this.Le, this.dt ??= runEffect.bind(null, this));
|
|
41
46
|
}
|
|
42
47
|
return;
|
|
43
48
|
}
|
|
@@ -45,13 +50,13 @@ function notifyEffectStatus(t, e) {
|
|
|
45
50
|
haltReactivity(unwrapStatusError(r));
|
|
46
51
|
throw r;
|
|
47
52
|
}
|
|
48
|
-
} else if (this.
|
|
53
|
+
} else if (this.Le === EFFECT_RENDER) {
|
|
49
54
|
this.C.notify(this, STATUS_PENDING | STATUS_ERROR, E, r);
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
function runEffect(t, e) {
|
|
54
|
-
if (!t.
|
|
59
|
+
if (!t.Ye || t.ue & REACTIVE_DISPOSED) return;
|
|
55
60
|
// Ownership (#3319): a value computed under a transaction is applied by that
|
|
56
61
|
// transaction's commit. The ordinary effect phase runs with a transaction
|
|
57
62
|
// active only when the flush's finalize ENTERED one (every other path parks
|
|
@@ -68,8 +73,8 @@ function runEffect(t, e) {
|
|
|
68
73
|
// transaction. Hand the run to the regular queue, where the transaction's
|
|
69
74
|
// gate stashes it with the owner. Lane-less runners with no live owner
|
|
70
75
|
// (reverts, wake-only lanes) apply now.
|
|
71
|
-
if (t.
|
|
72
|
-
t.C.enqueue(t.
|
|
76
|
+
if (t.It !== null && !currentTransition(t.It).Tt && (e & LANE_RUN ? !t.o?.Ue : activeTransition !== null)) {
|
|
77
|
+
t.C.enqueue(t.Le, t.dt);
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
// Error arm (#2840), user effects only: a compute-phase error that is still
|
|
@@ -82,14 +87,14 @@ function runEffect(t, e) {
|
|
|
82
87
|
// Render effects bypass: their errors route to boundaries synchronously in
|
|
83
88
|
// notifyEffectStatus, and a runner queued by an earlier valueChanged in the
|
|
84
89
|
// same flush must not be hijacked by a later-arriving error status.
|
|
85
|
-
if (t.S & STATUS_ERROR && t.
|
|
90
|
+
if (t.S & STATUS_ERROR && t.Le === EFFECT_USER) {
|
|
86
91
|
const e = unwrapStatusError(t.o?._);
|
|
87
|
-
t.
|
|
88
|
-
t.
|
|
92
|
+
t.Ut = t.Qe;
|
|
93
|
+
t.Ye = false;
|
|
89
94
|
try {
|
|
90
|
-
t.
|
|
91
|
-
const e = t.
|
|
92
|
-
t.
|
|
95
|
+
t.Vt ? t.Vt(e, () => {
|
|
96
|
+
const e = t.yt;
|
|
97
|
+
t.yt = undefined;
|
|
93
98
|
e?.();
|
|
94
99
|
}) : console.error(e);
|
|
95
100
|
} catch (e) {
|
|
@@ -100,14 +105,17 @@ function runEffect(t, e) {
|
|
|
100
105
|
}
|
|
101
106
|
return;
|
|
102
107
|
}
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
// Captured before the callback: its own throw errors the node below, but
|
|
109
|
+
// the compute pass that produced `_value` was clean, so its tail still goes.
|
|
110
|
+
const E = t.o?._ == null;
|
|
111
|
+
const r = t.yt;
|
|
112
|
+
t.yt = undefined;
|
|
105
113
|
try {
|
|
106
|
-
|
|
107
|
-
const e = t.
|
|
114
|
+
r?.();
|
|
115
|
+
const e = t.Lt(t.Qe, t.Ut);
|
|
108
116
|
if (false && e !== undefined && typeof e !== "function") ;
|
|
109
117
|
// The final cleanup is invoked by disposeChildren at true disposal.
|
|
110
|
-
t.
|
|
118
|
+
t.yt = e;
|
|
111
119
|
} catch (e) {
|
|
112
120
|
ext(t)._ = new StatusError(t, e);
|
|
113
121
|
t.S |= STATUS_ERROR;
|
|
@@ -116,12 +124,18 @@ function runEffect(t, e) {
|
|
|
116
124
|
throw e;
|
|
117
125
|
}
|
|
118
126
|
} finally {
|
|
119
|
-
t.
|
|
120
|
-
t.
|
|
127
|
+
t.Ut = t.Qe;
|
|
128
|
+
t.Ye = false;
|
|
129
|
+
// The run applied: this is the frame now, so the dependency tail the
|
|
130
|
+
// compute pass left linked goes (A30, #3438 — `recompute` defers an
|
|
131
|
+
// effect's trim while a run is owed; the twin of `commitPendingNode`'s
|
|
132
|
+
// trim for a staged pass). An errored compute kept its full list with
|
|
133
|
+
// `_depsTail` marking where it stopped; leave it, as the commit does.
|
|
134
|
+
if (E) trimStaleDeps(t);
|
|
121
135
|
}
|
|
122
136
|
}
|
|
123
137
|
|
|
124
|
-
GlobalQueue.
|
|
138
|
+
GlobalQueue.Et = runEffect;
|
|
125
139
|
|
|
126
140
|
/**
|
|
127
141
|
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
@@ -132,30 +146,30 @@ GlobalQueue.ct = runEffect;
|
|
|
132
146
|
// `_modified` is NOT redundant with the heap: the heap dedups within a
|
|
133
147
|
// pass, but a held transition's passes each enqueue `_run` into the same
|
|
134
148
|
// user queue, and this gate is what collapses them into one run at commit.
|
|
135
|
-
if (!E.
|
|
149
|
+
if (!E.Ye || E.ue & REACTIVE_DISPOSED) return;
|
|
136
150
|
try {
|
|
137
|
-
E.
|
|
151
|
+
E.Ye = false;
|
|
138
152
|
recompute(E);
|
|
139
153
|
} finally {}
|
|
140
154
|
};
|
|
141
155
|
const E = computed(() => {
|
|
142
|
-
const e = E.
|
|
143
|
-
E.
|
|
156
|
+
const e = E.yt;
|
|
157
|
+
E.yt = undefined;
|
|
144
158
|
e?.();
|
|
145
159
|
const r = staleValues(t);
|
|
146
|
-
E.
|
|
160
|
+
E.yt = r;
|
|
147
161
|
}, {
|
|
148
162
|
...e,
|
|
149
163
|
lazy: true
|
|
150
164
|
});
|
|
151
|
-
E.
|
|
165
|
+
E.yt = undefined;
|
|
152
166
|
E.T = E.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
|
|
153
|
-
E.
|
|
154
|
-
E.
|
|
167
|
+
E.Ye = true;
|
|
168
|
+
E.Le = EFFECT_TRACKED;
|
|
155
169
|
// Status dispatch rides the SHARED notifier (statusNotifierOf keys off
|
|
156
170
|
// _type): its error arm is behavior-identical to the closure that used to
|
|
157
171
|
// live here, without the per-node NodeExtension allocation.
|
|
158
|
-
E.
|
|
172
|
+
E.Ke = run;
|
|
159
173
|
// The first run rides the heap like every wake (GlobalQueue._update), so a
|
|
160
174
|
// tracked effect created inside a render-effect callback runs after that
|
|
161
175
|
// pass's staged writes commit, not before.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ROOT_ERROR_HOOK } from "./scheduler.js";
|
|
2
|
+
|
|
3
|
+
let ambientHook;
|
|
4
|
+
|
|
5
|
+
const reported = new WeakSet;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Registers the ambient client error hook — the one call a browser `init()`
|
|
9
|
+
* makes to see every failure a boundary renders a fallback for, in
|
|
10
|
+
* production. (Uncaught errors reach `reportError` / `window.onerror`.)
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* configureClientErrors({
|
|
14
|
+
* onError: (error, { ownerPath }) =>
|
|
15
|
+
* Sentry.captureException(error, {
|
|
16
|
+
* mechanism: { type: "solid.error_boundary", handled: true }
|
|
17
|
+
* })
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/ function configureClientErrors(e) {
|
|
21
|
+
if (e && e.onError !== undefined && typeof e.onError !== "function") {
|
|
22
|
+
throw new TypeError(`Invalid onError: expected a function, received ${typeof e.onError}.`);
|
|
23
|
+
}
|
|
24
|
+
ambientHook = e ? e.onError : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The nearest root's hook above `owner` (parked under `ROOT_ERROR_HOOK`), else the ambient one. */ function hookFor(e) {
|
|
28
|
+
for (let n = e; n; n = n._parent) {
|
|
29
|
+
const e = n[ROOT_ERROR_HOOK];
|
|
30
|
+
if (e !== undefined) return e;
|
|
31
|
+
}
|
|
32
|
+
return ambientHook;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Component labels up the owner chain, root first — `_name` where the runtime keeps it. */ function labels(e) {
|
|
36
|
+
const n = [];
|
|
37
|
+
for (let o = e; o; o = o._parent) {
|
|
38
|
+
const e = o._name;
|
|
39
|
+
if (typeof e === "string" && e.length) n.push(e);
|
|
40
|
+
}
|
|
41
|
+
return n.length ? n.reverse() : undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Tells the client error hook about `error`, caught by the boundary whose
|
|
46
|
+
* owner is `owner`, thrown by `thrower` (the computation the engine's status
|
|
47
|
+
* wrapper named; unknown for a value that never crossed one) — once per
|
|
48
|
+
* error object. A throwing hook is reported on the console and otherwise
|
|
49
|
+
* ignored — a monitor must never take the app down.
|
|
50
|
+
* @internal
|
|
51
|
+
*/ function reportClientError(e, n, o) {
|
|
52
|
+
const r = e !== null && (typeof e === "object" || typeof e === "function");
|
|
53
|
+
if (r) {
|
|
54
|
+
if (reported.has(e)) return;
|
|
55
|
+
reported.add(e);
|
|
56
|
+
}
|
|
57
|
+
const t = hookFor(n);
|
|
58
|
+
if (t === undefined) return;
|
|
59
|
+
const i = {};
|
|
60
|
+
const f = labels(n);
|
|
61
|
+
const c = labels(o) ?? f;
|
|
62
|
+
if (c !== undefined) i.ownerPath = c;
|
|
63
|
+
if (f !== undefined) i.boundaryPath = f;
|
|
64
|
+
try {
|
|
65
|
+
t(e, i);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error(e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { configureClientErrors, reportClientError };
|
|
@@ -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.ce, () => {
|
|
50
50
|
setSignal(n, undefined);
|
|
51
51
|
});
|
|
52
52
|
cleanup(() => r.dispose());
|
|
53
|
-
e.
|
|
53
|
+
e.ce = 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.wt = externalSourceConfig ? wireExternalSource : null;
|
|
68
|
+
GlobalQueue.Yt = externalSourceConfig ? externalUntrack : null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function enableExternalSource(e) {
|
package/dist/prod/core/graph.js
CHANGED
|
@@ -10,17 +10,17 @@ import { bumpNotifyEpoch } from "./scheduler.js";
|
|
|
10
10
|
|
|
11
11
|
// https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
|
|
12
12
|
function unlinkSubs(e) {
|
|
13
|
-
const n = e.
|
|
14
|
-
const l = e.
|
|
15
|
-
const o = e.
|
|
16
|
-
const s = e.
|
|
17
|
-
if (o !== null) o.
|
|
18
|
-
if (s !== null) s.
|
|
13
|
+
const n = e.Ee;
|
|
14
|
+
const l = e.de;
|
|
15
|
+
const o = e.Ne;
|
|
16
|
+
const s = e.rn;
|
|
17
|
+
if (o !== null) o.rn = s; else n.Gt = s;
|
|
18
|
+
if (s !== null) s.Ne = o; else {
|
|
19
19
|
n.u = o;
|
|
20
20
|
if (o === null) {
|
|
21
21
|
// Slot nodes (store leaves) dispatch to the ONE shared hook — no
|
|
22
22
|
// per-node unobserved closure, no NodeExtension to hold it.
|
|
23
|
-
if (n.T & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.
|
|
23
|
+
if (n.T & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.Pt?.();
|
|
24
24
|
// No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
|
|
25
25
|
// A pending node is exempt: its in-flight async work (or the
|
|
26
26
|
// transition holding it) is an observer — tearing down would orphan
|
|
@@ -28,20 +28,20 @@ function unlinkSubs(e) {
|
|
|
28
28
|
// this same last-one-out check when that observer releases (the
|
|
29
29
|
// untracked-read dormancy sweep guards on pending identically).
|
|
30
30
|
const e = n;
|
|
31
|
-
e.
|
|
31
|
+
e.ce && e.T & CONFIG_AUTO_DISPOSE && !(e.ue & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return l;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function trimStaleDeps(e) {
|
|
38
|
-
const n = e.
|
|
39
|
-
let l = n !== null ? n.
|
|
38
|
+
const n = e.ot;
|
|
39
|
+
let l = n !== null ? n.de : e.Se;
|
|
40
40
|
if (l !== null) {
|
|
41
41
|
do {
|
|
42
42
|
l = unlinkSubs(l);
|
|
43
43
|
} while (l !== null);
|
|
44
|
-
if (n !== null) n.
|
|
44
|
+
if (n !== null) n.de = null; else e.Se = null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -50,13 +50,13 @@ function trimStaleDeps(e) {
|
|
|
50
50
|
// and skipping early also avoids adding one (hidden-class churn) via the
|
|
51
51
|
// null-out below.
|
|
52
52
|
function clearDeps(e) {
|
|
53
|
-
let n = e.
|
|
53
|
+
let n = e.Se;
|
|
54
54
|
if (!n) return;
|
|
55
55
|
do {
|
|
56
56
|
n = unlinkSubs(n);
|
|
57
57
|
} while (n !== null);
|
|
58
|
-
e.
|
|
59
|
-
e.
|
|
58
|
+
e.Se = null;
|
|
59
|
+
e.ot = null;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function unobserved(e) {
|
|
@@ -94,7 +94,7 @@ function sweepDormant() {
|
|
|
94
94
|
// is an observer; the settle path re-runs last-one-out), lost its
|
|
95
95
|
// AUTO_DISPOSE bit (owner teardown strips it, #3024), or already been
|
|
96
96
|
// torn down.
|
|
97
|
-
if (!e.u && e.T & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.
|
|
97
|
+
if (!e.u && e.T & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.ue & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
|
|
98
98
|
unobserved(e);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -108,20 +108,20 @@ function link(e, n, l = false) {
|
|
|
108
108
|
// not relabel the value dependency as probe-only — the value read is what
|
|
109
109
|
// real-error propagation and affects() coverage key off, regardless of
|
|
110
110
|
// read order within the computation.
|
|
111
|
-
const o = n.
|
|
112
|
-
if (o !== null && o.
|
|
113
|
-
o.
|
|
111
|
+
const o = n.ot;
|
|
112
|
+
if (o !== null && o.Ee === e) {
|
|
113
|
+
o.He &&= l;
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
let s = null;
|
|
117
|
-
const t = n.
|
|
117
|
+
const t = n.ue & REACTIVE_RECOMPUTING_DEPS;
|
|
118
118
|
if (t) {
|
|
119
|
-
s = o !== null ? o.
|
|
120
|
-
if (s !== null && s.
|
|
121
|
-
s.
|
|
122
|
-
n.
|
|
119
|
+
s = o !== null ? o.de : n.Se;
|
|
120
|
+
if (s !== null && s.Ee === e) {
|
|
121
|
+
s.qe = n.Ze;
|
|
122
|
+
n.ot = s;
|
|
123
123
|
// First touch of this pass: the previous pass's label is stale.
|
|
124
|
-
s.
|
|
124
|
+
s.He = l;
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -130,24 +130,24 @@ function link(e, n, l = false) {
|
|
|
130
130
|
// [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
|
|
131
131
|
// (the old alien-signals `isValidLink` walk, O(n²) when a computation
|
|
132
132
|
// re-reads earlier deps non-consecutively, e.g. store leaf reads).
|
|
133
|
-
const r = e.
|
|
134
|
-
if (r !== null && r.
|
|
133
|
+
const r = e.Gt;
|
|
134
|
+
if (r !== null && r._e === n && (!t || r.qe === n.Ze)) {
|
|
135
135
|
// Gen-matched during a recompute = repeat touch this pass (AND); outside
|
|
136
136
|
// a recompute there is no pass boundary, so the latest read labels it.
|
|
137
|
-
if (t) r.
|
|
137
|
+
if (t) r.He &&= l; else r.He = l;
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
const u = n.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
const u = n.ot = e.Gt = {
|
|
141
|
+
Ee: e,
|
|
142
|
+
_e: n,
|
|
143
|
+
de: s,
|
|
144
|
+
rn: r,
|
|
145
|
+
Ne: null,
|
|
146
|
+
qe: n.Ze,
|
|
147
|
+
He: l
|
|
148
148
|
};
|
|
149
|
-
if (o !== null) o.
|
|
150
|
-
if (r !== null) r.
|
|
149
|
+
if (o !== null) o.de = u; else n.Se = u;
|
|
150
|
+
if (r !== null) r.Ne = u; else e.u = u;
|
|
151
151
|
// New subscriber edge: staged-rewrite skips (§12d) must not miss it.
|
|
152
152
|
bumpNotifyEpoch();
|
|
153
153
|
}
|
package/dist/prod/core/heap.js
CHANGED
|
@@ -5,7 +5,7 @@ import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_ZOMBIE, REACTIVE_RE
|
|
|
5
5
|
import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
6
6
|
|
|
7
7
|
/** The queue a node belongs to, picked from its own zombie flag. */ function queueFor(e) {
|
|
8
|
-
return e.
|
|
8
|
+
return e.ue & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -16,34 +16,34 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
|
|
|
16
16
|
* (see GlobalQueue._update, #3291).
|
|
17
17
|
*/ function enqueueSub(e) {
|
|
18
18
|
const E = queueFor(e);
|
|
19
|
-
if (E.
|
|
19
|
+
if (E.et > e.tt) E.et = e.tt;
|
|
20
20
|
insertIntoHeap(e, E);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function actualInsertIntoHeap(e, E) {
|
|
24
|
-
const t = (e.
|
|
25
|
-
if (t >= e.
|
|
26
|
-
const n = e.
|
|
24
|
+
const t = (e._parent?.xt ? e._parent.Qt?.tt : e._parent?.tt) ?? -1;
|
|
25
|
+
if (t >= e.tt) e.tt = t + 1;
|
|
26
|
+
const n = e.tt;
|
|
27
27
|
const I = E.eE[n];
|
|
28
28
|
if (I === undefined) E.eE[n] = e; else {
|
|
29
|
-
const E = I.
|
|
30
|
-
E.
|
|
31
|
-
e.
|
|
32
|
-
I.
|
|
29
|
+
const E = I.Rt;
|
|
30
|
+
E.At = e;
|
|
31
|
+
e.Rt = E;
|
|
32
|
+
I.Rt = e;
|
|
33
33
|
}
|
|
34
34
|
if (n > E.EE) E.EE = n;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function insertIntoHeap(e, E) {
|
|
38
|
-
let t = e.
|
|
38
|
+
let t = e.ue;
|
|
39
39
|
// RECOMPUTING refusals are not always losses: a genuinely missed wake (a
|
|
40
40
|
// write to a link this pass already validated) is latched link-side in
|
|
41
41
|
// insertSubs as REACTIVE_MISSED_WAKE for recompute's tail (#3037).
|
|
42
42
|
if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
|
|
43
43
|
if (t & REACTIVE_CHECK) {
|
|
44
|
-
e.
|
|
44
|
+
e.ue = t & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
45
45
|
} else {
|
|
46
|
-
e.
|
|
46
|
+
e.ue = t | REACTIVE_IN_HEAP;
|
|
47
47
|
// An unmarked node entering an already-marked heap is marked on the
|
|
48
48
|
// spot, keeping the markHeap memo valid. `_marked` is only reset by
|
|
49
49
|
// runHeap, so a write between two mid-tick pulls (read-time markHeap +
|
|
@@ -60,52 +60,52 @@ function insertIntoHeap(e, E) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function insertIntoHeapHeight(e, E) {
|
|
63
|
-
let t = e.
|
|
63
|
+
let t = e.ue;
|
|
64
64
|
if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)) return;
|
|
65
|
-
e.
|
|
65
|
+
e.ue = t | REACTIVE_IN_HEAP_HEIGHT;
|
|
66
66
|
actualInsertIntoHeap(e, E);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function deleteFromHeap(e, E) {
|
|
70
|
-
const t = e.
|
|
70
|
+
const t = e.ue;
|
|
71
71
|
if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
72
|
-
e.
|
|
73
|
-
const n = e.
|
|
74
|
-
if (e.
|
|
75
|
-
const t = e.
|
|
72
|
+
e.ue = t & -25;
|
|
73
|
+
const n = e.tt;
|
|
74
|
+
if (e.Rt === e) E.eE[n] = undefined; else {
|
|
75
|
+
const t = e.At;
|
|
76
76
|
const I = E.eE[n];
|
|
77
77
|
const o = t ?? I;
|
|
78
|
-
if (e === I) E.eE[n] = t; else e.
|
|
79
|
-
o.
|
|
78
|
+
if (e === I) E.eE[n] = t; else e.Rt.At = t;
|
|
79
|
+
o.Rt = e.Rt;
|
|
80
80
|
}
|
|
81
|
-
e.
|
|
82
|
-
e.
|
|
81
|
+
e.Rt = e;
|
|
82
|
+
e.At = undefined;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
function markHeap(e) {
|
|
86
86
|
if (e.tE) return;
|
|
87
87
|
e.tE = true;
|
|
88
88
|
for (let E = 0; E <= e.EE; E++) {
|
|
89
|
-
for (let t = e.eE[E]; t !== undefined; t = t.
|
|
90
|
-
if (t.
|
|
89
|
+
for (let t = e.eE[E]; t !== undefined; t = t.At) {
|
|
90
|
+
if (t.ue & REACTIVE_IN_HEAP) markNode(t);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function markNode(e, E = REACTIVE_DIRTY) {
|
|
96
|
-
const t = e.
|
|
96
|
+
const t = e.ue;
|
|
97
97
|
if ((t & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= E) return;
|
|
98
|
-
e.
|
|
99
|
-
for (let E = e.u; E !== null; E = E.
|
|
100
|
-
markNode(E.
|
|
98
|
+
e.ue = t & -4 | E;
|
|
99
|
+
for (let E = e.u; E !== null; E = E.Ne) {
|
|
100
|
+
markNode(E._e, REACTIVE_CHECK);
|
|
101
101
|
}
|
|
102
102
|
// Firewall children (projection machinery only): gate the cold-extension
|
|
103
103
|
// deref on the config bit — markNode runs per sub edge per write, and an
|
|
104
104
|
// unconditional _x chase here taxed every propagation (diamond -22%).
|
|
105
105
|
if (e.T & CONFIG_FW_CHILDREN) {
|
|
106
|
-
for (let E = e.o.i; E !== null; E = E.
|
|
107
|
-
for (let e = E.u; e !== null; e = e.
|
|
108
|
-
markNode(e.
|
|
106
|
+
for (let E = e.o.i; E !== null; E = E.De) {
|
|
107
|
+
for (let e = E.u; e !== null; e = e.Ne) {
|
|
108
|
+
markNode(e._e, REACTIVE_CHECK);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -113,11 +113,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
|
|
|
113
113
|
|
|
114
114
|
function runHeap(e, E) {
|
|
115
115
|
e.tE = false;
|
|
116
|
-
for (e.
|
|
117
|
-
let t = e.eE[e.
|
|
116
|
+
for (e.et = 0; e.et <= e.EE; e.et++) {
|
|
117
|
+
let t = e.eE[e.et];
|
|
118
118
|
while (t !== undefined) {
|
|
119
|
-
if (t.
|
|
120
|
-
t = e.eE[e.
|
|
119
|
+
if (t.ue & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
|
|
120
|
+
t = e.eE[e.et];
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
e.EE = 0;
|
|
@@ -125,21 +125,21 @@ function runHeap(e, E) {
|
|
|
125
125
|
|
|
126
126
|
function adjustHeight(e, E) {
|
|
127
127
|
deleteFromHeap(e, E);
|
|
128
|
-
let t = e.
|
|
129
|
-
for (let E = e.
|
|
130
|
-
const e = E.
|
|
131
|
-
const n = e.
|
|
132
|
-
if (n.
|
|
128
|
+
let t = e.tt;
|
|
129
|
+
for (let E = e.Se; E; E = E.de) {
|
|
130
|
+
const e = E.Ee;
|
|
131
|
+
const n = e.Te || e;
|
|
132
|
+
if (n.ce && n.tt >= t) t = n.tt + 1;
|
|
133
133
|
}
|
|
134
|
-
if (e.
|
|
135
|
-
e.
|
|
136
|
-
for (let E = e.u; E !== null; E = E.
|
|
134
|
+
if (e.tt !== t) {
|
|
135
|
+
e.tt = t;
|
|
136
|
+
for (let E = e.u; E !== null; E = E.Ne) {
|
|
137
137
|
// Route each subscriber by its own zombie flag, mirroring the
|
|
138
138
|
// post-recompute height-adjust path. Inserting into the running `heap`
|
|
139
139
|
// unconditionally can park a zombie in `dirtyQueue` (or a live node in
|
|
140
140
|
// `zombieQueue`), breaking the flag/queue invariant `deleteFromHeap`
|
|
141
141
|
// relies on — the same corruption class as #2759.
|
|
142
|
-
insertIntoHeapHeight(E.
|
|
142
|
+
insertIntoHeapHeight(E._e, queueFor(E._e));
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|