@solidjs/signals 0.7.4 → 0.7.5

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
@@ -326,7 +326,7 @@ var Transition = class _Transition {
326
326
  function cloneGraph(node) {
327
327
  if (node._optimistic) {
328
328
  if (node._state !== STATE_DISPOSED) {
329
- node._optimistic._init?.();
329
+ !node._transition && node._optimistic._init?.();
330
330
  ActiveTransition.addOptimistic(node._optimistic);
331
331
  }
332
332
  return node;
@@ -685,6 +685,10 @@ var Computation = class extends Owner {
685
685
  }
686
686
  }
687
687
  _read() {
688
+ if (staleCheck && (this._stateFlags & LOADING_BIT || this._transition)) {
689
+ staleCheck._value = true;
690
+ this._transition?._signal.read();
691
+ }
688
692
  track(this);
689
693
  newFlags |= this._stateFlags & ~currentMask;
690
694
  if (this._stateFlags & ERROR_BIT) {
@@ -733,10 +737,6 @@ var Computation = class extends Owner {
733
737
  if ((notStale || this._stateFlags & UNINITIALIZED_BIT) && this._stateFlags & LOADING_BIT) {
734
738
  throw new NotReadyError(this);
735
739
  }
736
- if (staleCheck && (this._stateFlags & LOADING_BIT || this._transition)) {
737
- staleCheck._value = true;
738
- this._transition?._signal.read();
739
- }
740
740
  return this._read();
741
741
  }
742
742
  /** Update the computation with a new value. */
@@ -1401,10 +1401,11 @@ function createOptimistic(first, second, third) {
1401
1401
  const node = typeof first === "function" ? new Computation(
1402
1402
  second,
1403
1403
  (prev) => {
1404
- const res = first(prev);
1405
- if (node._optimistic._transition)
1404
+ if (node._optimistic._transition) {
1405
+ latest(() => first(prev));
1406
1406
  return prev;
1407
- return res;
1407
+ }
1408
+ return first(prev);
1408
1409
  },
1409
1410
  third
1410
1411
  ) : new Computation(first, null, second);
@@ -1897,10 +1898,11 @@ function createOptimisticStore(first, second, options) {
1897
1898
  const derived = typeof first === "function";
1898
1899
  const { store, node } = derived ? createProjectionInternal(
1899
1900
  (draft) => {
1900
- const res = first(draft);
1901
- if (reset._transition)
1901
+ if (reset._transition) {
1902
+ latest(() => first(draft));
1902
1903
  return draft;
1903
- return res;
1904
+ }
1905
+ return first(draft);
1904
1906
  },
1905
1907
  second,
1906
1908
  options
package/dist/node.cjs CHANGED
@@ -327,7 +327,7 @@ function cloneGraph(node) {
327
327
  var _a, _b;
328
328
  if (node.j) {
329
329
  if (node.a !== STATE_DISPOSED) {
330
- (_b = (_a = node.j).ia) == null ? void 0 : _b.call(_a);
330
+ !node.f && ((_b = (_a = node.j).ia) == null ? void 0 : _b.call(_a));
331
331
  ActiveTransition.addOptimistic(node.j);
332
332
  }
333
333
  return node;
@@ -686,6 +686,11 @@ var Computation = class extends Owner {
686
686
  }
687
687
  }
688
688
  ha() {
689
+ var _a;
690
+ if (staleCheck && (this.g & LOADING_BIT || this.f)) {
691
+ staleCheck.m = true;
692
+ (_a = this.f) == null ? void 0 : _a.aa.read();
693
+ }
689
694
  track(this);
690
695
  newFlags |= this.g & ~currentMask;
691
696
  if (this.g & ERROR_BIT) {
@@ -720,7 +725,6 @@ var Computation = class extends Owner {
720
725
  * before continuing
721
726
  */
722
727
  wait() {
723
- var _a;
724
728
  if (ActiveTransition && (ActiveTransition.b.has(this) || !this.d && this.g & (UNINITIALIZED_BIT | ERROR_BIT))) {
725
729
  const clone = ActiveTransition.b.get(this) || cloneGraph(this);
726
730
  if (clone !== this)
@@ -735,10 +739,6 @@ var Computation = class extends Owner {
735
739
  if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
736
740
  throw new NotReadyError(this);
737
741
  }
738
- if (staleCheck && (this.g & LOADING_BIT || this.f)) {
739
- staleCheck.m = true;
740
- (_a = this.f) == null ? void 0 : _a.aa.read();
741
- }
742
742
  return this.ha();
743
743
  }
744
744
  /** Update the computation with a new value. */
@@ -1400,10 +1400,11 @@ function createOptimistic(first, second, third) {
1400
1400
  const node = typeof first === "function" ? new Computation(
1401
1401
  second,
1402
1402
  (prev) => {
1403
- const res = first(prev);
1404
- if (node.j.f)
1403
+ if (node.j.f) {
1404
+ latest(() => first(prev));
1405
1405
  return prev;
1406
- return res;
1406
+ }
1407
+ return first(prev);
1407
1408
  },
1408
1409
  third
1409
1410
  ) : new Computation(first, null, second);
@@ -1903,10 +1904,11 @@ function createOptimisticStore(first, second, options) {
1903
1904
  const derived = typeof first === "function";
1904
1905
  const { store, node } = derived ? createProjectionInternal(
1905
1906
  (draft) => {
1906
- const res = first(draft);
1907
- if (reset.f)
1907
+ if (reset.f) {
1908
+ latest(() => first(draft));
1908
1909
  return draft;
1909
- return res;
1910
+ }
1911
+ return first(draft);
1910
1912
  },
1911
1913
  second,
1912
1914
  options
package/dist/prod.js CHANGED
@@ -323,7 +323,7 @@ var Transition = class _Transition {
323
323
  function cloneGraph(node) {
324
324
  if (node.j) {
325
325
  if (node.a !== STATE_DISPOSED) {
326
- node.j.ia?.();
326
+ !node.f && node.j.ia?.();
327
327
  ActiveTransition.addOptimistic(node.j);
328
328
  }
329
329
  return node;
@@ -681,6 +681,10 @@ var Computation = class extends Owner {
681
681
  }
682
682
  }
683
683
  ha() {
684
+ if (staleCheck && (this.g & LOADING_BIT || this.f)) {
685
+ staleCheck.m = true;
686
+ this.f?.aa.read();
687
+ }
684
688
  track(this);
685
689
  newFlags |= this.g & ~currentMask;
686
690
  if (this.g & ERROR_BIT) {
@@ -729,10 +733,6 @@ var Computation = class extends Owner {
729
733
  if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
730
734
  throw new NotReadyError(this);
731
735
  }
732
- if (staleCheck && (this.g & LOADING_BIT || this.f)) {
733
- staleCheck.m = true;
734
- this.f?.aa.read();
735
- }
736
736
  return this.ha();
737
737
  }
738
738
  /** Update the computation with a new value. */
@@ -1387,10 +1387,11 @@ function createOptimistic(first, second, third) {
1387
1387
  const node = typeof first === "function" ? new Computation(
1388
1388
  second,
1389
1389
  (prev) => {
1390
- const res = first(prev);
1391
- if (node.j.f)
1390
+ if (node.j.f) {
1391
+ latest(() => first(prev));
1392
1392
  return prev;
1393
- return res;
1393
+ }
1394
+ return first(prev);
1394
1395
  },
1395
1396
  third
1396
1397
  ) : new Computation(first, null, second);
@@ -1883,10 +1884,11 @@ function createOptimisticStore(first, second, options) {
1883
1884
  const derived = typeof first === "function";
1884
1885
  const { store, node } = derived ? createProjectionInternal(
1885
1886
  (draft) => {
1886
- const res = first(draft);
1887
- if (reset.f)
1887
+ if (reset.f) {
1888
+ latest(() => first(draft));
1888
1889
  return draft;
1889
- return res;
1890
+ }
1891
+ return first(draft);
1890
1892
  },
1891
1893
  second,
1892
1894
  options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",