@solidjs/signals 0.8.7 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/prod.js CHANGED
@@ -40,11 +40,11 @@ function actualInsertIntoHeap(e, t) {
40
40
  if (r === undefined) t.l[i] = e;
41
41
  else {
42
42
  const t = r.T;
43
- t.R = e;
43
+ t.h = e;
44
44
  e.T = t;
45
45
  r.T = e;
46
46
  }
47
- if (i > t.h) t.h = i;
47
+ if (i > t.R) t.R = i;
48
48
  }
49
49
  function insertIntoHeap(e, t) {
50
50
  let n = e._;
@@ -67,21 +67,21 @@ function deleteFromHeap(e, t) {
67
67
  const i = e.o;
68
68
  if (e.T === e) t.l[i] = undefined;
69
69
  else {
70
- const n = e.R;
70
+ const n = e.h;
71
71
  const r = t.l[i];
72
72
  const s = n ?? r;
73
73
  if (e === r) t.l[i] = n;
74
- else e.T.R = n;
74
+ else e.T.h = n;
75
75
  s.T = e.T;
76
76
  }
77
77
  e.T = e;
78
- e.R = undefined;
78
+ e.h = undefined;
79
79
  }
80
80
  function markHeap(e) {
81
81
  if (e.S) return;
82
82
  e.S = true;
83
- for (let t = 0; t <= e.h; t++) {
84
- for (let n = e.l[t]; n !== undefined; n = n.R) {
83
+ for (let t = 0; t <= e.R; t++) {
84
+ for (let n = e.l[t]; n !== undefined; n = n.h) {
85
85
  if (n._ & REACTIVE_IN_HEAP) markNode(n);
86
86
  }
87
87
  }
@@ -103,7 +103,7 @@ function markNode(e, t = REACTIVE_DIRTY) {
103
103
  }
104
104
  function runHeap(e, t) {
105
105
  e.S = false;
106
- for (e.C = 0; e.C <= e.h; e.C++) {
106
+ for (e.C = 0; e.C <= e.R; e.C++) {
107
107
  let n = e.l[e.C];
108
108
  while (n !== undefined) {
109
109
  if (n._ & REACTIVE_IN_HEAP) t(n);
@@ -111,7 +111,7 @@ function runHeap(e, t) {
111
111
  n = e.l[e.C];
112
112
  }
113
113
  }
114
- e.h = 0;
114
+ e.R = 0;
115
115
  }
116
116
  function adjustHeight(e, t) {
117
117
  deleteFromHeap(e, t);
@@ -129,8 +129,8 @@ function adjustHeight(e, t) {
129
129
  }
130
130
  }
131
131
  const transitions = new Set();
132
- const dirtyQueue = { l: new Array(2e3).fill(undefined), S: false, C: 0, h: 0 };
133
- const zombieQueue = { l: new Array(2e3).fill(undefined), S: false, C: 0, h: 0 };
132
+ const dirtyQueue = { l: new Array(2e3).fill(undefined), S: false, C: 0, R: 0 };
133
+ const zombieQueue = { l: new Array(2e3).fill(undefined), S: false, C: 0, R: 0 };
134
134
  let clock = 0;
135
135
  let activeTransition = null;
136
136
  let scheduled = false;
@@ -214,7 +214,7 @@ class GlobalQueue extends Queue {
214
214
  this.stashQueues(activeTransition.queueStash);
215
215
  clock++;
216
216
  scheduled = false;
217
- runPending(activeTransition.pendingNodes, true);
217
+ runTransitionPending(activeTransition.pendingNodes, true);
218
218
  activeTransition = null;
219
219
  return;
220
220
  }
@@ -222,18 +222,14 @@ class GlobalQueue extends Queue {
222
222
  this.restoreQueues(activeTransition.queueStash);
223
223
  transitions.delete(activeTransition);
224
224
  activeTransition = null;
225
- if (runPending(this.$, false)) runHeap(dirtyQueue, GlobalQueue.L);
225
+ runTransitionPending(this.$, false);
226
+ dirtyQueue.R >= dirtyQueue.C && runHeap(dirtyQueue, GlobalQueue.L);
226
227
  } else if (transitions.size) runHeap(zombieQueue, GlobalQueue.L);
227
- for (let e = 0; e < this.$.length; e++) {
228
- const t = this.$[e];
229
- if (t.W !== NOT_PENDING) {
230
- t.j = t.W;
231
- t.W = NOT_PENDING;
232
- if (t.K) t.M = true;
233
- }
234
- if (t.m) GlobalQueue.F(t, false, true);
228
+ runPending(this.$);
229
+ while (dirtyQueue.R >= dirtyQueue.C) {
230
+ runHeap(dirtyQueue, GlobalQueue.L);
231
+ runPending(this.$);
235
232
  }
236
- this.$.length = 0;
237
233
  clock++;
238
234
  scheduled = false;
239
235
  this.run(EFFECT_RENDER);
@@ -245,8 +241,8 @@ class GlobalQueue extends Queue {
245
241
  notify(e, t, n) {
246
242
  if (t & STATUS_PENDING) {
247
243
  if (n & STATUS_PENDING) {
248
- if (activeTransition && !activeTransition.asyncNodes.includes(e.Y.cause)) {
249
- activeTransition.asyncNodes.push(e.Y.cause);
244
+ if (activeTransition && !activeTransition.asyncNodes.includes(e.W.cause)) {
245
+ activeTransition.asyncNodes.push(e.W.cause);
250
246
  schedule();
251
247
  }
252
248
  }
@@ -257,7 +253,7 @@ class GlobalQueue extends Queue {
257
253
  initTransition(e) {
258
254
  if (activeTransition && activeTransition.time === clock) return;
259
255
  if (!activeTransition) {
260
- activeTransition = e.B ?? {
256
+ activeTransition = e.j ?? {
261
257
  time: clock,
262
258
  pendingNodes: [],
263
259
  asyncNodes: [],
@@ -268,29 +264,36 @@ class GlobalQueue extends Queue {
268
264
  activeTransition.time = clock;
269
265
  for (let e = 0; e < this.$.length; e++) {
270
266
  const t = this.$[e];
271
- t.B = activeTransition;
267
+ t.j = activeTransition;
272
268
  activeTransition.pendingNodes.push(t);
273
269
  }
274
270
  this.$ = activeTransition.pendingNodes;
275
271
  }
276
272
  }
277
- function runPending(e, t) {
278
- let n = false;
279
- const i = e.slice();
280
- for (let e = 0; e < i.length; e++) {
281
- const r = i[e];
282
- r.B = activeTransition;
283
- if (r.X) {
284
- r.X.q(t);
285
- n = true;
273
+ function runPending(e) {
274
+ for (let t = 0; t < e.length; t++) {
275
+ const n = e[t];
276
+ if (n.K !== NOT_PENDING) {
277
+ n.M = n.K;
278
+ n.K = NOT_PENDING;
279
+ if (n.Y) n.B = true;
286
280
  }
287
- if (r.Z && r.Z.W !== NOT_PENDING) {
288
- r.Z.q(r.Z.W);
289
- r.Z.W = NOT_PENDING;
290
- n = true;
281
+ if (n.X && n.X.K !== NOT_PENDING) n.X.q(n.X.K);
282
+ if (n.m) GlobalQueue.F(n, false, true);
283
+ }
284
+ e.length = 0;
285
+ }
286
+ function runTransitionPending(e, t) {
287
+ const n = e.slice();
288
+ for (let e = 0; e < n.length; e++) {
289
+ const i = n[e];
290
+ i.j = activeTransition;
291
+ if (i.Z) i.Z.q(t);
292
+ if (i.X && i.X.K !== NOT_PENDING) {
293
+ i.X.q(i.X.K);
294
+ i.X.K = NOT_PENDING;
291
295
  }
292
296
  }
293
- return n;
294
297
  }
295
298
  const globalQueue = new GlobalQueue();
296
299
  function flush() {
@@ -313,7 +316,7 @@ function transitionComplete(e) {
313
316
  }
314
317
  function runInTransition(e, t) {
315
318
  const n = activeTransition;
316
- activeTransition = e.B;
319
+ activeTransition = e.j;
317
320
  t(e);
318
321
  activeTransition = n;
319
322
  }
@@ -323,6 +326,7 @@ let tracking = false;
323
326
  let stale = false;
324
327
  let pendingValueCheck = false;
325
328
  let pendingCheck = null;
329
+ let refreshing = false;
326
330
  let context = null;
327
331
  function notifySubs(e) {
328
332
  for (let t = e.O; t !== null; t = t.p) {
@@ -332,11 +336,11 @@ function notifySubs(e) {
332
336
  }
333
337
  }
334
338
  function recompute(e, t = false) {
335
- const n = e.K && e.B != activeTransition;
339
+ const n = e.Y && e.j != activeTransition;
336
340
  if (!t) {
337
- if (e.B && activeTransition !== e.B && !n) globalQueue.initTransition(e);
341
+ if (e.j && activeTransition !== e.j && !n) globalQueue.initTransition(e);
338
342
  deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
339
- if (e.B) disposeChildren(e);
343
+ if (e.j) disposeChildren(e);
340
344
  else {
341
345
  markDisposal(e);
342
346
  e.ee = e.te;
@@ -350,15 +354,15 @@ function recompute(e, t = false) {
350
354
  e.re = null;
351
355
  e._ = REACTIVE_RECOMPUTING_DEPS;
352
356
  e.se = clock;
353
- let r = e.W === NOT_PENDING ? e.j : e.W;
357
+ let r = e.K === NOT_PENDING ? e.M : e.K;
354
358
  let s = e.o;
355
359
  let o = e.J;
356
- let u = e.Y;
360
+ let u = e.W;
357
361
  let l = tracking;
358
362
  setStatusFlags(e, STATUS_NONE | (o & STATUS_UNINITIALIZED));
359
363
  tracking = true;
360
364
  try {
361
- r = e.m(r);
365
+ r = handleAsync(e, e.m(r));
362
366
  e.J &= ~STATUS_UNINITIALIZED;
363
367
  } catch (t) {
364
368
  if (t instanceof NotReadyError) {
@@ -381,14 +385,14 @@ function recompute(e, t = false) {
381
385
  else e.D = null;
382
386
  }
383
387
  }
384
- const c = !e.oe || !e.oe(e.W === NOT_PENDING || e.ue || n ? e.j : e.W, r);
385
- const a = e.J !== o || e.Y !== u;
388
+ const c = !e.oe || !e.oe(e.K === NOT_PENDING || e.ue || n ? e.M : e.K, r);
389
+ const a = e.J !== o || e.W !== u;
386
390
  e.le?.(a, o);
387
391
  if (c || a) {
388
392
  if (c) {
389
- if (t || e.ue || n) e.j = r;
390
- else e.W = r;
391
- if (e.Z) e.Z.W = r;
393
+ if (t || e.ue || n) e.M = r;
394
+ else e.K = r;
395
+ if (e.X) e.X.K = r;
392
396
  }
393
397
  for (let t = e.O; t !== null; t = t.p) {
394
398
  const n = t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
@@ -400,8 +404,55 @@ function recompute(e, t = false) {
400
404
  insertIntoHeapHeight(t.A, t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
401
405
  }
402
406
  }
403
- if ((!t || e.J & STATUS_PENDING) && !e.ue && !e.B) globalQueue.$.push(e);
404
- if (e.B && n) runInTransition(e, recompute);
407
+ if ((!t || e.J & STATUS_PENDING) && !e.ue && !e.j) globalQueue.$.push(e);
408
+ if (e.j && n) runInTransition(e, recompute);
409
+ }
410
+ function handleAsync(e, t, n) {
411
+ const i = typeof t === "object" && t !== null;
412
+ const r = i && t instanceof Promise;
413
+ const s = i && untrack(() => t[Symbol.asyncIterator]);
414
+ if (!r && !s) {
415
+ e.ce = null;
416
+ return t;
417
+ }
418
+ e.ce = t;
419
+ if (r) {
420
+ t.then(i => {
421
+ if (e.ce !== t) return;
422
+ globalQueue.initTransition(e);
423
+ n?.(i) ?? setSignal(e, () => i);
424
+ flush();
425
+ }).catch(n => {
426
+ if (e.ce !== t) return;
427
+ globalQueue.initTransition(e);
428
+ setStatusFlags(e, STATUS_ERROR, n);
429
+ e.se = clock;
430
+ notifySubs(e);
431
+ schedule();
432
+ flush();
433
+ });
434
+ } else {
435
+ (async () => {
436
+ try {
437
+ for await (let i of t) {
438
+ if (e.ce !== t) return;
439
+ globalQueue.initTransition(e);
440
+ n?.(i) ?? setSignal(e, () => i);
441
+ flush();
442
+ }
443
+ } catch (n) {
444
+ if (e.ce !== t) return;
445
+ globalQueue.initTransition(e);
446
+ setStatusFlags(e, STATUS_ERROR, n);
447
+ e.se = clock;
448
+ notifySubs(e);
449
+ schedule();
450
+ flush();
451
+ }
452
+ })();
453
+ }
454
+ globalQueue.initTransition(e);
455
+ throw new NotReadyError(context);
405
456
  }
406
457
  function updateIfNecessary(e) {
407
458
  if (e._ & REACTIVE_CHECK) {
@@ -425,15 +476,15 @@ function unlinkSubs(e) {
425
476
  const t = e.V;
426
477
  const n = e.P;
427
478
  const i = e.p;
428
- const r = e.ce;
429
- if (i !== null) i.ce = r;
430
- else t.ae = r;
479
+ const r = e.ae;
480
+ if (i !== null) i.ae = r;
481
+ else t.fe = r;
431
482
  if (r !== null) r.p = i;
432
483
  else {
433
484
  t.O = i;
434
485
  if (i === null) {
435
- t.fe?.();
436
- t.m && !t.Ee && unobserved(t);
486
+ t.Ee?.();
487
+ t.m && !t.de && unobserved(t);
437
488
  }
438
489
  }
439
490
  return n;
@@ -459,9 +510,9 @@ function link(e, t) {
459
510
  return;
460
511
  }
461
512
  }
462
- const s = e.ae;
513
+ const s = e.fe;
463
514
  if (s !== null && s.A === t && (!r || isValidLink(s, t))) return;
464
- const o = (t.re = e.ae = { V: e, A: t, P: i, ce: s, p: null });
515
+ const o = (t.re = e.fe = { V: e, A: t, P: i, ae: s, p: null });
465
516
  if (n !== null) n.P = o;
466
517
  else t.D = o;
467
518
  if (s !== null) s.p = o;
@@ -481,7 +532,7 @@ function isValidLink(e, t) {
481
532
  }
482
533
  function setStatusFlags(e, t, n = null) {
483
534
  e.J = t;
484
- e.Y = n;
535
+ e.W = n;
485
536
  }
486
537
  function markDisposal(e) {
487
538
  let t = e.ie;
@@ -492,7 +543,7 @@ function markDisposal(e) {
492
543
  insertIntoHeap(t, zombieQueue);
493
544
  }
494
545
  markDisposal(t);
495
- t = t.de;
546
+ t = t.Te;
496
547
  }
497
548
  }
498
549
  function dispose(e) {
@@ -509,7 +560,7 @@ function disposeChildren(e, t = false, n) {
509
560
  if (t) e._ = REACTIVE_DISPOSED;
510
561
  let i = n ? e.ne : e.ie;
511
562
  while (i) {
512
- const e = i.de;
563
+ const e = i.Te;
513
564
  if (i.D) {
514
565
  const e = i;
515
566
  deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
@@ -527,7 +578,7 @@ function disposeChildren(e, t = false, n) {
527
578
  e.ne = null;
528
579
  } else {
529
580
  e.ie = null;
530
- e.de = null;
581
+ e.Te = null;
531
582
  }
532
583
  runDisposal(e, n);
533
584
  }
@@ -545,7 +596,7 @@ function runDisposal(e, t) {
545
596
  t ? (e.ee = null) : (e.te = null);
546
597
  }
547
598
  function getNextChildId(e) {
548
- if (e.id != null) return formatId(e.id, e.Te++);
599
+ if (e.id != null) return formatId(e.id, e.he++);
549
600
  throw new Error("Cannot get child id from owner without an id");
550
601
  }
551
602
  function formatId(e, t) {
@@ -558,33 +609,34 @@ function computed(e, t, n) {
558
609
  id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
559
610
  oe: n?.equals != null ? n.equals : isEqual,
560
611
  Re: !!n?.pureWrite,
561
- fe: n?.unobserved,
612
+ Ee: n?.unobserved,
562
613
  te: null,
563
- he: context?.he ?? globalQueue,
564
- _e: context?._e ?? defaultContext,
565
- Te: 0,
614
+ _e: context?._e ?? globalQueue,
615
+ Se: context?.Se ?? defaultContext,
616
+ he: 0,
566
617
  m: e,
567
- j: t,
618
+ M: t,
568
619
  o: 0,
569
620
  N: null,
570
- R: undefined,
621
+ h: undefined,
571
622
  T: null,
572
623
  D: null,
573
624
  re: null,
574
625
  O: null,
575
- ae: null,
626
+ fe: null,
576
627
  i: context,
577
- de: null,
628
+ Te: null,
578
629
  ie: null,
579
630
  _: REACTIVE_NONE,
580
631
  J: STATUS_UNINITIALIZED,
581
632
  se: clock,
582
- W: NOT_PENDING,
633
+ K: NOT_PENDING,
583
634
  ee: null,
584
635
  ne: null,
585
- B: null
636
+ ce: null,
637
+ j: null
586
638
  };
587
- if (n?.Se) Object.assign(i, n.Se);
639
+ if (n?.Oe) Object.assign(i, n.Oe);
588
640
  i.T = i;
589
641
  const r = context?.t ? context.u : context;
590
642
  if (context) {
@@ -592,7 +644,7 @@ function computed(e, t, n) {
592
644
  if (e === null) {
593
645
  context.ie = i;
594
646
  } else {
595
- i.de = e;
647
+ i.Te = e;
596
648
  context.ie = i;
597
649
  }
598
650
  }
@@ -600,79 +652,20 @@ function computed(e, t, n) {
600
652
  recompute(i, true);
601
653
  return i;
602
654
  }
603
- function asyncComputed(e, t, n) {
604
- let i = undefined;
605
- let r = false;
606
- const fn = t => {
607
- const n = e(t, r);
608
- r = false;
609
- i = n;
610
- const o = n instanceof Promise;
611
- const u = n[Symbol.asyncIterator];
612
- if (!o && !u) {
613
- return n;
614
- }
615
- if (o) {
616
- n.then(e => {
617
- if (i !== n) return;
618
- globalQueue.initTransition(s);
619
- setSignal(s, () => e);
620
- flush();
621
- }).catch(e => {
622
- if (i !== n) return;
623
- globalQueue.initTransition(s);
624
- setStatusFlags(s, STATUS_ERROR, e);
625
- s.se = clock;
626
- notifySubs(s);
627
- schedule();
628
- flush();
629
- });
630
- } else {
631
- (async () => {
632
- try {
633
- for await (let e of n) {
634
- if (i !== n) return;
635
- globalQueue.initTransition(s);
636
- setSignal(s, () => e);
637
- flush();
638
- }
639
- } catch (e) {
640
- if (i !== n) return;
641
- globalQueue.initTransition(s);
642
- setStatusFlags(s, STATUS_ERROR, e);
643
- s.se = clock;
644
- notifySubs(s);
645
- schedule();
646
- flush();
647
- }
648
- })();
649
- }
650
- globalQueue.initTransition(context);
651
- throw new NotReadyError(context);
652
- };
653
- const s = computed(fn, t, n);
654
- s.Oe = () => {
655
- r = true;
656
- recompute(s);
657
- schedule();
658
- flush();
659
- };
660
- return s;
661
- }
662
655
  function signal(e, t, n = null) {
663
656
  const i = {
664
657
  id: t?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
665
658
  oe: t?.equals != null ? t.equals : isEqual,
666
659
  Re: !!t?.pureWrite,
667
- fe: t?.unobserved,
668
- j: e,
660
+ Ee: t?.unobserved,
661
+ M: e,
669
662
  O: null,
670
- ae: null,
663
+ fe: null,
671
664
  J: STATUS_NONE,
672
665
  se: clock,
673
666
  U: n,
674
667
  I: n?.N || null,
675
- W: NOT_PENDING
668
+ K: NOT_PENDING
676
669
  };
677
670
  n && (n.N = i);
678
671
  return i;
@@ -692,6 +685,7 @@ function untrack(e) {
692
685
  function read(e) {
693
686
  let t = context;
694
687
  if (t?.t) t = t.u;
688
+ if (refreshing && e.m) recompute(e);
695
689
  if (t && tracking && !pendingCheck && !pendingValueCheck) {
696
690
  if (e.m && e._ & REACTIVE_DISPOSED) recompute(e);
697
691
  link(e, t);
@@ -710,33 +704,33 @@ function read(e) {
710
704
  }
711
705
  }
712
706
  if (pendingCheck) {
713
- if (!e.X) {
714
- e.X = signal(false);
715
- e.X.ue = true;
716
- e.X.q = t => setSignal(e.X, t);
707
+ if (!e.Z) {
708
+ e.Z = signal(false);
709
+ e.Z.ue = true;
710
+ e.Z.q = t => setSignal(e.Z, t);
717
711
  }
718
712
  const t = pendingCheck;
719
713
  pendingCheck = null;
720
- t.j = read(e.X) || t.j;
714
+ t.M = read(e.Z) || t.M;
721
715
  pendingCheck = t;
722
716
  }
723
717
  if (pendingValueCheck) {
724
- if (!e.Z) {
725
- e.Z = signal(e.j);
726
- e.Z.ue = true;
727
- e.Z.q = t => setSignal(e.Z, t);
718
+ if (!e.X) {
719
+ e.X = signal(e.M);
720
+ e.X.ue = true;
721
+ e.X.q = t => setSignal(e.X, t);
728
722
  }
729
723
  pendingValueCheck = false;
730
724
  try {
731
- return read(e.Z);
725
+ return read(e.X);
732
726
  } finally {
733
727
  pendingValueCheck = true;
734
728
  }
735
729
  }
736
730
  if (e.J & STATUS_PENDING && !pendingCheck) {
737
- if ((t && !stale) || e.J & STATUS_UNINITIALIZED) throw e.Y;
731
+ if ((t && !stale) || e.J & STATUS_UNINITIALIZED) throw e.W;
738
732
  else if (t && stale) {
739
- setStatusFlags(t, t.J | 1, e.Y);
733
+ setStatusFlags(t, t.J | 1, e.W);
740
734
  }
741
735
  }
742
736
  if (e.J & STATUS_ERROR) {
@@ -744,29 +738,29 @@ function read(e) {
744
738
  recompute(e, true);
745
739
  return read(e);
746
740
  } else {
747
- throw e.Y;
741
+ throw e.W;
748
742
  }
749
743
  }
750
744
  return !t ||
751
745
  e.ue ||
752
- e.W === NOT_PENDING ||
753
- (stale && !pendingCheck && e.B && activeTransition !== e.B)
754
- ? e.j
755
- : e.W;
746
+ e.K === NOT_PENDING ||
747
+ (stale && !pendingCheck && e.j && activeTransition !== e.j)
748
+ ? e.M
749
+ : e.K;
756
750
  }
757
751
  function setSignal(e, t) {
758
752
  if (typeof t === "function") {
759
- t = t(e.W === NOT_PENDING ? e.j : e.W);
753
+ t = t(e.K === NOT_PENDING ? e.M : e.K);
760
754
  }
761
- const n = !e.oe || !e.oe(e.W === NOT_PENDING || e.ue ? e.j : e.W, t);
755
+ const n = !e.oe || !e.oe(e.K === NOT_PENDING || e.ue ? e.M : e.K, t);
762
756
  if (!n && !e.J) return t;
763
757
  if (n) {
764
- if (e.ue) e.j = t;
758
+ if (e.ue) e.M = t;
765
759
  else {
766
- if (e.W === NOT_PENDING) globalQueue.$.push(e);
767
- e.W = t;
760
+ if (e.K === NOT_PENDING) globalQueue.$.push(e);
761
+ e.K = t;
768
762
  }
769
- if (e.Z) e.Z.W = t;
763
+ if (e.X) e.X.K = t;
770
764
  }
771
765
  setStatusFlags(e, STATUS_NONE);
772
766
  e.se = clock;
@@ -798,12 +792,12 @@ function createOwner(e) {
798
792
  t: true,
799
793
  u: t?.t ? t.u : t,
800
794
  ie: null,
801
- de: null,
795
+ Te: null,
802
796
  te: null,
803
797
  id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
804
- he: t?.he ?? globalQueue,
805
- _e: t?._e || defaultContext,
806
- Te: 0,
798
+ _e: t?._e ?? globalQueue,
799
+ Se: t?.Se || defaultContext,
800
+ he: 0,
807
801
  ee: null,
808
802
  ne: null,
809
803
  i: t,
@@ -816,7 +810,7 @@ function createOwner(e) {
816
810
  if (e === null) {
817
811
  t.ie = n;
818
812
  } else {
819
- n.de = e;
813
+ n.Te = e;
820
814
  t.ie = n;
821
815
  }
822
816
  }
@@ -855,10 +849,10 @@ function pending(e) {
855
849
  }
856
850
  function isPending(e) {
857
851
  const t = pendingCheck;
858
- pendingCheck = { j: false };
852
+ pendingCheck = { M: false };
859
853
  try {
860
854
  staleValues(e);
861
- return pendingCheck.j;
855
+ return pendingCheck.M;
862
856
  } catch (e) {
863
857
  if (!(e instanceof NotReadyError)) return false;
864
858
  throw e;
@@ -866,6 +860,22 @@ function isPending(e) {
866
860
  pendingCheck = t;
867
861
  }
868
862
  }
863
+ function refresh(e) {
864
+ let t = refreshing;
865
+ refreshing = true;
866
+ try {
867
+ return untrack(e);
868
+ } finally {
869
+ refreshing = t;
870
+ if (!t) {
871
+ schedule();
872
+ flush();
873
+ }
874
+ }
875
+ }
876
+ function isRefreshing() {
877
+ return refreshing;
878
+ }
869
879
  function createContext(e, t) {
870
880
  return { id: Symbol(t), defaultValue: e };
871
881
  }
@@ -873,7 +883,7 @@ function getContext(e, t = getOwner()) {
873
883
  if (!t) {
874
884
  throw new NoOwnerError();
875
885
  }
876
- const n = hasContext(e, t) ? t._e[e.id] : e.defaultValue;
886
+ const n = hasContext(e, t) ? t.Se[e.id] : e.defaultValue;
877
887
  if (isUndefined(n)) {
878
888
  throw new ContextNotFoundError();
879
889
  }
@@ -883,10 +893,10 @@ function setContext(e, t, n = getOwner()) {
883
893
  if (!n) {
884
894
  throw new NoOwnerError();
885
895
  }
886
- n._e = { ...n._e, [e.id]: isUndefined(t) ? e.defaultValue : t };
896
+ n.Se = { ...n.Se, [e.id]: isUndefined(t) ? e.defaultValue : t };
887
897
  }
888
898
  function hasContext(e, t) {
889
- return !isUndefined(t?._e[e.id]);
899
+ return !isUndefined(t?.Se[e.id]);
890
900
  }
891
901
  function isUndefined(e) {
892
902
  return typeof e === "undefined";
@@ -895,23 +905,23 @@ function effect(e, t, n, i, r) {
895
905
  let s = false;
896
906
  const o = computed(e, i, {
897
907
  ...r,
898
- Se: {
899
- M: true,
908
+ Oe: {
909
+ B: true,
900
910
  pe: i,
901
911
  Ae: t,
902
912
  Ne: n,
903
913
  Ie: undefined,
904
- K: r?.render ? EFFECT_RENDER : EFFECT_USER,
914
+ Y: r?.render ? EFFECT_RENDER : EFFECT_USER,
905
915
  le(e, t) {
906
916
  if (s) {
907
917
  const n = this.J && this.J === t && e;
908
- this.M = !(this.J & STATUS_ERROR) && !(this.J & STATUS_PENDING & ~t) && !n;
909
- if (this.M) this.he.enqueue(this.K, runEffect.bind(this));
918
+ this.B = !(this.J & STATUS_ERROR) && !(this.J & STATUS_PENDING & ~t) && !n;
919
+ if (this.B) this._e.enqueue(this.Y, runEffect.bind(this));
910
920
  }
911
921
  if (this.J & STATUS_ERROR) {
912
- let e = this.Y;
913
- this.he.notify(this, STATUS_PENDING, 0);
914
- if (this.K === EFFECT_USER) {
922
+ let e = this.W;
923
+ this._e.notify(this, STATUS_PENDING, 0);
924
+ if (this.Y === EFFECT_USER) {
915
925
  try {
916
926
  return this.Ne
917
927
  ? this.Ne(e, () => {
@@ -923,31 +933,31 @@ function effect(e, t, n, i, r) {
923
933
  e = t;
924
934
  }
925
935
  }
926
- if (!this.he.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
927
- } else if (this.K === EFFECT_RENDER) {
928
- this.he.notify(this, STATUS_PENDING | STATUS_ERROR, this.J);
936
+ if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
937
+ } else if (this.Y === EFFECT_RENDER) {
938
+ this._e.notify(this, STATUS_PENDING | STATUS_ERROR, this.J);
929
939
  }
930
940
  }
931
941
  }
932
942
  });
933
943
  s = true;
934
- if (o.K === EFFECT_RENDER) o.m = t => staleValues(() => e(t));
944
+ if (o.Y === EFFECT_RENDER) o.m = t => staleValues(() => e(t));
935
945
  !r?.defer &&
936
946
  !(o.J & (STATUS_ERROR | STATUS_PENDING)) &&
937
- (o.K === EFFECT_USER ? o.he.enqueue(o.K, runEffect.bind(o)) : runEffect.call(o));
947
+ (o.Y === EFFECT_USER ? o._e.enqueue(o.Y, runEffect.bind(o)) : runEffect.call(o));
938
948
  onCleanup(() => o.Ie?.());
939
949
  }
940
950
  function runEffect() {
941
- if (!this.M || this._ & REACTIVE_DISPOSED) return;
951
+ if (!this.B || this._ & REACTIVE_DISPOSED) return;
942
952
  this.Ie?.();
943
953
  this.Ie = undefined;
944
954
  try {
945
- this.Ie = this.Ae(this.j, this.pe);
955
+ this.Ie = this.Ae(this.M, this.pe);
946
956
  } catch (e) {
947
- if (!this.he.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
957
+ if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
948
958
  } finally {
949
- this.pe = this.j;
950
- this.M = false;
959
+ this.pe = this.M;
960
+ this.B = false;
951
961
  }
952
962
  }
953
963
  function createSignal(e, t, n) {
@@ -964,12 +974,6 @@ function createMemo(e, t, n) {
964
974
  let i = computed(e, t, n);
965
975
  return read.bind(null, i);
966
976
  }
967
- function createAsync(e, t, n) {
968
- const i = asyncComputed(e, t, n);
969
- const r = read.bind(null, i);
970
- r.refresh = i.Oe;
971
- return r;
972
- }
973
977
  function createEffect(e, t, n, i) {
974
978
  void effect(e, t.effect || t, t.error, n, i);
975
979
  }
@@ -1049,7 +1053,7 @@ function applyState(e, t, n, i) {
1049
1053
  let t = false;
1050
1054
  const l = getOverrideValue(s, o, u, "length");
1051
1055
  if (e.length && l && e[0] && n(e[0]) != null) {
1052
- let c, a, f, E, d, T, R, h;
1056
+ let c, a, f, E, d, T, h, R;
1053
1057
  for (
1054
1058
  f = 0, E = Math.min(l, e.length);
1055
1059
  f < E && ((T = getOverrideValue(s, o, u, f)) === e[f] || (T && e[f] && n(T) === n(e[f])));
@@ -1083,22 +1087,22 @@ function applyState(e, t, n, i) {
1083
1087
  l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
1084
1088
  return;
1085
1089
  }
1086
- R = new Array(d + 1);
1090
+ h = new Array(d + 1);
1087
1091
  for (a = d; a >= f; a--) {
1088
1092
  T = e[a];
1089
- h = T ? n(T) : T;
1090
- c = S.get(h);
1091
- R[a] = c === undefined ? -1 : c;
1092
- S.set(h, a);
1093
+ R = T ? n(T) : T;
1094
+ c = S.get(R);
1095
+ h[a] = c === undefined ? -1 : c;
1096
+ S.set(R, a);
1093
1097
  }
1094
1098
  for (c = f; c <= E; c++) {
1095
1099
  T = getOverrideValue(s, o, u, c);
1096
- h = T ? n(T) : T;
1097
- a = S.get(h);
1100
+ R = T ? n(T) : T;
1101
+ a = S.get(R);
1098
1102
  if (a !== undefined && a !== -1) {
1099
1103
  _[a] = T;
1100
- a = R[a];
1101
- S.set(h, a);
1104
+ a = h[a];
1105
+ S.set(R, a);
1102
1106
  }
1103
1107
  }
1104
1108
  for (a = f; a < e.length; a++) {
@@ -1173,11 +1177,12 @@ function createProjectionInternal(e, t = {}, n) {
1173
1177
  };
1174
1178
  const s = wrapProjection(t);
1175
1179
  i = computed(() => {
1176
- storeSetter(s, t => {
1177
- const i = e(t);
1178
- if (i !== t && i !== undefined) {
1179
- reconcile(i, n?.key || "id", n?.all)(t);
1180
- }
1180
+ const t = i || getOwner();
1181
+ storeSetter(s, i => {
1182
+ const r = handleAsync(t, e(i), e => {
1183
+ e !== i && e !== undefined && storeSetter(s, reconcile(e, n?.key || "id", n?.all));
1184
+ });
1185
+ r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(i);
1181
1186
  });
1182
1187
  });
1183
1188
  return { store: s, node: i };
@@ -1277,7 +1282,7 @@ const storeTraps = {
1277
1282
  if (e && e.get) return e.get.call(n);
1278
1283
  }
1279
1284
  if (Writing?.has(n)) {
1280
- let n = r && (s || !o) ? (r.W !== NOT_PENDING ? r.W : r.j) : u[t];
1285
+ let n = r && (s || !o) ? (r.K !== NOT_PENDING ? r.K : r.M) : u[t];
1281
1286
  n === $DELETED && (n = undefined);
1282
1287
  if (!isWrappable(n)) return n;
1283
1288
  const i = wrap(n, e);
@@ -1710,7 +1715,7 @@ function updateKeyedMap() {
1710
1715
  E = new Array(t),
1711
1716
  d = new Array(t),
1712
1717
  T = this.Ue ? new Array(t) : undefined,
1713
- R = this.me ? new Array(t) : undefined;
1718
+ h = this.me ? new Array(t) : undefined;
1714
1719
  for (
1715
1720
  s = 0, o = Math.min(this.ye, t);
1716
1721
  s < o && (this.De[s] === e[s] || (this.Ue && compare(this.Ve, this.De[s], e[s])));
@@ -1728,7 +1733,7 @@ function updateKeyedMap() {
1728
1733
  E[u] = this.we[o];
1729
1734
  d[u] = this.be[o];
1730
1735
  T && (T[u] = this.Ue[o]);
1731
- R && (R[u] = this.me[o]);
1736
+ h && (h[u] = this.me[o]);
1732
1737
  }
1733
1738
  a = new Map();
1734
1739
  f = new Array(u + 1);
@@ -1747,7 +1752,7 @@ function updateKeyedMap() {
1747
1752
  E[i] = this.we[n];
1748
1753
  d[i] = this.be[n];
1749
1754
  T && (T[i] = this.Ue[n]);
1750
- R && (R[i] = this.me[n]);
1755
+ h && (h[i] = this.me[n]);
1751
1756
  i = f[i];
1752
1757
  a.set(c, i);
1753
1758
  } else this.be[n].dispose();
@@ -1760,8 +1765,8 @@ function updateKeyedMap() {
1760
1765
  this.Ue[i] = T[i];
1761
1766
  setSignal(this.Ue[i], e[i]);
1762
1767
  }
1763
- if (R) {
1764
- this.me[i] = R[i];
1768
+ if (h) {
1769
+ this.me[i] = h[i];
1765
1770
  setSignal(this.me[i], i);
1766
1771
  }
1767
1772
  } else {
@@ -1839,26 +1844,26 @@ function compare(e, t, n) {
1839
1844
  }
1840
1845
  function boundaryComputed(e, t) {
1841
1846
  const n = computed(e, undefined, {
1842
- Se: {
1847
+ Oe: {
1843
1848
  le() {
1844
1849
  let e = this.J;
1845
1850
  this.J &= ~this.He;
1846
1851
  if (this.He & STATUS_PENDING && !(this.J & STATUS_UNINITIALIZED)) {
1847
1852
  e &= ~STATUS_PENDING;
1848
1853
  }
1849
- this.he.notify(this, this.He, e);
1854
+ this._e.notify(this, this.He, e);
1850
1855
  },
1851
1856
  He: t
1852
1857
  }
1853
1858
  });
1854
1859
  n.He = t;
1855
- n.Ee = true;
1860
+ n.de = true;
1856
1861
  return n;
1857
1862
  }
1858
1863
  function createBoundChildren(e, t, n, i) {
1859
- const r = e.he;
1860
- r.addChild((e.he = n));
1861
- onCleanup(() => r.removeChild(e.he));
1864
+ const r = e._e;
1865
+ r.addChild((e._e = n));
1866
+ onCleanup(() => r.removeChild(e._e));
1862
1867
  return runWithOwner(e, () => {
1863
1868
  const e = computed(t);
1864
1869
  return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
@@ -1974,7 +1979,7 @@ function collectErrorSources(e, t) {
1974
1979
  function createErrorBoundary(e, t) {
1975
1980
  return createCollectionBoundary(STATUS_ERROR, e, e => {
1976
1981
  let n = e.be.values().next().value;
1977
- return t(n.Y, () => {
1982
+ return t(n.W, () => {
1978
1983
  const t = [];
1979
1984
  for (const n of e.be) collectErrorSources(n, t);
1980
1985
  for (const e of t) recompute(e);
@@ -2039,7 +2044,6 @@ export {
2039
2044
  NoOwnerError,
2040
2045
  NotReadyError,
2041
2046
  SUPPORTS_PROXY,
2042
- createAsync,
2043
2047
  createBoundary,
2044
2048
  createContext,
2045
2049
  createEffect,
@@ -2064,6 +2068,7 @@ export {
2064
2068
  getOwner,
2065
2069
  isEqual,
2066
2070
  isPending,
2071
+ isRefreshing,
2067
2072
  isWrappable,
2068
2073
  mapArray,
2069
2074
  merge,
@@ -2072,6 +2077,7 @@ export {
2072
2077
  onSettled,
2073
2078
  pending,
2074
2079
  reconcile,
2080
+ refresh,
2075
2081
  repeat,
2076
2082
  resolve,
2077
2083
  runWithOwner,