@solidjs/signals 2.0.0-rc.6 → 2.0.0-rc.7

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 (65) hide show
  1. package/dist/dev.js +2033 -1291
  2. package/dist/node.cjs +1821 -2401
  3. package/dist/node.dev.cjs +13724 -0
  4. package/dist/prod/boundaries.js +3 -1
  5. package/dist/prod/core/async.js +6 -1
  6. package/dist/prod/core/attribution-hooks.js +3 -0
  7. package/dist/prod/core/constants.js +9 -1
  8. package/dist/prod/core/context.js +10 -16
  9. package/dist/prod/core/core.js +215 -139
  10. package/dist/prod/core/dev.js +2 -0
  11. package/dist/prod/core/effect.js +37 -28
  12. package/dist/prod/core/external.js +2 -2
  13. package/dist/prod/core/graph.js +35 -31
  14. package/dist/prod/core/heap.js +34 -40
  15. package/dist/prod/core/lanes.js +41 -27
  16. package/dist/prod/core/optimistic.js +42 -32
  17. package/dist/prod/core/owner.js +32 -32
  18. package/dist/prod/core/scheduler.js +140 -154
  19. package/dist/prod/core/verdict.js +31 -34
  20. package/dist/prod/index.js +0 -2
  21. package/dist/prod/map.js +104 -94
  22. package/dist/prod/signals.js +51 -34
  23. package/dist/prod/store/next/optimistic.js +153 -172
  24. package/dist/prod/store/next/reconcile.js +140 -288
  25. package/dist/prod/store/next/store.js +307 -237
  26. package/dist/prod/store/store.js +2 -2
  27. package/dist/types/core/attribution-hooks.d.ts +64 -0
  28. package/dist/types/core/attribution.d.ts +265 -9
  29. package/dist/types/core/constants.d.ts +8 -0
  30. package/dist/types/core/core.d.ts +12 -3
  31. package/dist/types/core/dev.d.ts +49 -8
  32. package/dist/types/core/heap.d.ts +5 -3
  33. package/dist/types/core/invariants.d.ts +1 -1
  34. package/dist/types/core/lanes.d.ts +10 -0
  35. package/dist/types/core/scheduler.d.ts +9 -4
  36. package/dist/types/signals.d.ts +10 -0
  37. package/dist/types/store/index.d.ts +3 -6
  38. package/dist/types/store/next/optimistic.d.ts +4 -2
  39. package/dist/types/store/next/reconcile.d.ts +5 -12
  40. package/dist/types/store/next/store.d.ts +3 -9
  41. package/dist/types/store/next/target.d.ts +20 -46
  42. package/dist/types/store/store.d.ts +14 -9
  43. package/dist/types-cjs/core/attribution-hooks.d.cts +64 -0
  44. package/dist/types-cjs/core/attribution.d.cts +265 -9
  45. package/dist/types-cjs/core/constants.d.cts +8 -0
  46. package/dist/types-cjs/core/core.d.cts +12 -3
  47. package/dist/types-cjs/core/dev.d.cts +49 -8
  48. package/dist/types-cjs/core/heap.d.cts +5 -3
  49. package/dist/types-cjs/core/invariants.d.cts +1 -1
  50. package/dist/types-cjs/core/lanes.d.cts +10 -0
  51. package/dist/types-cjs/core/scheduler.d.cts +9 -4
  52. package/dist/types-cjs/signals.d.cts +10 -0
  53. package/dist/types-cjs/store/index.d.cts +3 -6
  54. package/dist/types-cjs/store/next/optimistic.d.cts +4 -2
  55. package/dist/types-cjs/store/next/reconcile.d.cts +5 -12
  56. package/dist/types-cjs/store/next/store.d.cts +3 -9
  57. package/dist/types-cjs/store/next/target.d.cts +20 -46
  58. package/dist/types-cjs/store/store.d.cts +14 -9
  59. package/package.json +3 -2
  60. package/dist/prod/store/next/patch-hooks.js +0 -13
  61. package/dist/prod/store/next/patch.js +0 -614
  62. package/dist/types/store/next/patch-hooks.d.ts +0 -41
  63. package/dist/types/store/next/patch.d.ts +0 -91
  64. package/dist/types-cjs/store/next/patch-hooks.d.cts +0 -41
  65. package/dist/types-cjs/store/next/patch.d.cts +0 -91
