@solidjs/signals 0.13.0 → 0.13.2

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
@@ -398,7 +398,13 @@ function commitPendingNodes() {
398
398
  n._pendingValue = NOT_PENDING;
399
399
  if (n._type && n._type !== EFFECT_TRACKED) n._modified = true;
400
400
  }
401
- if (!(n._statusFlags & STATUS_PENDING)) n._statusFlags &= ~STATUS_UNINITIALIZED;
401
+ if (n._statusFlags & STATUS_PENDING) {
402
+ const _src = n._error?.source;
403
+ if (_src && !(_src._statusFlags & STATUS_PENDING)) {
404
+ n._statusFlags &= -6;
405
+ n._error = null;
406
+ }
407
+ } else n._statusFlags &= ~STATUS_UNINITIALIZED;
402
408
  if (n._fn) GlobalQueue._dispose(n, false, true);
403
409
  }
404
410
  pendingNodes.length = 0;
@@ -1015,6 +1021,8 @@ function runEffect() {
1015
1021
  try {
1016
1022
  this._cleanup = this._effectFn(this._value, this._prevValue);
1017
1023
  } catch (error) {
1024
+ this._error = new StatusError(this, error);
1025
+ this._statusFlags |= STATUS_ERROR;
1018
1026
  if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
1019
1027
  } finally {
1020
1028
  setStrictRead(prevStrictRead);
@@ -1469,7 +1477,9 @@ function read(el) {
1469
1477
  }
1470
1478
  }
1471
1479
  if (owner._statusFlags & STATUS_PENDING) {
1472
- if (c && !(stale && owner._transition && activeTransition !== owner._transition)) {
1480
+ const _errSource = owner._error?.source;
1481
+ if (_errSource && !(_errSource._statusFlags & STATUS_PENDING)) clearStatus(owner);
1482
+ else if (c && !(stale && owner._transition && activeTransition !== owner._transition)) {
1473
1483
  if (currentOptimisticLane) {
1474
1484
  const pendingLane = owner._optimisticLane;
1475
1485
  const lane = findLane(currentOptimisticLane);
@@ -1511,7 +1521,7 @@ function read(el) {
1511
1521
  (currentOptimisticLane !== null &&
1512
1522
  (el._overrideValue !== undefined ||
1513
1523
  el._optimisticLane ||
1514
- owner === el ||
1524
+ (owner === el && stale) ||
1515
1525
  !!(owner._statusFlags & STATUS_PENDING))) ||
1516
1526
  el._pendingValue === NOT_PENDING ||
1517
1527
  (stale && el._transition && activeTransition !== el._transition)
package/dist/node.cjs CHANGED
@@ -32,8 +32,8 @@ const s = 1 << 4;
32
32
  const o = 1 << 5;
33
33
  const u = 1 << 6;
34
34
  const f = 1 << 7;
35
- const c = 1 << 8;
36
- const l = 1 << 9;
35
+ const l = 1 << 8;
36
+ const c = 1 << 9;
37
37
  const a = 1 << 0;
38
38
  const d = 1 << 1;
39
39
  const p = 1 << 2;
@@ -351,7 +351,7 @@ function insertSubs(e, t = false) {
351
351
  const r = e.ie !== undefined;
352
352
  for (let i = e.O; i !== null; i = i.P) {
353
353
  if (r && i.k.se) {
354
- i.k.m |= c;
354
+ i.k.m |= l;
355
355
  continue;
356
356
  }
357
357
  if (t && n) {
@@ -365,7 +365,7 @@ function insertSubs(e, t = false) {
365
365
  if (e.oe === g) {
366
366
  if (!e.ue) {
367
367
  e.ue = true;
368
- e.fe.enqueue(y, e.ce);
368
+ e.fe.enqueue(y, e.le);
369
369
  }
370
370
  continue;
371
371
  }
@@ -378,12 +378,18 @@ function commitPendingNodes() {
378
378
  const e = A.D;
379
379
  for (let t = 0; t < e.length; t++) {
380
380
  const n = e[t];
381
- if (n.le !== S) {
382
- n.ae = n.le;
383
- n.le = S;
381
+ if (n.ce !== S) {
382
+ n.ae = n.ce;
383
+ n.ce = S;
384
384
  if (n.oe && n.oe !== g) n.ue = true;
385
385
  }
386
- if (!(n.de & a)) n.de &= ~p;
386
+ if (n.de & a) {
387
+ const e = n.Y?.source;
388
+ if (e && !(e.de & a)) {
389
+ n.de &= -6;
390
+ n.Y = null;
391
+ }
392
+ } else n.de &= ~p;
387
393
  if (n.H) GlobalQueue.U(n, false, true);
388
394
  }
389
395
  e.length = 0;
@@ -399,9 +405,9 @@ function finalizePureQueue(e = null, t = false) {
399
405
  for (let e = 0; e < t.length; e++) {
400
406
  const n = t[e];
401
407
  n.re = undefined;
402
- if (n.le !== S) {
403
- n.ae = n.le;
404
- n.le = S;
408
+ if (n.ce !== S) {
409
+ n.ae = n.ce;
410
+ n.ce = S;
405
411
  }
406
412
  const r = n.pe;
407
413
  n.pe = S;
@@ -573,7 +579,7 @@ function handleAsync(e, t, r) {
573
579
  if (o) o.T.delete(e);
574
580
  if (r) r(i);
575
581
  else if (e.pe !== undefined) {
576
- if (e.pe !== undefined && e.pe !== S) e.le = i;
582
+ if (e.pe !== undefined && e.pe !== S) e.ce = i;
577
583
  else {
578
584
  e.ae = i;
579
585
  insertSubs(e);
@@ -682,7 +688,7 @@ function notifyStatus(e, t, n, r, i) {
682
688
  }
683
689
  }
684
690
  const f = r || u;
685
- const c = r || o ? undefined : i;
691
+ const l = r || o ? undefined : i;
686
692
  if (e._e) {
687
693
  if (f) {
688
694
  e._e(t, n);
@@ -695,7 +701,7 @@ function notifyStatus(e, t, n, r, i) {
695
701
  r.k.$ = k;
696
702
  if (r.k.Y !== n) {
697
703
  !r.k.ne && A.D.push(r.k);
698
- notifyStatus(r.k, t, n, f, c);
704
+ notifyStatus(r.k, t, n, f, l);
699
705
  }
700
706
  }
701
707
  for (let r = e.C; r !== null; r = r.j) {
@@ -703,7 +709,7 @@ function notifyStatus(e, t, n, r, i) {
703
709
  e.k.$ = k;
704
710
  if (e.k.Y !== n) {
705
711
  !e.k.ne && A.D.push(e.k);
706
- notifyStatus(e.k, t, n, f, c);
712
+ notifyStatus(e.k, t, n, f, l);
707
713
  }
708
714
  }
709
715
  }
@@ -949,6 +955,8 @@ function runEffect() {
949
955
  try {
950
956
  this.Te = this.Re(this.ae, this.He);
951
957
  } catch (e) {
958
+ this.Y = new StatusError(this, e);
959
+ this.de |= d;
952
960
  if (!this.fe.notify(this, d, d)) throw e;
953
961
  } finally {
954
962
  this.He = this.ae;
@@ -976,7 +984,7 @@ function trackedEffect(e, t) {
976
984
  n.Te = undefined;
977
985
  n.ue = true;
978
986
  n.oe = g;
979
- n.ce = run;
987
+ n.le = run;
980
988
  n.fe.enqueue(y, run);
981
989
  onCleanup(() => n.Te?.());
982
990
  }
@@ -1044,8 +1052,8 @@ function releaseSubtree(e) {
1044
1052
  if (t.H) {
1045
1053
  const e = t;
1046
1054
  e.se = false;
1047
- if (e.m & c) {
1048
- e.m &= ~c;
1055
+ if (e.m & l) {
1056
+ e.m &= ~l;
1049
1057
  e.m |= n;
1050
1058
  if (P.A > e.o) P.A = e.o;
1051
1059
  insertIntoHeap(e, P);
@@ -1082,13 +1090,13 @@ function recompute(t, n = false) {
1082
1090
  }
1083
1091
  const s = !!(t.m & f);
1084
1092
  const u = t.pe !== undefined && t.pe !== S;
1085
- const l = !!(t.de & a);
1093
+ const c = !!(t.de & a);
1086
1094
  const p = M;
1087
1095
  M = t;
1088
1096
  t.ke = null;
1089
1097
  t.m = r;
1090
1098
  t.$ = k;
1091
- let h = t.le === S ? t.ae : t.le;
1099
+ let h = t.ce === S ? t.ae : t.ce;
1092
1100
  let y = t.o;
1093
1101
  let w = H;
1094
1102
  let m = V;
@@ -1123,7 +1131,7 @@ function recompute(t, n = false) {
1123
1131
  );
1124
1132
  } finally {
1125
1133
  H = w;
1126
- t.m = e | (n ? t.m & c : 0);
1134
+ t.m = e | (n ? t.m & l : 0);
1127
1135
  M = p;
1128
1136
  }
1129
1137
  if (!t.Y) {
@@ -1136,21 +1144,21 @@ function recompute(t, n = false) {
1136
1144
  if (e !== null) e.N = null;
1137
1145
  else t.W = null;
1138
1146
  }
1139
- const f = u ? t.pe : t.le === S ? t.ae : t.le;
1140
- const c = !t.me || !t.me(f, h);
1141
- if (c) {
1147
+ const f = u ? t.pe : t.ce === S ? t.ae : t.ce;
1148
+ const l = !t.me || !t.me(f, h);
1149
+ if (l) {
1142
1150
  const e = u ? t.pe : undefined;
1143
1151
  if (n || (i && C !== t.ne) || s) {
1144
1152
  t.ae = h;
1145
1153
  if (u && s) {
1146
1154
  t.pe = h;
1147
- t.le = h;
1155
+ t.ce = h;
1148
1156
  }
1149
- } else t.le = h;
1150
- if (u && !s && l && !t.Se) t.pe = h;
1157
+ } else t.ce = h;
1158
+ if (u && !s && c && !t.Se) t.pe = h;
1151
1159
  if (!u || s || t.pe !== e) insertSubs(t, s || u);
1152
1160
  } else if (u) {
1153
- t.le = h;
1161
+ t.ce = h;
1154
1162
  } else if (t.o != y) {
1155
1163
  for (let e = t.O; e !== null; e = e.P) {
1156
1164
  insertIntoHeapHeight(e.k, e.k.m & o ? v : P);
@@ -1177,7 +1185,7 @@ function updateIfNecessary(r) {
1177
1185
  if (r.m & (n | f) || (r.Y && r.$ < k && !r.we)) {
1178
1186
  recompute(r);
1179
1187
  }
1180
- r.m = e | (r.m & c);
1188
+ r.m = e | (r.m & l);
1181
1189
  }
1182
1190
  function computed(t, n, r) {
1183
1191
  const i = r?.transparent ?? false;
@@ -1204,10 +1212,10 @@ function computed(t, n, r) {
1204
1212
  i: M,
1205
1213
  Ee: null,
1206
1214
  Ce: null,
1207
- m: r?.lazy ? l : e,
1215
+ m: r?.lazy ? c : e,
1208
1216
  de: p,
1209
1217
  $: k,
1210
- le: S,
1218
+ ce: S,
1211
1219
  We: null,
1212
1220
  je: null,
1213
1221
  we: null,
@@ -1257,7 +1265,7 @@ function signal(e, t, n = null) {
1257
1265
  $: k,
1258
1266
  I: n,
1259
1267
  j: n?.C || null,
1260
- le: S
1268
+ ce: S
1261
1269
  };
1262
1270
  n && (n.C = r);
1263
1271
  if (D && !r.Fe && !((n?.de ?? 0) & a)) {
@@ -1329,8 +1337,8 @@ function read(e) {
1329
1337
  let t = M;
1330
1338
  if (t?.t) t = t.u;
1331
1339
  if (Q && e.H) recompute(e);
1332
- if (e.m & l) {
1333
- e.m &= ~l;
1340
+ if (e.m & c) {
1341
+ e.m &= ~c;
1334
1342
  recompute(e, true);
1335
1343
  }
1336
1344
  const n = e.I || e;
@@ -1351,7 +1359,9 @@ function read(e) {
1351
1359
  }
1352
1360
  }
1353
1361
  if (n.de & a) {
1354
- if (t && !(R && n.ne && C !== n.ne)) {
1362
+ const r = n.Y?.source;
1363
+ if (r && !(r.de & a)) clearStatus(n);
1364
+ else if (t && !(R && n.ne && C !== n.ne)) {
1355
1365
  if (V) {
1356
1366
  const r = n.re;
1357
1367
  const i = findLane(V);
@@ -1377,24 +1387,24 @@ function read(e) {
1377
1387
  const n = e.ie;
1378
1388
  if (n !== undefined) {
1379
1389
  const r = n === w ? undefined : n;
1380
- const i = e.le !== S ? e.le : e.ae;
1381
- if (i !== r) t.m |= c;
1390
+ const i = e.ce !== S ? e.ce : e.ae;
1391
+ if (i !== r) t.m |= l;
1382
1392
  return r;
1383
1393
  }
1384
1394
  }
1385
1395
  if (e.pe !== undefined && e.pe !== S) return e.pe;
1386
1396
  return !t ||
1387
- (V !== null && (e.pe !== undefined || e.re || n === e || !!(n.de & a))) ||
1388
- e.le === S ||
1397
+ (V !== null && (e.pe !== undefined || e.re || (n === e && R) || !!(n.de & a))) ||
1398
+ e.ce === S ||
1389
1399
  (R && e.ne && C !== e.ne)
1390
1400
  ? e.ae
1391
- : e.le;
1401
+ : e.ce;
1392
1402
  }
1393
1403
  function setSignal(e, t) {
1394
1404
  if (e.ne && C !== e.ne) A.initTransition(e.ne);
1395
1405
  const n = e.pe !== undefined && !j;
1396
1406
  const r = e.pe !== undefined && e.pe !== S;
1397
- const i = n ? (r ? e.pe : e.ae) : e.le === S ? e.ae : e.le;
1407
+ const i = n ? (r ? e.pe : e.ae) : e.ce === S ? e.ae : e.ce;
1398
1408
  if (typeof t === "function") t = t(i);
1399
1409
  const s = !e.me || !e.me(i, t) || !!(e.de & p);
1400
1410
  if (!s) {
@@ -1408,7 +1418,7 @@ function setSignal(e, t) {
1408
1418
  const n = e.pe === S;
1409
1419
  if (!n && e.ne) A.initTransition(e.ne);
1410
1420
  if (n) {
1411
- e.le = e.ae;
1421
+ e.ce = e.ae;
1412
1422
  A.B.push(e);
1413
1423
  }
1414
1424
  e.Se = true;
@@ -1416,8 +1426,8 @@ function setSignal(e, t) {
1416
1426
  e.re = r;
1417
1427
  e.pe = t;
1418
1428
  } else {
1419
- if (e.le === S) A.D.push(e);
1420
- e.le = t;
1429
+ if (e.ce === S) A.D.push(e);
1430
+ e.ce = t;
1421
1431
  }
1422
1432
  updatePendingSignal(e);
1423
1433
  if (e.be) {
@@ -1460,7 +1470,7 @@ function computePendingState(e) {
1460
1470
  }
1461
1471
  return true;
1462
1472
  }
1463
- if (e.le !== S && !(t.de & p)) return true;
1473
+ if (e.ce !== S && !(t.de & p)) return true;
1464
1474
  return !!(t.de & a && !(t.de & p));
1465
1475
  }
1466
1476
  function updatePendingSignal(e) {
@@ -1718,7 +1728,7 @@ function applyState(e, t, n) {
1718
1728
  let t = false;
1719
1729
  const f = getOverrideValue(i, s, u, "length", o);
1720
1730
  if (e.length && f && e[0] && n(e[0]) != null) {
1721
- let c, l, a, d, p, h, y, g;
1731
+ let l, c, a, d, p, h, y, g;
1722
1732
  for (
1723
1733
  a = 0, d = Math.min(f, e.length);
1724
1734
  a < d &&
@@ -1739,44 +1749,44 @@ function applyState(e, t, n) {
1739
1749
  S[p] = h;
1740
1750
  }
1741
1751
  if (a > p || a > d) {
1742
- for (l = a; l <= p; l++) {
1752
+ for (c = a; c <= p; c++) {
1743
1753
  t = true;
1744
- r[$][l] && setSignal(r[$][l], wrap(e[l], r));
1754
+ r[$][c] && setSignal(r[$][c], wrap(e[c], r));
1745
1755
  }
1746
- for (; l < e.length; l++) {
1756
+ for (; c < e.length; c++) {
1747
1757
  t = true;
1748
- const i = wrap(S[l], r);
1749
- r[$][l] && setSignal(r[$][l], i);
1750
- applyState(e[l], i, n);
1758
+ const i = wrap(S[c], r);
1759
+ r[$][c] && setSignal(r[$][c], i);
1760
+ applyState(e[c], i, n);
1751
1761
  }
1752
1762
  t && r[$][K] && setSignal(r[$][K], void 0);
1753
1763
  f !== e.length && r[$].length && setSignal(r[$].length, e.length);
1754
1764
  return;
1755
1765
  }
1756
1766
  y = new Array(p + 1);
1757
- for (l = p; l >= a; l--) {
1758
- h = e[l];
1767
+ for (c = p; c >= a; c--) {
1768
+ h = e[c];
1759
1769
  g = h ? n(h) : h;
1760
- c = w.get(g);
1761
- y[l] = c === undefined ? -1 : c;
1762
- w.set(g, l);
1770
+ l = w.get(g);
1771
+ y[c] = l === undefined ? -1 : l;
1772
+ w.set(g, c);
1763
1773
  }
1764
- for (c = a; c <= d; c++) {
1765
- h = getOverrideValue(i, s, u, c, o);
1774
+ for (l = a; l <= d; l++) {
1775
+ h = getOverrideValue(i, s, u, l, o);
1766
1776
  g = h ? n(h) : h;
1767
- l = w.get(g);
1768
- if (l !== undefined && l !== -1) {
1769
- S[l] = h;
1770
- l = y[l];
1771
- w.set(g, l);
1777
+ c = w.get(g);
1778
+ if (c !== undefined && c !== -1) {
1779
+ S[c] = h;
1780
+ c = y[c];
1781
+ w.set(g, c);
1772
1782
  }
1773
1783
  }
1774
- for (l = a; l < e.length; l++) {
1775
- if (l in S) {
1776
- const t = wrap(S[l], r);
1777
- r[$][l] && setSignal(r[$][l], t);
1778
- applyState(e[l], t, n);
1779
- } else r[$][l] && setSignal(r[$][l], wrap(e[l], r));
1784
+ for (c = a; c < e.length; c++) {
1785
+ if (c in S) {
1786
+ const t = wrap(S[c], r);
1787
+ r[$][c] && setSignal(r[$][c], t);
1788
+ applyState(e[c], t, n);
1789
+ } else r[$][c] && setSignal(r[$][c], wrap(e[c], r));
1780
1790
  }
1781
1791
  if (a < e.length) t = true;
1782
1792
  } else if (e.length) {
@@ -1795,11 +1805,11 @@ function applyState(e, t, n) {
1795
1805
  if (u) {
1796
1806
  const t = u[K];
1797
1807
  const f = t ? getAllKeys(i, s, e) : Object.keys(u);
1798
- for (let c = 0, l = f.length; c < l; c++) {
1799
- const l = f[c];
1800
- const a = u[l];
1801
- const d = unwrap(getOverrideValue(i, s, u, l, o));
1802
- let p = unwrap(e[l]);
1808
+ for (let l = 0, c = f.length; l < c; l++) {
1809
+ const c = f[l];
1810
+ const a = u[c];
1811
+ const d = unwrap(getOverrideValue(i, s, u, c, o));
1812
+ let p = unwrap(e[c]);
1803
1813
  if (d === p) continue;
1804
1814
  if (!d || !isWrappable(d) || !isWrappable(p) || (n(d) != null && n(d) !== n(p))) {
1805
1815
  t && setSignal(t, void 0);
@@ -2010,8 +2020,8 @@ const fe = {
2010
2020
  i && (o || !u)
2011
2021
  ? i.pe !== undefined && i.pe !== S
2012
2022
  ? i.pe
2013
- : i.le !== S
2014
- ? i.le
2023
+ : i.ce !== S
2024
+ ? i.ce
2015
2025
  : i.ae
2016
2026
  : f[t];
2017
2027
  n === J && (n = undefined);
@@ -2020,19 +2030,19 @@ const fe = {
2020
2030
  ue?.add(r);
2021
2031
  return r;
2022
2032
  }
2023
- let c = i ? (o || !u ? read(r[t]) : (read(r[t]), f[t])) : f[t];
2024
- c === J && (c = undefined);
2033
+ let l = i ? (o || !u ? read(r[t]) : (read(r[t]), f[t])) : f[t];
2034
+ l === J && (l = undefined);
2025
2035
  if (!i) {
2026
- if (!o && typeof c === "function" && !f.hasOwnProperty(t)) {
2036
+ if (!o && typeof l === "function" && !f.hasOwnProperty(t)) {
2027
2037
  let t;
2028
2038
  return !Array.isArray(e[X]) && (t = Object.getPrototypeOf(e[X])) && t !== Object.prototype
2029
- ? c.bind(f)
2030
- : c;
2039
+ ? l.bind(f)
2040
+ : l;
2031
2041
  } else if (getObserver()) {
2032
- return read(getNode(r, t, isWrappable(c) ? wrap(c, e) : c, e[re], isEqual, e[ie], e[m]));
2042
+ return read(getNode(r, t, isWrappable(l) ? wrap(l, e) : l, e[re], isEqual, e[ie], e[m]));
2033
2043
  }
2034
2044
  }
2035
- return isWrappable(c) ? wrap(c, e) : c;
2045
+ return isWrappable(l) ? wrap(l, e) : l;
2036
2046
  },
2037
2047
  has(e, t) {
2038
2048
  if (t === U || t === K || t === "__proto__") return true;
@@ -2065,21 +2075,21 @@ const fe = {
2065
2075
  const u = o ? Z : Y;
2066
2076
  if (o) trackOptimisticStore(r);
2067
2077
  const f = e[Z] && t in e[Z] ? e[Z][t] : e[Y] && t in e[Y] ? e[Y][t] : s;
2068
- const c = n?.[z]?.[X] ?? n;
2069
- if (f === c) return true;
2070
- const l = e[Z]?.length || e[Y]?.length || i.length;
2071
- if (c !== undefined && c === s) delete e[u][t];
2072
- else (e[u] || (e[u] = Object.create(null)))[t] = c;
2073
- const d = isWrappable(c);
2078
+ const l = n?.[z]?.[X] ?? n;
2079
+ if (f === l) return true;
2080
+ const c = e[Z]?.length || e[Y]?.length || i.length;
2081
+ if (l !== undefined && l === s) delete e[u][t];
2082
+ else (e[u] || (e[u] = Object.create(null)))[t] = l;
2083
+ const d = isWrappable(l);
2074
2084
  e[ee]?.[t] && setSignal(e[ee][t], true);
2075
2085
  const p = getNodes(e, $);
2076
- p[t] && setSignal(p[t], () => (d ? wrap(c, e) : c));
2086
+ p[t] && setSignal(p[t], () => (d ? wrap(l, e) : l));
2077
2087
  if (Array.isArray(i)) {
2078
2088
  if (t === "length") {
2079
- p.length && setSignal(p.length, c);
2089
+ p.length && setSignal(p.length, l);
2080
2090
  } else {
2081
2091
  const e = parseInt(t) + 1;
2082
- if (e > l) p.length && setSignal(p.length, e);
2092
+ if (e > c) p.length && setSignal(p.length, e);
2083
2093
  }
2084
2094
  }
2085
2095
  p[K] && setSignal(p[K], undefined);
@@ -2246,7 +2256,7 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
2246
2256
  }
2247
2257
  return { store: s, node: r };
2248
2258
  }
2249
- const ce = Symbol(0);
2259
+ const le = Symbol(0);
2250
2260
  function updatePath(e, t, n = 0) {
2251
2261
  let r,
2252
2262
  i = e;
@@ -2290,7 +2300,7 @@ function updatePath(e, t, n = 0) {
2290
2300
  if (s === i) return;
2291
2301
  }
2292
2302
  if (r === undefined && s == undefined) return;
2293
- if (s === ce) {
2303
+ if (s === le) {
2294
2304
  delete e[r];
2295
2305
  } else if (r === undefined || (isWrappable(i) && isWrappable(s) && !Array.isArray(s))) {
2296
2306
  const t = r !== undefined ? e[r] : e;
@@ -2300,16 +2310,16 @@ function updatePath(e, t, n = 0) {
2300
2310
  e[r] = s;
2301
2311
  }
2302
2312
  }
2303
- const le = Object.assign(
2313
+ const ce = Object.assign(
2304
2314
  function storePath(...e) {
2305
2315
  return t => {
2306
2316
  updatePath(t, e);
2307
2317
  };
2308
2318
  },
2309
- { DELETE: ce }
2319
+ { DELETE: le }
2310
2320
  );
2311
2321
  function snapshotImpl(e, t, n, r) {
2312
- let i, s, o, u, f, c;
2322
+ let i, s, o, u, f, l;
2313
2323
  if (!isWrappable(e)) return e;
2314
2324
  if (n && n.has(e)) return n.get(e);
2315
2325
  if (!n) n = new Map();
@@ -2326,24 +2336,24 @@ function snapshotImpl(e, t, n, r) {
2326
2336
  }
2327
2337
  if (s) {
2328
2338
  const s = o?.length || e.length;
2329
- for (let l = 0; l < s; l++) {
2330
- c = o && l in o ? o[l] : e[l];
2331
- if (c === J) continue;
2332
- if (t && isWrappable(c)) wrap(c, i);
2333
- if ((f = snapshotImpl(c, t, n, r)) !== c || u) {
2339
+ for (let c = 0; c < s; c++) {
2340
+ l = o && c in o ? o[c] : e[c];
2341
+ if (l === J) continue;
2342
+ if (t && isWrappable(l)) wrap(l, i);
2343
+ if ((f = snapshotImpl(l, t, n, r)) !== l || u) {
2334
2344
  if (!u) n.set(e, (u = [...e]));
2335
- u[l] = f;
2345
+ u[c] = f;
2336
2346
  }
2337
2347
  }
2338
2348
  } else {
2339
2349
  const s = getKeys(e, o);
2340
- for (let l = 0, a = s.length; l < a; l++) {
2341
- let a = s[l];
2350
+ for (let c = 0, a = s.length; c < a; c++) {
2351
+ let a = s[c];
2342
2352
  const d = getPropertyDescriptor(e, o, a);
2343
2353
  if (d.get) continue;
2344
- c = o && a in o ? o[a] : e[a];
2345
- if (t && isWrappable(c)) wrap(c, i);
2346
- if ((f = snapshotImpl(c, t, n, r)) !== e[a] || u) {
2354
+ l = o && a in o ? o[a] : e[a];
2355
+ if (t && isWrappable(l)) wrap(l, i);
2356
+ if ((f = snapshotImpl(l, t, n, r)) !== e[a] || u) {
2347
2357
  if (!u) {
2348
2358
  u = Object.create(Object.getPrototypeOf(e));
2349
2359
  Object.assign(u, e);
@@ -2560,8 +2570,8 @@ function updateKeyedMap() {
2560
2570
  o,
2561
2571
  u,
2562
2572
  f,
2563
- c,
2564
2573
  l,
2574
+ c,
2565
2575
  a,
2566
2576
  d = new Array(t),
2567
2577
  p = new Array(t),
@@ -2586,26 +2596,26 @@ function updateKeyedMap() {
2586
2596
  h && (h[u] = this.Xe[o]);
2587
2597
  y && (y[u] = this.Ye[o]);
2588
2598
  }
2589
- l = new Map();
2599
+ c = new Map();
2590
2600
  a = new Array(u + 1);
2591
2601
  for (r = u; r >= s; r--) {
2592
2602
  f = e[r];
2593
- c = this.Je ? this.Je(f) : f;
2594
- n = l.get(c);
2603
+ l = this.Je ? this.Je(f) : f;
2604
+ n = c.get(l);
2595
2605
  a[r] = n === undefined ? -1 : n;
2596
- l.set(c, r);
2606
+ c.set(l, r);
2597
2607
  }
2598
2608
  for (n = s; n <= o; n++) {
2599
2609
  f = this.Ge[n];
2600
- c = this.Je ? this.Je(f) : f;
2601
- r = l.get(c);
2610
+ l = this.Je ? this.Je(f) : f;
2611
+ r = c.get(l);
2602
2612
  if (r !== undefined && r !== -1) {
2603
2613
  d[r] = this.ze[n];
2604
2614
  p[r] = this.Ue[n];
2605
2615
  h && (h[r] = this.Xe[n]);
2606
2616
  y && (y[r] = this.Ye[n]);
2607
2617
  r = a[r];
2608
- l.set(c, r);
2618
+ c.set(l, r);
2609
2619
  } else this.Ue[n].dispose();
2610
2620
  }
2611
2621
  for (r = s; r < t; r++) {
@@ -2909,5 +2919,5 @@ exports.runWithOwner = runWithOwner;
2909
2919
  exports.setContext = setContext;
2910
2920
  exports.setSnapshotCapture = setSnapshotCapture;
2911
2921
  exports.snapshot = snapshot;
2912
- exports.storePath = le;
2922
+ exports.storePath = ce;
2913
2923
  exports.untrack = untrack;
package/dist/prod.js CHANGED
@@ -382,7 +382,13 @@ function commitPendingNodes() {
382
382
  n.le = NOT_PENDING;
383
383
  if (n.se && n.se !== EFFECT_TRACKED) n.ue = true;
384
384
  }
385
- if (!(n.Ee & STATUS_PENDING)) n.Ee &= ~STATUS_UNINITIALIZED;
385
+ if (n.Ee & STATUS_PENDING) {
386
+ const e = n.q?.source;
387
+ if (e && !(e.Ee & STATUS_PENDING)) {
388
+ n.Ee &= -6;
389
+ n.q = null;
390
+ }
391
+ } else n.Ee &= ~STATUS_UNINITIALIZED;
386
392
  if (n.L) GlobalQueue.Y(n, false, true);
387
393
  }
388
394
  e.length = 0;
@@ -948,6 +954,8 @@ function runEffect() {
948
954
  try {
949
955
  this.We = this.Ue(this.fe, this.ke);
950
956
  } catch (e) {
957
+ this.q = new StatusError(this, e);
958
+ this.Ee |= STATUS_ERROR;
951
959
  if (!this.ce.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
952
960
  } finally {
953
961
  this.ke = this.fe;
@@ -1351,7 +1359,9 @@ function read(e) {
1351
1359
  }
1352
1360
  }
1353
1361
  if (n.Ee & STATUS_PENDING) {
1354
- if (t && !(stale && n.ne && activeTransition !== n.ne)) {
1362
+ const i = n.q?.source;
1363
+ if (i && !(i.Ee & STATUS_PENDING)) clearStatus(n);
1364
+ else if (t && !(stale && n.ne && activeTransition !== n.ne)) {
1355
1365
  if (currentOptimisticLane) {
1356
1366
  const i = n.ie;
1357
1367
  const r = findLane(currentOptimisticLane);
@@ -1385,7 +1395,7 @@ function read(e) {
1385
1395
  if (e.Te !== undefined && e.Te !== NOT_PENDING) return e.Te;
1386
1396
  return !t ||
1387
1397
  (currentOptimisticLane !== null &&
1388
- (e.Te !== undefined || e.ie || n === e || !!(n.Ee & STATUS_PENDING))) ||
1398
+ (e.Te !== undefined || e.ie || (n === e && stale) || !!(n.Ee & STATUS_PENDING))) ||
1389
1399
  e.le === NOT_PENDING ||
1390
1400
  (stale && e.ne && activeTransition !== e.ne)
1391
1401
  ? e.fe
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "SolidJS' standalone reactivity implementation",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",