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

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 (134) hide show
  1. package/dist/dev-shared.js +6357 -0
  2. package/dist/dev.attribution.js +2485 -0
  3. package/dist/dev.js +2851 -7027
  4. package/dist/observe/affects.js +129 -0
  5. package/dist/observe/attribution.js +7 -0
  6. package/dist/observe/boundaries.js +641 -0
  7. package/dist/observe/core/action.js +177 -0
  8. package/dist/observe/core/async.js +846 -0
  9. package/dist/observe/core/attribution-costs.js +66 -0
  10. package/dist/observe/core/attribution-feedback.js +282 -0
  11. package/dist/observe/core/attribution-hooks.js +82 -0
  12. package/dist/observe/core/attribution-queries.js +28 -0
  13. package/dist/observe/core/attribution.js +2095 -0
  14. package/dist/observe/core/constants.js +248 -0
  15. package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
  16. package/dist/observe/core/core.js +1789 -0
  17. package/dist/observe/core/dev.js +293 -0
  18. package/dist/observe/core/effect.js +195 -0
  19. package/dist/observe/core/error-hooks.js +71 -0
  20. package/dist/observe/core/error.js +80 -0
  21. package/dist/observe/core/external.js +98 -0
  22. package/dist/observe/core/graph.js +155 -0
  23. package/dist/observe/core/heap.js +147 -0
  24. package/dist/observe/core/invariants.js +45 -0
  25. package/dist/observe/core/lanes.js +205 -0
  26. package/dist/observe/core/optimistic.js +585 -0
  27. package/dist/observe/core/owner.js +322 -0
  28. package/dist/observe/core/scheduler.js +1428 -0
  29. package/dist/observe/core/verdict.js +669 -0
  30. package/dist/observe/index.js +59 -0
  31. package/dist/observe/map.js +484 -0
  32. package/dist/{types-cjs/signals.d.cts → observe/signals.js} +311 -317
  33. package/dist/observe/store/index.js +40 -0
  34. package/dist/observe/store/next/optimistic.js +660 -0
  35. package/dist/observe/store/next/projection.js +255 -0
  36. package/dist/observe/store/next/reconcile.js +375 -0
  37. package/dist/observe/store/next/store.js +2327 -0
  38. package/dist/observe/store/next/target.js +51 -0
  39. package/dist/observe/store/store.js +325 -0
  40. package/dist/observe/store/storePath.js +103 -0
  41. package/dist/observe/store/utils.js +1023 -0
  42. package/dist/prod/attribution.js +41 -0
  43. package/dist/prod/boundaries.js +128 -76
  44. package/dist/prod/core/action.js +65 -37
  45. package/dist/prod/core/async.js +324 -172
  46. package/dist/prod/core/constants.js +57 -1
  47. package/dist/prod/core/context.js +3 -3
  48. package/dist/prod/core/core.js +1003 -364
  49. package/dist/prod/core/dev.js +17 -1
  50. package/dist/prod/core/effect.js +76 -42
  51. package/dist/prod/core/error-hooks.js +71 -0
  52. package/dist/prod/core/external.js +4 -4
  53. package/dist/prod/core/graph.js +37 -37
  54. package/dist/prod/core/heap.js +61 -56
  55. package/dist/prod/core/lanes.js +107 -63
  56. package/dist/prod/core/optimistic.js +374 -93
  57. package/dist/prod/core/owner.js +62 -46
  58. package/dist/prod/core/scheduler.js +653 -286
  59. package/dist/prod/core/verdict.js +245 -127
  60. package/dist/prod/index.js +15 -5
  61. package/dist/prod/map.js +292 -141
  62. package/dist/prod/signals.js +29 -16
  63. package/dist/prod/store/next/optimistic.js +77 -55
  64. package/dist/prod/store/next/projection.js +31 -20
  65. package/dist/prod/store/next/reconcile.js +87 -84
  66. package/dist/prod/store/next/store.js +718 -401
  67. package/dist/prod/store/next/target.js +32 -10
  68. package/dist/prod/store/store.js +12 -14
  69. package/dist/prod/store/utils.js +950 -130
  70. package/dist/types/attribution.d.ts +20 -0
  71. package/dist/types/attribution.prod.d.ts +22 -0
  72. package/dist/types/boundaries.d.ts +10 -1
  73. package/dist/types/core/action.d.ts +12 -5
  74. package/dist/types/core/async.d.ts +1 -1
  75. package/dist/types/core/attribution-costs.d.ts +35 -0
  76. package/dist/types/core/attribution-feedback.d.ts +133 -0
  77. package/dist/types/core/attribution-hooks.d.ts +147 -9
  78. package/dist/types/core/attribution-queries.d.ts +10 -0
  79. package/dist/types/core/attribution.d.ts +216 -182
  80. package/dist/types/core/constants.d.ts +56 -0
  81. package/dist/types/core/core.d.ts +190 -2
  82. package/dist/types/core/dev.d.ts +246 -28
  83. package/dist/types/core/effect.d.ts +8 -1
  84. package/dist/types/core/error-hooks.d.ts +71 -0
  85. package/dist/types/core/index.d.ts +4 -1
  86. package/dist/types/core/invariants.d.ts +4 -0
  87. package/dist/types/core/lanes.d.ts +39 -5
  88. package/dist/types/core/scheduler.d.ts +153 -0
  89. package/dist/types/core/types.d.ts +32 -9
  90. package/dist/types/index.d.ts +10 -3
  91. package/dist/types/map.d.ts +2 -0
  92. package/dist/types/signals.d.ts +8 -0
  93. package/dist/types/store/index.d.ts +2 -0
  94. package/dist/types/store/next/optimistic.d.ts +1 -1
  95. package/dist/types/store/next/store.d.ts +11 -5
  96. package/dist/types/store/next/target.d.ts +37 -10
  97. package/dist/types/store/utils.d.ts +178 -0
  98. package/package.json +21 -17
  99. package/dist/node.cjs +0 -10541
  100. package/dist/node.dev.cjs +0 -13724
  101. package/dist/types-cjs/affects.d.cts +0 -47
  102. package/dist/types-cjs/boundaries.d.cts +0 -175
  103. package/dist/types-cjs/core/action.d.cts +0 -64
  104. package/dist/types-cjs/core/async.d.cts +0 -23
  105. package/dist/types-cjs/core/attribution-hooks.d.cts +0 -127
  106. package/dist/types-cjs/core/attribution.d.cts +0 -495
  107. package/dist/types-cjs/core/constants.d.cts +0 -159
  108. package/dist/types-cjs/core/core.d.cts +0 -185
  109. package/dist/types-cjs/core/dev.d.cts +0 -136
  110. package/dist/types-cjs/core/effect.d.cts +0 -30
  111. package/dist/types-cjs/core/error.d.cts +0 -56
  112. package/dist/types-cjs/core/external.d.cts +0 -15
  113. package/dist/types-cjs/core/graph.d.cts +0 -28
  114. package/dist/types-cjs/core/heap.d.cts +0 -24
  115. package/dist/types-cjs/core/index.d.cts +0 -13
  116. package/dist/types-cjs/core/invariants.d.cts +0 -59
  117. package/dist/types-cjs/core/lanes.d.cts +0 -54
  118. package/dist/types-cjs/core/optimistic.d.cts +0 -6
  119. package/dist/types-cjs/core/owner.d.cts +0 -124
  120. package/dist/types-cjs/core/scheduler.d.cts +0 -236
  121. package/dist/types-cjs/core/types.d.cts +0 -204
  122. package/dist/types-cjs/core/verdict.d.cts +0 -2
  123. package/dist/types-cjs/index.d.cts +0 -10
  124. package/dist/types-cjs/map.d.cts +0 -69
  125. package/dist/types-cjs/package.json +0 -3
  126. package/dist/types-cjs/store/index.d.cts +0 -18
  127. package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
  128. package/dist/types-cjs/store/next/projection.d.cts +0 -8
  129. package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
  130. package/dist/types-cjs/store/next/store.d.cts +0 -121
  131. package/dist/types-cjs/store/next/target.d.cts +0 -166
  132. package/dist/types-cjs/store/store.d.cts +0 -143
  133. package/dist/types-cjs/store/storePath.d.cts +0 -58
  134. package/dist/types-cjs/store/utils.d.cts +0 -74
