@solidjs/signals 0.6.0 → 0.6.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
@@ -64,8 +64,6 @@ var Queue = class {
64
64
  _children = [];
65
65
  created = clock;
66
66
  enqueue(type, fn) {
67
- if (ActiveTransition && ActiveTransition._clonedQueues.has(this))
68
- return ActiveTransition._clonedQueues.get(this).enqueue(type, fn);
69
67
  pureQueue.push(fn);
70
68
  if (type)
71
69
  this._queues[type - 1].push(fn);
@@ -116,8 +114,6 @@ var Queue = class {
116
114
  }
117
115
  }
118
116
  notify(...args) {
119
- if (ActiveTransition && ActiveTransition._clonedQueues.has(this))
120
- return ActiveTransition._clonedQueues.get(this).notify(...args);
121
117
  if (this._parent)
122
118
  return this._parent.notify(...args);
123
119
  return false;
@@ -288,6 +284,7 @@ var Transition = class _Transition {
288
284
  } else
289
285
  value = temp.value;
290
286
  }
287
+ ActiveTransition = null;
291
288
  finishTransition(transition2);
292
289
  })();
293
290
  }
@@ -297,6 +294,7 @@ var Transition = class _Transition {
297
294
  while (transition2._done instanceof _Transition)
298
295
  transition2 = transition2._done;
299
296
  transition2._promises.delete(result);
297
+ ActiveTransition = null;
300
298
  finishTransition(transition2);
301
299
  });
302
300
  }
