@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/lanes.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CONFIG_HAS_LANE,
|
|
1
|
+
import { CONFIG_DERIVED_OVERRIDE, CONFIG_HAS_LANE, REACTIVE_DISPOSED } from "./constants.js";
|
|
2
2
|
|
|
3
|
-
import { ext } from "./core.js";
|
|
3
|
+
import { hasActiveOverride, ext, ownsHold, currentOptimisticLane } from "./core.js";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { enqueueSub } from "./heap.js";
|
|
6
|
+
|
|
7
|
+
import { currentTransition, activeTransition, waitingTransition } from "./scheduler.js";
|
|
6
8
|
|
|
7
9
|
// Map from optimistic signal to its lane (reused for multiple writes to same signal)
|
|
8
10
|
const signalLanes = new WeakMap;
|
|
@@ -20,16 +22,16 @@ const activeLanes = new Set;
|
|
|
20
22
|
}
|
|
21
23
|
// Detect parent lane: _parentSource chains from pendingSignal → pendingValueComputed → original.
|
|
22
24
|
// The child lane should not merge with the parent lane.
|
|
23
|
-
const i = n.o?.
|
|
24
|
-
const t = i?.o?.
|
|
25
|
+
const i = n.o?.Ht;
|
|
26
|
+
const t = i?.o?.Ue;
|
|
25
27
|
const r = t ? findLane(t) : null;
|
|
26
28
|
e = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
an: n,
|
|
30
|
+
ye: new Set,
|
|
31
|
+
fn: [ [], [] ],
|
|
32
|
+
cn: null,
|
|
33
|
+
Ge: activeTransition,
|
|
34
|
+
Ln: r
|
|
33
35
|
};
|
|
34
36
|
signalLanes.set(n, e);
|
|
35
37
|
activeLanes.add(e);
|
|
@@ -39,8 +41,8 @@ const activeLanes = new Set;
|
|
|
39
41
|
// parent-child is a property of the nodes, not of write order — otherwise
|
|
40
42
|
// the owner's write merges the companion's subscribers into this lane and
|
|
41
43
|
// their effects wait on its async instead of flushing immediately.
|
|
42
|
-
adoptCompanionLane(n.o?.
|
|
43
|
-
adoptCompanionLane(n.o?.
|
|
44
|
+
adoptCompanionLane(n.o?.je, e);
|
|
45
|
+
adoptCompanionLane(n.o?.xe, e);
|
|
44
46
|
return e;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -51,13 +53,13 @@ function adoptCompanionLane(n, e) {
|
|
|
51
53
|
const t = findLane(i);
|
|
52
54
|
// Only the companion's own unmerged root is safely re-parentable: a root
|
|
53
55
|
// that absorbed other lanes carries work that is not a child of this owner.
|
|
54
|
-
if (t !== e && t.
|
|
56
|
+
if (t !== e && t.an === n && !t.Ln) t.Ln = e;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Union-find: find the root lane.
|
|
59
61
|
*/ function findLane(n) {
|
|
60
|
-
while (n.
|
|
62
|
+
while (n.cn) n = n.cn;
|
|
61
63
|
return n;
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -77,38 +79,79 @@ function adoptCompanionLane(n, e) {
|
|
|
77
79
|
* the async the other member's transaction observed must hold the merged
|
|
78
80
|
* reveal just the same (A15 for lanes, #3335).
|
|
79
81
|
*/ function laneHeld(n) {
|
|
80
|
-
if (!n.
|
|
81
|
-
for (const e of n.
|
|
82
|
+
if (!n.Ge) return false;
|
|
83
|
+
for (const e of n.ye) if (waitingTransition(e) !== null) return true;
|
|
82
84
|
return false;
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Lanes mirror transitions (#3460): a render effect OFF a HELD lane that reads
|
|
89
|
+
* a value the lane is revealing — an override, a `latest()` shadow — sees the
|
|
90
|
+
* committed value, exactly as a stale reader of a held transaction does
|
|
91
|
+
* (A15 reveal corollary): it publishes now, with the frame that is on screen
|
|
92
|
+
* (the lane defers its own readers' runs, so the committed value is what is
|
|
93
|
+
* visible), entangles nothing — a sync write is never held by a lane — and
|
|
94
|
+
* re-derives at the release. The release re-run rides the lane's own render
|
|
95
|
+
* queue, which runs when the lane reveals (runLaneEffects) or its transaction
|
|
96
|
+
* commits (cleanupCompletedLanes). A reader ON the lane computes the lane's
|
|
97
|
+
* reveal and takes the value as before.
|
|
98
|
+
*
|
|
99
|
+
* OFF the lane is provenance, not membership — the transaction mirror
|
|
100
|
+
* exactly: a stale reader of a transaction is a pass that runs outside it. A
|
|
101
|
+
* pass under the lane's own transaction is the lane's work — its write (lane
|
|
102
|
+
* posture), or the landing of its async, which re-enters the transaction
|
|
103
|
+
* (#3334) and runs a member with no ambient lane. Read as an outsider, that
|
|
104
|
+
* pass published the committed view and queued a replay that revealed the
|
|
105
|
+
* override beside its unready derivation at the release (`1:0` for an
|
|
106
|
+
* optimistic frame that never became ready; #3479 review). Membership is the
|
|
107
|
+
* wrong test the other way: a member re-run by a sibling's sync write is a
|
|
108
|
+
* mainline pass and shows the committed view.
|
|
109
|
+
*/ function readsHeldCommitted(n, e) {
|
|
110
|
+
const i = resolveLane(n);
|
|
111
|
+
if (!i || !laneHeld(i)) return false;
|
|
112
|
+
if (ownsLane(i, n)) return false;
|
|
113
|
+
i.fn[0].push(() => e.ue & REACTIVE_DISPOSED || enqueueSub(e));
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The ownership relation for a lane hold (core `ownsHold`, §6 ruling 2): the
|
|
118
|
+
* running pass owns `lane`'s hold if it runs under the transition that owns
|
|
119
|
+
* the lane (the node's, resolved through override ownership and merges) or
|
|
120
|
+
* inside the lane itself. */ function ownsLane(n, e) {
|
|
121
|
+
if (activeTransition !== null) {
|
|
122
|
+
const n = resolveTransition(e);
|
|
123
|
+
if (n && ownsHold(n)) return true;
|
|
124
|
+
}
|
|
125
|
+
return currentOptimisticLane !== null && findLane(currentOptimisticLane) === n;
|
|
126
|
+
}
|
|
127
|
+
|
|
85
128
|
/**
|
|
86
129
|
* Merge two lanes when their dependency graphs overlap.
|
|
87
130
|
*/ function mergeLanes(n, e) {
|
|
88
131
|
n = findLane(n);
|
|
89
132
|
e = findLane(e);
|
|
90
133
|
if (n === e) return n;
|
|
91
|
-
e.
|
|
134
|
+
e.cn = n;
|
|
92
135
|
// Move (not copy) the merged lane's work: after the merge all routing goes
|
|
93
136
|
// through findLane() to the root, so anything left behind here is dead —
|
|
94
137
|
// and anything *added* here later is a routing bug (INV-5).
|
|
95
|
-
for (const i of e.
|
|
96
|
-
e.
|
|
97
|
-
n.
|
|
98
|
-
n.
|
|
99
|
-
e.
|
|
100
|
-
e.
|
|
138
|
+
for (const i of e.ye) n.ye.add(i);
|
|
139
|
+
e.ye.clear();
|
|
140
|
+
n.fn[0].push(...e.fn[0]);
|
|
141
|
+
n.fn[1].push(...e.fn[1]);
|
|
142
|
+
e.fn[0].length = 0;
|
|
143
|
+
e.fn[1].length = 0;
|
|
101
144
|
return n;
|
|
102
145
|
}
|
|
103
146
|
|
|
104
147
|
/**
|
|
105
148
|
* Resolve a node's lane: follow union-find chain, verify active, clear if stale.
|
|
106
149
|
*/ function resolveLane(n) {
|
|
107
|
-
const e = n.o?.
|
|
150
|
+
const e = n.o?.Ue;
|
|
108
151
|
if (!e) return undefined;
|
|
109
152
|
const i = findLane(e);
|
|
110
153
|
if (activeLanes.has(i)) return i;
|
|
111
|
-
if (n.o !== null) n.o.
|
|
154
|
+
if (n.o !== null) n.o.Ue = undefined;
|
|
112
155
|
return undefined;
|
|
113
156
|
}
|
|
114
157
|
|
|
@@ -118,19 +161,12 @@ function resolveTransition(n) {
|
|
|
118
161
|
// transactions (#2912) — the merged root's _transition would hand this
|
|
119
162
|
// node's override to whichever action wrote last through the shared
|
|
120
163
|
// reader. Chase merge chains; a dead owner settled through another path.
|
|
121
|
-
if (hasActiveOverride(n) && n.o?.
|
|
122
|
-
const e = ext(n).
|
|
123
|
-
if (e.
|
|
124
|
-
if (n.o !== null) n.o.
|
|
164
|
+
if (hasActiveOverride(n) && n.o?.Ft) {
|
|
165
|
+
const e = ext(n).Ft = currentTransition(n.o?.Ft);
|
|
166
|
+
if (e.Tt !== true) return e;
|
|
167
|
+
if (n.o !== null) n.o.Ft = null;
|
|
125
168
|
}
|
|
126
|
-
return resolveLane(n)?.
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Check if a node has an active optimistic override.
|
|
131
|
-
*/ function hasActiveOverride(n) {
|
|
132
|
-
const e = n.o;
|
|
133
|
-
return e !== null && e.be !== undefined && e.be !== NOT_PENDING;
|
|
169
|
+
return resolveLane(n)?.Ge ?? n.Ge;
|
|
134
170
|
}
|
|
135
171
|
|
|
136
172
|
/**
|
|
@@ -138,31 +174,32 @@ function resolveTransition(n) {
|
|
|
138
174
|
* a different active lane), merge unless the node has an active override.
|
|
139
175
|
*/ function assignOrMergeLane(n, e) {
|
|
140
176
|
const i = findLane(e);
|
|
141
|
-
const t = n.o?.
|
|
177
|
+
const t = n.o?.Ue;
|
|
142
178
|
if (t) {
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
// (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
179
|
+
// A merged lane is followed to its root like any other: the root is where
|
|
180
|
+
// the subscriber's affinity lives now. Replacing it with the source lane
|
|
181
|
+
// outright (as this once did) skipped the parent/child check below — an
|
|
182
|
+
// isPending reader of two async siblings had their two companion lanes
|
|
183
|
+
// merge, and the next parent-lane notification then moved it onto the
|
|
184
|
+
// held parent, where its verdict waited on the async it reports (#3409).
|
|
151
185
|
const r = findLane(t);
|
|
152
186
|
if (activeLanes.has(r)) {
|
|
153
|
-
|
|
187
|
+
// A WRITTEN override is its own lane's source and merges nothing
|
|
188
|
+
// through it; a derived one (lanes stage, #3479) is a plain member —
|
|
189
|
+
// the shared reader that merges two writers' lanes carries one.
|
|
190
|
+
if (r !== i && (!hasActiveOverride(n) || n.T & CONFIG_DERIVED_OVERRIDE)) {
|
|
154
191
|
// Parent-child lanes stay independent so isPending resolves without
|
|
155
192
|
// waiting for the parent's async. The child keeps ownership.
|
|
156
|
-
if (i.
|
|
157
|
-
ext(n).
|
|
193
|
+
if (i.Ln && findLane(i.Ln) === r) {
|
|
194
|
+
ext(n).Ue = e;
|
|
158
195
|
n.T |= CONFIG_HAS_LANE;
|
|
159
|
-
} else if (r.
|
|
196
|
+
} else if (r.Ln && findLane(r.Ln) === i) ; else mergeLanes(i, r);
|
|
160
197
|
}
|
|
161
198
|
return;
|
|
162
199
|
}
|
|
163
200
|
}
|
|
164
|
-
ext(n).
|
|
201
|
+
ext(n).Ue = e;
|
|
165
202
|
n.T |= CONFIG_HAS_LANE;
|
|
166
203
|
}
|
|
167
204
|
|
|
168
|
-
export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, laneHeld, mergeLanes, resolveLane, resolveTransition, signalLanes };
|
|
205
|
+
export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, laneHeld, mergeLanes, ownsLane, readsHeldCommitted, resolveLane, resolveTransition, signalLanes };
|