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

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 (66) hide show
  1. package/dist/dev-shared.js +248 -189
  2. package/dist/dev.attribution.js +124 -41
  3. package/dist/dev.js +553 -322
  4. package/dist/observe/affects.js +34 -31
  5. package/dist/observe/boundaries.js +166 -132
  6. package/dist/observe/core/async.js +90 -83
  7. package/dist/observe/core/attribution-queries.js +1 -1
  8. package/dist/observe/core/attribution.js +281 -197
  9. package/dist/observe/core/constants.js +7 -2
  10. package/dist/observe/core/context.js +3 -3
  11. package/dist/observe/core/core.js +277 -245
  12. package/dist/observe/core/dev.js +3 -3
  13. package/dist/observe/core/effect.js +21 -21
  14. package/dist/observe/core/external.js +2 -2
  15. package/dist/observe/core/graph.js +25 -25
  16. package/dist/observe/core/heap.js +9 -9
  17. package/dist/observe/core/lanes.js +206 -160
  18. package/dist/observe/core/owner.js +27 -27
  19. package/dist/observe/core/scheduler.js +92 -86
  20. package/dist/observe/core/verdict.js +66 -54
  21. package/dist/observe/map.js +35 -35
  22. package/dist/observe/reveal.js +24 -24
  23. package/dist/observe/signals.js +38 -28
  24. package/dist/observe/store/affects.js +75 -68
  25. package/dist/observe/store/hooks.js +13 -0
  26. package/dist/observe/store/index.js +0 -2
  27. package/dist/observe/store/optimistic.js +67 -34
  28. package/dist/observe/store/projection.js +37 -31
  29. package/dist/observe/store/reconcile.js +32 -30
  30. package/dist/observe/store/store.js +128 -85
  31. package/dist/prod/affects.js +34 -31
  32. package/dist/prod/boundaries.js +143 -109
  33. package/dist/prod/core/async.js +64 -67
  34. package/dist/prod/core/constants.js +7 -2
  35. package/dist/prod/core/context.js +3 -3
  36. package/dist/prod/core/core.js +302 -270
  37. package/dist/prod/core/effect.js +38 -38
  38. package/dist/prod/core/external.js +4 -4
  39. package/dist/prod/core/graph.js +27 -27
  40. package/dist/prod/core/heap.js +30 -30
  41. package/dist/prod/core/lanes.js +257 -211
  42. package/dist/prod/core/owner.js +39 -39
  43. package/dist/prod/core/scheduler.js +125 -119
  44. package/dist/prod/core/verdict.js +70 -58
  45. package/dist/prod/map.js +73 -73
  46. package/dist/prod/reveal.js +38 -38
  47. package/dist/prod/signals.js +30 -20
  48. package/dist/prod/store/affects.js +75 -68
  49. package/dist/prod/store/hooks.js +13 -0
  50. package/dist/prod/store/index.js +0 -2
  51. package/dist/prod/store/optimistic.js +114 -81
  52. package/dist/prod/store/projection.js +30 -24
  53. package/dist/prod/store/reconcile.js +32 -30
  54. package/dist/prod/store/store.js +136 -93
  55. package/dist/types/boundaries.d.ts +4 -0
  56. package/dist/types/core/attribution.d.ts +6 -2
  57. package/dist/types/core/constants.d.ts +5 -0
  58. package/dist/types/core/core.d.ts +33 -3
  59. package/dist/types/core/lanes.d.ts +10 -0
  60. package/dist/types/core/scheduler.d.ts +12 -6
  61. package/dist/types/core/types.d.ts +0 -6
  62. package/dist/types/store/affects.d.ts +11 -0
  63. package/dist/types/store/hooks.d.ts +48 -0
  64. package/dist/types/store/index.d.ts +0 -1
  65. package/dist/types/store/store.d.ts +3 -38
  66. package/package.json +1 -1
@@ -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.H ?? null;
152
+ let n = "_parent" in e ? e : e.L ?? 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.H ?? null;
178
+ let n = "_parent" in e ? e : e.L ?? 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.H = n;
249
+ e.L = n;
250
250
  }
251
251
 
