@solidjs/signals 0.5.0 → 0.6.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/prod.js CHANGED
@@ -45,7 +45,7 @@ function schedule() {
45
45
  if (scheduled)
46
46
  return;
47
47
  scheduled = true;
48
- if (!globalQueue.A)
48
+ if (!globalQueue.B)
49
49
  queueMicrotask(flush);
50
50
  }
51
51
  function notifyUnobserved() {
@@ -59,7 +59,7 @@ function notifyUnobserved() {
59
59
  var pureQueue = [];
60
60
  var Queue = class {
61
61
  k = null;
62
- A = false;
62
+ B = false;
63
63
  g = [[], []];
64
64
  f = [];
65
65
  created = clock;
@@ -86,9 +86,9 @@ var Queue = class {
86
86
  }
87
87
  }
88
88
  flush() {
89
- if (this.A)
89
+ if (this.B)
90
90
  return;
91
- this.A = true;
91
+ this.B = true;
92
92
  try {
93
93
  this.run(EFFECT_PURE);
94
94
  incrementClock();
@@ -96,7 +96,7 @@ var Queue = class {
96
96
  this.run(EFFECT_RENDER);
97
97
  this.run(EFFECT_USER);
98
98
  } finally {
99
- this.A = false;
99
+ this.B = false;
100
100
  Unobserved.length && notifyUnobserved();
101
101
  }
102
102
  }
@@ -162,15 +162,15 @@ function runQueue(queue, type) {
162
162
  var Transition = class _Transition {
163
163
  a = /* @__PURE__ */ new Map();
164
164
  t = /* @__PURE__ */ new Set();
165
- Q = /* @__PURE__ */ new Set();
165
+ G = /* @__PURE__ */ new Set();
166
166
  W = /* @__PURE__ */ new Set();
167
- I = false;
167
+ w = false;
168
168
  g = [[], []];
169
169
  p = /* @__PURE__ */ new Map();
170
- E = [];
170
+ H = [];
171
171
  f = [];
172
172
  k = null;
173
- A = false;
173
+ B = false;
174
174
  X = false;
175
175
  e = globalQueue;
176
176
  created = clock;
@@ -181,15 +181,15 @@ var Transition = class _Transition {
181
181
  }
182
182
  }
183
183
  enqueue(type, fn) {
184
- this.E.push(fn);
184
+ this.H.push(fn);
185
185
  if (type)
186
186
  this.g[type - 1].push(fn);
187
187
  this.schedule();
188
188
  }
189
189
  run(type) {
190
190
  if (type === EFFECT_PURE) {
191
- this.E.length && runQueue(this.E, type);
192
- this.E = [];
191
+ this.H.length && runQueue(this.H, type);
192
+ this.H = [];
193
193
  return;
194
194
  } else if (this.g[type - 1].length) {
195
195
  const effects = this.g[type - 1];
@@ -201,9 +201,9 @@ var Transition = class _Transition {
201
201
  }
202
202
  }
203
203
  flush() {
204
- if (this.A)
204
+ if (this.B)
205
205
  return;
206
- this.A = true;
206
+ this.B = true;
207
207
  let currentTransition = ActiveTransition;
208
208
  ActiveTransition = this;
209
209
  try {
@@ -213,7 +213,7 @@ var Transition = class _Transition {
213
213
  ActiveTransition = currentTransition;
214
214
  finishTransition(this);
215
215
  } finally {
216
- this.A = false;
216
+ this.B = false;
217
217
  ActiveTransition = currentTransition;
218
218
  }
219
219
  }
@@ -239,7 +239,7 @@ var Transition = class _Transition {
239
239
  merge(queue) {
240
240
  this.g[0].push.apply(this.g[0], queue.g[0]);
241
241
  this.g[1].push.apply(this.g[1], queue.g[1]);
242
- this.E.push.apply(this.E, queue.E);
242
+ this.H.push.apply(this.H, queue.H);
243
243
  for (let i = 0; i < queue.f.length; i++) {
244
244
  const og = this.f.find((c) => c.e === queue.f[i].e);
245
245
  if (og)
@@ -252,13 +252,13 @@ var Transition = class _Transition {
252
252
  if (this.X)
253
253
  return;
254
254
  this.X = true;
255
- if (!this.A)
255
+ if (!this.B)
256
256
  queueMicrotask(() => this.flush());
257
257
  }
258
258
  runTransition(fn, force = false) {
259
- if (this.I) {
260
- if (this.I instanceof _Transition)
261
- return this.I.runTransition(fn, force);
259
+ if (this.w) {
260
+ if (this.w instanceof _Transition)
261
+ return this.w.runTransition(fn, force);
262
262
  if (!force)
263
263
  throw new Error("Transition already completed");
264
264
  fn();
@@ -266,12 +266,34 @@ var Transition = class _Transition {
266
266
  }
267
267
  ActiveTransition = this;
268
268
  try {
269
- const result = fn();
270
- const transition2 = ActiveTransition;
269
+ let result = fn();
270
+ let transition2 = ActiveTransition;
271
+ if (result?.next) {
272
+ (async function() {
273
+ let temp, value;
274
+ while (!(temp = result.next(value)).done) {
275
+ if (temp.value instanceof Promise) {
276
+ transition2.G.add(temp.value);
277
+ try {
278
+ value = await temp.value;
279
+ } finally {
280
+ while (transition2.w instanceof _Transition)
281
+ transition2 = transition2.w;
282
+ transition2.G.delete(temp.value);
283
+ }
284
+ ActiveTransition = transition2;
285
+ } else
286
+ value = temp.value;
287
+ }
288
+ finishTransition(transition2);
289
+ })();
290
+ }
271
291
  if (result instanceof Promise) {
272
- transition2.Q.add(result);
292
+ transition2.G.add(result);
273
293
  result.finally(() => {
274
- transition2.Q.delete(result);
294
+ while (transition2.w instanceof _Transition)
295
+ transition2 = transition2.w;
296
+ transition2.G.delete(result);
275
297
  finishTransition(transition2);
276
298
  });
277
299
  }
@@ -348,7 +370,7 @@ function cloneQueue(queue, parent, clonedQueues) {
348
370
  },
349
371
  notify(node, type, flags) {
350
372
  node = node.e || node;
351
- if (!clone.F || type & LOADING_BIT) {
373
+ if (!clone.I || type & LOADING_BIT) {
352
374
  type &= ~LOADING_BIT;
353
375
  ActiveTransition?.notify(node, LOADING_BIT, flags);
354
376
  if (!type)
@@ -389,10 +411,10 @@ function mergeTransitions(t1, t2) {
389
411
  c.j = t1;
390
412
  t1.W.add(c);
391
413
  });
392
- t2.Q.forEach((p) => t1.Q.add(p));
414
+ t2.G.forEach((p) => t1.G.add(p));
393
415
  t2.t.forEach((n) => t1.t.add(n));
394
416
  t1.merge(t2);
395
- t2.I = t1;
417
+ t2.w = t1;
396
418
  }
397
419
  function getTransitionSource(input) {
398
420
  return ActiveTransition && ActiveTransition.a.get(input) || input;
@@ -408,7 +430,7 @@ function initialDispose(node) {
408
430
  }
409
431
  }
410
432
  function finishTransition(transition2) {
411
- if (transition2.I || transition2.X || transition2.Q.size || transition2.t.size)
433
+ if (transition2.w || transition2.X || transition2.G.size || transition2.t.size)
412
434
  return;
413
435
  globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
414
436
  globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
@@ -431,15 +453,15 @@ function finishTransition(transition2) {
431
453
  Object.assign(source, clone);
432
454
  delete source.e;
433
455
  let current = clone.n;
434
- if (current?.w === clone)
435
- current.w = source;
456
+ if (current?.x === clone)
457
+ current.x = source;
436
458
  while (current?.k === clone) {
437
459
  current.k = source;
438
460
  current = current.n;
439
461
  }
440
462
  delete source.j;
441
463
  }
442
- transition2.I = true;
464
+ transition2.w = true;
443
465
  for (const reset of transition2.W) {
444
466
  delete reset.j;
445
467
  reset();
@@ -464,10 +486,10 @@ var Owner = class {
464
486
  // See comment at the top of the file for an example of the _nextSibling traversal
465
487
  k = null;
466
488
  n = null;
467
- w = null;
489
+ x = null;
468
490
  c = STATE_CLEAN;
469
491
  o = null;
470
- x = defaultContext;
492
+ y = defaultContext;
471
493
  m = globalQueue;
472
494
  fa = 0;
473
495
  id = null;
@@ -479,15 +501,15 @@ var Owner = class {
479
501
  }
480
502
  append(child) {
481
503
  child.k = this;
482
- child.w = this;
504
+ child.x = this;
483
505
  if (this.n)
484
- this.n.w = child;
506
+ this.n.x = child;
485
507
  child.n = this.n;
486
508
  this.n = child;
487
509
  if (this.id != null && child.id == null)
488
510
  child.id = this.getNextChildId();
489
- if (child.x !== this.x) {
490
- child.x = { ...this.x, ...child.x };
511
+ if (child.y !== this.y) {
512
+ child.y = { ...this.y, ...child.y };
491
513
  }
492
514
  if (this.m)
493
515
  child.m = this.m;
@@ -495,7 +517,7 @@ var Owner = class {
495
517
  dispose(self = true) {
496
518
  if (this.c === STATE_DISPOSED)
497
519
  return;
498
- let head = self ? this.w || this.k : this, current = this.n, next = null;
520
+ let head = self ? this.x || this.k : this, current = this.n, next = null;
499
521
  while (current && current.k === this) {
500
522
  current.dispose(true);
501
523
  next = current.n;
@@ -506,16 +528,16 @@ var Owner = class {
506
528
  if (self)
507
529
  this.R();
508
530
  if (current)
509
- current.w = !self ? this : this.w;
531
+ current.x = !self ? this : this.x;
510
532
  if (head)
511
533
  head.n = current;
512
534
  }
513
535
  R() {
514
- if (this.w)
515
- this.w.n = null;
536
+ if (this.x)
537
+ this.x.n = null;
516
538
  this.k = null;
517
- this.w = null;
518
- this.x = defaultContext;
539
+ this.x = null;
540
+ this.y = defaultContext;
519
541
  this.c = STATE_DISPOSED;
520
542
  this.emptyDisposal();
521
543
  }
@@ -545,7 +567,7 @@ function getContext(context, owner = currentOwner) {
545
567
  if (!owner) {
546
568
  throw new NoOwnerError();
547
569
  }
548
- const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue;
570
+ const value = hasContext(context, owner) ? owner.y[context.id] : context.defaultValue;
549
571
  if (isUndefined(value)) {
550
572
  throw new ContextNotFoundError();
551
573
  }
@@ -555,13 +577,13 @@ function setContext(context, value, owner = currentOwner) {
555
577
  if (!owner) {
556
578
  throw new NoOwnerError();
557
579
  }
558
- owner.x = {
559
- ...owner.x,
580
+ owner.y = {
581
+ ...owner.y,
560
582
  [context.id]: isUndefined(value) ? context.defaultValue : value
561
583
  };
562
584
  }
563
585
  function hasContext(context, owner = currentOwner) {
564
- return !isUndefined(owner?.x[context.id]);
586
+ return !isUndefined(owner?.y[context.id]);
565
587
  }
566
588
  function onCleanup(fn) {
567
589
  if (!currentOwner)
@@ -601,8 +623,8 @@ var Computation = class extends Owner {
601
623
  a = null;
602
624
  b = null;
603
625
  l;
604
- J;
605
- K;
626
+ L;
627
+ M;
606
628
  // Used in __DEV__ mode, hopefully removed in production
607
629
  la;
608
630
  // Using false is an optimization as an alternative to _equals: () => false
@@ -614,13 +636,13 @@ var Computation = class extends Owner {
614
636
  h = 0;
615
637
  /** Which flags raised by sources are handled, vs. being passed through. */
616
638
  ba = DEFAULT_FLAGS;
617
- L = -1;
618
- G = false;
639
+ N = -1;
640
+ J = false;
619
641
  j;
620
642
  e;
621
643
  constructor(initialValue, compute2, options) {
622
644
  super(options?.id, compute2 === null);
623
- this.K = compute2;
645
+ this.M = compute2;
624
646
  this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
625
647
  this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
626
648
  this.l = initialValue;
@@ -639,7 +661,7 @@ var Computation = class extends Owner {
639
661
  track(this);
640
662
  newFlags |= this.h & ~currentMask;
641
663
  if (this.h & ERROR_BIT) {
642
- throw this.J;
664
+ throw this.L;
643
665
  } else {
644
666
  return this.l;
645
667
  }
@@ -654,11 +676,11 @@ var Computation = class extends Owner {
654
676
  if (clone !== this)
655
677
  return clone.read();
656
678
  }
657
- if (this.K) {
658
- if (this.h & ERROR_BIT && this.L <= clock)
679
+ if (this.M) {
680
+ if (this.h & ERROR_BIT && this.N <= clock)
659
681
  update(this);
660
682
  else
661
- this.H();
683
+ this.K();
662
684
  }
663
685
  return this.ga();
664
686
  }
@@ -675,11 +697,11 @@ var Computation = class extends Owner {
675
697
  if (clone !== this)
676
698
  return clone.wait();
677
699
  }
678
- if (this.K) {
679
- if (this.h & ERROR_BIT && this.L <= clock)
700
+ if (this.M) {
701
+ if (this.h & ERROR_BIT && this.N <= clock)
680
702
  update(this);
681
703
  else
682
- this.H();
704
+ this.K();
683
705
  }
684
706
  if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
685
707
  track(this);
@@ -702,15 +724,15 @@ var Computation = class extends Owner {
702
724
  this.aa === false || !this.aa(this.l, newValue));
703
725
  if (valueChanged) {
704
726
  this.l = newValue;
705
- this.J = void 0;
727
+ this.L = void 0;
706
728
  }
707
729
  const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
708
730
  this.h = flags;
709
- this.L = clock + 1;
731
+ this.N = clock + 1;
710
732
  if (this.b) {
711
733
  for (let i = 0; i < this.b.length; i++) {
712
734
  if (valueChanged) {
713
- this.b[i].y(STATE_DIRTY);
735
+ this.b[i].z(STATE_DIRTY);
714
736
  } else if (changedFlagsMask) {
715
737
  this.b[i].Z(changedFlagsMask, changedFlags);
716
738
  }
@@ -721,14 +743,14 @@ var Computation = class extends Owner {
721
743
  /**
722
744
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
723
745
  */
724
- y(state, skipQueue) {
725
- if (this.c >= state && !this.G)
746
+ z(state, skipQueue) {
747
+ if (this.c >= state && !this.J)
726
748
  return;
727
- this.G = !!skipQueue;
749
+ this.J = !!skipQueue;
728
750
  this.c = state;
729
751
  if (this.b) {
730
752
  for (let i = 0; i < this.b.length; i++) {
731
- this.b[i].y(STATE_CHECK, skipQueue);
753
+ this.b[i].z(STATE_CHECK, skipQueue);
732
754
  }
733
755
  }
734
756
  }
@@ -742,7 +764,7 @@ var Computation = class extends Owner {
742
764
  if (this.c >= STATE_DIRTY)
743
765
  return;
744
766
  if (mask & this.ba) {
745
- this.y(STATE_DIRTY);
767
+ this.z(STATE_DIRTY);
746
768
  return;
747
769
  }
748
770
  if (this.c >= STATE_CHECK)
@@ -750,7 +772,7 @@ var Computation = class extends Owner {
750
772
  const prevFlags = this.h & mask;
751
773
  const deltaFlags = prevFlags ^ newFlags2;
752
774
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
753
- this.y(STATE_CHECK);
775
+ this.z(STATE_CHECK);
754
776
  } else {
755
777
  this.h ^= deltaFlags;
756
778
  if (this.b) {
@@ -760,13 +782,13 @@ var Computation = class extends Owner {
760
782
  }
761
783
  }
762
784
  }
763
- M(error) {
785
+ D(error) {
764
786
  if (ActiveTransition && !this.e) {
765
787
  const clone = cloneGraph(this);
766
788
  if (clone !== this)
767
- return clone.M(error);
789
+ return clone.D(error);
768
790
  }
769
- this.J = error;
791
+ this.L = error;
770
792
  this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
771
793
  }
772
794
  /**
@@ -776,8 +798,8 @@ var Computation = class extends Owner {
776
798
  *
777
799
  * This function will ensure that the value and states we read from the computation are up to date
778
800
  */
779
- H() {
780
- if (!this.K) {
801
+ K() {
802
+ if (!this.M) {
781
803
  return;
782
804
  }
783
805
  if (this.c === STATE_DISPOSED) {
@@ -790,7 +812,7 @@ var Computation = class extends Owner {
790
812
  if (this.c === STATE_CHECK) {
791
813
  for (let i = 0; i < this.a.length; i++) {
792
814
  const source = getTransitionSource(this.a[i]);
793
- source.H();
815
+ source.K();
794
816
  observerFlags |= source.h & ~UNINITIALIZED_BIT;
795
817
  if (this.c === STATE_DIRTY) {
796
818
  break;
@@ -827,7 +849,7 @@ function track(computation) {
827
849
  newSources.push(computation);
828
850
  }
829
851
  if (updateCheck) {
830
- updateCheck.l = computation.L > currentObserver.L;
852
+ updateCheck.l = computation.N > currentObserver.N;
831
853
  }
832
854
  }
833
855
  }
@@ -843,13 +865,13 @@ function update(node) {
843
865
  }
844
866
  node.dispose(false);
845
867
  node.emptyDisposal();
846
- const result = compute(node, node.K, node);
868
+ const result = compute(node, node.M, node);
847
869
  node.write(result, newFlags, true);
848
870
  } catch (error) {
849
871
  if (error instanceof NotReadyError) {
850
872
  node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
851
873
  } else {
852
- node.M(error);
874
+ node.D(error);
853
875
  }
854
876
  } finally {
855
877
  if (newSources) {
@@ -878,7 +900,7 @@ function update(node) {
878
900
  newSources = prevSources;
879
901
  newSourcesIndex = prevSourcesIndex;
880
902
  newFlags = prevFlags;
881
- node.L = clock + 1;
903
+ node.N = clock + 1;
882
904
  node.c = STATE_CLEAN;
883
905
  }
884
906
  }
@@ -953,7 +975,7 @@ function runWithObserver(observer, run) {
953
975
  newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
954
976
  );
955
977
  } else {
956
- observer.M(error);
978
+ observer.D(error);
957
979
  }
958
980
  } finally {
959
981
  if (newSources) {
@@ -998,28 +1020,28 @@ function compute(owner, fn, observer) {
998
1020
  var Effect = class extends Computation {
999
1021
  ca;
1000
1022
  _;
1001
- N;
1023
+ O;
1002
1024
  da = false;
1003
1025
  $;
1004
- B;
1026
+ C;
1005
1027
  constructor(initialValue, compute2, effect, error, options) {
1006
1028
  super(initialValue, compute2, options);
1007
1029
  this.ca = effect;
1008
1030
  this._ = error;
1009
1031
  this.$ = initialValue;
1010
- this.B = options?.render ? EFFECT_RENDER : EFFECT_USER;
1011
- if (this.B === EFFECT_RENDER) {
1012
- this.K = function(p) {
1032
+ this.C = options?.render ? EFFECT_RENDER : EFFECT_USER;
1033
+ if (this.C === EFFECT_RENDER) {
1034
+ this.M = function(p) {
1013
1035
  return !this.e && clock > this.m.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1014
1036
  };
1015
1037
  }
1016
- this.H();
1017
- !options?.defer && (this.B === EFFECT_USER ? this.m.enqueue(this.B, this.C.bind(this)) : this.C(this.B));
1038
+ this.K();
1039
+ !options?.defer && (this.C === EFFECT_USER ? this.m.enqueue(this.C, this.E.bind(this)) : this.E(this.C));
1018
1040
  }
1019
1041
  write(value, flags = 0) {
1020
1042
  if (this.c == STATE_DIRTY) {
1021
1043
  this.h = flags;
1022
- if (this.B === EFFECT_RENDER) {
1044
+ if (this.C === EFFECT_RENDER) {
1023
1045
  this.m.notify(this, LOADING_BIT | ERROR_BIT, this.h);
1024
1046
  }
1025
1047
  }
@@ -1027,14 +1049,14 @@ var Effect = class extends Computation {
1027
1049
  return this.l;
1028
1050
  this.l = value;
1029
1051
  this.da = true;
1030
- this.J = void 0;
1052
+ this.L = void 0;
1031
1053
  return value;
1032
1054
  }
1033
- y(state, skipQueue) {
1055
+ z(state, skipQueue) {
1034
1056
  if (this.c >= state || skipQueue)
1035
1057
  return;
1036
1058
  if (this.c === STATE_CLEAN)
1037
- this.m.enqueue(this.B, this.C.bind(this));
1059
+ this.m.enqueue(this.C, this.E.bind(this));
1038
1060
  this.c = state;
1039
1061
  }
1040
1062
  Z(mask, newFlags2) {
@@ -1042,21 +1064,21 @@ var Effect = class extends Computation {
1042
1064
  if (this.c >= STATE_DIRTY)
1043
1065
  return;
1044
1066
  if (mask & 3) {
1045
- this.y(STATE_DIRTY);
1067
+ this.z(STATE_DIRTY);
1046
1068
  return;
1047
1069
  }
1048
1070
  }
1049
1071
  super.Z(mask, newFlags2);
1050
1072
  }
1051
- M(error) {
1052
- this.J = error;
1073
+ D(error) {
1074
+ this.L = error;
1053
1075
  this.m.notify(this, LOADING_BIT, 0);
1054
1076
  this.h = ERROR_BIT;
1055
- if (this.B === EFFECT_USER) {
1077
+ if (this.C === EFFECT_USER) {
1056
1078
  try {
1057
1079
  return this._ ? this._(error, () => {
1058
- this.N?.();
1059
- this.N = void 0;
1080
+ this.O?.();
1081
+ this.O = void 0;
1060
1082
  }) : console.error(error);
1061
1083
  } catch (e) {
1062
1084
  error = e;
@@ -1071,18 +1093,18 @@ var Effect = class extends Computation {
1071
1093
  this.ca = void 0;
1072
1094
  this.$ = void 0;
1073
1095
  this._ = void 0;
1074
- this.N?.();
1075
- this.N = void 0;
1096
+ this.O?.();
1097
+ this.O = void 0;
1076
1098
  this.m.notify(this, ERROR_BIT | LOADING_BIT, 0);
1077
1099
  super.R();
1078
1100
  }
1079
- C(type) {
1101
+ E(type) {
1080
1102
  if (type) {
1081
1103
  const effect = this.e || this;
1082
1104
  if (effect.da && effect.c !== STATE_DISPOSED) {
1083
- effect.N?.();
1105
+ effect.O?.();
1084
1106
  try {
1085
- effect.N = effect.ca(effect.l, effect.$);
1107
+ effect.O = effect.ca(effect.l, effect.$);
1086
1108
  } catch (e) {
1087
1109
  if (!effect.m.notify(effect, ERROR_BIT, ERROR_BIT))
1088
1110
  throw e;
@@ -1098,16 +1120,16 @@ var Effect = class extends Computation {
1098
1120
  var EagerComputation = class extends Computation {
1099
1121
  constructor(initialValue, compute2, options) {
1100
1122
  super(initialValue, compute2, options);
1101
- !options?.defer && this.H();
1123
+ !options?.defer && this.K();
1102
1124
  }
1103
- y(state, skipQueue) {
1104
- if (this.c >= state && !this.G)
1125
+ z(state, skipQueue) {
1126
+ if (this.c >= state && !this.J)
1105
1127
  return;
1106
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1107
- this.m.enqueue(EFFECT_PURE, this.C.bind(this));
1108
- super.y(state, skipQueue);
1128
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.J))
1129
+ this.m.enqueue(EFFECT_PURE, this.E.bind(this));
1130
+ super.z(state, skipQueue);
1109
1131
  }
1110
- C() {
1132
+ E() {
1111
1133
  this.c !== STATE_CLEAN && runTop(this);
1112
1134
  }
1113
1135
  };
@@ -1116,15 +1138,15 @@ var FirewallComputation = class extends Computation {
1116
1138
  constructor(compute2) {
1117
1139
  super(void 0, compute2);
1118
1140
  }
1119
- y(state, skipQueue) {
1120
- if (this.c >= state && !this.G)
1141
+ z(state, skipQueue) {
1142
+ if (this.c >= state && !this.J)
1121
1143
  return;
1122
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1123
- this.m.enqueue(EFFECT_PURE, this.C.bind(this));
1124
- super.y(state, true);
1125
- this.G = !!skipQueue;
1144
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.J))
1145
+ this.m.enqueue(EFFECT_PURE, this.E.bind(this));
1146
+ super.z(state, true);
1147
+ this.J = !!skipQueue;
1126
1148
  }
1127
- C() {
1149
+ E() {
1128
1150
  this.c !== STATE_CLEAN && runTop(this);
1129
1151
  }
1130
1152
  };
@@ -1139,22 +1161,156 @@ function runTop(node) {
1139
1161
  }
1140
1162
  for (let i = ancestors.length - 1; i >= 0; i--) {
1141
1163
  if (ancestors[i].c !== STATE_DISPOSED)
1142
- ancestors[i].H();
1164
+ ancestors[i].K();
1143
1165
  }
1144
1166
  }
1145
1167
 
1168
+ // src/store/reconcile.ts
1169
+ function unwrap(value) {
1170
+ return value?.[$TARGET]?.[STORE_NODE] ?? value;
1171
+ }
1172
+ function getOverrideValue(value, override, key) {
1173
+ return override && key in override ? override[key] : value[key];
1174
+ }
1175
+ function getAllKeys(value, override, next) {
1176
+ const keys = getKeys(value, override);
1177
+ const nextKeys = Object.keys(next);
1178
+ return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
1179
+ }
1180
+ function applyState(next, state, keyFn, all) {
1181
+ const target = state?.[$TARGET];
1182
+ if (!target)
1183
+ return;
1184
+ const previous = target[STORE_VALUE];
1185
+ const override = target[STORE_OVERRIDE];
1186
+ if (next === previous && !override)
1187
+ return;
1188
+ (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
1189
+ target[STORE_VALUE] = next;
1190
+ target[STORE_OVERRIDE] = void 0;
1191
+ if (Array.isArray(previous)) {
1192
+ let changed = false;
1193
+ const prevLength = getOverrideValue(previous, override, "length");
1194
+ if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
1195
+ let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
1196
+ for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
1197
+ applyState(next[start], wrap(item, target), keyFn, all);
1198
+ }
1199
+ const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
1200
+ for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
1201
+ temp[newEnd] = item;
1202
+ }
1203
+ if (start > newEnd || start > end) {
1204
+ for (j = start; j <= newEnd; j++) {
1205
+ changed = true;
1206
+ target[STORE_NODE][j]?.write(wrap(next[j], target));
1207
+ }
1208
+ for (; j < next.length; j++) {
1209
+ changed = true;
1210
+ const wrapped = wrap(temp[j], target);
1211
+ target[STORE_NODE][j]?.write(wrapped);
1212
+ applyState(next[j], wrapped, keyFn, all);
1213
+ }
1214
+ changed && target[STORE_NODE][$TRACK]?.write(void 0);
1215
+ prevLength !== next.length && target[STORE_NODE].length?.write(next.length);
1216
+ return;
1217
+ }
1218
+ newIndicesNext = new Array(newEnd + 1);
1219
+ for (j = newEnd; j >= start; j--) {
1220
+ item = next[j];
1221
+ keyVal = item ? keyFn(item) : item;
1222
+ i = newIndices.get(keyVal);
1223
+ newIndicesNext[j] = i === void 0 ? -1 : i;
1224
+ newIndices.set(keyVal, j);
1225
+ }
1226
+ for (i = start; i <= end; i++) {
1227
+ item = getOverrideValue(previous, override, i);
1228
+ keyVal = item ? keyFn(item) : item;
1229
+ j = newIndices.get(keyVal);
1230
+ if (j !== void 0 && j !== -1) {
1231
+ temp[j] = item;
1232
+ j = newIndicesNext[j];
1233
+ newIndices.set(keyVal, j);
1234
+ }
1235
+ }
1236
+ for (j = start; j < next.length; j++) {
1237
+ if (j in temp) {
1238
+ const wrapped = wrap(temp[j], target);
1239
+ target[STORE_NODE][j]?.write(wrapped);
1240
+ applyState(next[j], wrapped, keyFn, all);
1241
+ } else
1242
+ target[STORE_NODE][j]?.write(wrap(next[j], target));
1243
+ }
1244
+ if (start < next.length)
1245
+ changed = true;
1246
+ } else if (prevLength && next.length) {
1247
+ for (let i = 0, len = next.length; i < len; i++) {
1248
+ const item = getOverrideValue(previous, override, i);
1249
+ isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
1250
+ }
1251
+ }
1252
+ if (prevLength !== next.length) {
1253
+ changed = true;
1254
+ target[STORE_NODE].length?.write(next.length);
1255
+ }
1256
+ changed && target[STORE_NODE][$TRACK]?.write(void 0);
1257
+ return;
1258
+ }
1259
+ let nodes = target[STORE_NODE];
1260
+ if (nodes) {
1261
+ const tracked = nodes[$TRACK];
1262
+ const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
1263
+ for (let i = 0, len = keys.length; i < len; i++) {
1264
+ const key = keys[i];
1265
+ const node = nodes[key];
1266
+ const previousValue = unwrap(getOverrideValue(previous, override, key));
1267
+ let nextValue = unwrap(next[key]);
1268
+ if (previousValue === nextValue)
1269
+ continue;
1270
+ if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
1271
+ tracked?.write(void 0);
1272
+ node?.write(isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
1273
+ } else
1274
+ applyState(nextValue, wrap(previousValue, target), keyFn, all);
1275
+ }
1276
+ }
1277
+ if (nodes = target[STORE_HAS]) {
1278
+ const keys = Object.keys(nodes);
1279
+ for (let i = 0, len = keys.length; i < len; i++) {
1280
+ nodes[keys[i]].write(keys[i] in next);
1281
+ }
1282
+ }
1283
+ }
1284
+ function reconcile(value, key, all = false) {
1285
+ return (state) => {
1286
+ if (state == null)
1287
+ throw new Error("Cannot reconcile null or undefined state");
1288
+ const keyFn = typeof key === "string" ? (item) => item[key] : key;
1289
+ const eq = keyFn(state);
1290
+ if (eq !== void 0 && keyFn(value) !== keyFn(state))
1291
+ throw new Error("Cannot reconcile states with different identity");
1292
+ applyState(value, state, keyFn, all);
1293
+ };
1294
+ }
1295
+
1146
1296
  // src/store/projection.ts
1147
- function createProjection(fn, initialValue = {}) {
1297
+ function createProjection(fn, initialValue = {}, options) {
1148
1298
  let wrappedStore;
1149
1299
  const node = new FirewallComputation(() => {
1150
- storeSetter(wrappedStore, fn);
1300
+ storeSetter(wrappedStore, (s) => {
1301
+ const value = fn(s);
1302
+ if (value !== s && value !== void 0) {
1303
+ reconcile(value, options?.key || "id", options?.all)(s);
1304
+ }
1305
+ });
1151
1306
  });
1152
1307
  const wrappedMap = /* @__PURE__ */ new WeakMap();
1153
1308
  const traps = {
1154
1309
  ...storeTraps,
1155
1310
  get(target, property, receiver) {
1156
1311
  const o = getOwner();
1157
- (!o || o !== node) && node.wait();
1312
+ const n = getTransitionSource(node);
1313
+ (!o || o !== n) && n.wait();
1158
1314
  return storeTraps.get(target, property, receiver);
1159
1315
  }
1160
1316
  };
@@ -1396,8 +1552,8 @@ function storeSetter(store, fn) {
1396
1552
  Writing = prevWriting;
1397
1553
  }
1398
1554
  }
1399
- function createStore(first, second) {
1400
- const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second) : wrap(first);
1555
+ function createStore(first, second, options) {
1556
+ const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second, options) : wrap(first);
1401
1557
  return [wrappedStore, (fn) => storeSetter(wrappedStore, fn)];
1402
1558
  }
1403
1559
  function recursivelyNotify(state, lookup) {
@@ -1461,134 +1617,6 @@ function deep(store) {
1461
1617
  return store[$DEEP];
1462
1618
  }
1463
1619
 
1464
- // src/store/reconcile.ts
1465
- function unwrap(value) {
1466
- return value?.[$TARGET]?.[STORE_NODE] ?? value;
1467
- }
1468
- function getOverrideValue(value, override, key) {
1469
- return override && key in override ? override[key] : value[key];
1470
- }
1471
- function getAllKeys(value, override, next) {
1472
- const keys = getKeys(value, override);
1473
- const nextKeys = Object.keys(next);
1474
- return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
1475
- }
1476
- function applyState(next, state, keyFn, all) {
1477
- const target = state?.[$TARGET];
1478
- if (!target)
1479
- return;
1480
- const previous = target[STORE_VALUE];
1481
- const override = target[STORE_OVERRIDE];
1482
- if (next === previous && !override)
1483
- return;
1484
- (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
1485
- target[STORE_VALUE] = next;
1486
- target[STORE_OVERRIDE] = void 0;
1487
- if (Array.isArray(previous)) {
1488
- let changed = false;
1489
- const prevLength = getOverrideValue(previous, override, "length");
1490
- if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
1491
- let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
1492
- for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
1493
- applyState(next[start], wrap(item, target), keyFn, all);
1494
- }
1495
- const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
1496
- for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
1497
- temp[newEnd] = item;
1498
- }
1499
- if (start > newEnd || start > end) {
1500
- for (j = start; j <= newEnd; j++) {
1501
- changed = true;
1502
- target[STORE_NODE][j]?.write(wrap(next[j], target));
1503
- }
1504
- for (; j < next.length; j++) {
1505
- changed = true;
1506
- const wrapped = wrap(temp[j], target);
1507
- target[STORE_NODE][j]?.write(wrapped);
1508
- applyState(next[j], wrapped, keyFn, all);
1509
- }
1510
- changed && target[STORE_NODE][$TRACK]?.write(void 0);
1511
- prevLength !== next.length && target[STORE_NODE].length?.write(next.length);
1512
- return;
1513
- }
1514
- newIndicesNext = new Array(newEnd + 1);
1515
- for (j = newEnd; j >= start; j--) {
1516
- item = next[j];
1517
- keyVal = item ? keyFn(item) : item;
1518
- i = newIndices.get(keyVal);
1519
- newIndicesNext[j] = i === void 0 ? -1 : i;
1520
- newIndices.set(keyVal, j);
1521
- }
1522
- for (i = start; i <= end; i++) {
1523
- item = getOverrideValue(previous, override, i);
1524
- keyVal = item ? keyFn(item) : item;
1525
- j = newIndices.get(keyVal);
1526
- if (j !== void 0 && j !== -1) {
1527
- temp[j] = item;
1528
- j = newIndicesNext[j];
1529
- newIndices.set(keyVal, j);
1530
- }
1531
- }
1532
- for (j = start; j < next.length; j++) {
1533
- if (j in temp) {
1534
- const wrapped = wrap(temp[j], target);
1535
- target[STORE_NODE][j]?.write(wrapped);
1536
- applyState(next[j], wrapped, keyFn, all);
1537
- } else
1538
- target[STORE_NODE][j]?.write(wrap(next[j], target));
1539
- }
1540
- if (start < next.length)
1541
- changed = true;
1542
- } else if (prevLength && next.length) {
1543
- for (let i = 0, len = next.length; i < len; i++) {
1544
- const item = getOverrideValue(previous, override, i);
1545
- isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
1546
- }
1547
- }
1548
- if (prevLength !== next.length) {
1549
- changed = true;
1550
- target[STORE_NODE].length?.write(next.length);
1551
- }
1552
- changed && target[STORE_NODE][$TRACK]?.write(void 0);
1553
- return;
1554
- }
1555
- let nodes = target[STORE_NODE];
1556
- if (nodes) {
1557
- const tracked = nodes[$TRACK];
1558
- const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
1559
- for (let i = 0, len = keys.length; i < len; i++) {
1560
- const key = keys[i];
1561
- const node = nodes[key];
1562
- const previousValue = unwrap(getOverrideValue(previous, override, key));
1563
- let nextValue = unwrap(next[key]);
1564
- if (previousValue === nextValue)
1565
- continue;
1566
- if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
1567
- tracked?.write(void 0);
1568
- node?.write(isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
1569
- } else
1570
- applyState(nextValue, wrap(previousValue, target), keyFn, all);
1571
- }
1572
- }
1573
- if (nodes = target[STORE_HAS]) {
1574
- const keys = Object.keys(nodes);
1575
- for (let i = 0, len = keys.length; i < len; i++) {
1576
- nodes[keys[i]].write(keys[i] in next);
1577
- }
1578
- }
1579
- }
1580
- function reconcile(value, key, all = false) {
1581
- return (state) => {
1582
- if (state == null)
1583
- throw new Error("Cannot reconcile null or undefined state");
1584
- const keyFn = typeof key === "string" ? (item) => item[key] : key;
1585
- const eq = keyFn(state);
1586
- if (eq !== void 0 && keyFn(value) !== keyFn(state))
1587
- throw new Error("Cannot reconcile states with different identity");
1588
- applyState(value, state, keyFn, all);
1589
- };
1590
- }
1591
-
1592
1620
  // src/store/utils.ts
1593
1621
  function snapshot(item, map, lookup) {
1594
1622
  let target, isArray, override, result, unwrapped, v;
@@ -1847,22 +1875,24 @@ function createAsync(compute2, value, options) {
1847
1875
  }
1848
1876
  let abort = false;
1849
1877
  onCleanup(() => abort = true);
1850
- const transition2 = ActiveTransition;
1878
+ let transition2 = ActiveTransition;
1851
1879
  if (isPromise) {
1852
1880
  source.then(
1853
1881
  (value3) => {
1854
1882
  if (abort)
1855
1883
  return;
1856
1884
  if (transition2)
1857
- return transition2.runTransition(() => node.write(value3, 0, true), true);
1885
+ return transition2.runTransition(() => {
1886
+ node.write(value3, 0, true);
1887
+ }, true);
1858
1888
  node.write(value3, 0, true);
1859
1889
  },
1860
1890
  (error) => {
1861
1891
  if (abort)
1862
1892
  return;
1863
1893
  if (transition2)
1864
- return transition2.runTransition(() => node.M(error), true);
1865
- node.M(error);
1894
+ return transition2.runTransition(() => node.D(error), true);
1895
+ node.D(error);
1866
1896
  }
1867
1897
  );
1868
1898
  } else {
@@ -1871,12 +1901,22 @@ function createAsync(compute2, value, options) {
1871
1901
  for await (let value3 of source) {
1872
1902
  if (abort)
1873
1903
  return;
1904
+ if (transition2)
1905
+ return transition2.runTransition(() => {
1906
+ node.write(value3, 0, true);
1907
+ transition2 = null;
1908
+ }, true);
1874
1909
  node.write(value3, 0, true);
1875
1910
  }
1876
1911
  } catch (error) {
1877
1912
  if (abort)
1878
1913
  return;
1879
- node.write(error, ERROR_BIT);
1914
+ if (transition2)
1915
+ return transition2.runTransition(() => {
1916
+ node.D(error);
1917
+ transition2 = null;
1918
+ }, true);
1919
+ node.D(error);
1880
1920
  }
1881
1921
  })();
1882
1922
  }
@@ -1892,7 +1932,7 @@ function createAsync(compute2, value, options) {
1892
1932
  }
1893
1933
  n.c = STATE_DIRTY;
1894
1934
  refreshing = true;
1895
- n.H();
1935
+ n.K();
1896
1936
  };
1897
1937
  return read;
1898
1938
  }
@@ -1934,55 +1974,56 @@ function resolve(fn) {
1934
1974
  });
1935
1975
  });
1936
1976
  }
1937
- function tryCatch(fn) {
1938
- try {
1939
- const v = fn();
1940
- if (v instanceof Promise) {
1941
- return v.then(
1942
- (v2) => [void 0, v2],
1943
- (e) => {
1944
- if (e instanceof NotReadyError)
1945
- throw e;
1946
- return [e];
1947
- }
1948
- );
1949
- }
1950
- return [void 0, v];
1951
- } catch (e) {
1952
- if (e instanceof NotReadyError)
1953
- throw e;
1954
- return [e];
1955
- }
1956
- }
1957
- function createOptimistic(initial) {
1958
- const node = new Computation(initial, null);
1959
- const reset = () => node.write(initial);
1977
+ function createPending() {
1978
+ const node = new Computation(false, null);
1979
+ const reset = () => node.write(false);
1960
1980
  function write(v) {
1961
1981
  if (!ActiveTransition)
1962
- throw new Error("createOptimistic can only be updated inside a transition");
1982
+ return v;
1963
1983
  ActiveTransition.addOptimistic(reset);
1964
1984
  queueMicrotask(() => reset.j && node.write(v));
1965
1985
  }
1966
- return [node.read.bind(node), write];
1986
+ function read() {
1987
+ node.read();
1988
+ return !ActiveTransition;
1989
+ }
1990
+ return [read, write];
1967
1991
  }
1968
- function createOptimisticStore(first, second) {
1992
+ function useTransition() {
1993
+ const [pending, setPending] = createPending();
1994
+ function start(fn) {
1995
+ transition((resume) => {
1996
+ setPending(true);
1997
+ return fn(resume);
1998
+ });
1999
+ }
2000
+ return [pending, start];
2001
+ }
2002
+ function createOptimistic(first, second, options) {
1969
2003
  let store, setStore;
1970
2004
  if (typeof first === "function") {
1971
2005
  [store, setStore] = createStore((s) => {
1972
2006
  const value = first(s);
1973
2007
  if (!ActiveTransition)
1974
2008
  return value;
2009
+ ActiveTransition.addOptimistic(reset);
1975
2010
  }, {});
1976
2011
  } else
1977
2012
  [store, setStore] = createStore(first);
1978
- const reset = () => setStore(() => typeof first === "function" ? first(second) : first);
2013
+ const reset = () => setStore(
2014
+ (s) => reconcile(
2015
+ { value: typeof first === "function" ? first(second) : first },
2016
+ options?.key || "id",
2017
+ options?.all
2018
+ )(s)
2019
+ );
1979
2020
  function write(v) {
1980
2021
  if (!ActiveTransition)
1981
2022
  throw new Error("createOptimistic can only be updated inside a transition");
1982
2023
  ActiveTransition.addOptimistic(reset);
1983
2024
  queueMicrotask(() => reset.j && setStore(v));
1984
2025
  }
1985
- return [() => store.value, write];
2026
+ return [store, write];
1986
2027
  }
1987
2028
 
1988
2029
  // src/map.ts
@@ -1992,11 +2033,11 @@ function mapArray(list, map, options) {
1992
2033
  S: new Owner(),
1993
2034
  q: 0,
1994
2035
  ia: list,
1995
- D: [],
1996
- O: map,
2036
+ F: [],
2037
+ P: map,
1997
2038
  i: [],
1998
2039
  d: [],
1999
- P: keyFn,
2040
+ Q: keyFn,
2000
2041
  r: keyFn || options?.keyed === false ? [] : void 0,
2001
2042
  s: map.length > 1 ? [] : void 0,
2002
2043
  T: options?.fallback
@@ -2010,23 +2051,23 @@ function updateKeyedMap() {
2010
2051
  let i, j, mapper = this.r ? () => {
2011
2052
  this.r[j] = new Computation(newItems[j], null, pureOptions);
2012
2053
  this.s && (this.s[j] = new Computation(j, null, pureOptions));
2013
- return this.O(
2054
+ return this.P(
2014
2055
  Computation.prototype.read.bind(this.r[j]),
2015
2056
  this.s ? Computation.prototype.read.bind(this.s[j]) : void 0
2016
2057
  );
2017
2058
  } : this.s ? () => {
2018
2059
  const item = newItems[j];
2019
2060
  this.s[j] = new Computation(j, null, pureOptions);
2020
- return this.O(() => item, Computation.prototype.read.bind(this.s[j]));
2061
+ return this.P(() => item, Computation.prototype.read.bind(this.s[j]));
2021
2062
  } : () => {
2022
2063
  const item = newItems[j];
2023
- return this.O(() => item);
2064
+ return this.P(() => item);
2024
2065
  };
2025
2066
  if (newLen === 0) {
2026
2067
  if (this.q !== 0) {
2027
2068
  this.S.dispose(false);
2028
2069
  this.d = [];
2029
- this.D = [];
2070
+ this.F = [];
2030
2071
  this.i = [];
2031
2072
  this.q = 0;
2032
2073
  this.r && (this.r = []);
@@ -2044,17 +2085,17 @@ function updateKeyedMap() {
2044
2085
  this.d[0].dispose();
2045
2086
  this.i = new Array(newLen);
2046
2087
  for (j = 0; j < newLen; j++) {
2047
- this.D[j] = newItems[j];
2088
+ this.F[j] = newItems[j];
2048
2089
  this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2049
2090
  }
2050
2091
  this.q = newLen;
2051
2092
  } else {
2052
2093
  let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.r ? new Array(newLen) : void 0, tempIndexes = this.s ? new Array(newLen) : void 0;
2053
- for (start = 0, end = Math.min(this.q, newLen); start < end && (this.D[start] === newItems[start] || this.r && compare(this.P, this.D[start], newItems[start])); start++) {
2094
+ for (start = 0, end = Math.min(this.q, newLen); start < end && (this.F[start] === newItems[start] || this.r && compare(this.Q, this.F[start], newItems[start])); start++) {
2054
2095
  if (this.r)
2055
2096
  this.r[start].write(newItems[start]);
2056
2097
  }
2057
- for (end = this.q - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.r && compare(this.P, this.D[end], newItems[newEnd])); end--, newEnd--) {
2098
+ for (end = this.q - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.r && compare(this.Q, this.F[end], newItems[newEnd])); end--, newEnd--) {
2058
2099
  temp[newEnd] = this.i[end];
2059
2100
  tempNodes[newEnd] = this.d[end];
2060
2101
  tempRows && (tempRows[newEnd] = this.r[end]);
@@ -2064,14 +2105,14 @@ function updateKeyedMap() {
2064
2105
  newIndicesNext = new Array(newEnd + 1);
2065
2106
  for (j = newEnd; j >= start; j--) {
2066
2107
  item = newItems[j];
2067
- key = this.P ? this.P(item) : item;
2108
+ key = this.Q ? this.Q(item) : item;
2068
2109
  i = newIndices.get(key);
2069
2110
  newIndicesNext[j] = i === void 0 ? -1 : i;
2070
2111
  newIndices.set(key, j);
2071
2112
  }
2072
2113
  for (i = start; i <= end; i++) {
2073
- item = this.D[i];
2074
- key = this.P ? this.P(item) : item;
2114
+ item = this.F[i];
2115
+ key = this.Q ? this.Q(item) : item;
2075
2116
  j = newIndices.get(key);
2076
2117
  if (j !== void 0 && j !== -1) {
2077
2118
  temp[j] = this.i[i];
@@ -2100,7 +2141,7 @@ function updateKeyedMap() {
2100
2141
  }
2101
2142
  }
2102
2143
  this.i = this.i.slice(0, this.q = newLen);
2103
- this.D = newItems.slice(0);
2144
+ this.F = newItems.slice(0);
2104
2145
  }
2105
2146
  });
2106
2147
  return this.i;
@@ -2109,9 +2150,9 @@ function repeat(count, map, options) {
2109
2150
  return updateRepeat.bind({
2110
2151
  S: new Owner(),
2111
2152
  q: 0,
2112
- z: 0,
2153
+ A: 0,
2113
2154
  ja: count,
2114
- O: map,
2155
+ P: map,
2115
2156
  d: [],
2116
2157
  i: [],
2117
2158
  ka: options?.from,
@@ -2139,20 +2180,20 @@ function updateRepeat() {
2139
2180
  return;
2140
2181
  }
2141
2182
  const to = from + newLen;
2142
- const prevTo = this.z + this.q;
2183
+ const prevTo = this.A + this.q;
2143
2184
  if (this.q === 0 && this.d[0])
2144
2185
  this.d[0].dispose();
2145
2186
  for (let i = to; i < prevTo; i++)
2146
- this.d[i - this.z].dispose();
2147
- if (this.z < from) {
2148
- let i = this.z;
2187
+ this.d[i - this.A].dispose();
2188
+ if (this.A < from) {
2189
+ let i = this.A;
2149
2190
  while (i < from && i < this.q)
2150
2191
  this.d[i++].dispose();
2151
- this.d.splice(0, from - this.z);
2152
- this.i.splice(0, from - this.z);
2153
- } else if (this.z > from) {
2154
- let i = prevTo - this.z - 1;
2155
- let difference = this.z - from;
2192
+ this.d.splice(0, from - this.A);
2193
+ this.i.splice(0, from - this.A);
2194
+ } else if (this.A > from) {
2195
+ let i = prevTo - this.A - 1;
2196
+ let difference = this.A - from;
2156
2197
  this.d.length = this.i.length = newLen;
2157
2198
  while (i >= difference) {
2158
2199
  this.d[i] = this.d[i - difference];
@@ -2162,7 +2203,7 @@ function updateRepeat() {
2162
2203
  for (let i2 = 0; i2 < difference; i2++) {
2163
2204
  this.i[i2] = compute(
2164
2205
  this.d[i2] = new Owner(),
2165
- () => this.O(i2 + from),
2206
+ () => this.P(i2 + from),
2166
2207
  null
2167
2208
  );
2168
2209
  }
@@ -2170,12 +2211,12 @@ function updateRepeat() {
2170
2211
  for (let i = prevTo; i < to; i++) {
2171
2212
  this.i[i - from] = compute(
2172
2213
  this.d[i - from] = new Owner(),
2173
- () => this.O(i),
2214
+ () => this.P(i),
2174
2215
  null
2175
2216
  );
2176
2217
  }
2177
2218
  this.i = this.i.slice(0, newLen);
2178
- this.z = from;
2219
+ this.A = from;
2179
2220
  this.q = newLen;
2180
2221
  });
2181
2222
  return this.i;
@@ -2254,12 +2295,12 @@ var ConditionalQueue = class extends Queue {
2254
2295
  }
2255
2296
  };
2256
2297
  var CollectionQueue = class extends Queue {
2257
- F;
2298
+ I;
2258
2299
  d = /* @__PURE__ */ new Set();
2259
2300
  u = new Computation(false, null, { pureWrite: true });
2260
2301
  constructor(type) {
2261
2302
  super();
2262
- this.F = type;
2303
+ this.I = type;
2263
2304
  }
2264
2305
  run(type) {
2265
2306
  if (!type || this.u.read())
@@ -2269,9 +2310,9 @@ var CollectionQueue = class extends Queue {
2269
2310
  notify(node, type, flags) {
2270
2311
  if (ActiveTransition && ActiveTransition.p.has(this))
2271
2312
  return ActiveTransition.p.get(this).notify(node, type, flags);
2272
- if (!(type & this.F))
2313
+ if (!(type & this.I))
2273
2314
  return super.notify(node, type, flags);
2274
- if (flags & this.F) {
2315
+ if (flags & this.I) {
2275
2316
  this.d.add(node);
2276
2317
  if (this.d.size === 1)
2277
2318
  this.u.write(true);
@@ -2280,11 +2321,11 @@ var CollectionQueue = class extends Queue {
2280
2321
  if (this.d.size === 0)
2281
2322
  this.u.write(false);
2282
2323
  }
2283
- type &= ~this.F;
2324
+ type &= ~this.I;
2284
2325
  return type ? super.notify(node, type, flags) : true;
2285
2326
  }
2286
2327
  merge(queue) {
2287
- queue.d.forEach((n) => this.notify(n, this.F, this.F));
2328
+ queue.d.forEach((n) => this.notify(n, this.I, this.I));
2288
2329
  super.merge(queue);
2289
2330
  }
2290
2331
  };
@@ -2326,13 +2367,13 @@ function createSuspense(fn, fallback) {
2326
2367
  function createErrorBoundary(fn, fallback) {
2327
2368
  return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2328
2369
  let node = getTransitionSource(queue.d.values().next().value);
2329
- return fallback(node.J, () => {
2370
+ return fallback(node.L, () => {
2330
2371
  incrementClock();
2331
2372
  for (let node2 of queue.d) {
2332
2373
  if (ActiveTransition && !node2.e)
2333
2374
  node2 = cloneGraph(node2);
2334
2375
  node2.c = STATE_DIRTY;
2335
- node2.m?.enqueue(node2.B, node2.C.bind(node2));
2376
+ node2.m?.enqueue(node2.C, node2.E.bind(node2));
2336
2377
  }
2337
2378
  });
2338
2379
  });
@@ -2392,4 +2433,4 @@ function flattenArray(children, results = [], options) {
2392
2433
  return needsUnwrap;
2393
2434
  }
2394
2435
 
2395
- export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithObserver, runWithOwner, setContext, snapshot, transition, tryCatch, untrack };
2436
+ export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithObserver, runWithOwner, setContext, snapshot, transition, untrack, useTransition };