@solidjs/signals 0.4.4 → 0.4.6

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
@@ -39,7 +39,7 @@ function incrementClock() {
39
39
  clock++;
40
40
  }
41
41
  var ActiveTransition = null;
42
- var unobserved = [];
42
+ var Unobserved = [];
43
43
  var scheduled = false;
44
44
  function schedule() {
45
45
  if (scheduled)
@@ -49,12 +49,12 @@ function schedule() {
49
49
  queueMicrotask(flush);
50
50
  }
51
51
  function notifyUnobserved() {
52
- for (let i = 0; i < unobserved.length; i++) {
53
- const source = unobserved[i];
54
- if (!source.d || !source.d.length)
55
- unobserved[i].da?.();
52
+ for (let i = 0; i < Unobserved.length; i++) {
53
+ const source = Unobserved[i];
54
+ if (!source.b || !source.b.length)
55
+ Unobserved[i].da?.();
56
56
  }
57
- unobserved = [];
57
+ Unobserved = [];
58
58
  }
59
59
  var pureQueue = [];
60
60
  var Queue = class {
@@ -64,8 +64,8 @@ var Queue = class {
64
64
  e = [];
65
65
  created = clock;
66
66
  enqueue(type, fn) {
67
- if (ActiveTransition && ActiveTransition.w.has(this))
68
- return ActiveTransition.w.get(this).enqueue(type, fn);
67
+ if (ActiveTransition && ActiveTransition.u.has(this))
68
+ return ActiveTransition.u.get(this).enqueue(type, fn);
69
69
  pureQueue.push(fn);
70
70
  if (type)
71
71
  this.f[type - 1].push(fn);
@@ -97,7 +97,7 @@ var Queue = class {
97
97
  this.run(EFFECT_USER);
98
98
  } finally {
99
99
  this.z = false;
100
- unobserved.length && notifyUnobserved();
100
+ Unobserved.length && notifyUnobserved();
101
101
  }
102
102
  }
103
103
  addChild(child) {
@@ -110,8 +110,8 @@ var Queue = class {
110
110
  this.e.splice(index, 1);
111
111
  }
112
112
  notify(...args) {
113
- if (ActiveTransition && ActiveTransition.w.has(this))
114
- return ActiveTransition.w.get(this).notify(...args);
113
+ if (ActiveTransition && ActiveTransition.u.has(this))
114
+ return ActiveTransition.u.get(this).notify(...args);
115
115
  if (this.m)
116
116
  return this.m.notify(...args);
117
117
  return false;
@@ -120,7 +120,7 @@ var Queue = class {
120
120
  this.f[0].push.apply(this.f[0], queue.f[0]);
121
121
  this.f[1].push.apply(this.f[1], queue.f[1]);
122
122
  for (let i = 0; i < queue.e.length; i++) {
123
- const og = this.e.find((c) => c.j === queue.e[i].j);
123
+ const og = this.e.find((c) => c.g === queue.e[i].g);
124
124
  if (og)
125
125
  og.merge(queue.e[i]);
126
126
  else
@@ -140,12 +140,12 @@ function runQueue(queue, type) {
140
140
  }
141
141
  var Transition = class _Transition {
142
142
  a = /* @__PURE__ */ new Map();
143
- t = /* @__PURE__ */ new Set();
144
- Q = /* @__PURE__ */ new Set();
143
+ s = /* @__PURE__ */ new Set();
144
+ R = /* @__PURE__ */ new Set();
145
145
  W = /* @__PURE__ */ new Set();
146
146
  I = false;
147
147
  f = [[], []];
148
- w = /* @__PURE__ */ new Map();
148
+ u = /* @__PURE__ */ new Map();
149
149
  E = [];
150
150
  e = [];
151
151
  m = null;
@@ -153,9 +153,9 @@ var Transition = class _Transition {
153
153
  X = false;
154
154
  created = clock;
155
155
  constructor() {
156
- this.w.set(globalQueue, this);
156
+ this.u.set(globalQueue, this);
157
157
  for (const child of globalQueue.e) {
158
- cloneQueue(child, this, this.w);
158
+ cloneQueue(child, this, this.u);
159
159
  }
160
160
  }
161
161
  enqueue(type, fn) {
@@ -208,9 +208,9 @@ var Transition = class _Transition {
208
208
  if (!(type & LOADING_BIT))
209
209
  return false;
210
210
  if (flags & LOADING_BIT) {
211
- this.t.add(node);
211
+ this.s.add(node);
212
212
  } else {
213
- this.t.delete(node);
213
+ this.s.delete(node);
214
214
  }
215
215
  return true;
216
216
  }
@@ -219,7 +219,7 @@ var Transition = class _Transition {
219
219
  this.f[1].push.apply(this.f[1], queue.f[1]);
220
220
  this.E.push.apply(this.E, queue.E);
221
221
  for (let i = 0; i < queue.e.length; i++) {
222
- const og = this.e.find((c) => c.j === queue.e[i].j);
222
+ const og = this.e.find((c) => c.g === queue.e[i].g);
223
223
  if (og)
224
224
  og.merge(queue.e[i]);
225
225
  else
@@ -247,9 +247,9 @@ var Transition = class _Transition {
247
247
  const result = fn();
248
248
  const transition2 = ActiveTransition;
249
249
  if (result instanceof Promise) {
250
- transition2.Q.add(result);
250
+ transition2.R.add(result);
251
251
  result.finally(() => {
252
- transition2.Q.delete(result);
252
+ transition2.R.delete(result);
253
253
  finishTransition(transition2);
254
254
  });
255
255
  }
@@ -260,12 +260,12 @@ var Transition = class _Transition {
260
260
  }
261
261
  }
262
262
  addOptimistic(fn) {
263
- if (fn.k && fn.k !== this) {
264
- mergeTransitions(fn.k, this);
265
- ActiveTransition = fn.k;
263
+ if (fn.l && fn.l !== this) {
264
+ mergeTransitions(fn.l, this);
265
+ ActiveTransition = fn.l;
266
266
  return;
267
267
  }
268
- fn.k = this;
268
+ fn.l = this;
269
269
  this.W.add(fn);
270
270
  }
271
271
  };
@@ -274,51 +274,59 @@ function transition(fn) {
274
274
  queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
275
275
  }
276
276
  function cloneGraph(node) {
277
- if (node.k) {
278
- if (node.k !== ActiveTransition) {
279
- mergeTransitions(node.k, ActiveTransition);
280
- ActiveTransition = node.k;
277
+ if (node.l) {
278
+ if (node.l !== ActiveTransition) {
279
+ mergeTransitions(node.l, ActiveTransition);
280
+ ActiveTransition = node.l;
281
281
  }
282
- return node.k.a.get(node);
282
+ return node.l.a.get(node);
283
283
  }
284
284
  const clone = Object.create(Object.getPrototypeOf(node));
285
- Object.assign(clone, node, { n: null, s: null, j: node });
285
+ Object.assign(clone, node, {
286
+ n: null,
287
+ r: null,
288
+ b: null,
289
+ a: node.a ? [...node.a] : null,
290
+ g: node
291
+ });
286
292
  ActiveTransition.a.set(node, clone);
287
- node.k = ActiveTransition;
288
- if (node.d) {
289
- for (let i = 0, length = node.d.length; i < length; i++) {
290
- const o = node.d[i];
291
- node.d.push(cloneGraph(o));
293
+ node.l = ActiveTransition;
294
+ if (node.a) {
295
+ for (let i = 0; i < node.a.length; i++)
296
+ node.a[i].b.push(clone);
297
+ }
298
+ if (node.b) {
299
+ clone.b = [];
300
+ for (let i = 0, length = node.b.length; i < length; i++) {
301
+ !node.b[i].g && clone.b.push(cloneGraph(node.b[i]));
292
302
  }
293
303
  }
294
304
  return clone;
295
305
  }
296
- function removeSourceObservers(node, index) {
306
+ function replaceSourceObservers(node, transition2) {
297
307
  let source;
308
+ let transitionSource;
298
309
  let swap;
299
- for (let i = index; i < node.a.length; i++) {
300
- source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
301
- if (source.d) {
302
- if ((swap = source.d.indexOf(node)) !== -1) {
303
- source.d[swap] = source.d[source.d.length - 1];
304
- source.d.pop();
305
- }
306
- if (!source.d.length)
307
- unobserved.push(source);
310
+ for (let i = 0; i < node.a.length; i++) {
311
+ transitionSource = transition2.a.get(node.a[i]);
312
+ source = transitionSource || node.a[i];
313
+ if (source.b && (swap = source.b.indexOf(node)) !== -1) {
314
+ source.b[swap] = transitionSource ? node.g : source.b[source.b.length - 1];
315
+ !transitionSource && source.b.pop();
308
316
  }
309
317
  }
310
318
  }
311
319
  function cloneQueue(queue, parent, clonedQueues) {
312
320
  const clone = Object.create(Object.getPrototypeOf(queue));
313
321
  Object.assign(clone, queue, {
314
- j: queue,
322
+ g: queue,
315
323
  m: parent,
316
324
  e: [],
317
325
  enqueue(type, fn) {
318
326
  ActiveTransition?.enqueue(type, fn);
319
327
  },
320
328
  notify(node, type, flags) {
321
- node = node.j || node;
329
+ node = node.g || node;
322
330
  if (!clone.F || type & LOADING_BIT) {
323
331
  type &= ~LOADING_BIT;
324
332
  ActiveTransition?.notify(node, LOADING_BIT, flags);
@@ -336,7 +344,7 @@ function cloneQueue(queue, parent, clonedQueues) {
336
344
  }
337
345
  function resolveQueues(children) {
338
346
  for (const child of children) {
339
- const og = child.j;
347
+ const og = child.g;
340
348
  if (og) {
341
349
  const clonedChildren = child.e;
342
350
  delete child.enqueue;
@@ -344,50 +352,50 @@ function resolveQueues(children) {
344
352
  delete child.m;
345
353
  delete child.e;
346
354
  Object.assign(og, child);
347
- delete og.j;
355
+ delete og.g;
348
356
  resolveQueues(clonedChildren);
349
- } else if (child.m.j) {
350
- child.m.j.addChild(child);
357
+ } else if (child.m.g) {
358
+ child.m.g.addChild(child);
351
359
  }
352
360
  }
353
361
  }
354
362
  function mergeTransitions(t1, t2) {
355
363
  t2.a.forEach((value, key) => {
356
- key.k = t1;
364
+ key.l = t1;
357
365
  t1.a.set(key, value);
358
366
  });
359
367
  t2.W.forEach((c) => {
360
- c.k = t1;
368
+ c.l = t1;
361
369
  t1.W.add(c);
362
370
  });
363
- t2.Q.forEach((p) => t1.Q.add(p));
364
- t2.t.forEach((n) => t1.t.add(n));
371
+ t2.R.forEach((p) => t1.R.add(p));
372
+ t2.s.forEach((n) => t1.s.add(n));
365
373
  t1.merge(t2);
366
374
  t2.I = t1;
367
375
  }
368
376
  function finishTransition(transition2) {
369
- if (transition2.I || transition2.X || transition2.Q.size || transition2.t.size)
377
+ if (transition2.I || transition2.X || transition2.R.size || transition2.s.size)
370
378
  return;
371
379
  for (const [source, clone] of transition2.a) {
372
- if (source === clone || source.k !== transition2)
380
+ if (source === clone || source.l !== transition2)
373
381
  continue;
374
382
  if (clone.a)
375
- removeSourceObservers(clone, 0);
383
+ replaceSourceObservers(clone, transition2);
376
384
  source.dispose(false);
377
385
  source.emptyDisposal();
378
386
  Object.assign(source, clone);
379
- delete source.j;
380
- delete source.k;
387
+ delete source.g;
388
+ delete source.l;
381
389
  }
382
390
  globalQueue.f[0].push.apply(globalQueue.f[0], transition2.f[0]);
383
391
  globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
384
392
  resolveQueues(transition2.e);
385
393
  transition2.I = true;
386
- globalQueue.flush();
387
394
  for (const reset of transition2.W) {
388
- delete reset.k;
395
+ delete reset.l;
389
396
  reset();
390
397
  }
398
+ globalQueue.flush();
391
399
  }
392
400
 
393
401
  // src/core/owner.ts
@@ -406,12 +414,12 @@ var Owner = class {
406
414
  // However, the children are actually added in reverse creation order
407
415
  // See comment at the top of the file for an example of the _nextSibling traversal
408
416
  m = null;
409
- s = null;
417
+ r = null;
410
418
  B = null;
411
- b = STATE_CLEAN;
419
+ c = STATE_CLEAN;
412
420
  n = null;
413
- x = defaultContext;
414
- l = globalQueue;
421
+ w = defaultContext;
422
+ k = globalQueue;
415
423
  ea = 0;
416
424
  id = null;
417
425
  constructor(id = null, skipAppend = false) {
@@ -423,27 +431,27 @@ var Owner = class {
423
431
  append(child) {
424
432
  child.m = this;
425
433
  child.B = this;
426
- if (this.s)
427
- this.s.B = child;
428
- child.s = this.s;
429
- this.s = child;
434
+ if (this.r)
435
+ this.r.B = child;
436
+ child.r = this.r;
437
+ this.r = child;
430
438
  if (this.id != null && child.id == null)
431
439
  child.id = this.getNextChildId();
432
- if (child.x !== this.x) {
433
- child.x = { ...this.x, ...child.x };
440
+ if (child.w !== this.w) {
441
+ child.w = { ...this.w, ...child.w };
434
442
  }
435
- if (this.l)
436
- child.l = this.l;
443
+ if (this.k)
444
+ child.k = this.k;
437
445
  }
438
446
  dispose(self = true) {
439
- if (this.b === STATE_DISPOSED)
447
+ if (this.c === STATE_DISPOSED)
440
448
  return;
441
- let head = self ? this.B || this.m : this, current = this.s, next = null;
449
+ let head = self ? this.B || this.m : this, current = this.r, next = null;
442
450
  while (current && current.m === this) {
443
451
  current.dispose(true);
444
452
  current.J();
445
- next = current.s;
446
- current.s = null;
453
+ next = current.r;
454
+ current.r = null;
447
455
  current = next;
448
456
  }
449
457
  this.ea = 0;
@@ -452,15 +460,15 @@ var Owner = class {
452
460
  if (current)
453
461
  current.B = !self ? this : this.B;
454
462
  if (head)
455
- head.s = current;
463
+ head.r = current;
456
464
  }
457
465
  J() {
458
466
  if (this.B)
459
- this.B.s = null;
467
+ this.B.r = null;
460
468
  this.m = null;
461
469
  this.B = null;
462
- this.x = defaultContext;
463
- this.b = STATE_DISPOSED;
470
+ this.w = defaultContext;
471
+ this.c = STATE_DISPOSED;
464
472
  this.emptyDisposal();
465
473
  }
466
474
  emptyDisposal() {
@@ -489,7 +497,7 @@ function getContext(context, owner = currentOwner) {
489
497
  if (!owner) {
490
498
  throw new NoOwnerError();
491
499
  }
492
- const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue;
500
+ const value = hasContext(context, owner) ? owner.w[context.id] : context.defaultValue;
493
501
  if (isUndefined(value)) {
494
502
  throw new ContextNotFoundError();
495
503
  }
@@ -499,13 +507,13 @@ function setContext(context, value, owner = currentOwner) {
499
507
  if (!owner) {
500
508
  throw new NoOwnerError();
501
509
  }
502
- owner.x = {
503
- ...owner.x,
510
+ owner.w = {
511
+ ...owner.w,
504
512
  [context.id]: isUndefined(value) ? context.defaultValue : value
505
513
  };
506
514
  }
507
515
  function hasContext(context, owner = currentOwner) {
508
- return !isUndefined(owner?.x[context.id]);
516
+ return !isUndefined(owner?.w[context.id]);
509
517
  }
510
518
  function onCleanup(fn) {
511
519
  if (!currentOwner)
@@ -543,10 +551,10 @@ function getObserver() {
543
551
  var UNCHANGED = Symbol(0);
544
552
  var Computation = class extends Owner {
545
553
  a = null;
546
- d = null;
547
- i;
548
- R;
554
+ b = null;
555
+ j;
549
556
  K;
557
+ L;
550
558
  // Used in __DEV__ mode, hopefully removed in production
551
559
  ka;
552
560
  // Using false is an optimization as an alternative to _equals: () => false
@@ -558,16 +566,16 @@ var Computation = class extends Owner {
558
566
  h = 0;
559
567
  /** Which flags raised by sources are handled, vs. being passed through. */
560
568
  aa = DEFAULT_FLAGS;
561
- L = -1;
569
+ M = -1;
562
570
  G = false;
563
- k;
564
- j;
571
+ l;
572
+ g;
565
573
  constructor(initialValue, compute2, options) {
566
574
  super(options?.id, compute2 === null);
567
- this.K = compute2;
568
- this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
575
+ this.L = compute2;
576
+ this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
569
577
  this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
570
- this.i = initialValue;
578
+ this.j = initialValue;
571
579
  if (options?.equals !== void 0)
572
580
  this.$ = options.equals;
573
581
  if (options?.pureWrite)
@@ -575,7 +583,7 @@ var Computation = class extends Owner {
575
583
  if (options?.unobserved)
576
584
  this.da = options?.unobserved;
577
585
  if (ActiveTransition) {
578
- this.k = ActiveTransition;
586
+ this.l = ActiveTransition;
579
587
  ActiveTransition.a.set(this, this);
580
588
  }
581
589
  }
@@ -583,9 +591,9 @@ var Computation = class extends Owner {
583
591
  track(this);
584
592
  newFlags |= this.h & ~currentMask;
585
593
  if (this.h & ERROR_BIT) {
586
- throw this.R;
594
+ throw this.K;
587
595
  } else {
588
- return this.i;
596
+ return this.j;
589
597
  }
590
598
  }
591
599
  /**
@@ -593,13 +601,13 @@ var Computation = class extends Owner {
593
601
  * Automatically re-executes the surrounding computation when the value changes
594
602
  */
595
603
  read() {
596
- if (ActiveTransition && ActiveTransition.a.has(this)) {
597
- const clone = ActiveTransition.a.get(this);
604
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
605
+ const clone = ActiveTransition.a.get(this) || cloneGraph(this);
598
606
  if (clone !== this)
599
607
  return clone.read();
600
608
  }
601
- if (this.K) {
602
- if (this.h & ERROR_BIT && this.L <= clock)
609
+ if (this.L) {
610
+ if (this.h & ERROR_BIT && this.M <= clock)
603
611
  update(this);
604
612
  else
605
613
  this.H();
@@ -614,13 +622,13 @@ var Computation = class extends Owner {
614
622
  * before continuing
615
623
  */
616
624
  wait() {
617
- if (ActiveTransition && ActiveTransition.a.has(this)) {
618
- const clone = ActiveTransition.a.get(this);
625
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
626
+ const clone = ActiveTransition.a.get(this) || cloneGraph(this);
619
627
  if (clone !== this)
620
628
  return clone.wait();
621
629
  }
622
- if (this.K) {
623
- if (this.h & ERROR_BIT && this.L <= clock)
630
+ if (this.L) {
631
+ if (this.h & ERROR_BIT && this.M <= clock)
624
632
  update(this);
625
633
  else
626
634
  this.H();
@@ -630,54 +638,49 @@ var Computation = class extends Owner {
630
638
  throw new NotReadyError();
631
639
  }
632
640
  if (staleCheck && this.h & LOADING_BIT) {
633
- staleCheck.i = true;
641
+ staleCheck.j = true;
634
642
  }
635
643
  return this.fa();
636
644
  }
637
645
  /** Update the computation with a new value. */
638
646
  write(value, flags = 0, raw = false) {
639
- if (ActiveTransition && !this.j) {
647
+ if (ActiveTransition && !this.g) {
640
648
  const clone = cloneGraph(this);
641
649
  if (clone !== this)
642
650
  return clone.write(value, flags, raw);
643
651
  }
644
- const newValue = !raw && typeof value === "function" ? value(this.i) : value;
652
+ const newValue = !raw && typeof value === "function" ? value(this.j) : value;
645
653
  const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
646
- this.$ === false || !this.$(this.i, newValue));
654
+ this.$ === false || !this.$(this.j, newValue));
647
655
  if (valueChanged) {
648
- this.i = newValue;
649
- this.R = void 0;
656
+ this.j = newValue;
657
+ this.K = void 0;
650
658
  }
651
659
  const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
652
660
  this.h = flags;
653
- this.L = clock + 1;
654
- if (this.d) {
655
- for (let i = 0; i < this.d.length; i++) {
661
+ this.M = clock + 1;
662
+ if (this.b) {
663
+ for (let i = 0; i < this.b.length; i++) {
656
664
  if (valueChanged) {
657
- this.d[i].o(STATE_DIRTY);
665
+ this.b[i].x(STATE_DIRTY);
658
666
  } else if (changedFlagsMask) {
659
- this.d[i].Y(changedFlagsMask, changedFlags);
667
+ this.b[i].Y(changedFlagsMask, changedFlags);
660
668
  }
661
669
  }
662
670
  }
663
- return this.i;
671
+ return this.j;
664
672
  }
665
673
  /**
666
674
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
667
675
  */
668
- o(state, skipQueue) {
669
- if (ActiveTransition && ActiveTransition.a.has(this)) {
670
- const clone = ActiveTransition.a.get(this);
671
- if (clone !== this)
672
- return clone.o(state, skipQueue);
673
- }
674
- if (this.b >= state && !this.G)
676
+ x(state, skipQueue) {
677
+ if (this.c >= state && !this.G)
675
678
  return;
676
679
  this.G = !!skipQueue;
677
- this.b = state;
678
- if (this.d) {
679
- for (let i = 0; i < this.d.length; i++) {
680
- this.d[i].o(STATE_CHECK, skipQueue);
680
+ this.c = state;
681
+ if (this.b) {
682
+ for (let i = 0; i < this.b.length; i++) {
683
+ this.b[i].x(STATE_CHECK, skipQueue);
681
684
  }
682
685
  }
683
686
  }
@@ -688,34 +691,34 @@ var Computation = class extends Owner {
688
691
  * @param newFlags The source's new flags, masked to just the changed ones.
689
692
  */
690
693
  Y(mask, newFlags2) {
691
- if (this.b >= STATE_DIRTY)
694
+ if (this.c >= STATE_DIRTY)
692
695
  return;
693
696
  if (mask & this.aa) {
694
- this.o(STATE_DIRTY);
697
+ this.x(STATE_DIRTY);
695
698
  return;
696
699
  }
697
- if (this.b >= STATE_CHECK)
700
+ if (this.c >= STATE_CHECK)
698
701
  return;
699
702
  const prevFlags = this.h & mask;
700
703
  const deltaFlags = prevFlags ^ newFlags2;
701
704
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
702
- this.o(STATE_CHECK);
705
+ this.x(STATE_CHECK);
703
706
  } else {
704
707
  this.h ^= deltaFlags;
705
- if (this.d) {
706
- for (let i = 0; i < this.d.length; i++) {
707
- this.d[i].Y(mask, newFlags2);
708
+ if (this.b) {
709
+ for (let i = 0; i < this.b.length; i++) {
710
+ this.b[i].Y(mask, newFlags2);
708
711
  }
709
712
  }
710
713
  }
711
714
  }
712
- M(error) {
713
- if (ActiveTransition && !this.j) {
715
+ N(error) {
716
+ if (ActiveTransition && !this.g) {
714
717
  const clone = cloneGraph(this);
715
718
  if (clone !== this)
716
- return clone.M(error);
719
+ return clone.N(error);
717
720
  }
718
- this.R = error;
721
+ this.K = error;
719
722
  this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
720
723
  }
721
724
  /**
@@ -726,38 +729,38 @@ var Computation = class extends Owner {
726
729
  * This function will ensure that the value and states we read from the computation are up to date
727
730
  */
728
731
  H() {
729
- if (!this.K) {
732
+ if (!this.L) {
730
733
  return;
731
734
  }
732
- if (this.b === STATE_DISPOSED) {
735
+ if (this.c === STATE_DISPOSED) {
733
736
  return;
734
737
  }
735
- if (this.b === STATE_CLEAN) {
738
+ if (this.c === STATE_CLEAN) {
736
739
  return;
737
740
  }
738
741
  let observerFlags = 0;
739
- if (this.b === STATE_CHECK) {
742
+ if (this.c === STATE_CHECK) {
740
743
  for (let i = 0; i < this.a.length; i++) {
741
744
  const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
742
745
  source.H();
743
- observerFlags |= source.h;
744
- if (this.b === STATE_DIRTY) {
746
+ observerFlags |= source.h & ~UNINITIALIZED_BIT;
747
+ if (this.c === STATE_DIRTY) {
745
748
  break;
746
749
  }
747
750
  }
748
751
  }
749
- if (this.b === STATE_DIRTY) {
752
+ if (this.c === STATE_DIRTY) {
750
753
  update(this);
751
754
  } else {
752
755
  this.write(UNCHANGED, observerFlags);
753
- this.b = STATE_CLEAN;
756
+ this.c = STATE_CLEAN;
754
757
  }
755
758
  }
756
759
  /**
757
760
  * Remove ourselves from the owner graph and the computation graph
758
761
  */
759
762
  J() {
760
- if (this.b === STATE_DISPOSED)
763
+ if (this.c === STATE_DISPOSED)
761
764
  return;
762
765
  if (this.a)
763
766
  removeSourceObservers(this, 0);
@@ -765,8 +768,8 @@ var Computation = class extends Owner {
765
768
  }
766
769
  };
767
770
  function track(computation) {
768
- if (ActiveTransition && computation.j)
769
- computation = computation.j;
771
+ if (ActiveTransition && computation.g)
772
+ computation = computation.g;
770
773
  if (currentObserver) {
771
774
  if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
772
775
  newSourcesIndex++;
@@ -776,7 +779,7 @@ function track(computation) {
776
779
  newSources.push(computation);
777
780
  }
778
781
  if (updateCheck) {
779
- updateCheck.i = computation.L > currentObserver.L;
782
+ updateCheck.j = computation.M > currentObserver.M;
780
783
  }
781
784
  }
782
785
  }
@@ -788,13 +791,13 @@ function update(node) {
788
791
  try {
789
792
  node.dispose(false);
790
793
  node.emptyDisposal();
791
- const result = compute(node, node.K, node);
794
+ const result = compute(node, node.L, node);
792
795
  node.write(result, newFlags, true);
793
796
  } catch (error) {
794
797
  if (error instanceof NotReadyError) {
795
798
  node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
796
799
  } else {
797
- node.M(error);
800
+ node.N(error);
798
801
  }
799
802
  } finally {
800
803
  if (newSources) {
@@ -810,11 +813,11 @@ function update(node) {
810
813
  }
811
814
  let source;
812
815
  for (let i = newSourcesIndex; i < node.a.length; i++) {
813
- source = node.a[i];
814
- if (!source.d)
815
- source.d = [node];
816
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
817
+ if (!source.b)
818
+ source.b = [node];
816
819
  else
817
- source.d.push(node);
820
+ source.b.push(node);
818
821
  }
819
822
  } else if (node.a && newSourcesIndex < node.a.length) {
820
823
  removeSourceObservers(node, newSourcesIndex);
@@ -823,8 +826,23 @@ function update(node) {
823
826
  newSources = prevSources;
824
827
  newSourcesIndex = prevSourcesIndex;
825
828
  newFlags = prevFlags;
826
- node.L = clock + 1;
827
- node.b = STATE_CLEAN;
829
+ node.M = clock + 1;
830
+ node.c = STATE_CLEAN;
831
+ }
832
+ }
833
+ function removeSourceObservers(node, index) {
834
+ let source;
835
+ let swap;
836
+ for (let i = index; i < node.a.length; i++) {
837
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
838
+ if (source.b) {
839
+ if ((swap = source.b.indexOf(node)) !== -1) {
840
+ source.b[swap] = source.b[source.b.length - 1];
841
+ source.b.pop();
842
+ }
843
+ if (!source.b.length)
844
+ Unobserved.push(source);
845
+ }
828
846
  }
829
847
  }
830
848
  function isEqual(a, b) {
@@ -837,20 +855,20 @@ function untrack(fn) {
837
855
  }
838
856
  function hasUpdated(fn) {
839
857
  const current = updateCheck;
840
- updateCheck = { i: false };
858
+ updateCheck = { j: false };
841
859
  try {
842
860
  fn();
843
- return updateCheck.i;
861
+ return updateCheck.j;
844
862
  } finally {
845
863
  updateCheck = current;
846
864
  }
847
865
  }
848
866
  function pendingCheck(fn, loadingValue) {
849
867
  const current = staleCheck;
850
- staleCheck = { i: false };
868
+ staleCheck = { j: false };
851
869
  try {
852
870
  latest(fn);
853
- return staleCheck.i;
871
+ return staleCheck.j;
854
872
  } catch (err) {
855
873
  if (!(err instanceof NotReadyError))
856
874
  return false;
@@ -898,7 +916,7 @@ function runWithObserver(observer, run) {
898
916
  newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
899
917
  );
900
918
  } else {
901
- observer.M(error);
919
+ observer.N(error);
902
920
  }
903
921
  } finally {
904
922
  if (newSources) {
@@ -913,10 +931,10 @@ function runWithObserver(observer, run) {
913
931
  let source;
914
932
  for (let i = newSourcesIndex; i < observer.a.length; i++) {
915
933
  source = observer.a[i];
916
- if (!source.d)
917
- source.d = [observer];
934
+ if (!source.b)
935
+ source.b = [observer];
918
936
  else
919
- source.d.push(observer);
937
+ source.b.push(observer);
920
938
  }
921
939
  }
922
940
  newSources = prevSources;
@@ -930,7 +948,7 @@ function compute(owner, fn, observer) {
930
948
  currentMask = observer?.aa ?? DEFAULT_FLAGS;
931
949
  notStale = true;
932
950
  try {
933
- return fn(observer ? observer.i : void 0);
951
+ return fn.call(observer, observer ? observer.j : void 0);
934
952
  } finally {
935
953
  setOwner(prevOwner);
936
954
  currentObserver = prevObserver;
@@ -943,7 +961,7 @@ function compute(owner, fn, observer) {
943
961
  var Effect = class extends Computation {
944
962
  ba;
945
963
  Z;
946
- N;
964
+ O;
947
965
  ca = false;
948
966
  _;
949
967
  A;
@@ -954,89 +972,90 @@ var Effect = class extends Computation {
954
972
  this._ = initialValue;
955
973
  this.A = options?.render ? EFFECT_RENDER : EFFECT_USER;
956
974
  if (this.A === EFFECT_RENDER) {
957
- this.K = (p) => !ActiveTransition && clock > this.l.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
975
+ this.L = function(p) {
976
+ return !this.g && clock > this.k.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
977
+ };
958
978
  }
959
979
  this.H();
960
- !options?.defer && (this.A === EFFECT_USER ? this.l.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
980
+ !options?.defer && (this.A === EFFECT_USER ? this.k.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
961
981
  }
962
982
  write(value, flags = 0) {
963
- if (this.b == STATE_DIRTY) {
983
+ if (this.c == STATE_DIRTY) {
964
984
  this.h = flags;
965
985
  if (this.A === EFFECT_RENDER) {
966
- this.l.notify(this, LOADING_BIT | ERROR_BIT, flags);
986
+ this.k.notify(this, LOADING_BIT | ERROR_BIT, this.h);
967
987
  }
968
988
  }
969
989
  if (value === UNCHANGED)
970
- return this.i;
971
- this.i = value;
990
+ return this.j;
991
+ this.j = value;
972
992
  this.ca = true;
993
+ this.K = void 0;
973
994
  return value;
974
995
  }
975
- o(state, skipQueue) {
976
- if (ActiveTransition && ActiveTransition.a.has(this)) {
977
- return ActiveTransition.a.get(this).o(state, skipQueue);
978
- }
979
- if (this.b >= state || skipQueue)
996
+ x(state, skipQueue) {
997
+ if (this.c >= state || skipQueue)
980
998
  return;
981
- if (this.b === STATE_CLEAN)
982
- this.l.enqueue(this.A, this.C.bind(this));
983
- this.b = state;
999
+ if (this.c === STATE_CLEAN)
1000
+ this.k.enqueue(this.A, this.C.bind(this));
1001
+ this.c = state;
984
1002
  }
985
1003
  Y(mask, newFlags2) {
986
- if (ActiveTransition && ActiveTransition.a.has(this)) {
987
- if (this.b >= STATE_CHECK)
1004
+ if (this.g) {
1005
+ if (this.c >= STATE_DIRTY)
988
1006
  return;
989
1007
  if (mask & 3) {
990
- this.o(STATE_DIRTY);
1008
+ this.x(STATE_DIRTY);
991
1009
  return;
992
1010
  }
993
1011
  }
994
1012
  super.Y(mask, newFlags2);
995
1013
  }
996
- M(error) {
997
- this.R = error;
998
- this.l.notify(this, LOADING_BIT, 0);
1014
+ N(error) {
1015
+ this.K = error;
1016
+ this.k.notify(this, LOADING_BIT, 0);
999
1017
  this.h = ERROR_BIT;
1000
1018
  if (this.A === EFFECT_USER) {
1001
1019
  try {
1002
1020
  return this.Z ? this.Z(error, () => {
1003
- this.N?.();
1004
- this.N = void 0;
1021
+ this.O?.();
1022
+ this.O = void 0;
1005
1023
  }) : console.error(error);
1006
1024
  } catch (e) {
1007
1025
  error = e;
1008
1026
  }
1009
1027
  }
1010
- if (!this.l.notify(this, ERROR_BIT, ERROR_BIT))
1028
+ if (!this.k.notify(this, ERROR_BIT, ERROR_BIT))
1011
1029
  throw error;
1012
1030
  }
1013
1031
  J() {
1014
- if (this.b === STATE_DISPOSED)
1032
+ if (this.c === STATE_DISPOSED)
1015
1033
  return;
1016
1034
  this.ba = void 0;
1017
1035
  this._ = void 0;
1018
1036
  this.Z = void 0;
1019
- this.N?.();
1020
- this.N = void 0;
1037
+ this.O?.();
1038
+ this.O = void 0;
1039
+ this.k.notify(this, ERROR_BIT | LOADING_BIT, 0);
1021
1040
  super.J();
1022
1041
  }
1023
1042
  C(type) {
1024
1043
  if (type) {
1025
- const effect = this.j || this;
1026
- if (effect.ca && effect.b !== STATE_DISPOSED) {
1027
- effect.N?.();
1044
+ const effect = this.g || this;
1045
+ if (effect.ca && effect.c !== STATE_DISPOSED) {
1046
+ effect.O?.();
1028
1047
  try {
1029
- effect.N = effect.ba(effect.i, effect._);
1048
+ effect.O = effect.ba(effect.j, effect._);
1030
1049
  } catch (e) {
1031
- if (!effect.l.notify(effect, ERROR_BIT, ERROR_BIT))
1050
+ if (!effect.k.notify(effect, ERROR_BIT, ERROR_BIT))
1032
1051
  throw e;
1033
1052
  } finally {
1034
- effect._ = effect.i;
1053
+ effect._ = effect.j;
1035
1054
  effect.ca = false;
1036
1055
  }
1037
1056
  }
1038
1057
  } else
1039
- this.b !== STATE_CLEAN && runTop(this);
1058
+ this.c !== STATE_CLEAN && runTop(this);
1040
1059
  }
1041
1060
  };
1042
1061
  var EagerComputation = class extends Computation {
@@ -1044,18 +1063,15 @@ var EagerComputation = class extends Computation {
1044
1063
  super(initialValue, compute2, options);
1045
1064
  !options?.defer && this.H();
1046
1065
  }
1047
- o(state, skipQueue) {
1048
- if (ActiveTransition && ActiveTransition.a.has(this)) {
1049
- return ActiveTransition.a.get(this).o(state, skipQueue);
1050
- }
1051
- if (this.b >= state && !this.G)
1066
+ x(state, skipQueue) {
1067
+ if (this.c >= state && !this.G)
1052
1068
  return;
1053
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.G))
1054
- this.l.enqueue(EFFECT_PURE, this.C.bind(this));
1055
- super.o(state, skipQueue);
1069
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1070
+ this.k.enqueue(EFFECT_PURE, this.C.bind(this));
1071
+ super.x(state, skipQueue);
1056
1072
  }
1057
1073
  C() {
1058
- this.b !== STATE_CLEAN && runTop(this);
1074
+ this.c !== STATE_CLEAN && runTop(this);
1059
1075
  }
1060
1076
  };
1061
1077
  var FirewallComputation = class extends Computation {
@@ -1063,30 +1079,27 @@ var FirewallComputation = class extends Computation {
1063
1079
  constructor(compute2) {
1064
1080
  super(void 0, compute2);
1065
1081
  }
1066
- o(state, skipQueue) {
1067
- if (ActiveTransition && ActiveTransition.a.has(this)) {
1068
- return ActiveTransition.a.get(this).o(state, skipQueue);
1069
- }
1070
- if (this.b >= state && !this.G)
1082
+ x(state, skipQueue) {
1083
+ if (this.c >= state && !this.G)
1071
1084
  return;
1072
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.G))
1073
- this.l.enqueue(EFFECT_PURE, this.C.bind(this));
1074
- super.o(state, true);
1085
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1086
+ this.k.enqueue(EFFECT_PURE, this.C.bind(this));
1087
+ super.x(state, true);
1075
1088
  this.G = !!skipQueue;
1076
1089
  }
1077
1090
  C() {
1078
- this.b !== STATE_CLEAN && runTop(this);
1091
+ this.c !== STATE_CLEAN && runTop(this);
1079
1092
  }
1080
1093
  };
1081
1094
  function runTop(node) {
1082
1095
  const ancestors = [];
1083
1096
  for (let current = node; current !== null; current = current.m) {
1084
- if (current.b !== STATE_CLEAN) {
1097
+ if (current.c !== STATE_CLEAN) {
1085
1098
  ancestors.push(current);
1086
1099
  }
1087
1100
  }
1088
1101
  for (let i = ancestors.length - 1; i >= 0; i--) {
1089
- if (ancestors[i].b !== STATE_DISPOSED)
1102
+ if (ancestors[i].c !== STATE_DISPOSED)
1090
1103
  ancestors[i].H();
1091
1104
  }
1092
1105
  }
@@ -1221,7 +1234,7 @@ var storeTraps = {
1221
1234
  return desc.get.call(receiver);
1222
1235
  }
1223
1236
  if (Writing?.has(receiver)) {
1224
- let value2 = tracked && (overridden || !proxySource) ? tracked.i : storeValue[property];
1237
+ let value2 = tracked && (overridden || !proxySource) ? tracked.j : storeValue[property];
1225
1238
  value2 === $DELETED && (value2 = void 0);
1226
1239
  if (!isWrappable(value2))
1227
1240
  return value2;
@@ -1512,6 +1525,8 @@ function applyState(next, state, keyFn, all) {
1512
1525
  }
1513
1526
  function reconcile(value, key, all = false) {
1514
1527
  return (state) => {
1528
+ if (state == null)
1529
+ throw new Error("Cannot reconcile null or undefined state");
1515
1530
  const keyFn = typeof key === "string" ? (item) => item[key] : key;
1516
1531
  const eq = keyFn(state);
1517
1532
  if (eq !== void 0 && keyFn(value) !== keyFn(state))
@@ -1751,12 +1766,12 @@ function createMemo(compute2, value, options) {
1751
1766
  let resolvedValue;
1752
1767
  return () => {
1753
1768
  if (node) {
1754
- if (node.b === STATE_DISPOSED) {
1769
+ if (node.c === STATE_DISPOSED) {
1755
1770
  node = void 0;
1756
1771
  return resolvedValue;
1757
1772
  }
1758
1773
  resolvedValue = node.wait();
1759
- if (!node.a?.length && node.s?.m !== node) {
1774
+ if (!node.a?.length && node.r?.m !== node && !(node.h & UNINITIALIZED_BIT)) {
1760
1775
  node.dispose();
1761
1776
  node = void 0;
1762
1777
  }
@@ -1792,8 +1807,8 @@ function createAsync(compute2, value, options) {
1792
1807
  if (abort)
1793
1808
  return;
1794
1809
  if (transition2)
1795
- return transition2.runTransition(() => node.M(error), true);
1796
- node.M(error);
1810
+ return transition2.runTransition(() => node.N(error), true);
1811
+ node.N(error);
1797
1812
  }
1798
1813
  );
1799
1814
  } else {
@@ -1817,9 +1832,13 @@ function createAsync(compute2, value, options) {
1817
1832
  );
1818
1833
  const read = node.wait.bind(node);
1819
1834
  read.refresh = () => {
1820
- node.b = STATE_DIRTY;
1835
+ let n = node;
1836
+ if (ActiveTransition && !node.g) {
1837
+ n = cloneGraph(node);
1838
+ }
1839
+ n.c = STATE_DIRTY;
1821
1840
  refreshing = true;
1822
- node.H();
1841
+ n.H();
1823
1842
  };
1824
1843
  return read;
1825
1844
  }
@@ -1900,7 +1919,7 @@ function createOptimistic(initial, compute2, key) {
1900
1919
  (s) => {
1901
1920
  const value = initial();
1902
1921
  if (!ActiveTransition)
1903
- s.value = value;
1922
+ reconcile({ value }, key)(s);
1904
1923
  },
1905
1924
  { value: void 0 }
1906
1925
  );
@@ -1908,9 +1927,9 @@ function createOptimistic(initial, compute2, key) {
1908
1927
  [store, setStore] = createStore({ value: initial });
1909
1928
  const reset = () => setStore(
1910
1929
  (s) => reconcile(
1911
- typeof initial === "function" ? initial() : initial,
1930
+ { value: typeof initial === "function" ? initial() : initial },
1912
1931
  key
1913
- )(s.value)
1932
+ )(s)
1914
1933
  );
1915
1934
  let lastChange = void 0;
1916
1935
  function write(v) {
@@ -1932,15 +1951,15 @@ function mapArray(list, map, options) {
1932
1951
  const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
1933
1952
  return updateKeyedMap.bind({
1934
1953
  S: new Owner(),
1935
- p: 0,
1954
+ o: 0,
1936
1955
  ha: list,
1937
1956
  D: [],
1938
- O: map,
1939
- g: [],
1940
- c: [],
1941
- P: keyFn,
1942
- q: keyFn || options?.keyed === false ? [] : void 0,
1943
- r: map.length > 1 ? [] : void 0,
1957
+ P: map,
1958
+ i: [],
1959
+ d: [],
1960
+ Q: keyFn,
1961
+ p: keyFn || options?.keyed === false ? [] : void 0,
1962
+ q: map.length > 1 ? [] : void 0,
1944
1963
  T: options?.fallback
1945
1964
  });
1946
1965
  }
@@ -1949,113 +1968,113 @@ function updateKeyedMap() {
1949
1968
  const newItems = this.ha() || [], newLen = newItems.length;
1950
1969
  newItems[$TRACK];
1951
1970
  runWithOwner(this.S, () => {
1952
- let i, j, mapper = this.q ? () => {
1953
- this.q[j] = new Computation(newItems[j], null, pureOptions);
1954
- this.r && (this.r[j] = new Computation(j, null, pureOptions));
1955
- return this.O(
1956
- Computation.prototype.read.bind(this.q[j]),
1957
- this.r ? Computation.prototype.read.bind(this.r[j]) : void 0
1971
+ let i, j, mapper = this.p ? () => {
1972
+ this.p[j] = new Computation(newItems[j], null, pureOptions);
1973
+ this.q && (this.q[j] = new Computation(j, null, pureOptions));
1974
+ return this.P(
1975
+ Computation.prototype.read.bind(this.p[j]),
1976
+ this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
1958
1977
  );
1959
- } : this.r ? () => {
1978
+ } : this.q ? () => {
1960
1979
  const item = newItems[j];
1961
- this.r[j] = new Computation(j, null, pureOptions);
1962
- return this.O(() => item, Computation.prototype.read.bind(this.r[j]));
1980
+ this.q[j] = new Computation(j, null, pureOptions);
1981
+ return this.P(() => item, Computation.prototype.read.bind(this.q[j]));
1963
1982
  } : () => {
1964
1983
  const item = newItems[j];
1965
- return this.O(() => item);
1984
+ return this.P(() => item);
1966
1985
  };
1967
1986
  if (newLen === 0) {
1968
- if (this.p !== 0) {
1987
+ if (this.o !== 0) {
1969
1988
  this.S.dispose(false);
1970
- this.c = [];
1989
+ this.d = [];
1971
1990
  this.D = [];
1972
- this.g = [];
1973
- this.p = 0;
1991
+ this.i = [];
1992
+ this.o = 0;
1993
+ this.p && (this.p = []);
1974
1994
  this.q && (this.q = []);
1975
- this.r && (this.r = []);
1976
1995
  }
1977
- if (this.T && !this.g[0]) {
1978
- this.g[0] = compute(
1979
- this.c[0] = new Owner(),
1996
+ if (this.T && !this.i[0]) {
1997
+ this.i[0] = compute(
1998
+ this.d[0] = new Owner(),
1980
1999
  this.T,
1981
2000
  null
1982
2001
  );
1983
2002
  }
1984
- } else if (this.p === 0) {
1985
- if (this.c[0])
1986
- this.c[0].dispose();
1987
- this.g = new Array(newLen);
2003
+ } else if (this.o === 0) {
2004
+ if (this.d[0])
2005
+ this.d[0].dispose();
2006
+ this.i = new Array(newLen);
1988
2007
  for (j = 0; j < newLen; j++) {
1989
2008
  this.D[j] = newItems[j];
1990
- this.g[j] = compute(this.c[j] = new Owner(), mapper, null);
2009
+ this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
1991
2010
  }
1992
- this.p = newLen;
2011
+ this.o = newLen;
1993
2012
  } else {
1994
- let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.q ? new Array(newLen) : void 0, tempIndexes = this.r ? new Array(newLen) : void 0;
1995
- for (start = 0, end = Math.min(this.p, newLen); start < end && (this.D[start] === newItems[start] || this.q && compare(this.P, this.D[start], newItems[start])); start++) {
1996
- if (this.q)
1997
- this.q[start].write(newItems[start]);
2013
+ 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;
2014
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.D[start] === newItems[start] || this.p && compare(this.Q, this.D[start], newItems[start])); start++) {
2015
+ if (this.p)
2016
+ this.p[start].write(newItems[start]);
1998
2017
  }
1999
- for (end = this.p - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.q && compare(this.P, this.D[end], newItems[newEnd])); end--, newEnd--) {
2000
- temp[newEnd] = this.g[end];
2001
- tempNodes[newEnd] = this.c[end];
2002
- tempRows && (tempRows[newEnd] = this.q[end]);
2003
- tempIndexes && (tempIndexes[newEnd] = this.r[end]);
2018
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.p && compare(this.Q, this.D[end], newItems[newEnd])); end--, newEnd--) {
2019
+ temp[newEnd] = this.i[end];
2020
+ tempNodes[newEnd] = this.d[end];
2021
+ tempRows && (tempRows[newEnd] = this.p[end]);
2022
+ tempIndexes && (tempIndexes[newEnd] = this.q[end]);
2004
2023
  }
2005
2024
  newIndices = /* @__PURE__ */ new Map();
2006
2025
  newIndicesNext = new Array(newEnd + 1);
2007
2026
  for (j = newEnd; j >= start; j--) {
2008
2027
  item = newItems[j];
2009
- key = this.P ? this.P(item) : item;
2028
+ key = this.Q ? this.Q(item) : item;
2010
2029
  i = newIndices.get(key);
2011
2030
  newIndicesNext[j] = i === void 0 ? -1 : i;
2012
2031
  newIndices.set(key, j);
2013
2032
  }
2014
2033
  for (i = start; i <= end; i++) {
2015
2034
  item = this.D[i];
2016
- key = this.P ? this.P(item) : item;
2035
+ key = this.Q ? this.Q(item) : item;
2017
2036
  j = newIndices.get(key);
2018
2037
  if (j !== void 0 && j !== -1) {
2019
- temp[j] = this.g[i];
2020
- tempNodes[j] = this.c[i];
2021
- tempRows && (tempRows[j] = this.q[i]);
2022
- tempIndexes && (tempIndexes[j] = this.r[i]);
2038
+ temp[j] = this.i[i];
2039
+ tempNodes[j] = this.d[i];
2040
+ tempRows && (tempRows[j] = this.p[i]);
2041
+ tempIndexes && (tempIndexes[j] = this.q[i]);
2023
2042
  j = newIndicesNext[j];
2024
2043
  newIndices.set(key, j);
2025
2044
  } else
2026
- this.c[i].dispose();
2045
+ this.d[i].dispose();
2027
2046
  }
2028
2047
  for (j = start; j < newLen; j++) {
2029
2048
  if (j in temp) {
2030
- this.g[j] = temp[j];
2031
- this.c[j] = tempNodes[j];
2049
+ this.i[j] = temp[j];
2050
+ this.d[j] = tempNodes[j];
2032
2051
  if (tempRows) {
2033
- this.q[j] = tempRows[j];
2034
- this.q[j].write(newItems[j]);
2052
+ this.p[j] = tempRows[j];
2053
+ this.p[j].write(newItems[j]);
2035
2054
  }
2036
2055
  if (tempIndexes) {
2037
- this.r[j] = tempIndexes[j];
2038
- this.r[j].write(j);
2056
+ this.q[j] = tempIndexes[j];
2057
+ this.q[j].write(j);
2039
2058
  }
2040
2059
  } else {
2041
- this.g[j] = compute(this.c[j] = new Owner(), mapper, null);
2060
+ this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2042
2061
  }
2043
2062
  }
2044
- this.g = this.g.slice(0, this.p = newLen);
2063
+ this.i = this.i.slice(0, this.o = newLen);
2045
2064
  this.D = newItems.slice(0);
2046
2065
  }
2047
2066
  });
2048
- return this.g;
2067
+ return this.i;
2049
2068
  }
2050
2069
  function repeat(count, map, options) {
2051
2070
  return updateRepeat.bind({
2052
2071
  S: new Owner(),
2053
- p: 0,
2072
+ o: 0,
2054
2073
  y: 0,
2055
2074
  ia: count,
2056
- O: map,
2057
- c: [],
2058
- g: [],
2075
+ P: map,
2076
+ d: [],
2077
+ i: [],
2059
2078
  ja: options?.from,
2060
2079
  T: options?.fallback
2061
2080
  });
@@ -2065,15 +2084,15 @@ function updateRepeat() {
2065
2084
  const from = this.ja?.() || 0;
2066
2085
  runWithOwner(this.S, () => {
2067
2086
  if (newLen === 0) {
2068
- if (this.p !== 0) {
2087
+ if (this.o !== 0) {
2069
2088
  this.S.dispose(false);
2070
- this.c = [];
2071
- this.g = [];
2072
- this.p = 0;
2089
+ this.d = [];
2090
+ this.i = [];
2091
+ this.o = 0;
2073
2092
  }
2074
- if (this.T && !this.g[0]) {
2075
- this.g[0] = compute(
2076
- this.c[0] = new Owner(),
2093
+ if (this.T && !this.i[0]) {
2094
+ this.i[0] = compute(
2095
+ this.d[0] = new Owner(),
2077
2096
  this.T,
2078
2097
  null
2079
2098
  );
@@ -2081,46 +2100,46 @@ function updateRepeat() {
2081
2100
  return;
2082
2101
  }
2083
2102
  const to = from + newLen;
2084
- const prevTo = this.y + this.p;
2085
- if (this.p === 0 && this.c[0])
2086
- this.c[0].dispose();
2103
+ const prevTo = this.y + this.o;
2104
+ if (this.o === 0 && this.d[0])
2105
+ this.d[0].dispose();
2087
2106
  for (let i = to; i < prevTo; i++)
2088
- this.c[i - this.y].dispose();
2107
+ this.d[i - this.y].dispose();
2089
2108
  if (this.y < from) {
2090
2109
  let i = this.y;
2091
- while (i < from && i < this.p)
2092
- this.c[i++].dispose();
2093
- this.c.splice(0, from - this.y);
2094
- this.g.splice(0, from - this.y);
2110
+ while (i < from && i < this.o)
2111
+ this.d[i++].dispose();
2112
+ this.d.splice(0, from - this.y);
2113
+ this.i.splice(0, from - this.y);
2095
2114
  } else if (this.y > from) {
2096
2115
  let i = prevTo - this.y - 1;
2097
2116
  let difference = this.y - from;
2098
- this.c.length = this.g.length = newLen;
2117
+ this.d.length = this.i.length = newLen;
2099
2118
  while (i >= difference) {
2100
- this.c[i] = this.c[i - difference];
2101
- this.g[i] = this.g[i - difference];
2119
+ this.d[i] = this.d[i - difference];
2120
+ this.i[i] = this.i[i - difference];
2102
2121
  i--;
2103
2122
  }
2104
2123
  for (let i2 = 0; i2 < difference; i2++) {
2105
- this.g[i2] = compute(
2106
- this.c[i2] = new Owner(),
2107
- () => this.O(i2 + from),
2124
+ this.i[i2] = compute(
2125
+ this.d[i2] = new Owner(),
2126
+ () => this.P(i2 + from),
2108
2127
  null
2109
2128
  );
2110
2129
  }
2111
2130
  }
2112
2131
  for (let i = prevTo; i < to; i++) {
2113
- this.g[i - from] = compute(
2114
- this.c[i - from] = new Owner(),
2115
- () => this.O(i),
2132
+ this.i[i - from] = compute(
2133
+ this.d[i - from] = new Owner(),
2134
+ () => this.P(i),
2116
2135
  null
2117
2136
  );
2118
2137
  }
2119
- this.g = this.g.slice(0, newLen);
2138
+ this.i = this.i.slice(0, newLen);
2120
2139
  this.y = from;
2121
- this.p = newLen;
2140
+ this.o = newLen;
2122
2141
  });
2123
- return this.g;
2142
+ return this.i;
2124
2143
  }
2125
2144
  function compare(key, a, b) {
2126
2145
  return key ? key(a) === key(b) : true;
@@ -2138,14 +2157,14 @@ var BoundaryComputation = class extends EagerComputation {
2138
2157
  if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT)) {
2139
2158
  flags &= ~LOADING_BIT;
2140
2159
  }
2141
- this.l.notify(this, this.U, flags);
2142
- return this.i;
2160
+ this.k.notify(this, this.U, flags);
2161
+ return this.j;
2143
2162
  }
2144
2163
  };
2145
2164
  function createBoundChildren(owner, fn, queue, mask) {
2146
- const parentQueue = owner.l;
2147
- parentQueue.addChild(owner.l = queue);
2148
- onCleanup(() => parentQueue.removeChild(owner.l));
2165
+ const parentQueue = owner.k;
2166
+ parentQueue.addChild(owner.k = queue);
2167
+ onCleanup(() => parentQueue.removeChild(owner.k));
2149
2168
  return compute(
2150
2169
  owner,
2151
2170
  () => {
@@ -2156,27 +2175,27 @@ function createBoundChildren(owner, fn, queue, mask) {
2156
2175
  );
2157
2176
  }
2158
2177
  var ConditionalQueue = class extends Queue {
2159
- u;
2178
+ t;
2160
2179
  V = /* @__PURE__ */ new Set();
2161
- t = /* @__PURE__ */ new Set();
2180
+ s = /* @__PURE__ */ new Set();
2162
2181
  constructor(disabled) {
2163
2182
  super();
2164
- this.u = disabled;
2183
+ this.t = disabled;
2165
2184
  }
2166
2185
  run(type) {
2167
- if (!type || this.u.read())
2186
+ if (!type || this.t.read())
2168
2187
  return;
2169
2188
  return super.run(type);
2170
2189
  }
2171
2190
  notify(node, type, flags) {
2172
- if (ActiveTransition && ActiveTransition.w.has(this))
2173
- return ActiveTransition.w.get(this).notify(node, type, flags);
2174
- if (this.u.read()) {
2191
+ if (ActiveTransition && ActiveTransition.u.has(this))
2192
+ return ActiveTransition.u.get(this).notify(node, type, flags);
2193
+ if (this.t.read()) {
2175
2194
  if (type & LOADING_BIT) {
2176
2195
  if (flags & LOADING_BIT) {
2177
- this.t.add(node);
2196
+ this.s.add(node);
2178
2197
  type &= ~LOADING_BIT;
2179
- } else if (this.t.delete(node))
2198
+ } else if (this.s.delete(node))
2180
2199
  type &= ~LOADING_BIT;
2181
2200
  }
2182
2201
  if (type & ERROR_BIT) {
@@ -2190,43 +2209,43 @@ var ConditionalQueue = class extends Queue {
2190
2209
  return type ? super.notify(node, type, flags) : true;
2191
2210
  }
2192
2211
  merge(queue) {
2193
- queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2212
+ queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2194
2213
  queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2195
2214
  super.merge(queue);
2196
2215
  }
2197
2216
  };
2198
2217
  var CollectionQueue = class extends Queue {
2199
2218
  F;
2200
- c = /* @__PURE__ */ new Set();
2201
- u = new Computation(false, null, { pureWrite: true });
2219
+ d = /* @__PURE__ */ new Set();
2220
+ t = new Computation(false, null, { pureWrite: true });
2202
2221
  constructor(type) {
2203
2222
  super();
2204
2223
  this.F = type;
2205
2224
  }
2206
2225
  run(type) {
2207
- if (!type || this.u.read())
2226
+ if (!type || this.t.read())
2208
2227
  return;
2209
2228
  return super.run(type);
2210
2229
  }
2211
2230
  notify(node, type, flags) {
2212
- if (ActiveTransition && ActiveTransition.w.has(this))
2213
- return ActiveTransition.w.get(this).notify(node, type, flags);
2231
+ if (ActiveTransition && ActiveTransition.u.has(this))
2232
+ return ActiveTransition.u.get(this).notify(node, type, flags);
2214
2233
  if (!(type & this.F))
2215
2234
  return super.notify(node, type, flags);
2216
2235
  if (flags & this.F) {
2217
- this.c.add(node);
2218
- if (this.c.size === 1)
2219
- this.u.write(true);
2236
+ this.d.add(node);
2237
+ if (this.d.size === 1)
2238
+ this.t.write(true);
2220
2239
  } else {
2221
- this.c.delete(node);
2222
- if (this.c.size === 0)
2223
- this.u.write(false);
2240
+ this.d.delete(node);
2241
+ if (this.d.size === 0)
2242
+ this.t.write(false);
2224
2243
  }
2225
2244
  type &= ~this.F;
2226
2245
  return type ? super.notify(node, type, flags) : true;
2227
2246
  }
2228
2247
  merge(queue) {
2229
- queue.c.forEach((n) => this.notify(n, this.F, this.F));
2248
+ queue.d.forEach((n) => this.notify(n, this.F, this.F));
2230
2249
  super.merge(queue);
2231
2250
  }
2232
2251
  };
@@ -2237,25 +2256,25 @@ function createBoundary(fn, condition) {
2237
2256
  );
2238
2257
  const tree = createBoundChildren(owner, fn, queue, 0);
2239
2258
  new EagerComputation(void 0, () => {
2240
- const disabled = queue.u.read();
2259
+ const disabled = queue.t.read();
2241
2260
  tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
2242
2261
  if (!disabled) {
2243
- queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2262
+ queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2244
2263
  queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2245
- queue.t.clear();
2264
+ queue.s.clear();
2246
2265
  queue.V.clear();
2247
2266
  }
2248
2267
  });
2249
- return () => queue.u.read() ? void 0 : tree.read();
2268
+ return () => queue.t.read() ? void 0 : tree.read();
2250
2269
  }
2251
2270
  function createCollectionBoundary(type, fn, fallback) {
2252
2271
  const owner = new Owner();
2253
2272
  const queue = new CollectionQueue(type);
2254
2273
  const tree = createBoundChildren(owner, fn, queue, type);
2255
2274
  const decision = new Computation(void 0, () => {
2256
- if (!queue.u.read()) {
2275
+ if (!queue.t.read()) {
2257
2276
  const resolved = tree.read();
2258
- if (!queue.u.read())
2277
+ if (!queue.t.read())
2259
2278
  return resolved;
2260
2279
  }
2261
2280
  return fallback(queue);
@@ -2267,13 +2286,15 @@ function createSuspense(fn, fallback) {
2267
2286
  }
2268
2287
  function createErrorBoundary(fn, fallback) {
2269
2288
  return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2270
- let node = queue.c.values().next().value;
2289
+ let node = queue.d.values().next().value;
2271
2290
  ActiveTransition && ActiveTransition.a.has(node) && (node = ActiveTransition.a.get(node));
2272
- return fallback(node.R, () => {
2291
+ return fallback(node.K, () => {
2273
2292
  incrementClock();
2274
- for (let node2 of queue.c) {
2275
- node2.b = STATE_DIRTY;
2276
- node2.l?.enqueue(node2.A, node2.C.bind(node2));
2293
+ for (let node2 of queue.d) {
2294
+ if (ActiveTransition && !node2.g)
2295
+ node2 = cloneGraph(node2);
2296
+ node2.c = STATE_DIRTY;
2297
+ node2.k?.enqueue(node2.A, node2.C.bind(node2));
2277
2298
  }
2278
2299
  });
2279
2300
  });