@@ -1,3 +1,5 @@
1
+ import "./core.js";
2
+
1
3
  const DEV = undefined;
2
4
 
3
5
  export { DEV };
@@ -4,7 +4,9 @@ import { setEffectStatusNotify, ext, createEffectNode, recompute, computed, stal
4
4
 
5
5
  import { unwrapStatusError, StatusError } from "./error.js";
6
6
 
7
- import { GlobalQueue, haltReactivity } from "./scheduler.js";
7
+ import { enqueueSub } from "./heap.js";
8
+
9
+ import { GlobalQueue, haltReactivity, schedule } from "./scheduler.js";
8
10
 
9
11
  /**
10
12
  * Effects are the leaf nodes of our reactive graph. When their sources change, they are
@@ -12,9 +14,9 @@ import { GlobalQueue, haltReactivity } from "./scheduler.js";
12
14
  * sources and recompute
13
15
  */ function effect(t, e, E, f) {
14
16
  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.ge === EFFECT_USER || f?.schedule ? R.C.enqueue(R.ge, runEffect.bind(null, R)) : runEffect(R));
17
+ const n = createEffectNode(t, e, E, r ? EFFECT_USER : EFFECT_RENDER, f);
18
+ recompute(n, true);
19
+ !f?.defer && (n.ge === EFFECT_USER || f?.schedule ? n.C.enqueue(n.ge, runEffect.bind(null, n)) : runEffect(n));
18
20
  }
19
21
 
