@solidjs/signals 2.0.0-rc.15 → 2.0.0-rc.17
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 +2268 -1734
- package/dist/dev.attribution.js +75 -52
- package/dist/dev.js +1348 -658
- package/dist/observe/affects-marks.js +86 -0
- package/dist/observe/affects.js +22 -73
- package/dist/observe/boundaries.js +192 -190
- package/dist/observe/core/async.js +177 -131
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +176 -159
- package/dist/observe/core/constants.js +17 -3
- package/dist/observe/core/context.js +5 -3
- package/dist/observe/core/core.js +520 -364
- package/dist/observe/core/dev.js +66 -38
- package/dist/observe/core/effect.js +50 -48
- package/dist/observe/core/error.js +5 -3
- package/dist/observe/core/external.js +5 -6
- package/dist/observe/core/graph.js +60 -44
- package/dist/observe/core/heap.js +33 -33
- package/dist/observe/core/identities.js +62 -0
- package/dist/observe/core/lanes.js +238 -260
- package/dist/observe/core/owner.js +117 -79
- package/dist/observe/core/scheduler.js +381 -217
- package/dist/observe/core/truth.js +45 -0
- package/dist/observe/core/verdict.js +91 -50
- package/dist/observe/deferred.js +184 -0
- package/dist/observe/index.js +7 -1
- package/dist/observe/map.js +345 -260
- package/dist/observe/reveal.js +76 -76
- package/dist/observe/signals.js +47 -31
- package/dist/observe/store/affects.js +18 -18
- package/dist/observe/store/edges.js +39 -0
- package/dist/observe/store/optimistic.js +146 -100
- package/dist/observe/store/projection.js +68 -55
- package/dist/observe/store/store.js +180 -118
- package/dist/prod/affects-marks.js +86 -0
- package/dist/prod/affects.js +23 -72
- package/dist/prod/boundaries.js +156 -154
- package/dist/prod/core/async.js +173 -127
- package/dist/prod/core/constants.js +17 -3
- package/dist/prod/core/context.js +5 -3
- package/dist/prod/core/core.js +495 -343
- package/dist/prod/core/effect.js +70 -68
- package/dist/prod/core/error.js +5 -3
- package/dist/prod/core/external.js +5 -6
- package/dist/prod/core/graph.js +60 -44
- package/dist/prod/core/heap.js +38 -38
- package/dist/prod/core/identities.js +62 -0
- package/dist/prod/core/lanes.js +230 -252
- package/dist/prod/core/owner.js +114 -77
- package/dist/prod/core/scheduler.js +327 -163
- package/dist/prod/core/truth.js +45 -0
- package/dist/prod/core/verdict.js +90 -49
- package/dist/prod/deferred.js +182 -0
- package/dist/prod/index.js +7 -1
- package/dist/prod/map.js +360 -275
- package/dist/prod/reveal.js +76 -76
- package/dist/prod/signals.js +42 -26
- package/dist/prod/store/affects.js +6 -6
- package/dist/prod/store/edges.js +39 -0
- package/dist/prod/store/optimistic.js +143 -98
- package/dist/prod/store/projection.js +25 -19
- package/dist/prod/store/store.js +157 -100
- package/dist/types/affects-marks.d.ts +14 -0
- package/dist/types/boundaries.d.ts +1 -1
- package/dist/types/core/async.d.ts +10 -0
- package/dist/types/core/constants.d.ts +13 -1
- package/dist/types/core/core.d.ts +54 -5
- package/dist/types/core/dev.d.ts +51 -13
- package/dist/types/core/error.d.ts +9 -1
- package/dist/types/core/graph.d.ts +11 -0
- package/dist/types/core/identities.d.ts +17 -0
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/lanes.d.ts +2 -14
- package/dist/types/core/owner.d.ts +9 -3
- package/dist/types/core/scheduler.d.ts +70 -32
- package/dist/types/core/truth.d.ts +16 -0
- package/dist/types/core/types.d.ts +21 -0
- package/dist/types/core/verdict.d.ts +32 -0
- package/dist/types/deferred.d.ts +28 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/map.d.ts +2 -2
- package/dist/types/signals.d.ts +28 -7
- package/dist/types/store/edges.d.ts +9 -0
- package/dist/types/store/index.d.ts +10 -3
- package/dist/types/store/optimistic.d.ts +3 -2
- package/dist/types/store/projection.d.ts +4 -3
- package/dist/types/store/store.d.ts +1 -1
- package/dist/types/store/target.d.ts +16 -8
- package/dist/types/store/types.d.ts +14 -0
- package/package.json +1 -1
|
@@ -11,22 +11,22 @@ import { dirtyQueue } from "./scheduler.js";
|
|
|
11
11
|
* callback to the user queue once the pass has committed (see
|
|
12
12
|
* GlobalQueue._update, #3291).
|
|
13
13
|
*/ function enqueueSub(e) {
|
|
14
|
-
if (dirtyQueue.
|
|
14
|
+
if (dirtyQueue.st > e.Et) dirtyQueue.st = e.Et;
|
|
15
15
|
insertIntoHeap(e, dirtyQueue);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function actualInsertIntoHeap(e, t) {
|
|
19
|
-
const E = (e._parent?.
|
|
20
|
-
if (E >= e.
|
|
21
|
-
const n = e.
|
|
22
|
-
const I = t.
|
|
23
|
-
if (I === undefined) t.
|
|
19
|
+
const E = (e._parent?.Pt ? e._parent.Ht?.Et : e._parent?.Et) ?? -1;
|
|
20
|
+
if (E >= e.Et) e.Et = E + 1;
|
|
21
|
+
const n = e.Et;
|
|
22
|
+
const I = t.gt[n];
|
|
23
|
+
if (I === undefined) t.gt[n] = e; else {
|
|
24
24
|
const t = I.Rt;
|
|
25
|
-
t.
|
|
25
|
+
t.At = e;
|
|
26
26
|
e.Rt = t;
|
|
27
27
|
I.Rt = e;
|
|
28
28
|
}
|
|
29
|
-
if (n > t.
|
|
29
|
+
if (n > t.jt) t.jt = n;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function insertIntoHeap(e, t) {
|
|
@@ -49,7 +49,7 @@ function insertIntoHeap(e, t) {
|
|
|
49
49
|
// parked in the heap for a synchronous mount (each row writing a ref
|
|
50
50
|
// signal its effect subscribes to), mounting N rows was O(N²) (#3350).
|
|
51
51
|
// markNode's own guard skips an already-DIRTY node.
|
|
52
|
-
if (t.
|
|
52
|
+
if (t.p) markNode(e);
|
|
53
53
|
}
|
|
54
54
|
if (!(E & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
|
|
55
55
|
}
|
|
@@ -65,23 +65,23 @@ function deleteFromHeap(e, t) {
|
|
|
65
65
|
const E = e.R;
|
|
66
66
|
if (!(E & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
67
67
|
e.R = E & -25;
|
|
68
|
-
const n = e.
|
|
69
|
-
if (e.Rt === e) t.
|
|
70
|
-
const E = e.
|
|
71
|
-
const I = t.
|
|
68
|
+
const n = e.Et;
|
|
69
|
+
if (e.Rt === e) t.gt[n] = undefined; else {
|
|
70
|
+
const E = e.At;
|
|
71
|
+
const I = t.gt[n];
|
|
72
72
|
const i = E ?? I;
|
|
73
|
-
if (e === I) t.
|
|
73
|
+
if (e === I) t.gt[n] = E; else e.Rt.At = E;
|
|
74
74
|
i.Rt = e.Rt;
|
|
75
75
|
}
|
|
76
76
|
e.Rt = e;
|
|
77
|
-
e.
|
|
77
|
+
e.At = undefined;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
function markHeap(e) {
|
|
81
|
-
if (e.
|
|
82
|
-
e.
|
|
83
|
-
for (let t = 0; t <= e.
|
|
84
|
-
for (let E = e.
|
|
81
|
+
if (e.p) return;
|
|
82
|
+
e.p = true;
|
|
83
|
+
for (let t = 0; t <= e.jt; t++) {
|
|
84
|
+
for (let E = e.gt[t]; E !== undefined; E = E.At) {
|
|
85
85
|
if (E.R & REACTIVE_IN_HEAP) markNode(E);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -91,33 +91,33 @@ function markNode(e, t = REACTIVE_DIRTY) {
|
|
|
91
91
|
const E = e.R;
|
|
92
92
|
if ((E & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
93
93
|
e.R = E & -4 | t;
|
|
94
|
-
for (let t = e.
|
|
95
|
-
markNode(t.
|
|
94
|
+
for (let t = e.o; t !== null; t = t.t) {
|
|
95
|
+
markNode(t.u, REACTIVE_CHECK);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function runHeap(e, t) {
|
|
100
|
-
e.
|
|
101
|
-
for (e.
|
|
102
|
-
let E = e.
|
|
100
|
+
e.p = false;
|
|
101
|
+
for (e.st = 0; e.st <= e.jt; e.st++) {
|
|
102
|
+
let E = e.gt[e.st];
|
|
103
103
|
while (E !== undefined) {
|
|
104
104
|
if (E.R & REACTIVE_IN_HEAP) t(E); else adjustHeight(E, e);
|
|
105
|
-
E = e.
|
|
105
|
+
E = e.gt[e.st];
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
e.
|
|
108
|
+
e.jt = 0;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
function adjustHeight(e, t) {
|
|
112
112
|
deleteFromHeap(e, t);
|
|
113
|
-
let E = e.
|
|
114
|
-
for (let t = e.
|
|
115
|
-
const e = t.
|
|
116
|
-
if (e.
|
|
113
|
+
let E = e.Et;
|
|
114
|
+
for (let t = e.C; t; t = t.G) {
|
|
115
|
+
const e = t.S;
|
|
116
|
+
if (e.X && e.Et >= E) E = e.Et + 1;
|
|
117
117
|
}
|
|
118
|
-
if (e.
|
|
119
|
-
e.
|
|
120
|
-
for (let E = e.
|
|
118
|
+
if (e.Et !== E) {
|
|
119
|
+
e.Et = E;
|
|
120
|
+
for (let E = e.o; E !== null; E = E.t) insertIntoHeapHeight(E.u, t);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CONFIG_TRANSPARENT } from "./constants.js";
|
|
2
|
+
|
|
3
|
+
import "./dev.js";
|
|
4
|
+
|
|
5
|
+
import { getOwner } from "./owner.js";
|
|
6
|
+
|
|
7
|
+
// Deferred hydration, dependency edges: plain-signal identities.
|
|
8
|
+
// While on (`setSignalIdentities`; the server-components client turns it on
|
|
9
|
+
// before hydrating), a plain signal created under an id-bearing owner is
|
|
10
|
+
// named `<owner id>~<n>`, n counting the plain signals (and plain store
|
|
11
|
+
// roots: `createStore` over an object, store/edges.ts) created under that
|
|
12
|
+
// owner in its current pass (transparent owners defer to the nearest
|
|
13
|
+
// id-bearing one, as child ids do). The server names the same signal the
|
|
14
|
+
// same way and restarts the count on every re-run, so an edge it shipped (a
|
|
15
|
+
// slot fill read it) matches the client node; the write hook receives the
|
|
16
|
+
// node and looks its name up (`signalName`). The count restarts when the owner's pass
|
|
17
|
+
// generation (`_depGen`, bumped by every recompute) moves on. Only the
|
|
18
|
+
// frames client imports this module, so nothing here ships without it.
|
|
19
|
+
// Names live in a side table, not on the node: frames reads them across the
|
|
20
|
+
// package boundary, where a mangled field would not survive.
|
|
21
|
+
let counts = null;
|
|
22
|
+
|
|
23
|
+
const names = new WeakMap;
|
|
24
|
+
|
|
25
|
+
/** @internal The identity of a plain signal named while identities were on. */ function signalName(n) {
|
|
26
|
+
return n === undefined ? undefined : names.get(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function identify(n) {
|
|
30
|
+
let e = getOwner();
|
|
31
|
+
if (!e) return;
|
|
32
|
+
while (e.l & CONFIG_TRANSPARENT && e._parent) e = e._parent;
|
|
33
|
+
if (e.id == null) return;
|
|
34
|
+
const t = e.Ne;
|
|
35
|
+
let i = counts.get(e);
|
|
36
|
+
if (i === undefined || i[0] !== t) counts.set(e, i = [ t, 0 ]);
|
|
37
|
+
const s = e.id + "~" + i[1]++;
|
|
38
|
+
// A store root named twice (one object made into two stores, or a store
|
|
39
|
+
// handed to `createStore`) is one target under two server names: its
|
|
40
|
+
// writes cannot be attributed (an empty name).
|
|
41
|
+
names.set(n, names.has(n) ? "" : s);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @internal Name plain signals from now on (`on`), or stop. */ function setSignalIdentities(n) {
|
|
45
|
+
counts = n ? counts || new WeakMap : null;
|
|
46
|
+
signalHook = n ? identify : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @internal Called with every plain signal `createSignal` makes, and every
|
|
51
|
+
* plain store root `createStore` makes, while set (the namer above). Never
|
|
52
|
+
* set unless `setSignalIdentities` is imported, so a bundle without it keeps
|
|
53
|
+
* only a null check.
|
|
54
|
+
*/ let signalHook = null;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @internal Dev only: `watch` is called with every node read while set (the
|
|
58
|
+
* dev hook `onRead`) — the frames client's identity-drift check watches the
|
|
59
|
+
* named signals a deferred occurrence reads as it mounts. A no-op in prod.
|
|
60
|
+
*/ function setReadWatch(n) {}
|
|
61
|
+
|
|
62
|
+
export { setReadWatch, setSignalIdentities, signalHook, signalName };
|