@@ -2,4 +2,20 @@ import "./core.js";
2
2
 
3
3
  const DEV = undefined;
4
4
 
5
- export { DEV };
5
+ /**
6
+ * Root-first names of the owners enclosing `subject` (inclusive when the
7
+ * subject is itself a named owner). Signals hop to their registering owner
8
+ * (`_owner`, set by registerGraph). Unnamed owners are skipped so the path
9
+ * reads as the component tree plus the scope: `<App> › <TodoRow> › effect`.
10
+ */ function ownerPath(n) {
11
+ if (!n) return undefined;
12
+ let e = "_parent" in n ? n : n.se ?? null;
13
+ const t = [];
14
+ for (;e !== null; e = e._parent) {
15
+ const n = e._name;
16
+ if (typeof n === "string" && n.length) t.push(n);
17
+ }
18
+ return t.length ? t.reverse() : undefined;
19
+ }
20
+
21
+ export { DEV, ownerPath };
@@ -1,31 +1,36 @@
1
- import { REACTIVE_DISPOSED, STATUS_ERROR, EFFECT_USER, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, STATUS_PENDING } from "./constants.js";
1
+ import { REACTIVE_DISPOSED, LANE_RUN, STATUS_ERROR, EFFECT_USER, NOT_PENDING, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, STATUS_PENDING } from "./constants.js";
2
2
 
