@solidjs/signals 0.6.4 → 0.7.0

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.
package/dist/node.cjs CHANGED
@@ -47,14 +47,14 @@ function schedule() {
47
47
  if (scheduled)
48
48
  return;
49
49
  scheduled = true;
50
- if (!globalQueue.y)
50
+ if (!globalQueue.B)
51
51
  queueMicrotask(flush);
52
52
  }
53
53
  function notifyUnobserved() {
54
54
  var _a, _b;
55
55
  for (let i = 0; i < Unobserved.length; i++) {
56
56
  const source = Unobserved[i];
57
- if (!source.b || !source.b.length)
57
+ if (!source.c || !source.c.length)
58
58
  (_b = (_a = Unobserved[i]).ea) == null ? void 0 : _b.call(_a);
59
59
  }
60
60
  Unobserved = [];
@@ -62,7 +62,7 @@ function notifyUnobserved() {
62
62
  var pureQueue = [];
63
63
  var Queue = class {
64
64
  k = null;
65
- y = false;
65
+ B = false;
66
66
  g = [[], []];
67
67
  f = [];
68
68
  created = clock;
@@ -87,9 +87,9 @@ var Queue = class {
87
87
  }
88
88
  }
89
89
  flush() {
90
- if (this.y)
90
+ if (this.B)
91
91
  return;
92
- this.y = true;
92
+ this.B = true;
93
93
  try {
94
94
  this.run(EFFECT_PURE);
95
95
  incrementClock();
@@ -97,7 +97,7 @@ var Queue = class {
97
97
  this.run(EFFECT_RENDER);
98
98
  this.run(EFFECT_USER);
99
99
  } finally {
100
- this.y = false;
100
+ this.B = false;
101
101
  Unobserved.length && notifyUnobserved();
102
102
  }
103
103
  }
@@ -125,7 +125,7 @@ var Queue = class {
125
125
  this.g[0].push.apply(this.g[0], queue.g[0]);
126
126
  this.g[1].push.apply(this.g[1], queue.g[1]);
127
127
  for (let i = 0; i < queue.f.length; i++) {
128
- const og = this.f.find((c) => c.e === queue.f[i].e);
128
+ const og = this.f.find((c) => c.d === queue.f[i].d);
129
129
  if (og)
130
130
  og.merge(queue.f[i]);
131
131
  else
@@ -144,12 +144,12 @@ function removeSourceObservers(node, index) {
144
144
  let swap;
145
145
  for (let i = index; i < node.a.length; i++) {
146
146
  source = getTransitionSource(node.a[i]);
147
- if (source.b) {
148
- if ((swap = source.b.indexOf(node)) !== -1) {
149
- source.b[swap] = source.b[source.b.length - 1];
150
- source.b.pop();
147
+ if (source.c) {
148
+ if ((swap = source.c.indexOf(node)) !== -1) {
149
+ source.c[swap] = source.c[source.c.length - 1];
150
+ source.c.pop();
151
151
  }
152
- if (!source.b.length)
152
+ if (!source.c.length)
153
153
  Unobserved.push(source);
154
154
  }
155
155
  }
@@ -160,18 +160,18 @@ function runQueue(queue, type) {
160
160
  }
161
161
  var Transition = class _Transition {
162
162
  a = /* @__PURE__ */ new Map();
163
- r = /* @__PURE__ */ new Set();
163
+ s = /* @__PURE__ */ new Set();
164
164
  H = /* @__PURE__ */ new Set();
165
165
  I = /* @__PURE__ */ new Set();
166
- B = false;
166
+ D = false;
167
167
  g = [[], []];
168
168
  G = /* @__PURE__ */ new Map();
169
169
  J = [];
170
170
  f = [];
171
171
  k = null;
172
- y = false;
172
+ B = false;
173
173
  Y = false;
174
- e = globalQueue;
174
+ d = globalQueue;
175
175
  created = clock;
176
176
  constructor() {
177
177
  this.G.set(globalQueue, this);
@@ -200,9 +200,9 @@ var Transition = class _Transition {
200
200
  }
201
201
  }
202
202
  flush() {
203
- if (this.y)
203
+ if (this.B)
204
204
  return;
205
- this.y = true;
205
+ this.B = true;
206
206
  let currentTransition = ActiveTransition;
207
207
  ActiveTransition = this;
208
208
  try {
@@ -212,7 +212,7 @@ var Transition = class _Transition {
212
212
  ActiveTransition = currentTransition;
213
213
  finishTransition(this);
214
214
  } finally {
215
- this.y = false;
215
+ this.B = false;
216
216
  ActiveTransition = currentTransition;
217
217
  }
218
218
  }
@@ -229,9 +229,9 @@ var Transition = class _Transition {
229
229
  if (!(type & LOADING_BIT))
230
230
  return false;
231
231
  if (flags & LOADING_BIT) {
232
- this.r.add(node);
232
+ this.s.add(node);
233
233
  } else {
234
- this.r.delete(node);
234
+ this.s.delete(node);
235
235
  }
236
236
  return true;
237
237
  }
@@ -240,7 +240,7 @@ var Transition = class _Transition {
240
240
  this.g[1].push.apply(this.g[1], queue.g[1]);
241
241
  this.J.push.apply(this.J, queue.J);
242
242
  for (let i = 0; i < queue.f.length; i++) {
243
- const og = this.f.find((c) => c.e === queue.f[i].e);
243
+ const og = this.f.find((c) => c.d === queue.f[i].d);
244
244
  if (og)
245
245
  og.merge(queue.f[i]);
246
246
  else
@@ -251,13 +251,13 @@ var Transition = class _Transition {
251
251
  if (this.Y)
252
252
  return;
253
253
  this.Y = true;
254
- if (!this.y)
254
+ if (!this.B)
255
255
  queueMicrotask(() => this.flush());
256
256
  }
257
257
  runTransition(fn, force = false) {
258
- if (this.B) {
259
- if (this.B instanceof _Transition)
260
- return this.B.runTransition(fn, force);
258
+ if (this.D) {
259
+ if (this.D instanceof _Transition)
260
+ return this.D.runTransition(fn, force);
261
261
  if (!force)
262
262
  throw new Error("Transition already completed");
263
263
  fn();
@@ -328,29 +328,29 @@ function cloneGraph(node, optimistic) {
328
328
  Object.assign(clone, node, {
329
329
  n: null,
330
330
  m: null,
331
- b: null,
331
+ c: null,
332
332
  a: node.a ? [...node.a] : null,
333
- e: node,
333
+ d: node,
334
334
  I: !!optimistic
335
335
  });
336
- delete clone.S;
336
+ delete clone.T;
337
337
  ActiveTransition.a.set(node, clone);
338
338
  node.j = ActiveTransition;
339
339
  if (!optimistic && node.a) {
340
340
  for (let i = 0; i < node.a.length; i++)
341
- node.a[i].b.push(clone);
341
+ node.a[i].c.push(clone);
342
342
  }
343
- if (node.b) {
344
- clone.b = [];
345
- for (let i = 0, length = node.b.length; i < length; i++) {
346
- !node.b[i].e && clone.b.push(cloneGraph(node.b[i], optimistic));
343
+ if (node.c) {
344
+ clone.c = [];
345
+ for (let i = 0, length = node.c.length; i < length; i++) {
346
+ !node.c[i].d && clone.c.push(cloneGraph(node.c[i], optimistic));
347
347
  }
348
348
  }
349
349
  return clone;
350
350
  }
351
351
  function latestTransition(t) {
352
- while (t.B instanceof Transition)
353
- t = t.B;
352
+ while (t.D instanceof Transition)
353
+ t = t.D;
354
354
  return t;
355
355
  }
356
356
  function replaceSourceObservers(node, transition2) {
@@ -360,16 +360,16 @@ function replaceSourceObservers(node, transition2) {
360
360
  for (let i = 0; i < node.a.length; i++) {
361
361
  transitionSource = transition2.a.get(node.a[i]);
362
362
  source = transitionSource || node.a[i];
363
- if (source.b && (swap = source.b.indexOf(node)) !== -1) {
364
- source.b[swap] = transitionSource ? node.e : source.b[source.b.length - 1];
365
- !transitionSource && source.b.pop();
363
+ if (source.c && (swap = source.c.indexOf(node)) !== -1) {
364
+ source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
365
+ !transitionSource && source.c.pop();
366
366
  }
367
367
  }
368
368
  }
369
369
  function cloneQueue(queue, parent, transition2) {
370
370
  const clone = Object.create(Object.getPrototypeOf(queue));
371
371
  Object.assign(clone, queue, {
372
- e: queue,
372
+ d: queue,
373
373
  k: parent,
374
374
  f: [],
375
375
  enqueue(type, fn) {
@@ -377,7 +377,7 @@ function cloneQueue(queue, parent, transition2) {
377
377
  transition2.enqueue(type, fn);
378
378
  },
379
379
  notify(node, type, flags) {
380
- node = node.e || node;
380
+ node = node.d || node;
381
381
  if (!clone.K || type & LOADING_BIT) {
382
382
  type &= ~LOADING_BIT;
383
383
  transition2 = latestTransition(transition2);
@@ -396,7 +396,7 @@ function cloneQueue(queue, parent, transition2) {
396
396
  }
397
397
  function resolveQueues(children) {
398
398
  for (const child of children) {
399
- const og = child.e;
399
+ const og = child.d;
400
400
  if (og) {
401
401
  const clonedChildren = child.f;
402
402
  delete child.enqueue;
@@ -404,10 +404,10 @@ function resolveQueues(children) {
404
404
  delete child.k;
405
405
  delete child.f;
406
406
  Object.assign(og, child);
407
- delete og.e;
407
+ delete og.d;
408
408
  resolveQueues(clonedChildren);
409
- } else if (child.k.e) {
410
- child.k.e.addChild(child);
409
+ } else if (child.k.d) {
410
+ child.k.d.addChild(child);
411
411
  }
412
412
  }
413
413
  }
@@ -421,17 +421,17 @@ function mergeTransitions(t1, t2) {
421
421
  t1.I.add(c);
422
422
  });
423
423
  t2.H.forEach((p) => t1.H.add(p));
424
- t2.r.forEach((n) => t1.r.add(n));
424
+ t2.s.forEach((n) => t1.s.add(n));
425
425
  t1.merge(t2);
426
- t2.B = t1;
426
+ t2.D = t1;
427
427
  }
428
428
  function getTransitionSource(input) {
429
429
  return ActiveTransition && ActiveTransition.a.get(input) || input;
430
430
  }
431
431
  function getQueue(node) {
432
432
  var _a;
433
- const transition2 = ActiveTransition || ((_a = node.e) == null ? void 0 : _a.j);
434
- return transition2 && transition2.G.get(node.z) || node.z;
433
+ const transition2 = ActiveTransition || ((_a = node.d) == null ? void 0 : _a.j);
434
+ return transition2 && transition2.G.get(node.C) || node.C;
435
435
  }
436
436
  function initialDispose(node) {
437
437
  let current = node.m;
@@ -444,7 +444,7 @@ function initialDispose(node) {
444
444
  }
445
445
  }
446
446
  function finishTransition(transition2) {
447
- if (transition2.B || transition2.Y || transition2.H.size || transition2.r.size)
447
+ if (transition2.D || transition2.Y || transition2.H.size || transition2.s.size)
448
448
  return;
449
449
  globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
450
450
  globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
@@ -462,8 +462,8 @@ function finishTransition(transition2) {
462
462
  delete source.j;
463
463
  continue;
464
464
  }
465
- if (clone.Z || clone.c === STATE_DISPOSED) {
466
- source.dispose(clone.c === STATE_DISPOSED);
465
+ if (clone.Z || clone.b === STATE_DISPOSED) {
466
+ source.dispose(clone.b === STATE_DISPOSED);
467
467
  source.emptyDisposal();
468
468
  delete clone.Z;
469
469
  } else {
@@ -471,17 +471,17 @@ function finishTransition(transition2) {
471
471
  delete clone.n;
472
472
  }
473
473
  Object.assign(source, clone);
474
- delete source.e;
474
+ delete source.d;
475
475
  let current = clone.m;
476
- if ((current == null ? void 0 : current.t) === clone)
477
- current.t = source;
476
+ if ((current == null ? void 0 : current.y) === clone)
477
+ current.y = source;
478
478
  while ((current == null ? void 0 : current.k) === clone) {
479
479
  current.k = source;
480
480
  current = current.m;
481
481
  }
482
482
  delete source.j;
483
483
  }
484
- transition2.B = true;
484
+ transition2.D = true;
485
485
  for (const reset of transition2.I) {
486
486
  delete reset.j;
487
487
  reset();
@@ -506,11 +506,11 @@ var Owner = class {
506
506
  // See comment at the top of the file for an example of the _nextSibling traversal
507
507
  k = null;
508
508
  m = null;
509
- t = null;
510
- c = STATE_CLEAN;
509
+ y = null;
510
+ b = STATE_CLEAN;
511
511
  n = null;
512
- u = defaultContext;
513
- z = globalQueue;
512
+ z = defaultContext;
513
+ C = globalQueue;
514
514
  fa = 0;
515
515
  id = null;
516
516
  constructor(id = null, skipAppend = false) {
@@ -521,23 +521,23 @@ var Owner = class {
521
521
  }
522
522
  append(child) {
523
523
  child.k = this;
524
- child.t = this;
524
+ child.y = this;
525
525
  if (this.m)
526
- this.m.t = child;
526
+ this.m.y = child;
527
527
  child.m = this.m;
528
528
  this.m = child;
529
529
  if (this.id != null && child.id == null)
530
530
  child.id = this.getNextChildId();
531
- if (child.u !== this.u) {
532
- child.u = { ...this.u, ...child.u };
531
+ if (child.z !== this.z) {
532
+ child.z = { ...this.z, ...child.z };
533
533
  }
534
- if (this.z)
535
- child.z = this.z;
534
+ if (this.C)
535
+ child.C = this.C;
536
536
  }
537
537
  dispose(self = true) {
538
- if (this.c === STATE_DISPOSED)
538
+ if (this.b === STATE_DISPOSED)
539
539
  return;
540
- let head = self ? this.t || this.k : this, current = this.m, next = null;
540
+ let head = self ? this.y || this.k : this, current = this.m, next = null;
541
541
  while (current && current.k === this) {
542
542
  current.dispose(true);
543
543
  next = current.m;
@@ -546,19 +546,19 @@ var Owner = class {
546
546
  }
547
547
  this.fa = 0;
548
548
  if (self)
549
- this.T();
549
+ this.L();
550
550
  if (current)
551
- current.t = !self ? this : this.t;
551
+ current.y = !self ? this : this.y;
552
552
  if (head)
553
553
  head.m = current;
554
554
  }
555
- T() {
556
- if (this.t)
557
- this.t.m = null;
555
+ L() {
556
+ if (this.y)
557
+ this.y.m = null;
558
558
  this.k = null;
559
- this.t = null;
560
- this.u = defaultContext;
561
- this.c = STATE_DISPOSED;
559
+ this.y = null;
560
+ this.z = defaultContext;
561
+ this.b = STATE_DISPOSED;
562
562
  this.emptyDisposal();
563
563
  }
564
564
  emptyDisposal() {
@@ -587,7 +587,7 @@ function getContext(context, owner = currentOwner) {
587
587
  if (!owner) {
588
588
  throw new NoOwnerError();
589
589
  }
590
- const value = hasContext(context, owner) ? owner.u[context.id] : context.defaultValue;
590
+ const value = hasContext(context, owner) ? owner.z[context.id] : context.defaultValue;
591
591
  if (isUndefined(value)) {
592
592
  throw new ContextNotFoundError();
593
593
  }
@@ -597,13 +597,13 @@ function setContext(context, value, owner = currentOwner) {
597
597
  if (!owner) {
598
598
  throw new NoOwnerError();
599
599
  }
600
- owner.u = {
601
- ...owner.u,
600
+ owner.z = {
601
+ ...owner.z,
602
602
  [context.id]: isUndefined(value) ? context.defaultValue : value
603
603
  };
604
604
  }
605
605
  function hasContext(context, owner = currentOwner) {
606
- return !isUndefined(owner == null ? void 0 : owner.u[context.id]);
606
+ return !isUndefined(owner == null ? void 0 : owner.z[context.id]);
607
607
  }
608
608
  function onCleanup(fn) {
609
609
  if (!currentOwner)
@@ -641,10 +641,10 @@ function getObserver() {
641
641
  var UNCHANGED = Symbol(0);
642
642
  var Computation = class extends Owner {
643
643
  a = null;
644
- b = null;
644
+ c = null;
645
645
  l;
646
- M;
647
- N;
646
+ O;
647
+ P;
648
648
  // Used in __DEV__ mode, hopefully removed in production
649
649
  la;
650
650
  // Using false is an optimization as an alternative to _equals: () => false
@@ -653,19 +653,19 @@ var Computation = class extends Owner {
653
653
  ea;
654
654
  ha = false;
655
655
  /** Whether the computation is an error or has ancestors that are unresolved */
656
- h = 0;
656
+ i = 0;
657
657
  /** Which flags raised by sources are handled, vs. being passed through. */
658
658
  ba = DEFAULT_FLAGS;
659
- O = -1;
660
- C = false;
659
+ Q = -1;
660
+ E = false;
661
661
  j;
662
- e;
662
+ d;
663
663
  I = false;
664
664
  constructor(initialValue, compute2, options) {
665
665
  super(options == null ? void 0 : options.id, compute2 === null);
666
- this.N = compute2;
667
- this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
668
- this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
666
+ this.P = compute2;
667
+ this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
668
+ this.i = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
669
669
  this.l = initialValue;
670
670
  if ((options == null ? void 0 : options.equals) !== void 0)
671
671
  this.aa = options.equals;
@@ -678,9 +678,9 @@ var Computation = class extends Owner {
678
678
  }
679
679
  ga() {
680
680
  track(this);
681
- newFlags |= this.h & ~currentMask;
682
- if (this.h & ERROR_BIT) {
683
- throw this.M;
681
+ newFlags |= this.i & ~currentMask;
682
+ if (this.i & ERROR_BIT) {
683
+ throw this.O;
684
684
  } else {
685
685
  return this.l;
686
686
  }
@@ -690,16 +690,16 @@ var Computation = class extends Owner {
690
690
  * Automatically re-executes the surrounding computation when the value changes
691
691
  */
692
692
  read() {
693
- if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & (UNINITIALIZED_BIT | ERROR_BIT))) {
693
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
694
694
  const clone = ActiveTransition.a.get(this) || cloneGraph(this);
695
695
  if (clone !== this)
696
696
  return clone.read();
697
697
  }
698
- if (this.N) {
699
- if (this.h & ERROR_BIT && this.O <= clock)
698
+ if (this.P) {
699
+ if (this.i & ERROR_BIT && this.Q <= clock)
700
700
  update(this);
701
701
  else
702
- this.L();
702
+ this.M();
703
703
  }
704
704
  return this.ga();
705
705
  }
@@ -711,49 +711,49 @@ var Computation = class extends Owner {
711
711
  * before continuing
712
712
  */
713
713
  wait() {
714
- if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & (UNINITIALIZED_BIT | ERROR_BIT))) {
714
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
715
715
  const clone = ActiveTransition.a.get(this) || cloneGraph(this);
716
716
  if (clone !== this)
717
717
  return clone.wait();
718
718
  }
719
- if (this.N) {
720
- if (this.h & ERROR_BIT && this.O <= clock)
719
+ if (this.P) {
720
+ if (this.i & ERROR_BIT && this.Q <= clock)
721
721
  update(this);
722
722
  else
723
- this.L();
723
+ this.M();
724
724
  }
725
- if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
725
+ if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
726
726
  track(this);
727
727
  throw new NotReadyError();
728
728
  }
729
- if (staleCheck && this.h & LOADING_BIT) {
729
+ if (staleCheck && this.i & LOADING_BIT) {
730
730
  staleCheck.l = true;
731
731
  }
732
732
  return this.ga();
733
733
  }
734
734
  /** Update the computation with a new value. */
735
735
  write(value, flags = 0, raw = false) {
736
- if (ActiveTransition && !this.e) {
736
+ if (ActiveTransition && !this.d) {
737
737
  const clone = cloneGraph(this);
738
738
  if (clone !== this)
739
739
  return clone.write(value, flags, raw);
740
740
  }
741
741
  const newValue = !raw && typeof value === "function" ? value(this.l) : value;
742
- const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
742
+ const valueChanged = newValue !== UNCHANGED && (!!(this.i & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
743
743
  this.aa === false || !this.aa(this.l, newValue));
744
744
  if (valueChanged) {
745
745
  this.l = newValue;
746
- this.M = void 0;
746
+ this.O = void 0;
747
747
  }
748
- const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
749
- this.h = flags;
750
- this.O = clock + 1;
751
- if (this.b) {
752
- for (let i = 0; i < this.b.length; i++) {
748
+ const changedFlagsMask = this.i ^ flags, changedFlags = changedFlagsMask & flags;
749
+ this.i = flags;
750
+ this.Q = clock + 1;
751
+ if (this.c) {
752
+ for (let i = 0; i < this.c.length; i++) {
753
753
  if (valueChanged) {
754
- this.b[i].w(STATE_DIRTY);
754
+ this.c[i].t(STATE_DIRTY);
755
755
  } else if (changedFlagsMask) {
756
- this.b[i]._(changedFlagsMask, changedFlags);
756
+ this.c[i]._(changedFlagsMask, changedFlags);
757
757
  }
758
758
  }
759
759
  }
@@ -762,14 +762,14 @@ var Computation = class extends Owner {
762
762
  /**
763
763
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
764
764
  */
765
- w(state, skipQueue) {
766
- if (this.c >= state && !this.C)
765
+ t(state, skipQueue) {
766
+ if (this.b >= state && !this.E)
767
767
  return;
768
- this.C = !!skipQueue;
769
- this.c = state;
770
- if (this.b) {
771
- for (let i = 0; i < this.b.length; i++) {
772
- this.b[i].w(STATE_CHECK, skipQueue);
768
+ this.E = !!skipQueue;
769
+ this.b = state;
770
+ if (this.c) {
771
+ for (let i = 0; i < this.c.length; i++) {
772
+ this.c[i].t(STATE_CHECK, skipQueue);
773
773
  }
774
774
  }
775
775
  }
@@ -780,35 +780,35 @@ var Computation = class extends Owner {
780
780
  * @param newFlags The source's new flags, masked to just the changed ones.
781
781
  */
782
782
  _(mask, newFlags2) {
783
- if (this.c >= STATE_DIRTY)
783
+ if (this.b >= STATE_DIRTY)
784
784
  return;
785
785
  if (mask & this.ba) {
786
- this.w(STATE_DIRTY);
786
+ this.t(STATE_DIRTY);
787
787
  return;
788
788
  }
789
- if (this.c >= STATE_CHECK && !this.C)
789
+ if (this.b >= STATE_CHECK && !this.E)
790
790
  return;
791
- const prevFlags = this.h & mask;
791
+ const prevFlags = this.i & mask;
792
792
  const deltaFlags = prevFlags ^ newFlags2;
793
793
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
794
- this.w(STATE_CHECK);
794
+ this.t(STATE_CHECK);
795
795
  } else {
796
- this.h ^= deltaFlags;
797
- if (this.b) {
798
- for (let i = 0; i < this.b.length; i++) {
799
- this.b[i]._(mask, newFlags2);
796
+ this.i ^= deltaFlags;
797
+ if (this.c) {
798
+ for (let i = 0; i < this.c.length; i++) {
799
+ this.c[i]._(mask, newFlags2);
800
800
  }
801
801
  }
802
802
  }
803
803
  }
804
- D(error) {
805
- if (ActiveTransition && !this.e) {
804
+ N(error) {
805
+ if (ActiveTransition && !this.d) {
806
806
  const clone = cloneGraph(this);
807
807
  if (clone !== this)
808
- return clone.D(error);
808
+ return clone.N(error);
809
809
  }
810
- this.M = error;
811
- this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
810
+ this.O = error;
811
+ this.write(UNCHANGED, this.i & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
812
812
  }
813
813
  /**
814
814
  * This is the core part of the reactivity system, which makes sure that the values are updated
@@ -817,48 +817,48 @@ var Computation = class extends Owner {
817
817
  *
818
818
  * This function will ensure that the value and states we read from the computation are up to date
819
819
  */
820
- L() {
821
- if (!this.N) {
820
+ M() {
821
+ if (!this.P) {
822
822
  return;
823
823
  }
824
- if (this.c === STATE_DISPOSED) {
824
+ if (this.b === STATE_DISPOSED) {
825
825
  return;
826
826
  }
827
- if (this.c === STATE_CLEAN) {
827
+ if (this.b === STATE_CLEAN) {
828
828
  return;
829
829
  }
830
830
  let observerFlags = 0;
831
- if (this.c === STATE_CHECK) {
831
+ if (this.b === STATE_CHECK) {
832
832
  for (let i = 0; i < this.a.length; i++) {
833
833
  const source = getTransitionSource(this.a[i]);
834
- source.L();
835
- observerFlags |= source.h & ~UNINITIALIZED_BIT;
836
- if (this.c === STATE_DIRTY) {
834
+ source.M();
835
+ observerFlags |= source.i & ~UNINITIALIZED_BIT;
836
+ if (this.b === STATE_DIRTY) {
837
837
  break;
838
838
  }
839
839
  }
840
840
  }
841
- if (this.c === STATE_DIRTY) {
841
+ if (this.b === STATE_DIRTY) {
842
842
  update(this);
843
843
  } else {
844
844
  this.write(UNCHANGED, observerFlags);
845
- this.c = STATE_CLEAN;
845
+ this.b = STATE_CLEAN;
846
846
  }
847
847
  }
848
848
  /**
849
849
  * Remove ourselves from the owner graph and the computation graph
850
850
  */
851
- T() {
852
- if (this.c === STATE_DISPOSED)
851
+ L() {
852
+ if (this.b === STATE_DISPOSED)
853
853
  return;
854
854
  if (this.a)
855
855
  removeSourceObservers(this, 0);
856
- super.T();
856
+ super.L();
857
857
  }
858
858
  };
859
859
  function track(computation) {
860
- if (ActiveTransition && computation.e)
861
- computation = computation.e;
860
+ if (ActiveTransition && computation.d)
861
+ computation = computation.d;
862
862
  if (currentObserver) {
863
863
  if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
864
864
  newSourcesIndex++;
@@ -868,7 +868,7 @@ function track(computation) {
868
868
  newSources.push(computation);
869
869
  }
870
870
  if (updateCheck) {
871
- updateCheck.l = computation.O > currentObserver.O;
871
+ updateCheck.l = computation.Q > currentObserver.Q;
872
872
  }
873
873
  }
874
874
  }
@@ -878,19 +878,19 @@ function update(node) {
878
878
  newSourcesIndex = 0;
879
879
  newFlags = 0;
880
880
  try {
881
- if (ActiveTransition && node.e && !node.Z) {
882
- initialDispose(node.e);
881
+ if (ActiveTransition && node.d && !node.Z) {
882
+ initialDispose(node.d);
883
883
  node.Z = true;
884
884
  }
885
885
  node.dispose(false);
886
886
  node.emptyDisposal();
887
- const result = compute(node, node.N, node);
887
+ const result = compute(node, node.P, node);
888
888
  node.write(result, newFlags, true);
889
889
  } catch (error) {
890
890
  if (error instanceof NotReadyError) {
891
- node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
891
+ node.write(UNCHANGED, newFlags | LOADING_BIT | node.i & UNINITIALIZED_BIT);
892
892
  } else {
893
- node.D(error);
893
+ node.N(error);
894
894
  }
895
895
  } finally {
896
896
  if (newSources) {
@@ -907,10 +907,10 @@ function update(node) {
907
907
  let source;
908
908
  for (let i = newSourcesIndex; i < node.a.length; i++) {
909
909
  source = getTransitionSource(node.a[i]);
910
- if (!source.b)
911
- source.b = [node];
910
+ if (!source.c)
911
+ source.c = [node];
912
912
  else
913
- source.b.push(node);
913
+ source.c.push(node);
914
914
  }
915
915
  } else if (node.a && newSourcesIndex < node.a.length) {
916
916
  removeSourceObservers(node, newSourcesIndex);
@@ -919,8 +919,8 @@ function update(node) {
919
919
  newSources = prevSources;
920
920
  newSourcesIndex = prevSourcesIndex;
921
921
  newFlags = prevFlags;
922
- node.O = clock + 1;
923
- node.c = STATE_CLEAN;
922
+ node.Q = clock + 1;
923
+ node.b = STATE_CLEAN;
924
924
  }
925
925
  }
926
926
  function isEqual(a, b) {
@@ -980,46 +980,6 @@ function latest(fn, fallback) {
980
980
  notStale = prevNotStale;
981
981
  }
982
982
  }
983
- function runWithObserver(observer, run) {
984
- const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
985
- newSources = null;
986
- newSourcesIndex = observer.a ? observer.a.length : 0;
987
- newFlags = 0;
988
- try {
989
- return compute(observer, run, observer);
990
- } catch (error) {
991
- if (error instanceof NotReadyError) {
992
- observer.write(
993
- UNCHANGED,
994
- newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
995
- );
996
- } else {
997
- observer.D(error);
998
- }
999
- } finally {
1000
- if (newSources) {
1001
- if (newSourcesIndex > 0) {
1002
- observer.a.length = newSourcesIndex + newSources.length;
1003
- for (let i = 0; i < newSources.length; i++) {
1004
- observer.a[newSourcesIndex + i] = newSources[i];
1005
- }
1006
- } else {
1007
- observer.a = newSources;
1008
- }
1009
- let source;
1010
- for (let i = newSourcesIndex; i < observer.a.length; i++) {
1011
- source = observer.a[i];
1012
- if (!source.b)
1013
- source.b = [observer];
1014
- else
1015
- source.b.push(observer);
1016
- }
1017
- }
1018
- newSources = prevSources;
1019
- newSourcesIndex = prevSourcesIndex;
1020
- newFlags = prevFlags;
1021
- }
1022
- }
1023
983
  function compute(owner, fn, observer) {
1024
984
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
1025
985
  currentObserver = observer;
@@ -1039,66 +999,66 @@ function compute(owner, fn, observer) {
1039
999
  var Effect = class extends Computation {
1040
1000
  ca;
1041
1001
  $;
1042
- P;
1002
+ u;
1043
1003
  da = false;
1044
- S;
1045
- A;
1004
+ T;
1005
+ r;
1046
1006
  constructor(initialValue, compute2, effect, error, options) {
1047
1007
  super(initialValue, compute2, options);
1048
1008
  this.ca = effect;
1049
1009
  this.$ = error;
1050
- this.S = initialValue;
1051
- this.A = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
1052
- if (this.A === EFFECT_RENDER) {
1053
- this.N = function(p) {
1054
- return !this.e && clock > this.z.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1010
+ this.T = initialValue;
1011
+ this.r = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
1012
+ if (this.r === EFFECT_RENDER) {
1013
+ this.P = function(p) {
1014
+ return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1055
1015
  };
1056
1016
  }
1057
- this.L();
1058
- !(options == null ? void 0 : options.defer) && (this.A === EFFECT_USER ? getQueue(this).enqueue(this.A, this.E.bind(this)) : this.E(this.A));
1017
+ this.M();
1018
+ !(options == null ? void 0 : options.defer) && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
1059
1019
  }
1060
1020
  write(value, flags = 0) {
1061
- if (this.c == STATE_DIRTY) {
1062
- this.h = flags;
1063
- if (this.A === EFFECT_RENDER) {
1064
- getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.h);
1021
+ if (this.b == STATE_DIRTY) {
1022
+ this.i = flags;
1023
+ if (this.r === EFFECT_RENDER) {
1024
+ getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.i);
1065
1025
  }
1066
1026
  }
1067
1027
  if (value === UNCHANGED)
1068
1028
  return this.l;
1069
1029
  this.l = value;
1070
1030
  this.da = true;
1071
- this.M = void 0;
1031
+ this.O = void 0;
1072
1032
  return value;
1073
1033
  }
1074
- w(state, skipQueue) {
1075
- if (this.c >= state || skipQueue)
1034
+ t(state, skipQueue) {
1035
+ if (this.b >= state || skipQueue)
1076
1036
  return;
1077
- if (this.c === STATE_CLEAN || this.e && !ActiveTransition)
1078
- getQueue(this).enqueue(this.A, this.E.bind(this));
1079
- this.c = state;
1037
+ if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
1038
+ getQueue(this).enqueue(this.r, this.w.bind(this));
1039
+ this.b = state;
1080
1040
  }
1081
1041
  _(mask, newFlags2) {
1082
- if (this.e) {
1083
- if (this.c >= STATE_DIRTY)
1042
+ if (this.d) {
1043
+ if (this.b >= STATE_DIRTY)
1084
1044
  return;
1085
1045
  if (mask & 3) {
1086
- this.w(STATE_DIRTY);
1046
+ this.t(STATE_DIRTY);
1087
1047
  return;
1088
1048
  }
1089
1049
  }
1090
1050
  super._(mask, newFlags2);
1091
1051
  }
1092
- D(error) {
1093
- this.M = error;
1052
+ N(error) {
1053
+ this.O = error;
1094
1054
  getQueue(this).notify(this, LOADING_BIT, 0);
1095
- this.h = ERROR_BIT;
1096
- if (this.A === EFFECT_USER) {
1055
+ this.i = ERROR_BIT;
1056
+ if (this.r === EFFECT_USER) {
1097
1057
  try {
1098
1058
  return this.$ ? this.$(error, () => {
1099
1059
  var _a;
1100
- (_a = this.P) == null ? void 0 : _a.call(this);
1101
- this.P = void 0;
1060
+ (_a = this.u) == null ? void 0 : _a.call(this);
1061
+ this.u = void 0;
1102
1062
  }) : console.error(error);
1103
1063
  } catch (e) {
1104
1064
  error = e;
@@ -1107,52 +1067,85 @@ var Effect = class extends Computation {
1107
1067
  if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
1108
1068
  throw error;
1109
1069
  }
1110
- T() {
1070
+ L() {
1111
1071
  var _a;
1112
- if (this.c === STATE_DISPOSED)
1072
+ if (this.b === STATE_DISPOSED)
1113
1073
  return;
1114
1074
  this.ca = void 0;
1115
- this.S = void 0;
1075
+ this.T = void 0;
1116
1076
  this.$ = void 0;
1117
- (_a = this.P) == null ? void 0 : _a.call(this);
1118
- this.P = void 0;
1077
+ (_a = this.u) == null ? void 0 : _a.call(this);
1078
+ this.u = void 0;
1119
1079
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1120
- super.T();
1080
+ super.L();
1121
1081
  }
1122
- E(type) {
1082
+ w(type) {
1123
1083
  var _a;
1124
1084
  if (type) {
1125
- const effect = this.e || this;
1126
- if (effect.da && effect.c !== STATE_DISPOSED) {
1127
- (_a = effect.P) == null ? void 0 : _a.call(effect);
1085
+ const effect = this.d || this;
1086
+ if (effect.da && effect.b !== STATE_DISPOSED) {
1087
+ (_a = effect.u) == null ? void 0 : _a.call(effect);
1128
1088
  try {
1129
- effect.P = effect.ca(effect.l, effect.S);
1089
+ effect.u = effect.ca(effect.l, effect.T);
1130
1090
  } catch (e) {
1131
1091
  if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
1132
1092
  throw e;
1133
1093
  } finally {
1134
- effect.S = effect.l;
1094
+ effect.T = effect.l;
1135
1095
  effect.da = false;
1136
1096
  }
1137
1097
  }
1138
1098
  } else
1139
- this.c !== STATE_CLEAN && runTop(this);
1099
+ this.b !== STATE_CLEAN && runTop(this);
1100
+ }
1101
+ };
1102
+ var TrackedEffect = class extends Computation {
1103
+ r = EFFECT_USER;
1104
+ u;
1105
+ constructor(compute2, options) {
1106
+ super(void 0, () => {
1107
+ var _a;
1108
+ (_a = this.u) == null ? void 0 : _a.call(this);
1109
+ this.u = latest(compute2);
1110
+ return void 0;
1111
+ }, options);
1112
+ getQueue(this).enqueue(this.r, this.w.bind(this));
1113
+ }
1114
+ t(state, skipQueue) {
1115
+ if (this.b >= state || skipQueue)
1116
+ return;
1117
+ if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
1118
+ getQueue(this).enqueue(this.r, this.w.bind(this));
1119
+ this.b = state;
1120
+ }
1121
+ L() {
1122
+ var _a;
1123
+ if (this.b === STATE_DISPOSED)
1124
+ return;
1125
+ (_a = this.u) == null ? void 0 : _a.call(this);
1126
+ this.u = void 0;
1127
+ getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1128
+ super.L();
1129
+ }
1130
+ w(type) {
1131
+ if (type)
1132
+ this.b !== STATE_CLEAN && runTop(this);
1140
1133
  }
1141
1134
  };
1142
1135
  var EagerComputation = class extends Computation {
1143
1136
  constructor(initialValue, compute2, options) {
1144
1137
  super(initialValue, compute2, options);
1145
- !(options == null ? void 0 : options.defer) && this.L();
1138
+ !(options == null ? void 0 : options.defer) && this.M();
1146
1139
  }
1147
- w(state, skipQueue) {
1148
- if (this.c >= state && !this.C)
1140
+ t(state, skipQueue) {
1141
+ if (this.b >= state && !this.E)
1149
1142
  return;
1150
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.C))
1151
- getQueue(this).enqueue(EFFECT_PURE, this.E.bind(this));
1152
- super.w(state, skipQueue);
1143
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1144
+ getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1145
+ super.t(state, skipQueue);
1153
1146
  }
1154
- E() {
1155
- this.c !== STATE_CLEAN && runTop(this);
1147
+ w() {
1148
+ this.b !== STATE_CLEAN && runTop(this);
1156
1149
  }
1157
1150
  };
1158
1151
  var FirewallComputation = class extends Computation {
@@ -1160,16 +1153,16 @@ var FirewallComputation = class extends Computation {
1160
1153
  constructor(compute2) {
1161
1154
  super(void 0, compute2);
1162
1155
  }
1163
- w(state, skipQueue) {
1164
- if (this.c >= state && !this.C)
1156
+ t(state, skipQueue) {
1157
+ if (this.b >= state && !this.E)
1165
1158
  return;
1166
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.C))
1167
- getQueue(this).enqueue(EFFECT_PURE, this.E.bind(this));
1168
- super.w(state, true);
1169
- this.C = !!skipQueue;
1159
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1160
+ getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1161
+ super.t(state, true);
1162
+ this.E = !!skipQueue;
1170
1163
  }
1171
- E() {
1172
- this.c !== STATE_CLEAN && runTop(this);
1164
+ w() {
1165
+ this.b !== STATE_CLEAN && runTop(this);
1173
1166
  }
1174
1167
  };
1175
1168
  function runTop(node) {
@@ -1177,28 +1170,21 @@ function runTop(node) {
1177
1170
  for (let current = node; current !== null; current = current.k) {
1178
1171
  if (ActiveTransition && current.j)
1179
1172
  current = ActiveTransition.a.get(current);
1180
- if (current.c !== STATE_CLEAN) {
1173
+ if (current.b !== STATE_CLEAN) {
1181
1174
  ancestors.push(current);
1182
1175
  }
1183
1176
  }
1184
1177
  for (let i = ancestors.length - 1; i >= 0; i--) {
1185
- if (ancestors[i].c !== STATE_DISPOSED)
1186
- ancestors[i].L();
1178
+ if (ancestors[i].b !== STATE_DISPOSED)
1179
+ ancestors[i].M();
1187
1180
  }
1188
1181
  }
1189
1182
 
1190
1183
  // src/signals.ts
1191
1184
  function createSignal(first, second, third) {
1192
1185
  if (typeof first === "function") {
1193
- const memo = createMemo((p) => {
1194
- const node2 = new Computation(
1195
- first(p ? untrack(p[0]) : second),
1196
- null,
1197
- third
1198
- );
1199
- return [node2.read.bind(node2), node2.write.bind(node2)];
1200
- });
1201
- return [() => memo()[0](), (value) => memo()[1](value)];
1186
+ const node2 = new Computation(second, first, third);
1187
+ return [node2.read.bind(node2), node2.write.bind(node2)];
1202
1188
  }
1203
1189
  const o = getOwner();
1204
1190
  const needsId = (o == null ? void 0 : o.id) != null;
@@ -1219,12 +1205,12 @@ function createMemo(compute2, value, options) {
1219
1205
  return () => {
1220
1206
  var _a, _b;
1221
1207
  if (node) {
1222
- if (node.c === STATE_DISPOSED) {
1208
+ if (node.b === STATE_DISPOSED) {
1223
1209
  node = void 0;
1224
1210
  return resolvedValue;
1225
1211
  }
1226
1212
  resolvedValue = node.wait();
1227
- if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.k) !== node && !(node.h & UNINITIALIZED_BIT)) {
1213
+ if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.k) !== node && !(node.i & UNINITIALIZED_BIT)) {
1228
1214
  node.dispose();
1229
1215
  node = void 0;
1230
1216
  }
@@ -1262,8 +1248,8 @@ function createAsync(compute2, value, options) {
1262
1248
  if (abort)
1263
1249
  return;
1264
1250
  if (transition2)
1265
- return transition2.runTransition(() => node.D(error), true);
1266
- node.D(error);
1251
+ return transition2.runTransition(() => node.N(error), true);
1252
+ node.N(error);
1267
1253
  }
1268
1254
  );
1269
1255
  } else {
@@ -1284,10 +1270,10 @@ function createAsync(compute2, value, options) {
1284
1270
  return;
1285
1271
  if (transition2)
1286
1272
  return transition2.runTransition(() => {
1287
- node.D(error);
1273
+ node.N(error);
1288
1274
  transition2 = null;
1289
1275
  }, true);
1290
- node.D(error);
1276
+ node.N(error);
1291
1277
  }
1292
1278
  })();
1293
1279
  }
@@ -1298,12 +1284,12 @@ function createAsync(compute2, value, options) {
1298
1284
  const read = node.wait.bind(node);
1299
1285
  read.refresh = () => {
1300
1286
  let n = node;
1301
- if (ActiveTransition && !node.e) {
1287
+ if (ActiveTransition && !node.d) {
1302
1288
  n = cloneGraph(node);
1303
1289
  }
1304
- n.c = STATE_DIRTY;
1290
+ n.b = STATE_DIRTY;
1305
1291
  refreshing = true;
1306
- n.L();
1292
+ n.M();
1307
1293
  };
1308
1294
  return read;
1309
1295
  }
@@ -1311,7 +1297,7 @@ function createEffect(compute2, effect, value, options) {
1311
1297
  void new Effect(
1312
1298
  value,
1313
1299
  compute2,
1314
- effect.effect ? effect.effect : effect,
1300
+ effect.effect || effect,
1315
1301
  effect.error,
1316
1302
  options
1317
1303
  );
@@ -1322,6 +1308,30 @@ function createRenderEffect(compute2, effect, value, options) {
1322
1308
  ...options
1323
1309
  });
1324
1310
  }
1311
+ function createTrackedEffect(compute2, options) {
1312
+ void new TrackedEffect(compute2, options);
1313
+ }
1314
+ function createReaction(effect, options) {
1315
+ let cleanup = void 0;
1316
+ onCleanup(() => cleanup == null ? void 0 : cleanup());
1317
+ return (tracking) => {
1318
+ const node = new Effect(
1319
+ void 0,
1320
+ tracking,
1321
+ () => {
1322
+ var _a;
1323
+ cleanup == null ? void 0 : cleanup();
1324
+ cleanup = (_a = effect.effect || effect) == null ? void 0 : _a();
1325
+ node.dispose(true);
1326
+ },
1327
+ effect.error,
1328
+ {
1329
+ defer: true,
1330
+ ...options
1331
+ }
1332
+ );
1333
+ };
1334
+ }
1325
1335
  function createRoot(init, options) {
1326
1336
  const owner = new Owner(options == null ? void 0 : options.id);
1327
1337
  return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
@@ -1345,23 +1355,20 @@ function resolve(fn) {
1345
1355
  });
1346
1356
  });
1347
1357
  }
1348
- function createPending() {
1349
- const node = new Computation(false, null);
1350
- const reset = () => node.write(false);
1351
- function write() {
1358
+ function createOptimistic(first, second, third) {
1359
+ const node = typeof first === "function" ? new Computation(second, first, third) : new Computation(first, null, second);
1360
+ const reset = () => node.write(first);
1361
+ function write(v) {
1352
1362
  if (!ActiveTransition)
1353
- return false;
1363
+ throw new Error("createOptimistic can only be updated inside a transition");
1354
1364
  ActiveTransition.addOptimistic(reset);
1355
- queueMicrotask(() => reset.j && node.write(true));
1356
- }
1357
- function read() {
1358
- const v = node.read();
1359
- return ActiveTransition ? false : v;
1365
+ cloneGraph(node, true);
1366
+ queueMicrotask(() => reset.j && node.write(v));
1360
1367
  }
1361
- return [read, write];
1368
+ return [node.read.bind(node), write];
1362
1369
  }
1363
1370
  function useTransition() {
1364
- const [pending, setPending] = createPending();
1371
+ const [pending, setPending] = createOptimistic(false);
1365
1372
  function start(fn) {
1366
1373
  transition((resume) => {
1367
1374
  setPending(true);
@@ -1834,7 +1841,7 @@ function deep(store) {
1834
1841
  }
1835
1842
 
1836
1843
  // src/store/optimistic.ts
1837
- function createOptimistic(first, second, options) {
1844
+ function createOptimisticStore(first, second, options) {
1838
1845
  const derived = typeof first === "function";
1839
1846
  const { store, node } = derived ? createProjectionInternal(first, second, options) : createProjectionInternal(() => {
1840
1847
  }, first);
@@ -1848,7 +1855,7 @@ function createOptimistic(first, second, options) {
1848
1855
  );
1849
1856
  const write = (v) => {
1850
1857
  if (!ActiveTransition)
1851
- throw new Error("createOptimistic can only be updated inside a transition");
1858
+ throw new Error("createOptimisticStore can only be updated inside a transition");
1852
1859
  ActiveTransition.addOptimistic(reset);
1853
1860
  cloneGraph(node, true);
1854
1861
  queueMicrotask(() => reset.j && storeSetter(store, v));
@@ -2065,10 +2072,10 @@ function mapArray(list, map, options) {
2065
2072
  o: 0,
2066
2073
  ia: list,
2067
2074
  F: [],
2068
- Q: map,
2069
- i: [],
2070
- d: [],
2071
- R: keyFn,
2075
+ R: map,
2076
+ h: [],
2077
+ e: [],
2078
+ S: keyFn,
2072
2079
  p: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
2073
2080
  q: map.length > 1 ? [] : void 0,
2074
2081
  V: options == null ? void 0 : options.fallback
@@ -2082,53 +2089,53 @@ function updateKeyedMap() {
2082
2089
  let i, j, mapper = this.p ? () => {
2083
2090
  this.p[j] = new Computation(newItems[j], null, pureOptions);
2084
2091
  this.q && (this.q[j] = new Computation(j, null, pureOptions));
2085
- return this.Q(
2092
+ return this.R(
2086
2093
  Computation.prototype.read.bind(this.p[j]),
2087
2094
  this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
2088
2095
  );
2089
2096
  } : this.q ? () => {
2090
2097
  const item = newItems[j];
2091
2098
  this.q[j] = new Computation(j, null, pureOptions);
2092
- return this.Q(() => item, Computation.prototype.read.bind(this.q[j]));
2099
+ return this.R(() => item, Computation.prototype.read.bind(this.q[j]));
2093
2100
  } : () => {
2094
2101
  const item = newItems[j];
2095
- return this.Q(() => item);
2102
+ return this.R(() => item);
2096
2103
  };
2097
2104
  if (newLen === 0) {
2098
2105
  if (this.o !== 0) {
2099
2106
  this.U.dispose(false);
2100
- this.d = [];
2107
+ this.e = [];
2101
2108
  this.F = [];
2102
- this.i = [];
2109
+ this.h = [];
2103
2110
  this.o = 0;
2104
2111
  this.p && (this.p = []);
2105
2112
  this.q && (this.q = []);
2106
2113
  }
2107
- if (this.V && !this.i[0]) {
2108
- this.i[0] = compute(
2109
- this.d[0] = new Owner(),
2114
+ if (this.V && !this.h[0]) {
2115
+ this.h[0] = compute(
2116
+ this.e[0] = new Owner(),
2110
2117
  this.V,
2111
2118
  null
2112
2119
  );
2113
2120
  }
2114
2121
  } else if (this.o === 0) {
2115
- if (this.d[0])
2116
- this.d[0].dispose();
2117
- this.i = new Array(newLen);
2122
+ if (this.e[0])
2123
+ this.e[0].dispose();
2124
+ this.h = new Array(newLen);
2118
2125
  for (j = 0; j < newLen; j++) {
2119
2126
  this.F[j] = newItems[j];
2120
- this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2127
+ this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
2121
2128
  }
2122
2129
  this.o = newLen;
2123
2130
  } else {
2124
2131
  let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
2125
- for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.R, this.F[start], newItems[start])); start++) {
2132
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.S, this.F[start], newItems[start])); start++) {
2126
2133
  if (this.p)
2127
2134
  this.p[start].write(newItems[start]);
2128
2135
  }
2129
- for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.R, this.F[end], newItems[newEnd])); end--, newEnd--) {
2130
- temp[newEnd] = this.i[end];
2131
- tempNodes[newEnd] = this.d[end];
2136
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.S, this.F[end], newItems[newEnd])); end--, newEnd--) {
2137
+ temp[newEnd] = this.h[end];
2138
+ tempNodes[newEnd] = this.e[end];
2132
2139
  tempRows && (tempRows[newEnd] = this.p[end]);
2133
2140
  tempIndexes && (tempIndexes[newEnd] = this.q[end]);
2134
2141
  }
@@ -2136,29 +2143,29 @@ function updateKeyedMap() {
2136
2143
  newIndicesNext = new Array(newEnd + 1);
2137
2144
  for (j = newEnd; j >= start; j--) {
2138
2145
  item = newItems[j];
2139
- key = this.R ? this.R(item) : item;
2146
+ key = this.S ? this.S(item) : item;
2140
2147
  i = newIndices.get(key);
2141
2148
  newIndicesNext[j] = i === void 0 ? -1 : i;
2142
2149
  newIndices.set(key, j);
2143
2150
  }
2144
2151
  for (i = start; i <= end; i++) {
2145
2152
  item = this.F[i];
2146
- key = this.R ? this.R(item) : item;
2153
+ key = this.S ? this.S(item) : item;
2147
2154
  j = newIndices.get(key);
2148
2155
  if (j !== void 0 && j !== -1) {
2149
- temp[j] = this.i[i];
2150
- tempNodes[j] = this.d[i];
2156
+ temp[j] = this.h[i];
2157
+ tempNodes[j] = this.e[i];
2151
2158
  tempRows && (tempRows[j] = this.p[i]);
2152
2159
  tempIndexes && (tempIndexes[j] = this.q[i]);
2153
2160
  j = newIndicesNext[j];
2154
2161
  newIndices.set(key, j);
2155
2162
  } else
2156
- this.d[i].dispose();
2163
+ this.e[i].dispose();
2157
2164
  }
2158
2165
  for (j = start; j < newLen; j++) {
2159
2166
  if (j in temp) {
2160
- this.i[j] = temp[j];
2161
- this.d[j] = tempNodes[j];
2167
+ this.h[j] = temp[j];
2168
+ this.e[j] = tempNodes[j];
2162
2169
  if (tempRows) {
2163
2170
  this.p[j] = tempRows[j];
2164
2171
  this.p[j].write(newItems[j]);
@@ -2168,24 +2175,24 @@ function updateKeyedMap() {
2168
2175
  this.q[j].write(j);
2169
2176
  }
2170
2177
  } else {
2171
- this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2178
+ this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
2172
2179
  }
2173
2180
  }
2174
- this.i = this.i.slice(0, this.o = newLen);
2181
+ this.h = this.h.slice(0, this.o = newLen);
2175
2182
  this.F = newItems.slice(0);
2176
2183
  }
2177
2184
  });
2178
- return this.i;
2185
+ return this.h;
2179
2186
  }
2180
2187
  function repeat(count, map, options) {
2181
2188
  return updateRepeat.bind({
2182
2189
  U: new Owner(),
2183
2190
  o: 0,
2184
- x: 0,
2191
+ A: 0,
2185
2192
  ja: count,
2186
- Q: map,
2187
- d: [],
2188
- i: [],
2193
+ R: map,
2194
+ e: [],
2195
+ h: [],
2189
2196
  ka: options == null ? void 0 : options.from,
2190
2197
  V: options == null ? void 0 : options.fallback
2191
2198
  });
@@ -2198,13 +2205,13 @@ function updateRepeat() {
2198
2205
  if (newLen === 0) {
2199
2206
  if (this.o !== 0) {
2200
2207
  this.U.dispose(false);
2201
- this.d = [];
2202
- this.i = [];
2208
+ this.e = [];
2209
+ this.h = [];
2203
2210
  this.o = 0;
2204
2211
  }
2205
- if (this.V && !this.i[0]) {
2206
- this.i[0] = compute(
2207
- this.d[0] = new Owner(),
2212
+ if (this.V && !this.h[0]) {
2213
+ this.h[0] = compute(
2214
+ this.e[0] = new Owner(),
2208
2215
  this.V,
2209
2216
  null
2210
2217
  );
@@ -2212,46 +2219,46 @@ function updateRepeat() {
2212
2219
  return;
2213
2220
  }
2214
2221
  const to = from + newLen;
2215
- const prevTo = this.x + this.o;
2216
- if (this.o === 0 && this.d[0])
2217
- this.d[0].dispose();
2222
+ const prevTo = this.A + this.o;
2223
+ if (this.o === 0 && this.e[0])
2224
+ this.e[0].dispose();
2218
2225
  for (let i = to; i < prevTo; i++)
2219
- this.d[i - this.x].dispose();
2220
- if (this.x < from) {
2221
- let i = this.x;
2226
+ this.e[i - this.A].dispose();
2227
+ if (this.A < from) {
2228
+ let i = this.A;
2222
2229
  while (i < from && i < this.o)
2223
- this.d[i++].dispose();
2224
- this.d.splice(0, from - this.x);
2225
- this.i.splice(0, from - this.x);
2226
- } else if (this.x > from) {
2227
- let i = prevTo - this.x - 1;
2228
- let difference = this.x - from;
2229
- this.d.length = this.i.length = newLen;
2230
+ this.e[i++].dispose();
2231
+ this.e.splice(0, from - this.A);
2232
+ this.h.splice(0, from - this.A);
2233
+ } else if (this.A > from) {
2234
+ let i = prevTo - this.A - 1;
2235
+ let difference = this.A - from;
2236
+ this.e.length = this.h.length = newLen;
2230
2237
  while (i >= difference) {
2231
- this.d[i] = this.d[i - difference];
2232
- this.i[i] = this.i[i - difference];
2238
+ this.e[i] = this.e[i - difference];
2239
+ this.h[i] = this.h[i - difference];
2233
2240
  i--;
2234
2241
  }
2235
2242
  for (let i2 = 0; i2 < difference; i2++) {
2236
- this.i[i2] = compute(
2237
- this.d[i2] = new Owner(),
2238
- () => this.Q(i2 + from),
2243
+ this.h[i2] = compute(
2244
+ this.e[i2] = new Owner(),
2245
+ () => this.R(i2 + from),
2239
2246
  null
2240
2247
  );
2241
2248
  }
2242
2249
  }
2243
2250
  for (let i = prevTo; i < to; i++) {
2244
- this.i[i - from] = compute(
2245
- this.d[i - from] = new Owner(),
2246
- () => this.Q(i),
2251
+ this.h[i - from] = compute(
2252
+ this.e[i - from] = new Owner(),
2253
+ () => this.R(i),
2247
2254
  null
2248
2255
  );
2249
2256
  }
2250
- this.i = this.i.slice(0, newLen);
2251
- this.x = from;
2257
+ this.h = this.h.slice(0, newLen);
2258
+ this.A = from;
2252
2259
  this.o = newLen;
2253
2260
  });
2254
- return this.i;
2261
+ return this.h;
2255
2262
  }
2256
2263
  function compare(key, a, b) {
2257
2264
  return key ? key(a) === key(b) : true;
@@ -2266,7 +2273,7 @@ var BoundaryComputation = class extends EagerComputation {
2266
2273
  }
2267
2274
  write(value, flags) {
2268
2275
  super.write(value, flags & ~this.W);
2269
- if (this.W & LOADING_BIT && !(this.h & UNINITIALIZED_BIT || ActiveTransition)) {
2276
+ if (this.W & LOADING_BIT && !(this.i & UNINITIALIZED_BIT || ActiveTransition)) {
2270
2277
  flags &= ~LOADING_BIT;
2271
2278
  }
2272
2279
  getQueue(this).notify(this, this.W, flags);
@@ -2274,9 +2281,9 @@ var BoundaryComputation = class extends EagerComputation {
2274
2281
  }
2275
2282
  };
2276
2283
  function createBoundChildren(owner, fn, queue, mask) {
2277
- const parentQueue = owner.z;
2278
- parentQueue.addChild(owner.z = queue);
2279
- onCleanup(() => parentQueue.removeChild(owner.z));
2284
+ const parentQueue = owner.C;
2285
+ parentQueue.addChild(owner.C = queue);
2286
+ onCleanup(() => parentQueue.removeChild(owner.C));
2280
2287
  return compute(
2281
2288
  owner,
2282
2289
  () => {
@@ -2287,25 +2294,25 @@ function createBoundChildren(owner, fn, queue, mask) {
2287
2294
  );
2288
2295
  }
2289
2296
  var ConditionalQueue = class extends Queue {
2290
- s;
2297
+ x;
2291
2298
  X = /* @__PURE__ */ new Set();
2292
- r = /* @__PURE__ */ new Set();
2299
+ s = /* @__PURE__ */ new Set();
2293
2300
  constructor(disabled) {
2294
2301
  super();
2295
- this.s = disabled;
2302
+ this.x = disabled;
2296
2303
  }
2297
2304
  run(type) {
2298
- if (!type || this.s.read())
2305
+ if (!type || this.x.read())
2299
2306
  return;
2300
2307
  return super.run(type);
2301
2308
  }
2302
2309
  notify(node, type, flags) {
2303
- if (this.s.read()) {
2310
+ if (this.x.read()) {
2304
2311
  if (type & LOADING_BIT) {
2305
2312
  if (flags & LOADING_BIT) {
2306
- this.r.add(node);
2313
+ this.s.add(node);
2307
2314
  type &= ~LOADING_BIT;
2308
- } else if (this.r.delete(node))
2315
+ } else if (this.s.delete(node))
2309
2316
  type &= ~LOADING_BIT;
2310
2317
  }
2311
2318
  if (type & ERROR_BIT) {
@@ -2319,21 +2326,21 @@ var ConditionalQueue = class extends Queue {
2319
2326
  return type ? super.notify(node, type, flags) : true;
2320
2327
  }
2321
2328
  merge(queue) {
2322
- queue.r.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2329
+ queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2323
2330
  queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2324
2331
  super.merge(queue);
2325
2332
  }
2326
2333
  };
2327
2334
  var CollectionQueue = class extends Queue {
2328
2335
  K;
2329
- d = /* @__PURE__ */ new Set();
2330
- s = new Computation(false, null, { pureWrite: true });
2336
+ e = /* @__PURE__ */ new Set();
2337
+ x = new Computation(false, null, { pureWrite: true });
2331
2338
  constructor(type) {
2332
2339
  super();
2333
2340
  this.K = type;
2334
2341
  }
2335
2342
  run(type) {
2336
- if (!type || this.s.read())
2343
+ if (!type || this.x.read())
2337
2344
  return;
2338
2345
  return super.run(type);
2339
2346
  }
@@ -2341,19 +2348,19 @@ var CollectionQueue = class extends Queue {
2341
2348
  if (!(type & this.K))
2342
2349
  return super.notify(node, type, flags);
2343
2350
  if (flags & this.K) {
2344
- this.d.add(node);
2345
- if (this.d.size === 1)
2346
- this.s.write(true);
2347
- } else if (this.d.size > 0) {
2348
- this.d.delete(node);
2349
- if (this.d.size === 0)
2350
- this.s.write(false);
2351
+ this.e.add(node);
2352
+ if (this.e.size === 1)
2353
+ this.x.write(true);
2354
+ } else if (this.e.size > 0) {
2355
+ this.e.delete(node);
2356
+ if (this.e.size === 0)
2357
+ this.x.write(false);
2351
2358
  }
2352
2359
  type &= ~this.K;
2353
2360
  return type ? super.notify(node, type, flags) : true;
2354
2361
  }
2355
2362
  merge(queue) {
2356
- queue.d.forEach((n) => this.notify(n, this.K, this.K));
2363
+ queue.e.forEach((n) => this.notify(n, this.K, this.K));
2357
2364
  super.merge(queue);
2358
2365
  }
2359
2366
  };
@@ -2364,25 +2371,25 @@ function createBoundary(fn, condition) {
2364
2371
  );
2365
2372
  const tree = createBoundChildren(owner, fn, queue, 0);
2366
2373
  new EagerComputation(void 0, () => {
2367
- const disabled = queue.s.read();
2374
+ const disabled = queue.x.read();
2368
2375
  tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
2369
2376
  if (!disabled) {
2370
- queue.r.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2377
+ queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2371
2378
  queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2372
- queue.r.clear();
2379
+ queue.s.clear();
2373
2380
  queue.X.clear();
2374
2381
  }
2375
2382
  });
2376
- return () => queue.s.read() ? void 0 : tree.read();
2383
+ return () => queue.x.read() ? void 0 : tree.read();
2377
2384
  }
2378
2385
  function createCollectionBoundary(type, fn, fallback) {
2379
2386
  const owner = new Owner();
2380
2387
  const queue = new CollectionQueue(type);
2381
2388
  const tree = createBoundChildren(owner, fn, queue, type);
2382
2389
  const decision = new Computation(void 0, () => {
2383
- if (!queue.s.read()) {
2390
+ if (!queue.x.read()) {
2384
2391
  const resolved = tree.read();
2385
- if (!untrack(() => queue.s.read()))
2392
+ if (!untrack(() => queue.x.read()))
2386
2393
  return resolved;
2387
2394
  }
2388
2395
  return fallback(queue);
@@ -2394,14 +2401,14 @@ function createSuspense(fn, fallback) {
2394
2401
  }
2395
2402
  function createErrorBoundary(fn, fallback) {
2396
2403
  return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2397
- let node = getTransitionSource(queue.d.values().next().value);
2398
- return fallback(node.M, () => {
2404
+ let node = getTransitionSource(queue.e.values().next().value);
2405
+ return fallback(node.O, () => {
2399
2406
  incrementClock();
2400
- for (let node2 of queue.d) {
2401
- if (ActiveTransition && !node2.e)
2407
+ for (let node2 of queue.e) {
2408
+ if (ActiveTransition && !node2.d)
2402
2409
  node2 = cloneGraph(node2);
2403
- node2.c = STATE_DIRTY;
2404
- getQueue(node2).enqueue(node2.A, node2.E.bind(node2));
2410
+ node2.b = STATE_DIRTY;
2411
+ getQueue(node2).enqueue(node2.r, node2.w.bind(node2));
2405
2412
  }
2406
2413
  });
2407
2414
  });
@@ -2478,12 +2485,15 @@ exports.createEffect = createEffect;
2478
2485
  exports.createErrorBoundary = createErrorBoundary;
2479
2486
  exports.createMemo = createMemo;
2480
2487
  exports.createOptimistic = createOptimistic;
2488
+ exports.createOptimisticStore = createOptimisticStore;
2481
2489
  exports.createProjection = createProjection;
2490
+ exports.createReaction = createReaction;
2482
2491
  exports.createRenderEffect = createRenderEffect;
2483
2492
  exports.createRoot = createRoot;
2484
2493
  exports.createSignal = createSignal;
2485
2494
  exports.createStore = createStore;
2486
2495
  exports.createSuspense = createSuspense;
2496
+ exports.createTrackedEffect = createTrackedEffect;
2487
2497
  exports.deep = deep;
2488
2498
  exports.flatten = flatten;
2489
2499
  exports.flush = flush;
@@ -2503,7 +2513,6 @@ exports.onCleanup = onCleanup;
2503
2513
  exports.reconcile = reconcile;
2504
2514
  exports.repeat = repeat;
2505
2515
  exports.resolve = resolve;
2506
- exports.runWithObserver = runWithObserver;
2507
2516
  exports.runWithOwner = runWithOwner;
2508
2517
  exports.setContext = setContext;
2509
2518
  exports.snapshot = snapshot;