@solidjs/signals 0.9.6 → 0.9.8

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
@@ -350,7 +350,6 @@ function insertSubs(node, optimistic = false) {
350
350
  function finalizePureQueue(completingTransition = null, incomplete = false) {
351
351
  let resolvePending = !incomplete;
352
352
  if (dirtyQueue._max >= dirtyQueue._min) {
353
- resolvePending = true;
354
353
  runHeap(dirtyQueue, GlobalQueue._update);
355
354
  }
356
355
  if (resolvePending) {
@@ -562,6 +561,7 @@ function recompute(el, create = false) {
562
561
  setOptimisticReadActive(prevOptimisticRead);
563
562
  (!create || el._statusFlags & STATUS_PENDING) &&
564
563
  !el._transition &&
564
+ !(activeTransition && el._optimistic) &&
565
565
  globalQueue._pendingNodes.push(el);
566
566
  el._transition &&
567
567
  isEffect &&
@@ -677,7 +677,7 @@ function clearStatus(el) {
677
677
  }
678
678
  }
679
679
  function notifyStatus(el, status, error) {
680
- el._statusFlags = status | (el._statusFlags & STATUS_UNINITIALIZED);
680
+ el._statusFlags = status | (status !== STATUS_ERROR ? el._statusFlags & STATUS_UNINITIALIZED : 0);
681
681
  el._error = error;
682
682
  updatePendingSignal(el);
683
683
  if (el._notifyStatus) return el._notifyStatus();
@@ -942,7 +942,10 @@ function getPendingValueComputed(el) {
942
942
  if (!el._pendingValueComputed) {
943
943
  const prevPending = pendingReadActive;
944
944
  pendingReadActive = false;
945
+ const prevContext = context;
946
+ context = null;
945
947
  el._pendingValueComputed = optimisticComputed(() => read(el));
948
+ context = prevContext;
946
949
  pendingReadActive = prevPending;
947
950
  }
948
951
  return el._pendingValueComputed;
@@ -1039,12 +1042,14 @@ function setSignal(el, v) {
1039
1042
  const valueChanged = !el._equals || !el._equals(currentValue, v);
1040
1043
  if (!valueChanged) return v;
1041
1044
  if (isOptimistic) {
1042
- const isFirstWrite = el._pendingValue === NOT_PENDING;
1043
- if (el._transition && !isFirstWrite) {
1045
+ const alreadyTracked = globalQueue._optimisticNodes.includes(el);
1046
+ if (el._transition && alreadyTracked) {
1044
1047
  globalQueue.initTransition(el._transition);
1045
1048
  }
1046
- if (isFirstWrite) {
1049
+ if (el._pendingValue === NOT_PENDING) {
1047
1050
  el._pendingValue = el._value;
1051
+ }
1052
+ if (!alreadyTracked) {
1048
1053
  globalQueue._optimisticNodes.push(el);
1049
1054
  }
1050
1055
  el._value = v;
package/dist/node.cjs CHANGED
@@ -343,7 +343,6 @@ function insertSubs(e, t = false) {
343
343
  function finalizePureQueue(e = null, t = false) {
344
344
  let n = !t;
345
345
  if (_.S >= _.W) {
346
- n = true;
347
346
  runHeap(_, GlobalQueue.K);
348
347
  }
349
348
  if (n) {
@@ -539,7 +538,7 @@ function recompute(t, n = false) {
539
538
  }
540
539
  }
541
540
  setOptimisticReadActive(y);
542
- (!n || t.re & c) && !t.X && A.D.push(t);
541
+ (!n || t.re & c) && !t.X && !(v && t.le) && A.D.push(t);
543
542
  t.X && i && v !== t.X && runInTransition(t.X, () => recompute(t));
544
543
  }
545
544
  function handleAsync(e, t, n) {
@@ -651,7 +650,7 @@ function clearStatus(e) {
651
650
  }
652
651
  }
653
652
  function notifyStatus(e, t, n) {
654
- e.re = t | (e.re & d);
653
+ e.re = t | (t !== a ? e.re & d : 0);
655
654
  e.J = n;
656
655
  updatePendingSignal(e);
657
656
  if (e.pe) return e.pe();
@@ -907,7 +906,10 @@ function getPendingValueComputed(e) {
907
906
  if (!e.xe) {
908
907
  const t = I;
909
908
  I = false;
909
+ const n = Q;
910
+ Q = null;
910
911
  e.xe = optimisticComputed(() => read(e));
912
+ Q = n;
911
913
  I = t;
912
914
  }
913
915
  return e.xe;
@@ -986,12 +988,14 @@ function setSignal(e, t) {
986
988
  const i = !e.ae || !e.ae(r, t);
987
989
  if (!i) return t;
988
990
  if (n) {
989
- const n = e.te === g;
990
- if (e.X && !n) {
991
+ const n = A.B.includes(e);
992
+ if (e.X && n) {
991
993
  A.initTransition(e.X);
992
994
  }
993
- if (n) {
995
+ if (e.te === g) {
994
996
  e.te = e.ne;
997
+ }
998
+ if (!n) {
995
999
  A.B.push(e);
996
1000
  }
997
1001
  e.ne = t;
package/dist/prod.js CHANGED
@@ -342,7 +342,6 @@ function insertSubs(e, t = false) {
342
342
  function finalizePureQueue(e = null, t = false) {
343
343
  let n = !t;
344
344
  if (dirtyQueue.O >= dirtyQueue.N) {
345
- n = true;
346
345
  runHeap(dirtyQueue, GlobalQueue.j);
347
346
  }
348
347
  if (n) {
@@ -539,7 +538,7 @@ function recompute(e, t = false) {
539
538
  }
540
539
  }
541
540
  setOptimisticReadActive(c);
542
- (!t || e.ie & STATUS_PENDING) && !e.X && globalQueue.L.push(e);
541
+ (!t || e.ie & STATUS_PENDING) && !e.X && !(activeTransition && e.le) && globalQueue.L.push(e);
543
542
  e.X && n && activeTransition !== e.X && runInTransition(e.X, () => recompute(e));
544
543
  }
545
544
  function handleAsync(e, t, n) {
@@ -651,7 +650,7 @@ function clearStatus(e) {
651
650
  }
652
651
  }
653
652
  function notifyStatus(e, t, n) {
654
- e.ie = t | (e.ie & STATUS_UNINITIALIZED);
653
+ e.ie = t | (t !== STATUS_ERROR ? e.ie & STATUS_UNINITIALIZED : 0);
655
654
  e.B = n;
656
655
  updatePendingSignal(e);
657
656
  if (e.Te) return e.Te();
@@ -907,7 +906,10 @@ function getPendingValueComputed(e) {
907
906
  if (!e.ge) {
908
907
  const t = pendingReadActive;
909
908
  pendingReadActive = false;
909
+ const n = context;
910
+ context = null;
910
911
  e.ge = optimisticComputed(() => read(e));
912
+ context = n;
911
913
  pendingReadActive = t;
912
914
  }
913
915
  return e.ge;
@@ -997,12 +999,14 @@ function setSignal(e, t) {
997
999
  const r = !e.fe || !e.fe(i, t);
998
1000
  if (!r) return t;
999
1001
  if (n) {
1000
- const n = e.te === NOT_PENDING;
1001
- if (e.X && !n) {
1002
+ const n = globalQueue.H.includes(e);
1003
+ if (e.X && n) {
1002
1004
  globalQueue.initTransition(e.X);
1003
1005
  }
1004
- if (n) {
1006
+ if (e.te === NOT_PENDING) {
1005
1007
  e.te = e.ne;
1008
+ }
1009
+ if (!n) {
1006
1010
  globalQueue.H.push(e);
1007
1011
  }
1008
1012
  e.ne = t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",