@solidjs/signals 0.4.7 → 0.4.9
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 +68 -33
- package/dist/node.cjs +463 -428
- package/dist/prod.js +463 -428
- 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) {
|
|
@@ -378,25 +398,51 @@ function mergeTransitions(t1, t2) {
|
|
|
378
398
|
t1.merge(t2);
|
|
379
399
|
t2._done = t1;
|
|
380
400
|
}
|
|
401
|
+
function getTransitionSource(input) {
|
|
402
|
+
return ActiveTransition && ActiveTransition._sources.get(input) || input;
|
|
403
|
+
}
|
|
404
|
+
function initialDispose(node) {
|
|
405
|
+
let current = node._nextSibling;
|
|
406
|
+
while (current !== null && current._parent === node) {
|
|
407
|
+
initialDispose(current);
|
|
408
|
+
const clone = ActiveTransition._sources.get(current);
|
|
409
|
+
if (clone && !clone._updated)
|
|
410
|
+
clone.dispose(true);
|
|
411
|
+
current = current._nextSibling;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
381
414
|
function finishTransition(transition2) {
|
|
382
415
|
if (transition2._done || transition2._scheduled || transition2._promises.size || transition2._pendingNodes.size)
|
|
383
416
|
return;
|
|
417
|
+
globalQueue._queues[0].push.apply(globalQueue._queues[0], transition2._queues[0]);
|
|
418
|
+
globalQueue._queues[1].push.apply(globalQueue._queues[1], transition2._queues[1]);
|
|
419
|
+
resolveQueues(transition2._children);
|
|
384
420
|
for (const [source, clone] of transition2._sources) {
|
|
385
|
-
if (source === clone || source._transition !== transition2)
|
|
421
|
+
if (source === clone || source._transition !== transition2) {
|
|
422
|
+
delete source._transition;
|
|
386
423
|
continue;
|
|
424
|
+
}
|
|
387
425
|
if (clone._sources)
|
|
388
426
|
replaceSourceObservers(clone, transition2);
|
|
389
|
-
if (
|
|
390
|
-
source.dispose(
|
|
427
|
+
if (clone._updated || clone._state === STATE_DISPOSED) {
|
|
428
|
+
source.dispose(clone._state === STATE_DISPOSED);
|
|
391
429
|
source.emptyDisposal();
|
|
392
|
-
|
|
393
|
-
|
|
430
|
+
delete clone._updated;
|
|
431
|
+
} else {
|
|
432
|
+
delete clone._nextSibling;
|
|
433
|
+
delete clone._disposal;
|
|
434
|
+
}
|
|
435
|
+
Object.assign(source, clone);
|
|
436
|
+
delete source._cloned;
|
|
437
|
+
let current = clone._nextSibling;
|
|
438
|
+
if (current?._prevSibling === clone)
|
|
439
|
+
current._prevSibling = source;
|
|
440
|
+
while (current?._parent === clone) {
|
|
441
|
+
current._parent = source;
|
|
442
|
+
current = current._nextSibling;
|
|
394
443
|
}
|
|
395
444
|
delete source._transition;
|
|
396
445
|
}
|
|
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
446
|
transition2._done = true;
|
|
401
447
|
for (const reset of transition2._optimistic) {
|
|
402
448
|
delete reset._transition;
|
|
@@ -456,7 +502,6 @@ var Owner = class {
|
|
|
456
502
|
let head = self ? this._prevSibling || this._parent : this, current = this._nextSibling, next = null;
|
|
457
503
|
while (current && current._parent === this) {
|
|
458
504
|
current.dispose(true);
|
|
459
|
-
current._disposeNode();
|
|
460
505
|
next = current._nextSibling;
|
|
461
506
|
current._nextSibling = null;
|
|
462
507
|
current = next;
|
|
@@ -609,7 +654,7 @@ var Computation = class extends Owner {
|
|
|
609
654
|
* Automatically re-executes the surrounding computation when the value changes
|
|
610
655
|
*/
|
|
611
656
|
read() {
|
|
612
|
-
if (ActiveTransition && (ActiveTransition._sources.has(this) || !this._cloned && this._stateFlags & UNINITIALIZED_BIT)) {
|
|
657
|
+
if (ActiveTransition && (ActiveTransition._sources.has(this) || !this._cloned && this._stateFlags & UNINITIALIZED_BIT | ERROR_BIT)) {
|
|
613
658
|
const clone = ActiveTransition._sources.get(this) || cloneGraph(this);
|
|
614
659
|
if (clone !== this)
|
|
615
660
|
return clone.read();
|
|
@@ -751,7 +796,7 @@ var Computation = class extends Owner {
|
|
|
751
796
|
let observerFlags = 0;
|
|
752
797
|
if (this._state === STATE_CHECK) {
|
|
753
798
|
for (let i = 0; i < this._sources.length; i++) {
|
|
754
|
-
const source =
|
|
799
|
+
const source = getTransitionSource(this._sources[i]);
|
|
755
800
|
source._updateIfNecessary();
|
|
756
801
|
observerFlags |= source._stateFlags & ~UNINITIALIZED_BIT;
|
|
757
802
|
if (this._state === STATE_DIRTY) {
|
|
@@ -799,6 +844,10 @@ function update(node) {
|
|
|
799
844
|
newSourcesIndex = 0;
|
|
800
845
|
newFlags = 0;
|
|
801
846
|
try {
|
|
847
|
+
if (ActiveTransition && node._cloned && !node._updated) {
|
|
848
|
+
initialDispose(node._cloned);
|
|
849
|
+
node._updated = true;
|
|
850
|
+
}
|
|
802
851
|
node.dispose(false);
|
|
803
852
|
node.emptyDisposal();
|
|
804
853
|
const result = compute(node, node._compute, node);
|
|
@@ -823,7 +872,7 @@ function update(node) {
|
|
|
823
872
|
}
|
|
824
873
|
let source;
|
|
825
874
|
for (let i = newSourcesIndex; i < node._sources.length; i++) {
|
|
826
|
-
source =
|
|
875
|
+
source = getTransitionSource(node._sources[i]);
|
|
827
876
|
if (!source._observers)
|
|
828
877
|
source._observers = [node];
|
|
829
878
|
else
|
|
@@ -840,21 +889,6 @@ function update(node) {
|
|
|
840
889
|
node._state = STATE_CLEAN;
|
|
841
890
|
}
|
|
842
891
|
}
|
|
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
892
|
function isEqual(a, b) {
|
|
859
893
|
return a === b;
|
|
860
894
|
}
|
|
@@ -1110,6 +1144,8 @@ var FirewallComputation = class extends Computation {
|
|
|
1110
1144
|
function runTop(node) {
|
|
1111
1145
|
const ancestors = [];
|
|
1112
1146
|
for (let current = node; current !== null; current = current._parent) {
|
|
1147
|
+
if (ActiveTransition && current._transition)
|
|
1148
|
+
current = ActiveTransition._sources.get(current);
|
|
1113
1149
|
if (current._state !== STATE_CLEAN) {
|
|
1114
1150
|
ancestors.push(current);
|
|
1115
1151
|
}
|
|
@@ -2252,7 +2288,7 @@ var CollectionQueue = class extends Queue {
|
|
|
2252
2288
|
this._nodes.add(node);
|
|
2253
2289
|
if (this._nodes.size === 1)
|
|
2254
2290
|
this._disabled.write(true);
|
|
2255
|
-
} else {
|
|
2291
|
+
} else if (this._nodes.size > 0) {
|
|
2256
2292
|
this._nodes.delete(node);
|
|
2257
2293
|
if (this._nodes.size === 0)
|
|
2258
2294
|
this._disabled.write(false);
|
|
@@ -2302,8 +2338,7 @@ function createSuspense(fn, fallback) {
|
|
|
2302
2338
|
}
|
|
2303
2339
|
function createErrorBoundary(fn, fallback) {
|
|
2304
2340
|
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));
|
|
2341
|
+
let node = getTransitionSource(queue._nodes.values().next().value);
|
|
2307
2342
|
return fallback(node._error, () => {
|
|
2308
2343
|
incrementClock();
|
|
2309
2344
|
for (let node2 of queue._nodes) {
|