@solidjs/signals 0.13.1 → 0.13.3

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/dev.js CHANGED
@@ -1021,6 +1021,8 @@ function runEffect() {
1021
1021
  try {
1022
1022
  this._cleanup = this._effectFn(this._value, this._prevValue);
1023
1023
  } catch (error) {
1024
+ this._error = new StatusError(this, error);
1025
+ this._statusFlags |= STATUS_ERROR;
1024
1026
  if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
1025
1027
  } finally {
1026
1028
  setStrictRead(prevStrictRead);
@@ -1355,6 +1357,7 @@ function signal(v, options, firewall = null) {
1355
1357
  const s = {
1356
1358
  _equals: options?.equals != null ? options.equals : isEqual,
1357
1359
  _pureWrite: !!options?.pureWrite,
1360
+ _noSnapshot: !!options?._noSnapshot,
1358
1361
  _unobserved: options?.unobserved,
1359
1362
  _value: v,
1360
1363
  _subs: null,
@@ -1366,7 +1369,11 @@ function signal(v, options, firewall = null) {
1366
1369
  };
1367
1370
  s._name = options?.name ?? "signal";
1368
1371
  firewall && (firewall._child = s);
1369
- if (snapshotCaptureActive && !s._pureWrite && !((firewall?._statusFlags ?? 0) & STATUS_PENDING)) {
1372
+ if (
1373
+ snapshotCaptureActive &&
1374
+ !s._noSnapshot &&
1375
+ !((firewall?._statusFlags ?? 0) & STATUS_PENDING)
1376
+ ) {
1370
1377
  s._snapshotValue = v === undefined ? NO_SNAPSHOT : v;
1371
1378
  snapshotSources.add(s);
1372
1379
  }
@@ -1519,7 +1526,7 @@ function read(el) {
1519
1526
  (currentOptimisticLane !== null &&
1520
1527
  (el._overrideValue !== undefined ||
1521
1528
  el._optimisticLane ||
1522
- owner === el ||
1529
+ (owner === el && stale) ||
1523
1530
  !!(owner._statusFlags & STATUS_PENDING))) ||
1524
1531
  el._pendingValue === NOT_PENDING ||
1525
1532
  (stale && el._transition && activeTransition !== el._transition)
@@ -3016,7 +3023,7 @@ const ON_INIT = Symbol();
3016
3023
  class CollectionQueue extends Queue {
3017
3024
  _collectionType;
3018
3025
  _sources = new Set();
3019
- _disabled = signal(false, { pureWrite: true });
3026
+ _disabled = signal(false, { pureWrite: true, _noSnapshot: true });
3020
3027
  _initialized = false;
3021
3028
  _onFn;
3022
3029
  _prevOn = ON_INIT;
package/dist/node.cjs CHANGED
@@ -955,6 +955,8 @@ function runEffect() {
955
955
  try {
956
956
  this.Te = this.Re(this.ae, this.He);
957
957
  } catch (e) {
958
+ this.Y = new StatusError(this, e);
959
+ this.de |= d;
958
960
  if (!this.fe.notify(this, d, d)) throw e;
959
961
  } finally {
960
962
  this.He = this.ae;
@@ -1256,6 +1258,7 @@ function signal(e, t, n = null) {
1256
1258
  const r = {
1257
1259
  me: t?.equals != null ? t.equals : isEqual,
1258
1260
  Fe: !!t?.pureWrite,
1261
+ Me: !!t?.Me,
1259
1262
  Pe: t?.unobserved,
1260
1263
  ae: e,
1261
1264
  O: null,
@@ -1266,7 +1269,7 @@ function signal(e, t, n = null) {
1266
1269
  ce: S
1267
1270
  };
1268
1271
  n && (n.C = r);
1269
- if (D && !r.Fe && !((n?.de ?? 0) & a)) {
1272
+ if (D && !r.Me && !((n?.de ?? 0) & a)) {
1270
1273
  r.ie = e === undefined ? w : e;
1271
1274
  B.add(r);
1272
1275
  }
@@ -1392,7 +1395,7 @@ function read(e) {
1392
1395
  }
1393
1396
  if (e.pe !== undefined && e.pe !== S) return e.pe;
1394
1397
  return !t ||
1395
- (V !== null && (e.pe !== undefined || e.re || n === e || !!(n.de & a))) ||
1398
+ (V !== null && (e.pe !== undefined || e.re || (n === e && R) || !!(n.de & a))) ||
1396
1399
  e.ce === S ||
1397
1400
  (R && e.ne && C !== e.ne)
1398
1401
  ? e.ae
@@ -1449,14 +1452,14 @@ function runWithOwner(e, t) {
1449
1452
  }
1450
1453
  }
1451
1454
  function getPendingSignal(e) {
1452
- if (!e.Me) {
1453
- e.Me = optimisticSignal(false, { pureWrite: true });
1455
+ if (!e.Ve) {
1456
+ e.Ve = optimisticSignal(false, { pureWrite: true });
1454
1457
  if (e.ye) {
1455
- e.Me.ye = e;
1458
+ e.Ve.ye = e;
1456
1459
  }
1457
- if (computePendingState(e)) setSignal(e.Me, true);
1460
+ if (computePendingState(e)) setSignal(e.Ve, true);
1458
1461
  }
1459
- return e.Me;
1462
+ return e.Ve;
1460
1463
  }
1461
1464
  function computePendingState(e) {
1462
1465
  const t = e;
@@ -1472,9 +1475,9 @@ function computePendingState(e) {
1472
1475
  return !!(t.de & a && !(t.de & p));
1473
1476
  }
1474
1477
  function updatePendingSignal(e) {
1475
- if (e.Me) {
1478
+ if (e.Ve) {
1476
1479
  const t = computePendingState(e);
1477
- const n = e.Me;
1480
+ const n = e.Ve;
1478
1481
  setSignal(n, t);
1479
1482
  if (!t && n.re) {
1480
1483
  const t = resolveLane(e);
@@ -2504,65 +2507,65 @@ function mapArray(e, t, n) {
2504
2507
  const s = t;
2505
2508
  return createMemo(
2506
2509
  updateKeyedMap.bind({
2507
- Ve: createOwner(),
2508
- De: 0,
2509
- Be: e,
2510
- Ge: [],
2511
- Ke: s,
2512
- ze: [],
2510
+ De: createOwner(),
2511
+ Be: 0,
2512
+ Ge: e,
2513
+ Ke: [],
2514
+ ze: s,
2513
2515
  Ue: [],
2514
- Je: r,
2515
- Xe: r || n?.keyed === false ? [] : undefined,
2516
- Ye: i ? [] : undefined,
2517
- Ze: n?.fallback
2516
+ Je: [],
2517
+ Xe: r,
2518
+ Ye: r || n?.keyed === false ? [] : undefined,
2519
+ Ze: i ? [] : undefined,
2520
+ $e: n?.fallback
2518
2521
  })
2519
2522
  );
2520
2523
  }
2521
2524
  const pe = { pureWrite: true };
2522
2525
  function updateKeyedMap() {
2523
- const e = this.Be() || [],
2526
+ const e = this.Ge() || [],
2524
2527
  t = e.length;
2525
2528
  e[K];
2526
- runWithOwner(this.Ve, () => {
2529
+ runWithOwner(this.De, () => {
2527
2530
  let n,
2528
2531
  r,
2529
- i = this.Xe
2532
+ i = this.Ye
2530
2533
  ? () => {
2531
- this.Xe[r] = signal(e[r], pe);
2532
- this.Ye && (this.Ye[r] = signal(r, pe));
2533
- return this.Ke(accessor(this.Xe[r]), this.Ye ? accessor(this.Ye[r]) : undefined);
2534
+ this.Ye[r] = signal(e[r], pe);
2535
+ this.Ze && (this.Ze[r] = signal(r, pe));
2536
+ return this.ze(accessor(this.Ye[r]), this.Ze ? accessor(this.Ze[r]) : undefined);
2534
2537
  }
2535
- : this.Ye
2538
+ : this.Ze
2536
2539
  ? () => {
2537
2540
  const t = e[r];
2538
- this.Ye[r] = signal(r, pe);
2539
- return this.Ke(() => t, accessor(this.Ye[r]));
2541
+ this.Ze[r] = signal(r, pe);
2542
+ return this.ze(() => t, accessor(this.Ze[r]));
2540
2543
  }
2541
2544
  : () => {
2542
2545
  const t = e[r];
2543
- return this.Ke(() => t);
2546
+ return this.ze(() => t);
2544
2547
  };
2545
2548
  if (t === 0) {
2546
- if (this.De !== 0) {
2547
- this.Ve.dispose(false);
2549
+ if (this.Be !== 0) {
2550
+ this.De.dispose(false);
2551
+ this.Je = [];
2552
+ this.Ke = [];
2548
2553
  this.Ue = [];
2549
- this.Ge = [];
2550
- this.ze = [];
2551
- this.De = 0;
2552
- this.Xe && (this.Xe = []);
2554
+ this.Be = 0;
2553
2555
  this.Ye && (this.Ye = []);
2556
+ this.Ze && (this.Ze = []);
2554
2557
  }
2555
- if (this.Ze && !this.ze[0]) {
2556
- this.ze[0] = runWithOwner((this.Ue[0] = createOwner()), this.Ze);
2558
+ if (this.$e && !this.Ue[0]) {
2559
+ this.Ue[0] = runWithOwner((this.Je[0] = createOwner()), this.$e);
2557
2560
  }
2558
- } else if (this.De === 0) {
2559
- if (this.Ue[0]) this.Ue[0].dispose();
2560
- this.ze = new Array(t);
2561
+ } else if (this.Be === 0) {
2562
+ if (this.Je[0]) this.Je[0].dispose();
2563
+ this.Ue = new Array(t);
2561
2564
  for (r = 0; r < t; r++) {
2562
- this.Ge[r] = e[r];
2563
- this.ze[r] = runWithOwner((this.Ue[r] = createOwner()), i);
2565
+ this.Ke[r] = e[r];
2566
+ this.Ue[r] = runWithOwner((this.Je[r] = createOwner()), i);
2564
2567
  }
2565
- this.De = t;
2568
+ this.Be = t;
2566
2569
  } else {
2567
2570
  let s,
2568
2571
  o,
@@ -2573,131 +2576,131 @@ function updateKeyedMap() {
2573
2576
  a,
2574
2577
  d = new Array(t),
2575
2578
  p = new Array(t),
2576
- h = this.Xe ? new Array(t) : undefined,
2577
- y = this.Ye ? new Array(t) : undefined;
2579
+ h = this.Ye ? new Array(t) : undefined,
2580
+ y = this.Ze ? new Array(t) : undefined;
2578
2581
  for (
2579
- s = 0, o = Math.min(this.De, t);
2580
- s < o && (this.Ge[s] === e[s] || (this.Xe && compare(this.Je, this.Ge[s], e[s])));
2582
+ s = 0, o = Math.min(this.Be, t);
2583
+ s < o && (this.Ke[s] === e[s] || (this.Ye && compare(this.Xe, this.Ke[s], e[s])));
2581
2584
  s++
2582
2585
  ) {
2583
- if (this.Xe) setSignal(this.Xe[s], e[s]);
2586
+ if (this.Ye) setSignal(this.Ye[s], e[s]);
2584
2587
  }
2585
2588
  for (
2586
- o = this.De - 1, u = t - 1;
2589
+ o = this.Be - 1, u = t - 1;
2587
2590
  o >= s &&
2588
2591
  u >= s &&
2589
- (this.Ge[o] === e[u] || (this.Xe && compare(this.Je, this.Ge[o], e[u])));
2592
+ (this.Ke[o] === e[u] || (this.Ye && compare(this.Xe, this.Ke[o], e[u])));
2590
2593
  o--, u--
2591
2594
  ) {
2592
- d[u] = this.ze[o];
2593
- p[u] = this.Ue[o];
2594
- h && (h[u] = this.Xe[o]);
2595
- y && (y[u] = this.Ye[o]);
2595
+ d[u] = this.Ue[o];
2596
+ p[u] = this.Je[o];
2597
+ h && (h[u] = this.Ye[o]);
2598
+ y && (y[u] = this.Ze[o]);
2596
2599
  }
2597
2600
  c = new Map();
2598
2601
  a = new Array(u + 1);
2599
2602
  for (r = u; r >= s; r--) {
2600
2603
  f = e[r];
2601
- l = this.Je ? this.Je(f) : f;
2604
+ l = this.Xe ? this.Xe(f) : f;
2602
2605
  n = c.get(l);
2603
2606
  a[r] = n === undefined ? -1 : n;
2604
2607
  c.set(l, r);
2605
2608
  }
2606
2609
  for (n = s; n <= o; n++) {
2607
- f = this.Ge[n];
2608
- l = this.Je ? this.Je(f) : f;
2610
+ f = this.Ke[n];
2611
+ l = this.Xe ? this.Xe(f) : f;
2609
2612
  r = c.get(l);
2610
2613
  if (r !== undefined && r !== -1) {
2611
- d[r] = this.ze[n];
2612
- p[r] = this.Ue[n];
2613
- h && (h[r] = this.Xe[n]);
2614
- y && (y[r] = this.Ye[n]);
2614
+ d[r] = this.Ue[n];
2615
+ p[r] = this.Je[n];
2616
+ h && (h[r] = this.Ye[n]);
2617
+ y && (y[r] = this.Ze[n]);
2615
2618
  r = a[r];
2616
2619
  c.set(l, r);
2617
- } else this.Ue[n].dispose();
2620
+ } else this.Je[n].dispose();
2618
2621
  }
2619
2622
  for (r = s; r < t; r++) {
2620
2623
  if (r in d) {
2621
- this.ze[r] = d[r];
2622
- this.Ue[r] = p[r];
2624
+ this.Ue[r] = d[r];
2625
+ this.Je[r] = p[r];
2623
2626
  if (h) {
2624
- this.Xe[r] = h[r];
2625
- setSignal(this.Xe[r], e[r]);
2627
+ this.Ye[r] = h[r];
2628
+ setSignal(this.Ye[r], e[r]);
2626
2629
  }
2627
2630
  if (y) {
2628
- this.Ye[r] = y[r];
2629
- setSignal(this.Ye[r], r);
2631
+ this.Ze[r] = y[r];
2632
+ setSignal(this.Ze[r], r);
2630
2633
  }
2631
2634
  } else {
2632
- this.ze[r] = runWithOwner((this.Ue[r] = createOwner()), i);
2635
+ this.Ue[r] = runWithOwner((this.Je[r] = createOwner()), i);
2633
2636
  }
2634
2637
  }
2635
- this.ze = this.ze.slice(0, (this.De = t));
2636
- this.Ge = e.slice(0);
2638
+ this.Ue = this.Ue.slice(0, (this.Be = t));
2639
+ this.Ke = e.slice(0);
2637
2640
  }
2638
2641
  });
2639
- return this.ze;
2642
+ return this.Ue;
2640
2643
  }
2641
2644
  function repeat(e, t, n) {
2642
2645
  const r = t;
2643
2646
  return updateRepeat.bind({
2644
- Ve: createOwner(),
2645
- De: 0,
2646
- $e: 0,
2647
- et: e,
2648
- Ke: r,
2647
+ De: createOwner(),
2648
+ Be: 0,
2649
+ et: 0,
2650
+ tt: e,
2651
+ ze: r,
2652
+ Je: [],
2649
2653
  Ue: [],
2650
- ze: [],
2651
- tt: n?.from,
2652
- Ze: n?.fallback
2654
+ nt: n?.from,
2655
+ $e: n?.fallback
2653
2656
  });
2654
2657
  }
2655
2658
  function updateRepeat() {
2656
- const e = this.et();
2657
- const t = this.tt?.() || 0;
2658
- runWithOwner(this.Ve, () => {
2659
+ const e = this.tt();
2660
+ const t = this.nt?.() || 0;
2661
+ runWithOwner(this.De, () => {
2659
2662
  if (e === 0) {
2660
- if (this.De !== 0) {
2661
- this.Ve.dispose(false);
2663
+ if (this.Be !== 0) {
2664
+ this.De.dispose(false);
2665
+ this.Je = [];
2662
2666
  this.Ue = [];
2663
- this.ze = [];
2664
- this.De = 0;
2667
+ this.Be = 0;
2665
2668
  }
2666
- if (this.Ze && !this.ze[0]) {
2667
- this.ze[0] = runWithOwner((this.Ue[0] = createOwner()), this.Ze);
2669
+ if (this.$e && !this.Ue[0]) {
2670
+ this.Ue[0] = runWithOwner((this.Je[0] = createOwner()), this.$e);
2668
2671
  }
2669
2672
  return;
2670
2673
  }
2671
2674
  const n = t + e;
2672
- const r = this.$e + this.De;
2673
- if (this.De === 0 && this.Ue[0]) this.Ue[0].dispose();
2674
- for (let e = n; e < r; e++) this.Ue[e - this.$e].dispose();
2675
- if (this.$e < t) {
2676
- let e = this.$e;
2677
- while (e < t && e < this.De) this.Ue[e++].dispose();
2678
- this.Ue.splice(0, t - this.$e);
2679
- this.ze.splice(0, t - this.$e);
2680
- } else if (this.$e > t) {
2681
- let n = r - this.$e - 1;
2682
- let i = this.$e - t;
2683
- this.Ue.length = this.ze.length = e;
2675
+ const r = this.et + this.Be;
2676
+ if (this.Be === 0 && this.Je[0]) this.Je[0].dispose();
2677
+ for (let e = n; e < r; e++) this.Je[e - this.et].dispose();
2678
+ if (this.et < t) {
2679
+ let e = this.et;
2680
+ while (e < t && e < this.Be) this.Je[e++].dispose();
2681
+ this.Je.splice(0, t - this.et);
2682
+ this.Ue.splice(0, t - this.et);
2683
+ } else if (this.et > t) {
2684
+ let n = r - this.et - 1;
2685
+ let i = this.et - t;
2686
+ this.Je.length = this.Ue.length = e;
2684
2687
  while (n >= i) {
2688
+ this.Je[n] = this.Je[n - i];
2685
2689
  this.Ue[n] = this.Ue[n - i];
2686
- this.ze[n] = this.ze[n - i];
2687
2690
  n--;
2688
2691
  }
2689
2692
  for (let e = 0; e < i; e++) {
2690
- this.ze[e] = runWithOwner((this.Ue[e] = createOwner()), () => this.Ke(e + t));
2693
+ this.Ue[e] = runWithOwner((this.Je[e] = createOwner()), () => this.ze(e + t));
2691
2694
  }
2692
2695
  }
2693
2696
  for (let e = r; e < n; e++) {
2694
- this.ze[e - t] = runWithOwner((this.Ue[e - t] = createOwner()), () => this.Ke(e));
2697
+ this.Ue[e - t] = runWithOwner((this.Je[e - t] = createOwner()), () => this.ze(e));
2695
2698
  }
2696
- this.ze = this.ze.slice(0, e);
2697
- this.$e = t;
2698
- this.De = e;
2699
+ this.Ue = this.Ue.slice(0, e);
2700
+ this.et = t;
2701
+ this.Be = e;
2699
2702
  });
2700
- return this.ze;
2703
+ return this.Ue;
2701
2704
  }
2702
2705
  function compare(e, t, n) {
2703
2706
  return e ? e(t) === e(n) : true;
@@ -2707,10 +2710,10 @@ function boundaryComputed(e, t) {
2707
2710
  n._e = (e, t) => {
2708
2711
  const r = e !== undefined ? e : n.de;
2709
2712
  const i = t !== undefined ? t : n.Y;
2710
- n.de &= ~n.nt;
2711
- n.fe.notify(n, n.nt, r, i);
2713
+ n.de &= ~n.rt;
2714
+ n.fe.notify(n, n.rt, r, i);
2712
2715
  };
2713
- n.nt = t;
2716
+ n.rt = t;
2714
2717
  n.ve = true;
2715
2718
  recompute(n, true);
2716
2719
  return n;
@@ -2726,57 +2729,57 @@ function createBoundChildren(e, t, n, r) {
2726
2729
  }
2727
2730
  const he = Symbol();
2728
2731
  class CollectionQueue extends Queue {
2729
- rt;
2730
- it = new Set();
2731
- st = signal(false, { pureWrite: true });
2732
- ot = false;
2733
- ut;
2734
- ft = he;
2732
+ it;
2733
+ st = new Set();
2734
+ ot = signal(false, { pureWrite: true, Me: true });
2735
+ ut = false;
2736
+ ft;
2737
+ lt = he;
2735
2738
  constructor(e) {
2736
2739
  super();
2737
- this.rt = e;
2740
+ this.it = e;
2738
2741
  }
2739
2742
  run(e) {
2740
- if (!e || read(this.st)) return;
2743
+ if (!e || read(this.ot)) return;
2741
2744
  return super.run(e);
2742
2745
  }
2743
2746
  notify(e, t, n, r) {
2744
- if (!(t & this.rt)) return super.notify(e, t, n, r);
2745
- if (this.ot && this.ut) {
2747
+ if (!(t & this.it)) return super.notify(e, t, n, r);
2748
+ if (this.ut && this.ft) {
2746
2749
  const e = untrack(() => {
2747
2750
  try {
2748
- return this.ut();
2751
+ return this.ft();
2749
2752
  } catch {
2750
2753
  return he;
2751
2754
  }
2752
2755
  });
2753
- if (e !== this.ft) {
2754
- this.ft = e;
2755
- this.ot = false;
2756
- this.it.clear();
2756
+ if (e !== this.lt) {
2757
+ this.lt = e;
2758
+ this.ut = false;
2759
+ this.st.clear();
2757
2760
  }
2758
2761
  }
2759
- if (this.rt & a && this.ot) return super.notify(e, t, n, r);
2760
- if (n & this.rt) {
2762
+ if (this.it & a && this.ut) return super.notify(e, t, n, r);
2763
+ if (n & this.it) {
2761
2764
  const t = r?.source || e.Y?.source;
2762
2765
  if (t) {
2763
- const e = this.it.size === 0;
2764
- this.it.add(t);
2765
- if (e) setSignal(this.st, true);
2766
+ const e = this.st.size === 0;
2767
+ this.st.add(t);
2768
+ if (e) setSignal(this.ot, true);
2766
2769
  }
2767
2770
  }
2768
- t &= ~this.rt;
2771
+ t &= ~this.it;
2769
2772
  return t ? super.notify(e, t, n, r) : true;
2770
2773
  }
2771
2774
  checkSources() {
2772
- for (const e of this.it) {
2773
- if (!(e.de & this.rt)) this.it.delete(e);
2775
+ for (const e of this.st) {
2776
+ if (!(e.de & this.it)) this.st.delete(e);
2774
2777
  }
2775
- if (!this.it.size) {
2776
- setSignal(this.st, false);
2777
- if (this.ut) {
2778
+ if (!this.st.size) {
2779
+ setSignal(this.ot, false);
2780
+ if (this.ft) {
2778
2781
  try {
2779
- this.ft = untrack(() => this.ut());
2782
+ this.lt = untrack(() => this.ft());
2780
2783
  } catch {}
2781
2784
  }
2782
2785
  }
@@ -2785,13 +2788,13 @@ class CollectionQueue extends Queue {
2785
2788
  function createCollectionBoundary(e, t, n, r) {
2786
2789
  const i = createOwner();
2787
2790
  const s = new CollectionQueue(e);
2788
- if (r) s.ut = r;
2791
+ if (r) s.ft = r;
2789
2792
  const o = createBoundChildren(i, t, s, e);
2790
2793
  const u = computed(() => {
2791
- if (!read(s.st)) {
2794
+ if (!read(s.ot)) {
2792
2795
  const e = read(o);
2793
- if (!untrack(() => read(s.st))) {
2794
- s.ot = true;
2796
+ if (!untrack(() => read(s.ot))) {
2797
+ s.ut = true;
2795
2798
  return e;
2796
2799
  }
2797
2800
  }
@@ -2804,10 +2807,10 @@ function createLoadingBoundary(e, t, n) {
2804
2807
  }
2805
2808
  function createErrorBoundary(e, t) {
2806
2809
  return createCollectionBoundary(d, e, e => {
2807
- let n = e.it.values().next().value;
2810
+ let n = e.st.values().next().value;
2808
2811
  const r = n.Y?.cause ?? n.Y;
2809
2812
  return t(r, () => {
2810
- for (const t of e.it) recompute(t);
2813
+ for (const t of e.st) recompute(t);
2811
2814
  schedule();
2812
2815
  });
2813
2816
  });
package/dist/prod.js CHANGED
@@ -954,6 +954,8 @@ function runEffect() {
954
954
  try {
955
955
  this.We = this.Ue(this.fe, this.ke);
956
956
  } catch (e) {
957
+ this.q = new StatusError(this, e);
958
+ this.Ee |= STATUS_ERROR;
957
959
  if (!this.ce.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
958
960
  } finally {
959
961
  this.ke = this.fe;
@@ -1256,6 +1258,7 @@ function signal(e, t, n = null) {
1256
1258
  const i = {
1257
1259
  Ie: t?.equals != null ? t.equals : isEqual,
1258
1260
  Ge: !!t?.pureWrite,
1261
+ Qe: !!t?.Qe,
1259
1262
  ge: t?.unobserved,
1260
1263
  fe: e,
1261
1264
  I: null,
@@ -1266,7 +1269,7 @@ function signal(e, t, n = null) {
1266
1269
  le: NOT_PENDING
1267
1270
  };
1268
1271
  n && (n.A = i);
1269
- if (snapshotCaptureActive && !i.Ge && !((n?.Ee ?? 0) & STATUS_PENDING)) {
1272
+ if (snapshotCaptureActive && !i.Qe && !((n?.Ee ?? 0) & STATUS_PENDING)) {
1270
1273
  i.re = e === undefined ? NO_SNAPSHOT : e;
1271
1274
  snapshotSources.add(i);
1272
1275
  }
@@ -1393,7 +1396,7 @@ function read(e) {
1393
1396
  if (e.Te !== undefined && e.Te !== NOT_PENDING) return e.Te;
1394
1397
  return !t ||
1395
1398
  (currentOptimisticLane !== null &&
1396
- (e.Te !== undefined || e.ie || n === e || !!(n.Ee & STATUS_PENDING))) ||
1399
+ (e.Te !== undefined || e.ie || (n === e && stale) || !!(n.Ee & STATUS_PENDING))) ||
1397
1400
  e.le === NOT_PENDING ||
1398
1401
  (stale && e.ne && activeTransition !== e.ne)
1399
1402
  ? e.fe
@@ -1450,14 +1453,14 @@ function runWithOwner(e, t) {
1450
1453
  }
1451
1454
  }
1452
1455
  function getPendingSignal(e) {
1453
- if (!e.Qe) {
1454
- e.Qe = optimisticSignal(false, { pureWrite: true });
1456
+ if (!e.Fe) {
1457
+ e.Fe = optimisticSignal(false, { pureWrite: true });
1455
1458
  if (e.Se) {
1456
- e.Qe.Se = e;
1459
+ e.Fe.Se = e;
1457
1460
  }
1458
- if (computePendingState(e)) setSignal(e.Qe, true);
1461
+ if (computePendingState(e)) setSignal(e.Fe, true);
1459
1462
  }
1460
- return e.Qe;
1463
+ return e.Fe;
1461
1464
  }
1462
1465
  function computePendingState(e) {
1463
1466
  const t = e;
@@ -1473,9 +1476,9 @@ function computePendingState(e) {
1473
1476
  return !!(t.Ee & STATUS_PENDING && !(t.Ee & STATUS_UNINITIALIZED));
1474
1477
  }
1475
1478
  function updatePendingSignal(e) {
1476
- if (e.Qe) {
1479
+ if (e.Fe) {
1477
1480
  const t = computePendingState(e);
1478
- const n = e.Qe;
1481
+ const n = e.Fe;
1479
1482
  setSignal(n, t);
1480
1483
  if (!t && n.ie) {
1481
1484
  const t = resolveLane(e);
@@ -2555,65 +2558,65 @@ function mapArray(e, t, n) {
2555
2558
  const o = t;
2556
2559
  return createMemo(
2557
2560
  updateKeyedMap.bind({
2558
- Fe: createOwner(),
2559
- Me: 0,
2560
- $e: e,
2561
- je: [],
2562
- Ke: o,
2563
- Ye: [],
2561
+ Me: createOwner(),
2562
+ $e: 0,
2563
+ je: e,
2564
+ Ke: [],
2565
+ Ye: o,
2564
2566
  Be: [],
2565
- Ze: i,
2566
- qe: i || n?.keyed === false ? [] : undefined,
2567
- Xe: r ? [] : undefined,
2568
- ze: n?.fallback
2567
+ Ze: [],
2568
+ qe: i,
2569
+ Xe: i || n?.keyed === false ? [] : undefined,
2570
+ ze: r ? [] : undefined,
2571
+ Je: n?.fallback
2569
2572
  })
2570
2573
  );
2571
2574
  }
2572
2575
  const pureOptions = { pureWrite: true };
2573
2576
  function updateKeyedMap() {
2574
- const e = this.$e() || [],
2577
+ const e = this.je() || [],
2575
2578
  t = e.length;
2576
2579
  e[$TRACK];
2577
- runWithOwner(this.Fe, () => {
2580
+ runWithOwner(this.Me, () => {
2578
2581
  let n,
2579
2582
  i,
2580
- r = this.qe
2583
+ r = this.Xe
2581
2584
  ? () => {
2582
- this.qe[i] = signal(e[i], pureOptions);
2583
- this.Xe && (this.Xe[i] = signal(i, pureOptions));
2584
- return this.Ke(accessor(this.qe[i]), this.Xe ? accessor(this.Xe[i]) : undefined);
2585
+ this.Xe[i] = signal(e[i], pureOptions);
2586
+ this.ze && (this.ze[i] = signal(i, pureOptions));
2587
+ return this.Ye(accessor(this.Xe[i]), this.ze ? accessor(this.ze[i]) : undefined);
2585
2588
  }
2586
- : this.Xe
2589
+ : this.ze
2587
2590
  ? () => {
2588
2591
  const t = e[i];
2589
- this.Xe[i] = signal(i, pureOptions);
2590
- return this.Ke(() => t, accessor(this.Xe[i]));
2592
+ this.ze[i] = signal(i, pureOptions);
2593
+ return this.Ye(() => t, accessor(this.ze[i]));
2591
2594
  }
2592
2595
  : () => {
2593
2596
  const t = e[i];
2594
- return this.Ke(() => t);
2597
+ return this.Ye(() => t);
2595
2598
  };
2596
2599
  if (t === 0) {
2597
- if (this.Me !== 0) {
2598
- this.Fe.dispose(false);
2600
+ if (this.$e !== 0) {
2601
+ this.Me.dispose(false);
2602
+ this.Ze = [];
2603
+ this.Ke = [];
2599
2604
  this.Be = [];
2600
- this.je = [];
2601
- this.Ye = [];
2602
- this.Me = 0;
2603
- this.qe && (this.qe = []);
2605
+ this.$e = 0;
2604
2606
  this.Xe && (this.Xe = []);
2607
+ this.ze && (this.ze = []);
2605
2608
  }
2606
- if (this.ze && !this.Ye[0]) {
2607
- this.Ye[0] = runWithOwner((this.Be[0] = createOwner()), this.ze);
2609
+ if (this.Je && !this.Be[0]) {
2610
+ this.Be[0] = runWithOwner((this.Ze[0] = createOwner()), this.Je);
2608
2611
  }
2609
- } else if (this.Me === 0) {
2610
- if (this.Be[0]) this.Be[0].dispose();
2611
- this.Ye = new Array(t);
2612
+ } else if (this.$e === 0) {
2613
+ if (this.Ze[0]) this.Ze[0].dispose();
2614
+ this.Be = new Array(t);
2612
2615
  for (i = 0; i < t; i++) {
2613
- this.je[i] = e[i];
2614
- this.Ye[i] = runWithOwner((this.Be[i] = createOwner()), r);
2616
+ this.Ke[i] = e[i];
2617
+ this.Be[i] = runWithOwner((this.Ze[i] = createOwner()), r);
2615
2618
  }
2616
- this.Me = t;
2619
+ this.$e = t;
2617
2620
  } else {
2618
2621
  let o,
2619
2622
  s,
@@ -2624,131 +2627,131 @@ function updateKeyedMap() {
2624
2627
  f,
2625
2628
  E = new Array(t),
2626
2629
  T = new Array(t),
2627
- d = this.qe ? new Array(t) : undefined,
2628
- S = this.Xe ? new Array(t) : undefined;
2630
+ d = this.Xe ? new Array(t) : undefined,
2631
+ S = this.ze ? new Array(t) : undefined;
2629
2632
  for (
2630
- o = 0, s = Math.min(this.Me, t);
2631
- o < s && (this.je[o] === e[o] || (this.qe && compare(this.Ze, this.je[o], e[o])));
2633
+ o = 0, s = Math.min(this.$e, t);
2634
+ o < s && (this.Ke[o] === e[o] || (this.Xe && compare(this.qe, this.Ke[o], e[o])));
2632
2635
  o++
2633
2636
  ) {
2634
- if (this.qe) setSignal(this.qe[o], e[o]);
2637
+ if (this.Xe) setSignal(this.Xe[o], e[o]);
2635
2638
  }
2636
2639
  for (
2637
- s = this.Me - 1, u = t - 1;
2640
+ s = this.$e - 1, u = t - 1;
2638
2641
  s >= o &&
2639
2642
  u >= o &&
2640
- (this.je[s] === e[u] || (this.qe && compare(this.Ze, this.je[s], e[u])));
2643
+ (this.Ke[s] === e[u] || (this.Xe && compare(this.qe, this.Ke[s], e[u])));
2641
2644
  s--, u--
2642
2645
  ) {
2643
- E[u] = this.Ye[s];
2644
- T[u] = this.Be[s];
2645
- d && (d[u] = this.qe[s]);
2646
- S && (S[u] = this.Xe[s]);
2646
+ E[u] = this.Be[s];
2647
+ T[u] = this.Ze[s];
2648
+ d && (d[u] = this.Xe[s]);
2649
+ S && (S[u] = this.ze[s]);
2647
2650
  }
2648
2651
  l = new Map();
2649
2652
  f = new Array(u + 1);
2650
2653
  for (i = u; i >= o; i--) {
2651
2654
  c = e[i];
2652
- a = this.Ze ? this.Ze(c) : c;
2655
+ a = this.qe ? this.qe(c) : c;
2653
2656
  n = l.get(a);
2654
2657
  f[i] = n === undefined ? -1 : n;
2655
2658
  l.set(a, i);
2656
2659
  }
2657
2660
  for (n = o; n <= s; n++) {
2658
- c = this.je[n];
2659
- a = this.Ze ? this.Ze(c) : c;
2661
+ c = this.Ke[n];
2662
+ a = this.qe ? this.qe(c) : c;
2660
2663
  i = l.get(a);
2661
2664
  if (i !== undefined && i !== -1) {
2662
- E[i] = this.Ye[n];
2663
- T[i] = this.Be[n];
2664
- d && (d[i] = this.qe[n]);
2665
- S && (S[i] = this.Xe[n]);
2665
+ E[i] = this.Be[n];
2666
+ T[i] = this.Ze[n];
2667
+ d && (d[i] = this.Xe[n]);
2668
+ S && (S[i] = this.ze[n]);
2666
2669
  i = f[i];
2667
2670
  l.set(a, i);
2668
- } else this.Be[n].dispose();
2671
+ } else this.Ze[n].dispose();
2669
2672
  }
2670
2673
  for (i = o; i < t; i++) {
2671
2674
  if (i in E) {
2672
- this.Ye[i] = E[i];
2673
- this.Be[i] = T[i];
2675
+ this.Be[i] = E[i];
2676
+ this.Ze[i] = T[i];
2674
2677
  if (d) {
2675
- this.qe[i] = d[i];
2676
- setSignal(this.qe[i], e[i]);
2678
+ this.Xe[i] = d[i];
2679
+ setSignal(this.Xe[i], e[i]);
2677
2680
  }
2678
2681
  if (S) {
2679
- this.Xe[i] = S[i];
2680
- setSignal(this.Xe[i], i);
2682
+ this.ze[i] = S[i];
2683
+ setSignal(this.ze[i], i);
2681
2684
  }
2682
2685
  } else {
2683
- this.Ye[i] = runWithOwner((this.Be[i] = createOwner()), r);
2686
+ this.Be[i] = runWithOwner((this.Ze[i] = createOwner()), r);
2684
2687
  }
2685
2688
  }
2686
- this.Ye = this.Ye.slice(0, (this.Me = t));
2687
- this.je = e.slice(0);
2689
+ this.Be = this.Be.slice(0, (this.$e = t));
2690
+ this.Ke = e.slice(0);
2688
2691
  }
2689
2692
  });
2690
- return this.Ye;
2693
+ return this.Be;
2691
2694
  }
2692
2695
  function repeat(e, t, n) {
2693
2696
  const i = t;
2694
2697
  return updateRepeat.bind({
2695
- Fe: createOwner(),
2696
- Me: 0,
2697
- Je: 0,
2698
- et: e,
2699
- Ke: i,
2698
+ Me: createOwner(),
2699
+ $e: 0,
2700
+ et: 0,
2701
+ tt: e,
2702
+ Ye: i,
2703
+ Ze: [],
2700
2704
  Be: [],
2701
- Ye: [],
2702
- tt: n?.from,
2703
- ze: n?.fallback
2705
+ nt: n?.from,
2706
+ Je: n?.fallback
2704
2707
  });
2705
2708
  }
2706
2709
  function updateRepeat() {
2707
- const e = this.et();
2708
- const t = this.tt?.() || 0;
2709
- runWithOwner(this.Fe, () => {
2710
+ const e = this.tt();
2711
+ const t = this.nt?.() || 0;
2712
+ runWithOwner(this.Me, () => {
2710
2713
  if (e === 0) {
2711
- if (this.Me !== 0) {
2712
- this.Fe.dispose(false);
2714
+ if (this.$e !== 0) {
2715
+ this.Me.dispose(false);
2716
+ this.Ze = [];
2713
2717
  this.Be = [];
2714
- this.Ye = [];
2715
- this.Me = 0;
2718
+ this.$e = 0;
2716
2719
  }
2717
- if (this.ze && !this.Ye[0]) {
2718
- this.Ye[0] = runWithOwner((this.Be[0] = createOwner()), this.ze);
2720
+ if (this.Je && !this.Be[0]) {
2721
+ this.Be[0] = runWithOwner((this.Ze[0] = createOwner()), this.Je);
2719
2722
  }
2720
2723
  return;
2721
2724
  }
2722
2725
  const n = t + e;
2723
- const i = this.Je + this.Me;
2724
- if (this.Me === 0 && this.Be[0]) this.Be[0].dispose();
2725
- for (let e = n; e < i; e++) this.Be[e - this.Je].dispose();
2726
- if (this.Je < t) {
2727
- let e = this.Je;
2728
- while (e < t && e < this.Me) this.Be[e++].dispose();
2729
- this.Be.splice(0, t - this.Je);
2730
- this.Ye.splice(0, t - this.Je);
2731
- } else if (this.Je > t) {
2732
- let n = i - this.Je - 1;
2733
- let r = this.Je - t;
2734
- this.Be.length = this.Ye.length = e;
2726
+ const i = this.et + this.$e;
2727
+ if (this.$e === 0 && this.Ze[0]) this.Ze[0].dispose();
2728
+ for (let e = n; e < i; e++) this.Ze[e - this.et].dispose();
2729
+ if (this.et < t) {
2730
+ let e = this.et;
2731
+ while (e < t && e < this.$e) this.Ze[e++].dispose();
2732
+ this.Ze.splice(0, t - this.et);
2733
+ this.Be.splice(0, t - this.et);
2734
+ } else if (this.et > t) {
2735
+ let n = i - this.et - 1;
2736
+ let r = this.et - t;
2737
+ this.Ze.length = this.Be.length = e;
2735
2738
  while (n >= r) {
2739
+ this.Ze[n] = this.Ze[n - r];
2736
2740
  this.Be[n] = this.Be[n - r];
2737
- this.Ye[n] = this.Ye[n - r];
2738
2741
  n--;
2739
2742
  }
2740
2743
  for (let e = 0; e < r; e++) {
2741
- this.Ye[e] = runWithOwner((this.Be[e] = createOwner()), () => this.Ke(e + t));
2744
+ this.Be[e] = runWithOwner((this.Ze[e] = createOwner()), () => this.Ye(e + t));
2742
2745
  }
2743
2746
  }
2744
2747
  for (let e = i; e < n; e++) {
2745
- this.Ye[e - t] = runWithOwner((this.Be[e - t] = createOwner()), () => this.Ke(e));
2748
+ this.Be[e - t] = runWithOwner((this.Ze[e - t] = createOwner()), () => this.Ye(e));
2746
2749
  }
2747
- this.Ye = this.Ye.slice(0, e);
2748
- this.Je = t;
2749
- this.Me = e;
2750
+ this.Be = this.Be.slice(0, e);
2751
+ this.et = t;
2752
+ this.$e = e;
2750
2753
  });
2751
- return this.Ye;
2754
+ return this.Be;
2752
2755
  }
2753
2756
  function compare(e, t, n) {
2754
2757
  return e ? e(t) === e(n) : true;
@@ -2758,10 +2761,10 @@ function boundaryComputed(e, t) {
2758
2761
  n.he = (e, t) => {
2759
2762
  const i = e !== undefined ? e : n.Ee;
2760
2763
  const r = t !== undefined ? t : n.q;
2761
- n.Ee &= ~n.nt;
2762
- n.ce.notify(n, n.nt, i, r);
2764
+ n.Ee &= ~n.it;
2765
+ n.ce.notify(n, n.it, i, r);
2763
2766
  };
2764
- n.nt = t;
2767
+ n.it = t;
2765
2768
  n.Pe = true;
2766
2769
  recompute(n, true);
2767
2770
  return n;
@@ -2777,57 +2780,57 @@ function createBoundChildren(e, t, n, i) {
2777
2780
  }
2778
2781
  const ON_INIT = Symbol();
2779
2782
  class CollectionQueue extends Queue {
2780
- it;
2781
- rt = new Set();
2782
- ot = signal(false, { pureWrite: true });
2783
- st = false;
2784
- ut;
2785
- ct = ON_INIT;
2783
+ rt;
2784
+ ot = new Set();
2785
+ st = signal(false, { pureWrite: true, Qe: true });
2786
+ ut = false;
2787
+ ct;
2788
+ lt = ON_INIT;
2786
2789
  constructor(e) {
2787
2790
  super();
2788
- this.it = e;
2791
+ this.rt = e;
2789
2792
  }
2790
2793
  run(e) {
2791
- if (!e || read(this.ot)) return;
2794
+ if (!e || read(this.st)) return;
2792
2795
  return super.run(e);
2793
2796
  }
2794
2797
  notify(e, t, n, i) {
2795
- if (!(t & this.it)) return super.notify(e, t, n, i);
2796
- if (this.st && this.ut) {
2798
+ if (!(t & this.rt)) return super.notify(e, t, n, i);
2799
+ if (this.ut && this.ct) {
2797
2800
  const e = untrack(() => {
2798
2801
  try {
2799
- return this.ut();
2802
+ return this.ct();
2800
2803
  } catch {
2801
2804
  return ON_INIT;
2802
2805
  }
2803
2806
  });
2804
- if (e !== this.ct) {
2805
- this.ct = e;
2806
- this.st = false;
2807
- this.rt.clear();
2807
+ if (e !== this.lt) {
2808
+ this.lt = e;
2809
+ this.ut = false;
2810
+ this.ot.clear();
2808
2811
  }
2809
2812
  }
2810
- if (this.it & STATUS_PENDING && this.st) return super.notify(e, t, n, i);
2811
- if (n & this.it) {
2813
+ if (this.rt & STATUS_PENDING && this.ut) return super.notify(e, t, n, i);
2814
+ if (n & this.rt) {
2812
2815
  const t = i?.source || e.q?.source;
2813
2816
  if (t) {
2814
- const e = this.rt.size === 0;
2815
- this.rt.add(t);
2816
- if (e) setSignal(this.ot, true);
2817
+ const e = this.ot.size === 0;
2818
+ this.ot.add(t);
2819
+ if (e) setSignal(this.st, true);
2817
2820
  }
2818
2821
  }
2819
- t &= ~this.it;
2822
+ t &= ~this.rt;
2820
2823
  return t ? super.notify(e, t, n, i) : true;
2821
2824
  }
2822
2825
  checkSources() {
2823
- for (const e of this.rt) {
2824
- if (!(e.Ee & this.it)) this.rt.delete(e);
2826
+ for (const e of this.ot) {
2827
+ if (!(e.Ee & this.rt)) this.ot.delete(e);
2825
2828
  }
2826
- if (!this.rt.size) {
2827
- setSignal(this.ot, false);
2828
- if (this.ut) {
2829
+ if (!this.ot.size) {
2830
+ setSignal(this.st, false);
2831
+ if (this.ct) {
2829
2832
  try {
2830
- this.ct = untrack(() => this.ut());
2833
+ this.lt = untrack(() => this.ct());
2831
2834
  } catch {}
2832
2835
  }
2833
2836
  }
@@ -2836,13 +2839,13 @@ class CollectionQueue extends Queue {
2836
2839
  function createCollectionBoundary(e, t, n, i) {
2837
2840
  const r = createOwner();
2838
2841
  const o = new CollectionQueue(e);
2839
- if (i) o.ut = i;
2842
+ if (i) o.ct = i;
2840
2843
  const s = createBoundChildren(r, t, o, e);
2841
2844
  const u = computed(() => {
2842
- if (!read(o.ot)) {
2845
+ if (!read(o.st)) {
2843
2846
  const e = read(s);
2844
- if (!untrack(() => read(o.ot))) {
2845
- o.st = true;
2847
+ if (!untrack(() => read(o.st))) {
2848
+ o.ut = true;
2846
2849
  return e;
2847
2850
  }
2848
2851
  }
@@ -2855,10 +2858,10 @@ function createLoadingBoundary(e, t, n) {
2855
2858
  }
2856
2859
  function createErrorBoundary(e, t) {
2857
2860
  return createCollectionBoundary(STATUS_ERROR, e, e => {
2858
- let n = e.rt.values().next().value;
2861
+ let n = e.ot.values().next().value;
2859
2862
  const i = n.q?.cause ?? n.q;
2860
2863
  return t(i, () => {
2861
- for (const t of e.rt) recompute(t);
2864
+ for (const t of e.ot) recompute(t);
2862
2865
  schedule();
2863
2866
  });
2864
2867
  });
@@ -17,6 +17,8 @@ export interface NodeOptions<T> {
17
17
  transparent?: boolean;
18
18
  equals?: ((prev: T, next: T) => boolean) | false;
19
19
  pureWrite?: boolean;
20
+ /** Exclude this signal from snapshot capture (internal — not part of public API) */
21
+ _noSnapshot?: boolean;
20
22
  unobserved?: () => void;
21
23
  lazy?: boolean;
22
24
  }
@@ -28,6 +30,7 @@ export interface RawSignal<T> {
28
30
  _name?: string;
29
31
  _equals: false | ((a: T, b: T) => boolean);
30
32
  _pureWrite?: boolean;
33
+ _noSnapshot?: boolean;
31
34
  _unobserved?: () => void;
32
35
  _time: number;
33
36
  _transition: Transition | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
4
4
  "description": "SolidJS' standalone reactivity implementation",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",