@solidjs/signals 2.0.0-rc.11 → 2.0.0-rc.14

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 (118) hide show
  1. package/dist/dev-shared.js +2056 -3773
  2. package/dist/dev.attribution.js +159 -91
  3. package/dist/dev.js +7263 -8384
  4. package/dist/observe/affects.js +125 -104
  5. package/dist/observe/boundaries.js +458 -665
  6. package/dist/observe/core/action.js +63 -66
  7. package/dist/observe/core/async.js +240 -383
  8. package/dist/observe/core/attribution-queries.js +1 -1
  9. package/dist/observe/core/attribution.js +271 -199
  10. package/dist/observe/core/constants.js +115 -178
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +840 -1428
  13. package/dist/observe/core/dev.js +41 -18
  14. package/dist/observe/core/effect.js +75 -86
  15. package/dist/observe/core/external.js +5 -5
  16. package/dist/observe/core/graph.js +61 -70
  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 +704 -181
  20. package/dist/observe/core/owner.js +80 -101
  21. package/dist/observe/core/scheduler.js +708 -1351
  22. package/dist/observe/core/verdict.js +302 -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 +133 -215
  28. package/dist/observe/store/affects.js +135 -0
  29. package/dist/observe/store/index.js +29 -24
  30. package/dist/observe/store/optimistic.js +538 -0
  31. package/dist/observe/store/projection.js +302 -0
  32. package/dist/observe/store/reconcile.js +257 -0
  33. package/dist/observe/store/store.js +1945 -277
  34. package/dist/observe/store/storePath.js +1 -1
  35. package/dist/{prod/store/next → observe/store}/target.js +17 -18
  36. package/dist/observe/store/types.js +73 -0
  37. package/dist/observe/store/utils.js +1 -13
  38. package/dist/prod/affects.js +127 -106
  39. package/dist/prod/boundaries.js +442 -654
  40. package/dist/prod/core/action.js +71 -74
  41. package/dist/prod/core/async.js +307 -442
  42. package/dist/prod/core/constants.js +112 -177
  43. package/dist/prod/core/context.js +3 -3
  44. package/dist/prod/core/core.js +852 -1448
  45. package/dist/prod/core/effect.js +88 -99
  46. package/dist/prod/core/external.js +5 -5
  47. package/dist/prod/core/graph.js +61 -70
  48. package/dist/prod/core/heap.js +75 -98
  49. package/dist/prod/core/invariants.js +1 -32
  50. package/dist/prod/core/lanes.js +666 -181
  51. package/dist/prod/core/owner.js +75 -96
  52. package/dist/prod/core/scheduler.js +677 -1332
  53. package/dist/prod/core/verdict.js +297 -621
  54. package/dist/prod/flatten.js +77 -0
  55. package/dist/prod/index.js +15 -13
  56. package/dist/prod/map.js +143 -146
  57. package/dist/prod/reveal.js +212 -0
  58. package/dist/prod/signals.js +144 -226
  59. package/dist/prod/store/affects.js +135 -0
  60. package/dist/prod/store/index.js +28 -19
  61. package/dist/prod/store/optimistic.js +533 -0
  62. package/dist/prod/store/projection.js +295 -0
  63. package/dist/prod/store/reconcile.js +257 -0
  64. package/dist/prod/store/store.js +1840 -272
  65. package/dist/prod/store/storePath.js +1 -1
  66. package/dist/{observe/store/next → prod/store}/target.js +13 -17
  67. package/dist/prod/store/types.js +73 -0
  68. package/dist/prod/store/utils.js +1 -11
  69. package/dist/types/affects.d.ts +11 -30
  70. package/dist/types/boundaries.d.ts +62 -176
  71. package/dist/types/carved.d.ts +1 -0
  72. package/dist/types/core/action.d.ts +5 -6
  73. package/dist/types/core/async.d.ts +10 -5
  74. package/dist/types/core/attribution-hooks.d.ts +48 -1
  75. package/dist/types/core/attribution.d.ts +29 -9
  76. package/dist/types/core/constants.d.ts +125 -171
  77. package/dist/types/core/core.d.ts +104 -264
  78. package/dist/types/core/dev.d.ts +60 -7
  79. package/dist/types/core/effect.d.ts +0 -7
  80. package/dist/types/core/graph.d.ts +7 -1
  81. package/dist/types/core/heap.d.ts +5 -7
  82. package/dist/types/core/index.d.ts +6 -6
  83. package/dist/types/core/invariants.d.ts +0 -29
  84. package/dist/types/core/lanes.d.ts +65 -87
  85. package/dist/types/core/owner.d.ts +3 -3
  86. package/dist/types/core/scheduler.d.ts +249 -331
  87. package/dist/types/core/types.d.ts +51 -85
  88. package/dist/types/core/verdict.d.ts +3 -0
  89. package/dist/types/flatten.d.ts +8 -0
  90. package/dist/types/index.d.ts +7 -5
  91. package/dist/types/reveal.d.ts +19 -0
  92. package/dist/types/signals.d.ts +53 -92
  93. package/dist/types/store/affects.d.ts +1 -0
  94. package/dist/types/store/index.d.ts +35 -15
  95. package/dist/types/store/optimistic.d.ts +23 -0
  96. package/dist/types/store/projection.d.ts +18 -0
  97. package/dist/types/store/reconcile.d.ts +3 -0
  98. package/dist/types/store/store.d.ts +165 -143
  99. package/dist/types/store/storePath.d.ts +1 -1
  100. package/dist/types/store/target.d.ts +151 -0
  101. package/dist/types/store/types.d.ts +84 -0
  102. package/package.json +1 -1
  103. package/dist/observe/core/optimistic.js +0 -669
  104. package/dist/observe/store/next/optimistic.js +0 -717
  105. package/dist/observe/store/next/projection.js +0 -266
  106. package/dist/observe/store/next/reconcile.js +0 -375
  107. package/dist/observe/store/next/store.js +0 -2480
  108. package/dist/prod/core/optimistic.js +0 -658
  109. package/dist/prod/store/next/optimistic.js +0 -710
  110. package/dist/prod/store/next/projection.js +0 -257
  111. package/dist/prod/store/next/reconcile.js +0 -373
  112. package/dist/prod/store/next/store.js +0 -2356
  113. package/dist/types/core/optimistic.d.ts +0 -6
  114. package/dist/types/store/next/optimistic.d.ts +0 -25
  115. package/dist/types/store/next/projection.d.ts +0 -27
  116. package/dist/types/store/next/reconcile.d.ts +0 -10
  117. package/dist/types/store/next/store.d.ts +0 -143
  118. 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.He > e.Le) dirtyQueue.He = e.Le;
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?.Et ? e._parent.ut?.Le : e._parent?.Le) ?? -1;
20
+ if (E >= e.Le) e.Le = E + 1;
21
+ const n = e.Le;
22
+ const I = t.Ht[n];
23
+ if (I === undefined) t.Ht[n] = e; else {
24
+ const t = I.Ke;
25
+ t.je = e;
26
+ e.Ke = t;
27
+ I.Ke = e;
33
28
  }
34
- if (n > E.EE) E.EE = n;
29
+ if (n > t.At) t.At = 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.C) 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.Le;
69
+ if (e.Ke === 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.Ke.je = E;
74
+ i.Ke = e.Ke;
80
75
  }
81
- e.Fn = e;
82
- e.Pn = undefined;
76
+ e.Ke = 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.C) return;
82
+ e.C = true;
83
+ for (let t = 0; t <= e.At; 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.l) {
95
+ markNode(t.o, 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.C = false;
101
+ for (e.He = 0; e.He <= e.At; e.He++) {
102
+ let E = e.Ht[e.He];
103
+ while (E !== undefined) {
104
+ if (E.R & REACTIVE_IN_HEAP) t(E); else adjustHeight(E, e);
105
+ E = e.Ht[e.He];
121
106
  }
122
107
  }
123
- e.EE = 0;
108
+ e.At = 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.Le;
114
+ for (let t = e._; t; t = t.p) {
115
+ const e = t.I;
116
+ if (e.re && e.Le >= E) E = e.Le + 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.Le !== E) {
119
+ e.Le = E;
120
+ for (let E = e.t; E !== null; E = E.l) insertIntoHeapHeight(E.o, 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 };