@solidjs/signals 2.0.0-rc.3 → 2.0.0-rc.5

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 (71) hide show
  1. package/dist/dev.js +2494 -271
  2. package/dist/node.cjs +3691 -1595
  3. package/dist/prod/affects.js +13 -12
  4. package/dist/prod/boundaries.js +43 -35
  5. package/dist/prod/core/action.js +3 -3
  6. package/dist/prod/core/async.js +137 -106
  7. package/dist/prod/core/constants.js +55 -1
  8. package/dist/prod/core/core.js +354 -247
  9. package/dist/prod/core/effect.js +47 -50
  10. package/dist/prod/core/error.js +13 -1
  11. package/dist/prod/core/external.js +4 -4
  12. package/dist/prod/core/graph.js +88 -52
  13. package/dist/prod/core/heap.js +38 -38
  14. package/dist/prod/core/lanes.js +34 -34
  15. package/dist/prod/core/optimistic.js +61 -58
  16. package/dist/prod/core/owner.js +38 -38
  17. package/dist/prod/core/scheduler.js +401 -174
  18. package/dist/prod/core/verdict.js +132 -65
  19. package/dist/prod/index.js +7 -3
  20. package/dist/prod/map.js +106 -106
  21. package/dist/prod/signals.js +253 -25
  22. package/dist/prod/store/index.js +2 -0
  23. package/dist/prod/store/next/optimistic.js +314 -121
  24. package/dist/prod/store/next/patch-hooks.js +13 -0
  25. package/dist/prod/store/next/patch.js +614 -0
  26. package/dist/prod/store/next/projection.js +23 -19
  27. package/dist/prod/store/next/reconcile.js +307 -120
  28. package/dist/prod/store/next/store.js +440 -117
  29. package/dist/prod/store/next/target.js +13 -4
  30. package/dist/prod/store/store.js +5 -5
  31. package/dist/types/core/async.d.ts +2 -0
  32. package/dist/types/core/attribution.d.ts +9 -4
  33. package/dist/types/core/constants.d.ts +54 -0
  34. package/dist/types/core/core.d.ts +34 -21
  35. package/dist/types/core/dev.d.ts +8 -0
  36. package/dist/types/core/error.d.ts +9 -0
  37. package/dist/types/core/graph.d.ts +22 -0
  38. package/dist/types/core/index.d.ts +2 -2
  39. package/dist/types/core/scheduler.d.ts +46 -0
  40. package/dist/types/core/types.d.ts +12 -0
  41. package/dist/types/index.d.ts +3 -3
  42. package/dist/types/signals.d.ts +108 -0
  43. package/dist/types/store/index.d.ts +2 -0
  44. package/dist/types/store/next/optimistic.d.ts +13 -10
  45. package/dist/types/store/next/patch-hooks.d.ts +41 -0
  46. package/dist/types/store/next/patch.d.ts +91 -0
  47. package/dist/types/store/next/projection.d.ts +1 -1
  48. package/dist/types/store/next/reconcile.d.ts +14 -0
  49. package/dist/types/store/next/store.d.ts +52 -2
  50. package/dist/types/store/next/target.d.ts +73 -8
  51. package/dist/types-cjs/core/async.d.cts +2 -0
  52. package/dist/types-cjs/core/attribution.d.cts +9 -4
  53. package/dist/types-cjs/core/constants.d.cts +54 -0
  54. package/dist/types-cjs/core/core.d.cts +34 -21
  55. package/dist/types-cjs/core/dev.d.cts +8 -0
  56. package/dist/types-cjs/core/error.d.cts +9 -0
  57. package/dist/types-cjs/core/graph.d.cts +22 -0
  58. package/dist/types-cjs/core/index.d.cts +2 -2
  59. package/dist/types-cjs/core/scheduler.d.cts +46 -0
  60. package/dist/types-cjs/core/types.d.cts +12 -0
  61. package/dist/types-cjs/index.d.cts +3 -3
  62. package/dist/types-cjs/signals.d.cts +108 -0
  63. package/dist/types-cjs/store/index.d.cts +2 -0
  64. package/dist/types-cjs/store/next/optimistic.d.cts +13 -10
  65. package/dist/types-cjs/store/next/patch-hooks.d.cts +41 -0
  66. package/dist/types-cjs/store/next/patch.d.cts +91 -0
  67. package/dist/types-cjs/store/next/projection.d.cts +1 -1
  68. package/dist/types-cjs/store/next/reconcile.d.cts +14 -0
  69. package/dist/types-cjs/store/next/store.d.cts +52 -2
  70. package/dist/types-cjs/store/next/target.d.cts +73 -8
  71. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
