@solidjs/signals 0.1.0 → 0.2.1

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
@@ -45,11 +45,11 @@ function schedule() {
45
45
  if (scheduled)
46
46
  return;
47
47
  scheduled = true;
48
- if (!globalQueue.H)
48
+ if (!globalQueue.I)
49
49
  queueMicrotask(flushSync);
50
50
  }
51
51
  var Queue = class {
52
- H = false;
52
+ I = false;
53
53
  r = [[], [], []];
54
54
  D = [];
55
55
  created = clock;
@@ -78,9 +78,9 @@ var Queue = class {
78
78
  return true;
79
79
  }
80
80
  flush() {
81
- if (this.H)
81
+ if (this.I)
82
82
  return;
83
- this.H = true;
83
+ this.I = true;
84
84
  try {
85
85
  while (this.run(EFFECT_PURE)) {
86
86
  }
@@ -89,7 +89,7 @@ var Queue = class {
89
89
  this.run(EFFECT_RENDER);
90
90
  this.run(EFFECT_USER);
91
91
  } finally {
92
- this.H = false;
92
+ this.I = false;
93
93
  }
94
94
  }
95
95
  addChild(child) {
@@ -238,19 +238,19 @@ var Owner = class {
238
238
  let head = self ? this.t || this.s : this, current = this.n, next = null;
239
239
  while (current && current.s === this) {
240
240
  current.dispose(true);
241
- current.A();
241
+ current.z();
242
242
  next = current.n;
243
243
  current.n = null;
244
244
  current = next;
245
245
  }
246
246
  if (self)
247
- this.A();
247
+ this.z();
248
248
  if (current)
249
249
  current.t = !self ? this : this.t;
250
250
  if (head)
251
251
  head.n = current;
252
252
  }
253
- A() {
253
+ z() {
254
254
  if (this.t)
255
255
  this.t.n = null;
256
256
  this.s = null;
@@ -351,11 +351,11 @@ function getObserver() {
351
351
  }
352
352
  var UNCHANGED = Symbol(0);
353
353
  var Computation = class extends Owner {
354
- f = null;
355
- d = null;
356
- b;
354
+ b = null;
355
+ c = null;
356
+ e;
357
357
  E;
358
- u;
358
+ A;
359
359
  // Used in __DEV__ mode, hopefully removed in production
360
360
  Z;
361
361
  // Using false is an optimization as an alternative to _equals: () => false
@@ -363,18 +363,18 @@ var Computation = class extends Owner {
363
363
  N = isEqual;
364
364
  U;
365
365
  /** Whether the computation is an error or has ancestors that are unresolved */
366
- c = 0;
366
+ d = 0;
367
367
  /** Which flags raised by sources are handled, vs. being passed through. */
368
368
  O = DEFAULT_FLAGS;
369
369
  P = null;
370
- z = -1;
371
- I = false;
370
+ x = -1;
371
+ J = false;
372
372
  constructor(initialValue, compute2, options) {
373
373
  super(compute2 === null);
374
- this.u = compute2;
374
+ this.A = compute2;
375
375
  this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
376
- this.c = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
377
- this.b = initialValue;
376
+ this.d = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
377
+ this.e = initialValue;
378
378
  if ((options == null ? void 0 : options.equals) !== void 0)
379
379
  this.N = options.equals;
380
380
  if (options == null ? void 0 : options.unobserved)
@@ -382,19 +382,19 @@ var Computation = class extends Owner {
382
382
  }
383
383
  V() {
384
384
  var _a;
385
- if (this.u) {
386
- if (this.c & ERROR_BIT && this.z <= getClock())
385
+ if (this.A) {
386
+ if (this.d & ERROR_BIT && this.x <= getClock())
387
387
  update(this);
388
388
  else
389
389
  this.y();
390
390
  }
391
- if (!this.u || ((_a = this.f) == null ? void 0 : _a.length))
391
+ if (!this.A || ((_a = this.b) == null ? void 0 : _a.length))
392
392
  track(this);
393
- newFlags |= this.c & ~currentMask;
394
- if (this.c & ERROR_BIT) {
393
+ newFlags |= this.d & ~currentMask;
394
+ if (this.d & ERROR_BIT) {
395
395
  throw this.E;
396
396
  } else {
397
- return this.b;
397
+ return this.e;
398
398
  }
399
399
  }
400
400
  /**
@@ -412,14 +412,14 @@ var Computation = class extends Owner {
412
412
  * before continuing
413
413
  */
414
414
  wait() {
415
- if (this.u && this.c & ERROR_BIT && this.z <= getClock()) {
415
+ if (this.A && this.d & ERROR_BIT && this.x <= getClock()) {
416
416
  update(this);
417
417
  }
418
- if ((notStale || this.c & UNINITIALIZED_BIT) && this.loading()) {
418
+ if ((notStale || this.d & UNINITIALIZED_BIT) && this.loading()) {
419
419
  throw new NotReadyError();
420
420
  }
421
421
  if (staleCheck && this.loading())
422
- staleCheck.b = true;
422
+ staleCheck.e = true;
423
423
  return this.V();
424
424
  }
425
425
  /**
@@ -437,37 +437,37 @@ var Computation = class extends Owner {
437
437
  }
438
438
  /** Update the computation with a new value. */
439
439
  write(value, flags = 0, raw = false) {
440
- const newValue = !raw && typeof value === "function" ? value(this.b) : value;
441
- const valueChanged = newValue !== UNCHANGED && (!!(this.c & UNINITIALIZED_BIT) || this.N === false || !this.N(this.b, newValue));
440
+ const newValue = !raw && typeof value === "function" ? value(this.e) : value;
441
+ const valueChanged = newValue !== UNCHANGED && (!!(this.d & UNINITIALIZED_BIT) || this.N === false || !this.N(this.e, newValue));
442
442
  if (valueChanged) {
443
- this.b = newValue;
443
+ this.e = newValue;
444
444
  this.E = void 0;
445
445
  }
446
- const changedFlagsMask = this.c ^ flags, changedFlags = changedFlagsMask & flags;
447
- this.c = flags;
448
- this.z = getClock() + 1;
449
- if (this.d) {
450
- for (let i = 0; i < this.d.length; i++) {
446
+ const changedFlagsMask = this.d ^ flags, changedFlags = changedFlagsMask & flags;
447
+ this.d = flags;
448
+ this.x = getClock() + 1;
449
+ if (this.c) {
450
+ for (let i = 0; i < this.c.length; i++) {
451
451
  if (valueChanged) {
452
- this.d[i].q(STATE_DIRTY);
452
+ this.c[i].q(STATE_DIRTY);
453
453
  } else if (changedFlagsMask) {
454
- this.d[i].W(changedFlagsMask, changedFlags);
454
+ this.c[i].W(changedFlagsMask, changedFlags);
455
455
  }
456
456
  }
457
457
  }
458
- return this.b;
458
+ return this.e;
459
459
  }
460
460
  /**
461
461
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
462
462
  */
463
463
  q(state, skipQueue) {
464
- if (this.a >= state && !this.I)
464
+ if (this.a >= state && !this.J)
465
465
  return;
466
- this.I = !!skipQueue;
466
+ this.J = !!skipQueue;
467
467
  this.a = state;
468
- if (this.d) {
469
- for (let i = 0; i < this.d.length; i++) {
470
- this.d[i].q(STATE_CHECK, skipQueue);
468
+ if (this.c) {
469
+ for (let i = 0; i < this.c.length; i++) {
470
+ this.c[i].q(STATE_CHECK, skipQueue);
471
471
  }
472
472
  }
473
473
  }
@@ -486,22 +486,22 @@ var Computation = class extends Owner {
486
486
  }
487
487
  if (this.a >= STATE_CHECK)
488
488
  return;
489
- const prevFlags = this.c & mask;
489
+ const prevFlags = this.d & mask;
490
490
  const deltaFlags = prevFlags ^ newFlags2;
491
491
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
492
492
  this.q(STATE_CHECK);
493
493
  } else {
494
- this.c ^= deltaFlags;
495
- if (this.d) {
496
- for (let i = 0; i < this.d.length; i++) {
497
- this.d[i].W(mask, newFlags2);
494
+ this.d ^= deltaFlags;
495
+ if (this.c) {
496
+ for (let i = 0; i < this.c.length; i++) {
497
+ this.c[i].W(mask, newFlags2);
498
498
  }
499
499
  }
500
500
  }
501
501
  }
502
- J(error) {
502
+ F(error) {
503
503
  this.E = error;
504
- this.write(UNCHANGED, this.c & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
504
+ this.write(UNCHANGED, this.d & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
505
505
  }
506
506
  /**
507
507
  * This is the core part of the reactivity system, which makes sure that the values are updated
@@ -519,9 +519,9 @@ var Computation = class extends Owner {
519
519
  }
520
520
  let observerFlags = 0;
521
521
  if (this.a === STATE_CHECK) {
522
- for (let i = 0; i < this.f.length; i++) {
523
- this.f[i].y();
524
- observerFlags |= this.f[i].c;
522
+ for (let i = 0; i < this.b.length; i++) {
523
+ this.b[i].y();
524
+ observerFlags |= this.b[i].d;
525
525
  if (this.a === STATE_DIRTY) {
526
526
  break;
527
527
  }
@@ -537,12 +537,12 @@ var Computation = class extends Owner {
537
537
  /**
538
538
  * Remove ourselves from the owner graph and the computation graph
539
539
  */
540
- A() {
540
+ z() {
541
541
  if (this.a === STATE_DISPOSED)
542
542
  return;
543
- if (this.f)
543
+ if (this.b)
544
544
  removeSourceObservers(this, 0);
545
- super.A();
545
+ super.z();
546
546
  }
547
547
  };
548
548
  function loadingState(node) {
@@ -553,7 +553,7 @@ function loadingState(node) {
553
553
  () => {
554
554
  track(node);
555
555
  node.y();
556
- return !!(node.c & LOADING_BIT);
556
+ return !!(node.d & LOADING_BIT);
557
557
  },
558
558
  options
559
559
  );
@@ -563,7 +563,7 @@ function loadingState(node) {
563
563
  }
564
564
  function track(computation) {
565
565
  if (currentObserver) {
566
- if (!newSources && currentObserver.f && currentObserver.f[newSourcesIndex] === computation) {
566
+ if (!newSources && currentObserver.b && currentObserver.b[newSourcesIndex] === computation) {
567
567
  newSourcesIndex++;
568
568
  } else if (!newSources)
569
569
  newSources = [computation];
@@ -571,7 +571,7 @@ function track(computation) {
571
571
  newSources.push(computation);
572
572
  }
573
573
  if (updateCheck) {
574
- updateCheck.b = computation.z > currentObserver.z;
574
+ updateCheck.e = computation.x > currentObserver.x;
575
575
  }
576
576
  }
577
577
  }
@@ -583,42 +583,42 @@ function update(node) {
583
583
  try {
584
584
  node.dispose(false);
585
585
  node.emptyDisposal();
586
- const result = compute(node, node.u, node);
586
+ const result = compute(node, node.A, node);
587
587
  node.write(result, newFlags, true);
588
588
  } catch (error) {
589
589
  if (error instanceof NotReadyError) {
590
- node.write(UNCHANGED, newFlags | LOADING_BIT | node.c & UNINITIALIZED_BIT);
590
+ node.write(UNCHANGED, newFlags | LOADING_BIT | node.d & UNINITIALIZED_BIT);
591
591
  } else {
592
- node.J(error);
592
+ node.F(error);
593
593
  }
594
594
  } finally {
595
595
  if (newSources) {
596
- if (node.f)
596
+ if (node.b)
597
597
  removeSourceObservers(node, newSourcesIndex);
598
- if (node.f && newSourcesIndex > 0) {
599
- node.f.length = newSourcesIndex + newSources.length;
598
+ if (node.b && newSourcesIndex > 0) {
599
+ node.b.length = newSourcesIndex + newSources.length;
600
600
  for (let i = 0; i < newSources.length; i++) {
601
- node.f[newSourcesIndex + i] = newSources[i];
601
+ node.b[newSourcesIndex + i] = newSources[i];
602
602
  }
603
603
  } else {
604
- node.f = newSources;
604
+ node.b = newSources;
605
605
  }
606
606
  let source;
607
- for (let i = newSourcesIndex; i < node.f.length; i++) {
608
- source = node.f[i];
609
- if (!source.d)
610
- source.d = [node];
607
+ for (let i = newSourcesIndex; i < node.b.length; i++) {
608
+ source = node.b[i];
609
+ if (!source.c)
610
+ source.c = [node];
611
611
  else
612
- source.d.push(node);
612
+ source.c.push(node);
613
613
  }
614
- } else if (node.f && newSourcesIndex < node.f.length) {
614
+ } else if (node.b && newSourcesIndex < node.b.length) {
615
615
  removeSourceObservers(node, newSourcesIndex);
616
- node.f.length = newSourcesIndex;
616
+ node.b.length = newSourcesIndex;
617
617
  }
618
618
  newSources = prevSources;
619
619
  newSourcesIndex = prevSourcesIndex;
620
620
  newFlags = prevFlags;
621
- node.z = getClock() + 1;
621
+ node.x = getClock() + 1;
622
622
  node.a = STATE_CLEAN;
623
623
  }
624
624
  }
@@ -626,13 +626,13 @@ function removeSourceObservers(node, index) {
626
626
  var _a;
627
627
  let source;
628
628
  let swap;
629
- for (let i = index; i < node.f.length; i++) {
630
- source = node.f[i];
631
- if (source.d) {
632
- swap = source.d.indexOf(node);
633
- source.d[swap] = source.d[source.d.length - 1];
634
- source.d.pop();
635
- if (!source.d.length)
629
+ for (let i = index; i < node.b.length; i++) {
630
+ source = node.b[i];
631
+ if (source.c) {
632
+ swap = source.c.indexOf(node);
633
+ source.c[swap] = source.c[source.c.length - 1];
634
+ source.c.pop();
635
+ if (!source.c.length)
636
636
  (_a = source.U) == null ? void 0 : _a.call(source);
637
637
  }
638
638
  }
@@ -647,32 +647,40 @@ function untrack(fn) {
647
647
  }
648
648
  function hasUpdated(fn) {
649
649
  const current = updateCheck;
650
- updateCheck = { b: false };
650
+ updateCheck = { e: false };
651
651
  try {
652
652
  fn();
653
- return updateCheck.b;
653
+ return updateCheck.e;
654
654
  } finally {
655
655
  updateCheck = current;
656
656
  }
657
657
  }
658
- function isStale(fn) {
658
+ function isPending(fn, loadingValue) {
659
+ const argLength = arguments.length;
659
660
  const current = staleCheck;
660
- staleCheck = { b: false };
661
+ staleCheck = { e: false };
661
662
  try {
662
663
  latest(fn);
663
- return staleCheck.b;
664
- } catch {
664
+ return staleCheck.e;
665
+ } catch (err) {
666
+ if (argLength > 1 && err instanceof NotReadyError)
667
+ return !!loadingValue;
668
+ throw err;
665
669
  } finally {
666
670
  staleCheck = current;
667
671
  }
668
- return false;
669
672
  }
670
- function latest(fn) {
673
+ function latest(fn, fallback) {
674
+ const argLength = arguments.length;
671
675
  const prevFlags = newFlags;
672
676
  const prevNotStale = notStale;
673
677
  notStale = false;
674
678
  try {
675
679
  return fn();
680
+ } catch (err) {
681
+ if (argLength > 1 && err instanceof NotReadyError)
682
+ return fallback;
683
+ throw err;
676
684
  } finally {
677
685
  newFlags = prevFlags;
678
686
  notStale = prevNotStale;
@@ -687,13 +695,53 @@ function catchError(fn) {
687
695
  return e;
688
696
  }
689
697
  }
698
+ function runWithObserver(observer, run) {
699
+ const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
700
+ newSources = null;
701
+ newSourcesIndex = observer.b ? observer.b.length : 0;
702
+ newFlags = 0;
703
+ try {
704
+ return compute(observer, run, observer);
705
+ } catch (error) {
706
+ if (error instanceof NotReadyError) {
707
+ observer.write(
708
+ UNCHANGED,
709
+ newFlags | LOADING_BIT | observer.d & UNINITIALIZED_BIT
710
+ );
711
+ } else {
712
+ observer.F(error);
713
+ }
714
+ } finally {
715
+ if (newSources) {
716
+ if (newSourcesIndex > 0) {
717
+ observer.b.length = newSourcesIndex + newSources.length;
718
+ for (let i = 0; i < newSources.length; i++) {
719
+ observer.b[newSourcesIndex + i] = newSources[i];
720
+ }
721
+ } else {
722
+ observer.b = newSources;
723
+ }
724
+ let source;
725
+ for (let i = newSourcesIndex; i < observer.b.length; i++) {
726
+ source = observer.b[i];
727
+ if (!source.c)
728
+ source.c = [observer];
729
+ else
730
+ source.c.push(observer);
731
+ }
732
+ }
733
+ newSources = prevSources;
734
+ newSourcesIndex = prevSourcesIndex;
735
+ newFlags = prevFlags;
736
+ }
737
+ }
690
738
  function compute(owner, fn, observer) {
691
739
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
692
740
  currentObserver = observer;
693
741
  currentMask = (observer == null ? void 0 : observer.O) ?? DEFAULT_FLAGS;
694
742
  notStale = true;
695
743
  try {
696
- return fn(observer ? observer.b : void 0);
744
+ return fn(observer ? observer.e : void 0);
697
745
  } finally {
698
746
  setOwner(prevOwner);
699
747
  currentObserver = prevObserver;
@@ -716,33 +764,31 @@ var Effect = class extends Computation {
716
764
  B;
717
765
  Q = false;
718
766
  M;
719
- w;
767
+ u;
720
768
  constructor(initialValue, compute2, effect, error, options) {
721
769
  super(initialValue, compute2, options);
722
770
  this.K = effect;
723
771
  this.L = error;
724
772
  this.M = initialValue;
725
- this.w = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
726
- if (this.w === EFFECT_RENDER) {
727
- this.u = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
728
- }
729
- if (!(options == null ? void 0 : options.defer)) {
730
- this.y();
731
- this.w === EFFECT_USER ? this.h.enqueue(this.w, this) : this.T();
773
+ this.u = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
774
+ if (this.u === EFFECT_RENDER) {
775
+ this.A = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
732
776
  }
777
+ this.y();
778
+ !(options == null ? void 0 : options.defer) && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.T());
733
779
  }
734
780
  write(value, flags = 0) {
735
781
  var _a, _b;
736
782
  if (this.a == STATE_DIRTY) {
737
- const currentFlags = this.c;
738
- this.c = flags;
739
- if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
783
+ const currentFlags = this.d;
784
+ this.d = flags;
785
+ if (this.u === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
740
786
  (_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
741
787
  }
742
788
  }
743
789
  if (value === UNCHANGED)
744
- return this.b;
745
- this.b = value;
790
+ return this.e;
791
+ this.e = value;
746
792
  this.Q = true;
747
793
  return value;
748
794
  }
@@ -750,17 +796,17 @@ var Effect = class extends Computation {
750
796
  if (this.a >= state || skipQueue)
751
797
  return;
752
798
  if (this.a === STATE_CLEAN)
753
- this.h.enqueue(this.w, this);
799
+ this.h.enqueue(this.u, this);
754
800
  this.a = state;
755
801
  }
756
- J(error) {
802
+ F(error) {
757
803
  var _a, _b, _c;
758
804
  (_a = this.B) == null ? void 0 : _a.call(this);
759
- if (this.c & LOADING_BIT) {
760
- this.c = 0;
805
+ if (this.d & LOADING_BIT) {
806
+ this.d = 0;
761
807
  (_c = (_b = this.h).R) == null ? void 0 : _c.call(_b, this);
762
808
  }
763
- if (this.w === EFFECT_USER) {
809
+ if (this.u === EFFECT_USER) {
764
810
  try {
765
811
  return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
766
812
  } catch (e) {
@@ -769,7 +815,7 @@ var Effect = class extends Computation {
769
815
  }
770
816
  this.handleError(error);
771
817
  }
772
- A() {
818
+ z() {
773
819
  var _a;
774
820
  if (this.a === STATE_DISPOSED)
775
821
  return;
@@ -778,18 +824,18 @@ var Effect = class extends Computation {
778
824
  this.L = void 0;
779
825
  (_a = this.B) == null ? void 0 : _a.call(this);
780
826
  this.B = void 0;
781
- super.A();
827
+ super.z();
782
828
  }
783
829
  T() {
784
830
  var _a;
785
831
  if (this.Q && this.a !== STATE_DISPOSED) {
786
832
  (_a = this.B) == null ? void 0 : _a.call(this);
787
833
  try {
788
- this.B = this.K(this.b, this.M);
834
+ this.B = this.K(this.e, this.M);
789
835
  } catch (e) {
790
836
  this.handleError(e);
791
837
  } finally {
792
- this.M = this.b;
838
+ this.M = this.e;
793
839
  this.Q = false;
794
840
  }
795
841
  }
@@ -801,7 +847,7 @@ var EagerComputation = class extends Computation {
801
847
  !(options == null ? void 0 : options.defer) && this.y();
802
848
  }
803
849
  q(state, skipQueue) {
804
- if (this.a >= state && !this.I)
850
+ if (this.a >= state && !this.J)
805
851
  return;
806
852
  if (this.a === STATE_CLEAN && !skipQueue)
807
853
  this.h.enqueue(EFFECT_PURE, this);
@@ -813,7 +859,7 @@ var ProjectionComputation = class extends Computation {
813
859
  super(null, compute2);
814
860
  }
815
861
  q(state, skipQueue) {
816
- if (this.a >= state && !this.I)
862
+ if (this.a >= state && !this.J)
817
863
  return;
818
864
  if (this.a === STATE_CLEAN && !skipQueue)
819
865
  this.h.enqueue(EFFECT_PURE, this);
@@ -823,7 +869,7 @@ var ProjectionComputation = class extends Computation {
823
869
 
824
870
  // src/core/suspense.ts
825
871
  var SuspenseQueue = class extends Queue {
826
- e = /* @__PURE__ */ new Set();
872
+ f = /* @__PURE__ */ new Set();
827
873
  o = false;
828
874
  S = new Computation(false, null);
829
875
  run(type) {
@@ -832,15 +878,15 @@ var SuspenseQueue = class extends Queue {
832
878
  return super.run(type);
833
879
  }
834
880
  R(node) {
835
- if (node.c & LOADING_BIT) {
836
- this.e.add(node);
881
+ if (node.d & LOADING_BIT) {
882
+ this.f.add(node);
837
883
  if (!this.o) {
838
884
  this.o = true;
839
885
  this.S.write(true);
840
886
  }
841
887
  } else {
842
- this.e.delete(node);
843
- if (this.e.size === 0) {
888
+ this.f.delete(node);
889
+ if (this.f.size === 0) {
844
890
  this.o = false;
845
891
  this.S.write(false);
846
892
  }
@@ -850,13 +896,13 @@ var SuspenseQueue = class extends Queue {
850
896
  var LiveComputation = class extends EagerComputation {
851
897
  write(value, flags = 0) {
852
898
  var _a, _b;
853
- const currentFlags = this.c;
899
+ const currentFlags = this.d;
854
900
  const dirty = this.a === STATE_DIRTY;
855
901
  super.write(value, flags);
856
902
  if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
857
903
  (_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
858
904
  }
859
- return this.b;
905
+ return this.e;
860
906
  }
861
907
  };
862
908
  function createSuspense(fn, fallback) {
@@ -897,10 +943,10 @@ function createMemo(compute2, value, options) {
897
943
  var _a, _b, _c;
898
944
  if (node) {
899
945
  resolvedValue = node.wait();
900
- if (!((_a = node.f) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.s) !== node) {
946
+ if (!((_a = node.b) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.s) !== node) {
901
947
  node.dispose();
902
948
  node = void 0;
903
- } else if (!node.s && !((_c = node.d) == null ? void 0 : _c.length)) {
949
+ } else if (!node.s && !((_c = node.c) == null ? void 0 : _c.length)) {
904
950
  node.dispose();
905
951
  node.a = STATE_DIRTY;
906
952
  }
@@ -912,10 +958,10 @@ function createAsync(compute2, value, options) {
912
958
  let uninitialized = value === void 0;
913
959
  const lhs = new EagerComputation(
914
960
  {
915
- b: value
961
+ e: value
916
962
  },
917
963
  (p) => {
918
- const value2 = p == null ? void 0 : p.b;
964
+ const value2 = p == null ? void 0 : p.e;
919
965
  const source = compute2(value2);
920
966
  const isPromise = source instanceof Promise;
921
967
  const iterator = source[Symbol.asyncIterator];
@@ -924,13 +970,13 @@ function createAsync(compute2, value, options) {
924
970
  wait() {
925
971
  return source;
926
972
  },
927
- b: source
973
+ e: source
928
974
  };
929
975
  }
930
976
  const signal = new Computation(value2, null, options);
931
977
  const w = signal.wait;
932
978
  signal.wait = function() {
933
- if (signal.c & ERROR_BIT && signal.z <= getClock()) {
979
+ if (signal.d & ERROR_BIT && signal.x <= getClock()) {
934
980
  lhs.q(STATE_DIRTY);
935
981
  throw new NotReadyError();
936
982
  }
@@ -945,7 +991,7 @@ function createAsync(compute2, value, options) {
945
991
  },
946
992
  (error) => {
947
993
  uninitialized = true;
948
- signal.J(error);
994
+ signal.F(error);
949
995
  }
950
996
  );
951
997
  } else {
@@ -974,13 +1020,13 @@ function createEffect(compute2, effect, error, value, options) {
974
1020
  compute2,
975
1021
  effect,
976
1022
  error,
977
- void 0
1023
+ options
978
1024
  );
979
1025
  }
980
1026
  function createRenderEffect(compute2, effect, value, options) {
981
1027
  void new Effect(value, compute2, effect, void 0, {
982
1028
  render: true,
983
- ...void 0
1029
+ ...options
984
1030
  });
985
1031
  }
986
1032
  function createRoot(init) {
@@ -988,12 +1034,7 @@ function createRoot(init) {
988
1034
  return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
989
1035
  }
990
1036
  function runWithOwner(owner, run) {
991
- try {
992
- return compute(owner, run, null);
993
- } catch (error) {
994
- owner == null ? void 0 : owner.handleError(error);
995
- return void 0;
996
- }
1037
+ return compute(owner, run, null);
997
1038
  }
998
1039
  function createErrorBoundary(fn, fallback) {
999
1040
  const owner = new Owner();
@@ -1021,7 +1062,7 @@ function createErrorBoundary(fn, fallback) {
1021
1062
  () => {
1022
1063
  const c = new Computation(void 0, fn);
1023
1064
  const f = new EagerComputation(void 0, () => flatten(c.read()), { defer: true });
1024
- f.J = function(error2) {
1065
+ f.F = function(error2) {
1025
1066
  this.handleError(error2);
1026
1067
  };
1027
1068
  return f;
@@ -1039,7 +1080,7 @@ function createErrorBoundary(fn, fallback) {
1039
1080
  incrementClock();
1040
1081
  for (let node of nodes) {
1041
1082
  node.a = STATE_DIRTY;
1042
- (_a = node.h) == null ? void 0 : _a.enqueue(node.w, node);
1083
+ (_a = node.h) == null ? void 0 : _a.enqueue(node.u, node);
1043
1084
  }
1044
1085
  });
1045
1086
  });
@@ -1061,19 +1102,6 @@ function resolve(fn) {
1061
1102
  });
1062
1103
  });
1063
1104
  }
1064
- function createReaction(effect, error, options) {
1065
- const node = new Effect(void 0, () => {
1066
- }, effect, error, {
1067
- defer: true,
1068
- ...void 0
1069
- });
1070
- return (tracking) => {
1071
- node.u = tracking;
1072
- node.a = STATE_DIRTY;
1073
- node.y();
1074
- node.u = null;
1075
- };
1076
- }
1077
1105
 
1078
1106
  // src/store/projection.ts
1079
1107
  function createProjection(fn, initialValue = {}) {
@@ -1220,7 +1248,7 @@ var proxyTraps = {
1220
1248
  return desc.get.call(receiver);
1221
1249
  }
1222
1250
  if (Writing.has(storeValue)) {
1223
- const value2 = tracked ? tracked.b : storeValue[property];
1251
+ const value2 = tracked ? tracked.e : storeValue[property];
1224
1252
  return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
1225
1253
  }
1226
1254
  let value = tracked ? nodes[property].read() : storeValue[property];
@@ -1561,13 +1589,13 @@ function omit(props, ...keys) {
1561
1589
  function mapArray(list, map, options) {
1562
1590
  const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
1563
1591
  return updateKeyedMap.bind({
1564
- F: new Owner(),
1592
+ G: new Owner(),
1565
1593
  i: 0,
1566
1594
  X: list,
1567
- x: [],
1568
- G: map,
1595
+ w: [],
1596
+ H: map,
1569
1597
  g: [],
1570
- e: [],
1598
+ f: [],
1571
1599
  C: keyFn,
1572
1600
  j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
1573
1601
  k: map.length > 1 ? [] : void 0,
@@ -1577,27 +1605,27 @@ function mapArray(list, map, options) {
1577
1605
  function updateKeyedMap() {
1578
1606
  const newItems = this.X() || [], newLen = newItems.length;
1579
1607
  newItems[$TRACK];
1580
- runWithOwner(this.F, () => {
1608
+ runWithOwner(this.G, () => {
1581
1609
  let i, j, mapper = this.j ? () => {
1582
1610
  this.j[j] = new Computation(newItems[j], null);
1583
1611
  this.k && (this.k[j] = new Computation(j, null));
1584
- return this.G(
1612
+ return this.H(
1585
1613
  Computation.prototype.read.bind(this.j[j]),
1586
1614
  this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
1587
1615
  );
1588
1616
  } : this.k ? () => {
1589
1617
  const item = newItems[j];
1590
1618
  this.k[j] = new Computation(j, null);
1591
- return this.G(() => item, Computation.prototype.read.bind(this.k[j]));
1619
+ return this.H(() => item, Computation.prototype.read.bind(this.k[j]));
1592
1620
  } : () => {
1593
1621
  const item = newItems[j];
1594
- return this.G(() => item);
1622
+ return this.H(() => item);
1595
1623
  };
1596
1624
  if (newLen === 0) {
1597
1625
  if (this.i !== 0) {
1598
- this.F.dispose(false);
1599
- this.e = [];
1600
- this.x = [];
1626
+ this.G.dispose(false);
1627
+ this.f = [];
1628
+ this.w = [];
1601
1629
  this.g = [];
1602
1630
  this.i = 0;
1603
1631
  this.j && (this.j = []);
@@ -1605,29 +1633,29 @@ function updateKeyedMap() {
1605
1633
  }
1606
1634
  if (this.o && !this.g[0]) {
1607
1635
  this.g[0] = compute(
1608
- this.e[0] = new Owner(),
1636
+ this.f[0] = new Owner(),
1609
1637
  this.o,
1610
1638
  null
1611
1639
  );
1612
1640
  }
1613
1641
  } else if (this.i === 0) {
1614
- if (this.e[0])
1615
- this.e[0].dispose();
1642
+ if (this.f[0])
1643
+ this.f[0].dispose();
1616
1644
  this.g = new Array(newLen);
1617
1645
  for (j = 0; j < newLen; j++) {
1618
- this.x[j] = newItems[j];
1619
- this.g[j] = compute(this.e[j] = new Owner(), mapper, null);
1646
+ this.w[j] = newItems[j];
1647
+ this.g[j] = compute(this.f[j] = new Owner(), mapper, null);
1620
1648
  }
1621
1649
  this.i = newLen;
1622
1650
  } else {
1623
1651
  let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.j ? new Array(newLen) : void 0, tempIndexes = this.k ? new Array(newLen) : void 0;
1624
- for (start = 0, end = Math.min(this.i, newLen); start < end && (this.x[start] === newItems[start] || this.j && compare(this.C, this.x[start], newItems[start])); start++) {
1652
+ for (start = 0, end = Math.min(this.i, newLen); start < end && (this.w[start] === newItems[start] || this.j && compare(this.C, this.w[start], newItems[start])); start++) {
1625
1653
  if (this.j)
1626
1654
  this.j[start].write(newItems[start]);
1627
1655
  }
1628
- for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.x[end] === newItems[newEnd] || this.j && compare(this.C, this.x[end], newItems[newEnd])); end--, newEnd--) {
1656
+ for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.w[end] === newItems[newEnd] || this.j && compare(this.C, this.w[end], newItems[newEnd])); end--, newEnd--) {
1629
1657
  temp[newEnd] = this.g[end];
1630
- tempNodes[newEnd] = this.e[end];
1658
+ tempNodes[newEnd] = this.f[end];
1631
1659
  tempRows && (tempRows[newEnd] = this.j[end]);
1632
1660
  tempIndexes && (tempIndexes[newEnd] = this.k[end]);
1633
1661
  }
@@ -1641,23 +1669,23 @@ function updateKeyedMap() {
1641
1669
  newIndices.set(key, j);
1642
1670
  }
1643
1671
  for (i = start; i <= end; i++) {
1644
- item = this.x[i];
1672
+ item = this.w[i];
1645
1673
  key = this.C ? this.C(item) : item;
1646
1674
  j = newIndices.get(key);
1647
1675
  if (j !== void 0 && j !== -1) {
1648
1676
  temp[j] = this.g[i];
1649
- tempNodes[j] = this.e[i];
1677
+ tempNodes[j] = this.f[i];
1650
1678
  tempRows && (tempRows[j] = this.j[i]);
1651
1679
  tempIndexes && (tempIndexes[j] = this.k[i]);
1652
1680
  j = newIndicesNext[j];
1653
1681
  newIndices.set(key, j);
1654
1682
  } else
1655
- this.e[i].dispose();
1683
+ this.f[i].dispose();
1656
1684
  }
1657
1685
  for (j = start; j < newLen; j++) {
1658
1686
  if (j in temp) {
1659
1687
  this.g[j] = temp[j];
1660
- this.e[j] = tempNodes[j];
1688
+ this.f[j] = tempNodes[j];
1661
1689
  if (tempRows) {
1662
1690
  this.j[j] = tempRows[j];
1663
1691
  this.j[j].write(newItems[j]);
@@ -1667,55 +1695,55 @@ function updateKeyedMap() {
1667
1695
  this.k[j].write(j);
1668
1696
  }
1669
1697
  } else {
1670
- this.g[j] = compute(this.e[j] = new Owner(), mapper, null);
1698
+ this.g[j] = compute(this.f[j] = new Owner(), mapper, null);
1671
1699
  }
1672
1700
  }
1673
1701
  this.g = this.g.slice(0, this.i = newLen);
1674
- this.x = newItems.slice(0);
1702
+ this.w = newItems.slice(0);
1675
1703
  }
1676
1704
  });
1677
1705
  return this.g;
1678
1706
  }
1679
1707
  function repeat(count, map, options) {
1680
1708
  return updateRepeat.bind({
1681
- F: new Owner(),
1709
+ G: new Owner(),
1682
1710
  i: 0,
1683
1711
  Y: count,
1684
- G: map,
1685
- e: [],
1712
+ H: map,
1713
+ f: [],
1686
1714
  g: [],
1687
1715
  o: options == null ? void 0 : options.fallback
1688
1716
  });
1689
1717
  }
1690
1718
  function updateRepeat() {
1691
1719
  const newLen = this.Y();
1692
- runWithOwner(this.F, () => {
1720
+ runWithOwner(this.G, () => {
1693
1721
  if (newLen === 0) {
1694
1722
  if (this.i !== 0) {
1695
- this.F.dispose(false);
1696
- this.e = [];
1723
+ this.G.dispose(false);
1724
+ this.f = [];
1697
1725
  this.g = [];
1698
1726
  this.i = 0;
1699
1727
  }
1700
1728
  if (this.o && !this.g[0]) {
1701
1729
  this.g[0] = compute(
1702
- this.e[0] = new Owner(),
1730
+ this.f[0] = new Owner(),
1703
1731
  this.o,
1704
1732
  null
1705
1733
  );
1706
1734
  }
1707
1735
  } else {
1708
- if (this.i === 0 && this.e[0])
1709
- this.e[0].dispose();
1736
+ if (this.i === 0 && this.f[0])
1737
+ this.f[0].dispose();
1710
1738
  for (let i = this.i; i < newLen; i++) {
1711
1739
  this.g[i] = compute(
1712
- this.e[i] = new Owner(),
1713
- () => this.G(i),
1740
+ this.f[i] = new Owner(),
1741
+ () => this.H(i),
1714
1742
  null
1715
1743
  );
1716
1744
  }
1717
1745
  for (let i = newLen; i < this.i; i++)
1718
- this.e[i].dispose();
1746
+ this.f[i].dispose();
1719
1747
  this.g = this.g.slice(0, newLen);
1720
1748
  this.i = newLen;
1721
1749
  }
@@ -1745,7 +1773,6 @@ exports.createEffect = createEffect;
1745
1773
  exports.createErrorBoundary = createErrorBoundary;
1746
1774
  exports.createMemo = createMemo;
1747
1775
  exports.createProjection = createProjection;
1748
- exports.createReaction = createReaction;
1749
1776
  exports.createRenderEffect = createRenderEffect;
1750
1777
  exports.createRoot = createRoot;
1751
1778
  exports.createSignal = createSignal;
@@ -1759,7 +1786,7 @@ exports.getOwner = getOwner;
1759
1786
  exports.hasContext = hasContext;
1760
1787
  exports.hasUpdated = hasUpdated;
1761
1788
  exports.isEqual = isEqual;
1762
- exports.isStale = isStale;
1789
+ exports.isPending = isPending;
1763
1790
  exports.isWrappable = isWrappable;
1764
1791
  exports.latest = latest;
1765
1792
  exports.mapArray = mapArray;
@@ -1769,6 +1796,7 @@ exports.onCleanup = onCleanup;
1769
1796
  exports.reconcile = reconcile;
1770
1797
  exports.repeat = repeat;
1771
1798
  exports.resolve = resolve;
1799
+ exports.runWithObserver = runWithObserver;
1772
1800
  exports.runWithOwner = runWithOwner;
1773
1801
  exports.setContext = setContext;
1774
1802
  exports.untrack = untrack;