3
3
  import { setEffectStatusNotify, ext, createEffectNode, recompute, computed, staleValues } from "./core.js";
4
4
 
5
5
  import { unwrapStatusError, StatusError } from "./error.js";
6
6
 
7
+ import { trimStaleDeps } from "./graph.js";
8
+
7
9
  import { enqueueSub } from "./heap.js";
8
10
 
9
- import { GlobalQueue, haltReactivity, schedule } from "./scheduler.js";
11
+ import { GlobalQueue, currentTransition, activeTransition, haltReactivity, schedule } from "./scheduler.js";
10
12
 
11
13
  /**
12
14
  * Effects are the leaf nodes of our reactive graph. When their sources change, they are
13
15
  * automatically added to the queue of effects to re-execute, which will cause them to fetch their
14
16
  * sources and recompute
15
- */ function effect(t, e, E, f) {
16
- const r = !!f?.user;
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));
17
+ */ function effect(t, e, E, r) {
18
+ const n = !!r?.user;
19
+ const i = createEffectNode(t, e, E, n ? EFFECT_USER : EFFECT_RENDER, r);
20
+ recompute(i, true);
21
+ // A first pass that derived from a live transaction's staged world was
22
+ // staged into that transaction (recompute: born held); the transaction's
23
+ // commit replays this effect. Its first run is not this creation's (A29).
24
+ !r?.defer && i.ve === NOT_PENDING && (i.Le === EFFECT_USER || r?.schedule ? i.C.enqueue(i.Le, runEffect.bind(null, i)) : runEffect(i, LANE_RUN));
20
25
  }
21
26
 
