@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.15

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 (121) hide show
  1. package/dist/dev-shared.js +2059 -3768
  2. package/dist/dev.attribution.js +237 -101
  3. package/dist/dev.js +7466 -8497
  4. package/dist/observe/affects.js +128 -104
  5. package/dist/observe/boundaries.js +492 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +243 -379
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +394 -253
  10. package/dist/observe/core/constants.js +120 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +874 -1440
  13. package/dist/observe/core/dev.js +3 -3
  14. package/dist/observe/core/effect.js +73 -84
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +62 -71
  17. package/dist/observe/core/heap.js +75 -98
  18. package/dist/observe/core/invariants.js +1 -34
  19. package/dist/observe/core/lanes.js +750 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +719 -1356
  22. package/dist/observe/core/verdict.js +314 -621
  23. package/dist/observe/flatten.js +79 -0
  24. package/dist/observe/index.js +15 -13
  25. package/dist/observe/map.js +232 -235
  26. package/dist/observe/reveal.js +212 -0
  27. package/dist/observe/signals.js +144 -216
  28. package/dist/observe/store/affects.js +142 -0
  29. package/dist/observe/store/hooks.js +13 -0
  30. package/dist/observe/store/index.js +27 -24
  31. package/dist/observe/store/optimistic.js +571 -0
  32. package/dist/observe/store/projection.js +308 -0
  33. package/dist/observe/store/reconcile.js +259 -0
  34. package/dist/observe/store/store.js +1988 -277
  35. package/dist/observe/store/storePath.js +1 -1
  36. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  37. package/dist/observe/store/types.js +73 -0
  38. package/dist/observe/store/utils.js +1 -13
  39. package/dist/prod/affects.js +130 -106
  40. package/dist/prod/boundaries.js +476 -654
  41. package/dist/prod/core/action.js +71 -74
  42. package/dist/prod/core/async.js +306 -444
  43. package/dist/prod/core/constants.js +117 -186
  44. package/dist/prod/core/context.js +3 -3
  45. package/dist/prod/core/core.js +888 -1462
  46. package/dist/prod/core/effect.js +88 -99
  47. package/dist/prod/core/external.js +5 -5
  48. package/dist/prod/core/graph.js +62 -71
  49. package/dist/prod/core/heap.js +75 -98
  50. package/dist/prod/core/invariants.js +1 -32
  51. package/dist/prod/core/lanes.js +712 -181
  52. package/dist/prod/core/owner.js +75 -96
  53. package/dist/prod/core/scheduler.js +686 -1335
  54. package/dist/prod/core/verdict.js +309 -621
  55. package/dist/prod/flatten.js +77 -0
  56. package/dist/prod/index.js +15 -13
  57. package/dist/prod/map.js +142 -145
  58. package/dist/prod/reveal.js +212 -0
  59. package/dist/prod/signals.js +155 -227
  60. package/dist/prod/store/affects.js +142 -0
  61. package/dist/prod/store/hooks.js +13 -0
  62. package/dist/prod/store/index.js +26 -19
  63. package/dist/prod/store/optimistic.js +566 -0
  64. package/dist/prod/store/projection.js +301 -0
  65. package/dist/prod/store/reconcile.js +259 -0
  66. package/dist/prod/store/store.js +1883 -272
  67. package/dist/prod/store/storePath.js +1 -1
  68. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  69. package/dist/prod/store/types.js +73 -0
  70. package/dist/prod/store/utils.js +1 -11
  71. package/dist/types/affects.d.ts +11 -30
  72. package/dist/types/boundaries.d.ts +66 -176
  73. package/dist/types/carved.d.ts +1 -0
  74. package/dist/types/core/action.d.ts +5 -6
  75. package/dist/types/core/async.d.ts +10 -5
  76. package/dist/types/core/attribution-hooks.d.ts +20 -1
  77. package/dist/types/core/attribution.d.ts +26 -11
  78. package/dist/types/core/constants.d.ts +130 -180
  79. package/dist/types/core/core.d.ts +134 -264
  80. package/dist/types/core/dev.d.ts +2 -2
  81. package/dist/types/core/effect.d.ts +0 -7
  82. package/dist/types/core/graph.d.ts +7 -1
  83. package/dist/types/core/heap.d.ts +5 -7
  84. package/dist/types/core/index.d.ts +5 -5
  85. package/dist/types/core/invariants.d.ts +0 -29
  86. package/dist/types/core/lanes.d.ts +74 -86
  87. package/dist/types/core/owner.d.ts +3 -3
  88. package/dist/types/core/scheduler.d.ts +255 -331
  89. package/dist/types/core/types.d.ts +45 -85
  90. package/dist/types/core/verdict.d.ts +3 -0
  91. package/dist/types/flatten.d.ts +8 -0
  92. package/dist/types/index.d.ts +6 -4
  93. package/dist/types/reveal.d.ts +19 -0
  94. package/dist/types/signals.d.ts +35 -91
  95. package/dist/types/store/affects.d.ts +12 -0
  96. package/dist/types/store/hooks.d.ts +48 -0
  97. package/dist/types/store/index.d.ts +34 -15
  98. package/dist/types/store/optimistic.d.ts +23 -0
  99. package/dist/types/store/projection.d.ts +18 -0
  100. package/dist/types/store/reconcile.d.ts +3 -0
  101. package/dist/types/store/store.d.ts +132 -145
  102. package/dist/types/store/storePath.d.ts +1 -1
  103. package/dist/types/store/target.d.ts +151 -0
  104. package/dist/types/store/types.d.ts +84 -0
  105. package/package.json +1 -1
  106. package/dist/observe/core/optimistic.js +0 -669
  107. package/dist/observe/store/next/optimistic.js +0 -717
  108. package/dist/observe/store/next/projection.js +0 -266
  109. package/dist/observe/store/next/reconcile.js +0 -375
  110. package/dist/observe/store/next/store.js +0 -2608
  111. package/dist/prod/core/optimistic.js +0 -658
  112. package/dist/prod/store/next/optimistic.js +0 -710
  113. package/dist/prod/store/next/projection.js +0 -257
  114. package/dist/prod/store/next/reconcile.js +0 -373
  115. package/dist/prod/store/next/store.js +0 -2484
  116. package/dist/types/core/optimistic.d.ts +0 -6
  117. package/dist/types/store/next/optimistic.d.ts +0 -25
  118. package/dist/types/store/next/projection.d.ts +0 -27
  119. package/dist/types/store/next/reconcile.d.ts +0 -10
  120. package/dist/types/store/next/store.d.ts +0 -145
  121. package/dist/types/store/next/target.d.ts +0 -196
