@solidjs/signals 0.7.0 → 0.7.1

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
@@ -1189,7 +1189,10 @@ function runTop(node) {
1189
1189
  function createSignal(first, second, third) {
1190
1190
  if (typeof first === "function") {
1191
1191
  const node2 = new Computation(second, first, third);
1192
- return [node2.read.bind(node2), node2.write.bind(node2)];
1192
+ return [node2.read.bind(node2), (v) => {
1193
+ node2._updateIfNecessary();
1194
+ return node2.write(v);
1195
+ }];
1193
1196
  }
1194
1197
  const o = getOwner();
1195
1198
  const needsId = o?.id != null;
@@ -1366,7 +1369,12 @@ function createOptimistic(first, second, third) {
1366
1369
  throw new Error("createOptimistic can only be updated inside a transition");
1367
1370
  ActiveTransition.addOptimistic(reset);
1368
1371
  cloneGraph(node, true);
1369
- queueMicrotask(() => reset._transition && node.write(v));
1372
+ queueMicrotask(() => {
1373
+ if (reset._transition) {
1374
+ node._updateIfNecessary();
1375
+ node.write(v);
1376
+ }
1377
+ });
1370
1378
  }
1371
1379
  return [node.read.bind(node), write];
1372
1380
  }
package/dist/node.cjs CHANGED
@@ -102,14 +102,14 @@ var Queue = class {
102
102
  }
103
103
  }
104
104
  addChild(child) {
105
- if (ActiveTransition && ActiveTransition.G.has(this))
106
- return ActiveTransition.G.get(this).addChild(child);
105
+ if (ActiveTransition && ActiveTransition.H.has(this))
106
+ return ActiveTransition.H.get(this).addChild(child);
107
107
  this.f.push(child);
108
108
  child.k = this;
109
109
  }