- import { REACTIVE_DISPOSED, STATUS_ERROR, EFFECT_USER, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, STATUS_PENDING, EFFECT_RENDER } from "./constants.js";
1
+ import { REACTIVE_DISPOSED, STATUS_ERROR, EFFECT_USER, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, STATUS_PENDING } from "./constants.js";
2
2
 
3
- import { ext, createEffectNode, recompute, computed, staleValues } from "./core.js";
3
+ import { setEffectStatusNotify, ext, createEffectNode, recompute, computed, staleValues } from "./core.js";
4
4
 
5
5
  import { unwrapStatusError, StatusError } from "./error.js";
6
6
 
@@ -10,20 +10,20 @@ import { GlobalQueue, haltReactivity } from "./scheduler.js";
10
10
  * Effects are the leaf nodes of our reactive graph. When their sources change, they are
11
11
  * automatically added to the queue of effects to re-execute, which will cause them to fetch their
12
12
  * sources and recompute
13
- */ function effect(t, e, E, R) {
14
- const r = !!R?.user;
15
- const f = createEffectNode(t, e, E, r ? EFFECT_USER : EFFECT_RENDER, notifyEffectStatus, R);
16
- recompute(f, true);
17
- !R?.defer && (f.Re === EFFECT_USER || R?.schedule ? f.C.enqueue(f.Re, runEffect.bind(null, f)) : runEffect(f));
13
+ */ function effect(t, e, E, f) {
14
+ const r = !!f?.user;
15
+ const R = createEffectNode(t, e, E, r ? EFFECT_USER : EFFECT_RENDER, f);
16
+ recompute(R, true);
17
+ !f?.defer && (R.he === EFFECT_USER || f?.schedule ? R.C.enqueue(R.he, runEffect.bind(null, R)) : runEffect(R));
18
18
  }
19
19
 
20
20
  function notifyEffectStatus(t, e) {
21
21
  // Use passed values if provided, otherwise read from node
22
22
  const E = t !== undefined ? t : this.S;
23
- const R = e !== undefined ? e : this.o?._;
23
+ const f = e !== undefined ? e : this.o?._;
24
24
  if (E & STATUS_ERROR) {
25
25
  this.C.notify(this, STATUS_PENDING, 0);
26
- if (this.Re === EFFECT_USER) {
26
+ if (this.he === EFFECT_USER) {
27
27
  // The error handler is the error arm of the effect phase (#2840 ruling):
28
28
  // queue it like the effect function. It runs in the same imperative,
29
29
  // writable scope, throws escalate the same way, and a held transition
@@ -34,22 +34,22 @@ function notifyEffectStatus(t, e) {
34
34
  // `status` arg without node-state writes) don't queue: the status
35
35
  // re-propagates unblocked at commit.
36
36
  if (this.S & STATUS_ERROR) {
37
- this.Xe = true;
38
- this.C.enqueue(this.Re, this.et ??= runEffect.bind(null, this));
37
+ this.tt = true;
38
+ this.C.enqueue(this.he, this.nt ??= runEffect.bind(null, this));
39
39
  }
40
40
  return;
41
41
  }
42
42
  if (!this.C.notify(this, STATUS_ERROR, STATUS_ERROR)) {
43
- haltReactivity(unwrapStatusError(R));
44
- throw R;
43
+ haltReactivity(unwrapStatusError(f));
44
+ throw f;
45
45
  }
46
- } else if (this.Re === EFFECT_RENDER) {
47
- this.C.notify(this, STATUS_PENDING | STATUS_ERROR, E, R);
46
+ } else if (this.he === EFFECT_RENDER) {
47
+ this.C.notify(this, STATUS_PENDING | STATUS_ERROR, E, f);
48
48
  }
49
49
  }
50
50
 
51
51
  function runEffect(t) {
52
- if (!t.Xe || t.ie & REACTIVE_DISPOSED) return;
52
+ if (!t.tt || t.ie & REACTIVE_DISPOSED) return;
53
53
  // Error arm (#2840), user effects only: a compute-phase error that is still
54
54
  // the node's settled state at effect time runs the bundle's error handler in
55
55
  // this same imperative, writable scope. Unwrap the StatusError used for
@@ -60,14 +60,14 @@ function runEffect(t) {
60
60
  // Render effects bypass: their errors route to boundaries synchronously in
61
61
  // notifyEffectStatus, and a runner queued by an earlier valueChanged in the
62
62
  // same flush must not be hijacked by a later-arriving error status.
63
- if (t.S & STATUS_ERROR && t.Re === EFFECT_USER) {
63
+ if (t.S & STATUS_ERROR && t.he === EFFECT_USER) {
64
64
  const e = unwrapStatusError(t.o?._);
65
- t.Tt = t.be;
66
- t.Xe = false;
65
+ t.At = t.be;
66
+ t.tt = false;
67
67
  try {
68
- t.St ? t.St(e, () => {
69
- const e = t.At;
70
- t.At = undefined;
68
+ t.Ct ? t.Ct(e, () => {
69
+ const e = t.Rt;
70
+ t.Rt = undefined;
71
71
  e?.();
72
72
  }) : console.error(e);
73
73
  } catch (e) {
@@ -78,14 +78,14 @@ function runEffect(t) {
78
78
  }
79
79
  return;
80
80
  }
81
- const e = t.At;
82
- t.At = undefined;
81
+ const e = t.Rt;
82
+ t.Rt = undefined;
83
83
  try {
84
84
  e?.();
85
- const E = t.dt(t.be, t.Tt);
85
+ const E = t.Ot(t.be, t.At);
86
86
  if (false && E !== undefined && typeof E !== "function") ;
87
87
  // The final cleanup is invoked by disposeChildren at true disposal.
88
- t.At = E;
88
+ t.Rt = E;
89
89
  } catch (e) {
90
90
  ext(t)._ = new StatusError(t, e);
91
91
  t.S |= STATUS_ERROR;
@@ -94,12 +94,12 @@ function runEffect(t) {
94
94
  throw e;
95
95
  }
96
96
  } finally {
97
- t.Tt = t.be;
98
- t.Xe = false;
97
+ t.At = t.be;
98
+ t.tt = false;
99
99
  }
100
100
  }
101
101
 
102
- GlobalQueue.tt = runEffect;
102
+ GlobalQueue.it = runEffect;
103
103
 
104
104
  /**
105
105
  * Internal tracked effect - bypasses heap, goes directly to effect queue.
@@ -107,39 +107,36 @@ GlobalQueue.tt = runEffect;
107
107
  * Uses stale reads.
108
108
  */ function trackedEffect(t, e) {
109
109
  const run = () => {
110
- if (!E.Xe || E.ie & REACTIVE_DISPOSED) return;
110
+ if (!E.tt || E.ie & REACTIVE_DISPOSED) return;
111
111
  try {
112
- E.Xe = false;
112
+ E.tt = false;
113
113
  recompute(E);
114
114
  } finally {}
115
115
  };
116
116
  const E = computed(() => {
117
- const e = E.At;
118
- E.At = undefined;
117
+ const e = E.Rt;
118
+ E.Rt = undefined;
119
119
  e?.();
120
- const R = staleValues(t);
121
- E.At = R;
120
+ const f = staleValues(t);
121
+ E.Rt = f;
122
122
  }, {
123
123
  ...e,
124
124
  lazy: true
125
125
  });
126
- E.At = undefined;
126
+ E.Rt = undefined;
127
127
  E.T = E.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
128
- E.Xe = true;
129
- E.Re = EFFECT_TRACKED;
130
- ext(E).A = (t, e) => {
131
- const R = t !== undefined ? t : E.S;
132
- if (R & STATUS_ERROR) {
133
- E.C.notify(E, STATUS_PENDING, 0);
134
- const t = e !== undefined ? e : E.o?._;
135
- if (!E.C.notify(E, STATUS_ERROR, STATUS_ERROR)) {
136
- haltReactivity(unwrapStatusError(t));
137
- throw t;
138
- }
139
- }
140
- };
141
- E.Ut = run;
128
+ E.tt = true;
129
+ E.he = EFFECT_TRACKED;
130
+ // Status dispatch rides the SHARED notifier (statusNotifierOf keys off
131
+ // _type): its error arm is behavior-identical to the closure that used to
132
+ // live here, without the per-node NodeExtension allocation.
133
+ E.yt = run;
142
134
  E.C.enqueue(EFFECT_USER, run);
143
135
  }
144
136
 
137
+ // Install the shared effect status notifier (statusNotifierOf serves it to
138
+ // every effect node) — module-scope: any bundle that creates effects
139
+ // evaluates this module.
140
+ setEffectStatusNotify(notifyEffectStatus);
141
+
145
142
  export { effect, trackedEffect };
@@ -53,6 +53,18 @@ class StatusError extends Error {
53
53
  return r instanceof StatusError ? r.cause : r;
54
54
  }
55
55
 
56
+ /**
57
+ * Rejection value of `until(fn, { timeout })` when the predicate does not turn
58
+ * truthy within the window. Inside an `action()`, the rejection is thrown back
59
+ * in at the `yield` point — catchable there, or the action fails and its
60
+ * optimistic state reverts.
61
+ */ class TimeoutError extends Error {
62
+ constructor(r = "Timed out waiting for condition") {
63
+ super(r);
64
+ this.name = "TimeoutError";
65
+ }
66
+ }
67
+
56
68
  class NoOwnerError extends Error {
57
69
  constructor() {
58
70
  super("");
@@ -65,4 +77,4 @@ class ContextNotFoundError extends Error {
65
77
  }
66
78
  }
67
79
 
68
- export { ContextNotFoundError, NoOwnerError, NotReadyError, StatusError, unwrapStatusError };
80
+ export { ContextNotFoundError, NoOwnerError, NotReadyError, StatusError, TimeoutError, unwrapStatusError };
@@ -46,11 +46,11 @@ function wireExternalSource(e) {
46
46
  equals: false,
47
47
  ownedWrite: true
48
48
  });
49
- const r = externalSourceConfig.factory(e.Se, () => {
49
+ const r = externalSourceConfig.factory(e.oe, () => {
50
50
  setSignal(n, undefined);
51
51
  });
52
52
  cleanup(() => r.dispose());
53
- e.Se = e => {
53
+ e.oe = e => {
54
54
  read(n);
55
55
  return r.track(e);
56
56
  };
@@ -64,8 +64,8 @@ function externalUntrack(e) {
64
64
  // removed on reset) so core's null checks stay equivalent to the old
65
65
  // `externalSourceConfig` truthiness checks.
66
66
  function syncExternalHooks() {
67
- GlobalQueue.Rt = externalSourceConfig ? wireExternalSource : null;
68
- GlobalQueue.Gt = externalSourceConfig ? externalUntrack : null;
67
+ GlobalQueue.Pt = externalSourceConfig ? wireExternalSource : null;
68
+ GlobalQueue.ht = externalSourceConfig ? externalUntrack : null;
69
69
  }
70
70
 
71
71
  function enableExternalSource(e) {
@@ -1,4 +1,4 @@
1
- import { CONFIG_AUTO_DISPOSE, REACTIVE_ZOMBIE, STATUS_PENDING, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
1
+ import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
2
2
 
3
3
  import { deleteFromHeap, queueFor } from "./heap.js";
4
4
 
@@ -8,36 +8,36 @@ import { bumpNotifyEpoch } from "./scheduler.js";
8
8
 
9
9
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
10
10
  function unlinkSubs(e) {
11
- const l = e.ut;
12
- const n = e.it;
13
- const u = e.fe;
14
- const s = e.el;
15
- if (u !== null) u.el = s; else l.rt = s;
16
- if (s !== null) s.fe = u; else {
17
- l.u = u;
18
- if (u === null) {
19
- l.o?.ft?.();
11
+ const n = e.ot;
12
+ const l = e.lt;
13
+ const o = e.ae;
14
+ const u = e.en;
15
+ if (o !== null) o.en = u; else n._t = u;
16
+ if (u !== null) u.ae = o; else {
17
+ n.u = o;
18
+ if (o === null) {
19
+ n.o?.Et?.();
20
20
  // No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
21
21
  // A pending node is exempt: its in-flight async work (or the
22
22
  // transition holding it) is an observer — tearing down would orphan
23
23
  // the work and re-execute it on the next read. The settle path runs
24
24
  // this same last-one-out check when that observer releases (the
25
- // untracked-read dispose in core.ts guards on pending identically).
26
- const e = l;
27
- e.Se && e.T & CONFIG_AUTO_DISPOSE && !(e.ie & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
25
+ // untracked-read dormancy sweep guards on pending identically).
26
+ const e = n;
27
+ e.oe && e.T & CONFIG_AUTO_DISPOSE && !(e.ie & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
28
28
  }
29
29
  }
30
- return n;
30
+ return l;
31
31
  }
32
32
 
33
33
  function trimStaleDeps(e) {
34
- const l = e.Ye;
35
- let n = l !== null ? l.it : e.nt;
36
- if (n !== null) {
34
+ const n = e.je;
35
+ let l = n !== null ? n.lt : e.ut;
36
+ if (l !== null) {
37
37
  do {
38
- n = unlinkSubs(n);
39
- } while (n !== null);
40
- if (l !== null) l.it = null; else e.nt = null;
38
+ l = unlinkSubs(l);
39
+ } while (l !== null);
40
+ if (n !== null) n.lt = null; else e.ut = null;
41
41
  }
42
42
  }
43
43
 
@@ -46,13 +46,13 @@ function trimStaleDeps(e) {
46
46
  // and skipping early also avoids adding one (hidden-class churn) via the
47
47
  // null-out below.
48
48
  function clearDeps(e) {
49
- let l = e.nt;
50
- if (!l) return;
49
+ let n = e.ut;
50
+ if (!n) return;
51
51
  do {
52
- l = unlinkSubs(l);
53
- } while (l !== null);
54
- e.nt = null;
55
- e.Ye = null;
52
+ n = unlinkSubs(n);
53
+ } while (n !== null);
54
+ e.ut = null;
55
+ e.je = null;
56
56
  }
57
57
 
58
58
  function unobserved(e) {
@@ -61,27 +61,63 @@ function unobserved(e) {
61
61
  disposeChildren(e, true);
62
62
  }
63
63
 
64
+ /**
65
+ * Deferred dormancy for never-observed auto-dispose computeds (#3078).
66
+ *
67
+ * An untracked top-level read of a subscriber-less observation-lifecycle memo
68
+ * used to call unobserved() inline at the end of read(). That kept the leak
69
+ * closed (the compute links the memo into its deps' sub lists — without a
70
+ * teardown point a never-observed memo is retained by its sources forever;
71
+ * upstream alien-signals has exactly this retention), but it made reads
72
+ * destructive: each read disposed the node, the next read revived it with a
73
+ * full recompute in whatever ambient transition/lane context happened to be
74
+ * current, so consecutive reads could return different answers with no write
75
+ * in between.
76
+ *
77
+ * Instead, reads queue the node here and the scheduler sweeps at the top of
78
+ * the next flush (before runHeap, so a same-tick dirtying is reclaimed
79
+ * instead of recomputed). Reads become idempotent within a tick (the node
80
+ * stays alive and serves its cache, uniform with observed memos) while
81
+ * reclamation still happens within one microtask — the enqueue site arms
82
+ * schedule(), so a flush is guaranteed even when no other work is queued.
83
+ */ const dormantNodes = new Set;
84
+
85
+ function sweepDormant() {
86
+ if (dormantNodes.size === 0) return;
87
+ for (const e of dormantNodes) {
88
+ // Re-validate at sweep time: the node may have gained a subscriber (its
89
+ // lifecycle is the unlinkSubs cascade now), gone pending (in-flight async
90
+ // is an observer; the settle path re-runs last-one-out), lost its
91
+ // AUTO_DISPOSE bit (owner teardown strips it, #3024), or already been
92
+ // torn down.
93
+ if (!e.u && e.T & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.ie & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
94
+ unobserved(e);
95
+ }
96
+ }
97
+ dormantNodes.clear();
98
+ }
99
+
64
100
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L52
65
- function link(e, l, n = false) {
101
+ function link(e, n, l = false) {
66
102
  // Repeat touches within one pass AND-combine `_pendingObserver`: a probe
67
103
  // read (`isPending(() => x())`) beside a value read of the same dep must
68
104
  // not relabel the value dependency as probe-only — the value read is what
69
105
  // real-error propagation and affects() coverage key off, regardless of
70
106
  // read order within the computation.
71
- const u = l.Ye;
72
- if (u !== null && u.ut === e) {
73
- u.me &&= n;
107
+ const o = n.je;
108
+ if (o !== null && o.ot === e) {
109
+ o.ve &&= l;
74
110
  return;
75
111
  }
76
- let s = null;
77
- const o = l.ie & REACTIVE_RECOMPUTING_DEPS;
78
- if (o) {
79
- s = u !== null ? u.it : l.nt;
80
- if (s !== null && s.ut === e) {
81
- s.ll = l.Ze;
82
- l.Ye = s;
112
+ let u = null;
113
+ const t = n.ie & REACTIVE_RECOMPUTING_DEPS;
114
+ if (t) {
115
+ u = o !== null ? o.lt : n.ut;
116
+ if (u !== null && u.ot === e) {
117
+ u.Ft = n.Ke;
118
+ n.je = u;
83
119
  // First touch of this pass: the previous pass's label is stale.
84
- s.me = n;
120
+ u.ve = l;
85
121
  return;
86
122
  }
87
123
  }
@@ -90,26 +126,26 @@ function link(e, l, n = false) {
90
126
  // [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
91
127
  // (the old alien-signals `isValidLink` walk, O(n²) when a computation
92
128
  // re-reads earlier deps non-consecutively, e.g. store leaf reads).
93
- const t = e.rt;
94
- if (t !== null && t.ae === l && (!o || t.ll === l.Ze)) {
129
+ const s = e._t;
130
+ if (s !== null && s.ce === n && (!t || s.Ft === n.Ke)) {
95
131
  // Gen-matched during a recompute = repeat touch this pass (AND); outside
96
132
  // a recompute there is no pass boundary, so the latest read labels it.
97
- if (o) t.me &&= n; else t.me = n;
133
+ if (t) s.ve &&= l; else s.ve = l;
98
134
  return;
99
135
  }
100
- const i = l.Ye = e.rt = {
101
- ut: e,
102
- ae: l,
103
- it: s,
104
- el: t,
105
- fe: null,
106
- ll: l.Ze,
107
- me: n
136
+ const r = n.je = e._t = {
137
+ ot: e,
138
+ ce: n,
139
+ lt: u,
140
+ en: s,
141
+ ae: null,
142
+ Ft: n.Ke,
143
+ ve: l
108
144
  };
109
- if (u !== null) u.it = i; else l.nt = i;
110
- if (t !== null) t.fe = i; else e.u = i;
145
+ if (o !== null) o.lt = r; else n.ut = r;
146
+ if (s !== null) s.ae = r; else e.u = r;
111
147
  // New subscriber edge: staged-rewrite skips (§12d) must not miss it.
112
148
  bumpNotifyEpoch();
113
149
  }
114
150
 
115
- export { clearDeps, link, trimStaleDeps, unlinkSubs, unobserved };
151
+ export { clearDeps, dormantNodes, link, sweepDormant, trimStaleDeps, unlinkSubs, unobserved };
@@ -1,6 +1,6 @@
1
1
  import "./core.js";
2
2
 
3
- import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, EFFECT_TRACKED, EFFECT_USER, REACTIVE_RECOMPUTING_DEPS, REACTIVE_MANUAL_WRITE, REACTIVE_ZOMBIE, REACTIVE_CHECK, REACTIVE_DIRTY, CONFIG_FW_CHILDREN } from "./constants.js";
3
+ import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, EFFECT_TRACKED, EFFECT_USER, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS, REACTIVE_MANUAL_WRITE, REACTIVE_CHECK, REACTIVE_DIRTY, CONFIG_FW_CHILDREN } from "./constants.js";
4
4
 
5
5
  import { zombieQueue, dirtyQueue } from "./scheduler.js";
6
6
 
@@ -13,29 +13,29 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
13
13
  * the heap and go directly to their effect queue; everything else is inserted
14
14
  * into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
15
15
  */ function enqueueSub(e) {
16
- if (e.Re === EFFECT_TRACKED) {
16
+ if (e.he === EFFECT_TRACKED) {
17
17
  const E = e;
18
- if (!E.Xe) {
19
- E.Xe = true;
20
- E.C.enqueue(EFFECT_USER, E.Ut);
18
+ if (!E.tt) {
19
+ E.tt = true;
20
+ E.C.enqueue(EFFECT_USER, E.yt);
21
21
  }
22
22
  return;
23
23
  }
24
24
  const E = queueFor(e);
25
- if (E.xe > e.Le) E.xe = e.Le;
25
+ if (E.Qe > e.Me) E.Qe = e.Me;
26
26
  insertIntoHeap(e, E);
27
27
  }
28
28
 
29
29
  function actualInsertIntoHeap(e, E) {
30
- const t = (e.ve?.Ct ? e.ve.Ot?.Le : e.ve?.Le) ?? -1;
31
- if (t >= e.Le) e.Le = t + 1;
32
- const n = e.Le;
30
+ const t = (e.ke?.Gt ? e.ke.Dt?.Me : e.ke?.Me) ?? -1;
31
+ if (t >= e.Me) e.Me = t + 1;
32
+ const n = e.Me;
33
33
  const I = E.eE[n];
34
34
  if (I === undefined) E.eE[n] = e; else {
35
- const E = I.st;
36
- E.ot = e;
37
- e.st = E;
38
- I.st = e;
35
+ const E = I.ct;
36
+ E.rt = e;
37
+ e.ct = E;
38
+ I.ct = e;
39
39
  }
40
40
  if (n > E.EE) E.EE = n;
41
41
  }
@@ -71,23 +71,23 @@ function deleteFromHeap(e, E) {
71
71
  const t = e.ie;
72
72
  if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
73
73
  e.ie = t & -25;
74
- const n = e.Le;
75
- if (e.st === e) E.eE[n] = undefined; else {
76
- const t = e.ot;
74
+ const n = e.Me;
75
+ if (e.ct === e) E.eE[n] = undefined; else {
76
+ const t = e.rt;
77
77
  const I = E.eE[n];
78
78
  const o = t ?? I;
79
- if (e === I) E.eE[n] = t; else e.st.ot = t;
80
- o.st = e.st;
79
+ if (e === I) E.eE[n] = t; else e.ct.rt = t;
80
+ o.ct = e.ct;
81
81
  }
82
- e.st = e;
83
- e.ot = undefined;
82
+ e.ct = e;
83
+ e.rt = undefined;
84
84
  }
85
85
 
86
86
  function markHeap(e) {
87
87
  if (e.tE) return;
88
88
  e.tE = true;
89
89
  for (let E = 0; E <= e.EE; E++) {
90
- for (let t = e.eE[E]; t !== undefined; t = t.ot) {
90
+ for (let t = e.eE[E]; t !== undefined; t = t.rt) {
91
91
  if (t.ie & REACTIVE_IN_HEAP) markNode(t);
92
92
  }
93
93
  }
@@ -97,16 +97,16 @@ function markNode(e, E = REACTIVE_DIRTY) {
97
97
  const t = e.ie;
98
98
  if ((t & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= E) return;
99
99
  e.ie = t & -4 | E;
100
- for (let E = e.u; E !== null; E = E.fe) {
101
- markNode(E.ae, REACTIVE_CHECK);
100
+ for (let E = e.u; E !== null; E = E.ae) {
101
+ markNode(E.ce, REACTIVE_CHECK);
102
102
  }
103
103
  // Firewall children (projection machinery only): gate the cold-extension
104
104
  // deref on the config bit — markNode runs per sub edge per write, and an
105
105
  // unconditional _x chase here taxed every propagation (diamond -22%).
106
106
  if (e.T & CONFIG_FW_CHILDREN) {
107
- for (let E = e.o.l; E !== null; E = E.ce) {
108
- for (let e = E.u; e !== null; e = e.fe) {
109
- markNode(e.ae, REACTIVE_CHECK);
107
+ for (let E = e.o.i; E !== null; E = E.Se) {
108
+ for (let e = E.u; e !== null; e = e.ae) {
109
+ markNode(e.ce, REACTIVE_CHECK);
110
110
  }
111
111
  }
112
112
  }
@@ -114,11 +114,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
114
114
 
115
115
  function runHeap(e, E) {
116
116
  e.tE = false;
117
- for (e.xe = 0; e.xe <= e.EE; e.xe++) {
118
- let t = e.eE[e.xe];
117
+ for (e.Qe = 0; e.Qe <= e.EE; e.Qe++) {
118
+ let t = e.eE[e.Qe];
119
119
  while (t !== undefined) {
120
120
  if (t.ie & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
121
- t = e.eE[e.xe];
121
+ t = e.eE[e.Qe];
122
122
  }
123
123
  }
124
124
  e.EE = 0;
@@ -126,21 +126,21 @@ function runHeap(e, E) {
126
126
 
127
127
  function adjustHeight(e, E) {
128
128
  deleteFromHeap(e, E);
129
- let t = e.Le;
130
- for (let E = e.nt; E; E = E.it) {
131
- const e = E.ut;
132
- const n = e.lt || e;
133
- if (n.Se && n.Le >= t) t = n.Le + 1;
129
+ let t = e.Me;
130
+ for (let E = e.ut; E; E = E.lt) {
131
+ const e = E.ot;
132
+ const n = e.st || e;
133
+ if (n.oe && n.Me >= t) t = n.Me + 1;
134
134
  }
135
- if (e.Le !== t) {
136
- e.Le = t;
137
- for (let E = e.u; E !== null; E = E.fe) {
135
+ if (e.Me !== t) {
136
+ e.Me = t;
137
+ for (let E = e.u; E !== null; E = E.ae) {
138
138
  // Route each subscriber by its own zombie flag, mirroring the
139
139
  // post-recompute height-adjust path. Inserting into the running `heap`
140
140
  // unconditionally can park a zombie in `dirtyQueue` (or a live node in
141
141
  // `zombieQueue`), breaking the flag/queue invariant `deleteFromHeap`
142
142
  // relies on — the same corruption class as #2759.
143
- insertIntoHeapHeight(E.ae, queueFor(E.ae));
143
+ insertIntoHeapHeight(E.ce, queueFor(E.ce));
144
144
  }
145
145
  }
146
146
  }