@solidjs/signals 2.0.0-rc.7 → 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 +6357 -0
- package/dist/dev.attribution.js +2485 -0
- package/dist/dev.js +2851 -7027
- package/dist/observe/affects.js +129 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +641 -0
- package/dist/observe/core/action.js +177 -0
- package/dist/observe/core/async.js +846 -0
- 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 +82 -0
- package/dist/observe/core/attribution-queries.js +28 -0
- package/dist/observe/core/attribution.js +2095 -0
- package/dist/observe/core/constants.js +248 -0
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1789 -0
- package/dist/observe/core/dev.js +293 -0
- package/dist/observe/core/effect.js +195 -0
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/error.js +80 -0
- package/dist/observe/core/external.js +98 -0
- package/dist/observe/core/graph.js +155 -0
- package/dist/observe/core/heap.js +147 -0
- package/dist/observe/core/invariants.js +45 -0
- package/dist/observe/core/lanes.js +205 -0
- package/dist/observe/core/optimistic.js +585 -0
- package/dist/observe/core/owner.js +322 -0
- package/dist/observe/core/scheduler.js +1428 -0
- package/dist/observe/core/verdict.js +669 -0
- package/dist/observe/index.js +59 -0
- package/dist/observe/map.js +484 -0
- package/dist/{types-cjs/signals.d.cts → observe/signals.js} +311 -317
- package/dist/observe/store/index.js +40 -0
- package/dist/observe/store/next/optimistic.js +660 -0
- package/dist/observe/store/next/projection.js +255 -0
- package/dist/observe/store/next/reconcile.js +375 -0
- package/dist/observe/store/next/store.js +2327 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +325 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +1023 -0
- package/dist/prod/attribution.js +41 -0
- package/dist/prod/boundaries.js +128 -76
- package/dist/prod/core/action.js +65 -37
- package/dist/prod/core/async.js +324 -172
- package/dist/prod/core/constants.js +57 -1
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +1003 -364
- package/dist/prod/core/dev.js +17 -1
- package/dist/prod/core/effect.js +76 -42
- 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 +61 -56
- package/dist/prod/core/lanes.js +107 -63
- package/dist/prod/core/optimistic.js +374 -93
- package/dist/prod/core/owner.js +62 -46
- package/dist/prod/core/scheduler.js +653 -286
- package/dist/prod/core/verdict.js +245 -127
- package/dist/prod/index.js +15 -5
- package/dist/prod/map.js +292 -141
- package/dist/prod/signals.js +29 -16
- package/dist/prod/store/next/optimistic.js +77 -55
- package/dist/prod/store/next/projection.js +31 -20
- package/dist/prod/store/next/reconcile.js +87 -84
- package/dist/prod/store/next/store.js +718 -401
- package/dist/prod/store/next/target.js +32 -10
- package/dist/prod/store/store.js +12 -14
- package/dist/prod/store/utils.js +950 -130
- package/dist/types/attribution.d.ts +20 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +10 -1
- package/dist/types/core/action.d.ts +12 -5
- package/dist/types/core/async.d.ts +1 -1
- 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 +147 -9
- package/dist/types/core/attribution-queries.d.ts +10 -0
- package/dist/types/core/attribution.d.ts +216 -182
- package/dist/types/core/constants.d.ts +56 -0
- package/dist/types/core/core.d.ts +190 -2
- package/dist/types/core/dev.d.ts +246 -28
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/index.d.ts +4 -1
- package/dist/types/core/invariants.d.ts +4 -0
- package/dist/types/core/lanes.d.ts +39 -5
- package/dist/types/core/scheduler.d.ts +153 -0
- package/dist/types/core/types.d.ts +32 -9
- package/dist/types/index.d.ts +10 -3
- package/dist/types/map.d.ts +2 -0
- package/dist/types/signals.d.ts +8 -0
- package/dist/types/store/index.d.ts +2 -0
- package/dist/types/store/next/optimistic.d.ts +1 -1
- package/dist/types/store/next/store.d.ts +11 -5
- package/dist/types/store/next/target.d.ts +37 -10
- package/dist/types/store/utils.d.ts +178 -0
- package/package.json +21 -17
- package/dist/node.cjs +0 -10541
- package/dist/node.dev.cjs +0 -13724
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -23
- package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
- package/dist/types-cjs/core/attribution.d.cts +0 -495
- package/dist/types-cjs/core/constants.d.cts +0 -159
- package/dist/types-cjs/core/core.d.cts +0 -185
- package/dist/types-cjs/core/dev.d.cts +0 -136
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -56
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -28
- package/dist/types-cjs/core/heap.d.cts +0 -24
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -54
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -236
- package/dist/types-cjs/core/types.d.cts +0 -204
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/store/index.d.cts +0 -18
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
- package/dist/types-cjs/store/next/store.d.cts +0 -121
- package/dist/types-cjs/store/next/target.d.cts +0 -166
- package/dist/types-cjs/store/store.d.cts +0 -143
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -74
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) {
|
|
@@ -243,30 +255,34 @@ function disposeRootSelf(e = true) {
|
|
|
243
255
|
*/ function createOwner(e) {
|
|
244
256
|
const t = context;
|
|
245
257
|
const n = e?.transparent ?? false;
|
|
246
|
-
|
|
258
|
+
// Prod and observe boilerplates (see core.ts computed()). The observe
|
|
259
|
+
// literal carries the `_name` slot the rendering layer fills with the
|
|
260
|
+
// component label (`owner._name = "<App>"`) — a slot, so labelling a root
|
|
261
|
+
// is a plain store rather than a shape fork between labelled and plain roots.
|
|
262
|
+
const i = {
|
|
247
263
|
id: inheritId(e, n, t),
|
|
248
264
|
T: n ? CONFIG_TRANSPARENT : 0,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
265
|
+
xt: true,
|
|
266
|
+
Qt: t?.xt ? t.Qt : t,
|
|
267
|
+
Xe: null,
|
|
268
|
+
$e: null,
|
|
269
|
+
Dt: null,
|
|
270
|
+
ke: null,
|
|
255
271
|
C: t?.C ?? globalQueue,
|
|
256
|
-
|
|
257
|
-
|
|
272
|
+
ze: t?.ze || defaultContext,
|
|
273
|
+
ut: 0,
|
|
258
274
|
o: null,
|
|
259
|
-
|
|
275
|
+
_parent: t,
|
|
260
276
|
dispose: disposeRootSelf
|
|
261
277
|
};
|
|
262
278
|
if (t) {
|
|
263
|
-
const e = t.
|
|
279
|
+
const e = t.Xe;
|
|
264
280
|
if (e === null) {
|
|
265
|
-
t.
|
|
281
|
+
t.Xe = i;
|
|
266
282
|
} else {
|
|
267
|
-
i
|
|
268
|
-
e.
|
|
269
|
-
t.
|
|
283
|
+
i.$e = e;
|
|
284
|
+
e.Dt = i;
|
|
285
|
+
t.Xe = i;
|
|
270
286
|
}
|
|
271
287
|
}
|
|
272
288
|
return i;
|