@solidjs/signals 0.4.11 → 0.6.0
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 +231 -190
- package/dist/node.cjs +386 -345
- package/dist/prod.js +384 -343
- package/dist/types/core/scheduler.d.ts +1 -1
- package/dist/types/signals.d.ts +22 -15
- package/dist/types/store/projection.d.ts +2 -2
- package/dist/types/store/store.d.ts +8 -4
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -47,7 +47,7 @@ function schedule() {
|
|
|
47
47
|
if (scheduled)
|
|
48
48
|
return;
|
|
49
49
|
scheduled = true;
|
|
50
|
-
if (!globalQueue.
|
|
50
|
+
if (!globalQueue.B)
|
|
51
51
|
queueMicrotask(flush);
|
|
52
52
|
}
|
|
53
53
|
function notifyUnobserved() {
|
|
@@ -62,7 +62,7 @@ function notifyUnobserved() {
|
|
|
62
62
|
var pureQueue = [];
|
|
63
63
|
var Queue = class {
|
|
64
64
|
k = null;
|
|
65
|
-
|
|
65
|
+
B = false;
|
|
66
66
|
g = [[], []];
|
|
67
67
|
f = [];
|
|
68
68
|
created = clock;
|
|
@@ -89,9 +89,9 @@ var Queue = class {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
flush() {
|
|
92
|
-
if (this.
|
|
92
|
+
if (this.B)
|
|
93
93
|
return;
|
|
94
|
-
this.
|
|
94
|
+
this.B = true;
|
|
95
95
|
try {
|
|
96
96
|
this.run(EFFECT_PURE);
|
|
97
97
|
incrementClock();
|
|
@@ -99,7 +99,7 @@ var Queue = class {
|
|
|
99
99
|
this.run(EFFECT_RENDER);
|
|
100
100
|
this.run(EFFECT_USER);
|
|
101
101
|
} finally {
|
|
102
|
-
this.
|
|
102
|
+
this.B = false;
|
|
103
103
|
Unobserved.length && notifyUnobserved();
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -165,15 +165,15 @@ function runQueue(queue, type) {
|
|
|
165
165
|
var Transition = class _Transition {
|
|
166
166
|
a = /* @__PURE__ */ new Map();
|
|
167
167
|
t = /* @__PURE__ */ new Set();
|
|
168
|
-
|
|
168
|
+
G = /* @__PURE__ */ new Set();
|
|
169
169
|
W = /* @__PURE__ */ new Set();
|
|
170
|
-
|
|
170
|
+
w = false;
|
|
171
171
|
g = [[], []];
|
|
172
172
|
p = /* @__PURE__ */ new Map();
|
|
173
|
-
|
|
173
|
+
H = [];
|
|
174
174
|
f = [];
|
|
175
175
|
k = null;
|
|
176
|
-
|
|
176
|
+
B = false;
|
|
177
177
|
X = false;
|
|
178
178
|
e = globalQueue;
|
|
179
179
|
created = clock;
|
|
@@ -184,15 +184,15 @@ var Transition = class _Transition {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
enqueue(type, fn) {
|
|
187
|
-
this.
|
|
187
|
+
this.H.push(fn);
|
|
188
188
|
if (type)
|
|
189
189
|
this.g[type - 1].push(fn);
|
|
190
190
|
this.schedule();
|
|
191
191
|
}
|
|
192
192
|
run(type) {
|
|
193
193
|
if (type === EFFECT_PURE) {
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
194
|
+
this.H.length && runQueue(this.H, type);
|
|
195
|
+
this.H = [];
|
|
196
196
|
return;
|
|
197
197
|
} else if (this.g[type - 1].length) {
|
|
198
198
|
const effects = this.g[type - 1];
|
|
@@ -204,9 +204,9 @@ var Transition = class _Transition {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
flush() {
|
|
207
|
-
if (this.
|
|
207
|
+
if (this.B)
|
|
208
208
|
return;
|
|
209
|
-
this.
|
|
209
|
+
this.B = true;
|
|
210
210
|
let currentTransition = ActiveTransition;
|
|
211
211
|
ActiveTransition = this;
|
|
212
212
|
try {
|
|
@@ -216,7 +216,7 @@ var Transition = class _Transition {
|
|
|
216
216
|
ActiveTransition = currentTransition;
|
|
217
217
|
finishTransition(this);
|
|
218
218
|
} finally {
|
|
219
|
-
this.
|
|
219
|
+
this.B = false;
|
|
220
220
|
ActiveTransition = currentTransition;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
@@ -242,7 +242,7 @@ var Transition = class _Transition {
|
|
|
242
242
|
merge(queue) {
|
|
243
243
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
244
244
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
245
|
-
this.
|
|
245
|
+
this.H.push.apply(this.H, queue.H);
|
|
246
246
|
for (let i = 0; i < queue.f.length; i++) {
|
|
247
247
|
const og = this.f.find((c) => c.e === queue.f[i].e);
|
|
248
248
|
if (og)
|
|
@@ -255,13 +255,13 @@ var Transition = class _Transition {
|
|
|
255
255
|
if (this.X)
|
|
256
256
|
return;
|
|
257
257
|
this.X = true;
|
|
258
|
-
if (!this.
|
|
258
|
+
if (!this.B)
|
|
259
259
|
queueMicrotask(() => this.flush());
|
|
260
260
|
}
|
|
261
261
|
runTransition(fn, force = false) {
|
|
262
|
-
if (this.
|
|
263
|
-
if (this.
|
|
264
|
-
return this.
|
|
262
|
+
if (this.w) {
|
|
263
|
+
if (this.w instanceof _Transition)
|
|
264
|
+
return this.w.runTransition(fn, force);
|
|
265
265
|
if (!force)
|
|
266
266
|
throw new Error("Transition already completed");
|
|
267
267
|
fn();
|
|
@@ -269,12 +269,34 @@ var Transition = class _Transition {
|
|
|
269
269
|
}
|
|
270
270
|
ActiveTransition = this;
|
|
271
271
|
try {
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
let result = fn();
|
|
273
|
+
let transition2 = ActiveTransition;
|
|
274
|
+
if (result == null ? void 0 : result.next) {
|
|
275
|
+
(async function() {
|
|
276
|
+
let temp, value;
|
|
277
|
+
while (!(temp = result.next(value)).done) {
|
|
278
|
+
if (temp.value instanceof Promise) {
|
|
279
|
+
transition2.G.add(temp.value);
|
|
280
|
+
try {
|
|
281
|
+
value = await temp.value;
|
|
282
|
+
} finally {
|
|
283
|
+
while (transition2.w instanceof _Transition)
|
|
284
|
+
transition2 = transition2.w;
|
|
285
|
+
transition2.G.delete(temp.value);
|
|
286
|
+
}
|
|
287
|
+
ActiveTransition = transition2;
|
|
288
|
+
} else
|
|
289
|
+
value = temp.value;
|
|
290
|
+
}
|
|
291
|
+
finishTransition(transition2);
|
|
292
|
+
})();
|
|
293
|
+
}
|
|
274
294
|
if (result instanceof Promise) {
|
|
275
|
-
transition2.
|
|
295
|
+
transition2.G.add(result);
|
|
276
296
|
result.finally(() => {
|
|
277
|
-
transition2.
|
|
297
|
+
while (transition2.w instanceof _Transition)
|
|
298
|
+
transition2 = transition2.w;
|
|
299
|
+
transition2.G.delete(result);
|
|
278
300
|
finishTransition(transition2);
|
|
279
301
|
});
|
|
280
302
|
}
|
|
@@ -351,7 +373,7 @@ function cloneQueue(queue, parent, clonedQueues) {
|
|
|
351
373
|
},
|
|
352
374
|
notify(node, type, flags) {
|
|
353
375
|
node = node.e || node;
|
|
354
|
-
if (!clone.
|
|
376
|
+
if (!clone.I || type & LOADING_BIT) {
|
|
355
377
|
type &= ~LOADING_BIT;
|
|
356
378
|
ActiveTransition == null ? void 0 : ActiveTransition.notify(node, LOADING_BIT, flags);
|
|
357
379
|
if (!type)
|
|
@@ -392,10 +414,10 @@ function mergeTransitions(t1, t2) {
|
|
|
392
414
|
c.j = t1;
|
|
393
415
|
t1.W.add(c);
|
|
394
416
|
});
|
|
395
|
-
t2.
|
|
417
|
+
t2.G.forEach((p) => t1.G.add(p));
|
|
396
418
|
t2.t.forEach((n) => t1.t.add(n));
|
|
397
419
|
t1.merge(t2);
|
|
398
|
-
t2.
|
|
420
|
+
t2.w = t1;
|
|
399
421
|
}
|
|
400
422
|
function getTransitionSource(input) {
|
|
401
423
|
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
@@ -411,7 +433,7 @@ function initialDispose(node) {
|
|
|
411
433
|
}
|
|
412
434
|
}
|
|
413
435
|
function finishTransition(transition2) {
|
|
414
|
-
if (transition2.
|
|
436
|
+
if (transition2.w || transition2.X || transition2.G.size || transition2.t.size)
|
|
415
437
|
return;
|
|
416
438
|
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
417
439
|
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
@@ -434,15 +456,15 @@ function finishTransition(transition2) {
|
|
|
434
456
|
Object.assign(source, clone);
|
|
435
457
|
delete source.e;
|
|
436
458
|
let current = clone.n;
|
|
437
|
-
if ((current == null ? void 0 : current.
|
|
438
|
-
current.
|
|
459
|
+
if ((current == null ? void 0 : current.x) === clone)
|
|
460
|
+
current.x = source;
|
|
439
461
|
while ((current == null ? void 0 : current.k) === clone) {
|
|
440
462
|
current.k = source;
|
|
441
463
|
current = current.n;
|
|
442
464
|
}
|
|
443
465
|
delete source.j;
|
|
444
466
|
}
|
|
445
|
-
transition2.
|
|
467
|
+
transition2.w = true;
|
|
446
468
|
for (const reset of transition2.W) {
|
|
447
469
|
delete reset.j;
|
|
448
470
|
reset();
|
|
@@ -467,10 +489,10 @@ var Owner = class {
|
|
|
467
489
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
468
490
|
k = null;
|
|
469
491
|
n = null;
|
|
470
|
-
|
|
492
|
+
x = null;
|
|
471
493
|
c = STATE_CLEAN;
|
|
472
494
|
o = null;
|
|
473
|
-
|
|
495
|
+
y = defaultContext;
|
|
474
496
|
m = globalQueue;
|
|
475
497
|
fa = 0;
|
|
476
498
|
id = null;
|
|
@@ -482,15 +504,15 @@ var Owner = class {
|
|
|
482
504
|
}
|
|
483
505
|
append(child) {
|
|
484
506
|
child.k = this;
|
|
485
|
-
child.
|
|
507
|
+
child.x = this;
|
|
486
508
|
if (this.n)
|
|
487
|
-
this.n.
|
|
509
|
+
this.n.x = child;
|
|
488
510
|
child.n = this.n;
|
|
489
511
|
this.n = child;
|
|
490
512
|
if (this.id != null && child.id == null)
|
|
491
513
|
child.id = this.getNextChildId();
|
|
492
|
-
if (child.
|
|
493
|
-
child.
|
|
514
|
+
if (child.y !== this.y) {
|
|
515
|
+
child.y = { ...this.y, ...child.y };
|
|
494
516
|
}
|
|
495
517
|
if (this.m)
|
|
496
518
|
child.m = this.m;
|
|
@@ -498,7 +520,7 @@ var Owner = class {
|
|
|
498
520
|
dispose(self = true) {
|
|
499
521
|
if (this.c === STATE_DISPOSED)
|
|
500
522
|
return;
|
|
501
|
-
let head = self ? this.
|
|
523
|
+
let head = self ? this.x || this.k : this, current = this.n, next = null;
|
|
502
524
|
while (current && current.k === this) {
|
|
503
525
|
current.dispose(true);
|
|
504
526
|
next = current.n;
|
|
@@ -509,16 +531,16 @@ var Owner = class {
|
|
|
509
531
|
if (self)
|
|
510
532
|
this.R();
|
|
511
533
|
if (current)
|
|
512
|
-
current.
|
|
534
|
+
current.x = !self ? this : this.x;
|
|
513
535
|
if (head)
|
|
514
536
|
head.n = current;
|
|
515
537
|
}
|
|
516
538
|
R() {
|
|
517
|
-
if (this.
|
|
518
|
-
this.
|
|
539
|
+
if (this.x)
|
|
540
|
+
this.x.n = null;
|
|
519
541
|
this.k = null;
|
|
520
|
-
this.
|
|
521
|
-
this.
|
|
542
|
+
this.x = null;
|
|
543
|
+
this.y = defaultContext;
|
|
522
544
|
this.c = STATE_DISPOSED;
|
|
523
545
|
this.emptyDisposal();
|
|
524
546
|
}
|
|
@@ -548,7 +570,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
548
570
|
if (!owner) {
|
|
549
571
|
throw new NoOwnerError();
|
|
550
572
|
}
|
|
551
|
-
const value = hasContext(context, owner) ? owner.
|
|
573
|
+
const value = hasContext(context, owner) ? owner.y[context.id] : context.defaultValue;
|
|
552
574
|
if (isUndefined(value)) {
|
|
553
575
|
throw new ContextNotFoundError();
|
|
554
576
|
}
|
|
@@ -558,13 +580,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
558
580
|
if (!owner) {
|
|
559
581
|
throw new NoOwnerError();
|
|
560
582
|
}
|
|
561
|
-
owner.
|
|
562
|
-
...owner.
|
|
583
|
+
owner.y = {
|
|
584
|
+
...owner.y,
|
|
563
585
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
564
586
|
};
|
|
565
587
|
}
|
|
566
588
|
function hasContext(context, owner = currentOwner) {
|
|
567
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
589
|
+
return !isUndefined(owner == null ? void 0 : owner.y[context.id]);
|
|
568
590
|
}
|
|
569
591
|
function onCleanup(fn) {
|
|
570
592
|
if (!currentOwner)
|
|
@@ -604,8 +626,8 @@ var Computation = class extends Owner {
|
|
|
604
626
|
a = null;
|
|
605
627
|
b = null;
|
|
606
628
|
l;
|
|
607
|
-
|
|
608
|
-
|
|
629
|
+
L;
|
|
630
|
+
M;
|
|
609
631
|
// Used in __DEV__ mode, hopefully removed in production
|
|
610
632
|
la;
|
|
611
633
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -617,13 +639,13 @@ var Computation = class extends Owner {
|
|
|
617
639
|
h = 0;
|
|
618
640
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
619
641
|
ba = DEFAULT_FLAGS;
|
|
620
|
-
|
|
621
|
-
|
|
642
|
+
N = -1;
|
|
643
|
+
J = false;
|
|
622
644
|
j;
|
|
623
645
|
e;
|
|
624
646
|
constructor(initialValue, compute2, options) {
|
|
625
647
|
super(options == null ? void 0 : options.id, compute2 === null);
|
|
626
|
-
this.
|
|
648
|
+
this.M = compute2;
|
|
627
649
|
this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
628
650
|
this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
629
651
|
this.l = initialValue;
|
|
@@ -642,7 +664,7 @@ var Computation = class extends Owner {
|
|
|
642
664
|
track(this);
|
|
643
665
|
newFlags |= this.h & ~currentMask;
|
|
644
666
|
if (this.h & ERROR_BIT) {
|
|
645
|
-
throw this.
|
|
667
|
+
throw this.L;
|
|
646
668
|
} else {
|
|
647
669
|
return this.l;
|
|
648
670
|
}
|
|
@@ -657,11 +679,11 @@ var Computation = class extends Owner {
|
|
|
657
679
|
if (clone !== this)
|
|
658
680
|
return clone.read();
|
|
659
681
|
}
|
|
660
|
-
if (this.
|
|
661
|
-
if (this.h & ERROR_BIT && this.
|
|
682
|
+
if (this.M) {
|
|
683
|
+
if (this.h & ERROR_BIT && this.N <= clock)
|
|
662
684
|
update(this);
|
|
663
685
|
else
|
|
664
|
-
this.
|
|
686
|
+
this.K();
|
|
665
687
|
}
|
|
666
688
|
return this.ga();
|
|
667
689
|
}
|
|
@@ -678,11 +700,11 @@ var Computation = class extends Owner {
|
|
|
678
700
|
if (clone !== this)
|
|
679
701
|
return clone.wait();
|
|
680
702
|
}
|
|
681
|
-
if (this.
|
|
682
|
-
if (this.h & ERROR_BIT && this.
|
|
703
|
+
if (this.M) {
|
|
704
|
+
if (this.h & ERROR_BIT && this.N <= clock)
|
|
683
705
|
update(this);
|
|
684
706
|
else
|
|
685
|
-
this.
|
|
707
|
+
this.K();
|
|
686
708
|
}
|
|
687
709
|
if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
|
|
688
710
|
track(this);
|
|
@@ -705,15 +727,15 @@ var Computation = class extends Owner {
|
|
|
705
727
|
this.aa === false || !this.aa(this.l, newValue));
|
|
706
728
|
if (valueChanged) {
|
|
707
729
|
this.l = newValue;
|
|
708
|
-
this.
|
|
730
|
+
this.L = void 0;
|
|
709
731
|
}
|
|
710
732
|
const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
|
|
711
733
|
this.h = flags;
|
|
712
|
-
this.
|
|
734
|
+
this.N = clock + 1;
|
|
713
735
|
if (this.b) {
|
|
714
736
|
for (let i = 0; i < this.b.length; i++) {
|
|
715
737
|
if (valueChanged) {
|
|
716
|
-
this.b[i].
|
|
738
|
+
this.b[i].z(STATE_DIRTY);
|
|
717
739
|
} else if (changedFlagsMask) {
|
|
718
740
|
this.b[i].Z(changedFlagsMask, changedFlags);
|
|
719
741
|
}
|
|
@@ -724,14 +746,14 @@ var Computation = class extends Owner {
|
|
|
724
746
|
/**
|
|
725
747
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
726
748
|
*/
|
|
727
|
-
|
|
728
|
-
if (this.c >= state && !this.
|
|
749
|
+
z(state, skipQueue) {
|
|
750
|
+
if (this.c >= state && !this.J)
|
|
729
751
|
return;
|
|
730
|
-
this.
|
|
752
|
+
this.J = !!skipQueue;
|
|
731
753
|
this.c = state;
|
|
732
754
|
if (this.b) {
|
|
733
755
|
for (let i = 0; i < this.b.length; i++) {
|
|
734
|
-
this.b[i].
|
|
756
|
+
this.b[i].z(STATE_CHECK, skipQueue);
|
|
735
757
|
}
|
|
736
758
|
}
|
|
737
759
|
}
|
|
@@ -745,7 +767,7 @@ var Computation = class extends Owner {
|
|
|
745
767
|
if (this.c >= STATE_DIRTY)
|
|
746
768
|
return;
|
|
747
769
|
if (mask & this.ba) {
|
|
748
|
-
this.
|
|
770
|
+
this.z(STATE_DIRTY);
|
|
749
771
|
return;
|
|
750
772
|
}
|
|
751
773
|
if (this.c >= STATE_CHECK)
|
|
@@ -753,7 +775,7 @@ var Computation = class extends Owner {
|
|
|
753
775
|
const prevFlags = this.h & mask;
|
|
754
776
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
755
777
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
756
|
-
this.
|
|
778
|
+
this.z(STATE_CHECK);
|
|
757
779
|
} else {
|
|
758
780
|
this.h ^= deltaFlags;
|
|
759
781
|
if (this.b) {
|
|
@@ -763,13 +785,13 @@ var Computation = class extends Owner {
|
|
|
763
785
|
}
|
|
764
786
|
}
|
|
765
787
|
}
|
|
766
|
-
|
|
788
|
+
D(error) {
|
|
767
789
|
if (ActiveTransition && !this.e) {
|
|
768
790
|
const clone = cloneGraph(this);
|
|
769
791
|
if (clone !== this)
|
|
770
|
-
return clone.
|
|
792
|
+
return clone.D(error);
|
|
771
793
|
}
|
|
772
|
-
this.
|
|
794
|
+
this.L = error;
|
|
773
795
|
this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
774
796
|
}
|
|
775
797
|
/**
|
|
@@ -779,8 +801,8 @@ var Computation = class extends Owner {
|
|
|
779
801
|
*
|
|
780
802
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
781
803
|
*/
|
|
782
|
-
|
|
783
|
-
if (!this.
|
|
804
|
+
K() {
|
|
805
|
+
if (!this.M) {
|
|
784
806
|
return;
|
|
785
807
|
}
|
|
786
808
|
if (this.c === STATE_DISPOSED) {
|
|
@@ -793,7 +815,7 @@ var Computation = class extends Owner {
|
|
|
793
815
|
if (this.c === STATE_CHECK) {
|
|
794
816
|
for (let i = 0; i < this.a.length; i++) {
|
|
795
817
|
const source = getTransitionSource(this.a[i]);
|
|
796
|
-
source.
|
|
818
|
+
source.K();
|
|
797
819
|
observerFlags |= source.h & ~UNINITIALIZED_BIT;
|
|
798
820
|
if (this.c === STATE_DIRTY) {
|
|
799
821
|
break;
|
|
@@ -830,7 +852,7 @@ function track(computation) {
|
|
|
830
852
|
newSources.push(computation);
|
|
831
853
|
}
|
|
832
854
|
if (updateCheck) {
|
|
833
|
-
updateCheck.l = computation.
|
|
855
|
+
updateCheck.l = computation.N > currentObserver.N;
|
|
834
856
|
}
|
|
835
857
|
}
|
|
836
858
|
}
|
|
@@ -846,13 +868,13 @@ function update(node) {
|
|
|
846
868
|
}
|
|
847
869
|
node.dispose(false);
|
|
848
870
|
node.emptyDisposal();
|
|
849
|
-
const result = compute(node, node.
|
|
871
|
+
const result = compute(node, node.M, node);
|
|
850
872
|
node.write(result, newFlags, true);
|
|
851
873
|
} catch (error) {
|
|
852
874
|
if (error instanceof NotReadyError) {
|
|
853
875
|
node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
|
|
854
876
|
} else {
|
|
855
|
-
node.
|
|
877
|
+
node.D(error);
|
|
856
878
|
}
|
|
857
879
|
} finally {
|
|
858
880
|
if (newSources) {
|
|
@@ -881,7 +903,7 @@ function update(node) {
|
|
|
881
903
|
newSources = prevSources;
|
|
882
904
|
newSourcesIndex = prevSourcesIndex;
|
|
883
905
|
newFlags = prevFlags;
|
|
884
|
-
node.
|
|
906
|
+
node.N = clock + 1;
|
|
885
907
|
node.c = STATE_CLEAN;
|
|
886
908
|
}
|
|
887
909
|
}
|
|
@@ -956,7 +978,7 @@ function runWithObserver(observer, run) {
|
|
|
956
978
|
newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
|
|
957
979
|
);
|
|
958
980
|
} else {
|
|
959
|
-
observer.
|
|
981
|
+
observer.D(error);
|
|
960
982
|
}
|
|
961
983
|
} finally {
|
|
962
984
|
if (newSources) {
|
|
@@ -1001,28 +1023,28 @@ function compute(owner, fn, observer) {
|
|
|
1001
1023
|
var Effect = class extends Computation {
|
|
1002
1024
|
ca;
|
|
1003
1025
|
_;
|
|
1004
|
-
|
|
1026
|
+
O;
|
|
1005
1027
|
da = false;
|
|
1006
1028
|
$;
|
|
1007
|
-
|
|
1029
|
+
C;
|
|
1008
1030
|
constructor(initialValue, compute2, effect, error, options) {
|
|
1009
1031
|
super(initialValue, compute2, options);
|
|
1010
1032
|
this.ca = effect;
|
|
1011
1033
|
this._ = error;
|
|
1012
1034
|
this.$ = initialValue;
|
|
1013
|
-
this.
|
|
1014
|
-
if (this.
|
|
1015
|
-
this.
|
|
1035
|
+
this.C = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
1036
|
+
if (this.C === EFFECT_RENDER) {
|
|
1037
|
+
this.M = function(p) {
|
|
1016
1038
|
return !this.e && clock > this.m.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1017
1039
|
};
|
|
1018
1040
|
}
|
|
1019
|
-
this.
|
|
1020
|
-
!(options == null ? void 0 : options.defer) && (this.
|
|
1041
|
+
this.K();
|
|
1042
|
+
!(options == null ? void 0 : options.defer) && (this.C === EFFECT_USER ? this.m.enqueue(this.C, this.E.bind(this)) : this.E(this.C));
|
|
1021
1043
|
}
|
|
1022
1044
|
write(value, flags = 0) {
|
|
1023
1045
|
if (this.c == STATE_DIRTY) {
|
|
1024
1046
|
this.h = flags;
|
|
1025
|
-
if (this.
|
|
1047
|
+
if (this.C === EFFECT_RENDER) {
|
|
1026
1048
|
this.m.notify(this, LOADING_BIT | ERROR_BIT, this.h);
|
|
1027
1049
|
}
|
|
1028
1050
|
}
|
|
@@ -1030,14 +1052,14 @@ var Effect = class extends Computation {
|
|
|
1030
1052
|
return this.l;
|
|
1031
1053
|
this.l = value;
|
|
1032
1054
|
this.da = true;
|
|
1033
|
-
this.
|
|
1055
|
+
this.L = void 0;
|
|
1034
1056
|
return value;
|
|
1035
1057
|
}
|
|
1036
|
-
|
|
1058
|
+
z(state, skipQueue) {
|
|
1037
1059
|
if (this.c >= state || skipQueue)
|
|
1038
1060
|
return;
|
|
1039
1061
|
if (this.c === STATE_CLEAN)
|
|
1040
|
-
this.m.enqueue(this.
|
|
1062
|
+
this.m.enqueue(this.C, this.E.bind(this));
|
|
1041
1063
|
this.c = state;
|
|
1042
1064
|
}
|
|
1043
1065
|
Z(mask, newFlags2) {
|
|
@@ -1045,22 +1067,22 @@ var Effect = class extends Computation {
|
|
|
1045
1067
|
if (this.c >= STATE_DIRTY)
|
|
1046
1068
|
return;
|
|
1047
1069
|
if (mask & 3) {
|
|
1048
|
-
this.
|
|
1070
|
+
this.z(STATE_DIRTY);
|
|
1049
1071
|
return;
|
|
1050
1072
|
}
|
|
1051
1073
|
}
|
|
1052
1074
|
super.Z(mask, newFlags2);
|
|
1053
1075
|
}
|
|
1054
|
-
|
|
1055
|
-
this.
|
|
1076
|
+
D(error) {
|
|
1077
|
+
this.L = error;
|
|
1056
1078
|
this.m.notify(this, LOADING_BIT, 0);
|
|
1057
1079
|
this.h = ERROR_BIT;
|
|
1058
|
-
if (this.
|
|
1080
|
+
if (this.C === EFFECT_USER) {
|
|
1059
1081
|
try {
|
|
1060
1082
|
return this._ ? this._(error, () => {
|
|
1061
1083
|
var _a;
|
|
1062
|
-
(_a = this.
|
|
1063
|
-
this.
|
|
1084
|
+
(_a = this.O) == null ? void 0 : _a.call(this);
|
|
1085
|
+
this.O = void 0;
|
|
1064
1086
|
}) : console.error(error);
|
|
1065
1087
|
} catch (e) {
|
|
1066
1088
|
error = e;
|
|
@@ -1076,19 +1098,19 @@ var Effect = class extends Computation {
|
|
|
1076
1098
|
this.ca = void 0;
|
|
1077
1099
|
this.$ = void 0;
|
|
1078
1100
|
this._ = void 0;
|
|
1079
|
-
(_a = this.
|
|
1080
|
-
this.
|
|
1101
|
+
(_a = this.O) == null ? void 0 : _a.call(this);
|
|
1102
|
+
this.O = void 0;
|
|
1081
1103
|
this.m.notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1082
1104
|
super.R();
|
|
1083
1105
|
}
|
|
1084
|
-
|
|
1106
|
+
E(type) {
|
|
1085
1107
|
var _a;
|
|
1086
1108
|
if (type) {
|
|
1087
1109
|
const effect = this.e || this;
|
|
1088
1110
|
if (effect.da && effect.c !== STATE_DISPOSED) {
|
|
1089
|
-
(_a = effect.
|
|
1111
|
+
(_a = effect.O) == null ? void 0 : _a.call(effect);
|
|
1090
1112
|
try {
|
|
1091
|
-
effect.
|
|
1113
|
+
effect.O = effect.ca(effect.l, effect.$);
|
|
1092
1114
|
} catch (e) {
|
|
1093
1115
|
if (!effect.m.notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1094
1116
|
throw e;
|
|
@@ -1104,16 +1126,16 @@ var Effect = class extends Computation {
|
|
|
1104
1126
|
var EagerComputation = class extends Computation {
|
|
1105
1127
|
constructor(initialValue, compute2, options) {
|
|
1106
1128
|
super(initialValue, compute2, options);
|
|
1107
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
1129
|
+
!(options == null ? void 0 : options.defer) && this.K();
|
|
1108
1130
|
}
|
|
1109
|
-
|
|
1110
|
-
if (this.c >= state && !this.
|
|
1131
|
+
z(state, skipQueue) {
|
|
1132
|
+
if (this.c >= state && !this.J)
|
|
1111
1133
|
return;
|
|
1112
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1113
|
-
this.m.enqueue(EFFECT_PURE, this.
|
|
1114
|
-
super.
|
|
1134
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.J))
|
|
1135
|
+
this.m.enqueue(EFFECT_PURE, this.E.bind(this));
|
|
1136
|
+
super.z(state, skipQueue);
|
|
1115
1137
|
}
|
|
1116
|
-
|
|
1138
|
+
E() {
|
|
1117
1139
|
this.c !== STATE_CLEAN && runTop(this);
|
|
1118
1140
|
}
|
|
1119
1141
|
};
|
|
@@ -1122,15 +1144,15 @@ var FirewallComputation = class extends Computation {
|
|
|
1122
1144
|
constructor(compute2) {
|
|
1123
1145
|
super(void 0, compute2);
|
|
1124
1146
|
}
|
|
1125
|
-
|
|
1126
|
-
if (this.c >= state && !this.
|
|
1147
|
+
z(state, skipQueue) {
|
|
1148
|
+
if (this.c >= state && !this.J)
|
|
1127
1149
|
return;
|
|
1128
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1129
|
-
this.m.enqueue(EFFECT_PURE, this.
|
|
1130
|
-
super.
|
|
1131
|
-
this.
|
|
1150
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.J))
|
|
1151
|
+
this.m.enqueue(EFFECT_PURE, this.E.bind(this));
|
|
1152
|
+
super.z(state, true);
|
|
1153
|
+
this.J = !!skipQueue;
|
|
1132
1154
|
}
|
|
1133
|
-
|
|
1155
|
+
E() {
|
|
1134
1156
|
this.c !== STATE_CLEAN && runTop(this);
|
|
1135
1157
|
}
|
|
1136
1158
|
};
|
|
@@ -1145,22 +1167,158 @@ function runTop(node) {
|
|
|
1145
1167
|
}
|
|
1146
1168
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1147
1169
|
if (ancestors[i].c !== STATE_DISPOSED)
|
|
1148
|
-
ancestors[i].
|
|
1170
|
+
ancestors[i].K();
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
// src/store/reconcile.ts
|
|
1175
|
+
function unwrap(value) {
|
|
1176
|
+
var _a;
|
|
1177
|
+
return ((_a = value == null ? void 0 : value[$TARGET]) == null ? void 0 : _a[STORE_NODE]) ?? value;
|
|
1178
|
+
}
|
|
1179
|
+
function getOverrideValue(value, override, key) {
|
|
1180
|
+
return override && key in override ? override[key] : value[key];
|
|
1181
|
+
}
|
|
1182
|
+
function getAllKeys(value, override, next) {
|
|
1183
|
+
const keys = getKeys(value, override);
|
|
1184
|
+
const nextKeys = Object.keys(next);
|
|
1185
|
+
return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
|
|
1186
|
+
}
|
|
1187
|
+
function applyState(next, state, keyFn, all) {
|
|
1188
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1189
|
+
const target = state == null ? void 0 : state[$TARGET];
|
|
1190
|
+
if (!target)
|
|
1191
|
+
return;
|
|
1192
|
+
const previous = target[STORE_VALUE];
|
|
1193
|
+
const override = target[STORE_OVERRIDE];
|
|
1194
|
+
if (next === previous && !override)
|
|
1195
|
+
return;
|
|
1196
|
+
(target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
|
|
1197
|
+
target[STORE_VALUE] = next;
|
|
1198
|
+
target[STORE_OVERRIDE] = void 0;
|
|
1199
|
+
if (Array.isArray(previous)) {
|
|
1200
|
+
let changed = false;
|
|
1201
|
+
const prevLength = getOverrideValue(previous, override, "length");
|
|
1202
|
+
if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
|
|
1203
|
+
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
1204
|
+
for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
|
|
1205
|
+
applyState(next[start], wrap(item, target), keyFn, all);
|
|
1206
|
+
}
|
|
1207
|
+
const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
|
|
1208
|
+
for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
|
|
1209
|
+
temp[newEnd] = item;
|
|
1210
|
+
}
|
|
1211
|
+
if (start > newEnd || start > end) {
|
|
1212
|
+
for (j = start; j <= newEnd; j++) {
|
|
1213
|
+
changed = true;
|
|
1214
|
+
(_a = target[STORE_NODE][j]) == null ? void 0 : _a.write(wrap(next[j], target));
|
|
1215
|
+
}
|
|
1216
|
+
for (; j < next.length; j++) {
|
|
1217
|
+
changed = true;
|
|
1218
|
+
const wrapped = wrap(temp[j], target);
|
|
1219
|
+
(_b = target[STORE_NODE][j]) == null ? void 0 : _b.write(wrapped);
|
|
1220
|
+
applyState(next[j], wrapped, keyFn, all);
|
|
1221
|
+
}
|
|
1222
|
+
changed && ((_c = target[STORE_NODE][$TRACK]) == null ? void 0 : _c.write(void 0));
|
|
1223
|
+
prevLength !== next.length && ((_d = target[STORE_NODE].length) == null ? void 0 : _d.write(next.length));
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
newIndicesNext = new Array(newEnd + 1);
|
|
1227
|
+
for (j = newEnd; j >= start; j--) {
|
|
1228
|
+
item = next[j];
|
|
1229
|
+
keyVal = item ? keyFn(item) : item;
|
|
1230
|
+
i = newIndices.get(keyVal);
|
|
1231
|
+
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1232
|
+
newIndices.set(keyVal, j);
|
|
1233
|
+
}
|
|
1234
|
+
for (i = start; i <= end; i++) {
|
|
1235
|
+
item = getOverrideValue(previous, override, i);
|
|
1236
|
+
keyVal = item ? keyFn(item) : item;
|
|
1237
|
+
j = newIndices.get(keyVal);
|
|
1238
|
+
if (j !== void 0 && j !== -1) {
|
|
1239
|
+
temp[j] = item;
|
|
1240
|
+
j = newIndicesNext[j];
|
|
1241
|
+
newIndices.set(keyVal, j);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
for (j = start; j < next.length; j++) {
|
|
1245
|
+
if (j in temp) {
|
|
1246
|
+
const wrapped = wrap(temp[j], target);
|
|
1247
|
+
(_e = target[STORE_NODE][j]) == null ? void 0 : _e.write(wrapped);
|
|
1248
|
+
applyState(next[j], wrapped, keyFn, all);
|
|
1249
|
+
} else
|
|
1250
|
+
(_f = target[STORE_NODE][j]) == null ? void 0 : _f.write(wrap(next[j], target));
|
|
1251
|
+
}
|
|
1252
|
+
if (start < next.length)
|
|
1253
|
+
changed = true;
|
|
1254
|
+
} else if (prevLength && next.length) {
|
|
1255
|
+
for (let i = 0, len = next.length; i < len; i++) {
|
|
1256
|
+
const item = getOverrideValue(previous, override, i);
|
|
1257
|
+
isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
if (prevLength !== next.length) {
|
|
1261
|
+
changed = true;
|
|
1262
|
+
(_g = target[STORE_NODE].length) == null ? void 0 : _g.write(next.length);
|
|
1263
|
+
}
|
|
1264
|
+
changed && ((_h = target[STORE_NODE][$TRACK]) == null ? void 0 : _h.write(void 0));
|
|
1265
|
+
return;
|
|
1149
1266
|
}
|
|
1267
|
+
let nodes = target[STORE_NODE];
|
|
1268
|
+
if (nodes) {
|
|
1269
|
+
const tracked = nodes[$TRACK];
|
|
1270
|
+
const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
|
|
1271
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1272
|
+
const key = keys[i];
|
|
1273
|
+
const node = nodes[key];
|
|
1274
|
+
const previousValue = unwrap(getOverrideValue(previous, override, key));
|
|
1275
|
+
let nextValue = unwrap(next[key]);
|
|
1276
|
+
if (previousValue === nextValue)
|
|
1277
|
+
continue;
|
|
1278
|
+
if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
|
|
1279
|
+
tracked == null ? void 0 : tracked.write(void 0);
|
|
1280
|
+
node == null ? void 0 : node.write(isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
|
|
1281
|
+
} else
|
|
1282
|
+
applyState(nextValue, wrap(previousValue, target), keyFn, all);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
if (nodes = target[STORE_HAS]) {
|
|
1286
|
+
const keys = Object.keys(nodes);
|
|
1287
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1288
|
+
nodes[keys[i]].write(keys[i] in next);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
function reconcile(value, key, all = false) {
|
|
1293
|
+
return (state) => {
|
|
1294
|
+
if (state == null)
|
|
1295
|
+
throw new Error("Cannot reconcile null or undefined state");
|
|
1296
|
+
const keyFn = typeof key === "string" ? (item) => item[key] : key;
|
|
1297
|
+
const eq = keyFn(state);
|
|
1298
|
+
if (eq !== void 0 && keyFn(value) !== keyFn(state))
|
|
1299
|
+
throw new Error("Cannot reconcile states with different identity");
|
|
1300
|
+
applyState(value, state, keyFn, all);
|
|
1301
|
+
};
|
|
1150
1302
|
}
|
|
1151
1303
|
|
|
1152
1304
|
// src/store/projection.ts
|
|
1153
|
-
function createProjection(fn, initialValue = {}) {
|
|
1305
|
+
function createProjection(fn, initialValue = {}, options) {
|
|
1154
1306
|
let wrappedStore;
|
|
1155
1307
|
const node = new FirewallComputation(() => {
|
|
1156
|
-
storeSetter(wrappedStore,
|
|
1308
|
+
storeSetter(wrappedStore, (s) => {
|
|
1309
|
+
const value = fn(s);
|
|
1310
|
+
if (value !== s && value !== void 0) {
|
|
1311
|
+
reconcile(value, (options == null ? void 0 : options.key) || "id", options == null ? void 0 : options.all)(s);
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1157
1314
|
});
|
|
1158
1315
|
const wrappedMap = /* @__PURE__ */ new WeakMap();
|
|
1159
1316
|
const traps = {
|
|
1160
1317
|
...storeTraps,
|
|
1161
1318
|
get(target, property, receiver) {
|
|
1162
1319
|
const o = getOwner();
|
|
1163
|
-
|
|
1320
|
+
const n = getTransitionSource(node);
|
|
1321
|
+
(!o || o !== n) && n.wait();
|
|
1164
1322
|
return storeTraps.get(target, property, receiver);
|
|
1165
1323
|
}
|
|
1166
1324
|
};
|
|
@@ -1385,14 +1543,29 @@ function storeSetter(store, fn) {
|
|
|
1385
1543
|
Writing = /* @__PURE__ */ new Set();
|
|
1386
1544
|
Writing.add(store);
|
|
1387
1545
|
try {
|
|
1388
|
-
fn(store);
|
|
1546
|
+
const value = fn(store);
|
|
1547
|
+
if (value !== store && value !== void 0) {
|
|
1548
|
+
if (Array.isArray(value)) {
|
|
1549
|
+
for (let i = 0, len = value.length; i < len; i++)
|
|
1550
|
+
store[i] = value[i];
|
|
1551
|
+
store.length = value.length;
|
|
1552
|
+
} else {
|
|
1553
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(store), ...Object.keys(value)]);
|
|
1554
|
+
keys.forEach((key) => {
|
|
1555
|
+
if (key in value)
|
|
1556
|
+
store[key] = value[key];
|
|
1557
|
+
else
|
|
1558
|
+
delete store[key];
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1389
1562
|
} finally {
|
|
1390
1563
|
Writing.clear();
|
|
1391
1564
|
Writing = prevWriting;
|
|
1392
1565
|
}
|
|
1393
1566
|
}
|
|
1394
|
-
function createStore(first, second) {
|
|
1395
|
-
const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second) : wrap(first);
|
|
1567
|
+
function createStore(first, second, options) {
|
|
1568
|
+
const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second, options) : wrap(first);
|
|
1396
1569
|
return [wrappedStore, (fn) => storeSetter(wrappedStore, fn)];
|
|
1397
1570
|
}
|
|
1398
1571
|
function recursivelyNotify(state, lookup) {
|
|
@@ -1457,136 +1630,6 @@ function deep(store) {
|
|
|
1457
1630
|
return store[$DEEP];
|
|
1458
1631
|
}
|
|
1459
1632
|
|
|
1460
|
-
// src/store/reconcile.ts
|
|
1461
|
-
function unwrap(value) {
|
|
1462
|
-
var _a;
|
|
1463
|
-
return ((_a = value == null ? void 0 : value[$TARGET]) == null ? void 0 : _a[STORE_NODE]) ?? value;
|
|
1464
|
-
}
|
|
1465
|
-
function getOverrideValue(value, override, key) {
|
|
1466
|
-
return override && key in override ? override[key] : value[key];
|
|
1467
|
-
}
|
|
1468
|
-
function getAllKeys(value, override, next) {
|
|
1469
|
-
const keys = getKeys(value, override);
|
|
1470
|
-
const nextKeys = Object.keys(next);
|
|
1471
|
-
return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
|
|
1472
|
-
}
|
|
1473
|
-
function applyState(next, state, keyFn, all) {
|
|
1474
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1475
|
-
const target = state == null ? void 0 : state[$TARGET];
|
|
1476
|
-
if (!target)
|
|
1477
|
-
return;
|
|
1478
|
-
const previous = target[STORE_VALUE];
|
|
1479
|
-
const override = target[STORE_OVERRIDE];
|
|
1480
|
-
if (next === previous && !override)
|
|
1481
|
-
return;
|
|
1482
|
-
(target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
|
|
1483
|
-
target[STORE_VALUE] = next;
|
|
1484
|
-
target[STORE_OVERRIDE] = void 0;
|
|
1485
|
-
if (Array.isArray(previous)) {
|
|
1486
|
-
let changed = false;
|
|
1487
|
-
const prevLength = getOverrideValue(previous, override, "length");
|
|
1488
|
-
if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
|
|
1489
|
-
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
1490
|
-
for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
|
|
1491
|
-
applyState(next[start], wrap(item, target), keyFn, all);
|
|
1492
|
-
}
|
|
1493
|
-
const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
|
|
1494
|
-
for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
|
|
1495
|
-
temp[newEnd] = item;
|
|
1496
|
-
}
|
|
1497
|
-
if (start > newEnd || start > end) {
|
|
1498
|
-
for (j = start; j <= newEnd; j++) {
|
|
1499
|
-
changed = true;
|
|
1500
|
-
(_a = target[STORE_NODE][j]) == null ? void 0 : _a.write(wrap(next[j], target));
|
|
1501
|
-
}
|
|
1502
|
-
for (; j < next.length; j++) {
|
|
1503
|
-
changed = true;
|
|
1504
|
-
const wrapped = wrap(temp[j], target);
|
|
1505
|
-
(_b = target[STORE_NODE][j]) == null ? void 0 : _b.write(wrapped);
|
|
1506
|
-
applyState(next[j], wrapped, keyFn, all);
|
|
1507
|
-
}
|
|
1508
|
-
changed && ((_c = target[STORE_NODE][$TRACK]) == null ? void 0 : _c.write(void 0));
|
|
1509
|
-
prevLength !== next.length && ((_d = target[STORE_NODE].length) == null ? void 0 : _d.write(next.length));
|
|
1510
|
-
return;
|
|
1511
|
-
}
|
|
1512
|
-
newIndicesNext = new Array(newEnd + 1);
|
|
1513
|
-
for (j = newEnd; j >= start; j--) {
|
|
1514
|
-
item = next[j];
|
|
1515
|
-
keyVal = item ? keyFn(item) : item;
|
|
1516
|
-
i = newIndices.get(keyVal);
|
|
1517
|
-
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1518
|
-
newIndices.set(keyVal, j);
|
|
1519
|
-
}
|
|
1520
|
-
for (i = start; i <= end; i++) {
|
|
1521
|
-
item = getOverrideValue(previous, override, i);
|
|
1522
|
-
keyVal = item ? keyFn(item) : item;
|
|
1523
|
-
j = newIndices.get(keyVal);
|
|
1524
|
-
if (j !== void 0 && j !== -1) {
|
|
1525
|
-
temp[j] = item;
|
|
1526
|
-
j = newIndicesNext[j];
|
|
1527
|
-
newIndices.set(keyVal, j);
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
for (j = start; j < next.length; j++) {
|
|
1531
|
-
if (j in temp) {
|
|
1532
|
-
const wrapped = wrap(temp[j], target);
|
|
1533
|
-
(_e = target[STORE_NODE][j]) == null ? void 0 : _e.write(wrapped);
|
|
1534
|
-
applyState(next[j], wrapped, keyFn, all);
|
|
1535
|
-
} else
|
|
1536
|
-
(_f = target[STORE_NODE][j]) == null ? void 0 : _f.write(wrap(next[j], target));
|
|
1537
|
-
}
|
|
1538
|
-
if (start < next.length)
|
|
1539
|
-
changed = true;
|
|
1540
|
-
} else if (prevLength && next.length) {
|
|
1541
|
-
for (let i = 0, len = next.length; i < len; i++) {
|
|
1542
|
-
const item = getOverrideValue(previous, override, i);
|
|
1543
|
-
isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
if (prevLength !== next.length) {
|
|
1547
|
-
changed = true;
|
|
1548
|
-
(_g = target[STORE_NODE].length) == null ? void 0 : _g.write(next.length);
|
|
1549
|
-
}
|
|
1550
|
-
changed && ((_h = target[STORE_NODE][$TRACK]) == null ? void 0 : _h.write(void 0));
|
|
1551
|
-
return;
|
|
1552
|
-
}
|
|
1553
|
-
let nodes = target[STORE_NODE];
|
|
1554
|
-
if (nodes) {
|
|
1555
|
-
const tracked = nodes[$TRACK];
|
|
1556
|
-
const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
|
|
1557
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1558
|
-
const key = keys[i];
|
|
1559
|
-
const node = nodes[key];
|
|
1560
|
-
const previousValue = unwrap(getOverrideValue(previous, override, key));
|
|
1561
|
-
let nextValue = unwrap(next[key]);
|
|
1562
|
-
if (previousValue === nextValue)
|
|
1563
|
-
continue;
|
|
1564
|
-
if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
|
|
1565
|
-
tracked == null ? void 0 : tracked.write(void 0);
|
|
1566
|
-
node == null ? void 0 : node.write(isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
|
|
1567
|
-
} else
|
|
1568
|
-
applyState(nextValue, wrap(previousValue, target), keyFn, all);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
if (nodes = target[STORE_HAS]) {
|
|
1572
|
-
const keys = Object.keys(nodes);
|
|
1573
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1574
|
-
nodes[keys[i]].write(keys[i] in next);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
function reconcile(value, key, all = false) {
|
|
1579
|
-
return (state) => {
|
|
1580
|
-
if (state == null)
|
|
1581
|
-
throw new Error("Cannot reconcile null or undefined state");
|
|
1582
|
-
const keyFn = typeof key === "string" ? (item) => item[key] : key;
|
|
1583
|
-
const eq = keyFn(state);
|
|
1584
|
-
if (eq !== void 0 && keyFn(value) !== keyFn(state))
|
|
1585
|
-
throw new Error("Cannot reconcile states with different identity");
|
|
1586
|
-
applyState(value, state, keyFn, all);
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
1633
|
// src/store/utils.ts
|
|
1591
1634
|
function snapshot(item, map, lookup) {
|
|
1592
1635
|
var _a;
|
|
@@ -1847,22 +1890,24 @@ function createAsync(compute2, value, options) {
|
|
|
1847
1890
|
}
|
|
1848
1891
|
let abort = false;
|
|
1849
1892
|
onCleanup(() => abort = true);
|
|
1850
|
-
|
|
1893
|
+
let transition2 = ActiveTransition;
|
|
1851
1894
|
if (isPromise) {
|
|
1852
1895
|
source.then(
|
|
1853
1896
|
(value3) => {
|
|
1854
1897
|
if (abort)
|
|
1855
1898
|
return;
|
|
1856
1899
|
if (transition2)
|
|
1857
|
-
return transition2.runTransition(() =>
|
|
1900
|
+
return transition2.runTransition(() => {
|
|
1901
|
+
node.write(value3, 0, true);
|
|
1902
|
+
}, true);
|
|
1858
1903
|
node.write(value3, 0, true);
|
|
1859
1904
|
},
|
|
1860
1905
|
(error) => {
|
|
1861
1906
|
if (abort)
|
|
1862
1907
|
return;
|
|
1863
1908
|
if (transition2)
|
|
1864
|
-
return transition2.runTransition(() => node.
|
|
1865
|
-
node.
|
|
1909
|
+
return transition2.runTransition(() => node.D(error), true);
|
|
1910
|
+
node.D(error);
|
|
1866
1911
|
}
|
|
1867
1912
|
);
|
|
1868
1913
|
} else {
|
|
@@ -1871,12 +1916,22 @@ function createAsync(compute2, value, options) {
|
|
|
1871
1916
|
for await (let value3 of source) {
|
|
1872
1917
|
if (abort)
|
|
1873
1918
|
return;
|
|
1919
|
+
if (transition2)
|
|
1920
|
+
return transition2.runTransition(() => {
|
|
1921
|
+
node.write(value3, 0, true);
|
|
1922
|
+
transition2 = null;
|
|
1923
|
+
}, true);
|
|
1874
1924
|
node.write(value3, 0, true);
|
|
1875
1925
|
}
|
|
1876
1926
|
} catch (error) {
|
|
1877
1927
|
if (abort)
|
|
1878
1928
|
return;
|
|
1879
|
-
|
|
1929
|
+
if (transition2)
|
|
1930
|
+
return transition2.runTransition(() => {
|
|
1931
|
+
node.D(error);
|
|
1932
|
+
transition2 = null;
|
|
1933
|
+
}, true);
|
|
1934
|
+
node.D(error);
|
|
1880
1935
|
}
|
|
1881
1936
|
})();
|
|
1882
1937
|
}
|
|
@@ -1892,7 +1947,7 @@ function createAsync(compute2, value, options) {
|
|
|
1892
1947
|
}
|
|
1893
1948
|
n.c = STATE_DIRTY;
|
|
1894
1949
|
refreshing = true;
|
|
1895
|
-
n.
|
|
1950
|
+
n.K();
|
|
1896
1951
|
};
|
|
1897
1952
|
return read;
|
|
1898
1953
|
}
|
|
@@ -1934,70 +1989,56 @@ function resolve(fn) {
|
|
|
1934
1989
|
});
|
|
1935
1990
|
});
|
|
1936
1991
|
}
|
|
1937
|
-
function
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
}
|
|
1950
|
-
return [void 0, v];
|
|
1951
|
-
} catch (e) {
|
|
1952
|
-
if (e instanceof NotReadyError)
|
|
1953
|
-
throw e;
|
|
1954
|
-
return [e];
|
|
1992
|
+
function createPending() {
|
|
1993
|
+
const node = new Computation(false, null);
|
|
1994
|
+
const reset = () => node.write(false);
|
|
1995
|
+
function write(v) {
|
|
1996
|
+
if (!ActiveTransition)
|
|
1997
|
+
return v;
|
|
1998
|
+
ActiveTransition.addOptimistic(reset);
|
|
1999
|
+
queueMicrotask(() => reset.j && node.write(v));
|
|
2000
|
+
}
|
|
2001
|
+
function read() {
|
|
2002
|
+
node.read();
|
|
2003
|
+
return !ActiveTransition;
|
|
1955
2004
|
}
|
|
2005
|
+
return [read, write];
|
|
1956
2006
|
}
|
|
1957
|
-
function
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
};
|
|
1965
|
-
var write = write2;
|
|
1966
|
-
const node = new Computation(initial, null);
|
|
1967
|
-
const reset2 = () => node.write(initial);
|
|
1968
|
-
return [node.read.bind(node), write2];
|
|
2007
|
+
function useTransition() {
|
|
2008
|
+
const [pending, setPending] = createPending();
|
|
2009
|
+
function start(fn) {
|
|
2010
|
+
transition((resume) => {
|
|
2011
|
+
setPending(true);
|
|
2012
|
+
return fn(resume);
|
|
2013
|
+
});
|
|
1969
2014
|
}
|
|
2015
|
+
return [pending, start];
|
|
2016
|
+
}
|
|
2017
|
+
function createOptimistic(first, second, options) {
|
|
1970
2018
|
let store, setStore;
|
|
1971
|
-
if (typeof
|
|
1972
|
-
[store, setStore] = createStore(
|
|
1973
|
-
(s)
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
{ value: void 0 }
|
|
1979
|
-
);
|
|
2019
|
+
if (typeof first === "function") {
|
|
2020
|
+
[store, setStore] = createStore((s) => {
|
|
2021
|
+
const value = first(s);
|
|
2022
|
+
if (!ActiveTransition)
|
|
2023
|
+
return value;
|
|
2024
|
+
ActiveTransition.addOptimistic(reset);
|
|
2025
|
+
}, {});
|
|
1980
2026
|
} else
|
|
1981
|
-
[store, setStore] = createStore(
|
|
2027
|
+
[store, setStore] = createStore(first);
|
|
1982
2028
|
const reset = () => setStore(
|
|
1983
2029
|
(s) => reconcile(
|
|
1984
|
-
{ value: typeof
|
|
1985
|
-
key
|
|
2030
|
+
{ value: typeof first === "function" ? first(second) : first },
|
|
2031
|
+
(options == null ? void 0 : options.key) || "id",
|
|
2032
|
+
options == null ? void 0 : options.all
|
|
1986
2033
|
)(s)
|
|
1987
2034
|
);
|
|
1988
|
-
let lastChange = void 0;
|
|
1989
2035
|
function write(v) {
|
|
1990
2036
|
if (!ActiveTransition)
|
|
1991
2037
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1992
2038
|
ActiveTransition.addOptimistic(reset);
|
|
1993
|
-
queueMicrotask(
|
|
1994
|
-
() => reset.j && setStore((s) => {
|
|
1995
|
-
lastChange = typeof v === "function" ? v(lastChange) : v;
|
|
1996
|
-
compute2(s.value, lastChange);
|
|
1997
|
-
})
|
|
1998
|
-
);
|
|
2039
|
+
queueMicrotask(() => reset.j && setStore(v));
|
|
1999
2040
|
}
|
|
2000
|
-
return [
|
|
2041
|
+
return [store, write];
|
|
2001
2042
|
}
|
|
2002
2043
|
|
|
2003
2044
|
// src/map.ts
|
|
@@ -2007,11 +2048,11 @@ function mapArray(list, map, options) {
|
|
|
2007
2048
|
S: new Owner(),
|
|
2008
2049
|
q: 0,
|
|
2009
2050
|
ia: list,
|
|
2010
|
-
|
|
2011
|
-
|
|
2051
|
+
F: [],
|
|
2052
|
+
P: map,
|
|
2012
2053
|
i: [],
|
|
2013
2054
|
d: [],
|
|
2014
|
-
|
|
2055
|
+
Q: keyFn,
|
|
2015
2056
|
r: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
2016
2057
|
s: map.length > 1 ? [] : void 0,
|
|
2017
2058
|
T: options == null ? void 0 : options.fallback
|
|
@@ -2025,23 +2066,23 @@ function updateKeyedMap() {
|
|
|
2025
2066
|
let i, j, mapper = this.r ? () => {
|
|
2026
2067
|
this.r[j] = new Computation(newItems[j], null, pureOptions);
|
|
2027
2068
|
this.s && (this.s[j] = new Computation(j, null, pureOptions));
|
|
2028
|
-
return this.
|
|
2069
|
+
return this.P(
|
|
2029
2070
|
Computation.prototype.read.bind(this.r[j]),
|
|
2030
2071
|
this.s ? Computation.prototype.read.bind(this.s[j]) : void 0
|
|
2031
2072
|
);
|
|
2032
2073
|
} : this.s ? () => {
|
|
2033
2074
|
const item = newItems[j];
|
|
2034
2075
|
this.s[j] = new Computation(j, null, pureOptions);
|
|
2035
|
-
return this.
|
|
2076
|
+
return this.P(() => item, Computation.prototype.read.bind(this.s[j]));
|
|
2036
2077
|
} : () => {
|
|
2037
2078
|
const item = newItems[j];
|
|
2038
|
-
return this.
|
|
2079
|
+
return this.P(() => item);
|
|
2039
2080
|
};
|
|
2040
2081
|
if (newLen === 0) {
|
|
2041
2082
|
if (this.q !== 0) {
|
|
2042
2083
|
this.S.dispose(false);
|
|
2043
2084
|
this.d = [];
|
|
2044
|
-
this.
|
|
2085
|
+
this.F = [];
|
|
2045
2086
|
this.i = [];
|
|
2046
2087
|
this.q = 0;
|
|
2047
2088
|
this.r && (this.r = []);
|
|
@@ -2059,17 +2100,17 @@ function updateKeyedMap() {
|
|
|
2059
2100
|
this.d[0].dispose();
|
|
2060
2101
|
this.i = new Array(newLen);
|
|
2061
2102
|
for (j = 0; j < newLen; j++) {
|
|
2062
|
-
this.
|
|
2103
|
+
this.F[j] = newItems[j];
|
|
2063
2104
|
this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
|
|
2064
2105
|
}
|
|
2065
2106
|
this.q = newLen;
|
|
2066
2107
|
} else {
|
|
2067
2108
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.r ? new Array(newLen) : void 0, tempIndexes = this.s ? new Array(newLen) : void 0;
|
|
2068
|
-
for (start = 0, end = Math.min(this.q, newLen); start < end && (this.
|
|
2109
|
+
for (start = 0, end = Math.min(this.q, newLen); start < end && (this.F[start] === newItems[start] || this.r && compare(this.Q, this.F[start], newItems[start])); start++) {
|
|
2069
2110
|
if (this.r)
|
|
2070
2111
|
this.r[start].write(newItems[start]);
|
|
2071
2112
|
}
|
|
2072
|
-
for (end = this.q - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
2113
|
+
for (end = this.q - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.r && compare(this.Q, this.F[end], newItems[newEnd])); end--, newEnd--) {
|
|
2073
2114
|
temp[newEnd] = this.i[end];
|
|
2074
2115
|
tempNodes[newEnd] = this.d[end];
|
|
2075
2116
|
tempRows && (tempRows[newEnd] = this.r[end]);
|
|
@@ -2079,14 +2120,14 @@ function updateKeyedMap() {
|
|
|
2079
2120
|
newIndicesNext = new Array(newEnd + 1);
|
|
2080
2121
|
for (j = newEnd; j >= start; j--) {
|
|
2081
2122
|
item = newItems[j];
|
|
2082
|
-
key = this.
|
|
2123
|
+
key = this.Q ? this.Q(item) : item;
|
|
2083
2124
|
i = newIndices.get(key);
|
|
2084
2125
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2085
2126
|
newIndices.set(key, j);
|
|
2086
2127
|
}
|
|
2087
2128
|
for (i = start; i <= end; i++) {
|
|
2088
|
-
item = this.
|
|
2089
|
-
key = this.
|
|
2129
|
+
item = this.F[i];
|
|
2130
|
+
key = this.Q ? this.Q(item) : item;
|
|
2090
2131
|
j = newIndices.get(key);
|
|
2091
2132
|
if (j !== void 0 && j !== -1) {
|
|
2092
2133
|
temp[j] = this.i[i];
|
|
@@ -2115,7 +2156,7 @@ function updateKeyedMap() {
|
|
|
2115
2156
|
}
|
|
2116
2157
|
}
|
|
2117
2158
|
this.i = this.i.slice(0, this.q = newLen);
|
|
2118
|
-
this.
|
|
2159
|
+
this.F = newItems.slice(0);
|
|
2119
2160
|
}
|
|
2120
2161
|
});
|
|
2121
2162
|
return this.i;
|
|
@@ -2124,9 +2165,9 @@ function repeat(count, map, options) {
|
|
|
2124
2165
|
return updateRepeat.bind({
|
|
2125
2166
|
S: new Owner(),
|
|
2126
2167
|
q: 0,
|
|
2127
|
-
|
|
2168
|
+
A: 0,
|
|
2128
2169
|
ja: count,
|
|
2129
|
-
|
|
2170
|
+
P: map,
|
|
2130
2171
|
d: [],
|
|
2131
2172
|
i: [],
|
|
2132
2173
|
ka: options == null ? void 0 : options.from,
|
|
@@ -2155,20 +2196,20 @@ function updateRepeat() {
|
|
|
2155
2196
|
return;
|
|
2156
2197
|
}
|
|
2157
2198
|
const to = from + newLen;
|
|
2158
|
-
const prevTo = this.
|
|
2199
|
+
const prevTo = this.A + this.q;
|
|
2159
2200
|
if (this.q === 0 && this.d[0])
|
|
2160
2201
|
this.d[0].dispose();
|
|
2161
2202
|
for (let i = to; i < prevTo; i++)
|
|
2162
|
-
this.d[i - this.
|
|
2163
|
-
if (this.
|
|
2164
|
-
let i = this.
|
|
2203
|
+
this.d[i - this.A].dispose();
|
|
2204
|
+
if (this.A < from) {
|
|
2205
|
+
let i = this.A;
|
|
2165
2206
|
while (i < from && i < this.q)
|
|
2166
2207
|
this.d[i++].dispose();
|
|
2167
|
-
this.d.splice(0, from - this.
|
|
2168
|
-
this.i.splice(0, from - this.
|
|
2169
|
-
} else if (this.
|
|
2170
|
-
let i = prevTo - this.
|
|
2171
|
-
let difference = this.
|
|
2208
|
+
this.d.splice(0, from - this.A);
|
|
2209
|
+
this.i.splice(0, from - this.A);
|
|
2210
|
+
} else if (this.A > from) {
|
|
2211
|
+
let i = prevTo - this.A - 1;
|
|
2212
|
+
let difference = this.A - from;
|
|
2172
2213
|
this.d.length = this.i.length = newLen;
|
|
2173
2214
|
while (i >= difference) {
|
|
2174
2215
|
this.d[i] = this.d[i - difference];
|
|
@@ -2178,7 +2219,7 @@ function updateRepeat() {
|
|
|
2178
2219
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2179
2220
|
this.i[i2] = compute(
|
|
2180
2221
|
this.d[i2] = new Owner(),
|
|
2181
|
-
() => this.
|
|
2222
|
+
() => this.P(i2 + from),
|
|
2182
2223
|
null
|
|
2183
2224
|
);
|
|
2184
2225
|
}
|
|
@@ -2186,12 +2227,12 @@ function updateRepeat() {
|
|
|
2186
2227
|
for (let i = prevTo; i < to; i++) {
|
|
2187
2228
|
this.i[i - from] = compute(
|
|
2188
2229
|
this.d[i - from] = new Owner(),
|
|
2189
|
-
() => this.
|
|
2230
|
+
() => this.P(i),
|
|
2190
2231
|
null
|
|
2191
2232
|
);
|
|
2192
2233
|
}
|
|
2193
2234
|
this.i = this.i.slice(0, newLen);
|
|
2194
|
-
this.
|
|
2235
|
+
this.A = from;
|
|
2195
2236
|
this.q = newLen;
|
|
2196
2237
|
});
|
|
2197
2238
|
return this.i;
|
|
@@ -2270,12 +2311,12 @@ var ConditionalQueue = class extends Queue {
|
|
|
2270
2311
|
}
|
|
2271
2312
|
};
|
|
2272
2313
|
var CollectionQueue = class extends Queue {
|
|
2273
|
-
|
|
2314
|
+
I;
|
|
2274
2315
|
d = /* @__PURE__ */ new Set();
|
|
2275
2316
|
u = new Computation(false, null, { pureWrite: true });
|
|
2276
2317
|
constructor(type) {
|
|
2277
2318
|
super();
|
|
2278
|
-
this.
|
|
2319
|
+
this.I = type;
|
|
2279
2320
|
}
|
|
2280
2321
|
run(type) {
|
|
2281
2322
|
if (!type || this.u.read())
|
|
@@ -2285,9 +2326,9 @@ var CollectionQueue = class extends Queue {
|
|
|
2285
2326
|
notify(node, type, flags) {
|
|
2286
2327
|
if (ActiveTransition && ActiveTransition.p.has(this))
|
|
2287
2328
|
return ActiveTransition.p.get(this).notify(node, type, flags);
|
|
2288
|
-
if (!(type & this.
|
|
2329
|
+
if (!(type & this.I))
|
|
2289
2330
|
return super.notify(node, type, flags);
|
|
2290
|
-
if (flags & this.
|
|
2331
|
+
if (flags & this.I) {
|
|
2291
2332
|
this.d.add(node);
|
|
2292
2333
|
if (this.d.size === 1)
|
|
2293
2334
|
this.u.write(true);
|
|
@@ -2296,11 +2337,11 @@ var CollectionQueue = class extends Queue {
|
|
|
2296
2337
|
if (this.d.size === 0)
|
|
2297
2338
|
this.u.write(false);
|
|
2298
2339
|
}
|
|
2299
|
-
type &= ~this.
|
|
2340
|
+
type &= ~this.I;
|
|
2300
2341
|
return type ? super.notify(node, type, flags) : true;
|
|
2301
2342
|
}
|
|
2302
2343
|
merge(queue) {
|
|
2303
|
-
queue.d.forEach((n) => this.notify(n, this.
|
|
2344
|
+
queue.d.forEach((n) => this.notify(n, this.I, this.I));
|
|
2304
2345
|
super.merge(queue);
|
|
2305
2346
|
}
|
|
2306
2347
|
};
|
|
@@ -2342,14 +2383,14 @@ function createSuspense(fn, fallback) {
|
|
|
2342
2383
|
function createErrorBoundary(fn, fallback) {
|
|
2343
2384
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2344
2385
|
let node = getTransitionSource(queue.d.values().next().value);
|
|
2345
|
-
return fallback(node.
|
|
2386
|
+
return fallback(node.L, () => {
|
|
2346
2387
|
var _a;
|
|
2347
2388
|
incrementClock();
|
|
2348
2389
|
for (let node2 of queue.d) {
|
|
2349
2390
|
if (ActiveTransition && !node2.e)
|
|
2350
2391
|
node2 = cloneGraph(node2);
|
|
2351
2392
|
node2.c = STATE_DIRTY;
|
|
2352
|
-
(_a = node2.m) == null ? void 0 : _a.enqueue(node2.
|
|
2393
|
+
(_a = node2.m) == null ? void 0 : _a.enqueue(node2.C, node2.E.bind(node2));
|
|
2353
2394
|
}
|
|
2354
2395
|
});
|
|
2355
2396
|
});
|
|
@@ -2456,5 +2497,5 @@ exports.runWithOwner = runWithOwner;
|
|
|
2456
2497
|
exports.setContext = setContext;
|
|
2457
2498
|
exports.snapshot = snapshot;
|
|
2458
2499
|
exports.transition = transition;
|
|
2459
|
-
exports.tryCatch = tryCatch;
|
|
2460
2500
|
exports.untrack = untrack;
|
|
2501
|
+
exports.useTransition = useTransition;
|