110
110
  removeChild(child) {
111
- if (ActiveTransition && ActiveTransition.G.has(this))
112
- return ActiveTransition.G.get(this).removeChild(child);
111
+ if (ActiveTransition && ActiveTransition.H.has(this))
112
+ return ActiveTransition.H.get(this).removeChild(child);
113
113
  const index = this.f.indexOf(child);
114
114
  if (index >= 0) {
115
115
  this.f.splice(index, 1);
@@ -161,12 +161,12 @@ function runQueue(queue, type) {
161
161
  var Transition = class _Transition {
162
162
  a = /* @__PURE__ */ new Map();
163
163
  s = /* @__PURE__ */ new Set();
164
- H = /* @__PURE__ */ new Set();
165
164
  I = /* @__PURE__ */ new Set();
166
- D = false;
165
+ J = /* @__PURE__ */ new Set();
166
+ E = false;
167
167
  g = [[], []];
168
- G = /* @__PURE__ */ new Map();
169
- J = [];
168
+ H = /* @__PURE__ */ new Map();
169
+ K = [];
170
170
  f = [];
171
171
  k = null;
172
172
  B = false;
@@ -174,21 +174,21 @@ var Transition = class _Transition {
174
174
  d = globalQueue;
175
175
  created = clock;
176
176
  constructor() {
177
- this.G.set(globalQueue, this);
177
+ this.H.set(globalQueue, this);
178
178
  for (const child of globalQueue.f) {
179
179
  cloneQueue(child, this, this);
180
180
  }
181
181
  }
182
182
  enqueue(type, fn) {
183
- this.J.push(fn);
183
+ this.K.push(fn);
184
184
  if (type)
185
185
  this.g[type - 1].push(fn);
186
186
  this.schedule();
187
187
  }
188
188
  run(type) {
189
189
  if (type === EFFECT_PURE) {
190
- this.J.length && runQueue(this.J, type);
191
- this.J = [];
190
+ this.K.length && runQueue(this.K, type);
191
+ this.K = [];
192
192
  return;
193
193
  } else if (this.g[type - 1].length) {
194
194
  const effects = this.g[type - 1];
@@ -238,7 +238,7 @@ var Transition = class _Transition {
238
238
  merge(queue) {
239
239
  this.g[0].push.apply(this.g[0], queue.g[0]);
240
240
  this.g[1].push.apply(this.g[1], queue.g[1]);
241
- this.J.push.apply(this.J, queue.J);
241
+ this.K.push.apply(this.K, queue.K);
242
242
  for (let i = 0; i < queue.f.length; i++) {
243
243
  const og = this.f.find((c) => c.d === queue.f[i].d);
244
244
  if (og)
@@ -255,9 +255,9 @@ var Transition = class _Transition {
255
255
  queueMicrotask(() => this.flush());
256
256
  }
257
257
  runTransition(fn, force = false) {
258
- if (this.D) {
259
- if (this.D instanceof _Transition)
260
- return this.D.runTransition(fn, force);
258
+ if (this.E) {
259
+ if (this.E instanceof _Transition)
260
+ return this.E.runTransition(fn, force);
261
261
  if (!force)
262
262
  throw new Error("Transition already completed");
263
263
  fn();
@@ -272,12 +272,12 @@ var Transition = class _Transition {
272
272
  let temp, value;
273
273
  while (!(temp = result.next(value)).done) {
274
274
  if (temp.value instanceof Promise) {
275
- transition2.H.add(temp.value);
275
+ transition2.I.add(temp.value);
276
276
  try {
277
277
  value = await temp.value;
278
278
  } finally {
279
279
  transition2 = latestTransition(transition2);
280
- transition2.H.delete(temp.value);
280
+ transition2.I.delete(temp.value);
281
281
  }
282
282
  ActiveTransition = transition2;
283
283
  } else
@@ -288,10 +288,10 @@ var Transition = class _Transition {
288
288
  })();
289
289
  }
290
290
  if (result instanceof Promise) {
291
- transition2.H.add(result);
291
+ transition2.I.add(result);
292
292
  result.finally(() => {
293
293
  transition2 = latestTransition(transition2);
294
- transition2.H.delete(result);
294
+ transition2.I.delete(result);
295
295
  ActiveTransition = null;
296
296
  finishTransition(transition2);
297
297
  });
@@ -309,7 +309,7 @@ var Transition = class _Transition {
309
309
  return;
310
310
  }
311
311
  fn.j = this;
312
- this.I.add(fn);
312
+ this.J.add(fn);
313
313
  }
314
314
  };
315
315
  function transition(fn) {
@@ -331,7 +331,7 @@ function cloneGraph(node, optimistic) {
331
331
  c: null,
332
332
  a: node.a ? [...node.a] : null,
333
333
  d: node,
334
- I: !!optimistic
334
+ J: !!optimistic
335
335
  });
336
336
  delete clone.T;
337
337
  ActiveTransition.a.set(node, clone);
@@ -349,8 +349,8 @@ function cloneGraph(node, optimistic) {
349
349
  return clone;
350
350
  }
351
351
  function latestTransition(t) {
352
- while (t.D instanceof Transition)
353
- t = t.D;
352
+ while (t.E instanceof Transition)
353
+ t = t.E;
354
354
  return t;
355
355
  }
356
356
  function replaceSourceObservers(node, transition2) {
@@ -378,7 +378,7 @@ function cloneQueue(queue, parent, transition2) {
378
378
  },
379
379
  notify(node, type, flags) {
380
380
  node = node.d || node;
381
- if (!clone.K || type & LOADING_BIT) {
381
+ if (!clone.L || type & LOADING_BIT) {
382
382
  type &= ~LOADING_BIT;
383
383
  transition2 = latestTransition(transition2);
384
384
  transition2.notify(node, LOADING_BIT, flags);
@@ -389,7 +389,7 @@ function cloneQueue(queue, parent, transition2) {
389
389
  }
390
390
  });
391
391
  parent.f.push(clone);
392
- transition2.G.set(queue, clone);
392
+ transition2.H.set(queue, clone);
393
393
  for (const child of queue.f) {
394
394
  cloneQueue(child, clone, transition2);
395
395
  }
@@ -416,14 +416,14 @@ function mergeTransitions(t1, t2) {
416
416
  key.j = t1;
417
417
  t1.a.set(key, value);
418
418
  });
419
- t2.I.forEach((c) => {
419
+ t2.J.forEach((c) => {
420
420
  c.j = t1;
421
- t1.I.add(c);
421
+ t1.J.add(c);
422
422
  });
423
- t2.H.forEach((p) => t1.H.add(p));
423
+ t2.I.forEach((p) => t1.I.add(p));
424
424
  t2.s.forEach((n) => t1.s.add(n));
425
425
  t1.merge(t2);
426
- t2.D = t1;
426
+ t2.E = t1;
427
427
  }
428
428
  function getTransitionSource(input) {
429
429
  return ActiveTransition && ActiveTransition.a.get(input) || input;
@@ -431,7 +431,7 @@ function getTransitionSource(input) {
431
431
  function getQueue(node) {
432
432
  var _a;
433
433
  const transition2 = ActiveTransition || ((_a = node.d) == null ? void 0 : _a.j);
434
- return transition2 && transition2.G.get(node.C) || node.C;
434
+ return transition2 && transition2.H.get(node.C) || node.C;
435
435
  }
436
436
  function initialDispose(node) {
437
437
  let current = node.m;
@@ -444,7 +444,7 @@ function initialDispose(node) {
444
444
  }
445
445
  }
446
446
  function finishTransition(transition2) {
447
- if (transition2.D || transition2.Y || transition2.H.size || transition2.s.size)
447
+ if (transition2.E || transition2.Y || transition2.I.size || transition2.s.size)
448
448
  return;
449
449
  globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
450
450
  globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
@@ -456,7 +456,7 @@ function finishTransition(transition2) {
456
456
  }
457
457
  if (clone.a)
458
458
  replaceSourceObservers(clone, transition2);
459
- if (clone.I) {
459
+ if (clone.J) {
460
460
  clone.dispose();
461
461
  clone.emptyDisposal();
462
462
  delete source.j;
@@ -481,8 +481,8 @@ function finishTransition(transition2) {
481
481
  }
482
482
  delete source.j;
483
483
  }
484
- transition2.D = true;
485
- for (const reset of transition2.I) {
484
+ transition2.E = true;
485
+ for (const reset of transition2.J) {
486
486
  delete reset.j;
487
487
  reset();
488
488
  }
@@ -546,13 +546,13 @@ var Owner = class {
546
546
  }
547
547
  this.fa = 0;
548
548
  if (self)
549
- this.L();
549
+ this.M();
550
550
  if (current)
551
551
  current.y = !self ? this : this.y;
552
552
  if (head)
553
553
  head.m = current;
554
554
  }
555
- L() {
555
+ M() {
556
556
  if (this.y)
557
557
  this.y.m = null;
558
558
  this.k = null;
@@ -657,10 +657,10 @@ var Computation = class extends Owner {
657
657
  /** Which flags raised by sources are handled, vs. being passed through. */
658
658
  ba = DEFAULT_FLAGS;
659
659
  Q = -1;
660
- E = false;
660
+ F = false;
661
661
  j;
662
662
  d;
663
- I = false;
663
+ J = false;
664
664
  constructor(initialValue, compute2, options) {
665
665
  super(options == null ? void 0 : options.id, compute2 === null);
666
666
  this.P = compute2;
@@ -699,7 +699,7 @@ var Computation = class extends Owner {
699
699
  if (this.i & ERROR_BIT && this.Q <= clock)
700
700
  update(this);
701
701
  else
702
- this.M();
702
+ this.D();
703
703
  }
704
704
  return this.ga();
705
705
  }
@@ -720,7 +720,7 @@ var Computation = class extends Owner {
720
720
  if (this.i & ERROR_BIT && this.Q <= clock)
721
721
  update(this);
722
722
  else
723
- this.M();
723
+ this.D();
724
724
  }
725
725
  if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
726
726
  track(this);
@@ -763,9 +763,9 @@ var Computation = class extends Owner {
763
763
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
764
764
  */
765
765
  t(state, skipQueue) {
766
- if (this.b >= state && !this.E)
766
+ if (this.b >= state && !this.F)
767
767
  return;
768
- this.E = !!skipQueue;
768
+ this.F = !!skipQueue;
769
769
  this.b = state;
770
770
  if (this.c) {
771
771
  for (let i = 0; i < this.c.length; i++) {
@@ -786,7 +786,7 @@ var Computation = class extends Owner {
786
786
  this.t(STATE_DIRTY);
787
787
  return;
788
788
  }
789
- if (this.b >= STATE_CHECK && !this.E)
789
+ if (this.b >= STATE_CHECK && !this.F)
790
790
  return;
791
791
  const prevFlags = this.i & mask;
792
792
  const deltaFlags = prevFlags ^ newFlags2;
@@ -817,7 +817,7 @@ var Computation = class extends Owner {
817
817
  *
818
818
  * This function will ensure that the value and states we read from the computation are up to date
819
819
  */
820
- M() {
820
+ D() {
821
821
  if (!this.P) {
822
822
  return;
823
823
  }
@@ -831,7 +831,7 @@ var Computation = class extends Owner {
831
831
  if (this.b === STATE_CHECK) {
832
832
  for (let i = 0; i < this.a.length; i++) {
833
833
  const source = getTransitionSource(this.a[i]);
834
- source.M();
834
+ source.D();
835
835
  observerFlags |= source.i & ~UNINITIALIZED_BIT;
836
836
  if (this.b === STATE_DIRTY) {
837
837
  break;
@@ -848,12 +848,12 @@ var Computation = class extends Owner {
848
848
  /**
849
849
  * Remove ourselves from the owner graph and the computation graph
850
850
  */
851
- L() {
851
+ M() {
852
852
  if (this.b === STATE_DISPOSED)
853
853
  return;
854
854
  if (this.a)
855
855
  removeSourceObservers(this, 0);
856
- super.L();
856
+ super.M();
857
857
  }
858
858
  };
859
859
  function track(computation) {
@@ -1014,7 +1014,7 @@ var Effect = class extends Computation {
1014
1014
  return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1015
1015
  };
1016
1016
  }
1017
- this.M();
1017
+ this.D();
1018
1018
  !(options == null ? void 0 : options.defer) && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
1019
1019
  }
1020
1020
  write(value, flags = 0) {
@@ -1067,7 +1067,7 @@ var Effect = class extends Computation {
1067
1067
  if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
1068
1068
  throw error;
1069
1069
  }
1070
- L() {
1070
+ M() {
1071
1071
  var _a;
1072
1072
  if (this.b === STATE_DISPOSED)
1073
1073
  return;
@@ -1077,7 +1077,7 @@ var Effect = class extends Computation {
1077
1077
  (_a = this.u) == null ? void 0 : _a.call(this);
1078
1078
  this.u = void 0;
1079
1079
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1080
- super.L();
1080
+ super.M();
1081
1081
  }
1082
1082
  w(type) {
1083
1083
  var _a;
@@ -1118,14 +1118,14 @@ var TrackedEffect = class extends Computation {
1118
1118
  getQueue(this).enqueue(this.r, this.w.bind(this));
1119
1119
  this.b = state;
1120
1120
  }
1121
- L() {
1121
+ M() {
1122
1122
  var _a;
1123
1123
  if (this.b === STATE_DISPOSED)
1124
1124
  return;
1125
1125
  (_a = this.u) == null ? void 0 : _a.call(this);
1126
1126
  this.u = void 0;
1127
1127
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1128
- super.L();
1128
+ super.M();
1129
1129
  }
1130
1130
  w(type) {
1131
1131
  if (type)
@@ -1135,12 +1135,12 @@ var TrackedEffect = class extends Computation {
1135
1135
  var EagerComputation = class extends Computation {
1136
1136
  constructor(initialValue, compute2, options) {
1137
1137
  super(initialValue, compute2, options);
1138
- !(options == null ? void 0 : options.defer) && this.M();
1138
+ !(options == null ? void 0 : options.defer) && this.D();
1139
1139
  }
1140
1140
  t(state, skipQueue) {
1141
- if (this.b >= state && !this.E)
1141
+ if (this.b >= state && !this.F)
1142
1142
  return;
1143
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1143
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
1144
1144
  getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1145
1145
  super.t(state, skipQueue);
1146
1146
  }
@@ -1154,12 +1154,12 @@ var FirewallComputation = class extends Computation {
1154
1154
  super(void 0, compute2);
1155
1155
  }
1156
1156
  t(state, skipQueue) {
1157
- if (this.b >= state && !this.E)
1157
+ if (this.b >= state && !this.F)
1158
1158
  return;
1159
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1159
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
1160
1160
  getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1161
1161
  super.t(state, true);
1162
- this.E = !!skipQueue;
1162
+ this.F = !!skipQueue;
1163
1163
  }
1164
1164
  w() {
1165
1165
  this.b !== STATE_CLEAN && runTop(this);
@@ -1176,7 +1176,7 @@ function runTop(node) {
1176
1176
  }
1177
1177
  for (let i = ancestors.length - 1; i >= 0; i--) {
1178
1178
  if (ancestors[i].b !== STATE_DISPOSED)
1179
- ancestors[i].M();
1179
+ ancestors[i].D();
1180
1180
  }
1181
1181
  }
1182
1182
 
@@ -1184,7 +1184,10 @@ function runTop(node) {
1184
1184
  function createSignal(first, second, third) {
1185
1185
  if (typeof first === "function") {
1186
1186
  const node2 = new Computation(second, first, third);
1187
- return [node2.read.bind(node2), node2.write.bind(node2)];
1187
+ return [node2.read.bind(node2), (v) => {
1188
+ node2.D();
1189
+ return node2.write(v);
1190
+ }];
1188
1191
  }
1189
1192
  const o = getOwner();
1190
1193
  const needsId = (o == null ? void 0 : o.id) != null;
@@ -1289,7 +1292,7 @@ function createAsync(compute2, value, options) {
1289
1292
  }
1290
1293
  n.b = STATE_DIRTY;
1291
1294
  refreshing = true;
1292
- n.M();
1295
+ n.D();
1293
1296
  };
1294
1297
  return read;
1295
1298
  }
@@ -1363,7 +1366,12 @@ function createOptimistic(first, second, third) {
1363
1366
  throw new Error("createOptimistic can only be updated inside a transition");
1364
1367
  ActiveTransition.addOptimistic(reset);
1365
1368
  cloneGraph(node, true);
1366
- queueMicrotask(() => reset.j && node.write(v));
1369
+ queueMicrotask(() => {
1370
+ if (reset.j) {
1371
+ node.D();
1372
+ node.write(v);
1373
+ }
1374
+ });
1367
1375
  }
1368
1376
  return [node.read.bind(node), write];
1369
1377
  }
@@ -2071,7 +2079,7 @@ function mapArray(list, map, options) {
2071
2079
  U: new Owner(),
2072
2080
  o: 0,
2073
2081
  ia: list,
2074
- F: [],
2082
+ G: [],
2075
2083
  R: map,
2076
2084
  h: [],
2077
2085
  e: [],
@@ -2105,7 +2113,7 @@ function updateKeyedMap() {
2105
2113
  if (this.o !== 0) {
2106
2114
  this.U.dispose(false);
2107
2115
  this.e = [];
2108
- this.F = [];
2116
+ this.G = [];
2109
2117
  this.h = [];
2110
2118
  this.o = 0;
2111
2119
  this.p && (this.p = []);
@@ -2123,17 +2131,17 @@ function updateKeyedMap() {
2123
2131
  this.e[0].dispose();
2124
2132
  this.h = new Array(newLen);
2125
2133
  for (j = 0; j < newLen; j++) {
2126
- this.F[j] = newItems[j];
2134
+ this.G[j] = newItems[j];
2127
2135
  this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
2128
2136
  }
2129
2137
  this.o = newLen;
2130
2138
  } else {
2131
2139
  let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
2132
- for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.S, this.F[start], newItems[start])); start++) {
2140
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.G[start] === newItems[start] || this.p && compare(this.S, this.G[start], newItems[start])); start++) {
2133
2141
  if (this.p)
2134
2142
  this.p[start].write(newItems[start]);
2135
2143
  }
2136
- for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.S, this.F[end], newItems[newEnd])); end--, newEnd--) {
2144
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.p && compare(this.S, this.G[end], newItems[newEnd])); end--, newEnd--) {
2137
2145
  temp[newEnd] = this.h[end];
2138
2146
  tempNodes[newEnd] = this.e[end];
2139
2147
  tempRows && (tempRows[newEnd] = this.p[end]);
@@ -2149,7 +2157,7 @@ function updateKeyedMap() {
2149
2157
  newIndices.set(key, j);
2150
2158
  }
2151
2159
  for (i = start; i <= end; i++) {
2152
- item = this.F[i];
2160
+ item = this.G[i];
2153
2161
  key = this.S ? this.S(item) : item;
2154
2162
  j = newIndices.get(key);
2155
2163
  if (j !== void 0 && j !== -1) {
@@ -2179,7 +2187,7 @@ function updateKeyedMap() {
2179
2187
  }
2180
2188
  }
2181
2189
  this.h = this.h.slice(0, this.o = newLen);
2182
- this.F = newItems.slice(0);
2190
+ this.G = newItems.slice(0);
2183
2191
  }
2184
2192
  });
2185
2193
  return this.h;
@@ -2332,12 +2340,12 @@ var ConditionalQueue = class extends Queue {
2332
2340
  }
2333
2341
  };
2334
2342
  var CollectionQueue = class extends Queue {
2335
- K;
2343
+ L;
2336
2344
  e = /* @__PURE__ */ new Set();
2337
2345
  x = new Computation(false, null, { pureWrite: true });
2338
2346
  constructor(type) {
2339
2347
  super();
2340
- this.K = type;
2348
+ this.L = type;
2341
2349
  }
2342
2350
  run(type) {
2343
2351
  if (!type || this.x.read())
@@ -2345,9 +2353,9 @@ var CollectionQueue = class extends Queue {
2345
2353
  return super.run(type);
2346
2354
  }
2347
2355
  notify(node, type, flags) {
2348
- if (!(type & this.K))
2356
+ if (!(type & this.L))
2349
2357
  return super.notify(node, type, flags);
2350
- if (flags & this.K) {
2358
+ if (flags & this.L) {
2351
2359
  this.e.add(node);
2352
2360
  if (this.e.size === 1)
2353
2361
  this.x.write(true);
@@ -2356,11 +2364,11 @@ var CollectionQueue = class extends Queue {
2356
2364
  if (this.e.size === 0)
2357
2365
  this.x.write(false);
2358
2366
  }
2359
- type &= ~this.K;
2367
+ type &= ~this.L;
2360
2368
  return type ? super.notify(node, type, flags) : true;
2361
2369
  }
2362
2370
  merge(queue) {
2363
- queue.e.forEach((n) => this.notify(n, this.K, this.K));
2371
+ queue.e.forEach((n) => this.notify(n, this.L, this.L));
2364
2372
  super.merge(queue);
2365
2373
  }
2366
2374
  };
package/dist/prod.js CHANGED
@@ -99,14 +99,14 @@ var Queue = class {
99
99
  }
100
100
  }
101
101
  addChild(child) {
102
- if (ActiveTransition && ActiveTransition.G.has(this))
103
- return ActiveTransition.G.get(this).addChild(child);
102
+ if (ActiveTransition && ActiveTransition.H.has(this))
103
+ return ActiveTransition.H.get(this).addChild(child);
104
104
  this.f.push(child);
105
105
  child.k = this;
106
106
  }
107
107
  removeChild(child) {
108
- if (ActiveTransition && ActiveTransition.G.has(this))
109
- return ActiveTransition.G.get(this).removeChild(child);
108
+ if (ActiveTransition && ActiveTransition.H.has(this))
109
+ return ActiveTransition.H.get(this).removeChild(child);
110
110
  const index = this.f.indexOf(child);
111
111
  if (index >= 0) {
112
112
  this.f.splice(index, 1);
@@ -158,12 +158,12 @@ function runQueue(queue, type) {
158
158
  var Transition = class _Transition {
159
159
  a = /* @__PURE__ */ new Map();
160
160
  s = /* @__PURE__ */ new Set();
161
- H = /* @__PURE__ */ new Set();
162
161
  I = /* @__PURE__ */ new Set();
163
- D = false;
162
+ J = /* @__PURE__ */ new Set();
163
+ E = false;
164
164
  g = [[], []];
165
- G = /* @__PURE__ */ new Map();
166
- J = [];
165
+ H = /* @__PURE__ */ new Map();
166
+ K = [];
167
167
  f = [];
168
168
  k = null;
169
169
  B = false;
@@ -171,21 +171,21 @@ var Transition = class _Transition {
171
171
  d = globalQueue;
172
172
  created = clock;
173
173
  constructor() {
174
- this.G.set(globalQueue, this);
174
+ this.H.set(globalQueue, this);
175
175
  for (const child of globalQueue.f) {
176
176
  cloneQueue(child, this, this);
177
177
  }
178
178
  }
179
179
  enqueue(type, fn) {
180
- this.J.push(fn);
180
+ this.K.push(fn);
181
181
  if (type)
182
182
  this.g[type - 1].push(fn);
183
183
  this.schedule();
184
184
  }
185
185
  run(type) {
186
186
  if (type === EFFECT_PURE) {
187
- this.J.length && runQueue(this.J, type);
188
- this.J = [];
187
+ this.K.length && runQueue(this.K, type);
188
+ this.K = [];
189
189
  return;
190
190
  } else if (this.g[type - 1].length) {
191
191
  const effects = this.g[type - 1];
@@ -235,7 +235,7 @@ var Transition = class _Transition {
235
235
  merge(queue) {
236
236
  this.g[0].push.apply(this.g[0], queue.g[0]);
237
237
  this.g[1].push.apply(this.g[1], queue.g[1]);
238
- this.J.push.apply(this.J, queue.J);
238
+ this.K.push.apply(this.K, queue.K);
239
239
  for (let i = 0; i < queue.f.length; i++) {
240
240
  const og = this.f.find((c) => c.d === queue.f[i].d);
241
241
  if (og)
@@ -252,9 +252,9 @@ var Transition = class _Transition {
252
252
  queueMicrotask(() => this.flush());
253
253
  }
254
254
  runTransition(fn, force = false) {
255
- if (this.D) {
256
- if (this.D instanceof _Transition)
257
- return this.D.runTransition(fn, force);
255
+ if (this.E) {
256
+ if (this.E instanceof _Transition)
257
+ return this.E.runTransition(fn, force);
258
258
  if (!force)
259
259
  throw new Error("Transition already completed");
260
260
  fn();
@@ -269,12 +269,12 @@ var Transition = class _Transition {
269
269
  let temp, value;
270
270
  while (!(temp = result.next(value)).done) {
271
271
  if (temp.value instanceof Promise) {
272
- transition2.H.add(temp.value);
272
+ transition2.I.add(temp.value);
273
273
  try {
274
274
  value = await temp.value;
275
275
  } finally {
276
276
  transition2 = latestTransition(transition2);
277
- transition2.H.delete(temp.value);
277
+ transition2.I.delete(temp.value);
278
278
  }
279
279
  ActiveTransition = transition2;
280
280
  } else
@@ -285,10 +285,10 @@ var Transition = class _Transition {
285
285
  })();
286
286
  }
287
287
  if (result instanceof Promise) {
288
- transition2.H.add(result);
288
+ transition2.I.add(result);
289
289
  result.finally(() => {
290
290
  transition2 = latestTransition(transition2);
291
- transition2.H.delete(result);
291
+ transition2.I.delete(result);
292
292
  ActiveTransition = null;
293
293
  finishTransition(transition2);
294
294
  });
@@ -306,7 +306,7 @@ var Transition = class _Transition {
306
306
  return;
307
307
  }
308
308
  fn.j = this;
309
- this.I.add(fn);
309
+ this.J.add(fn);
310
310
  }
311
311
  };
312
312
  function transition(fn) {
@@ -328,7 +328,7 @@ function cloneGraph(node, optimistic) {
328
328
  c: null,
329
329
  a: node.a ? [...node.a] : null,
330
330
  d: node,
331
- I: !!optimistic
331
+ J: !!optimistic
332
332
  });
333
333
  delete clone.T;
334
334
  ActiveTransition.a.set(node, clone);
@@ -346,8 +346,8 @@ function cloneGraph(node, optimistic) {
346
346
  return clone;
347
347
  }
348
348
  function latestTransition(t) {
349
- while (t.D instanceof Transition)
350
- t = t.D;
349
+ while (t.E instanceof Transition)
350
+ t = t.E;
351
351
  return t;
352
352
  }
353
353
  function replaceSourceObservers(node, transition2) {
@@ -375,7 +375,7 @@ function cloneQueue(queue, parent, transition2) {
375
375
  },
376
376
  notify(node, type, flags) {
377
377
  node = node.d || node;
378
- if (!clone.K || type & LOADING_BIT) {
378
+ if (!clone.L || type & LOADING_BIT) {
379
379
  type &= ~LOADING_BIT;
380
380
  transition2 = latestTransition(transition2);
381
381
  transition2.notify(node, LOADING_BIT, flags);
@@ -386,7 +386,7 @@ function cloneQueue(queue, parent, transition2) {
386
386
  }
387
387
  });
388
388
  parent.f.push(clone);
389
- transition2.G.set(queue, clone);
389
+ transition2.H.set(queue, clone);
390
390
  for (const child of queue.f) {
391
391
  cloneQueue(child, clone, transition2);
392
392
  }
@@ -413,21 +413,21 @@ function mergeTransitions(t1, t2) {
413
413
  key.j = t1;
414
414
  t1.a.set(key, value);
415
415
  });
416
- t2.I.forEach((c) => {
416
+ t2.J.forEach((c) => {
417
417
  c.j = t1;
418
- t1.I.add(c);
418
+ t1.J.add(c);
419
419
  });
420
- t2.H.forEach((p) => t1.H.add(p));
420
+ t2.I.forEach((p) => t1.I.add(p));
421
421
  t2.s.forEach((n) => t1.s.add(n));
422
422
  t1.merge(t2);
423
- t2.D = t1;
423
+ t2.E = t1;
424
424
  }
425
425
  function getTransitionSource(input) {
426
426
  return ActiveTransition && ActiveTransition.a.get(input) || input;
427
427
  }
428
428
  function getQueue(node) {
429
429
  const transition2 = ActiveTransition || node.d?.j;
430
- return transition2 && transition2.G.get(node.C) || node.C;
430
+ return transition2 && transition2.H.get(node.C) || node.C;
431
431
  }
432
432
  function initialDispose(node) {
433
433
  let current = node.m;
@@ -440,7 +440,7 @@ function initialDispose(node) {
440
440
  }
441
441
  }
442
442
  function finishTransition(transition2) {
443
- if (transition2.D || transition2.Y || transition2.H.size || transition2.s.size)
443
+ if (transition2.E || transition2.Y || transition2.I.size || transition2.s.size)
444
444
  return;
445
445
  globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
446
446
  globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
@@ -452,7 +452,7 @@ function finishTransition(transition2) {
452
452
  }
453
453
  if (clone.a)
454
454
  replaceSourceObservers(clone, transition2);
455
- if (clone.I) {
455
+ if (clone.J) {
456
456
  clone.dispose();
457
457
  clone.emptyDisposal();
458
458
  delete source.j;
@@ -477,8 +477,8 @@ function finishTransition(transition2) {
477
477
  }
478
478
  delete source.j;
479
479
  }
480
- transition2.D = true;
481
- for (const reset of transition2.I) {
480
+ transition2.E = true;
481
+ for (const reset of transition2.J) {
482
482
  delete reset.j;
483
483
  reset();
484
484
  }
@@ -542,13 +542,13 @@ var Owner = class {
542
542
  }
543
543
  this.fa = 0;
544
544
  if (self)
545
- this.L();
545
+ this.M();
546
546
  if (current)
547
547
  current.y = !self ? this : this.y;
548
548
  if (head)
549
549
  head.m = current;
550
550
  }
551
- L() {
551
+ M() {
552
552
  if (this.y)
553
553
  this.y.m = null;
554
554
  this.k = null;
@@ -653,10 +653,10 @@ var Computation = class extends Owner {
653
653
  /** Which flags raised by sources are handled, vs. being passed through. */
654
654
  ba = DEFAULT_FLAGS;
655
655
  Q = -1;
656
- E = false;
656
+ F = false;
657
657
  j;
658
658
  d;
659
- I = false;
659
+ J = false;
660
660
  constructor(initialValue, compute2, options) {
661
661
  super(options?.id, compute2 === null);
662
662
  this.P = compute2;
@@ -695,7 +695,7 @@ var Computation = class extends Owner {
695
695
  if (this.i & ERROR_BIT && this.Q <= clock)
696
696
  update(this);
697
697
  else
698
- this.M();
698
+ this.D();
699
699
  }
700
700
  return this.ga();
701
701
  }
@@ -716,7 +716,7 @@ var Computation = class extends Owner {
716
716
  if (this.i & ERROR_BIT && this.Q <= clock)
717
717
  update(this);
718
718
  else
719
- this.M();
719
+ this.D();
720
720
  }
721
721
  if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
722
722
  track(this);
@@ -759,9 +759,9 @@ var Computation = class extends Owner {
759
759
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
760
760
  */
761
761
  t(state, skipQueue) {
762
- if (this.b >= state && !this.E)
762
+ if (this.b >= state && !this.F)
763
763
  return;
764
- this.E = !!skipQueue;
764
+ this.F = !!skipQueue;
765
765
  this.b = state;
766
766
  if (this.c) {
767
767
  for (let i = 0; i < this.c.length; i++) {
@@ -782,7 +782,7 @@ var Computation = class extends Owner {
782
782
  this.t(STATE_DIRTY);
783
783
  return;
784
784
  }
785
- if (this.b >= STATE_CHECK && !this.E)
785
+ if (this.b >= STATE_CHECK && !this.F)
786
786
  return;
787
787
  const prevFlags = this.i & mask;
788
788
  const deltaFlags = prevFlags ^ newFlags2;
@@ -813,7 +813,7 @@ var Computation = class extends Owner {
813
813
  *
814
814
  * This function will ensure that the value and states we read from the computation are up to date
815
815
  */
816
- M() {
816
+ D() {
817
817
  if (!this.P) {
818
818
  return;
819
819
  }
@@ -827,7 +827,7 @@ var Computation = class extends Owner {
827
827
  if (this.b === STATE_CHECK) {
828
828
  for (let i = 0; i < this.a.length; i++) {
829
829
  const source = getTransitionSource(this.a[i]);
830
- source.M();
830
+ source.D();
831
831
  observerFlags |= source.i & ~UNINITIALIZED_BIT;
832
832
  if (this.b === STATE_DIRTY) {
833
833
  break;
@@ -844,12 +844,12 @@ var Computation = class extends Owner {
844
844
  /**
845
845
  * Remove ourselves from the owner graph and the computation graph
846
846
  */
847
- L() {
847
+ M() {
848
848
  if (this.b === STATE_DISPOSED)
849
849
  return;
850
850
  if (this.a)
851
851
  removeSourceObservers(this, 0);
852
- super.L();
852
+ super.M();
853
853
  }
854
854
  };
855
855
  function track(computation) {
@@ -1010,7 +1010,7 @@ var Effect = class extends Computation {
1010
1010
  return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1011
1011
  };
1012
1012
  }
1013
- this.M();
1013
+ this.D();
1014
1014
  !options?.defer && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
1015
1015
  }
1016
1016
  write(value, flags = 0) {
@@ -1062,7 +1062,7 @@ var Effect = class extends Computation {
1062
1062
  if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
1063
1063
  throw error;
1064
1064
  }
1065
- L() {
1065
+ M() {
1066
1066
  if (this.b === STATE_DISPOSED)
1067
1067
  return;
1068
1068
  this.ca = void 0;
@@ -1071,7 +1071,7 @@ var Effect = class extends Computation {
1071
1071
  this.u?.();
1072
1072
  this.u = void 0;
1073
1073
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1074
- super.L();
1074
+ super.M();
1075
1075
  }
1076
1076
  w(type) {
1077
1077
  if (type) {
@@ -1110,13 +1110,13 @@ var TrackedEffect = class extends Computation {
1110
1110
  getQueue(this).enqueue(this.r, this.w.bind(this));
1111
1111
  this.b = state;
1112
1112
  }
1113
- L() {
1113
+ M() {
1114
1114
  if (this.b === STATE_DISPOSED)
1115
1115
  return;
1116
1116
  this.u?.();
1117
1117
  this.u = void 0;
1118
1118
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1119
- super.L();
1119
+ super.M();
1120
1120
  }
1121
1121
  w(type) {
1122
1122
  if (type)
@@ -1126,12 +1126,12 @@ var TrackedEffect = class extends Computation {
1126
1126
  var EagerComputation = class extends Computation {
1127
1127
  constructor(initialValue, compute2, options) {
1128
1128
  super(initialValue, compute2, options);
1129
- !options?.defer && this.M();
1129
+ !options?.defer && this.D();
1130
1130
  }
1131
1131
  t(state, skipQueue) {
1132
- if (this.b >= state && !this.E)
1132
+ if (this.b >= state && !this.F)
1133
1133
  return;
1134
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1134
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
1135
1135
  getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1136
1136
  super.t(state, skipQueue);
1137
1137
  }
@@ -1145,12 +1145,12 @@ var FirewallComputation = class extends Computation {
1145
1145
  super(void 0, compute2);
1146
1146
  }
1147
1147
  t(state, skipQueue) {
1148
- if (this.b >= state && !this.E)
1148
+ if (this.b >= state && !this.F)
1149
1149
  return;
1150
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1150
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
1151
1151
  getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1152
1152
  super.t(state, true);
1153
- this.E = !!skipQueue;
1153
+ this.F = !!skipQueue;
1154
1154
  }
1155
1155
  w() {
1156
1156
  this.b !== STATE_CLEAN && runTop(this);
@@ -1167,7 +1167,7 @@ function runTop(node) {
1167
1167
  }
1168
1168
  for (let i = ancestors.length - 1; i >= 0; i--) {
1169
1169
  if (ancestors[i].b !== STATE_DISPOSED)
1170
- ancestors[i].M();
1170
+ ancestors[i].D();
1171
1171
  }
1172
1172
  }
1173
1173
 
@@ -1175,7 +1175,10 @@ function runTop(node) {
1175
1175
  function createSignal(first, second, third) {
1176
1176
  if (typeof first === "function") {
1177
1177
  const node2 = new Computation(second, first, third);
1178
- return [node2.read.bind(node2), node2.write.bind(node2)];
1178
+ return [node2.read.bind(node2), (v) => {
1179
+ node2.D();
1180
+ return node2.write(v);
1181
+ }];
1179
1182
  }
1180
1183
  const o = getOwner();
1181
1184
  const needsId = o?.id != null;
@@ -1279,7 +1282,7 @@ function createAsync(compute2, value, options) {
1279
1282
  }
1280
1283
  n.b = STATE_DIRTY;
1281
1284
  refreshing = true;
1282
- n.M();
1285
+ n.D();
1283
1286
  };
1284
1287
  return read;
1285
1288
  }
@@ -1352,7 +1355,12 @@ function createOptimistic(first, second, third) {
1352
1355
  throw new Error("createOptimistic can only be updated inside a transition");
1353
1356
  ActiveTransition.addOptimistic(reset);
1354
1357
  cloneGraph(node, true);
1355
- queueMicrotask(() => reset.j && node.write(v));
1358
+ queueMicrotask(() => {
1359
+ if (reset.j) {
1360
+ node.D();
1361
+ node.write(v);
1362
+ }
1363
+ });
1356
1364
  }
1357
1365
  return [node.read.bind(node), write];
1358
1366
  }
@@ -2052,7 +2060,7 @@ function mapArray(list, map, options) {
2052
2060
  U: new Owner(),
2053
2061
  o: 0,
2054
2062
  ia: list,
2055
- F: [],
2063
+ G: [],
2056
2064
  R: map,
2057
2065
  h: [],
2058
2066
  e: [],
@@ -2086,7 +2094,7 @@ function updateKeyedMap() {
2086
2094
  if (this.o !== 0) {
2087
2095
  this.U.dispose(false);
2088
2096
  this.e = [];
2089
- this.F = [];
2097
+ this.G = [];
2090
2098
  this.h = [];
2091
2099
  this.o = 0;
2092
2100
  this.p && (this.p = []);
@@ -2104,17 +2112,17 @@ function updateKeyedMap() {
2104
2112
  this.e[0].dispose();
2105
2113
  this.h = new Array(newLen);
2106
2114
  for (j = 0; j < newLen; j++) {
2107
- this.F[j] = newItems[j];
2115
+ this.G[j] = newItems[j];
2108
2116
  this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
2109
2117
  }
2110
2118
  this.o = newLen;
2111
2119
  } else {
2112
2120
  let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
2113
- for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.S, this.F[start], newItems[start])); start++) {
2121
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.G[start] === newItems[start] || this.p && compare(this.S, this.G[start], newItems[start])); start++) {
2114
2122
  if (this.p)
2115
2123
  this.p[start].write(newItems[start]);
2116
2124
  }
2117
- for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.S, this.F[end], newItems[newEnd])); end--, newEnd--) {
2125
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.p && compare(this.S, this.G[end], newItems[newEnd])); end--, newEnd--) {
2118
2126
  temp[newEnd] = this.h[end];
2119
2127
  tempNodes[newEnd] = this.e[end];
2120
2128
  tempRows && (tempRows[newEnd] = this.p[end]);
@@ -2130,7 +2138,7 @@ function updateKeyedMap() {
2130
2138
  newIndices.set(key, j);
2131
2139
  }
2132
2140
  for (i = start; i <= end; i++) {
2133
- item = this.F[i];
2141
+ item = this.G[i];
2134
2142
  key = this.S ? this.S(item) : item;
2135
2143
  j = newIndices.get(key);
2136
2144
  if (j !== void 0 && j !== -1) {
@@ -2160,7 +2168,7 @@ function updateKeyedMap() {
2160
2168
  }
2161
2169
  }
2162
2170
  this.h = this.h.slice(0, this.o = newLen);
2163
- this.F = newItems.slice(0);
2171
+ this.G = newItems.slice(0);
2164
2172
  }
2165
2173
  });
2166
2174
  return this.h;
@@ -2312,12 +2320,12 @@ var ConditionalQueue = class extends Queue {
2312
2320
  }
2313
2321
  };
2314
2322
  var CollectionQueue = class extends Queue {
2315
- K;
2323
+ L;
2316
2324
  e = /* @__PURE__ */ new Set();
2317
2325
  x = new Computation(false, null, { pureWrite: true });
2318
2326
  constructor(type) {
2319
2327
  super();
2320
- this.K = type;
2328
+ this.L = type;
2321
2329
  }
2322
2330
  run(type) {
2323
2331
  if (!type || this.x.read())
@@ -2325,9 +2333,9 @@ var CollectionQueue = class extends Queue {
2325
2333
  return super.run(type);
2326
2334
  }
2327
2335
  notify(node, type, flags) {
2328
- if (!(type & this.K))
2336
+ if (!(type & this.L))
2329
2337
  return super.notify(node, type, flags);
2330
- if (flags & this.K) {
2338
+ if (flags & this.L) {
2331
2339
  this.e.add(node);
2332
2340
  if (this.e.size === 1)
2333
2341
  this.x.write(true);
@@ -2336,11 +2344,11 @@ var CollectionQueue = class extends Queue {
2336
2344
  if (this.e.size === 0)
2337
2345
  this.x.write(false);
2338
2346
  }
2339
- type &= ~this.K;
2347
+ type &= ~this.L;
2340
2348
  return type ? super.notify(node, type, flags) : true;
2341
2349
  }
2342
2350
  merge(queue) {
2343
- queue.e.forEach((n) => this.notify(n, this.K, this.K));
2351
+ queue.e.forEach((n) => this.notify(n, this.L, this.L));
2344
2352
  super.merge(queue);
2345
2353
  }
2346
2354
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",