@solidjs/signals 2.0.0-rc.13 → 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 +2000 -3768
  2. package/dist/dev.attribution.js +132 -79
  3. package/dist/dev.js +7226 -8488
  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 +240 -183
  10. package/dist/observe/core/constants.js +115 -187
  11. package/dist/observe/core/context.js +3 -3
  12. package/dist/observe/core/core.js +840 -1438
  13. package/dist/observe/core/dev.js +3 -3
  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 -186
  43. package/dist/prod/core/context.js +3 -3
  44. package/dist/prod/core/core.js +852 -1458
  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 +20 -1
  75. package/dist/types/core/attribution.d.ts +20 -9
  76. package/dist/types/core/constants.d.ts +125 -180
  77. package/dist/types/core/core.d.ts +104 -264
  78. package/dist/types/core/dev.d.ts +2 -2
  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 +5 -5
  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 +6 -4
  91. package/dist/types/reveal.d.ts +19 -0
  92. package/dist/types/signals.d.ts +35 -91
  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 -2608
  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 -2484
  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 -145
  118. package/dist/types/store/next/target.d.ts +0 -196
@@ -149,7 +149,7 @@ let hasExclusions = false;
149
149
 
150
150
  function isExcluded(e) {
151
151
  if (!hasExclusions || !e) return false;
152
- let n = "_parent" in e ? e : e.ie ?? null;
152
+ let n = "_parent" in e ? e : e.H ?? null;
153
153
  for (;n !== null; n = n._parent) {
154
154
  const e = markedOwners.get(n);
155
155
  if (e !== undefined) return e;
@@ -175,7 +175,7 @@ const DEV = undefined;
175
175
  * Public as `OBSERVE.ownerPath`; the core's own sites import it directly.
176
176
  */ function ownerPath(e) {
177
177
  if (!e) return undefined;
178
- let n = "_parent" in e ? e : e.ie ?? null;
178
+ let n = "_parent" in e ? e : e.H ?? null;
179
179
  const t = [];
180
180
  for (;n !== null; n = n._parent) {
181
181
  const e = n._name;
@@ -246,7 +246,7 @@ const DEV = undefined;
246
246
  * locate signal subjects. The per-owner `_signals` list and the devtools
247
247
  * `onGraph` hook are dev-tier — the observe build pays one property write.
248
248
  */ function registerGraph(e, n) {
249
- e.ie = n;
249
+ e.H = n;
250
250
  }
251
251
 
252
252
  /**
@@ -1,6 +1,6 @@
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";
1
+ import { NOT_PENDING, EFFECT_USER, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, EFFECT_TRACKED, EFFECT_RENDER, REACTIVE_DISPOSED, STATUS_ERROR, STATUS_PENDING } from "./constants.js";
2
2
 
3
- import { setEffectStatusNotify, ext, createEffectNode, recompute, computed, staleValues } from "./core.js";
3
+ import { createEffectNode, recompute, computed, staleValues, ext, setEffectStatusNotify } from "./core.js";
4
4
 
5
5
  import { attrHooks } from "./attribution-hooks.js";
6
6
 
@@ -12,75 +12,63 @@ import { trimStaleDeps } from "./graph.js";
12
12
 
13
13
  import { enqueueSub } from "./heap.js";
14
14
 
15
- import { GlobalQueue, currentTransition, activeTransition, haltReactivity, schedule } from "./scheduler.js";
15
+ import { globalQueue, schedule, GlobalQueue, haltReactivity } from "./scheduler.js";
16
16
 
17
17
  /**
18
18
  * Effects are the leaf nodes of our reactive graph. When their sources change, they are
19
19
  * automatically added to the queue of effects to re-execute, which will cause them to fetch their
20
20
  * sources and recompute
21
- */ function effect(t, e, r, E) {
22
- const i = !!E?.user;
23
- const n = createEffectNode(t, e, r, i ? EFFECT_USER : EFFECT_RENDER, E);
24
- recompute(n, true);
25
- // A first pass that derived from a live transaction's staged world was
26
- // staged into that transaction (recompute: born held); the transaction's
27
- // commit replays this effect. Its first run is not this creation's (A29).
28
- !E?.defer && n._e === NOT_PENDING && (n.He === EFFECT_USER || E?.schedule ? n.T.enqueue(n.He, runEffect.bind(null, n)) : runEffect(n, LANE_RUN));
21
+ */ function effect(t, e, u, o) {
22
+ const E = !!o?.user;
23
+ const r = createEffectNode(t, e, u, E ? EFFECT_USER : EFFECT_RENDER, o);
24
+ recompute(r, true);
25
+ // A first pass that read a staged value was staged itself (recompute: born
26
+ // staged); the flush's commit replays this effect. Its first run is not this
27
+ // creation's (A29). A lane's node likewise: its run is the lane's, queued
28
+ // by the pass and released at the reveal (lanes.ts).
29
+ !o?.defer && r.Ae === NOT_PENDING && !r.m?._t?.Z && (r.i === EFFECT_USER || o?.schedule ? globalQueue.enqueue(r.i, runEffect.bind(null, r)) : runEffect(r, r.i));
29
30
  }
30
31
 
31
32
  function notifyEffectStatus(t, e) {
32
33
  // Use passed values if provided, otherwise read from node
33
- const r = t !== undefined ? t : this.S;
34
- const E = e !== undefined ? e : this.o?._;
35
- if (r & STATUS_ERROR) {
36
- this.T.notify(this, STATUS_PENDING, 0);
37
- if (this.He === EFFECT_USER) {
34
+ const u = t !== undefined ? t : this.G;
35
+ const o = e !== undefined ? e : this.m?.v;
36
+ if (u & STATUS_ERROR) {
37
+ globalQueue.notify(this, STATUS_PENDING, 0);
38
+ if (this.i === EFFECT_USER) {
38
39
  // The error handler is the error arm of the effect phase (#2840 ruling):
39
40
  // queue it like the effect function. It runs in the same imperative,
40
- // writable scope, throws escalate the same way, and a held transition
41
- // (or optimistic lane) defers it exactly as it defers the success arm.
42
- // No payload is queued — the node already carries `_statusFlags`/`_error`,
41
+ // writable scope and throws escalate the same way. No payload is queued — the node already carries `_statusFlags`/`_error`,
43
42
  // and the runner dispatches on them, so a recovery before the effect
44
43
  // phase takes the success arm instead. Blocked forwards (explicit
45
44
  // `status` arg without node-state writes) don't queue: the status
46
45
  // re-propagates unblocked at commit.
47
- if (this.S & STATUS_ERROR) {
48
- this.it = true;
49
- this.T.enqueue(this.He, this.Ct ??= runEffect.bind(null, this));
46
+ if (this.G & STATUS_ERROR) {
47
+ this.lt = true;
48
+ globalQueue.enqueue(this.i, this.J ??= runEffect.bind(null, this));
50
49
  }
51
50
  return;
52
51
  }
53
- if (!this.T.notify(this, STATUS_ERROR, STATUS_ERROR)) {
54
- haltReactivity(unwrapStatusError(E));
55
- throw E;
52
+ if (!globalQueue.notify(this, STATUS_ERROR, STATUS_ERROR)) {
53
+ haltReactivity(unwrapStatusError(o));
54
+ throw o;
56
55
  }
57
- } else if (this.He === EFFECT_RENDER) {
58
- this.T.notify(this, STATUS_PENDING | STATUS_ERROR, r, E);
56
+ } else if (this.i === EFFECT_RENDER) {
57
+ globalQueue.notify(this, STATUS_PENDING | STATUS_ERROR, u, o);
59
58
  }
60
59
  }
61
60
 
62
61
  function runEffect(t, e) {
63
- if (!t.it || t.oe & REACTIVE_DISPOSED) return;
64
- // Ownership (#3319): a value computed under a transaction is applied by that
65
- // transaction's commit. The ordinary effect phase runs with a transaction
66
- // active only when the flush's finalize ENTERED one (every other path parks
67
- // or settles first): leave a run owned by a still-held transaction queued —
68
- // `_modified` stays set — and the next gate stashes it with the owner.
69
- // Mainline-owned runs (null) apply now. Lanes are exempt by design (they
70
- // apply their own effects ahead of their transaction — the optimistic view)
71
- // and mark their runs with LANE_RUN.
72
-
73
- // Lane exemption has one exception (#3331): a lane runner for an effect that
74
- // no longer rides a lane — its optimistic source was superseded, so the lane
75
- // has no optimistic view left to apply, and the value this effect now
76
- // carries (or will, once its plain recompute lands) belongs to the still-held
77
- // transaction. Hand the run to the regular queue, where the transaction's
78
- // gate stashes it with the owner. Lane-less runners with no live owner
79
- // (reverts, wake-only lanes) apply now.
80
- if (t.Gt !== null && !currentTransition(t.Gt).Dt && (e & LANE_RUN ? !t.o?.Ce : activeTransition !== null)) {
81
- t.T.enqueue(t.He, t.Ct);
82
- return;
83
- }
62
+ if (!t.lt || t.R & REACTIVE_DISPOSED) return;
63
+ // A queued run behind a fallback (boundaries.ts) waits for the reveal: a
64
+ // user effect's, which would read a DOM that is not attached, and a render
65
+ // effect's update too (maintainer, 2026-10-02: "we held the queue but let
66
+ // the sync renders through… we definitely shouldn't be showing portals
67
+ // early") — a Portal's or head-tag's render effect writes outside the
68
+ // hidden subtree. The synchronous first render on creation is not a queued
69
+ // run and goes through. `_modified` stays set; the boundary re-queues the
70
+ // run (`release`).
71
+ if (GlobalQueue.de && GlobalQueue.de(t)) return;
84
72
  // Error arm (#2840), user effects only: a compute-phase error that is still
85
73
  // the node's settled state at effect time runs the bundle's error handler in
86
74
  // this same imperative, writable scope. Unwrap the StatusError used for
@@ -91,18 +79,18 @@ function runEffect(t, e) {
91
79
  // Render effects bypass: their errors route to boundaries synchronously in
92
80
  // notifyEffectStatus, and a runner queued by an earlier valueChanged in the
93
81
  // same flush must not be hijacked by a later-arriving error status.
94
- if (t.S & STATUS_ERROR && t.He === EFFECT_USER) {
95
- const e = unwrapStatusError(t.o?._);
96
- t.Mt = t.ce;
97
- t.it = false;
82
+ if (t.G & STATUS_ERROR && t.i === EFFECT_USER) {
83
+ const e = unwrapStatusError(t.m?.v);
84
+ t.Nt = t.pe;
85
+ t.lt = false;
98
86
  try {
99
- t.Wt ? t.Wt(e, () => {
100
- const e = t.qt;
101
- t.qt = undefined;
87
+ t.Lt ? t.Lt(e, () => {
88
+ const e = t.kt;
89
+ t.kt = undefined;
102
90
  e?.();
103
91
  }) : console.error(e);
104
92
  } catch (e) {
105
- if (!t.T.notify(t, STATUS_ERROR, STATUS_ERROR)) {
93
+ if (!globalQueue.notify(t, STATUS_ERROR, STATUS_ERROR)) {
106
94
  haltReactivity(e);
107
95
  throw e;
108
96
  }
@@ -111,43 +99,43 @@ function runEffect(t, e) {
111
99
  }
112
100
  // Captured before the callback: its own throw errors the node below, but
113
101
  // the compute pass that produced `_value` was clean, so its tail still goes.
114
- const r = t.o?._ == null;
102
+ const u = t.m?.v == null;
115
103
  // Observe tier, like its `effectRunEnd` twin below: the frame the engine
116
104
  // opens here is what stamps the callback's writes as the effect's (the
117
105
  // cascade an observer reports) and what times the callback (the `effect`
118
106
  // record) — facts a production observer needs, not only a dev console.
119
107
  if (attrHooks !== null) attrHooks.effectRunStart(t);
120
- const E = t.qt;
121
- t.qt = undefined;
108
+ const o = t.kt;
109
+ t.kt = undefined;
122
110
  try {
123
- E?.();
124
- const e = t.wt(t.ce, t.Mt);
111
+ o?.();
112
+ const e = t.Ut(t.pe, t.Nt);
125
113
  if (false && e !== undefined && typeof e !== "function") ;
126
114
  // The final cleanup is invoked by disposeChildren at true disposal.
127
- t.qt = e;
115
+ t.kt = e;
128
116
  } catch (e) {
129
- ext(t)._ = new StatusError(t, e);
130
- t.S |= STATUS_ERROR;
131
- if (!t.T.notify(t, STATUS_ERROR, STATUS_ERROR)) {
117
+ ext(t).v = new StatusError(t, e);
118
+ t.G |= STATUS_ERROR;
119
+ if (!globalQueue.notify(t, STATUS_ERROR, STATUS_ERROR)) {
132
120
  haltReactivity(e);
133
121
  throw e;
134
122
  }
135
123
  } finally {
136
- t.Mt = t.ce;
137
- t.it = false;
124
+ t.Nt = t.pe;
125
+ t.lt = false;
138
126
  // The run applied: this is the frame now, so the dependency tail the
139
127
  // compute pass left linked goes (A30, #3438 — `recompute` defers an
140
128
  // effect's trim while a run is owed; the twin of `commitPendingNode`'s
141
129
  // trim for a staged pass). An errored compute kept its full list with
142
130
  // `_depsTail` marking where it stopped; leave it, as the commit does.
143
- if (r) trimStaleDeps(t);
131
+ if (u) trimStaleDeps(t);
144
132
  }
145
133
  // Outside the try (see the rule in attribution-hooks.ts). Reached whether or
146
134
  // not the callback threw — a throw that escapes the catch above halts.
147
135
  if (attrHooks !== null) attrHooks.effectRunEnd(t);
148
136
  }
149
137
 
150
- GlobalQueue.Rt = runEffect;
138
+ GlobalQueue.X = runEffect;
151
139
 
152
140
  /**
153
141
  * Internal tracked effect - bypasses heap, goes directly to effect queue.
@@ -156,39 +144,40 @@ GlobalQueue.Rt = runEffect;
156
144
  */ function trackedEffect(t, e) {
157
145
  const run = () => {
158
146
  // `_modified` is NOT redundant with the heap: the heap dedups within a
159
- // pass, but a held transition's passes each enqueue `_run` into the same
160
- // user queue, and this gate is what collapses them into one run at commit.
161
- if (!r.it || r.oe & REACTIVE_DISPOSED) return;
147
+ // pass, but several passes in one flush each enqueue `_run` into the same
148
+ // user queue, and this gate is what collapses them into one run.
149
+ if (!u.lt || u.R & REACTIVE_DISPOSED) return;
150
+ if (GlobalQueue.de && GlobalQueue.de(u)) return;
162
151
  try {
163
- r.it = false;
164
- recompute(r);
152
+ u.lt = false;
153
+ recompute(u);
165
154
  } finally {}
166
155
  };
167
- const r = computed(() => {
168
- const e = r.qt;
169
- r.qt = undefined;
156
+ const u = computed(() => {
157
+ const e = u.kt;
158
+ u.kt = undefined;
170
159
  e?.();
171
- const E = staleValues(t);
172
- r.qt = E;
160
+ const o = staleValues(t);
161
+ u.kt = o;
173
162
  }, {
174
163
  ...e,
175
164
  lazy: true
176
165
  });
177
- r.qt = undefined;
178
- r.C = r.C & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
179
- r.it = true;
180
- r.He = EFFECT_TRACKED;
166
+ u.kt = undefined;
167
+ u.u = u.u & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
168
+ u.lt = true;
169
+ u.i = EFFECT_TRACKED;
181
170
  // Observe-tier label: the computed literal defaulted its `_name` slot to
182
171
  // "computed"; relabel by kind (a store into the slot, not a new field).
183
- if (e?.name === undefined) r._name = "trackedEffect";
172
+ if (e?.name === undefined) u._name = "trackedEffect";
184
173
  // Status dispatch rides the SHARED notifier (statusNotifierOf keys off
185
174
  // _type): its error arm is behavior-identical to the closure that used to
186
175
  // live here, without the per-node NodeExtension allocation.
187
- r.lt = run;
176
+ u.q = run;
188
177
  // The first run rides the heap like every wake (GlobalQueue._update), so a
189
178
  // tracked effect created inside a render-effect callback runs after that
190
179
  // pass's staged writes commit, not before.
191
- enqueueSub(r);
180
+ enqueueSub(u);
192
181
  schedule();
193
182
  }
194
183
 
@@ -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.re, () => {
50
50
  setSignal(n, undefined);
51
51
  });
52
52
  cleanup(() => r.dispose());
53
- e.Se = e => {
53
+ e.re = e => {
54
54
  read(n);
55
55
  return r.track(e);
56
56
  };
@@ -61,11 +61,11 @@ function externalUntrack(e) {
61
61
  }
62
62
 
63
63
  // The hooks mirror the config's liveness exactly (installed on enable,
64
- // removed on reset) so core's null checks stay equivalent to the old
64
+ // removed on reset) so core's presence checks stay equivalent to the old
65
65
  // `externalSourceConfig` truthiness checks.
66
66
  function syncExternalHooks() {
67
- GlobalQueue.Bt = externalSourceConfig ? wireExternalSource : null;
68
- GlobalQueue.Jt = externalSourceConfig ? externalUntrack : null;
67
+ GlobalQueue.xt = externalSourceConfig ? wireExternalSource : undefined;
68
+ GlobalQueue.Wt = externalSourceConfig ? externalUntrack : undefined;
69
69
  }
70
70
 
71
71
  function enableExternalSource(e) {
@@ -1,47 +1,54 @@
1
1
  import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, CONFIG_SLOT_NODE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
2
2
 
3
- import { slotUnobservedHook } from "./core.js";
4
-
5
- import { deleteFromHeap, queueFor } from "./heap.js";
3
+ import { deleteFromHeap } from "./heap.js";
6
4
 
7
5
  import { disposeChildren } from "./owner.js";
8
6
 
9
- import { bumpNotifyEpoch } from "./scheduler.js";
7
+ import { bumpNotifyEpoch, dirtyQueue } from "./scheduler.js";
8
+
9
+ /** The store's shared slot-node release handler (store/store.ts installs it
10
+ * once) — a live binding read directly by the sweep site: no wrapper frame,
11
+ * no null check (a CONFIG_SLOT_NODE node existing implies the store module
12
+ * loaded and registered it). */ let slotUnobservedHook;
13
+
14
+ function setSlotUnobserved(e) {
15
+ slotUnobservedHook = e;
16
+ }
10
17
 
11
18
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
12
19
  function unlinkSubs(e) {
13
- const n = e.De;
14
- const l = e.Ie;
15
- const o = e.Pe;
16
- const s = e.jn;
17
- if (o !== null) o.jn = s; else n.Ht = s;
18
- if (s !== null) s.Pe = o; else {
19
- n.u = o;
20
- if (o === null) {
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.C & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.o?.bt?.();
20
+ const n = e.I;
21
+ const o = e.p;
22
+ const l = e.l;
23
+ const t = e.ln;
24
+ if (l !== null) l.ln = t; else n.Dt = t;
25
+ if (t !== null) t.l = l; else {
26
+ n.t = l;
27
+ if (l === null) {
28
+ // Store slot nodes dispatch to the ONE shared hook — no per-node
29
+ // unobserved closure, no NodeExtension to hold it.
30
+ if (n.u & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.m?.Ft?.();
24
31
  // No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
25
- // A pending node is exempt: its in-flight async work (or the
26
- // transition holding it) is an observer — tearing down would orphan
27
- // the work and re-execute it on the next read. The settle path runs
28
- // this same last-one-out check when that observer releases (the
29
- // untracked-read dormancy sweep guards on pending identically).
32
+ // A pending node is exempt: its in-flight async work is an observer —
33
+ // tearing down would orphan the work and re-execute it on the next
34
+ // read. The settle path runs this same last-one-out check when that
35
+ // observer releases (the untracked-read dormancy sweep guards on
36
+ // pending identically).
30
37
  const e = n;
31
- e.Se && e.C & CONFIG_AUTO_DISPOSE && !(e.oe & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
38
+ e.re && e.u & CONFIG_AUTO_DISPOSE && !(e.R & REACTIVE_ZOMBIE) && !(e.G & STATUS_PENDING) && unobserved(e);
32
39
  }
33
40
  }
34
- return l;
41
+ return o;
35
42
  }
36
43
 
37
44
  function trimStaleDeps(e) {
38
- const n = e.Je;
39
- let l = n !== null ? n.Ie : e.Ee;
40
- if (l !== null) {
45
+ const n = e.S;
46
+ let o = n !== null ? n.p : e._;
47
+ if (o !== null) {
41
48
  do {
42
- l = unlinkSubs(l);
43
- } while (l !== null);
44
- if (n !== null) n.Ie = null; else e.Ee = null;
49
+ o = unlinkSubs(o);
50
+ } while (o !== null);
51
+ if (n !== null) n.p = null; else e._ = null;
45
52
  }
46
53
  }
47
54
 
@@ -50,17 +57,17 @@ function trimStaleDeps(e) {
50
57
  // and skipping early also avoids adding one (hidden-class churn) via the
51
58
  // null-out below.
52
59
  function clearDeps(e) {
53
- let n = e.Ee;
60
+ let n = e._;
54
61
  if (!n) return;
55
62
  do {
56
63
  n = unlinkSubs(n);
57
64
  } while (n !== null);
58
- e.Ee = null;
59
- e.Je = null;
65
+ e._ = null;
66
+ e.S = null;
60
67
  }
61
68
 
62
69
  function unobserved(e) {
63
- deleteFromHeap(e, queueFor(e));
70
+ deleteFromHeap(e, dirtyQueue);
64
71
  clearDeps(e);
65
72
  disposeChildren(e, true);
66
73
  }
@@ -94,7 +101,7 @@ function sweepDormant() {
94
101
  // is an observer; the settle path re-runs last-one-out), lost its
95
102
  // AUTO_DISPOSE bit (owner teardown strips it, #3024), or already been
96
103
  // torn down.
97
- if (!e.u && e.C & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.oe & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
104
+ if (!e.t && e.u & CONFIG_AUTO_DISPOSE && !(e.G & STATUS_PENDING) && !(e.R & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
98
105
  unobserved(e);
99
106
  }
100
107
  }
@@ -102,26 +109,16 @@ function sweepDormant() {
102
109
  }
103
110
 
104
111
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L52
105
- function link(e, n, l = false) {
106
- // Repeat touches within one pass AND-combine `_pendingObserver`: a probe
107
- // read (`isPending(() => x())`) beside a value read of the same dep must
108
- // not relabel the value dependency as probe-only — the value read is what
109
- // real-error propagation and affects() coverage key off, regardless of
110
- // read order within the computation.
111
- const o = n.Je;
112
- if (o !== null && o.De === e) {
113
- o.Be &&= l;
114
- return;
115
- }
116
- let s = null;
117
- const t = n.oe & REACTIVE_RECOMPUTING_DEPS;
112
+ function link(e, n) {
113
+ const o = n.S;
114
+ if (o !== null && o.I === e) return;
115
+ let l = null;
116
+ const t = n.R & REACTIVE_RECOMPUTING_DEPS;
118
117
  if (t) {
119
- s = o !== null ? o.Ie : n.Ee;
120
- if (s !== null && s.De === e) {
121
- s.Ze = n.We;
122
- n.Je = s;
123
- // First touch of this pass: the previous pass's label is stale.
124
- s.Be = l;
118
+ l = o !== null ? o.p : n._;
119
+ if (l !== null && l.I === e) {
120
+ l.Ue = n.he;
121
+ n.S = l;
125
122
  return;
126
123
  }
127
124
  }
@@ -130,26 +127,20 @@ function link(e, n, l = false) {
130
127
  // [deps.._depsTail] prefix — the O(1) equivalent of scanning the dep list
131
128
  // (the old alien-signals `isValidLink` walk, O(n²) when a computation
132
129
  // re-reads earlier deps non-consecutively, e.g. store leaf reads).
133
- const r = e.Ht;
134
- if (r !== null && r.Ae === n && (!t || r.Ze === n.We)) {
135
- // Gen-matched during a recompute = repeat touch this pass (AND); outside
136
- // a recompute there is no pass boundary, so the latest read labels it.
137
- if (t) r.Be &&= l; else r.Be = l;
138
- return;
139
- }
140
- const u = n.Je = e.Ht = {
141
- De: e,
142
- Ae: n,
143
- Ie: s,
144
- jn: r,
145
- Pe: null,
146
- Ze: n.We,
147
- Be: l
130
+ const s = e.Dt;
131
+ if (s !== null && s.o === n && (!t || s.Ue === n.he)) return;
132
+ const u = n.S = e.Dt = {
133
+ I: e,
134
+ o: n,
135
+ p: l,
136
+ ln: s,
137
+ l: null,
138
+ Ue: n.he
148
139
  };
149
- if (o !== null) o.Ie = u; else n.Ee = u;
150
- if (r !== null) r.Pe = u; else e.u = u;
140
+ if (o !== null) o.p = u; else n._ = u;
141
+ if (s !== null) s.l = u; else e.t = u;
151
142
  // New subscriber edge: staged-rewrite skips (§12d) must not miss it.
152
143
  bumpNotifyEpoch();
153
144
  }
154
145
 
155
- export { clearDeps, dormantNodes, link, sweepDormant, trimStaleDeps, unlinkSubs, unobserved };
146
+ export { clearDeps, dormantNodes, link, setSlotUnobserved, slotUnobservedHook, sweepDormant, trimStaleDeps, unlinkSubs, unobserved };