@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/owner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { REACTIVE_DISPOSED, CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, CONFIG_TRANSPARENT, defaultContext } from "./constants.js";
|
|
1
|
+
import { REACTIVE_DISPOSED, CONFIG_CHILD_COMPANIONS, STATUS_PENDING, CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, CONFIG_TRANSPARENT, defaultContext } from "./constants.js";
|
|
2
2
|
|
|
3
3
|
import { context, runWithOwner, pendingCheckActive, latestReadActive, tracking } from "./core.js";
|
|
4
4
|
|
|
@@ -6,16 +6,16 @@ import { clearDeps, unobserved } from "./graph.js";
|
|
|
6
6
|
|
|
7
7
|
import { deleteFromHeap, queueFor, insertIntoHeap, insertIntoHeapHeight } from "./heap.js";
|
|
8
8
|
|
|
9
|
-
import { GlobalQueue, zombieQueue, dirtyQueue, globalQueue } from "./scheduler.js";
|
|
9
|
+
import { GlobalQueue, wokenTransitions, schedule, zombieQueue, dirtyQueue, globalQueue } from "./scheduler.js";
|
|
10
10
|
|
|
11
11
|
const PENDING_OWNER = {};
|
|
12
12
|
|
|
13
13
|
// Dummy owner to trigger store's read() path
|
|
14
14
|
function markDisposal(e) {
|
|
15
|
-
let t = e.
|
|
15
|
+
let t = e.Xe;
|
|
16
16
|
while (t) {
|
|
17
|
-
const e = t.
|
|
18
|
-
t.
|
|
17
|
+
const e = t.ue;
|
|
18
|
+
t.ue = e | REACTIVE_ZOMBIE;
|
|
19
19
|
// migrate height-adjust entries too, not just recompute entries: every
|
|
20
20
|
// `deleteFromHeap` call site picks the queue from the zombie flag, so a
|
|
21
21
|
// node left physically linked in `dirtyQueue` after being zombified gets
|
|
@@ -26,7 +26,7 @@ function markDisposal(e) {
|
|
|
26
26
|
if (e & REACTIVE_IN_HEAP) insertIntoHeap(t, zombieQueue); else insertIntoHeapHeight(t, zombieQueue);
|
|
27
27
|
}
|
|
28
28
|
markDisposal(t);
|
|
29
|
-
t = t
|
|
29
|
+
t = t.$e;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -42,22 +42,34 @@ function dispose(e) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function disposeChildren(e, t = false, n) {
|
|
45
|
-
const i = e.
|
|
45
|
+
const i = e.ue;
|
|
46
46
|
if (i & REACTIVE_DISPOSED) return;
|
|
47
47
|
if (t) {
|
|
48
|
-
e.
|
|
48
|
+
e.ue = i | REACTIVE_DISPOSED;
|
|
49
49
|
// Companions are created detached and outlive their owner, but a verdict
|
|
50
50
|
// must not: a disposed source can never settle, so an isPending companion
|
|
51
51
|
// latched `true` here would hold a spinner forever (INV-9, the PR #2845
|
|
52
52
|
// edge). Snap runs after the DISPOSED flag is set so the oracle reads
|
|
53
53
|
// false, and notifies subscribers still watching the companion.
|
|
54
54
|
const t = e;
|
|
55
|
-
if (t.o?.
|
|
55
|
+
if (t.o?.je || t.o?.xe) GlobalQueue.En(t);
|
|
56
|
+
// A firewall's leaves have no lifecycle of their own, so a companion on
|
|
57
|
+
// one of them outlives its source the same way (INV-9's rationale). The
|
|
58
|
+
// firewall knows which leaves carry companions (CONFIG_CHILD_COMPANIONS,
|
|
59
|
+
// #3038): snap them with it — the snap retires a shadow whose firewall is
|
|
60
|
+
// disposed (spec O5).
|
|
61
|
+
if (t.T & CONFIG_CHILD_COMPANIONS) t.o.bt.forEach(GlobalQueue.En);
|
|
62
|
+
// A pending reader parked in a transaction may be the only thing holding
|
|
63
|
+
// it (#3372): its death is a completion event the transaction must be
|
|
64
|
+
// re-judged for, and nothing else re-enters a parked transaction.
|
|
65
|
+
const n = t.Ge;
|
|
66
|
+
if (n && t.S & STATUS_PENDING && !wokenTransitions.includes(n)) wokenTransitions.push(n),
|
|
67
|
+
schedule();
|
|
56
68
|
}
|
|
57
|
-
if (t && e.
|
|
58
|
-
let o = n ? e.o?.
|
|
69
|
+
if (t && e.ce && e.o !== null) e.o.Re = null;
|
|
70
|
+
let o = n ? e.o?.lt ?? null : e.Xe;
|
|
59
71
|
while (o) {
|
|
60
|
-
const e = o
|
|
72
|
+
const e = o.$e;
|
|
61
73
|
const t = o;
|
|
62
74
|
// Owner teardown is death regardless of the child's own lifecycle
|
|
63
75
|
// (#3024): strip AUTO_DISPOSE so a post-disposal read freezes at the
|
|
@@ -80,34 +92,34 @@ function disposeChildren(e, t = false, n) {
|
|
|
80
92
|
o = e;
|
|
81
93
|
}
|
|
82
94
|
if (n) {
|
|
83
|
-
if (e.o !== null) e.o.
|
|
95
|
+
if (e.o !== null) e.o.lt = null;
|
|
84
96
|
} else {
|
|
85
|
-
e.
|
|
86
|
-
e
|
|
97
|
+
e.Xe = null;
|
|
98
|
+
e.ut = 0;
|
|
87
99
|
}
|
|
88
100
|
// O(1) splice out of parent's chain on individual dispose. Skipped during
|
|
89
101
|
// batch dispose (parent already disposed) and zombie disposal (node sits on
|
|
90
102
|
// parent's _pendingFirstChild). We leave node._nextSibling intact so outer
|
|
91
103
|
// walks that already advanced past us still reach later siblings.
|
|
92
|
-
if (t && !n && !(i & REACTIVE_ZOMBIE) && e.
|
|
93
|
-
const t = e.
|
|
94
|
-
const n = e
|
|
95
|
-
if (t !== null) t
|
|
96
|
-
if (n !== null) n.
|
|
97
|
-
e.
|
|
104
|
+
if (t && !n && !(i & REACTIVE_ZOMBIE) && e._parent !== null && !(e._parent.ue & REACTIVE_DISPOSED)) {
|
|
105
|
+
const t = e.Dt;
|
|
106
|
+
const n = e.$e;
|
|
107
|
+
if (t !== null) t.$e = n; else e._parent.Xe = n;
|
|
108
|
+
if (n !== null) n.Dt = t;
|
|
109
|
+
e.Dt = null;
|
|
98
110
|
}
|
|
99
111
|
runDisposal(e, n);
|
|
100
112
|
// Final effect-returned cleanup fires at true disposal, after `_disposal`
|
|
101
113
|
// to mirror rerun ordering (compute-phase teardown first, cleanup last).
|
|
102
|
-
if (t && e.
|
|
103
|
-
const t = e.
|
|
104
|
-
e.
|
|
114
|
+
if (t && e.yt) {
|
|
115
|
+
const t = e.yt;
|
|
116
|
+
e.yt = undefined;
|
|
105
117
|
t();
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
|
|
109
121
|
function runDisposal(e, t) {
|
|
110
|
-
let n = t ? e.o?.
|
|
122
|
+
let n = t ? e.o?.it : e.ke;
|
|
111
123
|
if (!n) return;
|
|
112
124
|
if (Array.isArray(n)) {
|
|
113
125
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -118,14 +130,14 @@ function runDisposal(e, t) {
|
|
|
118
130
|
n.call(n);
|
|
119
131
|
}
|
|
120
132
|
if (t) {
|
|
121
|
-
if (e.o !== null) e.o.
|
|
122
|
-
} else e.
|
|
133
|
+
if (e.o !== null) e.o.it = null;
|
|
134
|
+
} else e.ke = null;
|
|
123
135
|
}
|
|
124
136
|
|
|
125
137
|
function childId(e, t) {
|
|
126
138
|
let n = e;
|
|
127
|
-
while (n.T & CONFIG_TRANSPARENT && n.
|
|
128
|
-
if (n.id != null) return formatId(n.id, t ? n
|
|
139
|
+
while (n.T & CONFIG_TRANSPARENT && n._parent) n = n._parent;
|
|
140
|
+
if (n.id != null) return formatId(n.id, t ? n.ut++ : n.ut);
|
|
129
141
|
throw new Error("");
|
|
130
142
|
}
|
|
131
143
|
|
|
@@ -206,7 +218,7 @@ function formatId(e, t) {
|
|
|
206
218
|
* checks. `cleanup()` is the unchecked primitive used by internals.
|
|
207
219
|
*/ function cleanup(e) {
|
|
208
220
|
if (!context) return e;
|
|
209
|
-
if (!context.
|
|
221
|
+
if (!context.ke) context.ke = e; else if (Array.isArray(context.ke)) context.ke.push(e); else context.ke = [ context.ke, e ];
|
|
210
222
|
return e;
|
|
211
223
|
}
|
|
212
224
|
|
|
@@ -226,7 +238,7 @@ function formatId(e, t) {
|
|
|
226
238
|
* }
|
|
227
239
|
* ```
|
|
228
240
|
*/ function isDisposed(e) {
|
|
229
|
-
return !!(e.
|
|
241
|
+
return !!(e.ue & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE));
|
|
230
242
|
}
|
|
231
243
|
|
|
232
244
|
function disposeRootSelf(e = true) {
|
|
@@ -250,27 +262,27 @@ function disposeRootSelf(e = true) {
|
|
|
250
262
|
const i = {
|
|
251
263
|
id: inheritId(e, n, t),
|
|
252
264
|
T: n ? CONFIG_TRANSPARENT : 0,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
265
|
+
xt: true,
|
|
266
|
+
Qt: t?.xt ? t.Qt : t,
|
|
267
|
+
Xe: null,
|
|
268
|
+
$e: null,
|
|
269
|
+
Dt: null,
|
|
270
|
+
ke: null,
|
|
259
271
|
C: t?.C ?? globalQueue,
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
ze: t?.ze || defaultContext,
|
|
273
|
+
ut: 0,
|
|
262
274
|
o: null,
|
|
263
|
-
|
|
275
|
+
_parent: t,
|
|
264
276
|
dispose: disposeRootSelf
|
|
265
277
|
};
|
|
266
278
|
if (t) {
|
|
267
|
-
const e = t.
|
|
279
|
+
const e = t.Xe;
|
|
268
280
|
if (e === null) {
|
|
269
|
-
t.
|
|
281
|
+
t.Xe = i;
|
|
270
282
|
} else {
|
|
271
|
-
i
|
|
272
|
-
e.
|
|
273
|
-
t.
|
|
283
|
+
i.$e = e;
|
|
284
|
+
e.Dt = i;
|
|
285
|
+
t.Xe = i;
|
|
274
286
|
}
|
|
275
287
|
}
|
|
276
288
|
return i;
|