252
252
  /**
@@ -26,16 +26,16 @@ import { globalQueue, schedule, GlobalQueue, haltReactivity } from "./scheduler.
26
26
  // staged); the flush's commit replays this effect. Its first run is not this
27
27
  // creation's (A29). A lane's node likewise: its run is the lane's, queued
28
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
+ !o?.defer && r.Oe === NOT_PENDING && !r.m?._t?.B && (r.u === EFFECT_USER || o?.schedule ? globalQueue.enqueue(r.u, runEffect.bind(null, r)) : runEffect(r, r.u));
30
30
  }
31
31
 
32
32
  function notifyEffectStatus(t, e) {
33
33
  // Use passed values if provided, otherwise read from node
34
- const u = t !== undefined ? t : this.G;
35
- const o = e !== undefined ? e : this.m?.v;
34
+ const u = t !== undefined ? t : this.S;
35
+ const o = e !== undefined ? e : this.m?.F;
36
36
  if (u & STATUS_ERROR) {
37
37
  globalQueue.notify(this, STATUS_PENDING, 0);
38
- if (this.i === EFFECT_USER) {
38
+ if (this.u === EFFECT_USER) {
39
39
  // The error handler is the error arm of the effect phase (#2840 ruling):
40
40
  // queue it like the effect function. It runs in the same imperative,
41
41
  // writable scope and throws escalate the same way. No payload is queued — the node already carries `_statusFlags`/`_error`,
@@ -43,9 +43,9 @@ function notifyEffectStatus(t, e) {
43
43
  // phase takes the success arm instead. Blocked forwards (explicit
44
44
  // `status` arg without node-state writes) don't queue: the status
45
45
  // re-propagates unblocked at commit.
46
- if (this.G & STATUS_ERROR) {
46
+ if (this.S & STATUS_ERROR) {
47
47
  this.lt = true;
48
- globalQueue.enqueue(this.i, this.J ??= runEffect.bind(null, this));
48
+ globalQueue.enqueue(this.u, this.Y ??= runEffect.bind(null, this));
49
49
  }
50
50
  return;
51
51
  }
@@ -53,7 +53,7 @@ function notifyEffectStatus(t, e) {
53
53
  haltReactivity(unwrapStatusError(o));
54
54
  throw o;
55
55
  }
56
- } else if (this.i === EFFECT_RENDER) {
56
+ } else if (this.u === EFFECT_RENDER) {
57
57
  globalQueue.notify(this, STATUS_PENDING | STATUS_ERROR, u, o);
58
58
  }
59
59
  }
@@ -68,7 +68,7 @@ function runEffect(t, e) {
68
68
  // hidden subtree. The synchronous first render on creation is not a queued
69
69
  // run and goes through. `_modified` stays set; the boundary re-queues the
70
70
  // run (`release`).
71
- if (GlobalQueue.de && GlobalQueue.de(t)) return;
71
+ if (GlobalQueue.Ee && GlobalQueue.Ee(t)) return;
72
72
  // Error arm (#2840), user effects only: a compute-phase error that is still
73
73
  // the node's settled state at effect time runs the bundle's error handler in
74
74
  // this same imperative, writable scope. Unwrap the StatusError used for
@@ -79,9 +79,9 @@ function runEffect(t, e) {
79
79
  // Render effects bypass: their errors route to boundaries synchronously in
80
80
  // notifyEffectStatus, and a runner queued by an earlier valueChanged in the
81
81
  // same flush must not be hijacked by a later-arriving error status.
82
- if (t.G & STATUS_ERROR && t.i === EFFECT_USER) {
83
- const e = unwrapStatusError(t.m?.v);
84
- t.Nt = t.pe;
82
+ if (t.S & STATUS_ERROR && t.u === EFFECT_USER) {
83
+ const e = unwrapStatusError(t.m?.F);
84
+ t.Nt = t.Ae;
85
85
  t.lt = false;
86
86
  try {
87
87
  t.Lt ? t.Lt(e, () => {
@@ -99,7 +99,7 @@ function runEffect(t, e) {
99
99
  }
100
100
  // Captured before the callback: its own throw errors the node below, but
101
101
  // the compute pass that produced `_value` was clean, so its tail still goes.
102
- const u = t.m?.v == null;
102
+ const u = t.m?.F == null;
103
103
  // Observe tier, like its `effectRunEnd` twin below: the frame the engine
104
104
  // opens here is what stamps the callback's writes as the effect's (the
105
105
  // cascade an observer reports) and what times the callback (the `effect`
@@ -109,19 +109,19 @@ function runEffect(t, e) {
109
109
  t.kt = undefined;
110
110
  try {
111
111
  o?.();
112
- const e = t.Ut(t.pe, t.Nt);
112
+ const e = t.Ut(t.Ae, t.Nt);
113
113
  if (false && e !== undefined && typeof e !== "function") ;
114
114
  // The final cleanup is invoked by disposeChildren at true disposal.
115
115
  t.kt = e;
116
116
  } catch (e) {
117
- ext(t).v = new StatusError(t, e);
118
- t.G |= STATUS_ERROR;
117
+ ext(t).F = new StatusError(t, e);
118
+ t.S |= STATUS_ERROR;
119
119
  if (!globalQueue.notify(t, STATUS_ERROR, STATUS_ERROR)) {
120
120
  haltReactivity(e);
121
121
  throw e;
122
122
  }
123
123
  } finally {
124
- t.Nt = t.pe;
124
+ t.Nt = t.Ae;
125
125
  t.lt = false;
126
126
  // The run applied: this is the frame now, so the dependency tail the
127
127
  // compute pass left linked goes (A30, #3438 — `recompute` defers an
@@ -135,7 +135,7 @@ function runEffect(t, e) {
135
135
  if (attrHooks !== null) attrHooks.effectRunEnd(t);
136
136
  }
137
137
 
138
- GlobalQueue.X = runEffect;
138
+ GlobalQueue.q = runEffect;
139
139
 
140
140
  /**
141
141
  * Internal tracked effect - bypasses heap, goes directly to effect queue.
@@ -147,7 +147,7 @@ GlobalQueue.X = runEffect;
147
147
  // pass, but several passes in one flush each enqueue `_run` into the same
148
148
  // user queue, and this gate is what collapses them into one run.
149
149
  if (!u.lt || u.R & REACTIVE_DISPOSED) return;
150
- if (GlobalQueue.de && GlobalQueue.de(u)) return;
150
+ if (GlobalQueue.Ee && GlobalQueue.Ee(u)) return;
151
151
  try {
152
152
  u.lt = false;
153
153
  recompute(u);
@@ -164,16 +164,16 @@ GlobalQueue.X = runEffect;
164
164
  lazy: true
165
165
  });
166
166
  u.kt = undefined;
167
- u.u = u.u & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
167
+ u.i = u.i & ~CONFIG_AUTO_DISPOSE | CONFIG_CHILDREN_FORBIDDEN;
168
168
  u.lt = true;
169
- u.i = EFFECT_TRACKED;
169
+ u.u = EFFECT_TRACKED;
170
170
  // Observe-tier label: the computed literal defaulted its `_name` slot to
171
171
  // "computed"; relabel by kind (a store into the slot, not a new field).
172
172
  if (e?.name === undefined) u._name = "trackedEffect";
173
173
  // Status dispatch rides the SHARED notifier (statusNotifierOf keys off
174
174
  // _type): its error arm is behavior-identical to the closure that used to
175
175
  // live here, without the per-node NodeExtension allocation.
176
- u.q = run;
176
+ u.M = run;
177
177
  // The first run rides the heap like every wake (GlobalQueue._update), so a
178
178
  // tracked effect created inside a render-effect callback runs after that
179
179
  // pass's staged writes commit, not before.
@@ -46,11 +46,11 @@ function wireExternalSource(e) {
46
46
  equals: false,
47
47
  ownedWrite: true
48
48
  });
49
- const r = externalSourceConfig.factory(e.re, () => {
49
+ const r = externalSourceConfig.factory(e.ee, () => {
50
50
  setSignal(n, undefined);
51
51
  });
52
52
  cleanup(() => r.dispose());
53
- e.re = e => {
53
+ e.ee = e => {
54
54
  read(n);
55
55
  return r.track(e);
56
56
  };
@@ -1,4 +1,4 @@
1
- import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, CONFIG_SLOT_NODE, REACTIVE_RECOMPUTING_DEPS } from "./constants.js";
1
+ import { CONFIG_AUTO_DISPOSE, STATUS_PENDING, REACTIVE_DISPOSED, REACTIVE_ZOMBIE, REACTIVE_RECOMPUTING_DEPS, CONFIG_SLOT_NODE } from "./constants.js";
2
2
 
3
3
  import { deleteFromHeap } from "./heap.js";
4
4
 
@@ -18,16 +18,16 @@ function setSlotUnobserved(e) {
18
18
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100
19
19
  function unlinkSubs(e) {
20
20
  const n = e.I;
21
- const o = e.p;
22
- const l = e.l;
21
+ const o = e._;
22
+ const l = e.o;
23
23
  const t = e.ln;
24
24
  if (l !== null) l.ln = t; else n.Dt = t;
25
- if (t !== null) t.l = l; else {
25
+ if (t !== null) t.o = l; else {
26
26
  n.t = l;
27
27
  if (l === null) {
28
28
  // Store slot nodes dispatch to the ONE shared hook — no per-node
29
29
  // unobserved closure, no NodeExtension to hold it.
30
- if (n.u & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.m?.Ft?.();
30
+ if (n.i & CONFIG_SLOT_NODE) slotUnobservedHook(n); else n.m?.Ft?.();
31
31
  // No more subscribers; only tear down if CONFIG_AUTO_DISPOSE is set.
32
32
  // A pending node is exempt: its in-flight async work is an observer —
33
33
  // tearing down would orphan the work and re-execute it on the next
@@ -35,20 +35,20 @@ function unlinkSubs(e) {
35
35
  // observer releases (the untracked-read dormancy sweep guards on
36
36
  // pending identically).
37
37
  const e = n;
38
- e.re && e.u & CONFIG_AUTO_DISPOSE && !(e.R & REACTIVE_ZOMBIE) && !(e.G & STATUS_PENDING) && unobserved(e);
38
+ e.ee && e.i & CONFIG_AUTO_DISPOSE && !(e.R & REACTIVE_ZOMBIE) && !(e.S & STATUS_PENDING) && unobserved(e);
39
39
  }
40
40
  }
41
41
  return o;
42
42
  }
43
43
 
44
44
  function trimStaleDeps(e) {
45
- const n = e.S;
46
- let o = n !== null ? n.p : e._;
45
+ const n = e.p;
46
+ let o = n !== null ? n._ : e.G;
47
47
  if (o !== null) {
48
48
  do {
49
49
  o = unlinkSubs(o);
50
50
  } while (o !== null);
51
- if (n !== null) n.p = null; else e._ = null;
51
+ if (n !== null) n._ = null; else e.G = null;
52
52
  }
53
53
  }
54
54
 
@@ -57,13 +57,13 @@ function trimStaleDeps(e) {
57
57
  // and skipping early also avoids adding one (hidden-class churn) via the
58
58
  // null-out below.
59
59
  function clearDeps(e) {
60
- let n = e._;
60
+ let n = e.G;
61
61
  if (!n) return;
62
62
  do {
63
63
  n = unlinkSubs(n);
64
64
  } while (n !== null);
65
- e._ = null;
66
- e.S = null;
65
+ e.G = null;
66
+ e.p = null;
67
67
  }
68
68
 
69
69
  function unobserved(e) {
@@ -101,7 +101,7 @@ function sweepDormant() {
101
101
  // is an observer; the settle path re-runs last-one-out), lost its
102
102
  // AUTO_DISPOSE bit (owner teardown strips it, #3024), or already been
103
103
  // torn down.
104
- if (!e.t && e.u & CONFIG_AUTO_DISPOSE && !(e.G & STATUS_PENDING) && !(e.R & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
104
+ if (!e.t && e.i & CONFIG_AUTO_DISPOSE && !(e.S & STATUS_PENDING) && !(e.R & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
105
105
  unobserved(e);
106
106
  }
107
107
  }
@@ -110,15 +110,15 @@ function sweepDormant() {
110
110
 
111
111
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L52
112
112
  function link(e, n) {
113
- const o = n.S;
113
+ const o = n.p;
114
114
  if (o !== null && o.I === e) return;
115
115
  let l = null;
116
116
  const t = n.R & REACTIVE_RECOMPUTING_DEPS;
117
117
  if (t) {
118
- l = o !== null ? o.p : n._;
118
+ l = o !== null ? o._ : n.G;
119
119
  if (l !== null && l.I === e) {
120
- l.Ue = n.he;
121
- n.S = l;
120
+ l.Pe = n.pe;
121
+ n.p = l;
122
122
  return;
123
123
  }
124
124
  }
@@ -128,17 +128,17 @@ function link(e, n) {
128
128
  // (the old alien-signals `isValidLink` walk, O(n²) when a computation
129
129
  // re-reads earlier deps non-consecutively, e.g. store leaf reads).
130
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 = {
131
+ if (s !== null && s.l === n && (!t || s.Pe === n.pe)) return;
132
+ const u = n.p = e.Dt = {
133
133
  I: e,
134
- o: n,
135
- p: l,
134
+ l: n,
135
+ _: l,
136
136
  ln: s,
137
- l: null,
138
- Ue: n.he
137
+ o: null,
138
+ Pe: n.pe
139
139
  };
140
- if (o !== null) o.p = u; else n._ = u;
141
- if (s !== null) s.l = u; else e.t = u;
140
+ if (o !== null) o._ = u; else n.G = u;
141
+ if (s !== null) s.o = u; else e.t = u;
142
142
  // New subscriber edge: staged-rewrite skips (§12d) must not miss it.
143
143
  bumpNotifyEpoch();
144
144
  }
@@ -49,7 +49,7 @@ function insertIntoHeap(e, t) {
49
49
  // parked in the heap for a synchronous mount (each row writing a ref
50
50
  // signal its effect subscribes to), mounting N rows was O(N²) (#3350).
51
51
  // markNode's own guard skips an already-DIRTY node.
52
- if (t.C) markNode(e);
52
+ if (t.N) markNode(e);
53
53
  }
54
54
  if (!(E & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
55
55
  }
@@ -78,8 +78,8 @@ function deleteFromHeap(e, t) {
78
78
  }
79
79
 
80
80
  function markHeap(e) {
81
- if (e.C) return;
82
- e.C = true;
81
+ if (e.N) return;
82
+ e.N = true;
83
83
  for (let t = 0; t <= e.Kt; t++) {
84
84
  for (let E = e.jt[t]; E !== undefined; E = E.Ot) {
85
85
  if (E.R & REACTIVE_IN_HEAP) markNode(E);
@@ -91,13 +91,13 @@ function markNode(e, t = REACTIVE_DIRTY) {
91
91
  const E = e.R;
92
92
  if ((E & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
93
93
  e.R = E & -4 | t;
94
- for (let t = e.t; t !== null; t = t.l) {
95
- markNode(t.o, REACTIVE_CHECK);
94
+ for (let t = e.t; t !== null; t = t.o) {
95
+ markNode(t.l, REACTIVE_CHECK);
96
96
  }
97
97
  }
98
98
 
99
99
  function runHeap(e, t) {
100
- e.C = false;
100
+ e.N = false;
101
101
  for (e.ut = 0; e.ut <= e.Kt; e.ut++) {
102
102
  let E = e.jt[e.ut];
103
103
  while (E !== undefined) {
@@ -111,13 +111,13 @@ function runHeap(e, t) {
111
111
  function adjustHeight(e, t) {
112
112
  deleteFromHeap(e, t);
113
113
  let E = e.it;
114
- for (let t = e._; t; t = t.p) {
114
+ for (let t = e.G; t; t = t._) {
115
115
  const e = t.I;
116
- if (e.re && e.it >= E) E = e.it + 1;
116
+ if (e.ee && e.it >= E) E = e.it + 1;
117
117
  }
118
118
  if (e.it !== E) {
119
119
  e.it = E;
120
- for (let E = e.t; E !== null; E = E.l) insertIntoHeapHeight(E.o, t);
120
+ for (let E = e.t; E !== null; E = E.o) insertIntoHeapHeight(E.l, t);
121
121
  }
122
122
  }
123
123