@solidjs/signals 0.4.8 → 0.4.10
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 +74 -40
- package/dist/node.cjs +466 -432
- package/dist/prod.js +466 -432
- package/dist/types/core/scheduler.d.ts +8 -3
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -101,13 +101,19 @@ var Queue = class {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
addChild(child) {
|
|
104
|
+
if (ActiveTransition && ActiveTransition._clonedQueues.has(this))
|
|
105
|
+
return ActiveTransition._clonedQueues.get(this).addChild(child);
|
|
104
106
|
this._children.push(child);
|
|
105
107
|
child._parent = this;
|
|
106
108
|
}
|
|
107
109
|
removeChild(child) {
|
|
110
|
+
if (ActiveTransition && ActiveTransition._clonedQueues.has(this))
|
|
111
|
+
return ActiveTransition._clonedQueues.get(this).removeChild(child);
|
|
108
112
|
const index = this._children.indexOf(child);
|
|
109
|
-
if (index >= 0)
|
|
113
|
+
if (index >= 0) {
|
|
110
114
|
this._children.splice(index, 1);
|
|
115
|
+
child._parent = null;
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
118
|
notify(...args) {
|
|
113
119
|
if (ActiveTransition && ActiveTransition._clonedQueues.has(this))
|
|
@@ -137,6 +143,21 @@ function flush() {
|
|
|
137
143
|
globalQueue.flush();
|
|
138
144
|
}
|
|
139
145
|
}
|
|
146
|
+
function removeSourceObservers(node, index) {
|
|
147
|
+
let source;
|
|
148
|
+
let swap;
|
|
149
|
+
for (let i = index; i < node._sources.length; i++) {
|
|
150
|
+
source = getTransitionSource(node._sources[i]);
|
|
151
|
+
if (source._observers) {
|
|
152
|
+
if ((swap = source._observers.indexOf(node)) !== -1) {
|
|
153
|
+
source._observers[swap] = source._observers[source._observers.length - 1];
|
|
154
|
+
source._observers.pop();
|
|
155
|
+
}
|
|
156
|
+
if (!source._observers.length)
|
|
157
|
+
Unobserved.push(source);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
140
161
|
function runQueue(queue, type) {
|
|
141
162
|
for (let i = 0; i < queue.length; i++)
|
|
142
163
|
queue[i](type);
|
|
@@ -154,6 +175,7 @@ var Transition = class _Transition {
|
|
|
154
175
|
_parent = null;
|
|
155
176
|
_running = false;
|
|
156
177
|
_scheduled = false;
|
|
178
|
+
_cloned = globalQueue;
|
|
157
179
|
created = clock;
|
|
158
180
|
constructor() {
|
|
159
181
|
this._clonedQueues.set(globalQueue, this);
|
|
@@ -292,8 +314,6 @@ function cloneGraph(node) {
|
|
|
292
314
|
_sources: node._sources ? [...node._sources] : null,
|
|
293
315
|
_cloned: node
|
|
294
316
|
});
|
|
295
|
-
if (clone._compute)
|
|
296
|
-
clone._stateFlags |= UNINITIALIZED_BIT;
|
|
297
317
|
ActiveTransition._sources.set(node, clone);
|
|
298
318
|
node._transition = ActiveTransition;
|
|
299
319
|
if (node._sources) {
|
|
@@ -310,14 +330,13 @@ function cloneGraph(node) {
|
|
|
310
330
|
}
|
|
311
331
|
function replaceSourceObservers(node, transition2) {
|
|
312
332
|
let source;
|
|
313
|
-
let transitionSource;
|
|
314
333
|
let swap;
|
|
315
334
|
for (let i = 0; i < node._sources.length; i++) {
|
|
316
|
-
|
|
317
|
-
source = transitionSource || node._sources[i];
|
|
335
|
+
source = transition2._sources.get(node._sources[i]) || node._sources[i];
|
|
318
336
|
if (source._observers && (swap = source._observers.indexOf(node)) !== -1) {
|
|
319
|
-
|
|
320
|
-
!
|
|
337
|
+
const remove = source._observers.indexOf(node._cloned) > -1;
|
|
338
|
+
source._observers[swap] = !remove ? node._cloned : source._observers[source._observers.length - 1];
|
|
339
|
+
remove && source._observers.pop();
|
|
321
340
|
}
|
|
322
341
|
}
|
|
323
342
|
}
|
|
@@ -378,25 +397,51 @@ function mergeTransitions(t1, t2) {
|
|
|
378
397
|
t1.merge(t2);
|
|
379
398
|
t2._done = t1;
|
|
380
399
|
}
|
|
400
|
+
function getTransitionSource(input) {
|
|
401
|
+
return ActiveTransition && ActiveTransition._sources.get(input) || input;
|
|
402
|
+
}
|
|
403
|
+
function initialDispose(node) {
|
|
404
|
+
let current = node._nextSibling;
|
|
405
|
+
while (current !== null && current._parent === node) {
|
|
406
|
+
initialDispose(current);
|
|
407
|
+
const clone = ActiveTransition._sources.get(current);
|
|
408
|
+
if (clone && !clone._updated)
|
|
409
|
+
clone.dispose(true);
|
|
410
|
+
current = current._nextSibling;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
381
413
|
function finishTransition(transition2) {
|
|
382
414
|
if (transition2._done || transition2._scheduled || transition2._promises.size || transition2._pendingNodes.size)
|
|
383
415
|
return;
|
|
416
|
+
globalQueue._queues[0].push.apply(globalQueue._queues[0], transition2._queues[0]);
|
|
417
|
+
globalQueue._queues[1].push.apply(globalQueue._queues[1], transition2._queues[1]);
|
|
418
|
+
resolveQueues(transition2._children);
|
|
384
419
|
for (const [source, clone] of transition2._sources) {
|
|
385
|
-
if (source === clone || source._transition !== transition2)
|
|
420
|
+
if (source === clone || source._transition !== transition2) {
|
|
421
|
+
delete source._transition;
|
|
386
422
|
continue;
|
|
423
|
+
}
|
|
387
424
|
if (clone._sources)
|
|
388
425
|
replaceSourceObservers(clone, transition2);
|
|
389
|
-
if (
|
|
390
|
-
source.dispose(
|
|
426
|
+
if (clone._updated || clone._state === STATE_DISPOSED) {
|
|
427
|
+
source.dispose(clone._state === STATE_DISPOSED);
|
|
391
428
|
source.emptyDisposal();
|
|
392
|
-
|
|
393
|
-
|
|
429
|
+
delete clone._updated;
|
|
430
|
+
} else {
|
|
431
|
+
delete clone._nextSibling;
|
|
432
|
+
delete clone._disposal;
|
|
433
|
+
}
|
|
434
|
+
Object.assign(source, clone);
|
|
435
|
+
delete source._cloned;
|
|
436
|
+
let current = clone._nextSibling;
|
|
437
|
+
if (current?._prevSibling === clone)
|
|
438
|
+
current._prevSibling = source;
|
|
439
|
+
while (current?._parent === clone) {
|
|
440
|
+
current._parent = source;
|
|
441
|
+
current = current._nextSibling;
|
|
394
442
|
}
|
|
395
443
|
delete source._transition;
|
|
396
444
|
}
|
|
397
|
-
globalQueue._queues[0].push.apply(globalQueue._queues[0], transition2._queues[0]);
|
|
398
|
-
globalQueue._queues[1].push.apply(globalQueue._queues[1], transition2._queues[1]);
|
|
399
|
-
resolveQueues(transition2._children);
|
|
400
445
|
transition2._done = true;
|
|
401
446
|
for (const reset of transition2._optimistic) {
|
|
402
447
|
delete reset._transition;
|
|
@@ -456,7 +501,6 @@ var Owner = class {
|
|
|
456
501
|
let head = self ? this._prevSibling || this._parent : this, current = this._nextSibling, next = null;
|
|
457
502
|
while (current && current._parent === this) {
|
|
458
503
|
current.dispose(true);
|
|
459
|
-
current._disposeNode();
|
|
460
504
|
next = current._nextSibling;
|
|
461
505
|
current._nextSibling = null;
|
|
462
506
|
current = next;
|
|
@@ -609,7 +653,7 @@ var Computation = class extends Owner {
|
|
|
609
653
|
* Automatically re-executes the surrounding computation when the value changes
|
|
610
654
|
*/
|
|
611
655
|
read() {
|
|
612
|
-
if (ActiveTransition && (ActiveTransition._sources.has(this) || !this._cloned && this._stateFlags & UNINITIALIZED_BIT)) {
|
|
656
|
+
if (ActiveTransition && (ActiveTransition._sources.has(this) || !this._cloned && this._stateFlags & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
613
657
|
const clone = ActiveTransition._sources.get(this) || cloneGraph(this);
|
|
614
658
|
if (clone !== this)
|
|
615
659
|
return clone.read();
|
|
@@ -630,7 +674,7 @@ var Computation = class extends Owner {
|
|
|
630
674
|
* before continuing
|
|
631
675
|
*/
|
|
632
676
|
wait() {
|
|
633
|
-
if (ActiveTransition && (ActiveTransition._sources.has(this) || !this._cloned && this._stateFlags & UNINITIALIZED_BIT)) {
|
|
677
|
+
if (ActiveTransition && (ActiveTransition._sources.has(this) || !this._cloned && this._stateFlags & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
634
678
|
const clone = ActiveTransition._sources.get(this) || cloneGraph(this);
|
|
635
679
|
if (clone !== this)
|
|
636
680
|
return clone.wait();
|
|
@@ -751,7 +795,7 @@ var Computation = class extends Owner {
|
|
|
751
795
|
let observerFlags = 0;
|
|
752
796
|
if (this._state === STATE_CHECK) {
|
|
753
797
|
for (let i = 0; i < this._sources.length; i++) {
|
|
754
|
-
const source =
|
|
798
|
+
const source = getTransitionSource(this._sources[i]);
|
|
755
799
|
source._updateIfNecessary();
|
|
756
800
|
observerFlags |= source._stateFlags & ~UNINITIALIZED_BIT;
|
|
757
801
|
if (this._state === STATE_DIRTY) {
|
|
@@ -799,6 +843,10 @@ function update(node) {
|
|
|
799
843
|
newSourcesIndex = 0;
|
|
800
844
|
newFlags = 0;
|
|
801
845
|
try {
|
|
846
|
+
if (ActiveTransition && node._cloned && !node._updated) {
|
|
847
|
+
initialDispose(node._cloned);
|
|
848
|
+
node._updated = true;
|
|
849
|
+
}
|
|
802
850
|
node.dispose(false);
|
|
803
851
|
node.emptyDisposal();
|
|
804
852
|
const result = compute(node, node._compute, node);
|
|
@@ -823,7 +871,7 @@ function update(node) {
|
|
|
823
871
|
}
|
|
824
872
|
let source;
|
|
825
873
|
for (let i = newSourcesIndex; i < node._sources.length; i++) {
|
|
826
|
-
source =
|
|
874
|
+
source = getTransitionSource(node._sources[i]);
|
|
827
875
|
if (!source._observers)
|
|
828
876
|
source._observers = [node];
|
|
829
877
|
else
|
|
@@ -840,21 +888,6 @@ function update(node) {
|
|
|
840
888
|
node._state = STATE_CLEAN;
|
|
841
889
|
}
|
|
842
890
|
}
|
|
843
|
-
function removeSourceObservers(node, index) {
|
|
844
|
-
let source;
|
|
845
|
-
let swap;
|
|
846
|
-
for (let i = index; i < node._sources.length; i++) {
|
|
847
|
-
source = ActiveTransition && ActiveTransition._sources.get(node._sources[i]) || node._sources[i];
|
|
848
|
-
if (source._observers) {
|
|
849
|
-
if ((swap = source._observers.indexOf(node)) !== -1) {
|
|
850
|
-
source._observers[swap] = source._observers[source._observers.length - 1];
|
|
851
|
-
source._observers.pop();
|
|
852
|
-
}
|
|
853
|
-
if (!source._observers.length)
|
|
854
|
-
Unobserved.push(source);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
891
|
function isEqual(a, b) {
|
|
859
892
|
return a === b;
|
|
860
893
|
}
|
|
@@ -1110,6 +1143,8 @@ var FirewallComputation = class extends Computation {
|
|
|
1110
1143
|
function runTop(node) {
|
|
1111
1144
|
const ancestors = [];
|
|
1112
1145
|
for (let current = node; current !== null; current = current._parent) {
|
|
1146
|
+
if (ActiveTransition && current._transition)
|
|
1147
|
+
current = ActiveTransition._sources.get(current);
|
|
1113
1148
|
if (current._state !== STATE_CLEAN) {
|
|
1114
1149
|
ancestors.push(current);
|
|
1115
1150
|
}
|
|
@@ -2170,7 +2205,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2170
2205
|
}
|
|
2171
2206
|
write(value, flags) {
|
|
2172
2207
|
super.write(value, flags & ~this._propagationMask);
|
|
2173
|
-
if (this._propagationMask & LOADING_BIT && !(this._stateFlags & UNINITIALIZED_BIT)) {
|
|
2208
|
+
if (this._propagationMask & LOADING_BIT && !(this._stateFlags & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2174
2209
|
flags &= ~LOADING_BIT;
|
|
2175
2210
|
}
|
|
2176
2211
|
this._queue.notify(this, this._propagationMask, flags);
|
|
@@ -2252,7 +2287,7 @@ var CollectionQueue = class extends Queue {
|
|
|
2252
2287
|
this._nodes.add(node);
|
|
2253
2288
|
if (this._nodes.size === 1)
|
|
2254
2289
|
this._disabled.write(true);
|
|
2255
|
-
} else {
|
|
2290
|
+
} else if (this._nodes.size > 0) {
|
|
2256
2291
|
this._nodes.delete(node);
|
|
2257
2292
|
if (this._nodes.size === 0)
|
|
2258
2293
|
this._disabled.write(false);
|
|
@@ -2302,8 +2337,7 @@ function createSuspense(fn, fallback) {
|
|
|
2302
2337
|
}
|
|
2303
2338
|
function createErrorBoundary(fn, fallback) {
|
|
2304
2339
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2305
|
-
let node = queue._nodes.values().next().value;
|
|
2306
|
-
ActiveTransition && ActiveTransition._sources.has(node) && (node = ActiveTransition._sources.get(node));
|
|
2340
|
+
let node = getTransitionSource(queue._nodes.values().next().value);
|
|
2307
2341
|
return fallback(node._error, () => {
|
|
2308
2342
|
incrementClock();
|
|
2309
2343
|
for (let node2 of queue._nodes) {
|