20
22
  function notifyEffectStatus(t, e) {
@@ -34,8 +36,8 @@ function notifyEffectStatus(t, e) {
34
36
  // `status` arg without node-state writes) don't queue: the status
35
37
  // re-propagates unblocked at commit.
36
38
  if (this.S & STATUS_ERROR) {
37
- this.tt = true;
38
- this.C.enqueue(this.ge, this.nt ??= runEffect.bind(null, this));
39
+ this.He = true;
40
+ this.C.enqueue(this.ge, this.it ??= runEffect.bind(null, this));
39
41
  }
40
42
  return;
41
43
  }
@@ -49,7 +51,7 @@ function notifyEffectStatus(t, e) {
49
51
  }
50
52
 
51
53
  function runEffect(t) {
52
- if (!t.tt || t.ie & REACTIVE_DISPOSED) return;
54
+ if (!t.He || t.ie & REACTIVE_DISPOSED) return;
53
55
  // Error arm (#2840), user effects only: a compute-phase error that is still
54
56
  // the node's settled state at effect time runs the bundle's error handler in
55
57
  // this same imperative, writable scope. Unwrap the StatusError used for
@@ -62,12 +64,12 @@ function runEffect(t) {
62
64
  // same flush must not be hijacked by a later-arriving error status.
63
65
  if (t.S & STATUS_ERROR && t.ge === EFFECT_USER) {
64
66
  const e = unwrapStatusError(t.o?._);
65
- t.At = t.be;
66
- t.tt = false;
67
+ t.Ot = t.be;
68
+ t.He = false;
67
69
  try {
68
- t.Ct ? t.Ct(e, () => {
69
- const e = t.Rt;
70
- t.Rt = undefined;
70
+ t.Rt ? t.Rt(e, () => {
71
+ const e = t.Gt;
72
+ t.Gt = undefined;
71
73
  e?.();
72
74
  }) : console.error(e);
73
75
  } catch (e) {
@@ -78,14 +80,14 @@ function runEffect(t) {
78
80
  }
79
81
  return;
80
82
  }
81
- const e = t.Rt;
82
- t.Rt = undefined;
83
+ const e = t.Gt;
84
+ t.Gt = undefined;
83
85
  try {
84
86
  e?.();
85
- const E = t.Ot(t.be, t.At);
87
+ const E = t.Ct(t.be, t.Ot);
86
88
  if (false && E !== undefined && typeof E !== "function") ;
87
89
  // The final cleanup is invoked by disposeChildren at true disposal.
88
- t.Rt = E;
90
+ t.Gt = E;
89
91
  } catch (e) {
90
92
  ext(t)._ = new StatusError(t, e);
91
93
  t.S |= STATUS_ERROR;
@@ -94,12 +96,12 @@ function runEffect(t) {
94
96
  throw e;
95
97
  }
96
98
  } finally {
97
- t.At = t.be;
98
- t.tt = false;
99
+ t.Ot = t.be;
100
+ t.He = false;
99
101
  }
100
102
  }
101
103
 
102
- GlobalQueue.it = runEffect;
104
+ GlobalQueue.ut = runEffect;
103
105
 
104
106
  /**
105
107
  * Internal tracked effect - bypasses heap, goes directly to effect queue.
@@ -107,31 +109,38 @@ GlobalQueue.it = runEffect;
107
109
  * Uses stale reads.
108
110
  */ function trackedEffect(t, e) {
109
111
  const run = () => {
110
- if (!E.tt || E.ie & REACTIVE_DISPOSED) return;
112
+ // `_modified` is NOT redundant with the heap: the heap dedups within a
113
+ // pass, but a held transition's passes each enqueue `_run` into the same
114
+ // user queue, and this gate is what collapses them into one run at commit.
115
+ if (!E.He || E.ie & REACTIVE_DISPOSED) return;
111
116
  try {
112
- E.tt = false;
117
+ E.He = false;
113
118
  recompute(E);
114
119
  } finally {}
115
120
  };
116
121
  const E = computed(() => {
117
- const e = E.Rt;
118
- E.Rt = undefined;
122
+ const e = E.Gt;
123
+ E.Gt = undefined;
119
124
  e?.();
120
125
  const f = staleValues(t);
121
- E.Rt = f;
126
+ E.Gt = f;
122
127
  }, {
123
128
  ...e,
124
129
  lazy: true
125
130
  });
126
- E.Rt = undefined;
131
+ E.Gt = undefined;
127
132
  E.T = E.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
128
- E.tt = true;
133
+ E.He = true;
129
134
  E.ge = EFFECT_TRACKED;
130
135
  // Status dispatch rides the SHARED notifier (statusNotifierOf keys off
131
136
  // _type): its error arm is behavior-identical to the closure that used to
132
137
  // live here, without the per-node NodeExtension allocation.
133
- E.yt = run;
134
- E.C.enqueue(EFFECT_USER, run);
138
+ E.Ve = run;
139
+ // The first run rides the heap like every wake (GlobalQueue._update), so a
140
+ // tracked effect created inside a render-effect callback runs after that
141
+ // pass's staged writes commit, not before.
142
+ enqueueSub(E);
143
+ schedule();
135
144
  }
136
145
 
137
146
  // Install the shared effect status notifier (statusNotifierOf serves it to
@@ -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.Pt = externalSourceConfig ? wireExternalSource : null;
68
- GlobalQueue.ht = externalSourceConfig ? externalUntrack : null;
67
+ GlobalQueue.Ft = externalSourceConfig ? wireExternalSource : null;
68
+ GlobalQueue.gt = externalSourceConfig ? externalUntrack : null;
69
69
  }
70
70
 
71
71
  function enableExternalSource(e) {
@@ -1,4 +1,6 @@
1
- import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
1
+ import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, CONFIG_SLOT_NODE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
2
+
3
+ import { slotUnobservedHook } from "./core.js";
2
4
 
3
5
  import { deleteFromHeap, queueFor } from "./heap.js";
4
6
 
@@ -8,15 +10,17 @@ import { bumpNotifyEpoch } from "./scheduler.js";
8
10
 
9
11
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
10
12
  function unlinkSubs(e) {
11
- const n = e.ot;
12
- const l = e.lt;
13
+ const n = e.st;
14
+ const l = e.ot;
13
15
  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 {
16
+ const s = e.en;
17
+ if (o !== null) o.en = s; else n.ft = s;
18
+ if (s !== null) s.ae = o; else {
17
19
  n.u = o;
18
20
  if (o === null) {
19
- n.o?.Et?.();
21
+ // Slot nodes (store leaves) dispatch to the ONE shared hook — no
22
+ // per-node unobserved closure, no NodeExtension to hold it.
23
+ if (n.T & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.Nt?.();
20
24
  // No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
21
25
  // A pending node is exempt: its in-flight async work (or the
22
26
  // transition holding it) is an observer — tearing down would orphan
@@ -31,13 +35,13 @@ function unlinkSubs(e) {
31
35
  }
32
36
 
33
37
  function trimStaleDeps(e) {
34
- const n = e.je;
35
- let l = n !== null ? n.lt : e.ut;
38
+ const n = e.Be;
39
+ let l = n !== null ? n.ot : e.lt;
36
40
  if (l !== null) {
37
41
  do {
38
42
  l = unlinkSubs(l);
39
43
  } while (l !== null);
40
- if (n !== null) n.lt = null; else e.ut = null;
44
+ if (n !== null) n.ot = null; else e.lt = null;
41
45
  }
42
46
  }
43
47
 
@@ -46,13 +50,13 @@ function trimStaleDeps(e) {
46
50
  // and skipping early also avoids adding one (hidden-class churn) via the
47
51
  // null-out below.
48
52
  function clearDeps(e) {
49
- let n = e.ut;
53
+ let n = e.lt;
50
54
  if (!n) return;
51
55
  do {
52
56
  n = unlinkSubs(n);
53
57
  } while (n !== null);
54
- e.ut = null;
55
- e.je = null;
58
+ e.lt = null;
59
+ e.Be = null;
56
60
  }
57
61
 
58
62
  function unobserved(e) {
@@ -104,20 +108,20 @@ function link(e, n, l = false) {
104
108
  // not relabel the value dependency as probe-only — the value read is what
105
109
  // real-error propagation and affects() coverage key off, regardless of
106
110
  // read order within the computation.
107
- const o = n.je;
108
- if (o !== null && o.ot === e) {
111
+ const o = n.Be;
112
+ if (o !== null && o.st === e) {
109
113
  o.ve &&= l;
110
114
  return;
111
115
  }
112
- let u = null;
116
+ let s = null;
113
117
  const t = n.ie & REACTIVE_RECOMPUTING_DEPS;
114
118
  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;
119
+ s = o !== null ? o.ot : n.lt;
120
+ if (s !== null && s.st === e) {
121
+ s.vt = n.ze;
122
+ n.Be = s;
119
123
  // First touch of this pass: the previous pass's label is stale.
120
- u.ve = l;
124
+ s.ve = l;
121
125
  return;
122
126
  }
123
127
  }
@@ -126,24 +130,24 @@ function link(e, n, l = false) {
126
130
  // [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
127
131
  // (the old alien-signals `isValidLink` walk, O(n²) when a computation
128
132
  // re-reads earlier deps non-consecutively, e.g. store leaf reads).
129
- const s = e._t;
130
- if (s !== null && s.ce === n && (!t || s.Ft === n.Ke)) {
133
+ const r = e.ft;
134
+ if (r !== null && r.ce === n && (!t || r.vt === n.ze)) {
131
135
  // Gen-matched during a recompute = repeat touch this pass (AND); outside
132
136
  // a recompute there is no pass boundary, so the latest read labels it.
133
- if (t) s.ve &&= l; else s.ve = l;
137
+ if (t) r.ve &&= l; else r.ve = l;
134
138
  return;
135
139
  }
136
- const r = n.je = e._t = {
137
- ot: e,
140
+ const u = n.Be = e.ft = {
141
+ st: e,
138
142
  ce: n,
139
- lt: u,
140
- en: s,
143
+ ot: s,
144
+ en: r,
141
145
  ae: null,
142
- Ft: n.Ke,
146
+ vt: n.ze,
143
147
  ve: l
144
148
  };
145
- if (o !== null) o.lt = r; else n.ut = r;
146
- if (s !== null) s.ae = r; else e.u = r;
149
+ if (o !== null) o.ot = u; else n.lt = u;
150
+ if (r !== null) r.ae = u; else e.u = u;
147
151
  // New subscriber edge: staged-rewrite skips (§12d) must not miss it.
148
152
  bumpNotifyEpoch();
149
153
  }
@@ -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_ZOMBIE, REACTIVE_RECOMPUTING_DEPS, REACTIVE_MANUAL_WRITE, REACTIVE_CHECK, REACTIVE_DIRTY, CONFIG_FW_CHILDREN } from "./constants.js";
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";
4
4
 
5
5
  import { zombieQueue, dirtyQueue } from "./scheduler.js";
6
6
 
@@ -9,35 +9,29 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
9
9
  }
10
10
 
11
11
  /**
12
- * Schedule one subscriber to re-run on the next flush: tracked effects bypass
13
- * the heap and go directly to their effect queue; everything else is inserted
14
- * into its own (zombie-flag-routed) heap with the `_min` cursor pulled down.
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).
15
17
  */ function enqueueSub(e) {
16
- if (e.ge === EFFECT_TRACKED) {
17
- const E = e;
18
- if (!E.tt) {
19
- E.tt = true;
20
- E.C.enqueue(EFFECT_USER, E.yt);
21
- }
22
- return;
23
- }
24
18
  const E = queueFor(e);
25
- if (E.Qe > e.Me) E.Qe = e.Me;
19
+ if (E.Me > e.qe) E.Me = e.qe;
26
20
  insertIntoHeap(e, E);
27
21
  }
28
22
 
29
23
  function actualInsertIntoHeap(e, E) {
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
- const I = E.eE[n];
34
- if (I === undefined) E.eE[n] = e; else {
35
- const E = I.ct;
36
- E.rt = e;
24
+ const t = (e.Le?.Dt ? e.Le.Pt?.qe : e.Le?.qe) ?? -1;
25
+ if (t >= e.qe) e.qe = t + 1;
26
+ const I = e.qe;
27
+ const n = E.eE[I];
28
+ if (n === undefined) E.eE[I] = e; else {
29
+ const E = n.ct;
30
+ E._t = e;
37
31
  e.ct = E;
38
- I.ct = e;
32
+ n.ct = e;
39
33
  }
40
- if (n > E.EE) E.EE = n;
34
+ if (I > E.EE) E.EE = I;
41
35
  }
42
36
 
43
37
  function insertIntoHeap(e, E) {
@@ -71,23 +65,23 @@ function deleteFromHeap(e, E) {
71
65
  const t = e.ie;
72
66
  if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
73
67
  e.ie = t & -25;
74
- const n = e.Me;
75
- if (e.ct === e) E.eE[n] = undefined; else {
76
- const t = e.rt;
77
- const I = E.eE[n];
78
- const o = t ?? I;
79
- if (e === I) E.eE[n] = t; else e.ct.rt = t;
68
+ const I = e.qe;
69
+ if (e.ct === e) E.eE[I] = undefined; else {
70
+ const t = e._t;
71
+ const n = E.eE[I];
72
+ const o = t ?? n;
73
+ if (e === n) E.eE[I] = t; else e.ct._t = t;
80
74
  o.ct = e.ct;
81
75
  }
82
76
  e.ct = e;
83
- e.rt = undefined;
77
+ e._t = undefined;
84
78
  }
85
79
 
86
80
  function markHeap(e) {
87
81
  if (e.tE) return;
88
82
  e.tE = true;
89
83
  for (let E = 0; E <= e.EE; E++) {
90
- for (let t = e.eE[E]; t !== undefined; t = t.rt) {
84
+ for (let t = e.eE[E]; t !== undefined; t = t._t) {
91
85
  if (t.ie & REACTIVE_IN_HEAP) markNode(t);
92
86
  }
93
87
  }
@@ -114,11 +108,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
114
108
 
115
109
  function runHeap(e, E) {
116
110
  e.tE = false;
117
- for (e.Qe = 0; e.Qe <= e.EE; e.Qe++) {
118
- let t = e.eE[e.Qe];
111
+ for (e.Me = 0; e.Me <= e.EE; e.Me++) {
112
+ let t = e.eE[e.Me];
119
113
  while (t !== undefined) {
120
114
  if (t.ie & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
121
- t = e.eE[e.Qe];
115
+ t = e.eE[e.Me];
122
116
  }
123
117
  }
124
118
  e.EE = 0;
@@ -126,14 +120,14 @@ function runHeap(e, E) {
126
120
 
127
121
  function adjustHeight(e, E) {
128
122
  deleteFromHeap(e, E);
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;
123
+ let t = e.qe;
124
+ for (let E = e.lt; E; E = E.ot) {
125
+ const e = E.st;
126
+ const I = e.rt || e;
127
+ if (I.oe && I.qe >= t) t = I.qe + 1;
134
128
  }
135
- if (e.Me !== t) {
136
- e.Me = t;
129
+ if (e.qe !== t) {
130
+ e.qe = t;
137
131
  for (let E = e.u; E !== null; E = E.ae) {
138
132
  // Route each subscriber by its own zombie flag, mirroring the
139
133
  // post-recompute height-adjust path. Inserting into the running `heap`
@@ -20,9 +20,9 @@ const activeLanes = new Set;
20
20
  }
21
21
  // Detect parent lane: _parentSource chains from pendingSignal → pendingValueComputed → original.
22
22
  // The child lane should not merge with the parent lane.
23
- const i = n.o?.Tt;
24
- const t = i?.o?.Je;
25
- const r = t ? findLane(t) : null;
23
+ const t = n.o?.St;
24
+ const i = t?.o?.$e;
25
+ const r = i ? findLane(i) : null;
26
26
  e = {
27
27
  nn: n,
28
28
  Oe: new Set,
@@ -46,12 +46,12 @@ const activeLanes = new Set;
46
46
 
47
47
  function adoptCompanionLane(n, e) {
48
48
  if (!n) return;
49
- const i = signalLanes.get(n);
50
- if (!i) return;
51
- const t = findLane(i);
49
+ const t = signalLanes.get(n);
50
+ if (!t) return;
51
+ const i = findLane(t);
52
52
  // Only the companion's own unmerged root is safely re-parentable: a root
53
53
  // that absorbed other lanes carries work that is not a child of this owner.
54
- if (t !== e && t.nn === n && !t.an) t.an = e;
54
+ if (i !== e && i.nn === n && !i.an) i.an = e;
55
55
  }
56
56
 
57
57
  /**
@@ -61,6 +61,20 @@ function adoptCompanionLane(n, e) {
61
61
  return n;
62
62
  }
63
63
 
64
+ /**
65
+ * Is the lane held? `_pendingAsync` records the async the lane OWNS (derived
66
+ * under it); the transaction's reporter map records the async a render effect
67
+ * OBSERVED pending with no boundary taking it (INV-3, the one registration
68
+ * site). A hold needs both — the same rule the transaction itself uses, so a
69
+ * memo nobody renders, or one a fallback-showing boundary caught, cannot tear
70
+ * a frame and holds nothing (#3289). An orphan lane has no observation record
71
+ * and never holds.
72
+ */ function laneHeld(n) {
73
+ const e = n.Ae;
74
+ if (e) for (const t of n.Oe) if (currentTransition(e)._e.has(t)) return true;
75
+ return false;
76
+ }
77
+
64
78
  /**
65
79
  * Merge two lanes when their dependency graphs overlap.
66
80
  */ function mergeLanes(n, e) {
@@ -71,7 +85,7 @@ function adoptCompanionLane(n, e) {
71
85
  // Move (not copy) the merged lane's work: after the merge all routing goes
72
86
  // through findLane() to the root, so anything left behind here is dead —
73
87
  // and anything *added* here later is a routing bug (INV-5).
74
- for (const i of e.Oe) n.Oe.add(i);
88
+ for (const t of e.Oe) n.Oe.add(t);
75
89
  e.Oe.clear();
76
90
  n.tn[0].push(...e.tn[0]);
77
91
  n.tn[1].push(...e.tn[1]);
@@ -83,11 +97,11 @@ function adoptCompanionLane(n, e) {
83
97
  /**
84
98
  * Resolve a node's lane: follow union-find chain, verify active, clear if stale.
85
99
  */ function resolveLane(n) {
86
- const e = n.o?.Je;
100
+ const e = n.o?.$e;
87
101
  if (!e) return undefined;
88
- const i = findLane(e);
89
- if (activeLanes.has(i)) return i;
90
- if (n.o !== null) n.o.Je = undefined;
102
+ const t = findLane(e);
103
+ if (activeLanes.has(t)) return t;
104
+ if (n.o !== null) n.o.$e = undefined;
91
105
  return undefined;
92
106
  }
93
107
 
@@ -97,10 +111,10 @@ function resolveTransition(n) {
97
111
  // transactions (#2912) — the merged root's _transition would hand this
98
112
  // node's override to whichever action wrote last through the shared
99
113
  // reader. Chase merge chains; a dead owner settled through another path.
100
- if (hasActiveOverride(n) && n.o?.Nt) {
101
- const e = ext(n).Nt = currentTransition(n.o?.Nt);
114
+ if (hasActiveOverride(n) && n.o?.Tt) {
115
+ const e = ext(n).Tt = currentTransition(n.o?.Tt);
102
116
  if (e.sn !== true) return e;
103
- if (n.o !== null) n.o.Nt = null;
117
+ if (n.o !== null) n.o.Tt = null;
104
118
  }
105
119
  return resolveLane(n)?.Ae ?? n.Ae;
106
120
  }
@@ -116,32 +130,32 @@ function resolveTransition(n) {
116
130
  * Assign or merge a lane onto a node. At convergence points (node already has
117
131
  * a different active lane), merge unless the node has an active override.
118
132
  */ function assignOrMergeLane(n, e) {
119
- const i = findLane(e);
120
- const t = n.o?.Je;
121
- if (t) {
133
+ const t = findLane(e);
134
+ const i = n.o?.$e;
135
+ if (i) {
122
136
  // If the subscriber's lane was merged into another lane, it's stale —
123
137
  // replace it with the new source lane instead of following the merge chain
124
138
  // (which would incorrectly merge the new lane into the old group)
125
- if (t.rn) {
126
- ext(n).Je = e;
139
+ if (i.rn) {
140
+ ext(n).$e = e;
127
141
  n.T |= CONFIG_HAS_LANE;
128
142
  return;
129
143
  }
130
- const r = findLane(t);
144
+ const r = findLane(i);
131
145
  if (activeLanes.has(r)) {
132
- if (r !== i && !hasActiveOverride(n)) {
146
+ if (r !== t && !hasActiveOverride(n)) {
133
147
  // Parent-child lanes stay independent so isPending resolves without
134
148
  // waiting for the parent's async. The child keeps ownership.
135
- if (i.an && findLane(i.an) === r) {
136
- ext(n).Je = e;
149
+ if (t.an && findLane(t.an) === r) {
150
+ ext(n).$e = e;
137
151
  n.T |= CONFIG_HAS_LANE;
138
- } else if (r.an && findLane(r.an) === i) ; else mergeLanes(i, r);
152
+ } else if (r.an && findLane(r.an) === t) ; else mergeLanes(t, r);
139
153
  }
140
154
  return;
141
155
  }
142
156
  }
143
- ext(n).Je = e;
157
+ ext(n).$e = e;
144
158
  n.T |= CONFIG_HAS_LANE;
145
159
  }
146
160
 
147
- export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane, resolveTransition, signalLanes };
161
+ export { activeLanes, assignOrMergeLane, findLane, getOrCreateLane, hasActiveOverride, laneHeld, mergeLanes, resolveLane, resolveTransition, signalLanes };