@solidjs/signals 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -47,7 +47,7 @@ function schedule() {
47
47
  if (scheduled)
48
48
  return;
49
49
  scheduled = true;
50
- if (!globalQueue.A)
50
+ if (!globalQueue.y)
51
51
  queueMicrotask(flush);
52
52
  }
53
53
  function notifyUnobserved() {
@@ -62,7 +62,7 @@ function notifyUnobserved() {
62
62
  var pureQueue = [];
63
63
  var Queue = class {
64
64
  k = null;
65
- A = false;
65
+ y = false;
66
66
  g = [[], []];
67
67
  f = [];
68
68
  created = clock;
@@ -87,9 +87,9 @@ var Queue = class {
87
87
  }
88
88
  }
89
89
  flush() {
90
- if (this.A)
90
+ if (this.y)
91
91
  return;
92
- this.A = true;
92
+ this.y = true;
93
93
  try {
94
94
  this.run(EFFECT_PURE);
95
95
  incrementClock();
@@ -97,19 +97,19 @@ var Queue = class {
97
97
  this.run(EFFECT_RENDER);
98
98
  this.run(EFFECT_USER);
99
99
  } finally {
100
- this.A = false;
100
+ this.y = false;
101
101
  Unobserved.length && notifyUnobserved();
102
102
  }
103
103
  }
104
104
  addChild(child) {
105
- if (ActiveTransition && ActiveTransition.r.has(this))
106
- return ActiveTransition.r.get(this).addChild(child);
105
+ if (ActiveTransition && ActiveTransition.G.has(this))
106
+ return ActiveTransition.G.get(this).addChild(child);
107
107
  this.f.push(child);
108
108
  child.k = this;
109
109
  }
110
110
  removeChild(child) {
111
- if (ActiveTransition && ActiveTransition.r.has(this))
112
- return ActiveTransition.r.get(this).removeChild(child);
111
+ if (ActiveTransition && ActiveTransition.G.has(this))
112
+ return ActiveTransition.G.get(this).removeChild(child);
113
113
  const index = this.f.indexOf(child);
114
114
  if (index >= 0) {
115
115
  this.f.splice(index, 1);
@@ -160,35 +160,35 @@ function runQueue(queue, type) {
160
160
  }
161
161
  var Transition = class _Transition {
162
162
  a = /* @__PURE__ */ new Map();
163
- s = /* @__PURE__ */ new Set();
163
+ r = /* @__PURE__ */ new Set();
164
164
  H = /* @__PURE__ */ new Set();
165
- W = /* @__PURE__ */ new Set();
166
- u = false;
165
+ I = /* @__PURE__ */ new Set();
166
+ B = false;
167
167
  g = [[], []];
168
- r = /* @__PURE__ */ new Map();
169
- I = [];
168
+ G = /* @__PURE__ */ new Map();
169
+ J = [];
170
170
  f = [];
171
171
  k = null;
172
- A = false;
173
- X = false;
172
+ y = false;
173
+ Y = false;
174
174
  e = globalQueue;
175
175
  created = clock;
176
176
  constructor() {
177
- this.r.set(globalQueue, this);
177
+ this.G.set(globalQueue, this);
178
178
  for (const child of globalQueue.f) {
179
- cloneQueue(child, this, this.r);
179
+ cloneQueue(child, this, this);
180
180
  }
181
181
  }
182
182
  enqueue(type, fn) {
183
- this.I.push(fn);
183
+ this.J.push(fn);
184
184
  if (type)
185
185
  this.g[type - 1].push(fn);
186
186
  this.schedule();
187
187
  }
188
188
  run(type) {
189
189
  if (type === EFFECT_PURE) {
190
- this.I.length && runQueue(this.I, type);
191
- this.I = [];
190
+ this.J.length && runQueue(this.J, type);
191
+ this.J = [];
192
192
  return;
193
193
  } else if (this.g[type - 1].length) {
194
194
  const effects = this.g[type - 1];
@@ -200,19 +200,19 @@ var Transition = class _Transition {
200
200
  }
201
201
  }
202
202
  flush() {
203
- if (this.A)
203
+ if (this.y)
204
204
  return;
205
- this.A = true;
205
+ this.y = true;
206
206
  let currentTransition = ActiveTransition;
207
207
  ActiveTransition = this;
208
208
  try {
209
209
  this.run(EFFECT_PURE);
210
210
  incrementClock();
211
- this.X = false;
211
+ this.Y = false;
212
212
  ActiveTransition = currentTransition;
213
213
  finishTransition(this);
214
214
  } finally {
215
- this.A = false;
215
+ this.y = false;
216
216
  ActiveTransition = currentTransition;
217
217
  }
218
218
  }
@@ -229,16 +229,16 @@ var Transition = class _Transition {
229
229
  if (!(type & LOADING_BIT))
230
230
  return false;
231
231
  if (flags & LOADING_BIT) {
232
- this.s.add(node);
232
+ this.r.add(node);
233
233
  } else {
234
- this.s.delete(node);
234
+ this.r.delete(node);
235
235
  }
236
236
  return true;
237
237
  }
238
238
  merge(queue) {
239
239
  this.g[0].push.apply(this.g[0], queue.g[0]);
240
240
  this.g[1].push.apply(this.g[1], queue.g[1]);
241
- this.I.push.apply(this.I, queue.I);
241
+ this.J.push.apply(this.J, queue.J);
242
242
  for (let i = 0; i < queue.f.length; i++) {
243
243
  const og = this.f.find((c) => c.e === queue.f[i].e);
244
244
  if (og)
@@ -248,16 +248,16 @@ var Transition = class _Transition {
248
248
  }
249
249
  }
250
250
  schedule() {
251
- if (this.X)
251
+ if (this.Y)
252
252
  return;
253
- this.X = true;
254
- if (!this.A)
253
+ this.Y = true;
254
+ if (!this.y)
255
255
  queueMicrotask(() => this.flush());
256
256
  }
257
257
  runTransition(fn, force = false) {
258
- if (this.u) {
259
- if (this.u instanceof _Transition)
260
- return this.u.runTransition(fn, force);
258
+ if (this.B) {
259
+ if (this.B instanceof _Transition)
260
+ return this.B.runTransition(fn, force);
261
261
  if (!force)
262
262
  throw new Error("Transition already completed");
263
263
  fn();
@@ -276,8 +276,7 @@ var Transition = class _Transition {
276
276
  try {
277
277
  value = await temp.value;
278
278
  } finally {
279
- while (transition2.u instanceof _Transition)
280
- transition2 = transition2.u;
279
+ transition2 = latestTransition(transition2);
281
280
  transition2.H.delete(temp.value);
282
281
  }
283
282
  ActiveTransition = transition2;
@@ -291,8 +290,7 @@ var Transition = class _Transition {
291
290
  if (result instanceof Promise) {
292
291
  transition2.H.add(result);
293
292
  result.finally(() => {
294
- while (transition2.u instanceof _Transition)
295
- transition2 = transition2.u;
293
+ transition2 = latestTransition(transition2);
296
294
  transition2.H.delete(result);
297
295
  ActiveTransition = null;
298
296
  finishTransition(transition2);
@@ -311,14 +309,14 @@ var Transition = class _Transition {
311
309
  return;
312
310
  }
313
311
  fn.j = this;
314
- this.W.add(fn);
312
+ this.I.add(fn);
315
313
  }
316
314
  };
317
315
  function transition(fn) {
318
316
  let t = new Transition();
319
317
  queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
320
318
  }
321
- function cloneGraph(node) {
319
+ function cloneGraph(node, optimistic) {
322
320
  if (node.j) {
323
321
  if (node.j !== ActiveTransition) {
324
322
  mergeTransitions(node.j, ActiveTransition);
@@ -332,48 +330,58 @@ function cloneGraph(node) {
332
330
  m: null,
333
331
  b: null,
334
332
  a: node.a ? [...node.a] : null,
335
- e: node
333
+ e: node,
334
+ I: !!optimistic
336
335
  });
336
+ delete clone.S;
337
337
  ActiveTransition.a.set(node, clone);
338
338
  node.j = ActiveTransition;
339
- if (node.a) {
339
+ if (!optimistic && node.a) {
340
340
  for (let i = 0; i < node.a.length; i++)
341
341
  node.a[i].b.push(clone);
342
342
  }
343
343
  if (node.b) {
344
344
  clone.b = [];
345
345
  for (let i = 0, length = node.b.length; i < length; i++) {
346
- !node.b[i].e && clone.b.push(cloneGraph(node.b[i]));
346
+ !node.b[i].e && clone.b.push(cloneGraph(node.b[i], optimistic));
347
347
  }
348
348
  }
349
349
  return clone;
350
350
  }
351
+ function latestTransition(t) {
352
+ while (t.B instanceof Transition)
353
+ t = t.B;
354
+ return t;
355
+ }
351
356
  function replaceSourceObservers(node, transition2) {
352
357
  let source;
358
+ let transitionSource;
353
359
  let swap;
354
360
  for (let i = 0; i < node.a.length; i++) {
355
- source = transition2.a.get(node.a[i]) || node.a[i];
361
+ transitionSource = transition2.a.get(node.a[i]);
362
+ source = transitionSource || node.a[i];
356
363
  if (source.b && (swap = source.b.indexOf(node)) !== -1) {
357
- const remove = source.b.indexOf(node.e) > -1;
358
- source.b[swap] = !remove ? node.e : source.b[source.b.length - 1];
359
- remove && source.b.pop();
364
+ source.b[swap] = transitionSource ? node.e : source.b[source.b.length - 1];
365
+ !transitionSource && source.b.pop();
360
366
  }
361
367
  }
362
368
  }
363
- function cloneQueue(queue, parent, clonedQueues) {
369
+ function cloneQueue(queue, parent, transition2) {
364
370
  const clone = Object.create(Object.getPrototypeOf(queue));
365
371
  Object.assign(clone, queue, {
366
372
  e: queue,
367
373
  k: parent,
368
374
  f: [],
369
375
  enqueue(type, fn) {
370
- ActiveTransition == null ? void 0 : ActiveTransition.enqueue(type, fn);
376
+ transition2 = latestTransition(transition2);
377
+ transition2.enqueue(type, fn);
371
378
  },
372
379
  notify(node, type, flags) {
373
380
  node = node.e || node;
374
- if (!clone.J || type & LOADING_BIT) {
381
+ if (!clone.K || type & LOADING_BIT) {
375
382
  type &= ~LOADING_BIT;
376
- ActiveTransition == null ? void 0 : ActiveTransition.notify(node, LOADING_BIT, flags);
383
+ transition2 = latestTransition(transition2);
384
+ transition2.notify(node, LOADING_BIT, flags);
377
385
  if (!type)
378
386
  return true;
379
387
  }
@@ -381,9 +389,9 @@ function cloneQueue(queue, parent, clonedQueues) {
381
389
  }
382
390
  });
383
391
  parent.f.push(clone);
384
- clonedQueues.set(queue, clone);
392
+ transition2.G.set(queue, clone);
385
393
  for (const child of queue.f) {
386
- cloneQueue(child, clone, clonedQueues);
394
+ cloneQueue(child, clone, transition2);
387
395
  }
388
396
  }
389
397
  function resolveQueues(children) {
@@ -408,14 +416,14 @@ function mergeTransitions(t1, t2) {
408
416
  key.j = t1;
409
417
  t1.a.set(key, value);
410
418
  });
411
- t2.W.forEach((c) => {
419
+ t2.I.forEach((c) => {
412
420
  c.j = t1;
413
- t1.W.add(c);
421
+ t1.I.add(c);
414
422
  });
415
423
  t2.H.forEach((p) => t1.H.add(p));
416
- t2.s.forEach((n) => t1.s.add(n));
424
+ t2.r.forEach((n) => t1.r.add(n));
417
425
  t1.merge(t2);
418
- t2.u = t1;
426
+ t2.B = t1;
419
427
  }
420
428
  function getTransitionSource(input) {
421
429
  return ActiveTransition && ActiveTransition.a.get(input) || input;
@@ -423,20 +431,20 @@ function getTransitionSource(input) {
423
431
  function getQueue(node) {
424
432
  var _a;
425
433
  const transition2 = ActiveTransition || ((_a = node.e) == null ? void 0 : _a.j);
426
- return transition2 && transition2.r.get(node.B) || node.B;
434
+ return transition2 && transition2.G.get(node.z) || node.z;
427
435
  }
428
436
  function initialDispose(node) {
429
437
  let current = node.m;
430
438
  while (current !== null && current.k === node) {
431
439
  initialDispose(current);
432
440
  const clone = ActiveTransition.a.get(current);
433
- if (clone && !clone.Y)
441
+ if (clone && !clone.Z)
434
442
  clone.dispose(true);
435
443
  current = current.m;
436
444
  }
437
445
  }
438
446
  function finishTransition(transition2) {
439
- if (transition2.u || transition2.X || transition2.H.size || transition2.s.size)
447
+ if (transition2.B || transition2.Y || transition2.H.size || transition2.r.size)
440
448
  return;
441
449
  globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
442
450
  globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
@@ -448,10 +456,16 @@ function finishTransition(transition2) {
448
456
  }
449
457
  if (clone.a)
450
458
  replaceSourceObservers(clone, transition2);
451
- if (clone.Y || clone.c === STATE_DISPOSED) {
459
+ if (clone.I) {
460
+ clone.dispose();
461
+ clone.emptyDisposal();
462
+ delete source.j;
463
+ continue;
464
+ }
465
+ if (clone.Z || clone.c === STATE_DISPOSED) {
452
466
  source.dispose(clone.c === STATE_DISPOSED);
453
467
  source.emptyDisposal();
454
- delete clone.Y;
468
+ delete clone.Z;
455
469
  } else {
456
470
  delete clone.m;
457
471
  delete clone.n;
@@ -459,16 +473,16 @@ function finishTransition(transition2) {
459
473
  Object.assign(source, clone);
460
474
  delete source.e;
461
475
  let current = clone.m;
462
- if ((current == null ? void 0 : current.w) === clone)
463
- current.w = source;
476
+ if ((current == null ? void 0 : current.t) === clone)
477
+ current.t = source;
464
478
  while ((current == null ? void 0 : current.k) === clone) {
465
479
  current.k = source;
466
480
  current = current.m;
467
481
  }
468
482
  delete source.j;
469
483
  }
470
- transition2.u = true;
471
- for (const reset of transition2.W) {
484
+ transition2.B = true;
485
+ for (const reset of transition2.I) {
472
486
  delete reset.j;
473
487
  reset();
474
488
  }
@@ -492,11 +506,11 @@ var Owner = class {
492
506
  // See comment at the top of the file for an example of the _nextSibling traversal
493
507
  k = null;
494
508
  m = null;
495
- w = null;
509
+ t = null;
496
510
  c = STATE_CLEAN;
497
511
  n = null;
498
- x = defaultContext;
499
- B = globalQueue;
512
+ u = defaultContext;
513
+ z = globalQueue;
500
514
  fa = 0;
501
515
  id = null;
502
516
  constructor(id = null, skipAppend = false) {
@@ -507,23 +521,23 @@ var Owner = class {
507
521
  }
508
522
  append(child) {
509
523
  child.k = this;
510
- child.w = this;
524
+ child.t = this;
511
525
  if (this.m)
512
- this.m.w = child;
526
+ this.m.t = child;
513
527
  child.m = this.m;
514
528
  this.m = child;
515
529
  if (this.id != null && child.id == null)
516
530
  child.id = this.getNextChildId();
517
- if (child.x !== this.x) {
518
- child.x = { ...this.x, ...child.x };
531
+ if (child.u !== this.u) {
532
+ child.u = { ...this.u, ...child.u };
519
533
  }
520
- if (this.B)
521
- child.B = this.B;
534
+ if (this.z)
535
+ child.z = this.z;
522
536
  }
523
537
  dispose(self = true) {
524
538
  if (this.c === STATE_DISPOSED)
525
539
  return;
526
- let head = self ? this.w || this.k : this, current = this.m, next = null;
540
+ let head = self ? this.t || this.k : this, current = this.m, next = null;
527
541
  while (current && current.k === this) {
528
542
  current.dispose(true);
529
543
  next = current.m;
@@ -532,18 +546,18 @@ var Owner = class {
532
546
  }
533
547
  this.fa = 0;
534
548
  if (self)
535
- this.R();
549
+ this.T();
536
550
  if (current)
537
- current.w = !self ? this : this.w;
551
+ current.t = !self ? this : this.t;
538
552
  if (head)
539
553
  head.m = current;
540
554
  }
541
- R() {
542
- if (this.w)
543
- this.w.m = null;
555
+ T() {
556
+ if (this.t)
557
+ this.t.m = null;
544
558
  this.k = null;
545
- this.w = null;
546
- this.x = defaultContext;
559
+ this.t = null;
560
+ this.u = defaultContext;
547
561
  this.c = STATE_DISPOSED;
548
562
  this.emptyDisposal();
549
563
  }
@@ -573,7 +587,7 @@ function getContext(context, owner = currentOwner) {
573
587
  if (!owner) {
574
588
  throw new NoOwnerError();
575
589
  }
576
- const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue;
590
+ const value = hasContext(context, owner) ? owner.u[context.id] : context.defaultValue;
577
591
  if (isUndefined(value)) {
578
592
  throw new ContextNotFoundError();
579
593
  }
@@ -583,13 +597,13 @@ function setContext(context, value, owner = currentOwner) {
583
597
  if (!owner) {
584
598
  throw new NoOwnerError();
585
599
  }
586
- owner.x = {
587
- ...owner.x,
600
+ owner.u = {
601
+ ...owner.u,
588
602
  [context.id]: isUndefined(value) ? context.defaultValue : value
589
603
  };
590
604
  }
591
605
  function hasContext(context, owner = currentOwner) {
592
- return !isUndefined(owner == null ? void 0 : owner.x[context.id]);
606
+ return !isUndefined(owner == null ? void 0 : owner.u[context.id]);
593
607
  }
594
608
  function onCleanup(fn) {
595
609
  if (!currentOwner)
@@ -629,8 +643,8 @@ var Computation = class extends Owner {
629
643
  a = null;
630
644
  b = null;
631
645
  l;
632
- L;
633
646
  M;
647
+ N;
634
648
  // Used in __DEV__ mode, hopefully removed in production
635
649
  la;
636
650
  // Using false is an optimization as an alternative to _equals: () => false
@@ -642,22 +656,21 @@ var Computation = class extends Owner {
642
656
  h = 0;
643
657
  /** Which flags raised by sources are handled, vs. being passed through. */
644
658
  ba = DEFAULT_FLAGS;
645
- N = -1;
646
- D = false;
659
+ O = -1;
660
+ C = false;
647
661
  j;
648
662
  e;
663
+ I = false;
649
664
  constructor(initialValue, compute2, options) {
650
665
  super(options == null ? void 0 : options.id, compute2 === null);
651
- this.M = compute2;
666
+ this.N = compute2;
652
667
  this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
653
668
  this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
654
669
  this.l = initialValue;
655
670
  if ((options == null ? void 0 : options.equals) !== void 0)
656
671
  this.aa = options.equals;
657
- if (options == null ? void 0 : options.pureWrite)
658
- this.ha = true;
659
- if (options == null ? void 0 : options.unobserved)
660
- this.ea = options == null ? void 0 : options.unobserved;
672
+ this.ha = !!(options == null ? void 0 : options.pureWrite);
673
+ this.ea = options == null ? void 0 : options.unobserved;
661
674
  if (ActiveTransition) {
662
675
  this.j = ActiveTransition;
663
676
  ActiveTransition.a.set(this, this);
@@ -667,7 +680,7 @@ var Computation = class extends Owner {
667
680
  track(this);
668
681
  newFlags |= this.h & ~currentMask;
669
682
  if (this.h & ERROR_BIT) {
670
- throw this.L;
683
+ throw this.M;
671
684
  } else {
672
685
  return this.l;
673
686
  }
@@ -682,11 +695,11 @@ var Computation = class extends Owner {
682
695
  if (clone !== this)
683
696
  return clone.read();
684
697
  }
685
- if (this.M) {
686
- if (this.h & ERROR_BIT && this.N <= clock)
698
+ if (this.N) {
699
+ if (this.h & ERROR_BIT && this.O <= clock)
687
700
  update(this);
688
701
  else
689
- this.K();
702
+ this.L();
690
703
  }
691
704
  return this.ga();
692
705
  }
@@ -703,11 +716,11 @@ var Computation = class extends Owner {
703
716
  if (clone !== this)
704
717
  return clone.wait();
705
718
  }
706
- if (this.M) {
707
- if (this.h & ERROR_BIT && this.N <= clock)
719
+ if (this.N) {
720
+ if (this.h & ERROR_BIT && this.O <= clock)
708
721
  update(this);
709
722
  else
710
- this.K();
723
+ this.L();
711
724
  }
712
725
  if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
713
726
  track(this);
@@ -730,17 +743,17 @@ var Computation = class extends Owner {
730
743
  this.aa === false || !this.aa(this.l, newValue));
731
744
  if (valueChanged) {
732
745
  this.l = newValue;
733
- this.L = void 0;
746
+ this.M = void 0;
734
747
  }
735
748
  const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
736
749
  this.h = flags;
737
- this.N = clock + 1;
750
+ this.O = clock + 1;
738
751
  if (this.b) {
739
752
  for (let i = 0; i < this.b.length; i++) {
740
753
  if (valueChanged) {
741
- this.b[i].y(STATE_DIRTY);
754
+ this.b[i].w(STATE_DIRTY);
742
755
  } else if (changedFlagsMask) {
743
- this.b[i].Z(changedFlagsMask, changedFlags);
756
+ this.b[i]._(changedFlagsMask, changedFlags);
744
757
  }
745
758
  }
746
759
  }
@@ -749,14 +762,14 @@ var Computation = class extends Owner {
749
762
  /**
750
763
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
751
764
  */
752
- y(state, skipQueue) {
753
- if (this.c >= state && !this.D)
765
+ w(state, skipQueue) {
766
+ if (this.c >= state && !this.C)
754
767
  return;
755
- this.D = !!skipQueue;
768
+ this.C = !!skipQueue;
756
769
  this.c = state;
757
770
  if (this.b) {
758
771
  for (let i = 0; i < this.b.length; i++) {
759
- this.b[i].y(STATE_CHECK, skipQueue);
772
+ this.b[i].w(STATE_CHECK, skipQueue);
760
773
  }
761
774
  }
762
775
  }
@@ -766,35 +779,35 @@ var Computation = class extends Owner {
766
779
  * @param mask A bitmask for which flag(s) were changed.
767
780
  * @param newFlags The source's new flags, masked to just the changed ones.
768
781
  */
769
- Z(mask, newFlags2) {
782
+ _(mask, newFlags2) {
770
783
  if (this.c >= STATE_DIRTY)
771
784
  return;
772
785
  if (mask & this.ba) {
773
- this.y(STATE_DIRTY);
786
+ this.w(STATE_DIRTY);
774
787
  return;
775
788
  }
776
- if (this.c >= STATE_CHECK && !this.D)
789
+ if (this.c >= STATE_CHECK && !this.C)
777
790
  return;
778
791
  const prevFlags = this.h & mask;
779
792
  const deltaFlags = prevFlags ^ newFlags2;
780
793
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
781
- this.y(STATE_CHECK);
794
+ this.w(STATE_CHECK);
782
795
  } else {
783
796
  this.h ^= deltaFlags;
784
797
  if (this.b) {
785
798
  for (let i = 0; i < this.b.length; i++) {
786
- this.b[i].Z(mask, newFlags2);
799
+ this.b[i]._(mask, newFlags2);
787
800
  }
788
801
  }
789
802
  }
790
803
  }
791
- E(error) {
804
+ D(error) {
792
805
  if (ActiveTransition && !this.e) {
793
806
  const clone = cloneGraph(this);
794
807
  if (clone !== this)
795
- return clone.E(error);
808
+ return clone.D(error);
796
809
  }
797
- this.L = error;
810
+ this.M = error;
798
811
  this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
799
812
  }
800
813
  /**
@@ -804,8 +817,8 @@ var Computation = class extends Owner {
804
817
  *
805
818
  * This function will ensure that the value and states we read from the computation are up to date
806
819
  */
807
- K() {
808
- if (!this.M) {
820
+ L() {
821
+ if (!this.N) {
809
822
  return;
810
823
  }
811
824
  if (this.c === STATE_DISPOSED) {
@@ -818,7 +831,7 @@ var Computation = class extends Owner {
818
831
  if (this.c === STATE_CHECK) {
819
832
  for (let i = 0; i < this.a.length; i++) {
820
833
  const source = getTransitionSource(this.a[i]);
821
- source.K();
834
+ source.L();
822
835
  observerFlags |= source.h & ~UNINITIALIZED_BIT;
823
836
  if (this.c === STATE_DIRTY) {
824
837
  break;
@@ -835,12 +848,12 @@ var Computation = class extends Owner {
835
848
  /**
836
849
  * Remove ourselves from the owner graph and the computation graph
837
850
  */
838
- R() {
851
+ T() {
839
852
  if (this.c === STATE_DISPOSED)
840
853
  return;
841
854
  if (this.a)
842
855
  removeSourceObservers(this, 0);
843
- super.R();
856
+ super.T();
844
857
  }
845
858
  };
846
859
  function track(computation) {
@@ -855,7 +868,7 @@ function track(computation) {
855
868
  newSources.push(computation);
856
869
  }
857
870
  if (updateCheck) {
858
- updateCheck.l = computation.N > currentObserver.N;
871
+ updateCheck.l = computation.O > currentObserver.O;
859
872
  }
860
873
  }
861
874
  }
@@ -865,19 +878,19 @@ function update(node) {
865
878
  newSourcesIndex = 0;
866
879
  newFlags = 0;
867
880
  try {
868
- if (ActiveTransition && node.e && !node.Y) {
881
+ if (ActiveTransition && node.e && !node.Z) {
869
882
  initialDispose(node.e);
870
- node.Y = true;
883
+ node.Z = true;
871
884
  }
872
885
  node.dispose(false);
873
886
  node.emptyDisposal();
874
- const result = compute(node, node.M, node);
887
+ const result = compute(node, node.N, node);
875
888
  node.write(result, newFlags, true);
876
889
  } catch (error) {
877
890
  if (error instanceof NotReadyError) {
878
891
  node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
879
892
  } else {
880
- node.E(error);
893
+ node.D(error);
881
894
  }
882
895
  } finally {
883
896
  if (newSources) {
@@ -906,7 +919,7 @@ function update(node) {
906
919
  newSources = prevSources;
907
920
  newSourcesIndex = prevSourcesIndex;
908
921
  newFlags = prevFlags;
909
- node.N = clock + 1;
922
+ node.O = clock + 1;
910
923
  node.c = STATE_CLEAN;
911
924
  }
912
925
  }
@@ -981,7 +994,7 @@ function runWithObserver(observer, run) {
981
994
  newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
982
995
  );
983
996
  } else {
984
- observer.E(error);
997
+ observer.D(error);
985
998
  }
986
999
  } finally {
987
1000
  if (newSources) {
@@ -1025,29 +1038,29 @@ function compute(owner, fn, observer) {
1025
1038
  // src/core/effect.ts
1026
1039
  var Effect = class extends Computation {
1027
1040
  ca;
1028
- _;
1029
- O;
1030
- da = false;
1031
1041
  $;
1032
- C;
1042
+ P;
1043
+ da = false;
1044
+ S;
1045
+ A;
1033
1046
  constructor(initialValue, compute2, effect, error, options) {
1034
1047
  super(initialValue, compute2, options);
1035
1048
  this.ca = effect;
1036
- this._ = error;
1037
- this.$ = initialValue;
1038
- this.C = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
1039
- if (this.C === EFFECT_RENDER) {
1040
- this.M = function(p) {
1041
- return !this.e && clock > this.B.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1049
+ this.$ = error;
1050
+ this.S = initialValue;
1051
+ this.A = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
1052
+ if (this.A === EFFECT_RENDER) {
1053
+ this.N = function(p) {
1054
+ return !this.e && clock > this.z.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1042
1055
  };
1043
1056
  }
1044
- this.K();
1045
- !(options == null ? void 0 : options.defer) && (this.C === EFFECT_USER ? getQueue(this).enqueue(this.C, this.F.bind(this)) : this.F(this.C));
1057
+ this.L();
1058
+ !(options == null ? void 0 : options.defer) && (this.A === EFFECT_USER ? getQueue(this).enqueue(this.A, this.E.bind(this)) : this.E(this.A));
1046
1059
  }
1047
1060
  write(value, flags = 0) {
1048
1061
  if (this.c == STATE_DIRTY) {
1049
1062
  this.h = flags;
1050
- if (this.C === EFFECT_RENDER) {
1063
+ if (this.A === EFFECT_RENDER) {
1051
1064
  getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.h);
1052
1065
  }
1053
1066
  }
@@ -1055,37 +1068,37 @@ var Effect = class extends Computation {
1055
1068
  return this.l;
1056
1069
  this.l = value;
1057
1070
  this.da = true;
1058
- this.L = void 0;
1071
+ this.M = void 0;
1059
1072
  return value;
1060
1073
  }
1061
- y(state, skipQueue) {
1074
+ w(state, skipQueue) {
1062
1075
  if (this.c >= state || skipQueue)
1063
1076
  return;
1064
- if (this.c === STATE_CLEAN)
1065
- getQueue(this).enqueue(this.C, this.F.bind(this));
1077
+ if (this.c === STATE_CLEAN || this.e && !ActiveTransition)
1078
+ getQueue(this).enqueue(this.A, this.E.bind(this));
1066
1079
  this.c = state;
1067
1080
  }
1068
- Z(mask, newFlags2) {
1081
+ _(mask, newFlags2) {
1069
1082
  if (this.e) {
1070
1083
  if (this.c >= STATE_DIRTY)
1071
1084
  return;
1072
1085
  if (mask & 3) {
1073
- this.y(STATE_DIRTY);
1086
+ this.w(STATE_DIRTY);
1074
1087
  return;
1075
1088
  }
1076
1089
  }
1077
- super.Z(mask, newFlags2);
1090
+ super._(mask, newFlags2);
1078
1091
  }
1079
- E(error) {
1080
- this.L = error;
1092
+ D(error) {
1093
+ this.M = error;
1081
1094
  getQueue(this).notify(this, LOADING_BIT, 0);
1082
1095
  this.h = ERROR_BIT;
1083
- if (this.C === EFFECT_USER) {
1096
+ if (this.A === EFFECT_USER) {
1084
1097
  try {
1085
- return this._ ? this._(error, () => {
1098
+ return this.$ ? this.$(error, () => {
1086
1099
  var _a;
1087
- (_a = this.O) == null ? void 0 : _a.call(this);
1088
- this.O = void 0;
1100
+ (_a = this.P) == null ? void 0 : _a.call(this);
1101
+ this.P = void 0;
1089
1102
  }) : console.error(error);
1090
1103
  } catch (e) {
1091
1104
  error = e;
@@ -1094,31 +1107,31 @@ var Effect = class extends Computation {
1094
1107
  if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
1095
1108
  throw error;
1096
1109
  }
1097
- R() {
1110
+ T() {
1098
1111
  var _a;
1099
1112
  if (this.c === STATE_DISPOSED)
1100
1113
  return;
1101
1114
  this.ca = void 0;
1115
+ this.S = void 0;
1102
1116
  this.$ = void 0;
1103
- this._ = void 0;
1104
- (_a = this.O) == null ? void 0 : _a.call(this);
1105
- this.O = void 0;
1117
+ (_a = this.P) == null ? void 0 : _a.call(this);
1118
+ this.P = void 0;
1106
1119
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1107
- super.R();
1120
+ super.T();
1108
1121
  }
1109
- F(type) {
1122
+ E(type) {
1110
1123
  var _a;
1111
1124
  if (type) {
1112
1125
  const effect = this.e || this;
1113
1126
  if (effect.da && effect.c !== STATE_DISPOSED) {
1114
- (_a = effect.O) == null ? void 0 : _a.call(effect);
1127
+ (_a = effect.P) == null ? void 0 : _a.call(effect);
1115
1128
  try {
1116
- effect.O = effect.ca(effect.l, effect.$);
1129
+ effect.P = effect.ca(effect.l, effect.S);
1117
1130
  } catch (e) {
1118
1131
  if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
1119
1132
  throw e;
1120
1133
  } finally {
1121
- effect.$ = effect.l;
1134
+ effect.S = effect.l;
1122
1135
  effect.da = false;
1123
1136
  }
1124
1137
  }
@@ -1129,16 +1142,16 @@ var Effect = class extends Computation {
1129
1142
  var EagerComputation = class extends Computation {
1130
1143
  constructor(initialValue, compute2, options) {
1131
1144
  super(initialValue, compute2, options);
1132
- !(options == null ? void 0 : options.defer) && this.K();
1145
+ !(options == null ? void 0 : options.defer) && this.L();
1133
1146
  }
1134
- y(state, skipQueue) {
1135
- if (this.c >= state && !this.D)
1147
+ w(state, skipQueue) {
1148
+ if (this.c >= state && !this.C)
1136
1149
  return;
1137
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.D))
1138
- getQueue(this).enqueue(EFFECT_PURE, this.F.bind(this));
1139
- super.y(state, skipQueue);
1150
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.C))
1151
+ getQueue(this).enqueue(EFFECT_PURE, this.E.bind(this));
1152
+ super.w(state, skipQueue);
1140
1153
  }
1141
- F() {
1154
+ E() {
1142
1155
  this.c !== STATE_CLEAN && runTop(this);
1143
1156
  }
1144
1157
  };
@@ -1147,15 +1160,15 @@ var FirewallComputation = class extends Computation {
1147
1160
  constructor(compute2) {
1148
1161
  super(void 0, compute2);
1149
1162
  }
1150
- y(state, skipQueue) {
1151
- if (this.c >= state && !this.D)
1163
+ w(state, skipQueue) {
1164
+ if (this.c >= state && !this.C)
1152
1165
  return;
1153
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.D))
1154
- getQueue(this).enqueue(EFFECT_PURE, this.F.bind(this));
1155
- super.y(state, true);
1156
- this.D = !!skipQueue;
1166
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.C))
1167
+ getQueue(this).enqueue(EFFECT_PURE, this.E.bind(this));
1168
+ super.w(state, true);
1169
+ this.C = !!skipQueue;
1157
1170
  }
1158
- F() {
1171
+ E() {
1159
1172
  this.c !== STATE_CLEAN && runTop(this);
1160
1173
  }
1161
1174
  };
@@ -1170,17 +1183,201 @@ function runTop(node) {
1170
1183
  }
1171
1184
  for (let i = ancestors.length - 1; i >= 0; i--) {
1172
1185
  if (ancestors[i].c !== STATE_DISPOSED)
1173
- ancestors[i].K();
1186
+ ancestors[i].L();
1174
1187
  }
1175
1188
  }
1176
1189
 
1190
+ // src/signals.ts
1191
+ function createSignal(first, second, third) {
1192
+ if (typeof first === "function") {
1193
+ const memo = createMemo((p) => {
1194
+ const node2 = new Computation(
1195
+ first(p ? untrack(p[0]) : second),
1196
+ null,
1197
+ third
1198
+ );
1199
+ return [node2.read.bind(node2), node2.write.bind(node2)];
1200
+ });
1201
+ return [() => memo()[0](), (value) => memo()[1](value)];
1202
+ }
1203
+ const o = getOwner();
1204
+ const needsId = (o == null ? void 0 : o.id) != null;
1205
+ const node = new Computation(
1206
+ first,
1207
+ null,
1208
+ needsId ? { id: o.getNextChildId(), ...second } : second
1209
+ );
1210
+ return [node.read.bind(node), node.write.bind(node)];
1211
+ }
1212
+ function createMemo(compute2, value, options) {
1213
+ let node = new Computation(
1214
+ value,
1215
+ compute2,
1216
+ options
1217
+ );
1218
+ let resolvedValue;
1219
+ return () => {
1220
+ var _a, _b;
1221
+ if (node) {
1222
+ if (node.c === STATE_DISPOSED) {
1223
+ node = void 0;
1224
+ return resolvedValue;
1225
+ }
1226
+ resolvedValue = node.wait();
1227
+ if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.k) !== node && !(node.h & UNINITIALIZED_BIT)) {
1228
+ node.dispose();
1229
+ node = void 0;
1230
+ }
1231
+ }
1232
+ return resolvedValue;
1233
+ };
1234
+ }
1235
+ function createAsync(compute2, value, options) {
1236
+ let refreshing = false;
1237
+ const node = new EagerComputation(
1238
+ value,
1239
+ (p) => {
1240
+ const source = compute2(p, refreshing);
1241
+ refreshing = false;
1242
+ const isPromise = source instanceof Promise;
1243
+ const iterator = source[Symbol.asyncIterator];
1244
+ if (!isPromise && !iterator) {
1245
+ return source;
1246
+ }
1247
+ let abort = false;
1248
+ onCleanup(() => abort = true);
1249
+ let transition2 = ActiveTransition;
1250
+ if (isPromise) {
1251
+ source.then(
1252
+ (value3) => {
1253
+ if (abort)
1254
+ return;
1255
+ if (transition2)
1256
+ return transition2.runTransition(() => {
1257
+ node.write(value3, 0, true);
1258
+ }, true);
1259
+ node.write(value3, 0, true);
1260
+ },
1261
+ (error) => {
1262
+ if (abort)
1263
+ return;
1264
+ if (transition2)
1265
+ return transition2.runTransition(() => node.D(error), true);
1266
+ node.D(error);
1267
+ }
1268
+ );
1269
+ } else {
1270
+ (async () => {
1271
+ try {
1272
+ for await (let value3 of source) {
1273
+ if (abort)
1274
+ return;
1275
+ if (transition2)
1276
+ return transition2.runTransition(() => {
1277
+ node.write(value3, 0, true);
1278
+ transition2 = null;
1279
+ }, true);
1280
+ node.write(value3, 0, true);
1281
+ }
1282
+ } catch (error) {
1283
+ if (abort)
1284
+ return;
1285
+ if (transition2)
1286
+ return transition2.runTransition(() => {
1287
+ node.D(error);
1288
+ transition2 = null;
1289
+ }, true);
1290
+ node.D(error);
1291
+ }
1292
+ })();
1293
+ }
1294
+ throw new NotReadyError();
1295
+ },
1296
+ options
1297
+ );
1298
+ const read = node.wait.bind(node);
1299
+ read.refresh = () => {
1300
+ let n = node;
1301
+ if (ActiveTransition && !node.e) {
1302
+ n = cloneGraph(node);
1303
+ }
1304
+ n.c = STATE_DIRTY;
1305
+ refreshing = true;
1306
+ n.L();
1307
+ };
1308
+ return read;
1309
+ }
1310
+ function createEffect(compute2, effect, value, options) {
1311
+ void new Effect(
1312
+ value,
1313
+ compute2,
1314
+ effect.effect ? effect.effect : effect,
1315
+ effect.error,
1316
+ options
1317
+ );
1318
+ }
1319
+ function createRenderEffect(compute2, effect, value, options) {
1320
+ void new Effect(value, compute2, effect, void 0, {
1321
+ render: true,
1322
+ ...options
1323
+ });
1324
+ }
1325
+ function createRoot(init, options) {
1326
+ const owner = new Owner(options == null ? void 0 : options.id);
1327
+ return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
1328
+ }
1329
+ function runWithOwner(owner, run) {
1330
+ return compute(owner, run, null);
1331
+ }
1332
+ function resolve(fn) {
1333
+ return new Promise((res, rej) => {
1334
+ createRoot((dispose) => {
1335
+ new EagerComputation(void 0, () => {
1336
+ try {
1337
+ res(fn());
1338
+ } catch (err) {
1339
+ if (err instanceof NotReadyError)
1340
+ throw err;
1341
+ rej(err);
1342
+ }
1343
+ dispose();
1344
+ });
1345
+ });
1346
+ });
1347
+ }
1348
+ function createPending() {
1349
+ const node = new Computation(false, null);
1350
+ const reset = () => node.write(false);
1351
+ function write() {
1352
+ if (!ActiveTransition)
1353
+ return false;
1354
+ ActiveTransition.addOptimistic(reset);
1355
+ queueMicrotask(() => reset.j && node.write(true));
1356
+ }
1357
+ function read() {
1358
+ const v = node.read();
1359
+ return ActiveTransition ? false : v;
1360
+ }
1361
+ return [read, write];
1362
+ }
1363
+ function useTransition() {
1364
+ const [pending, setPending] = createPending();
1365
+ function start(fn) {
1366
+ transition((resume) => {
1367
+ setPending(true);
1368
+ return fn(resume);
1369
+ });
1370
+ }
1371
+ return [pending, start];
1372
+ }
1373
+
1177
1374
  // src/store/reconcile.ts
1178
1375
  function unwrap(value) {
1179
1376
  var _a;
1180
1377
  return ((_a = value == null ? void 0 : value[$TARGET]) == null ? void 0 : _a[STORE_NODE]) ?? value;
1181
1378
  }
1182
- function getOverrideValue(value, override, key) {
1183
- return override && key in override ? override[key] : value[key];
1379
+ function getOverrideValue(value, override, nodes, key) {
1380
+ return nodes && key in nodes ? nodes[key].read() : override && key in override ? override[key] : value[key];
1184
1381
  }
1185
1382
  function getAllKeys(value, override, next) {
1186
1383
  const keys = getKeys(value, override);
@@ -1194,6 +1391,7 @@ function applyState(next, state, keyFn, all) {
1194
1391
  return;
1195
1392
  const previous = target[STORE_VALUE];
1196
1393
  const override = target[STORE_OVERRIDE];
1394
+ let nodes = target[STORE_NODE];
1197
1395
  if (next === previous && !override)
1198
1396
  return;
1199
1397
  (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
@@ -1201,14 +1399,14 @@ function applyState(next, state, keyFn, all) {
1201
1399
  target[STORE_OVERRIDE] = void 0;
1202
1400
  if (Array.isArray(previous)) {
1203
1401
  let changed = false;
1204
- const prevLength = getOverrideValue(previous, override, "length");
1402
+ const prevLength = getOverrideValue(previous, override, nodes, "length");
1205
1403
  if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
1206
1404
  let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
1207
- 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++) {
1405
+ for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, nodes, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
1208
1406
  applyState(next[start], wrap(item, target), keyFn, all);
1209
1407
  }
1210
1408
  const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
1211
- 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--) {
1409
+ for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, nodes, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
1212
1410
  temp[newEnd] = item;
1213
1411
  }
1214
1412
  if (start > newEnd || start > end) {
@@ -1235,7 +1433,7 @@ function applyState(next, state, keyFn, all) {
1235
1433
  newIndices.set(keyVal, j);
1236
1434
  }
1237
1435
  for (i = start; i <= end; i++) {
1238
- item = getOverrideValue(previous, override, i);
1436
+ item = getOverrideValue(previous, override, nodes, i);
1239
1437
  keyVal = item ? keyFn(item) : item;
1240
1438
  j = newIndices.get(keyVal);
1241
1439
  if (j !== void 0 && j !== -1) {
@@ -1256,7 +1454,7 @@ function applyState(next, state, keyFn, all) {
1256
1454
  changed = true;
1257
1455
  } else if (prevLength && next.length) {
1258
1456
  for (let i = 0, len = next.length; i < len; i++) {
1259
- const item = getOverrideValue(previous, override, i);
1457
+ const item = getOverrideValue(previous, override, nodes, i);
1260
1458
  isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
1261
1459
  }
1262
1460
  }
@@ -1267,14 +1465,13 @@ function applyState(next, state, keyFn, all) {
1267
1465
  changed && ((_h = target[STORE_NODE][$TRACK]) == null ? void 0 : _h.write(void 0));
1268
1466
  return;
1269
1467
  }
1270
- let nodes = target[STORE_NODE];
1271
1468
  if (nodes) {
1272
1469
  const tracked = nodes[$TRACK];
1273
1470
  const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
1274
1471
  for (let i = 0, len = keys.length; i < len; i++) {
1275
1472
  const key = keys[i];
1276
1473
  const node = nodes[key];
1277
- const previousValue = unwrap(getOverrideValue(previous, override, key));
1474
+ const previousValue = unwrap(getOverrideValue(previous, override, nodes, key));
1278
1475
  let nextValue = unwrap(next[key]);
1279
1476
  if (previousValue === nextValue)
1280
1477
  continue;
@@ -1305,16 +1502,7 @@ function reconcile(value, key, all = false) {
1305
1502
  }
1306
1503
 
1307
1504
  // src/store/projection.ts
1308
- function createProjection(fn, initialValue = {}, options) {
1309
- let wrappedStore;
1310
- const node = new FirewallComputation(() => {
1311
- storeSetter(wrappedStore, (s) => {
1312
- const value = fn(s);
1313
- if (value !== s && value !== void 0) {
1314
- reconcile(value, (options == null ? void 0 : options.key) || "id", options == null ? void 0 : options.all)(s);
1315
- }
1316
- });
1317
- });
1505
+ function createProjectionInternal(fn, initialValue = {}, options) {
1318
1506
  const wrappedMap = /* @__PURE__ */ new WeakMap();
1319
1507
  const traps = {
1320
1508
  ...storeTraps,
@@ -1325,7 +1513,7 @@ function createProjection(fn, initialValue = {}, options) {
1325
1513
  return storeTraps.get(target, property, receiver);
1326
1514
  }
1327
1515
  };
1328
- function wrapProjection(source) {
1516
+ const wrapProjection = (source) => {
1329
1517
  var _a;
1330
1518
  if (wrappedMap.has(source))
1331
1519
  return wrappedMap.get(source);
@@ -1337,8 +1525,20 @@ function createProjection(fn, initialValue = {}, options) {
1337
1525
  });
1338
1526
  wrappedMap.set(source, wrapped);
1339
1527
  return wrapped;
1340
- }
1341
- return wrappedStore = wrapProjection(initialValue);
1528
+ };
1529
+ const wrappedStore = wrapProjection(initialValue);
1530
+ const node = new FirewallComputation(() => {
1531
+ storeSetter(wrappedStore, (s) => {
1532
+ const value = fn(s);
1533
+ if (value !== s && value !== void 0) {
1534
+ reconcile(value, (options == null ? void 0 : options.key) || "id", options == null ? void 0 : options.all)(s);
1535
+ }
1536
+ });
1537
+ });
1538
+ return { store: wrappedStore, node };
1539
+ }
1540
+ function createProjection(fn, initialValue = {}, options) {
1541
+ return createProjectionInternal(fn, initialValue, options).store;
1342
1542
  }
1343
1543
 
1344
1544
  // src/store/store.ts
@@ -1472,14 +1672,14 @@ var storeTraps = {
1472
1672
  const store = target[$PROXY];
1473
1673
  if (Writing == null ? void 0 : Writing.has(target[$PROXY])) {
1474
1674
  untrack(() => {
1475
- var _a, _b, _c, _d, _e, _f, _g, _h;
1675
+ var _a, _b, _c, _d, _e, _f, _g;
1476
1676
  const state = target[STORE_VALUE];
1477
1677
  const base = state[property];
1478
- const prev = ((_a = target[STORE_OVERRIDE]) == null ? void 0 : _a[property]) || base;
1479
- const value = ((_b = rawValue == null ? void 0 : rawValue[$TARGET]) == null ? void 0 : _b[STORE_VALUE]) ?? rawValue;
1678
+ const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : base;
1679
+ const value = ((_a = rawValue == null ? void 0 : rawValue[$TARGET]) == null ? void 0 : _a[STORE_VALUE]) ?? rawValue;
1480
1680
  if (prev === value)
1481
1681
  return true;
1482
- const len = ((_c = target[STORE_OVERRIDE]) == null ? void 0 : _c.length) || state.length;
1682
+ const len = ((_b = target[STORE_OVERRIDE]) == null ? void 0 : _b.length) || state.length;
1483
1683
  if (value !== void 0 && value === base)
1484
1684
  delete target[STORE_OVERRIDE][property];
1485
1685
  else
@@ -1491,15 +1691,15 @@ var storeTraps = {
1491
1691
  }
1492
1692
  if (recursivelyNotify(store, storeLookup) && wrappable)
1493
1693
  recursivelyAddParent(value, store);
1494
- (_e = (_d = target[STORE_HAS]) == null ? void 0 : _d[property]) == null ? void 0 : _e.write(true);
1694
+ (_d = (_c = target[STORE_HAS]) == null ? void 0 : _c[property]) == null ? void 0 : _d.write(true);
1495
1695
  const nodes = getNodes(target, STORE_NODE);
1496
- (_f = nodes[property]) == null ? void 0 : _f.write(wrappable ? wrap(value, target) : value);
1696
+ (_e = nodes[property]) == null ? void 0 : _e.write(wrappable ? wrap(value, target) : value);
1497
1697
  if (Array.isArray(state)) {
1498
1698
  const index = parseInt(property) + 1;
1499
1699
  if (index > len)
1500
- (_g = nodes.length) == null ? void 0 : _g.write(index);
1700
+ (_f = nodes.length) == null ? void 0 : _f.write(index);
1501
1701
  }
1502
- (_h = nodes[$TRACK]) == null ? void 0 : _h.write(void 0);
1702
+ (_g = nodes[$TRACK]) == null ? void 0 : _g.write(void 0);
1503
1703
  });
1504
1704
  }
1505
1705
  return true;
@@ -1508,8 +1708,8 @@ var storeTraps = {
1508
1708
  var _a;
1509
1709
  if ((Writing == null ? void 0 : Writing.has(target[$PROXY])) && ((_a = target[STORE_OVERRIDE]) == null ? void 0 : _a[property]) !== $DELETED) {
1510
1710
  untrack(() => {
1511
- var _a2, _b, _c, _d, _e;
1512
- const prev = ((_a2 = target[STORE_OVERRIDE]) == null ? void 0 : _a2[property]) || target[STORE_VALUE][property];
1711
+ var _a2, _b, _c, _d;
1712
+ const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : target[STORE_VALUE][property];
1513
1713
  if (property in target[STORE_VALUE]) {
1514
1714
  (target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = $DELETED;
1515
1715
  } else if (target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]) {
@@ -1520,10 +1720,10 @@ var storeTraps = {
1520
1720
  const parents = PARENTS.get(prev);
1521
1721
  parents && (parents instanceof Set ? parents.delete(target) : PARENTS.delete(prev));
1522
1722
  }
1523
- (_c = (_b = target[STORE_HAS]) == null ? void 0 : _b[property]) == null ? void 0 : _c.write(false);
1723
+ (_b = (_a2 = target[STORE_HAS]) == null ? void 0 : _a2[property]) == null ? void 0 : _b.write(false);
1524
1724
  const nodes = getNodes(target, STORE_NODE);
1525
- (_d = nodes[property]) == null ? void 0 : _d.write(void 0);
1526
- (_e = nodes[$TRACK]) == null ? void 0 : _e.write(void 0);
1725
+ (_c = nodes[property]) == null ? void 0 : _c.write(void 0);
1726
+ (_d = nodes[$TRACK]) == null ? void 0 : _d.write(void 0);
1527
1727
  });
1528
1728
  }
1529
1729
  return true;
@@ -1568,7 +1768,7 @@ function storeSetter(store, fn) {
1568
1768
  }
1569
1769
  }
1570
1770
  function createStore(first, second, options) {
1571
- const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second, options) : wrap(first);
1771
+ const derived = typeof first === "function", wrappedStore = derived ? createProjectionInternal(first, second, options).store : wrap(first);
1572
1772
  return [wrappedStore, (fn) => storeSetter(wrappedStore, fn)];
1573
1773
  }
1574
1774
  function recursivelyNotify(state, lookup) {
@@ -1633,6 +1833,29 @@ function deep(store) {
1633
1833
  return store[$DEEP];
1634
1834
  }
1635
1835
 
1836
+ // src/store/optimistic.ts
1837
+ function createOptimistic(first, second, options) {
1838
+ const derived = typeof first === "function";
1839
+ const { store, node } = derived ? createProjectionInternal(first, second, options) : createProjectionInternal(() => {
1840
+ }, first);
1841
+ const reset = () => storeSetter(
1842
+ store,
1843
+ reconcile(
1844
+ derived ? first(store) || store : first,
1845
+ (options == null ? void 0 : options.key) || "id",
1846
+ options == null ? void 0 : options.all
1847
+ )
1848
+ );
1849
+ const write = (v) => {
1850
+ if (!ActiveTransition)
1851
+ throw new Error("createOptimistic can only be updated inside a transition");
1852
+ ActiveTransition.addOptimistic(reset);
1853
+ cloneGraph(node, true);
1854
+ queueMicrotask(() => reset.j && storeSetter(store, v));
1855
+ };
1856
+ return [store, write];
1857
+ }
1858
+
1636
1859
  // src/store/utils.ts
1637
1860
  function snapshot(item, map, lookup) {
1638
1861
  var _a;
@@ -1834,267 +2057,57 @@ function omit(props, ...keys) {
1834
2057
  return result;
1835
2058
  }
1836
2059
 
1837
- // src/signals.ts
1838
- function createSignal(first, second, third) {
1839
- if (typeof first === "function") {
1840
- const memo = createMemo((p) => {
1841
- const node2 = new Computation(
1842
- first(p ? untrack(p[0]) : second),
1843
- null,
1844
- third
1845
- );
1846
- return [node2.read.bind(node2), node2.write.bind(node2)];
1847
- });
1848
- return [() => memo()[0](), (value) => memo()[1](value)];
1849
- }
1850
- const o = getOwner();
1851
- const needsId = (o == null ? void 0 : o.id) != null;
1852
- const node = new Computation(
1853
- first,
1854
- null,
1855
- needsId ? { id: o.getNextChildId(), ...second } : second
1856
- );
1857
- return [node.read.bind(node), node.write.bind(node)];
1858
- }
1859
- function createMemo(compute2, value, options) {
1860
- let node = new Computation(
1861
- value,
1862
- compute2,
1863
- options
1864
- );
1865
- let resolvedValue;
1866
- return () => {
1867
- var _a, _b;
1868
- if (node) {
1869
- if (node.c === STATE_DISPOSED) {
1870
- node = void 0;
1871
- return resolvedValue;
1872
- }
1873
- resolvedValue = node.wait();
1874
- if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.k) !== node && !(node.h & UNINITIALIZED_BIT)) {
1875
- node.dispose();
1876
- node = void 0;
1877
- }
1878
- }
1879
- return resolvedValue;
1880
- };
1881
- }
1882
- function createAsync(compute2, value, options) {
1883
- let refreshing = false;
1884
- const node = new EagerComputation(
1885
- value,
1886
- (p) => {
1887
- const source = compute2(p, refreshing);
1888
- refreshing = false;
1889
- const isPromise = source instanceof Promise;
1890
- const iterator = source[Symbol.asyncIterator];
1891
- if (!isPromise && !iterator) {
1892
- return source;
1893
- }
1894
- let abort = false;
1895
- onCleanup(() => abort = true);
1896
- let transition2 = ActiveTransition;
1897
- if (isPromise) {
1898
- source.then(
1899
- (value3) => {
1900
- if (abort)
1901
- return;
1902
- if (transition2)
1903
- return transition2.runTransition(() => {
1904
- node.write(value3, 0, true);
1905
- }, true);
1906
- node.write(value3, 0, true);
1907
- },
1908
- (error) => {
1909
- if (abort)
1910
- return;
1911
- if (transition2)
1912
- return transition2.runTransition(() => node.E(error), true);
1913
- node.E(error);
1914
- }
1915
- );
1916
- } else {
1917
- (async () => {
1918
- try {
1919
- for await (let value3 of source) {
1920
- if (abort)
1921
- return;
1922
- if (transition2)
1923
- return transition2.runTransition(() => {
1924
- node.write(value3, 0, true);
1925
- transition2 = null;
1926
- }, true);
1927
- node.write(value3, 0, true);
1928
- }
1929
- } catch (error) {
1930
- if (abort)
1931
- return;
1932
- if (transition2)
1933
- return transition2.runTransition(() => {
1934
- node.E(error);
1935
- transition2 = null;
1936
- }, true);
1937
- node.E(error);
1938
- }
1939
- })();
1940
- }
1941
- throw new NotReadyError();
1942
- },
1943
- options
1944
- );
1945
- const read = node.wait.bind(node);
1946
- read.refresh = () => {
1947
- let n = node;
1948
- if (ActiveTransition && !node.e) {
1949
- n = cloneGraph(node);
1950
- }
1951
- n.c = STATE_DIRTY;
1952
- refreshing = true;
1953
- n.K();
1954
- };
1955
- return read;
1956
- }
1957
- function createEffect(compute2, effect, value, options) {
1958
- void new Effect(
1959
- value,
1960
- compute2,
1961
- effect.effect ? effect.effect : effect,
1962
- effect.error,
1963
- options
1964
- );
1965
- }
1966
- function createRenderEffect(compute2, effect, value, options) {
1967
- void new Effect(value, compute2, effect, void 0, {
1968
- render: true,
1969
- ...options
1970
- });
1971
- }
1972
- function createRoot(init, options) {
1973
- const owner = new Owner(options == null ? void 0 : options.id);
1974
- return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
1975
- }
1976
- function runWithOwner(owner, run) {
1977
- return compute(owner, run, null);
1978
- }
1979
- function resolve(fn) {
1980
- return new Promise((res, rej) => {
1981
- createRoot((dispose) => {
1982
- new EagerComputation(void 0, () => {
1983
- try {
1984
- res(fn());
1985
- } catch (err) {
1986
- if (err instanceof NotReadyError)
1987
- throw err;
1988
- rej(err);
1989
- }
1990
- dispose();
1991
- });
1992
- });
1993
- });
1994
- }
1995
- function createPending() {
1996
- const node = new Computation(false, null);
1997
- const reset = () => node.write(false);
1998
- function write() {
1999
- if (!ActiveTransition)
2000
- return false;
2001
- ActiveTransition.addOptimistic(reset);
2002
- queueMicrotask(() => reset.j && node.write(true));
2003
- }
2004
- function read() {
2005
- const v = node.read();
2006
- return ActiveTransition ? false : v;
2007
- }
2008
- return [read, write];
2009
- }
2010
- function useTransition() {
2011
- const [pending, setPending] = createPending();
2012
- function start(fn) {
2013
- transition((resume) => {
2014
- setPending(true);
2015
- return fn(resume);
2016
- });
2017
- }
2018
- return [pending, start];
2019
- }
2020
- function createOptimistic(first, second, options) {
2021
- let store, setStore;
2022
- if (typeof first === "function") {
2023
- [store, setStore] = createStore((s) => {
2024
- const value = first(s);
2025
- if (!ActiveTransition)
2026
- return value;
2027
- ActiveTransition.addOptimistic(reset);
2028
- }, {});
2029
- } else
2030
- [store, setStore] = createStore(first);
2031
- const reset = () => setStore(
2032
- reconcile(
2033
- typeof first === "function" ? first(second) : first,
2034
- (options == null ? void 0 : options.key) || "id",
2035
- options == null ? void 0 : options.all
2036
- )
2037
- );
2038
- function write(v) {
2039
- if (!ActiveTransition)
2040
- throw new Error("createOptimistic can only be updated inside a transition");
2041
- ActiveTransition.addOptimistic(reset);
2042
- queueMicrotask(() => reset.j && setStore(v));
2043
- }
2044
- return [store, write];
2045
- }
2046
-
2047
2060
  // src/map.ts
2048
2061
  function mapArray(list, map, options) {
2049
2062
  const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
2050
2063
  return updateKeyedMap.bind({
2051
- S: new Owner(),
2064
+ U: new Owner(),
2052
2065
  o: 0,
2053
2066
  ia: list,
2054
- G: [],
2055
- P: map,
2067
+ F: [],
2068
+ Q: map,
2056
2069
  i: [],
2057
2070
  d: [],
2058
- Q: keyFn,
2071
+ R: keyFn,
2059
2072
  p: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
2060
2073
  q: map.length > 1 ? [] : void 0,
2061
- T: options == null ? void 0 : options.fallback
2074
+ V: options == null ? void 0 : options.fallback
2062
2075
  });
2063
2076
  }
2064
2077
  var pureOptions = { pureWrite: true };
2065
2078
  function updateKeyedMap() {
2066
2079
  const newItems = this.ia() || [], newLen = newItems.length;
2067
2080
  newItems[$TRACK];
2068
- runWithOwner(this.S, () => {
2081
+ runWithOwner(this.U, () => {
2069
2082
  let i, j, mapper = this.p ? () => {
2070
2083
  this.p[j] = new Computation(newItems[j], null, pureOptions);
2071
2084
  this.q && (this.q[j] = new Computation(j, null, pureOptions));
2072
- return this.P(
2085
+ return this.Q(
2073
2086
  Computation.prototype.read.bind(this.p[j]),
2074
2087
  this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
2075
2088
  );
2076
2089
  } : this.q ? () => {
2077
2090
  const item = newItems[j];
2078
2091
  this.q[j] = new Computation(j, null, pureOptions);
2079
- return this.P(() => item, Computation.prototype.read.bind(this.q[j]));
2092
+ return this.Q(() => item, Computation.prototype.read.bind(this.q[j]));
2080
2093
  } : () => {
2081
2094
  const item = newItems[j];
2082
- return this.P(() => item);
2095
+ return this.Q(() => item);
2083
2096
  };
2084
2097
  if (newLen === 0) {
2085
2098
  if (this.o !== 0) {
2086
- this.S.dispose(false);
2099
+ this.U.dispose(false);
2087
2100
  this.d = [];
2088
- this.G = [];
2101
+ this.F = [];
2089
2102
  this.i = [];
2090
2103
  this.o = 0;
2091
2104
  this.p && (this.p = []);
2092
2105
  this.q && (this.q = []);
2093
2106
  }
2094
- if (this.T && !this.i[0]) {
2107
+ if (this.V && !this.i[0]) {
2095
2108
  this.i[0] = compute(
2096
2109
  this.d[0] = new Owner(),
2097
- this.T,
2110
+ this.V,
2098
2111
  null
2099
2112
  );
2100
2113
  }
@@ -2103,17 +2116,17 @@ function updateKeyedMap() {
2103
2116
  this.d[0].dispose();
2104
2117
  this.i = new Array(newLen);
2105
2118
  for (j = 0; j < newLen; j++) {
2106
- this.G[j] = newItems[j];
2119
+ this.F[j] = newItems[j];
2107
2120
  this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2108
2121
  }
2109
2122
  this.o = newLen;
2110
2123
  } else {
2111
2124
  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;
2112
- for (start = 0, end = Math.min(this.o, newLen); start < end && (this.G[start] === newItems[start] || this.p && compare(this.Q, this.G[start], newItems[start])); start++) {
2125
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.R, this.F[start], newItems[start])); start++) {
2113
2126
  if (this.p)
2114
2127
  this.p[start].write(newItems[start]);
2115
2128
  }
2116
- for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.p && compare(this.Q, this.G[end], newItems[newEnd])); end--, newEnd--) {
2129
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.R, this.F[end], newItems[newEnd])); end--, newEnd--) {
2117
2130
  temp[newEnd] = this.i[end];
2118
2131
  tempNodes[newEnd] = this.d[end];
2119
2132
  tempRows && (tempRows[newEnd] = this.p[end]);
@@ -2123,14 +2136,14 @@ function updateKeyedMap() {
2123
2136
  newIndicesNext = new Array(newEnd + 1);
2124
2137
  for (j = newEnd; j >= start; j--) {
2125
2138
  item = newItems[j];
2126
- key = this.Q ? this.Q(item) : item;
2139
+ key = this.R ? this.R(item) : item;
2127
2140
  i = newIndices.get(key);
2128
2141
  newIndicesNext[j] = i === void 0 ? -1 : i;
2129
2142
  newIndices.set(key, j);
2130
2143
  }
2131
2144
  for (i = start; i <= end; i++) {
2132
- item = this.G[i];
2133
- key = this.Q ? this.Q(item) : item;
2145
+ item = this.F[i];
2146
+ key = this.R ? this.R(item) : item;
2134
2147
  j = newIndices.get(key);
2135
2148
  if (j !== void 0 && j !== -1) {
2136
2149
  temp[j] = this.i[i];
@@ -2159,60 +2172,60 @@ function updateKeyedMap() {
2159
2172
  }
2160
2173
  }
2161
2174
  this.i = this.i.slice(0, this.o = newLen);
2162
- this.G = newItems.slice(0);
2175
+ this.F = newItems.slice(0);
2163
2176
  }
2164
2177
  });
2165
2178
  return this.i;
2166
2179
  }
2167
2180
  function repeat(count, map, options) {
2168
2181
  return updateRepeat.bind({
2169
- S: new Owner(),
2182
+ U: new Owner(),
2170
2183
  o: 0,
2171
- z: 0,
2184
+ x: 0,
2172
2185
  ja: count,
2173
- P: map,
2186
+ Q: map,
2174
2187
  d: [],
2175
2188
  i: [],
2176
2189
  ka: options == null ? void 0 : options.from,
2177
- T: options == null ? void 0 : options.fallback
2190
+ V: options == null ? void 0 : options.fallback
2178
2191
  });
2179
2192
  }
2180
2193
  function updateRepeat() {
2181
2194
  var _a;
2182
2195
  const newLen = this.ja();
2183
2196
  const from = ((_a = this.ka) == null ? void 0 : _a.call(this)) || 0;
2184
- runWithOwner(this.S, () => {
2197
+ runWithOwner(this.U, () => {
2185
2198
  if (newLen === 0) {
2186
2199
  if (this.o !== 0) {
2187
- this.S.dispose(false);
2200
+ this.U.dispose(false);
2188
2201
  this.d = [];
2189
2202
  this.i = [];
2190
2203
  this.o = 0;
2191
2204
  }
2192
- if (this.T && !this.i[0]) {
2205
+ if (this.V && !this.i[0]) {
2193
2206
  this.i[0] = compute(
2194
2207
  this.d[0] = new Owner(),
2195
- this.T,
2208
+ this.V,
2196
2209
  null
2197
2210
  );
2198
2211
  }
2199
2212
  return;
2200
2213
  }
2201
2214
  const to = from + newLen;
2202
- const prevTo = this.z + this.o;
2215
+ const prevTo = this.x + this.o;
2203
2216
  if (this.o === 0 && this.d[0])
2204
2217
  this.d[0].dispose();
2205
2218
  for (let i = to; i < prevTo; i++)
2206
- this.d[i - this.z].dispose();
2207
- if (this.z < from) {
2208
- let i = this.z;
2219
+ this.d[i - this.x].dispose();
2220
+ if (this.x < from) {
2221
+ let i = this.x;
2209
2222
  while (i < from && i < this.o)
2210
2223
  this.d[i++].dispose();
2211
- this.d.splice(0, from - this.z);
2212
- this.i.splice(0, from - this.z);
2213
- } else if (this.z > from) {
2214
- let i = prevTo - this.z - 1;
2215
- let difference = this.z - from;
2224
+ this.d.splice(0, from - this.x);
2225
+ this.i.splice(0, from - this.x);
2226
+ } else if (this.x > from) {
2227
+ let i = prevTo - this.x - 1;
2228
+ let difference = this.x - from;
2216
2229
  this.d.length = this.i.length = newLen;
2217
2230
  while (i >= difference) {
2218
2231
  this.d[i] = this.d[i - difference];
@@ -2222,7 +2235,7 @@ function updateRepeat() {
2222
2235
  for (let i2 = 0; i2 < difference; i2++) {
2223
2236
  this.i[i2] = compute(
2224
2237
  this.d[i2] = new Owner(),
2225
- () => this.P(i2 + from),
2238
+ () => this.Q(i2 + from),
2226
2239
  null
2227
2240
  );
2228
2241
  }
@@ -2230,12 +2243,12 @@ function updateRepeat() {
2230
2243
  for (let i = prevTo; i < to; i++) {
2231
2244
  this.i[i - from] = compute(
2232
2245
  this.d[i - from] = new Owner(),
2233
- () => this.P(i),
2246
+ () => this.Q(i),
2234
2247
  null
2235
2248
  );
2236
2249
  }
2237
2250
  this.i = this.i.slice(0, newLen);
2238
- this.z = from;
2251
+ this.x = from;
2239
2252
  this.o = newLen;
2240
2253
  });
2241
2254
  return this.i;
@@ -2246,24 +2259,24 @@ function compare(key, a, b) {
2246
2259
 
2247
2260
  // src/boundaries.ts
2248
2261
  var BoundaryComputation = class extends EagerComputation {
2249
- U;
2262
+ W;
2250
2263
  constructor(compute2, propagationMask) {
2251
2264
  super(void 0, compute2, { defer: true });
2252
- this.U = propagationMask;
2265
+ this.W = propagationMask;
2253
2266
  }
2254
2267
  write(value, flags) {
2255
- super.write(value, flags & ~this.U);
2256
- if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT || ActiveTransition)) {
2268
+ super.write(value, flags & ~this.W);
2269
+ if (this.W & LOADING_BIT && !(this.h & UNINITIALIZED_BIT || ActiveTransition)) {
2257
2270
  flags &= ~LOADING_BIT;
2258
2271
  }
2259
- getQueue(this).notify(this, this.U, flags);
2272
+ getQueue(this).notify(this, this.W, flags);
2260
2273
  return this.l;
2261
2274
  }
2262
2275
  };
2263
2276
  function createBoundChildren(owner, fn, queue, mask) {
2264
- const parentQueue = owner.B;
2265
- parentQueue.addChild(owner.B = queue);
2266
- onCleanup(() => parentQueue.removeChild(owner.B));
2277
+ const parentQueue = owner.z;
2278
+ parentQueue.addChild(owner.z = queue);
2279
+ onCleanup(() => parentQueue.removeChild(owner.z));
2267
2280
  return compute(
2268
2281
  owner,
2269
2282
  () => {
@@ -2274,77 +2287,73 @@ function createBoundChildren(owner, fn, queue, mask) {
2274
2287
  );
2275
2288
  }
2276
2289
  var ConditionalQueue = class extends Queue {
2277
- t;
2278
- V = /* @__PURE__ */ new Set();
2279
- s = /* @__PURE__ */ new Set();
2290
+ s;
2291
+ X = /* @__PURE__ */ new Set();
2292
+ r = /* @__PURE__ */ new Set();
2280
2293
  constructor(disabled) {
2281
2294
  super();
2282
- this.t = disabled;
2295
+ this.s = disabled;
2283
2296
  }
2284
2297
  run(type) {
2285
- if (!type || this.t.read())
2298
+ if (!type || this.s.read())
2286
2299
  return;
2287
2300
  return super.run(type);
2288
2301
  }
2289
2302
  notify(node, type, flags) {
2290
- if (ActiveTransition && ActiveTransition.r.has(this))
2291
- return ActiveTransition.r.get(this).notify(node, type, flags);
2292
- if (this.t.read()) {
2303
+ if (this.s.read()) {
2293
2304
  if (type & LOADING_BIT) {
2294
2305
  if (flags & LOADING_BIT) {
2295
- this.s.add(node);
2306
+ this.r.add(node);
2296
2307
  type &= ~LOADING_BIT;
2297
- } else if (this.s.delete(node))
2308
+ } else if (this.r.delete(node))
2298
2309
  type &= ~LOADING_BIT;
2299
2310
  }
2300
2311
  if (type & ERROR_BIT) {
2301
2312
  if (flags & ERROR_BIT) {
2302
- this.V.add(node);
2313
+ this.X.add(node);
2303
2314
  type &= ~ERROR_BIT;
2304
- } else if (this.V.delete(node))
2315
+ } else if (this.X.delete(node))
2305
2316
  type &= ~ERROR_BIT;
2306
2317
  }
2307
2318
  }
2308
2319
  return type ? super.notify(node, type, flags) : true;
2309
2320
  }
2310
2321
  merge(queue) {
2311
- queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2312
- queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2322
+ queue.r.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2323
+ queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2313
2324
  super.merge(queue);
2314
2325
  }
2315
2326
  };
2316
2327
  var CollectionQueue = class extends Queue {
2317
- J;
2328
+ K;
2318
2329
  d = /* @__PURE__ */ new Set();
2319
- t = new Computation(false, null, { pureWrite: true });
2330
+ s = new Computation(false, null, { pureWrite: true });
2320
2331
  constructor(type) {
2321
2332
  super();
2322
- this.J = type;
2333
+ this.K = type;
2323
2334
  }
2324
2335
  run(type) {
2325
- if (!type || this.t.read())
2336
+ if (!type || this.s.read())
2326
2337
  return;
2327
2338
  return super.run(type);
2328
2339
  }
2329
2340
  notify(node, type, flags) {
2330
- if (ActiveTransition && ActiveTransition.r.has(this))
2331
- return ActiveTransition.r.get(this).notify(node, type, flags);
2332
- if (!(type & this.J))
2341
+ if (!(type & this.K))
2333
2342
  return super.notify(node, type, flags);
2334
- if (flags & this.J) {
2343
+ if (flags & this.K) {
2335
2344
  this.d.add(node);
2336
2345
  if (this.d.size === 1)
2337
- this.t.write(true);
2346
+ this.s.write(true);
2338
2347
  } else if (this.d.size > 0) {
2339
2348
  this.d.delete(node);
2340
2349
  if (this.d.size === 0)
2341
- this.t.write(false);
2350
+ this.s.write(false);
2342
2351
  }
2343
- type &= ~this.J;
2352
+ type &= ~this.K;
2344
2353
  return type ? super.notify(node, type, flags) : true;
2345
2354
  }
2346
2355
  merge(queue) {
2347
- queue.d.forEach((n) => this.notify(n, this.J, this.J));
2356
+ queue.d.forEach((n) => this.notify(n, this.K, this.K));
2348
2357
  super.merge(queue);
2349
2358
  }
2350
2359
  };
@@ -2355,25 +2364,25 @@ function createBoundary(fn, condition) {
2355
2364
  );
2356
2365
  const tree = createBoundChildren(owner, fn, queue, 0);
2357
2366
  new EagerComputation(void 0, () => {
2358
- const disabled = queue.t.read();
2359
- tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
2367
+ const disabled = queue.s.read();
2368
+ tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
2360
2369
  if (!disabled) {
2361
- queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2362
- queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2363
- queue.s.clear();
2364
- queue.V.clear();
2370
+ queue.r.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2371
+ queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2372
+ queue.r.clear();
2373
+ queue.X.clear();
2365
2374
  }
2366
2375
  });
2367
- return () => queue.t.read() ? void 0 : tree.read();
2376
+ return () => queue.s.read() ? void 0 : tree.read();
2368
2377
  }
2369
2378
  function createCollectionBoundary(type, fn, fallback) {
2370
2379
  const owner = new Owner();
2371
2380
  const queue = new CollectionQueue(type);
2372
2381
  const tree = createBoundChildren(owner, fn, queue, type);
2373
2382
  const decision = new Computation(void 0, () => {
2374
- if (!queue.t.read()) {
2383
+ if (!queue.s.read()) {
2375
2384
  const resolved = tree.read();
2376
- if (!untrack(() => queue.t.read()))
2385
+ if (!untrack(() => queue.s.read()))
2377
2386
  return resolved;
2378
2387
  }
2379
2388
  return fallback(queue);
@@ -2386,13 +2395,13 @@ function createSuspense(fn, fallback) {
2386
2395
  function createErrorBoundary(fn, fallback) {
2387
2396
  return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2388
2397
  let node = getTransitionSource(queue.d.values().next().value);
2389
- return fallback(node.L, () => {
2398
+ return fallback(node.M, () => {
2390
2399
  incrementClock();
2391
2400
  for (let node2 of queue.d) {
2392
2401
  if (ActiveTransition && !node2.e)
2393
2402
  node2 = cloneGraph(node2);
2394
2403
  node2.c = STATE_DIRTY;
2395
- getQueue(node2).enqueue(node2.C, node2.F.bind(node2));
2404
+ getQueue(node2).enqueue(node2.A, node2.E.bind(node2));
2396
2405
  }
2397
2406
  });
2398
2407
  });