@solidjs/signals 0.9.0 → 0.9.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 +23 -19
- package/dist/node.cjs +189 -186
- package/dist/prod.js +91 -88
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -214,7 +214,7 @@ class GlobalQueue extends Queue {
|
|
|
214
214
|
this.stashQueues(activeTransition.queueStash);
|
|
215
215
|
clock++;
|
|
216
216
|
scheduled = false;
|
|
217
|
-
|
|
217
|
+
runTransitionPending(activeTransition.pendingNodes, true);
|
|
218
218
|
activeTransition = null;
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
@@ -222,18 +222,14 @@ class GlobalQueue extends Queue {
|
|
|
222
222
|
this.restoreQueues(activeTransition.queueStash);
|
|
223
223
|
transitions.delete(activeTransition);
|
|
224
224
|
activeTransition = null;
|
|
225
|
-
|
|
225
|
+
runTransitionPending(this.$, false);
|
|
226
|
+
dirtyQueue.R >= dirtyQueue.C && runHeap(dirtyQueue, GlobalQueue.L);
|
|
226
227
|
} else if (transitions.size) runHeap(zombieQueue, GlobalQueue.L);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
t.W = NOT_PENDING;
|
|
232
|
-
if (t.K) t.M = true;
|
|
233
|
-
}
|
|
234
|
-
if (t.m) GlobalQueue.F(t, false, true);
|
|
228
|
+
runPending(this.$);
|
|
229
|
+
while (dirtyQueue.R >= dirtyQueue.C) {
|
|
230
|
+
runHeap(dirtyQueue, GlobalQueue.L);
|
|
231
|
+
runPending(this.$);
|
|
235
232
|
}
|
|
236
|
-
this.$.length = 0;
|
|
237
233
|
clock++;
|
|
238
234
|
scheduled = false;
|
|
239
235
|
this.run(EFFECT_RENDER);
|
|
@@ -245,8 +241,8 @@ class GlobalQueue extends Queue {
|
|
|
245
241
|
notify(e, t, n) {
|
|
246
242
|
if (t & STATUS_PENDING) {
|
|
247
243
|
if (n & STATUS_PENDING) {
|
|
248
|
-
if (activeTransition && !activeTransition.asyncNodes.includes(e.
|
|
249
|
-
activeTransition.asyncNodes.push(e.
|
|
244
|
+
if (activeTransition && !activeTransition.asyncNodes.includes(e.W.cause)) {
|
|
245
|
+
activeTransition.asyncNodes.push(e.W.cause);
|
|
250
246
|
schedule();
|
|
251
247
|
}
|
|
252
248
|
}
|
|
@@ -257,7 +253,7 @@ class GlobalQueue extends Queue {
|
|
|
257
253
|
initTransition(e) {
|
|
258
254
|
if (activeTransition && activeTransition.time === clock) return;
|
|
259
255
|
if (!activeTransition) {
|
|
260
|
-
activeTransition = e.
|
|
256
|
+
activeTransition = e.j ?? {
|
|
261
257
|
time: clock,
|
|
262
258
|
pendingNodes: [],
|
|
263
259
|
asyncNodes: [],
|
|
@@ -268,29 +264,36 @@ class GlobalQueue extends Queue {
|
|
|
268
264
|
activeTransition.time = clock;
|
|
269
265
|
for (let e = 0; e < this.$.length; e++) {
|
|
270
266
|
const t = this.$[e];
|
|
271
|
-
t.
|
|
267
|
+
t.j = activeTransition;
|
|
272
268
|
activeTransition.pendingNodes.push(t);
|
|
273
269
|
}
|
|
274
270
|
this.$ = activeTransition.pendingNodes;
|
|
275
271
|
}
|
|
276
272
|
}
|
|
277
|
-
function runPending(e
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
r.X.q(t);
|
|
285
|
-
n = true;
|
|
273
|
+
function runPending(e) {
|
|
274
|
+
for (let t = 0; t < e.length; t++) {
|
|
275
|
+
const n = e[t];
|
|
276
|
+
if (n.K !== NOT_PENDING) {
|
|
277
|
+
n.M = n.K;
|
|
278
|
+
n.K = NOT_PENDING;
|
|
279
|
+
if (n.Y) n.B = true;
|
|
286
280
|
}
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
281
|
+
if (n.X && n.X.K !== NOT_PENDING) n.X.q(n.X.K);
|
|
282
|
+
if (n.m) GlobalQueue.F(n, false, true);
|
|
283
|
+
}
|
|
284
|
+
e.length = 0;
|
|
285
|
+
}
|
|
286
|
+
function runTransitionPending(e, t) {
|
|
287
|
+
const n = e.slice();
|
|
288
|
+
for (let e = 0; e < n.length; e++) {
|
|
289
|
+
const i = n[e];
|
|
290
|
+
i.j = activeTransition;
|
|
291
|
+
if (i.Z) i.Z.q(t);
|
|
292
|
+
if (i.X && i.X.K !== NOT_PENDING) {
|
|
293
|
+
i.X.q(i.X.K);
|
|
294
|
+
i.X.K = NOT_PENDING;
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
|
-
return n;
|
|
294
297
|
}
|
|
295
298
|
const globalQueue = new GlobalQueue();
|
|
296
299
|
function flush() {
|
|
@@ -313,7 +316,7 @@ function transitionComplete(e) {
|
|
|
313
316
|
}
|
|
314
317
|
function runInTransition(e, t) {
|
|
315
318
|
const n = activeTransition;
|
|
316
|
-
activeTransition = e.
|
|
319
|
+
activeTransition = e.j;
|
|
317
320
|
t(e);
|
|
318
321
|
activeTransition = n;
|
|
319
322
|
}
|
|
@@ -333,11 +336,11 @@ function notifySubs(e) {
|
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
338
|
function recompute(e, t = false) {
|
|
336
|
-
const n = e.
|
|
339
|
+
const n = e.Y && e.j != activeTransition;
|
|
337
340
|
if (!t) {
|
|
338
|
-
if (e.
|
|
341
|
+
if (e.j && activeTransition !== e.j && !n) globalQueue.initTransition(e);
|
|
339
342
|
deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
340
|
-
if (e.
|
|
343
|
+
if (e.j) disposeChildren(e);
|
|
341
344
|
else {
|
|
342
345
|
markDisposal(e);
|
|
343
346
|
e.ee = e.te;
|
|
@@ -351,10 +354,10 @@ function recompute(e, t = false) {
|
|
|
351
354
|
e.re = null;
|
|
352
355
|
e._ = REACTIVE_RECOMPUTING_DEPS;
|
|
353
356
|
e.se = clock;
|
|
354
|
-
let r = e.
|
|
357
|
+
let r = e.K === NOT_PENDING ? e.M : e.K;
|
|
355
358
|
let s = e.o;
|
|
356
359
|
let o = e.J;
|
|
357
|
-
let u = e.
|
|
360
|
+
let u = e.W;
|
|
358
361
|
let l = tracking;
|
|
359
362
|
setStatusFlags(e, STATUS_NONE | (o & STATUS_UNINITIALIZED));
|
|
360
363
|
tracking = true;
|
|
@@ -382,14 +385,14 @@ function recompute(e, t = false) {
|
|
|
382
385
|
else e.D = null;
|
|
383
386
|
}
|
|
384
387
|
}
|
|
385
|
-
const c = !e.oe || !e.oe(e.
|
|
386
|
-
const a = e.J !== o || e.
|
|
388
|
+
const c = !e.oe || !e.oe(e.K === NOT_PENDING || e.ue || n ? e.M : e.K, r);
|
|
389
|
+
const a = e.J !== o || e.W !== u;
|
|
387
390
|
e.le?.(a, o);
|
|
388
391
|
if (c || a) {
|
|
389
392
|
if (c) {
|
|
390
|
-
if (t || e.ue || n) e.
|
|
391
|
-
else e.
|
|
392
|
-
if (e.
|
|
393
|
+
if (t || e.ue || n) e.M = r;
|
|
394
|
+
else e.K = r;
|
|
395
|
+
if (e.X) e.X.K = r;
|
|
393
396
|
}
|
|
394
397
|
for (let t = e.O; t !== null; t = t.p) {
|
|
395
398
|
const n = t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
@@ -401,8 +404,8 @@ function recompute(e, t = false) {
|
|
|
401
404
|
insertIntoHeapHeight(t.A, t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
402
405
|
}
|
|
403
406
|
}
|
|
404
|
-
if ((!t || e.J & STATUS_PENDING) && !e.ue && !e.
|
|
405
|
-
if (e.
|
|
407
|
+
if ((!t || e.J & STATUS_PENDING) && !e.ue && !e.j) globalQueue.$.push(e);
|
|
408
|
+
if (e.j && n) runInTransition(e, recompute);
|
|
406
409
|
}
|
|
407
410
|
function handleAsync(e, t, n) {
|
|
408
411
|
const i = typeof t === "object" && t !== null;
|
|
@@ -529,7 +532,7 @@ function isValidLink(e, t) {
|
|
|
529
532
|
}
|
|
530
533
|
function setStatusFlags(e, t, n = null) {
|
|
531
534
|
e.J = t;
|
|
532
|
-
e.
|
|
535
|
+
e.W = n;
|
|
533
536
|
}
|
|
534
537
|
function markDisposal(e) {
|
|
535
538
|
let t = e.ie;
|
|
@@ -612,7 +615,7 @@ function computed(e, t, n) {
|
|
|
612
615
|
Se: context?.Se ?? defaultContext,
|
|
613
616
|
he: 0,
|
|
614
617
|
m: e,
|
|
615
|
-
|
|
618
|
+
M: t,
|
|
616
619
|
o: 0,
|
|
617
620
|
N: null,
|
|
618
621
|
h: undefined,
|
|
@@ -627,11 +630,11 @@ function computed(e, t, n) {
|
|
|
627
630
|
_: REACTIVE_NONE,
|
|
628
631
|
J: STATUS_UNINITIALIZED,
|
|
629
632
|
se: clock,
|
|
630
|
-
|
|
633
|
+
K: NOT_PENDING,
|
|
631
634
|
ee: null,
|
|
632
635
|
ne: null,
|
|
633
636
|
ce: null,
|
|
634
|
-
|
|
637
|
+
j: null
|
|
635
638
|
};
|
|
636
639
|
if (n?.Oe) Object.assign(i, n.Oe);
|
|
637
640
|
i.T = i;
|
|
@@ -655,14 +658,14 @@ function signal(e, t, n = null) {
|
|
|
655
658
|
oe: t?.equals != null ? t.equals : isEqual,
|
|
656
659
|
Re: !!t?.pureWrite,
|
|
657
660
|
Ee: t?.unobserved,
|
|
658
|
-
|
|
661
|
+
M: e,
|
|
659
662
|
O: null,
|
|
660
663
|
fe: null,
|
|
661
664
|
J: STATUS_NONE,
|
|
662
665
|
se: clock,
|
|
663
666
|
U: n,
|
|
664
667
|
I: n?.N || null,
|
|
665
|
-
|
|
668
|
+
K: NOT_PENDING
|
|
666
669
|
};
|
|
667
670
|
n && (n.N = i);
|
|
668
671
|
return i;
|
|
@@ -701,33 +704,33 @@ function read(e) {
|
|
|
701
704
|
}
|
|
702
705
|
}
|
|
703
706
|
if (pendingCheck) {
|
|
704
|
-
if (!e.
|
|
705
|
-
e.
|
|
706
|
-
e.
|
|
707
|
-
e.
|
|
707
|
+
if (!e.Z) {
|
|
708
|
+
e.Z = signal(false);
|
|
709
|
+
e.Z.ue = true;
|
|
710
|
+
e.Z.q = t => setSignal(e.Z, t);
|
|
708
711
|
}
|
|
709
712
|
const t = pendingCheck;
|
|
710
713
|
pendingCheck = null;
|
|
711
|
-
t.
|
|
714
|
+
t.M = read(e.Z) || t.M;
|
|
712
715
|
pendingCheck = t;
|
|
713
716
|
}
|
|
714
717
|
if (pendingValueCheck) {
|
|
715
|
-
if (!e.
|
|
716
|
-
e.
|
|
717
|
-
e.
|
|
718
|
-
e.
|
|
718
|
+
if (!e.X) {
|
|
719
|
+
e.X = signal(e.M);
|
|
720
|
+
e.X.ue = true;
|
|
721
|
+
e.X.q = t => setSignal(e.X, t);
|
|
719
722
|
}
|
|
720
723
|
pendingValueCheck = false;
|
|
721
724
|
try {
|
|
722
|
-
return read(e.
|
|
725
|
+
return read(e.X);
|
|
723
726
|
} finally {
|
|
724
727
|
pendingValueCheck = true;
|
|
725
728
|
}
|
|
726
729
|
}
|
|
727
730
|
if (e.J & STATUS_PENDING && !pendingCheck) {
|
|
728
|
-
if ((t && !stale) || e.J & STATUS_UNINITIALIZED) throw e.
|
|
731
|
+
if ((t && !stale) || e.J & STATUS_UNINITIALIZED) throw e.W;
|
|
729
732
|
else if (t && stale) {
|
|
730
|
-
setStatusFlags(t, t.J | 1, e.
|
|
733
|
+
setStatusFlags(t, t.J | 1, e.W);
|
|
731
734
|
}
|
|
732
735
|
}
|
|
733
736
|
if (e.J & STATUS_ERROR) {
|
|
@@ -735,29 +738,29 @@ function read(e) {
|
|
|
735
738
|
recompute(e, true);
|
|
736
739
|
return read(e);
|
|
737
740
|
} else {
|
|
738
|
-
throw e.
|
|
741
|
+
throw e.W;
|
|
739
742
|
}
|
|
740
743
|
}
|
|
741
744
|
return !t ||
|
|
742
745
|
e.ue ||
|
|
743
|
-
e.
|
|
744
|
-
(stale && !pendingCheck && e.
|
|
745
|
-
? e.
|
|
746
|
-
: e.
|
|
746
|
+
e.K === NOT_PENDING ||
|
|
747
|
+
(stale && !pendingCheck && e.j && activeTransition !== e.j)
|
|
748
|
+
? e.M
|
|
749
|
+
: e.K;
|
|
747
750
|
}
|
|
748
751
|
function setSignal(e, t) {
|
|
749
752
|
if (typeof t === "function") {
|
|
750
|
-
t = t(e.
|
|
753
|
+
t = t(e.K === NOT_PENDING ? e.M : e.K);
|
|
751
754
|
}
|
|
752
|
-
const n = !e.oe || !e.oe(e.
|
|
755
|
+
const n = !e.oe || !e.oe(e.K === NOT_PENDING || e.ue ? e.M : e.K, t);
|
|
753
756
|
if (!n && !e.J) return t;
|
|
754
757
|
if (n) {
|
|
755
|
-
if (e.ue) e.
|
|
758
|
+
if (e.ue) e.M = t;
|
|
756
759
|
else {
|
|
757
|
-
if (e.
|
|
758
|
-
e.
|
|
760
|
+
if (e.K === NOT_PENDING) globalQueue.$.push(e);
|
|
761
|
+
e.K = t;
|
|
759
762
|
}
|
|
760
|
-
if (e.
|
|
763
|
+
if (e.X) e.X.K = t;
|
|
761
764
|
}
|
|
762
765
|
setStatusFlags(e, STATUS_NONE);
|
|
763
766
|
e.se = clock;
|
|
@@ -846,10 +849,10 @@ function pending(e) {
|
|
|
846
849
|
}
|
|
847
850
|
function isPending(e) {
|
|
848
851
|
const t = pendingCheck;
|
|
849
|
-
pendingCheck = {
|
|
852
|
+
pendingCheck = { M: false };
|
|
850
853
|
try {
|
|
851
854
|
staleValues(e);
|
|
852
|
-
return pendingCheck.
|
|
855
|
+
return pendingCheck.M;
|
|
853
856
|
} catch (e) {
|
|
854
857
|
if (!(e instanceof NotReadyError)) return false;
|
|
855
858
|
throw e;
|
|
@@ -903,22 +906,22 @@ function effect(e, t, n, i, r) {
|
|
|
903
906
|
const o = computed(e, i, {
|
|
904
907
|
...r,
|
|
905
908
|
Oe: {
|
|
906
|
-
|
|
909
|
+
B: true,
|
|
907
910
|
pe: i,
|
|
908
911
|
Ae: t,
|
|
909
912
|
Ne: n,
|
|
910
913
|
Ie: undefined,
|
|
911
|
-
|
|
914
|
+
Y: r?.render ? EFFECT_RENDER : EFFECT_USER,
|
|
912
915
|
le(e, t) {
|
|
913
916
|
if (s) {
|
|
914
917
|
const n = this.J && this.J === t && e;
|
|
915
|
-
this.
|
|
916
|
-
if (this.
|
|
918
|
+
this.B = !(this.J & STATUS_ERROR) && !(this.J & STATUS_PENDING & ~t) && !n;
|
|
919
|
+
if (this.B) this._e.enqueue(this.Y, runEffect.bind(this));
|
|
917
920
|
}
|
|
918
921
|
if (this.J & STATUS_ERROR) {
|
|
919
|
-
let e = this.
|
|
922
|
+
let e = this.W;
|
|
920
923
|
this._e.notify(this, STATUS_PENDING, 0);
|
|
921
|
-
if (this.
|
|
924
|
+
if (this.Y === EFFECT_USER) {
|
|
922
925
|
try {
|
|
923
926
|
return this.Ne
|
|
924
927
|
? this.Ne(e, () => {
|
|
@@ -931,30 +934,30 @@ function effect(e, t, n, i, r) {
|
|
|
931
934
|
}
|
|
932
935
|
}
|
|
933
936
|
if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
934
|
-
} else if (this.
|
|
937
|
+
} else if (this.Y === EFFECT_RENDER) {
|
|
935
938
|
this._e.notify(this, STATUS_PENDING | STATUS_ERROR, this.J);
|
|
936
939
|
}
|
|
937
940
|
}
|
|
938
941
|
}
|
|
939
942
|
});
|
|
940
943
|
s = true;
|
|
941
|
-
if (o.
|
|
944
|
+
if (o.Y === EFFECT_RENDER) o.m = t => staleValues(() => e(t));
|
|
942
945
|
!r?.defer &&
|
|
943
946
|
!(o.J & (STATUS_ERROR | STATUS_PENDING)) &&
|
|
944
|
-
(o.
|
|
947
|
+
(o.Y === EFFECT_USER ? o._e.enqueue(o.Y, runEffect.bind(o)) : runEffect.call(o));
|
|
945
948
|
onCleanup(() => o.Ie?.());
|
|
946
949
|
}
|
|
947
950
|
function runEffect() {
|
|
948
|
-
if (!this.
|
|
951
|
+
if (!this.B || this._ & REACTIVE_DISPOSED) return;
|
|
949
952
|
this.Ie?.();
|
|
950
953
|
this.Ie = undefined;
|
|
951
954
|
try {
|
|
952
|
-
this.Ie = this.Ae(this.
|
|
955
|
+
this.Ie = this.Ae(this.M, this.pe);
|
|
953
956
|
} catch (e) {
|
|
954
957
|
if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
955
958
|
} finally {
|
|
956
|
-
this.pe = this.
|
|
957
|
-
this.
|
|
959
|
+
this.pe = this.M;
|
|
960
|
+
this.B = false;
|
|
958
961
|
}
|
|
959
962
|
}
|
|
960
963
|
function createSignal(e, t, n) {
|
|
@@ -1279,7 +1282,7 @@ const storeTraps = {
|
|
|
1279
1282
|
if (e && e.get) return e.get.call(n);
|
|
1280
1283
|
}
|
|
1281
1284
|
if (Writing?.has(n)) {
|
|
1282
|
-
let n = r && (s || !o) ? (r.
|
|
1285
|
+
let n = r && (s || !o) ? (r.K !== NOT_PENDING ? r.K : r.M) : u[t];
|
|
1283
1286
|
n === $DELETED && (n = undefined);
|
|
1284
1287
|
if (!isWrappable(n)) return n;
|
|
1285
1288
|
const i = wrap(n, e);
|
|
@@ -1976,7 +1979,7 @@ function collectErrorSources(e, t) {
|
|
|
1976
1979
|
function createErrorBoundary(e, t) {
|
|
1977
1980
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
1978
1981
|
let n = e.be.values().next().value;
|
|
1979
|
-
return t(n.
|
|
1982
|
+
return t(n.W, () => {
|
|
1980
1983
|
const t = [];
|
|
1981
1984
|
for (const n of e.be) collectErrorSources(n, t);
|
|
1982
1985
|
for (const e of t) recompute(e);
|