@@ -1,49 +1,44 @@
1
1
  import "./core.js";
2
2
 
3
- import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS, REACTIVE_MANUAL_WRITE, REACTIVE_CHECK, REACTIVE_DIRTY, CONFIG_FW_CHILDREN } from "./constants.js";
3
+ import { REACTIVE_IN_HEAP, REACTIVE_RECOMPUTING_DEPS, REACTIVE_CHECK, REACTIVE_DIRTY, REACTIVE_IN_HEAP_HEIGHT } from "./constants.js";
4
4
 
5
- import { zombieQueue, dirtyQueue } from "./scheduler.js";
6
-
7
- /** The queue a node belongs to, picked from its own zombie flag. */ function queueFor(e) {
8
- return e.oe & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
9
- }
5
+ import { dirtyQueue } from "./scheduler.js";
10
6
 
11
7
  /**
12
- * Schedule one subscriber to re-run on the next flush: inserted into its own
13
- * (zombie-flag-routed) heap with the `_min` cursor pulled down. Tracked
14
- * effects ride the heap too — the heap visit is their (empty) compute phase,
15
- * which hands the callback to the user queue once the pass has committed
16
- * (see GlobalQueue._update, #3291).
8
+ * Schedule one subscriber to re-run on the next flush: inserted into the
9
+ * dirty heap with the `_min` cursor pulled down. Tracked effects ride the
10
+ * heap too — the heap visit is their (empty) compute phase, which hands the
11
+ * callback to the user queue once the pass has committed (see
12
+ * GlobalQueue._update, #3291).
17
13
  */ function enqueueSub(e) {
18
- const E = queueFor(e);
19
- if (E.ln > e.rn) E.ln = e.rn;
20
- insertIntoHeap(e, E);
14
+ if (dirtyQueue.Ue > e.me) dirtyQueue.Ue = e.me;
15
+ insertIntoHeap(e, dirtyQueue);
21
16
  }