@@ -422,6 +420,10 @@ function mergeTransitions(t1, t2) {
422
420
  function getTransitionSource(input) {
423
421
  return ActiveTransition && ActiveTransition._sources.get(input) || input;
424
422
  }
423
+ function getQueue(node) {
424
+ const transition2 = node._cloned?._transition;
425
+ return transition2 && transition2._clonedQueues.get(node._queue) || node._queue;
426
+ }
425
427
  function initialDispose(node) {
426
428
  let current = node._nextSibling;
427
429
  while (current !== null && current._parent === node) {
@@ -773,7 +775,7 @@ var Computation = class extends Owner {
773
775
  this._notify(STATE_DIRTY);
774
776
  return;
775
777
  }
776
- if (this._state >= STATE_CHECK)
778
+ if (this._state >= STATE_CHECK && !this._forceNotify)
777
779
  return;
778
780
  const prevFlags = this._stateFlags & mask;
779
781
  const deltaFlags = prevFlags ^ newFlags2;
@@ -1042,7 +1044,7 @@ var Effect = class extends Computation {
1042
1044
  };
1043
1045
  }
1044
1046
  this._updateIfNecessary();
1045
- !options?.defer && (this._type === EFFECT_USER ? this._queue.enqueue(this._type, this._run.bind(this)) : this._run(this._type));
1047
+ !options?.defer && (this._type === EFFECT_USER ? getQueue(this).enqueue(this._type, this._run.bind(this)) : this._run(this._type));
1046
1048
  if (!this._parent)
1047
1049
  console.warn("Effects created outside a reactive context will never be disposed");
1048
1050
  }
@@ -1050,7 +1052,7 @@ var Effect = class extends Computation {
1050
1052
  if (this._state == STATE_DIRTY) {
1051
1053
  this._stateFlags = flags;
1052
1054
  if (this._type === EFFECT_RENDER) {
1053
- this._queue.notify(this, LOADING_BIT | ERROR_BIT, this._stateFlags);
1055
+ getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this._stateFlags);
1054
1056
  }
1055
1057
  }
1056
1058
  if (value === UNCHANGED)
@@ -1064,7 +1066,7 @@ var Effect = class extends Computation {
1064
1066
  if (this._state >= state || skipQueue)
1065
1067
  return;
1066
1068
  if (this._state === STATE_CLEAN)
1067
- this._queue.enqueue(this._type, this._run.bind(this));
1069
+ getQueue(this).enqueue(this._type, this._run.bind(this));
1068
1070
  this._state = state;
1069
1071
  }
1070
1072
  _notifyFlags(mask, newFlags2) {
@@ -1080,7 +1082,7 @@ var Effect = class extends Computation {
1080
1082
  }
1081
1083
  _setError(error) {
1082
1084
  this._error = error;
1083
- this._queue.notify(this, LOADING_BIT, 0);
1085
+ getQueue(this).notify(this, LOADING_BIT, 0);
1084
1086
  this._stateFlags = ERROR_BIT;
1085
1087
  if (this._type === EFFECT_USER) {
1086
1088
  try {
@@ -1092,7 +1094,7 @@ var Effect = class extends Computation {
1092
1094
  error = e;
1093
1095
  }
1094
1096
  }
1095
- if (!this._queue.notify(this, ERROR_BIT, ERROR_BIT))
1097
+ if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
1096
1098
  throw error;
1097
1099
  }
1098
1100
  _disposeNode() {
@@ -1103,7 +1105,7 @@ var Effect = class extends Computation {
1103
1105
  this._onerror = void 0;
1104
1106
  this._cleanup?.();
1105
1107
  this._cleanup = void 0;
1106
- this._queue.notify(this, ERROR_BIT | LOADING_BIT, 0);
1108
+ getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1107
1109
  super._disposeNode();
1108
1110
  }
1109
1111
  _run(type) {
@@ -1114,7 +1116,7 @@ var Effect = class extends Computation {
1114
1116
  try {
1115
1117
  effect._cleanup = effect._effect(effect._value, effect._prevValue);
1116
1118
  } catch (e) {
1117
- if (!effect._queue.notify(effect, ERROR_BIT, ERROR_BIT))
1119
+ if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
1118
1120
  throw e;
1119
1121
  } finally {
1120
1122
  effect._prevValue = effect._value;
@@ -1136,7 +1138,7 @@ var EagerComputation = class extends Computation {
1136
1138
  if (this._state >= state && !this._forceNotify)
1137
1139
  return;
1138
1140
  if (!skipQueue && (this._state === STATE_CLEAN || this._state === STATE_CHECK && this._forceNotify))
1139
- this._queue.enqueue(EFFECT_PURE, this._run.bind(this));
1141
+ getQueue(this).enqueue(EFFECT_PURE, this._run.bind(this));
1140
1142
  super._notify(state, skipQueue);
1141
1143
  }
1142
1144
  _run() {
@@ -1154,7 +1156,7 @@ var FirewallComputation = class extends Computation {
1154
1156
  if (this._state >= state && !this._forceNotify)
1155
1157
  return;
1156
1158
  if (!skipQueue && (this._state === STATE_CLEAN || this._state === STATE_CHECK && this._forceNotify))
1157
- this._queue.enqueue(EFFECT_PURE, this._run.bind(this));
1159
+ getQueue(this).enqueue(EFFECT_PURE, this._run.bind(this));
1158
1160
  super._notify(state, true);
1159
1161
  this._forceNotify = !!skipQueue;
1160
1162
  }
@@ -1989,15 +1991,15 @@ function resolve(fn) {
1989
1991
  function createPending() {
1990
1992
  const node = new Computation(false, null);
1991
1993
  const reset = () => node.write(false);
1992
- function write(v) {
1994
+ function write() {
1993
1995
  if (!ActiveTransition)
1994
- return v;
1996
+ return false;
1995
1997
  ActiveTransition.addOptimistic(reset);
1996
- queueMicrotask(() => reset._transition && node.write(v));
1998
+ queueMicrotask(() => reset._transition && node.write(true));
1997
1999
  }
1998
2000
  function read() {
1999
- node.read();
2000
- return !ActiveTransition;
2001
+ const v = node.read();
2002
+ return ActiveTransition ? false : v;
2001
2003
  }
2002
2004
  return [read, write];
2003
2005
  }
@@ -2023,11 +2025,11 @@ function createOptimistic(first, second, options) {
2023
2025
  } else
2024
2026
  [store, setStore] = createStore(first);
2025
2027
  const reset = () => setStore(
2026
- (s) => reconcile(
2027
- { value: typeof first === "function" ? first(second) : first },
2028
+ reconcile(
2029
+ typeof first === "function" ? first(second) : first,
2028
2030
  options?.key || "id",
2029
2031
  options?.all
2030
- )(s)
2032
+ )
2031
2033
  );
2032
2034
  function write(v) {
2033
2035
  if (!ActiveTransition)
@@ -2249,7 +2251,7 @@ var BoundaryComputation = class extends EagerComputation {
2249
2251
  if (this._propagationMask & LOADING_BIT && !(this._stateFlags & UNINITIALIZED_BIT || ActiveTransition)) {
2250
2252
  flags &= ~LOADING_BIT;
2251
2253
  }
2252
- this._queue.notify(this, this._propagationMask, flags);
2254
+ getQueue(this).notify(this, this._propagationMask, flags);
2253
2255
  return this._value;
2254
2256
  }
2255
2257
  };
@@ -2385,7 +2387,7 @@ function createErrorBoundary(fn, fallback) {
2385
2387
  if (ActiveTransition && !node2._cloned)
2386
2388
  node2 = cloneGraph(node2);
2387
2389
  node2._state = STATE_DIRTY;
2388
- node2._queue?.enqueue(node2._type, node2._run.bind(node2));
2390
+ getQueue(node2).enqueue(node2._type, node2._run.bind(node2));
2389
2391
  }
2390
2392
  });
2391
2393
  });