@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.
Files changed (90) hide show
  1. package/dist/dev-shared.js +2268 -1734
  2. package/dist/dev.attribution.js +75 -52
  3. package/dist/dev.js +1348 -658
  4. package/dist/observe/affects-marks.js +86 -0
  5. package/dist/observe/affects.js +22 -73
  6. package/dist/observe/boundaries.js +192 -190
  7. package/dist/observe/core/async.js +177 -131
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +176 -159
  10. package/dist/observe/core/constants.js +17 -3
  11. package/dist/observe/core/context.js +5 -3
  12. package/dist/observe/core/core.js +520 -364
  13. package/dist/observe/core/dev.js +66 -38
  14. package/dist/observe/core/effect.js +50 -48
  15. package/dist/observe/core/error.js +5 -3
  16. package/dist/observe/core/external.js +5 -6
  17. package/dist/observe/core/graph.js +60 -44
  18. package/dist/observe/core/heap.js +33 -33
  19. package/dist/observe/core/identities.js +62 -0
  20. package/dist/observe/core/lanes.js +238 -260
  21. package/dist/observe/core/owner.js +117 -79
  22. package/dist/observe/core/scheduler.js +381 -217
  23. package/dist/observe/core/truth.js +45 -0
  24. package/dist/observe/core/verdict.js +91 -50
  25. package/dist/observe/deferred.js +184 -0
  26. package/dist/observe/index.js +7 -1
  27. package/dist/observe/map.js +345 -260
  28. package/dist/observe/reveal.js +76 -76
  29. package/dist/observe/signals.js +47 -31
  30. package/dist/observe/store/affects.js +18 -18
  31. package/dist/observe/store/edges.js +39 -0
  32. package/dist/observe/store/optimistic.js +146 -100
  33. package/dist/observe/store/projection.js +68 -55
  34. package/dist/observe/store/store.js +180 -118
  35. package/dist/prod/affects-marks.js +86 -0
  36. package/dist/prod/affects.js +23 -72
  37. package/dist/prod/boundaries.js +156 -154
  38. package/dist/prod/core/async.js +173 -127
  39. package/dist/prod/core/constants.js +17 -3
  40. package/dist/prod/core/context.js +5 -3
  41. package/dist/prod/core/core.js +495 -343
  42. package/dist/prod/core/effect.js +70 -68
  43. package/dist/prod/core/error.js +5 -3
  44. package/dist/prod/core/external.js +5 -6
  45. package/dist/prod/core/graph.js +60 -44
  46. package/dist/prod/core/heap.js +38 -38
  47. package/dist/prod/core/identities.js +62 -0
  48. package/dist/prod/core/lanes.js +230 -252
  49. package/dist/prod/core/owner.js +114 -77
  50. package/dist/prod/core/scheduler.js +327 -163
  51. package/dist/prod/core/truth.js +45 -0
  52. package/dist/prod/core/verdict.js +90 -49
  53. package/dist/prod/deferred.js +182 -0
  54. package/dist/prod/index.js +7 -1
  55. package/dist/prod/map.js +360 -275
  56. package/dist/prod/reveal.js +76 -76
  57. package/dist/prod/signals.js +42 -26
  58. package/dist/prod/store/affects.js +6 -6
  59. package/dist/prod/store/edges.js +39 -0
  60. package/dist/prod/store/optimistic.js +143 -98
  61. package/dist/prod/store/projection.js +25 -19
  62. package/dist/prod/store/store.js +157 -100
  63. package/dist/types/affects-marks.d.ts +14 -0
  64. package/dist/types/boundaries.d.ts +1 -1
  65. package/dist/types/core/async.d.ts +10 -0
  66. package/dist/types/core/constants.d.ts +13 -1
  67. package/dist/types/core/core.d.ts +54 -5
  68. package/dist/types/core/dev.d.ts +51 -13
  69. package/dist/types/core/error.d.ts +9 -1
  70. package/dist/types/core/graph.d.ts +11 -0
  71. package/dist/types/core/identities.d.ts +17 -0
  72. package/dist/types/core/index.d.ts +2 -1
  73. package/dist/types/core/lanes.d.ts +2 -14
  74. package/dist/types/core/owner.d.ts +9 -3
  75. package/dist/types/core/scheduler.d.ts +70 -32
  76. package/dist/types/core/truth.d.ts +16 -0
  77. package/dist/types/core/types.d.ts +21 -0
  78. package/dist/types/core/verdict.d.ts +32 -0
  79. package/dist/types/deferred.d.ts +28 -0
  80. package/dist/types/index.d.ts +6 -0
  81. package/dist/types/map.d.ts +2 -2
  82. package/dist/types/signals.d.ts +28 -7
  83. package/dist/types/store/edges.d.ts +9 -0
  84. package/dist/types/store/index.d.ts +10 -3
  85. package/dist/types/store/optimistic.d.ts +3 -2
  86. package/dist/types/store/projection.d.ts +4 -3
  87. package/dist/types/store/store.d.ts +1 -1
  88. package/dist/types/store/target.d.ts +16 -8
  89. package/dist/types/store/types.d.ts +14 -0
  90. 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.ut > e.it) dirtyQueue.ut = e.it;
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?.Ht ? e._parent.gt?.it : e._parent?.it) ?? -1;
20
- if (E >= e.it) e.it = E + 1;
21
- const n = e.it;
22
- const I = t.jt[n];
23
- if (I === undefined) t.jt[n] = e; else {
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.Ot = e;
25
+ t.At = e;
26
26
  e.Rt = t;
27
27
  I.Rt = e;
28
28
  }
29
- if (n > t.Kt) t.Kt = n;
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.N) markNode(e);
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.it;
69
- if (e.Rt === e) t.jt[n] = undefined; else {
70
- const E = e.Ot;
71
- const I = t.jt[n];
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.jt[n] = E; else e.Rt.Ot = E;
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.Ot = undefined;
77
+ e.At = undefined;
78
78
  }
79
79
 
80
80
  function markHeap(e) {
81
- if (e.N) return;
82
- e.N = true;
83
- for (let t = 0; t <= e.Kt; t++) {
84
- for (let E = e.jt[t]; E !== undefined; E = E.Ot) {
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.t; t !== null; t = t.o) {
95
- markNode(t.l, REACTIVE_CHECK);
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.N = false;
101
- for (e.ut = 0; e.ut <= e.Kt; e.ut++) {
102
- let E = e.jt[e.ut];
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.jt[e.ut];
105
+ E = e.gt[e.st];
106
106
  }
107
107
  }
108
- e.Kt = 0;
108
+ e.jt = 0;
109
109
  }
110
110
 
111
111
  function adjustHeight(e, t) {
112
112
  deleteFromHeap(e, t);
113
- let E = e.it;
114
- for (let t = e.G; t; t = t._) {
115
- const e = t.I;
116
- if (e.ee && e.it >= E) E = e.it + 1;
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.it !== E) {
119
- e.it = E;
120
- for (let E = e.t; E !== null; E = E.o) insertIntoHeapHeight(E.l, t);
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 };