@solidjs/signals 0.8.0 → 0.8.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 +49 -15
- package/dist/node.cjs +436 -402
- package/dist/prod.js +436 -402
- package/dist/types/boundaries.d.ts +1 -0
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +11 -2
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -205,6 +205,30 @@ var Queue = class {
|
|
|
205
205
|
this._queues[type - 1].push(fn);
|
|
206
206
|
schedule();
|
|
207
207
|
}
|
|
208
|
+
stashQueues(stub) {
|
|
209
|
+
stub._queues[0].push(...this._queues[0]);
|
|
210
|
+
stub._queues[1].push(...this._queues[1]);
|
|
211
|
+
this._queues = [[], []];
|
|
212
|
+
for (let i = 0; i < this._children.length; i++) {
|
|
213
|
+
let child = this._children[i];
|
|
214
|
+
let childStub = stub._children[i];
|
|
215
|
+
if (!childStub) {
|
|
216
|
+
childStub = { _queues: [[], []], _children: [] };
|
|
217
|
+
stub._children[i] = childStub;
|
|
218
|
+
}
|
|
219
|
+
child.stashQueues(childStub);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
restoreQueues(stub) {
|
|
223
|
+
this._queues[0].push(...stub._queues[0]);
|
|
224
|
+
this._queues[1].push(...stub._queues[1]);
|
|
225
|
+
for (let i = 0; i < stub._children.length; i++) {
|
|
226
|
+
const childStub = stub._children[i];
|
|
227
|
+
let child = this._children[i];
|
|
228
|
+
if (child)
|
|
229
|
+
child.restoreQueues(childStub);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
208
232
|
};
|
|
209
233
|
var GlobalQueue = class _GlobalQueue extends Queue {
|
|
210
234
|
_running = false;
|
|
@@ -221,9 +245,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
221
245
|
if (!transitionComplete(activeTransition)) {
|
|
222
246
|
runHeap(zombieQueue, _GlobalQueue._update);
|
|
223
247
|
globalQueue._pendingNodes = [];
|
|
224
|
-
|
|
225
|
-
activeTransition.queues[1].push(...globalQueue._queues[1]);
|
|
226
|
-
globalQueue._queues = [[], []];
|
|
248
|
+
globalQueue.stashQueues(activeTransition.queueStash);
|
|
227
249
|
clock++;
|
|
228
250
|
scheduled = false;
|
|
229
251
|
runPending(activeTransition.pendingNodes, true);
|
|
@@ -231,8 +253,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
231
253
|
return;
|
|
232
254
|
}
|
|
233
255
|
globalQueue._pendingNodes.push(...activeTransition.pendingNodes);
|
|
234
|
-
globalQueue.
|
|
235
|
-
globalQueue._queues[1].push(...activeTransition.queues[1]);
|
|
256
|
+
globalQueue.restoreQueues(activeTransition.queueStash);
|
|
236
257
|
transitions.delete(activeTransition);
|
|
237
258
|
activeTransition = null;
|
|
238
259
|
if (runPending(globalQueue._pendingNodes, false))
|
|
@@ -276,7 +297,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
276
297
|
time: clock,
|
|
277
298
|
pendingNodes: [],
|
|
278
299
|
asyncNodes: [],
|
|
279
|
-
|
|
300
|
+
queueStash: { _queues: [[], []], _children: [] }
|
|
280
301
|
};
|
|
281
302
|
}
|
|
282
303
|
transitions.add(activeTransition);
|
|
@@ -343,6 +364,14 @@ var pendingValueCheck = false;
|
|
|
343
364
|
var pendingCheck = null;
|
|
344
365
|
var context = null;
|
|
345
366
|
var defaultContext = {};
|
|
367
|
+
function notifySubs(node) {
|
|
368
|
+
for (let s = node._subs; s !== null; s = s._nextSub) {
|
|
369
|
+
const queue = s._sub._flags & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
370
|
+
if (queue._min > s._sub._height)
|
|
371
|
+
queue._min = s._sub._height;
|
|
372
|
+
insertIntoHeap(s._sub, queue);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
346
375
|
function recompute(el, create = false) {
|
|
347
376
|
deleteFromHeap(el, el._flags & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
348
377
|
if (el._pendingValue !== NOT_PENDING || el._pendingFirstChild || el._pendingDisposal)
|
|
@@ -513,7 +542,7 @@ function setStatusFlags(signal2, flags, error = null) {
|
|
|
513
542
|
signal2._error = error;
|
|
514
543
|
}
|
|
515
544
|
function setError(signal2, error) {
|
|
516
|
-
setStatusFlags(signal2, 2 /* Error
|
|
545
|
+
setStatusFlags(signal2, 2 /* Error */, error);
|
|
517
546
|
}
|
|
518
547
|
function clearStatusFlags(signal2) {
|
|
519
548
|
setStatusFlags(signal2, 0 /* None */);
|
|
@@ -664,6 +693,9 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
664
693
|
return;
|
|
665
694
|
globalQueue.initTransition(self);
|
|
666
695
|
setError(self, e);
|
|
696
|
+
self._time = clock;
|
|
697
|
+
notifySubs(self);
|
|
698
|
+
schedule();
|
|
667
699
|
flush();
|
|
668
700
|
});
|
|
669
701
|
} else {
|
|
@@ -681,6 +713,9 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
681
713
|
return;
|
|
682
714
|
globalQueue.initTransition(self);
|
|
683
715
|
setError(self, error);
|
|
716
|
+
self._time = clock;
|
|
717
|
+
notifySubs(self);
|
|
718
|
+
schedule();
|
|
684
719
|
flush();
|
|
685
720
|
}
|
|
686
721
|
})();
|
|
@@ -831,9 +866,7 @@ function setSignal(el, v) {
|
|
|
831
866
|
}
|
|
832
867
|
clearStatusFlags(el);
|
|
833
868
|
el._time = clock;
|
|
834
|
-
|
|
835
|
-
insertIntoHeap(link2._sub, link2._sub._flags & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
836
|
-
}
|
|
869
|
+
notifySubs(el);
|
|
837
870
|
schedule();
|
|
838
871
|
return v;
|
|
839
872
|
}
|
|
@@ -1010,9 +1043,8 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
1010
1043
|
}
|
|
1011
1044
|
});
|
|
1012
1045
|
initialized = true;
|
|
1013
|
-
if (node._type === 1 /* Render */)
|
|
1014
|
-
node._fn = (p) =>
|
|
1015
|
-
}
|
|
1046
|
+
if (node._type === 1 /* Render */)
|
|
1047
|
+
node._fn = (p) => staleValues(() => compute(p));
|
|
1016
1048
|
!options?.defer && !(node._statusFlags & (2 /* Error */ | 1 /* Pending */)) && (node._type === 2 /* User */ ? node._queue.enqueue(node._type, runEffect.bind(node)) : runEffect.call(node));
|
|
1017
1049
|
onCleanup(() => node._cleanup?.());
|
|
1018
1050
|
if (!node._parent)
|
|
@@ -2032,6 +2064,7 @@ var CollectionQueue = class extends Queue {
|
|
|
2032
2064
|
_collectionType;
|
|
2033
2065
|
_nodes = /* @__PURE__ */ new Set();
|
|
2034
2066
|
_disabled = signal(false, { pureWrite: true });
|
|
2067
|
+
_initialized = false;
|
|
2035
2068
|
constructor(type) {
|
|
2036
2069
|
super();
|
|
2037
2070
|
this._collectionType = type;
|
|
@@ -2042,7 +2075,7 @@ var CollectionQueue = class extends Queue {
|
|
|
2042
2075
|
return super.run(type);
|
|
2043
2076
|
}
|
|
2044
2077
|
notify(node, type, flags) {
|
|
2045
|
-
if (!(type & this._collectionType))
|
|
2078
|
+
if (!(type & this._collectionType) || this._collectionType & 1 /* Pending */ && this._initialized)
|
|
2046
2079
|
return super.notify(node, type, flags);
|
|
2047
2080
|
if (flags & this._collectionType) {
|
|
2048
2081
|
this._nodes.add(node);
|
|
@@ -2083,7 +2116,8 @@ function createCollectionBoundary(type, fn, fallback) {
|
|
|
2083
2116
|
if (!read(queue._disabled)) {
|
|
2084
2117
|
const resolved = read(tree);
|
|
2085
2118
|
if (!untrack(() => read(queue._disabled)))
|
|
2086
|
-
|
|
2119
|
+
queue._initialized = true;
|
|
2120
|
+
return resolved;
|
|
2087
2121
|
}
|
|
2088
2122
|
return fallback(queue);
|
|
2089
2123
|
});
|