22
17
 
23
- function actualInsertIntoHeap(e, E) {
24
- const t = (e._parent?.Wn ? e._parent.qn?.rn : e._parent?.rn) ?? -1;
25
- if (t >= e.rn) e.rn = t + 1;
26
- const n = e.rn;
27
- const I = E.eE[n];
28
- if (I === undefined) E.eE[n] = e; else {
29
- const E = I.Fn;
30
- E.Pn = e;
31
- e.Fn = E;
32
- I.Fn = e;
18
+ function actualInsertIntoHeap(e, t) {
19
+ const E = (e._parent?.$e ? e._parent.et?.me : e._parent?.me) ?? -1;
20
+ if (E >= e.me) e.me = E + 1;
21
+ const n = e.me;
22
+ const I = t.Ht[n];
23
+ if (I === undefined) t.Ht[n] = e; else {
24
+ const t = I.we;
25
+ t.je = e;
26
+ e.we = t;
27
+ I.we = e;
33
28
  }
34
- if (n > E.EE) E.EE = n;
29
+ if (n > t.ft) t.ft = n;
35
30
  }
36
31
 
37
- function insertIntoHeap(e, E) {
38
- let t = e.oe;
32
+ function insertIntoHeap(e, t) {
33
+ let E = e.R;
39
34
  // RECOMPUTING refusals are not always losses: a genuinely missed wake (a
40
35
  // write to a link this pass already validated) is latched link-side in
41
36
  // insertSubs as REACTIVE_MISSED_WAKE for recompute's tail (#3037).
42
- if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
43
- if (t & REACTIVE_CHECK) {
44
- e.oe = t & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
37
+ if (E & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS)) return;
38
+ if (E & REACTIVE_CHECK) {
39
+ e.R = E & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
45
40
  } else {
46
- e.oe = t | REACTIVE_IN_HEAP;
41
+ e.R = E | REACTIVE_IN_HEAP;
47
42
  // An unmarked node entering an already-marked heap is marked on the
48
43
  // spot, keeping the markHeap memo valid. `_marked` is only reset by
49
44
  // runHeap, so a write between two mid-tick pulls (read-time markHeap +
@@ -54,94 +49,76 @@ function insertIntoHeap(e, E) {
54
49
  // parked in the heap for a synchronous mount (each row writing a ref
55
50
  // signal its effect subscribes to), mounting N rows was O(N²) (#3350).
56
51
  // markNode's own guard skips an already-DIRTY node.
57
- if (E.tE) markNode(e);
52
+ if (t.N) markNode(e);
58
53
  }
59
- if (!(t & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, E);
54
+ if (!(E & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
60
55
  }
61
56
 
62
- function insertIntoHeapHeight(e, E) {
63
- let t = e.oe;
64
- if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)) return;
65
- e.oe = t | REACTIVE_IN_HEAP_HEIGHT;
66
- actualInsertIntoHeap(e, E);
57
+ function insertIntoHeapHeight(e, t) {
58
+ let E = e.R;
59
+ if (E & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT)) return;
60
+ e.R = E | REACTIVE_IN_HEAP_HEIGHT;
61
+ actualInsertIntoHeap(e, t);
67
62
  }
68
63
 
69
- function deleteFromHeap(e, E) {
70
- const t = e.oe;
71
- if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
72
- e.oe = t & -25;
73
- const n = e.rn;
74
- if (e.Fn === e) E.eE[n] = undefined; else {
75
- const t = e.Pn;
76
- const I = E.eE[n];
77
- const o = t ?? I;
78
- if (e === I) E.eE[n] = t; else e.Fn.Pn = t;
79
- o.Fn = e.Fn;
64
+ function deleteFromHeap(e, t) {
65
+ const E = e.R;
66
+ if (!(E & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
67
+ e.R = E & -25;
68
+ const n = e.me;
69
+ if (e.we === e) t.Ht[n] = undefined; else {
70
+ const E = e.je;
71
+ const I = t.Ht[n];
72
+ const i = E ?? I;
73
+ if (e === I) t.Ht[n] = E; else e.we.je = E;
74
+ i.we = e.we;
80
75
  }
81
- e.Fn = e;
82
- e.Pn = undefined;
76
+ e.we = e;
77
+ e.je = undefined;
83
78
  }
84
79
 
85
80
  function markHeap(e) {
86
- if (e.tE) return;
87
- e.tE = true;
88
- for (let E = 0; E <= e.EE; E++) {
89
- for (let t = e.eE[E]; t !== undefined; t = t.Pn) {
90
- if (t.oe & REACTIVE_IN_HEAP) markNode(t);
81
+ if (e.N) return;
82
+ e.N = true;
83
+ for (let t = 0; t <= e.ft; t++) {
84
+ for (let E = e.Ht[t]; E !== undefined; E = E.je) {
85
+ if (E.R & REACTIVE_IN_HEAP) markNode(E);
91
86
  }
92
87
  }
93
88
  }
94
89
 
95
- function markNode(e, E = REACTIVE_DIRTY) {
96
- const t = e.oe;
97
- if ((t & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= E) return;
98
- e.oe = t & -4 | E;
99
- for (let E = e.u; E !== null; E = E.Ae) {
100
- markNode(E.ge, REACTIVE_CHECK);
101
- }
102
- // Firewall children (projection machinery only): gate the cold-extension
103
- // deref on the config bit — markNode runs per sub edge per write, and an
104
- // unconditional _x chase here taxed every propagation (diamond -22%).
105
- if (e.C & CONFIG_FW_CHILDREN) {
106
- for (let E = e.o.i; E !== null; E = E.Ue) {
107
- for (let e = E.u; e !== null; e = e.Ae) {
108
- markNode(e.ge, REACTIVE_CHECK);
109
- }
110
- }
90
+ function markNode(e, t = REACTIVE_DIRTY) {
91
+ const E = e.R;
92
+ if ((E & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
93
+ e.R = E & -4 | t;
94
+ for (let t = e.t; t !== null; t = t.o) {
95
+ markNode(t.l, REACTIVE_CHECK);
111
96
  }
112
97
  }
113
98
 
114
- function runHeap(e, E) {
115
- e.tE = false;
116
- for (e.ln = 0; e.ln <= e.EE; e.ln++) {
117
- let t = e.eE[e.ln];
118
- while (t !== undefined) {
119
- if (t.oe & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
120
- t = e.eE[e.ln];
99
+ function runHeap(e, t) {
100
+ e.N = false;
101
+ for (e.Ue = 0; e.Ue <= e.ft; e.Ue++) {
102
+ let E = e.Ht[e.Ue];
103
+ while (E !== undefined) {
104
+ if (E.R & REACTIVE_IN_HEAP) t(E); else adjustHeight(E, e);
105
+ E = e.Ht[e.Ue];
121
106
  }
122
107
  }
123
- e.EE = 0;
108
+ e.ft = 0;
124
109
  }
125
110
 
126
- function adjustHeight(e, E) {
127
- deleteFromHeap(e, E);
128
- let t = e.rn;
129
- for (let E = e.Ie; E; E = E.Ne) {
130
- const e = E.Oe;
131
- const n = e.De || e;
132
- if (n.he && n.rn >= t) t = n.rn + 1;
111
+ function adjustHeight(e, t) {
112
+ deleteFromHeap(e, t);
113
+ let E = e.me;
114
+ for (let t = e.p; t; t = t._) {
115
+ const e = t.I;
116
+ if (e.ee && e.me >= E) E = e.me + 1;
133
117
  }
134
- if (e.rn !== t) {
135
- e.rn = t;
136
- for (let E = e.u; E !== null; E = E.Ae) {
137
- // Route each subscriber by its own zombie flag, mirroring the
138
- // post-recompute height-adjust path. Inserting into the running `heap`
139
- // unconditionally can park a zombie in `dirtyQueue` (or a live node in
140
- // `zombieQueue`), breaking the flag/queue invariant `deleteFromHeap`
141
- // relies on — the same corruption class as #2759.
142
- insertIntoHeapHeight(E.ge, queueFor(E.ge));
143
- }
118
+ if (e.me !== E) {
119
+ e.me = E;
120
+ for (let E = e.t; E !== null; E = E.o) insertIntoHeapHeight(E.l, t);
144
121
  }
145
122
  }
146
123
 
147
- export { deleteFromHeap, enqueueSub, insertIntoHeap, insertIntoHeapHeight, markHeap, markNode, queueFor, runHeap };
124
+ export { deleteFromHeap, enqueueSub, insertIntoHeap, insertIntoHeapHeight, markHeap, markNode, runHeap };
@@ -1,36 +1,5 @@
1
1
  import "./core.js";
2
2
 
3
- /**
4
- * INV-2: a node with an *active* override must be registered for reversion in
5
- * the queue's or a transition's `_optimisticNodes`. An unregistered active
6
- * override would survive transition completion forever. Runs at the end of
7
- * every flush (not just quiescence — the invariant holds mid-transition).
8
- * (There is no revert-target requirement: authoritative values commit
9
- * silently into `_value` under the override mask — A17 — so reverting is
10
- * just dropping the override.)
11
- */ function devCheckActiveOverrides(e) {
12
- return;
13
- }
14
-
15
- /** INV-1: an isPending() probe must never leak past its own call. */ function devCheckFlushStart() {
16
- return;
17
- }
18
-
19
- /**
20
- * Companion-vs-oracle census (#2838 pre-work). A NON-ASSERTING diff logger:
21
- * at the end of every flush it compares each live companion's cached state
22
- * against a fresh oracle and logs every distinct divergence fingerprint once
23
- * (console, `[census]` prefix). Legit lane-scoped windows will show up too —
24
- * the census exists to enumerate the full taxonomy of mid-flight divergence
25
- * so the write-driven redesign knows every case it must produce, not to
26
- * judge them. Enabled only when the COMPANION_CENSUS env var is set (in
27
- * addition to `false`), so normal test runs pay one boolean check.
28
- */ typeof globalThis !== "undefined" && !!globalThis.process?.env?.COMPANION_CENSUS;
29
-
30
- function devCensusCompanions(e) {
31
- return;
32
- }
33
-
34
3
  /**
35
4
  * Quiescence checks. Run only when the system is fully drained: nothing
36
5
  * scheduled, no active/stashed transitions, no live lanes. At that point no
@@ -40,4 +9,4 @@ function devCensusCompanions(e) {
40
9
  return;
41
10
  }
42
11
 
43
- export { devCensusCompanions, devCheckActiveOverrides, devCheckFlushStart, devCheckQuiescent };
12
+ export { devCheckQuiescent };