22
27
  function notifyEffectStatus(t, e) {
23
28
  // Use passed values if provided, otherwise read from node
24
29
  const E = t !== undefined ? t : this.S;
25
- const f = e !== undefined ? e : this.o?._;
30
+ const r = e !== undefined ? e : this.o?._;
26
31
  if (E & STATUS_ERROR) {
27
32
  this.C.notify(this, STATUS_PENDING, 0);
28
- if (this.ge === EFFECT_USER) {
33
+ if (this.Le === EFFECT_USER) {
29
34
  // The error handler is the error arm of the effect phase (#2840 ruling):
30
35
  // queue it like the effect function. It runs in the same imperative,
31
36
  // writable scope, throws escalate the same way, and a held transition
@@ -36,22 +41,42 @@ function notifyEffectStatus(t, e) {
36
41
  // `status` arg without node-state writes) don't queue: the status
37
42
  // re-propagates unblocked at commit.
38
43
  if (this.S & STATUS_ERROR) {
39
- this.He = true;
40
- this.C.enqueue(this.ge, this.it ??= runEffect.bind(null, this));
44
+ this.Ye = true;
45
+ this.C.enqueue(this.Le, this.dt ??= runEffect.bind(null, this));
41
46
  }
42
47
  return;
43
48
  }
44
49
  if (!this.C.notify(this, STATUS_ERROR, STATUS_ERROR)) {
45
- haltReactivity(unwrapStatusError(f));
46
- throw f;
50
+ haltReactivity(unwrapStatusError(r));
51
+ throw r;
47
52
  }
48
- } else if (this.ge === EFFECT_RENDER) {
49
- this.C.notify(this, STATUS_PENDING | STATUS_ERROR, E, f);
53
+ } else if (this.Le === EFFECT_RENDER) {
54
+ this.C.notify(this, STATUS_PENDING | STATUS_ERROR, E, r);
50
55
  }
51
56
  }
52
57
 
53
- function runEffect(t) {
54
- if (!t.He || t.ie & REACTIVE_DISPOSED) return;
58
+ function runEffect(t, e) {
59
+ if (!t.Ye || t.ue & REACTIVE_DISPOSED) return;
60
+ // Ownership (#3319): a value computed under a transaction is applied by that
61
+ // transaction's commit. The ordinary effect phase runs with a transaction
62
+ // active only when the flush's finalize ENTERED one (every other path parks
63
+ // or settles first): leave a run owned by a still-held transaction queued —
64
+ // `_modified` stays set — and the next gate stashes it with the owner.
65
+ // Mainline-owned runs (null) apply now. Lanes are exempt by design (they
66
+ // apply their own effects ahead of their transaction — the optimistic view)
67
+ // and mark their runs with LANE_RUN.
68
+
69
+ // Lane exemption has one exception (#3331): a lane runner for an effect that
70
+ // no longer rides a lane — its optimistic source was superseded, so the lane
71
+ // has no optimistic view left to apply, and the value this effect now
72
+ // carries (or will, once its plain recompute lands) belongs to the still-held
73
+ // transaction. Hand the run to the regular queue, where the transaction's
74
+ // gate stashes it with the owner. Lane-less runners with no live owner
75
+ // (reverts, wake-only lanes) apply now.
76
+ if (t.It !== null && !currentTransition(t.It).Tt && (e & LANE_RUN ? !t.o?.Ue : activeTransition !== null)) {
77
+ t.C.enqueue(t.Le, t.dt);
78
+ return;
79
+ }
55
80
  // Error arm (#2840), user effects only: a compute-phase error that is still
56
81
  // the node's settled state at effect time runs the bundle's error handler in
57
82
  // this same imperative, writable scope. Unwrap the StatusError used for
@@ -62,14 +87,14 @@ function runEffect(t) {
62
87
  // Render effects bypass: their errors route to boundaries synchronously in
63
88
  // notifyEffectStatus, and a runner queued by an earlier valueChanged in the
64
89
  // same flush must not be hijacked by a later-arriving error status.
65
- if (t.S & STATUS_ERROR && t.ge === EFFECT_USER) {
90
+ if (t.S & STATUS_ERROR && t.Le === EFFECT_USER) {
66
91
  const e = unwrapStatusError(t.o?._);
67
- t.Ot = t.be;
68
- t.He = false;
92
+ t.Ut = t.Qe;
93
+ t.Ye = false;
69
94
  try {
70
- t.Rt ? t.Rt(e, () => {
71
- const e = t.Gt;
72
- t.Gt = undefined;
95
+ t.Vt ? t.Vt(e, () => {
96
+ const e = t.yt;
97
+ t.yt = undefined;
73
98
  e?.();
74
99
  }) : console.error(e);
75
100
  } catch (e) {
@@ -80,14 +105,17 @@ function runEffect(t) {
80
105
  }
81
106
  return;
82
107
  }
83
- const e = t.Gt;
84
- t.Gt = undefined;
108
+ // Captured before the callback: its own throw errors the node below, but
109
+ // the compute pass that produced `_value` was clean, so its tail still goes.
110
+ const E = t.o?._ == null;
111
+ const r = t.yt;
112
+ t.yt = undefined;
85
113
  try {
86
- e?.();
87
- const E = t.Ct(t.be, t.Ot);
88
- if (false && E !== undefined && typeof E !== "function") ;
114
+ r?.();
115
+ const e = t.Lt(t.Qe, t.Ut);
116
+ if (false && e !== undefined && typeof e !== "function") ;
89
117
  // The final cleanup is invoked by disposeChildren at true disposal.
90
- t.Gt = E;
118
+ t.yt = e;
91
119
  } catch (e) {
92
120
  ext(t)._ = new StatusError(t, e);
93
121
  t.S |= STATUS_ERROR;
@@ -96,12 +124,18 @@ function runEffect(t) {
96
124
  throw e;
97
125
  }
98
126
  } finally {
99
- t.Ot = t.be;
100
- t.He = false;
127
+ t.Ut = t.Qe;
128
+ t.Ye = false;
129
+ // The run applied: this is the frame now, so the dependency tail the
130
+ // compute pass left linked goes (A30, #3438 — `recompute` defers an
131
+ // effect's trim while a run is owed; the twin of `commitPendingNode`'s
132
+ // trim for a staged pass). An errored compute kept its full list with
133
+ // `_depsTail` marking where it stopped; leave it, as the commit does.
134
+ if (E) trimStaleDeps(t);
101
135
  }
102
136
  }
103
137
 
104
- GlobalQueue.ut = runEffect;
138
+ GlobalQueue.Et = runEffect;
105
139
 
106
140
  /**
107
141
  * Internal tracked effect - bypasses heap, goes directly to effect queue.
@@ -112,30 +146,30 @@ GlobalQueue.ut = runEffect;
112
146
  // `_modified` is NOT redundant with the heap: the heap dedups within a
113
147
  // pass, but a held transition's passes each enqueue `_run` into the same
114
148
  // user queue, and this gate is what collapses them into one run at commit.
115
- if (!E.He || E.ie & REACTIVE_DISPOSED) return;
149
+ if (!E.Ye || E.ue & REACTIVE_DISPOSED) return;
116
150
  try {
117
- E.He = false;
151
+ E.Ye = false;
118
152
  recompute(E);
119
153
  } finally {}
120
154
  };
121
155
  const E = computed(() => {
122
- const e = E.Gt;
123
- E.Gt = undefined;
156
+ const e = E.yt;
157
+ E.yt = undefined;
124
158
  e?.();
125
- const f = staleValues(t);
126
- E.Gt = f;
159
+ const r = staleValues(t);
160
+ E.yt = r;
127
161
  }, {
128
162
  ...e,
129
163
  lazy: true
130
164
  });
131
- E.Gt = undefined;
165
+ E.yt = undefined;
132
166
  E.T = E.T & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
133
- E.He = true;
134
- E.ge = EFFECT_TRACKED;
167
+ E.Ye = true;
168
+ E.Le = EFFECT_TRACKED;
135
169
  // Status dispatch rides the SHARED notifier (statusNotifierOf keys off
136
170
  // _type): its error arm is behavior-identical to the closure that used to
137
171
  // live here, without the per-node NodeExtension allocation.
138
- E.Ve = run;
172
+ E.Ke = run;
139
173
  // The first run rides the heap like every wake (GlobalQueue._update), so a
140
174
  // tracked effect created inside a render-effect callback runs after that
141
175
  // pass's staged writes commit, not before.
@@ -0,0 +1,71 @@
1
+ import { ROOT_ERROR_HOOK } from "./scheduler.js";
2
+
3
+ let ambientHook;
4
+
5
+ const reported = new WeakSet;
6
+
7
+ /**
8
+ * Registers the ambient client error hook — the one call a browser `init()`
9
+ * makes to see every failure a boundary renders a fallback for, in
10
+ * production. (Uncaught errors reach `reportError` / `window.onerror`.)
11
+ *
12
+ * ```ts
13
+ * configureClientErrors({
14
+ * onError: (error, { ownerPath }) =>
15
+ * Sentry.captureException(error, {
16
+ * mechanism: { type: "solid.error_boundary", handled: true }
17
+ * })
18
+ * });
19
+ * ```
20
+ */ function configureClientErrors(e) {
21
+ if (e && e.onError !== undefined && typeof e.onError !== "function") {
22
+ throw new TypeError(`Invalid onError: expected a function, received ${typeof e.onError}.`);
23
+ }
24
+ ambientHook = e ? e.onError : undefined;
25
+ }
26
+
27
+ /** The nearest root's hook above `owner` (parked under `ROOT_ERROR_HOOK`), else the ambient one. */ function hookFor(e) {
28
+ for (let n = e; n; n = n._parent) {
29
+ const e = n[ROOT_ERROR_HOOK];
30
+ if (e !== undefined) return e;
31
+ }
32
+ return ambientHook;
33
+ }
34
+
35
+ /** Component labels up the owner chain, root first — `_name` where the runtime keeps it. */ function labels(e) {
36
+ const n = [];
37
+ for (let o = e; o; o = o._parent) {
38
+ const e = o._name;
39
+ if (typeof e === "string" && e.length) n.push(e);
40
+ }
41
+ return n.length ? n.reverse() : undefined;
42
+ }
43
+
44
+ /**
45
+ * Tells the client error hook about `error`, caught by the boundary whose
46
+ * owner is `owner`, thrown by `thrower` (the computation the engine's status
47
+ * wrapper named; unknown for a value that never crossed one) — once per
48
+ * error object. A throwing hook is reported on the console and otherwise
49
+ * ignored — a monitor must never take the app down.
50
+ * @internal
51
+ */ function reportClientError(e, n, o) {
52
+ const r = e !== null && (typeof e === "object" || typeof e === "function");
53
+ if (r) {
54
+ if (reported.has(e)) return;
55
+ reported.add(e);
56
+ }
57
+ const t = hookFor(n);
58
+ if (t === undefined) return;
59
+ const i = {};
60
+ const f = labels(n);
61
+ const c = labels(o) ?? f;
62
+ if (c !== undefined) i.ownerPath = c;
63
+ if (f !== undefined) i.boundaryPath = f;
64
+ try {
65
+ t(e, i);
66
+ } catch (e) {
67
+ console.error(e);
68
+ }
69
+ }
70
+
71
+ export { configureClientErrors, reportClientError };
@@ -46,11 +46,11 @@ function wireExternalSource(e) {
46
46
  equals: false,
47
47
  ownedWrite: true
48
48
  });
49
- const r = externalSourceConfig.factory(e.oe, () => {
49
+ const r = externalSourceConfig.factory(e.ce, () => {
50
50
  setSignal(n, undefined);
51
51
  });
52
52
  cleanup(() => r.dispose());
53
- e.oe = e => {
53
+ e.ce = 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.Ft = externalSourceConfig ? wireExternalSource : null;
68
- GlobalQueue.gt = externalSourceConfig ? externalUntrack : null;
67
+ GlobalQueue.wt = externalSourceConfig ? wireExternalSource : null;
68
+ GlobalQueue.Yt = externalSourceConfig ? externalUntrack : null;
69
69
  }
70
70
 
71
71
  function enableExternalSource(e) {
@@ -10,17 +10,17 @@ import { bumpNotifyEpoch } from "./scheduler.js";
10
10
 
11
11
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
12
12
  function unlinkSubs(e) {
13
- const n = e.st;
14
- const l = e.ot;
15
- const o = e.ae;
16
- const s = e.en;
17
- if (o !== null) o.en = s; else n.ft = s;
18
- if (s !== null) s.ae = o; else {
13
+ const n = e.Ee;
14
+ const l = e.de;
15
+ const o = e.Ne;
16
+ const s = e.rn;
17
+ if (o !== null) o.rn = s; else n.Gt = s;
18
+ if (s !== null) s.Ne = o; else {
19
19
  n.u = o;
20
20
  if (o === null) {
21
21
  // Slot nodes (store leaves) dispatch to the ONE shared hook — no
22
22
  // per-node unobserved closure, no NodeExtension to hold it.
23
- if (n.T & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.Nt?.();
23
+ if (n.T & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.Pt?.();
24
24
  // No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
25
25
  // A pending node is exempt: its in-flight async work (or the
26
26
  // transition holding it) is an observer — tearing down would orphan
@@ -28,20 +28,20 @@ function unlinkSubs(e) {
28
28
  // this same last-one-out check when that observer releases (the
29
29
  // untracked-read dormancy sweep guards on pending identically).
30
30
  const e = n;
31
- e.oe && e.T & CONFIG_AUTO_DISPOSE && !(e.ie & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
31
+ e.ce && e.T & CONFIG_AUTO_DISPOSE && !(e.ue & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
32
32
  }
33
33
  }
34
34
  return l;
35
35
  }
36
36
 
37
37
  function trimStaleDeps(e) {
38
- const n = e.Be;
39
- let l = n !== null ? n.ot : e.lt;
38
+ const n = e.ot;
39
+ let l = n !== null ? n.de : e.Se;
40
40
  if (l !== null) {
41
41
  do {
42
42
  l = unlinkSubs(l);
43
43
  } while (l !== null);
44
- if (n !== null) n.ot = null; else e.lt = null;
44
+ if (n !== null) n.de = null; else e.Se = null;
45
45
  }
46
46
  }
47
47
 
@@ -50,13 +50,13 @@ function trimStaleDeps(e) {
50
50
  // and skipping early also avoids adding one (hidden-class churn) via the
51
51
  // null-out below.
52
52
  function clearDeps(e) {
53
- let n = e.lt;
53
+ let n = e.Se;
54
54
  if (!n) return;
55
55
  do {
56
56
  n = unlinkSubs(n);
57
57
  } while (n !== null);
58
- e.lt = null;
59
- e.Be = null;
58
+ e.Se = null;
59
+ e.ot = null;
60
60
  }
61
61
 
62
62
  function unobserved(e) {
@@ -94,7 +94,7 @@ function sweepDormant() {
94
94
  // is an observer; the settle path re-runs last-one-out), lost its
95
95
  // AUTO_DISPOSE bit (owner teardown strips it, #3024), or already been
96
96
  // torn down.
97
- if (!e.u && e.T & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.ie & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
97
+ if (!e.u && e.T & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.ue & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
98
98
  unobserved(e);
99
99
  }
100
100
  }
@@ -108,20 +108,20 @@ function link(e, n, l = false) {
108
108
  // not relabel the value dependency as probe-only — the value read is what
109
109
  // real-error propagation and affects() coverage key off, regardless of
110
110
  // read order within the computation.
111
- const o = n.Be;
112
- if (o !== null && o.st === e) {
113
- o.ve &&= l;
111
+ const o = n.ot;
112
+ if (o !== null && o.Ee === e) {
113
+ o.He &&= l;
114
114
  return;
115
115
  }
116
116
  let s = null;
117
- const t = n.ie & REACTIVE_RECOMPUTING_DEPS;
117
+ const t = n.ue & REACTIVE_RECOMPUTING_DEPS;
118
118
  if (t) {
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
+ s = o !== null ? o.de : n.Se;
120
+ if (s !== null && s.Ee === e) {
121
+ s.qe = n.Ze;
122
+ n.ot = s;
123
123
  // First touch of this pass: the previous pass's label is stale.
124
- s.ve = l;
124
+ s.He = l;
125
125
  return;
126
126
  }
127
127
  }
@@ -130,24 +130,24 @@ function link(e, n, l = false) {
130
130
  // [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
131
131
  // (the old alien-signals `isValidLink` walk, O(n²) when a computation
132
132
  // re-reads earlier deps non-consecutively, e.g. store leaf reads).
133
- const r = e.ft;
134
- if (r !== null && r.ce === n && (!t || r.vt === n.ze)) {
133
+ const r = e.Gt;
134
+ if (r !== null && r._e === n && (!t || r.qe === n.Ze)) {
135
135
  // Gen-matched during a recompute = repeat touch this pass (AND); outside
136
136
  // a recompute there is no pass boundary, so the latest read labels it.
137
- if (t) r.ve &&= l; else r.ve = l;
137
+ if (t) r.He &&= l; else r.He = l;
138
138
  return;
139
139
  }
140
- const u = n.Be = e.ft = {
141
- st: e,
142
- ce: n,
143
- ot: s,
144
- en: r,
145
- ae: null,
146
- vt: n.ze,
147
- ve: l
140
+ const u = n.ot = e.Gt = {
141
+ Ee: e,
142
+ _e: n,
143
+ de: s,
144
+ rn: r,
145
+ Ne: null,
146
+ qe: n.Ze,
147
+ He: l
148
148
  };
149
- if (o !== null) o.ot = u; else n.lt = u;
150
- if (r !== null) r.ae = u; else e.u = u;
149
+ if (o !== null) o.de = u; else n.Se = u;
150
+ if (r !== null) r.Ne = u; else e.u = u;
151
151
  // New subscriber edge: staged-rewrite skips (§12d) must not miss it.
152
152
  bumpNotifyEpoch();
153
153
  }
@@ -5,7 +5,7 @@ import { REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_ZOMBIE, REACTIVE_RE
5
5
  import { zombieQueue, dirtyQueue } from "./scheduler.js";
6
6
 
7
7
  /** The queue a node belongs to, picked from its own zombie flag. */ function queueFor(e) {
8
- return e.ie & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
8
+ return e.ue & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
9
9
  }
10
10
 
11
11
  /**
@@ -16,91 +16,96 @@ import { zombieQueue, dirtyQueue } from "./scheduler.js";
16
16
  * (see GlobalQueue._update, #3291).
17
17
  */ function enqueueSub(e) {
18
18
  const E = queueFor(e);
19
- if (E.Me > e.qe) E.Me = e.qe;
19
+ if (E.et > e.tt) E.et = e.tt;
20
20
  insertIntoHeap(e, E);
21
21
  }
22
22
 
23
23
  function actualInsertIntoHeap(e, 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;
31
- e.ct = E;
32
- n.ct = e;
24
+ const t = (e._parent?.xt ? e._parent.Qt?.tt : e._parent?.tt) ?? -1;
25
+ if (t >= e.tt) e.tt = t + 1;
26
+ const n = e.tt;
27
+ const I = E.eE[n];
28
+ if (I === undefined) E.eE[n] = e; else {
29
+ const E = I.Rt;
30
+ E.At = e;
31
+ e.Rt = E;
32
+ I.Rt = e;
33
33
  }
34
- if (I > E.EE) E.EE = I;
34
+ if (n > E.EE) E.EE = n;
35
35
  }
36
36
 
37
37
  function insertIntoHeap(e, E) {
38
- let t = e.ie;
38
+ let t = e.ue;
39
39
  // RECOMPUTING refusals are not always losses: a genuinely missed wake (a
40
40
  // write to a link this pass already validated) is latched link-side in
41
41
  // insertSubs as REACTIVE_MISSED_WAKE for recompute's tail (#3037).
42
42
  if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_MANUAL_WRITE)) return;
43
43
  if (t & REACTIVE_CHECK) {
44
- e.ie = t & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
44
+ e.ue = t & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
45
45
  } else {
46
- e.ie = t | REACTIVE_IN_HEAP;
47
- // An unmarked node entering a marked heap invalidates the markHeap memo:
48
- // `_marked` is only reset by runHeap, so a write between two mid-tick
49
- // pulls (read-time markHeap + updateIfNecessary) would otherwise leave
50
- // this node unmarked and every downstream pull stale until the next
51
- // flush (#2922: the second `latest()` returned the first write's value).
52
- if (E.tE && !(t & REACTIVE_DIRTY)) E.tE = false;
46
+ e.ue = t | REACTIVE_IN_HEAP;
47
+ // An unmarked node entering an already-marked heap is marked on the
48
+ // spot, keeping the markHeap memo valid. `_marked` is only reset by
49
+ // runHeap, so a write between two mid-tick pulls (read-time markHeap +
50
+ // updateIfNecessary) would otherwise leave this node unmarked and every
51
+ // downstream pull stale until the next flush (#2922: the second
52
+ // `latest()` returned the first write's value). Invalidating the memo
53
+ // instead re-walked the WHOLE heap on the next pull — with N effects
54
+ // parked in the heap for a synchronous mount (each row writing a ref
55
+ // signal its effect subscribes to), mounting N rows was O(N²) (#3350).
56
+ // markNode's own guard skips an already-DIRTY node.
57
+ if (E.tE) markNode(e);
53
58
  }
54
59
  if (!(t & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, E);
55
60
  }
56
61
 
57
62
  function insertIntoHeapHeight(e, E) {
58
- let t = e.ie;
63
+ let t = e.ue;
59
64
  if (t & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT | REACTIVE_MANUAL_WRITE)) return;
60
- e.ie = t | REACTIVE_IN_HEAP_HEIGHT;
65
+ e.ue = t | REACTIVE_IN_HEAP_HEIGHT;
61
66
  actualInsertIntoHeap(e, E);
62
67
  }
63
68
 
64
69
  function deleteFromHeap(e, E) {
65
- const t = e.ie;
70
+ const t = e.ue;
66
71
  if (!(t & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
67
- e.ie = t & -25;
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;
74
- o.ct = e.ct;
72
+ e.ue = t & -25;
73
+ const n = e.tt;
74
+ if (e.Rt === e) E.eE[n] = undefined; else {
75
+ const t = e.At;
76
+ const I = E.eE[n];
77
+ const o = t ?? I;
78
+ if (e === I) E.eE[n] = t; else e.Rt.At = t;
79
+ o.Rt = e.Rt;
75
80
  }
76
- e.ct = e;
77
- e._t = undefined;
81
+ e.Rt = e;
82
+ e.At = undefined;
78
83
  }
79
84
 
80
85
  function markHeap(e) {
81
86
  if (e.tE) return;
82
87
  e.tE = true;
83
88
  for (let E = 0; E <= e.EE; E++) {
84
- for (let t = e.eE[E]; t !== undefined; t = t._t) {
85
- if (t.ie & REACTIVE_IN_HEAP) markNode(t);
89
+ for (let t = e.eE[E]; t !== undefined; t = t.At) {
90
+ if (t.ue & REACTIVE_IN_HEAP) markNode(t);
86
91
  }
87
92
  }
88
93
  }
89
94
 
90
95
  function markNode(e, E = REACTIVE_DIRTY) {
91
- const t = e.ie;
96
+ const t = e.ue;
92
97
  if ((t & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= E) return;
93
- e.ie = t & -4 | E;
94
- for (let E = e.u; E !== null; E = E.ae) {
95
- markNode(E.ce, REACTIVE_CHECK);
98
+ e.ue = t & -4 | E;
99
+ for (let E = e.u; E !== null; E = E.Ne) {
100
+ markNode(E._e, REACTIVE_CHECK);
96
101
  }
97
102
  // Firewall children (projection machinery only): gate the cold-extension
98
103
  // deref on the config bit — markNode runs per sub edge per write, and an
99
104
  // unconditional _x chase here taxed every propagation (diamond -22%).
100
105
  if (e.T & CONFIG_FW_CHILDREN) {
101
- for (let E = e.o.i; E !== null; E = E.Se) {
102
- for (let e = E.u; e !== null; e = e.ae) {
103
- markNode(e.ce, REACTIVE_CHECK);
106
+ for (let E = e.o.i; E !== null; E = E.De) {
107
+ for (let e = E.u; e !== null; e = e.Ne) {
108
+ markNode(e._e, REACTIVE_CHECK);
104
109
  }
105
110
  }
106
111
  }
@@ -108,11 +113,11 @@ function markNode(e, E = REACTIVE_DIRTY) {
108
113
 
109
114
  function runHeap(e, E) {
110
115
  e.tE = false;
111
- for (e.Me = 0; e.Me <= e.EE; e.Me++) {
112
- let t = e.eE[e.Me];
116
+ for (e.et = 0; e.et <= e.EE; e.et++) {
117
+ let t = e.eE[e.et];
113
118
  while (t !== undefined) {
114
- if (t.ie & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
115
- t = e.eE[e.Me];
119
+ if (t.ue & REACTIVE_IN_HEAP) E(t); else adjustHeight(t, e);
120
+ t = e.eE[e.et];
116
121
  }
117
122
  }
118
123
  e.EE = 0;
@@ -120,21 +125,21 @@ function runHeap(e, E) {
120
125
 
121
126
  function adjustHeight(e, E) {
122
127
  deleteFromHeap(e, E);
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;
128
+ let t = e.tt;
129
+ for (let E = e.Se; E; E = E.de) {
130
+ const e = E.Ee;
131
+ const n = e.Te || e;
132
+ if (n.ce && n.tt >= t) t = n.tt + 1;
128
133
  }
129
- if (e.qe !== t) {
130
- e.qe = t;
131
- for (let E = e.u; E !== null; E = E.ae) {
134
+ if (e.tt !== t) {
135
+ e.tt = t;
136
+ for (let E = e.u; E !== null; E = E.Ne) {
132
137
  // Route each subscriber by its own zombie flag, mirroring the
133
138
  // post-recompute height-adjust path. Inserting into the running `heap`
134
139
  // unconditionally can park a zombie in `dirtyQueue` (or a live node in
135
140
  // `zombieQueue`), breaking the flag/queue invariant `deleteFromHeap`
136
141
  // relies on — the same corruption class as #2759.
137
- insertIntoHeapHeight(E.ce, queueFor(E.ce));
142
+ insertIntoHeapHeight(E._e, queueFor(E._e));
138
143
  }
139
144
  }
140
145
  }