@vue/server-renderer 3.4.26 → 3.5.0-alpha.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.
|
|
2
|
+
* @vue/server-renderer v3.5.0-alpha.2
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -420,123 +420,250 @@ class EffectScope {
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
function recordEffectScope(effect, scope = activeEffectScope) {
|
|
424
|
-
if (scope && scope.active) {
|
|
425
|
-
scope.effects.push(effect);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
423
|
function getCurrentScope() {
|
|
429
424
|
return activeEffectScope;
|
|
430
425
|
}
|
|
431
426
|
|
|
432
|
-
let
|
|
427
|
+
let activeSub;
|
|
433
428
|
class ReactiveEffect {
|
|
434
|
-
constructor(fn
|
|
429
|
+
constructor(fn) {
|
|
435
430
|
this.fn = fn;
|
|
436
|
-
this.trigger = trigger;
|
|
437
|
-
this.scheduler = scheduler;
|
|
438
|
-
this.active = true;
|
|
439
|
-
this.deps = [];
|
|
440
431
|
/**
|
|
441
432
|
* @internal
|
|
442
433
|
*/
|
|
443
|
-
this.
|
|
434
|
+
this.deps = void 0;
|
|
444
435
|
/**
|
|
445
436
|
* @internal
|
|
446
437
|
*/
|
|
447
|
-
this.
|
|
438
|
+
this.depsTail = void 0;
|
|
448
439
|
/**
|
|
449
440
|
* @internal
|
|
450
441
|
*/
|
|
451
|
-
this.
|
|
442
|
+
this.flags = 1 | 4;
|
|
452
443
|
/**
|
|
453
444
|
* @internal
|
|
454
445
|
*/
|
|
455
|
-
this.
|
|
446
|
+
this.nextEffect = void 0;
|
|
456
447
|
/**
|
|
457
448
|
* @internal
|
|
458
449
|
*/
|
|
459
|
-
this.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
|
464
|
-
this._dirtyLevel = 1;
|
|
465
|
-
pauseTracking();
|
|
466
|
-
for (let i = 0; i < this._depsLength; i++) {
|
|
467
|
-
const dep = this.deps[i];
|
|
468
|
-
if (dep.computed) {
|
|
469
|
-
triggerComputed(dep.computed);
|
|
470
|
-
if (this._dirtyLevel >= 4) {
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
if (this._dirtyLevel === 1) {
|
|
476
|
-
this._dirtyLevel = 0;
|
|
477
|
-
}
|
|
478
|
-
resetTracking();
|
|
450
|
+
this.cleanup = void 0;
|
|
451
|
+
this.scheduler = void 0;
|
|
452
|
+
if (activeEffectScope && activeEffectScope.active) {
|
|
453
|
+
activeEffectScope.effects.push(this);
|
|
479
454
|
}
|
|
480
|
-
return this._dirtyLevel >= 4;
|
|
481
455
|
}
|
|
482
|
-
|
|
483
|
-
|
|
456
|
+
/**
|
|
457
|
+
* @internal
|
|
458
|
+
*/
|
|
459
|
+
notify() {
|
|
460
|
+
if (this.flags & 2 && !(this.flags & 32)) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (this.flags & 64) {
|
|
464
|
+
return this.trigger();
|
|
465
|
+
}
|
|
466
|
+
if (!(this.flags & 8)) {
|
|
467
|
+
this.flags |= 8;
|
|
468
|
+
this.nextEffect = batchedEffect;
|
|
469
|
+
batchedEffect = this;
|
|
470
|
+
}
|
|
484
471
|
}
|
|
485
472
|
run() {
|
|
486
|
-
this.
|
|
487
|
-
if (!this.active) {
|
|
473
|
+
if (!(this.flags & 1)) {
|
|
488
474
|
return this.fn();
|
|
489
475
|
}
|
|
490
|
-
|
|
491
|
-
|
|
476
|
+
this.flags |= 2;
|
|
477
|
+
cleanupEffect(this);
|
|
478
|
+
prepareDeps(this);
|
|
479
|
+
const prevEffect = activeSub;
|
|
480
|
+
const prevShouldTrack = shouldTrack;
|
|
481
|
+
activeSub = this;
|
|
482
|
+
shouldTrack = true;
|
|
492
483
|
try {
|
|
493
|
-
shouldTrack = true;
|
|
494
|
-
activeEffect = this;
|
|
495
|
-
this._runnings++;
|
|
496
|
-
preCleanupEffect(this);
|
|
497
484
|
return this.fn();
|
|
498
485
|
} finally {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
486
|
+
if (activeSub !== this) {
|
|
487
|
+
warn$2(
|
|
488
|
+
"Active effect was not restored correctly - this is likely a Vue internal bug."
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
cleanupDeps(this);
|
|
492
|
+
activeSub = prevEffect;
|
|
493
|
+
shouldTrack = prevShouldTrack;
|
|
494
|
+
this.flags &= ~2;
|
|
503
495
|
}
|
|
504
496
|
}
|
|
505
497
|
stop() {
|
|
506
|
-
if (this.
|
|
507
|
-
|
|
508
|
-
|
|
498
|
+
if (this.flags & 1) {
|
|
499
|
+
for (let link = this.deps; link; link = link.nextDep) {
|
|
500
|
+
removeSub(link);
|
|
501
|
+
}
|
|
502
|
+
this.deps = this.depsTail = void 0;
|
|
503
|
+
cleanupEffect(this);
|
|
509
504
|
this.onStop && this.onStop();
|
|
510
|
-
this.
|
|
505
|
+
this.flags &= ~1;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
trigger() {
|
|
509
|
+
if (this.scheduler) {
|
|
510
|
+
this.scheduler();
|
|
511
|
+
} else {
|
|
512
|
+
this.runIfDirty();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* @internal
|
|
517
|
+
*/
|
|
518
|
+
runIfDirty() {
|
|
519
|
+
if (isDirty(this)) {
|
|
520
|
+
this.run();
|
|
511
521
|
}
|
|
512
522
|
}
|
|
523
|
+
get dirty() {
|
|
524
|
+
return isDirty(this);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
let batchDepth = 0;
|
|
528
|
+
let batchedEffect;
|
|
529
|
+
function startBatch() {
|
|
530
|
+
batchDepth++;
|
|
513
531
|
}
|
|
514
|
-
function
|
|
515
|
-
|
|
532
|
+
function endBatch() {
|
|
533
|
+
if (batchDepth > 1) {
|
|
534
|
+
batchDepth--;
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
let error;
|
|
538
|
+
while (batchedEffect) {
|
|
539
|
+
let e = batchedEffect;
|
|
540
|
+
batchedEffect = void 0;
|
|
541
|
+
while (e) {
|
|
542
|
+
const next = e.nextEffect;
|
|
543
|
+
e.nextEffect = void 0;
|
|
544
|
+
e.flags &= ~8;
|
|
545
|
+
if (e.flags & 1) {
|
|
546
|
+
try {
|
|
547
|
+
e.trigger();
|
|
548
|
+
} catch (err) {
|
|
549
|
+
if (!error)
|
|
550
|
+
error = err;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
e = next;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
batchDepth--;
|
|
557
|
+
if (error)
|
|
558
|
+
throw error;
|
|
516
559
|
}
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
|
|
560
|
+
function prepareDeps(sub) {
|
|
561
|
+
for (let link = sub.deps; link; link = link.nextDep) {
|
|
562
|
+
link.version = -1;
|
|
563
|
+
link.prevActiveLink = link.dep.activeLink;
|
|
564
|
+
link.dep.activeLink = link;
|
|
565
|
+
}
|
|
520
566
|
}
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
567
|
+
function cleanupDeps(sub) {
|
|
568
|
+
let head;
|
|
569
|
+
let tail = sub.depsTail;
|
|
570
|
+
for (let link = tail; link; link = link.prevDep) {
|
|
571
|
+
if (link.version === -1) {
|
|
572
|
+
if (link === tail)
|
|
573
|
+
tail = link.prevDep;
|
|
574
|
+
removeSub(link);
|
|
575
|
+
removeDep(link);
|
|
576
|
+
} else {
|
|
577
|
+
head = link;
|
|
578
|
+
}
|
|
579
|
+
link.dep.activeLink = link.prevActiveLink;
|
|
580
|
+
link.prevActiveLink = void 0;
|
|
581
|
+
}
|
|
582
|
+
sub.deps = head;
|
|
583
|
+
sub.depsTail = tail;
|
|
584
|
+
}
|
|
585
|
+
function isDirty(sub) {
|
|
586
|
+
for (let link = sub.deps; link; link = link.nextDep) {
|
|
587
|
+
if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
|
|
588
|
+
return true;
|
|
525
589
|
}
|
|
526
|
-
effect2.deps.length = effect2._depsLength;
|
|
527
590
|
}
|
|
591
|
+
if (sub._dirty) {
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
return false;
|
|
528
595
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
596
|
+
function refreshComputed(computed) {
|
|
597
|
+
if (computed.flags & 2) {
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
if (computed.flags & 4 && !(computed.flags & 16)) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
computed.flags &= ~16;
|
|
604
|
+
if (computed.globalVersion === globalVersion) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
computed.globalVersion = globalVersion;
|
|
608
|
+
const dep = computed.dep;
|
|
609
|
+
computed.flags |= 2;
|
|
610
|
+
if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
|
|
611
|
+
computed.flags &= ~2;
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const prevSub = activeSub;
|
|
615
|
+
const prevShouldTrack = shouldTrack;
|
|
616
|
+
activeSub = computed;
|
|
617
|
+
shouldTrack = true;
|
|
618
|
+
try {
|
|
619
|
+
prepareDeps(computed);
|
|
620
|
+
const value = computed.fn();
|
|
621
|
+
if (dep.version === 0 || hasChanged(value, computed._value)) {
|
|
622
|
+
computed._value = value;
|
|
623
|
+
dep.version++;
|
|
535
624
|
}
|
|
625
|
+
} catch (err) {
|
|
626
|
+
dep.version++;
|
|
627
|
+
throw err;
|
|
628
|
+
} finally {
|
|
629
|
+
activeSub = prevSub;
|
|
630
|
+
shouldTrack = prevShouldTrack;
|
|
631
|
+
cleanupDeps(computed);
|
|
632
|
+
computed.flags &= ~2;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function removeSub(link) {
|
|
636
|
+
const { dep, prevSub, nextSub } = link;
|
|
637
|
+
if (prevSub) {
|
|
638
|
+
prevSub.nextSub = nextSub;
|
|
639
|
+
link.prevSub = void 0;
|
|
640
|
+
}
|
|
641
|
+
if (nextSub) {
|
|
642
|
+
nextSub.prevSub = prevSub;
|
|
643
|
+
link.nextSub = void 0;
|
|
644
|
+
}
|
|
645
|
+
if (dep.subs === link) {
|
|
646
|
+
dep.subs = prevSub;
|
|
647
|
+
}
|
|
648
|
+
if (!dep.subs && dep.computed) {
|
|
649
|
+
dep.computed.flags &= ~4;
|
|
650
|
+
for (let l = dep.computed.deps; l; l = l.nextDep) {
|
|
651
|
+
removeSub(l);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function removeDep(link) {
|
|
656
|
+
const { prevDep, nextDep } = link;
|
|
657
|
+
if (prevDep) {
|
|
658
|
+
prevDep.nextDep = nextDep;
|
|
659
|
+
link.prevDep = void 0;
|
|
660
|
+
}
|
|
661
|
+
if (nextDep) {
|
|
662
|
+
nextDep.prevDep = prevDep;
|
|
663
|
+
link.nextDep = void 0;
|
|
536
664
|
}
|
|
537
665
|
}
|
|
538
666
|
let shouldTrack = true;
|
|
539
|
-
let pauseScheduleStack = 0;
|
|
540
667
|
const trackStack = [];
|
|
541
668
|
function pauseTracking() {
|
|
542
669
|
trackStack.push(shouldTrack);
|
|
@@ -546,188 +673,410 @@ function resetTracking() {
|
|
|
546
673
|
const last = trackStack.pop();
|
|
547
674
|
shouldTrack = last === void 0 ? true : last;
|
|
548
675
|
}
|
|
549
|
-
function
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
676
|
+
function cleanupEffect(e) {
|
|
677
|
+
const { cleanup } = e;
|
|
678
|
+
e.cleanup = void 0;
|
|
679
|
+
if (cleanup) {
|
|
680
|
+
const prevSub = activeSub;
|
|
681
|
+
activeSub = void 0;
|
|
682
|
+
try {
|
|
683
|
+
cleanup();
|
|
684
|
+
} finally {
|
|
685
|
+
activeSub = prevSub;
|
|
686
|
+
}
|
|
556
687
|
}
|
|
557
688
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
689
|
+
|
|
690
|
+
let globalVersion = 0;
|
|
691
|
+
class Dep {
|
|
692
|
+
constructor(computed) {
|
|
693
|
+
this.computed = computed;
|
|
694
|
+
this.version = 0;
|
|
695
|
+
/**
|
|
696
|
+
* Link between this dep and the current active effect
|
|
697
|
+
*/
|
|
698
|
+
this.activeLink = void 0;
|
|
699
|
+
/**
|
|
700
|
+
* Doubly linked list representing the subscribing effects (tail)
|
|
701
|
+
*/
|
|
702
|
+
this.subs = void 0;
|
|
571
703
|
{
|
|
572
|
-
|
|
704
|
+
this.subsHead = void 0;
|
|
573
705
|
}
|
|
574
706
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
707
|
+
track(debugInfo) {
|
|
708
|
+
if (!activeSub || !shouldTrack) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
let link = this.activeLink;
|
|
712
|
+
if (link === void 0 || link.sub !== activeSub) {
|
|
713
|
+
link = this.activeLink = {
|
|
714
|
+
dep: this,
|
|
715
|
+
sub: activeSub,
|
|
716
|
+
version: this.version,
|
|
717
|
+
nextDep: void 0,
|
|
718
|
+
prevDep: void 0,
|
|
719
|
+
nextSub: void 0,
|
|
720
|
+
prevSub: void 0,
|
|
721
|
+
prevActiveLink: void 0
|
|
722
|
+
};
|
|
723
|
+
if (!activeSub.deps) {
|
|
724
|
+
activeSub.deps = activeSub.depsTail = link;
|
|
725
|
+
} else {
|
|
726
|
+
link.prevDep = activeSub.depsTail;
|
|
727
|
+
activeSub.depsTail.nextDep = link;
|
|
728
|
+
activeSub.depsTail = link;
|
|
729
|
+
}
|
|
730
|
+
if (activeSub.flags & 4) {
|
|
731
|
+
addSub(link);
|
|
732
|
+
}
|
|
733
|
+
} else if (link.version === -1) {
|
|
734
|
+
link.version = this.version;
|
|
735
|
+
if (link.nextDep) {
|
|
736
|
+
const next = link.nextDep;
|
|
737
|
+
next.prevDep = link.prevDep;
|
|
738
|
+
if (link.prevDep) {
|
|
739
|
+
link.prevDep.nextDep = next;
|
|
740
|
+
}
|
|
741
|
+
link.prevDep = activeSub.depsTail;
|
|
742
|
+
link.nextDep = void 0;
|
|
743
|
+
activeSub.depsTail.nextDep = link;
|
|
744
|
+
activeSub.depsTail = link;
|
|
745
|
+
if (activeSub.deps === link) {
|
|
746
|
+
activeSub.deps = next;
|
|
747
|
+
}
|
|
589
748
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
749
|
+
}
|
|
750
|
+
if (activeSub.onTrack) {
|
|
751
|
+
activeSub.onTrack(
|
|
752
|
+
extend(
|
|
753
|
+
{
|
|
754
|
+
effect: activeSub
|
|
755
|
+
},
|
|
756
|
+
debugInfo
|
|
757
|
+
)
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
return link;
|
|
761
|
+
}
|
|
762
|
+
trigger(debugInfo) {
|
|
763
|
+
this.version++;
|
|
764
|
+
globalVersion++;
|
|
765
|
+
this.notify(debugInfo);
|
|
766
|
+
}
|
|
767
|
+
notify(debugInfo) {
|
|
768
|
+
startBatch();
|
|
769
|
+
try {
|
|
770
|
+
if (true) {
|
|
771
|
+
for (let head = this.subsHead; head; head = head.nextSub) {
|
|
772
|
+
if (head.sub.onTrigger && !(head.sub.flags & 8)) {
|
|
773
|
+
head.sub.onTrigger(
|
|
774
|
+
extend(
|
|
775
|
+
{
|
|
776
|
+
effect: head.sub
|
|
777
|
+
},
|
|
778
|
+
debugInfo
|
|
779
|
+
)
|
|
780
|
+
);
|
|
781
|
+
}
|
|
595
782
|
}
|
|
596
783
|
}
|
|
784
|
+
for (let link = this.subs; link; link = link.prevSub) {
|
|
785
|
+
link.sub.notify();
|
|
786
|
+
}
|
|
787
|
+
} finally {
|
|
788
|
+
endBatch();
|
|
597
789
|
}
|
|
598
790
|
}
|
|
599
|
-
resetScheduling();
|
|
600
791
|
}
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
|
|
792
|
+
function addSub(link) {
|
|
793
|
+
const computed = link.dep.computed;
|
|
794
|
+
if (computed && !link.dep.subs) {
|
|
795
|
+
computed.flags |= 4 | 16;
|
|
796
|
+
for (let l = computed.deps; l; l = l.nextDep) {
|
|
797
|
+
addSub(l);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
const currentTail = link.dep.subs;
|
|
801
|
+
if (currentTail !== link) {
|
|
802
|
+
link.prevSub = currentTail;
|
|
803
|
+
if (currentTail)
|
|
804
|
+
currentTail.nextSub = link;
|
|
805
|
+
}
|
|
806
|
+
if (link.dep.subsHead === void 0) {
|
|
807
|
+
link.dep.subsHead = link;
|
|
808
|
+
}
|
|
809
|
+
link.dep.subs = link;
|
|
810
|
+
}
|
|
609
811
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
610
|
-
const ITERATE_KEY = Symbol("iterate" );
|
|
611
|
-
const MAP_KEY_ITERATE_KEY = Symbol("Map
|
|
812
|
+
const ITERATE_KEY = Symbol("Object iterate" );
|
|
813
|
+
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
|
|
814
|
+
const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
|
|
612
815
|
function track(target, type, key) {
|
|
613
|
-
if (shouldTrack &&
|
|
816
|
+
if (shouldTrack && activeSub) {
|
|
614
817
|
let depsMap = targetMap.get(target);
|
|
615
818
|
if (!depsMap) {
|
|
616
819
|
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
617
820
|
}
|
|
618
821
|
let dep = depsMap.get(key);
|
|
619
822
|
if (!dep) {
|
|
620
|
-
depsMap.set(key, dep =
|
|
823
|
+
depsMap.set(key, dep = new Dep());
|
|
621
824
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
dep,
|
|
625
|
-
{
|
|
825
|
+
{
|
|
826
|
+
dep.track({
|
|
626
827
|
target,
|
|
627
828
|
type,
|
|
628
829
|
key
|
|
629
|
-
}
|
|
630
|
-
|
|
830
|
+
});
|
|
831
|
+
}
|
|
631
832
|
}
|
|
632
833
|
}
|
|
633
834
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
634
835
|
const depsMap = targetMap.get(target);
|
|
635
836
|
if (!depsMap) {
|
|
837
|
+
globalVersion++;
|
|
636
838
|
return;
|
|
637
839
|
}
|
|
638
840
|
let deps = [];
|
|
639
841
|
if (type === "clear") {
|
|
640
842
|
deps = [...depsMap.values()];
|
|
641
|
-
} else if (key === "length" && isArray(target)) {
|
|
642
|
-
const newLength = Number(newValue);
|
|
643
|
-
depsMap.forEach((dep, key2) => {
|
|
644
|
-
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
|
645
|
-
deps.push(dep);
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
843
|
} else {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (!
|
|
655
|
-
deps.push(
|
|
656
|
-
if (isMap(target)) {
|
|
657
|
-
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
658
|
-
}
|
|
659
|
-
} else if (isIntegerKey(key)) {
|
|
660
|
-
deps.push(depsMap.get("length"));
|
|
844
|
+
const targetIsArray = isArray(target);
|
|
845
|
+
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
846
|
+
if (targetIsArray && key === "length") {
|
|
847
|
+
const newLength = Number(newValue);
|
|
848
|
+
depsMap.forEach((dep, key2) => {
|
|
849
|
+
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
|
|
850
|
+
deps.push(dep);
|
|
661
851
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
852
|
+
});
|
|
853
|
+
} else {
|
|
854
|
+
const push = (dep) => dep && deps.push(dep);
|
|
855
|
+
if (key !== void 0) {
|
|
856
|
+
push(depsMap.get(key));
|
|
857
|
+
}
|
|
858
|
+
if (isArrayIndex) {
|
|
859
|
+
push(depsMap.get(ARRAY_ITERATE_KEY));
|
|
860
|
+
}
|
|
861
|
+
switch (type) {
|
|
862
|
+
case "add":
|
|
863
|
+
if (!targetIsArray) {
|
|
864
|
+
push(depsMap.get(ITERATE_KEY));
|
|
865
|
+
if (isMap(target)) {
|
|
866
|
+
push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
867
|
+
}
|
|
868
|
+
} else if (isArrayIndex) {
|
|
869
|
+
push(depsMap.get("length"));
|
|
870
|
+
}
|
|
871
|
+
break;
|
|
872
|
+
case "delete":
|
|
873
|
+
if (!targetIsArray) {
|
|
874
|
+
push(depsMap.get(ITERATE_KEY));
|
|
875
|
+
if (isMap(target)) {
|
|
876
|
+
push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
break;
|
|
880
|
+
case "set":
|
|
666
881
|
if (isMap(target)) {
|
|
667
|
-
|
|
882
|
+
push(depsMap.get(ITERATE_KEY));
|
|
668
883
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
case "set":
|
|
672
|
-
if (isMap(target)) {
|
|
673
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
674
|
-
}
|
|
675
|
-
break;
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
676
886
|
}
|
|
677
887
|
}
|
|
678
|
-
|
|
888
|
+
startBatch();
|
|
679
889
|
for (const dep of deps) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
890
|
+
{
|
|
891
|
+
dep.trigger({
|
|
892
|
+
target,
|
|
893
|
+
type,
|
|
894
|
+
key,
|
|
895
|
+
newValue,
|
|
896
|
+
oldValue,
|
|
897
|
+
oldTarget
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
endBatch();
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function reactiveReadArray(array) {
|
|
905
|
+
const raw = toRaw(array);
|
|
906
|
+
if (raw === array)
|
|
907
|
+
return raw;
|
|
908
|
+
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
909
|
+
return isShallow(array) ? raw : raw.map(toReactive);
|
|
910
|
+
}
|
|
911
|
+
function shallowReadArray(arr) {
|
|
912
|
+
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
913
|
+
return arr;
|
|
914
|
+
}
|
|
915
|
+
const arrayInstrumentations = {
|
|
916
|
+
__proto__: null,
|
|
917
|
+
[Symbol.iterator]() {
|
|
918
|
+
return iterator(this, Symbol.iterator, toReactive);
|
|
919
|
+
},
|
|
920
|
+
concat(...args) {
|
|
921
|
+
return reactiveReadArray(this).concat(
|
|
922
|
+
...args.map((x) => reactiveReadArray(x))
|
|
923
|
+
);
|
|
924
|
+
},
|
|
925
|
+
entries() {
|
|
926
|
+
return iterator(this, "entries", (value) => {
|
|
927
|
+
value[1] = toReactive(value[1]);
|
|
928
|
+
return value;
|
|
929
|
+
});
|
|
930
|
+
},
|
|
931
|
+
every(fn, thisArg) {
|
|
932
|
+
return apply(this, "every", fn, thisArg);
|
|
933
|
+
},
|
|
934
|
+
filter(fn, thisArg) {
|
|
935
|
+
const result = apply(this, "filter", fn, thisArg);
|
|
936
|
+
return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
|
|
937
|
+
},
|
|
938
|
+
find(fn, thisArg) {
|
|
939
|
+
const result = apply(this, "find", fn, thisArg);
|
|
940
|
+
return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
|
|
941
|
+
},
|
|
942
|
+
findIndex(fn, thisArg) {
|
|
943
|
+
return apply(this, "findIndex", fn, thisArg);
|
|
944
|
+
},
|
|
945
|
+
findLast(fn, thisArg) {
|
|
946
|
+
const result = apply(this, "findLast", fn, thisArg);
|
|
947
|
+
return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
|
|
948
|
+
},
|
|
949
|
+
findLastIndex(fn, thisArg) {
|
|
950
|
+
return apply(this, "findLastIndex", fn, thisArg);
|
|
951
|
+
},
|
|
952
|
+
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
|
|
953
|
+
forEach(fn, thisArg) {
|
|
954
|
+
return apply(this, "forEach", fn, thisArg);
|
|
955
|
+
},
|
|
956
|
+
includes(...args) {
|
|
957
|
+
return searchProxy(this, "includes", args);
|
|
958
|
+
},
|
|
959
|
+
indexOf(...args) {
|
|
960
|
+
return searchProxy(this, "indexOf", args);
|
|
961
|
+
},
|
|
962
|
+
join(separator) {
|
|
963
|
+
return reactiveReadArray(this).join(separator);
|
|
964
|
+
},
|
|
965
|
+
// keys() iterator only reads `length`, no optimisation required
|
|
966
|
+
lastIndexOf(...args) {
|
|
967
|
+
return searchProxy(this, "lastIndexOf", args);
|
|
968
|
+
},
|
|
969
|
+
map(fn, thisArg) {
|
|
970
|
+
return apply(this, "map", fn, thisArg);
|
|
971
|
+
},
|
|
972
|
+
pop() {
|
|
973
|
+
return noTracking(this, "pop");
|
|
974
|
+
},
|
|
975
|
+
push(...args) {
|
|
976
|
+
return noTracking(this, "push", args);
|
|
977
|
+
},
|
|
978
|
+
reduce(fn, ...args) {
|
|
979
|
+
return reduce(this, "reduce", fn, args);
|
|
980
|
+
},
|
|
981
|
+
reduceRight(fn, ...args) {
|
|
982
|
+
return reduce(this, "reduceRight", fn, args);
|
|
983
|
+
},
|
|
984
|
+
shift() {
|
|
985
|
+
return noTracking(this, "shift");
|
|
986
|
+
},
|
|
987
|
+
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
|
|
988
|
+
some(fn, thisArg) {
|
|
989
|
+
return apply(this, "some", fn, thisArg);
|
|
990
|
+
},
|
|
991
|
+
splice(...args) {
|
|
992
|
+
return noTracking(this, "splice", args);
|
|
993
|
+
},
|
|
994
|
+
toReversed() {
|
|
995
|
+
return reactiveReadArray(this).toReversed();
|
|
996
|
+
},
|
|
997
|
+
toSorted(comparer) {
|
|
998
|
+
return reactiveReadArray(this).toSorted(comparer);
|
|
999
|
+
},
|
|
1000
|
+
toSpliced(...args) {
|
|
1001
|
+
return reactiveReadArray(this).toSpliced(...args);
|
|
1002
|
+
},
|
|
1003
|
+
unshift(...args) {
|
|
1004
|
+
return noTracking(this, "unshift", args);
|
|
1005
|
+
},
|
|
1006
|
+
values() {
|
|
1007
|
+
return iterator(this, "values", toReactive);
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
function iterator(self, method, wrapValue) {
|
|
1011
|
+
const arr = shallowReadArray(self);
|
|
1012
|
+
const iter = arr[method]();
|
|
1013
|
+
if (arr !== self && !isShallow(self)) {
|
|
1014
|
+
iter._next = iter.next;
|
|
1015
|
+
iter.next = () => {
|
|
1016
|
+
const result = iter._next();
|
|
1017
|
+
if (result.value) {
|
|
1018
|
+
result.value = wrapValue(result.value);
|
|
1019
|
+
}
|
|
1020
|
+
return result;
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
return iter;
|
|
1024
|
+
}
|
|
1025
|
+
function apply(self, method, fn, thisArg) {
|
|
1026
|
+
const arr = shallowReadArray(self);
|
|
1027
|
+
let wrappedFn = fn;
|
|
1028
|
+
if (arr !== self) {
|
|
1029
|
+
if (!isShallow(self)) {
|
|
1030
|
+
wrappedFn = function(item, index) {
|
|
1031
|
+
return fn.call(this, toReactive(item), index, self);
|
|
1032
|
+
};
|
|
1033
|
+
} else if (fn.length > 2) {
|
|
1034
|
+
wrappedFn = function(item, index) {
|
|
1035
|
+
return fn.call(this, item, index, self);
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return arr[method](wrappedFn, thisArg);
|
|
1040
|
+
}
|
|
1041
|
+
function reduce(self, method, fn, args) {
|
|
1042
|
+
const arr = shallowReadArray(self);
|
|
1043
|
+
let wrappedFn = fn;
|
|
1044
|
+
if (arr !== self) {
|
|
1045
|
+
if (!isShallow(self)) {
|
|
1046
|
+
wrappedFn = function(acc, item, index) {
|
|
1047
|
+
return fn.call(this, acc, toReactive(item), index, self);
|
|
1048
|
+
};
|
|
1049
|
+
} else if (fn.length > 3) {
|
|
1050
|
+
wrappedFn = function(acc, item, index) {
|
|
1051
|
+
return fn.call(this, acc, item, index, self);
|
|
1052
|
+
};
|
|
693
1053
|
}
|
|
694
1054
|
}
|
|
695
|
-
|
|
1055
|
+
return arr[method](wrappedFn, ...args);
|
|
1056
|
+
}
|
|
1057
|
+
function searchProxy(self, method, args) {
|
|
1058
|
+
const arr = toRaw(self);
|
|
1059
|
+
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
1060
|
+
const res = arr[method](...args);
|
|
1061
|
+
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
1062
|
+
args[0] = toRaw(args[0]);
|
|
1063
|
+
return arr[method](...args);
|
|
1064
|
+
}
|
|
1065
|
+
return res;
|
|
1066
|
+
}
|
|
1067
|
+
function noTracking(self, method, args = []) {
|
|
1068
|
+
pauseTracking();
|
|
1069
|
+
startBatch();
|
|
1070
|
+
const res = toRaw(self)[method].apply(self, args);
|
|
1071
|
+
endBatch();
|
|
1072
|
+
resetTracking();
|
|
1073
|
+
return res;
|
|
696
1074
|
}
|
|
697
1075
|
|
|
698
1076
|
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
699
1077
|
const builtInSymbols = new Set(
|
|
700
1078
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
701
1079
|
);
|
|
702
|
-
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
703
|
-
function createArrayInstrumentations() {
|
|
704
|
-
const instrumentations = {};
|
|
705
|
-
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
706
|
-
instrumentations[key] = function(...args) {
|
|
707
|
-
const arr = toRaw(this);
|
|
708
|
-
for (let i = 0, l = this.length; i < l; i++) {
|
|
709
|
-
track(arr, "get", i + "");
|
|
710
|
-
}
|
|
711
|
-
const res = arr[key](...args);
|
|
712
|
-
if (res === -1 || res === false) {
|
|
713
|
-
return arr[key](...args.map(toRaw));
|
|
714
|
-
} else {
|
|
715
|
-
return res;
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
});
|
|
719
|
-
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
720
|
-
instrumentations[key] = function(...args) {
|
|
721
|
-
pauseTracking();
|
|
722
|
-
pauseScheduling();
|
|
723
|
-
const res = toRaw(this)[key].apply(this, args);
|
|
724
|
-
resetScheduling();
|
|
725
|
-
resetTracking();
|
|
726
|
-
return res;
|
|
727
|
-
};
|
|
728
|
-
});
|
|
729
|
-
return instrumentations;
|
|
730
|
-
}
|
|
731
1080
|
function hasOwnProperty(key) {
|
|
732
1081
|
if (!isSymbol(key))
|
|
733
1082
|
key = String(key);
|
|
@@ -758,14 +1107,22 @@ class BaseReactiveHandler {
|
|
|
758
1107
|
}
|
|
759
1108
|
const targetIsArray = isArray(target);
|
|
760
1109
|
if (!isReadonly2) {
|
|
761
|
-
|
|
762
|
-
|
|
1110
|
+
let fn;
|
|
1111
|
+
if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
|
1112
|
+
return fn;
|
|
763
1113
|
}
|
|
764
1114
|
if (key === "hasOwnProperty") {
|
|
765
1115
|
return hasOwnProperty;
|
|
766
1116
|
}
|
|
767
1117
|
}
|
|
768
|
-
const res = Reflect.get(
|
|
1118
|
+
const res = Reflect.get(
|
|
1119
|
+
target,
|
|
1120
|
+
key,
|
|
1121
|
+
// if this is a proxy wrapping a ref, return methods using the raw ref
|
|
1122
|
+
// as receiver so that we don't have to call `toRaw` on the ref in all
|
|
1123
|
+
// its class methods
|
|
1124
|
+
isRef(target) ? target : receiver
|
|
1125
|
+
);
|
|
769
1126
|
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
770
1127
|
return res;
|
|
771
1128
|
}
|
|
@@ -1264,106 +1621,8 @@ function markRaw(value) {
|
|
|
1264
1621
|
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
1265
1622
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1266
1623
|
|
|
1267
|
-
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
|
|
1268
|
-
class ComputedRefImpl {
|
|
1269
|
-
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1270
|
-
this.getter = getter;
|
|
1271
|
-
this._setter = _setter;
|
|
1272
|
-
this.dep = void 0;
|
|
1273
|
-
this.__v_isRef = true;
|
|
1274
|
-
this["__v_isReadonly"] = false;
|
|
1275
|
-
this.effect = new ReactiveEffect(
|
|
1276
|
-
() => getter(this._value),
|
|
1277
|
-
() => triggerRefValue(
|
|
1278
|
-
this,
|
|
1279
|
-
this.effect._dirtyLevel === 2 ? 2 : 3
|
|
1280
|
-
)
|
|
1281
|
-
);
|
|
1282
|
-
this.effect.computed = this;
|
|
1283
|
-
this.effect.active = this._cacheable = !isSSR;
|
|
1284
|
-
this["__v_isReadonly"] = isReadonly;
|
|
1285
|
-
}
|
|
1286
|
-
get value() {
|
|
1287
|
-
const self = toRaw(this);
|
|
1288
|
-
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
|
|
1289
|
-
triggerRefValue(self, 4);
|
|
1290
|
-
}
|
|
1291
|
-
trackRefValue(self);
|
|
1292
|
-
if (self.effect._dirtyLevel >= 2) {
|
|
1293
|
-
if (this._warnRecursive) {
|
|
1294
|
-
warn$2(COMPUTED_SIDE_EFFECT_WARN, `
|
|
1295
|
-
|
|
1296
|
-
getter: `, this.getter);
|
|
1297
|
-
}
|
|
1298
|
-
triggerRefValue(self, 2);
|
|
1299
|
-
}
|
|
1300
|
-
return self._value;
|
|
1301
|
-
}
|
|
1302
|
-
set value(newValue) {
|
|
1303
|
-
this._setter(newValue);
|
|
1304
|
-
}
|
|
1305
|
-
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
|
|
1306
|
-
get _dirty() {
|
|
1307
|
-
return this.effect.dirty;
|
|
1308
|
-
}
|
|
1309
|
-
set _dirty(v) {
|
|
1310
|
-
this.effect.dirty = v;
|
|
1311
|
-
}
|
|
1312
|
-
// #endregion
|
|
1313
|
-
}
|
|
1314
|
-
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
|
1315
|
-
let getter;
|
|
1316
|
-
let setter;
|
|
1317
|
-
const onlyGetter = isFunction(getterOrOptions);
|
|
1318
|
-
if (onlyGetter) {
|
|
1319
|
-
getter = getterOrOptions;
|
|
1320
|
-
setter = () => {
|
|
1321
|
-
warn$2("Write operation failed: computed value is readonly");
|
|
1322
|
-
} ;
|
|
1323
|
-
} else {
|
|
1324
|
-
getter = getterOrOptions.get;
|
|
1325
|
-
setter = getterOrOptions.set;
|
|
1326
|
-
}
|
|
1327
|
-
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1328
|
-
return cRef;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
function trackRefValue(ref2) {
|
|
1332
|
-
var _a;
|
|
1333
|
-
if (shouldTrack && activeEffect) {
|
|
1334
|
-
ref2 = toRaw(ref2);
|
|
1335
|
-
trackEffect(
|
|
1336
|
-
activeEffect,
|
|
1337
|
-
(_a = ref2.dep) != null ? _a : ref2.dep = createDep(
|
|
1338
|
-
() => ref2.dep = void 0,
|
|
1339
|
-
ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
|
1340
|
-
),
|
|
1341
|
-
{
|
|
1342
|
-
target: ref2,
|
|
1343
|
-
type: "get",
|
|
1344
|
-
key: "value"
|
|
1345
|
-
}
|
|
1346
|
-
);
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
|
|
1350
|
-
ref2 = toRaw(ref2);
|
|
1351
|
-
const dep = ref2.dep;
|
|
1352
|
-
if (dep) {
|
|
1353
|
-
triggerEffects(
|
|
1354
|
-
dep,
|
|
1355
|
-
dirtyLevel,
|
|
1356
|
-
{
|
|
1357
|
-
target: ref2,
|
|
1358
|
-
type: "set",
|
|
1359
|
-
key: "value",
|
|
1360
|
-
newValue: newVal
|
|
1361
|
-
}
|
|
1362
|
-
);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
1624
|
function isRef(r) {
|
|
1366
|
-
return
|
|
1625
|
+
return r ? r.__v_isRef === true : false;
|
|
1367
1626
|
}
|
|
1368
1627
|
function unref(ref2) {
|
|
1369
1628
|
return isRef(ref2) ? ref2.value : ref2;
|
|
@@ -1384,6 +1643,86 @@ function proxyRefs(objectWithRefs) {
|
|
|
1384
1643
|
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
1385
1644
|
}
|
|
1386
1645
|
|
|
1646
|
+
class ComputedRefImpl {
|
|
1647
|
+
constructor(fn, setter, isSSR) {
|
|
1648
|
+
this.fn = fn;
|
|
1649
|
+
this.setter = setter;
|
|
1650
|
+
/**
|
|
1651
|
+
* @internal
|
|
1652
|
+
*/
|
|
1653
|
+
this._value = void 0;
|
|
1654
|
+
/**
|
|
1655
|
+
* @internal
|
|
1656
|
+
*/
|
|
1657
|
+
this.dep = new Dep(this);
|
|
1658
|
+
/**
|
|
1659
|
+
* @internal
|
|
1660
|
+
*/
|
|
1661
|
+
this.__v_isRef = true;
|
|
1662
|
+
// A computed is also a subscriber that tracks other deps
|
|
1663
|
+
/**
|
|
1664
|
+
* @internal
|
|
1665
|
+
*/
|
|
1666
|
+
this.deps = void 0;
|
|
1667
|
+
/**
|
|
1668
|
+
* @internal
|
|
1669
|
+
*/
|
|
1670
|
+
this.depsTail = void 0;
|
|
1671
|
+
/**
|
|
1672
|
+
* @internal
|
|
1673
|
+
*/
|
|
1674
|
+
this.flags = 16;
|
|
1675
|
+
/**
|
|
1676
|
+
* @internal
|
|
1677
|
+
*/
|
|
1678
|
+
this.globalVersion = globalVersion - 1;
|
|
1679
|
+
// for backwards compat
|
|
1680
|
+
this.effect = this;
|
|
1681
|
+
this.__v_isReadonly = !setter;
|
|
1682
|
+
this.isSSR = isSSR;
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* @internal
|
|
1686
|
+
*/
|
|
1687
|
+
notify() {
|
|
1688
|
+
if (activeSub !== this) {
|
|
1689
|
+
this.flags |= 16;
|
|
1690
|
+
this.dep.notify();
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
get value() {
|
|
1694
|
+
const link = this.dep.track({
|
|
1695
|
+
target: this,
|
|
1696
|
+
type: "get",
|
|
1697
|
+
key: "value"
|
|
1698
|
+
}) ;
|
|
1699
|
+
refreshComputed(this);
|
|
1700
|
+
if (link) {
|
|
1701
|
+
link.version = this.dep.version;
|
|
1702
|
+
}
|
|
1703
|
+
return this._value;
|
|
1704
|
+
}
|
|
1705
|
+
set value(newValue) {
|
|
1706
|
+
if (this.setter) {
|
|
1707
|
+
this.setter(newValue);
|
|
1708
|
+
} else {
|
|
1709
|
+
warn$2("Write operation failed: computed value is readonly");
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
|
1714
|
+
let getter;
|
|
1715
|
+
let setter;
|
|
1716
|
+
if (isFunction(getterOrOptions)) {
|
|
1717
|
+
getter = getterOrOptions;
|
|
1718
|
+
} else {
|
|
1719
|
+
getter = getterOrOptions.get;
|
|
1720
|
+
setter = getterOrOptions.set;
|
|
1721
|
+
}
|
|
1722
|
+
const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
|
1723
|
+
return cRef;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1387
1726
|
const stack = [];
|
|
1388
1727
|
function pushWarningContext(vnode) {
|
|
1389
1728
|
stack.push(vnode);
|
|
@@ -1521,7 +1860,8 @@ const ErrorTypeStrings = {
|
|
|
1521
1860
|
[11]: "app warnHandler",
|
|
1522
1861
|
[12]: "ref function",
|
|
1523
1862
|
[13]: "async component loader",
|
|
1524
|
-
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
|
|
1863
|
+
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
|
|
1864
|
+
[15]: "app unmount cleanup function"
|
|
1525
1865
|
};
|
|
1526
1866
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
1527
1867
|
try {
|
|
@@ -1623,7 +1963,7 @@ function findInsertionIndex(id) {
|
|
|
1623
1963
|
const middle = start + end >>> 1;
|
|
1624
1964
|
const middleJob = queue[middle];
|
|
1625
1965
|
const middleJobId = getId(middleJob);
|
|
1626
|
-
if (middleJobId < id || middleJobId === id && middleJob.
|
|
1966
|
+
if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
|
|
1627
1967
|
start = middle + 1;
|
|
1628
1968
|
} else {
|
|
1629
1969
|
end = middle;
|
|
@@ -1632,15 +1972,21 @@ function findInsertionIndex(id) {
|
|
|
1632
1972
|
return start;
|
|
1633
1973
|
}
|
|
1634
1974
|
function queueJob(job) {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
|
|
1638
|
-
)) {
|
|
1975
|
+
var _a;
|
|
1976
|
+
if (!(job.flags & 1)) {
|
|
1639
1977
|
if (job.id == null) {
|
|
1640
1978
|
queue.push(job);
|
|
1979
|
+
} else if (
|
|
1980
|
+
// fast path when the job id is larger than the tail
|
|
1981
|
+
!(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
|
|
1982
|
+
) {
|
|
1983
|
+
queue.push(job);
|
|
1641
1984
|
} else {
|
|
1642
1985
|
queue.splice(findInsertionIndex(job.id), 0, job);
|
|
1643
1986
|
}
|
|
1987
|
+
if (!(job.flags & 4)) {
|
|
1988
|
+
job.flags |= 1;
|
|
1989
|
+
}
|
|
1644
1990
|
queueFlush();
|
|
1645
1991
|
}
|
|
1646
1992
|
}
|
|
@@ -1658,11 +2004,11 @@ function invalidateJob(job) {
|
|
|
1658
2004
|
}
|
|
1659
2005
|
function queuePostFlushCb(cb) {
|
|
1660
2006
|
if (!isArray(cb)) {
|
|
1661
|
-
if (!
|
|
1662
|
-
cb,
|
|
1663
|
-
cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
|
|
1664
|
-
)) {
|
|
2007
|
+
if (!(cb.flags & 1)) {
|
|
1665
2008
|
pendingPostFlushCbs.push(cb);
|
|
2009
|
+
if (!(cb.flags & 4)) {
|
|
2010
|
+
cb.flags |= 1;
|
|
2011
|
+
}
|
|
1666
2012
|
}
|
|
1667
2013
|
} else {
|
|
1668
2014
|
pendingPostFlushCbs.push(...cb);
|
|
@@ -1675,7 +2021,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
|
|
|
1675
2021
|
}
|
|
1676
2022
|
for (; i < queue.length; i++) {
|
|
1677
2023
|
const cb = queue[i];
|
|
1678
|
-
if (cb && cb.
|
|
2024
|
+
if (cb && cb.flags & 2) {
|
|
1679
2025
|
if (instance && cb.id !== instance.uid) {
|
|
1680
2026
|
continue;
|
|
1681
2027
|
}
|
|
@@ -1685,6 +2031,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
|
|
|
1685
2031
|
queue.splice(i, 1);
|
|
1686
2032
|
i--;
|
|
1687
2033
|
cb();
|
|
2034
|
+
cb.flags &= ~1;
|
|
1688
2035
|
}
|
|
1689
2036
|
}
|
|
1690
2037
|
}
|
|
@@ -1707,6 +2054,7 @@ function flushPostFlushCbs(seen) {
|
|
|
1707
2054
|
continue;
|
|
1708
2055
|
}
|
|
1709
2056
|
activePostFlushCbs[postFlushIndex]();
|
|
2057
|
+
activePostFlushCbs[postFlushIndex].flags &= ~1;
|
|
1710
2058
|
}
|
|
1711
2059
|
activePostFlushCbs = null;
|
|
1712
2060
|
postFlushIndex = 0;
|
|
@@ -1716,9 +2064,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
|
|
|
1716
2064
|
const comparator = (a, b) => {
|
|
1717
2065
|
const diff = getId(a) - getId(b);
|
|
1718
2066
|
if (diff === 0) {
|
|
1719
|
-
|
|
2067
|
+
const isAPre = a.flags & 2;
|
|
2068
|
+
const isBPre = b.flags & 2;
|
|
2069
|
+
if (isAPre && !isBPre)
|
|
1720
2070
|
return -1;
|
|
1721
|
-
if (
|
|
2071
|
+
if (isBPre && !isAPre)
|
|
1722
2072
|
return 1;
|
|
1723
2073
|
}
|
|
1724
2074
|
return diff;
|
|
@@ -1734,11 +2084,12 @@ function flushJobs(seen) {
|
|
|
1734
2084
|
try {
|
|
1735
2085
|
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
1736
2086
|
const job = queue[flushIndex];
|
|
1737
|
-
if (job && job.
|
|
2087
|
+
if (job && !(job.flags & 8)) {
|
|
1738
2088
|
if (check(job)) {
|
|
1739
2089
|
continue;
|
|
1740
2090
|
}
|
|
1741
2091
|
callWithErrorHandling(job, null, 14);
|
|
2092
|
+
job.flags &= ~1;
|
|
1742
2093
|
}
|
|
1743
2094
|
}
|
|
1744
2095
|
} finally {
|
|
@@ -1820,7 +2171,6 @@ function rerender(id, newRender) {
|
|
|
1820
2171
|
}
|
|
1821
2172
|
instance.renderCache = [];
|
|
1822
2173
|
isHmrUpdating = true;
|
|
1823
|
-
instance.effect.dirty = true;
|
|
1824
2174
|
instance.update();
|
|
1825
2175
|
isHmrUpdating = false;
|
|
1826
2176
|
});
|
|
@@ -1848,7 +2198,6 @@ function reload(id, newComp) {
|
|
|
1848
2198
|
instance.ceReload(newComp.styles);
|
|
1849
2199
|
hmrDirtyComponents.delete(oldComp);
|
|
1850
2200
|
} else if (instance.parent) {
|
|
1851
|
-
instance.parent.effect.dirty = true;
|
|
1852
2201
|
queueJob(instance.parent.update);
|
|
1853
2202
|
} else if (instance.appContext.reload) {
|
|
1854
2203
|
instance.appContext.reload();
|
|
@@ -2615,8 +2964,8 @@ function doWatch(source, cb, {
|
|
|
2615
2964
|
}
|
|
2616
2965
|
}
|
|
2617
2966
|
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
2618
|
-
const job = () => {
|
|
2619
|
-
if (!effect.
|
|
2967
|
+
const job = (immediateFirstRun) => {
|
|
2968
|
+
if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
|
|
2620
2969
|
return;
|
|
2621
2970
|
}
|
|
2622
2971
|
if (cb) {
|
|
@@ -2637,19 +2986,22 @@ function doWatch(source, cb, {
|
|
|
2637
2986
|
effect.run();
|
|
2638
2987
|
}
|
|
2639
2988
|
};
|
|
2640
|
-
|
|
2989
|
+
if (cb)
|
|
2990
|
+
job.flags |= 4;
|
|
2991
|
+
const effect = new ReactiveEffect(getter);
|
|
2641
2992
|
let scheduler;
|
|
2642
2993
|
if (flush === "sync") {
|
|
2994
|
+
effect.flags |= 64;
|
|
2643
2995
|
scheduler = job;
|
|
2644
2996
|
} else if (flush === "post") {
|
|
2645
2997
|
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
|
2646
2998
|
} else {
|
|
2647
|
-
job.
|
|
2999
|
+
job.flags |= 2;
|
|
2648
3000
|
if (instance)
|
|
2649
3001
|
job.id = instance.uid;
|
|
2650
3002
|
scheduler = () => queueJob(job);
|
|
2651
3003
|
}
|
|
2652
|
-
|
|
3004
|
+
effect.scheduler = scheduler;
|
|
2653
3005
|
const scope = getCurrentScope();
|
|
2654
3006
|
const unwatch = () => {
|
|
2655
3007
|
effect.stop();
|
|
@@ -2663,7 +3015,7 @@ function doWatch(source, cb, {
|
|
|
2663
3015
|
}
|
|
2664
3016
|
if (cb) {
|
|
2665
3017
|
if (immediate) {
|
|
2666
|
-
job();
|
|
3018
|
+
job(true);
|
|
2667
3019
|
} else {
|
|
2668
3020
|
oldValue = effect.run();
|
|
2669
3021
|
}
|
|
@@ -2874,7 +3226,6 @@ const publicPropertiesMap = (
|
|
|
2874
3226
|
$emit: (i) => i.emit,
|
|
2875
3227
|
$options: (i) => resolveMergedOptions(i) ,
|
|
2876
3228
|
$forceUpdate: (i) => i.f || (i.f = () => {
|
|
2877
|
-
i.effect.dirty = true;
|
|
2878
3229
|
queueJob(i.update);
|
|
2879
3230
|
}),
|
|
2880
3231
|
$nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
|
@@ -3532,6 +3883,7 @@ function createAppAPI(render, hydrate) {
|
|
|
3532
3883
|
}
|
|
3533
3884
|
const context = createAppContext();
|
|
3534
3885
|
const installedPlugins = /* @__PURE__ */ new WeakSet();
|
|
3886
|
+
const pluginCleanupFns = [];
|
|
3535
3887
|
let isMounted = false;
|
|
3536
3888
|
const app = context.app = {
|
|
3537
3889
|
_uid: uid$1++,
|
|
@@ -3649,8 +4001,21 @@ If you want to remount the same app, move your app creation logic into a factory
|
|
|
3649
4001
|
);
|
|
3650
4002
|
}
|
|
3651
4003
|
},
|
|
4004
|
+
onUnmount(cleanupFn) {
|
|
4005
|
+
if (typeof cleanupFn !== "function") {
|
|
4006
|
+
warn$1(
|
|
4007
|
+
`Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
|
|
4008
|
+
);
|
|
4009
|
+
}
|
|
4010
|
+
pluginCleanupFns.push(cleanupFn);
|
|
4011
|
+
},
|
|
3652
4012
|
unmount() {
|
|
3653
4013
|
if (isMounted) {
|
|
4014
|
+
callWithAsyncErrorHandling(
|
|
4015
|
+
pluginCleanupFns,
|
|
4016
|
+
app._instance,
|
|
4017
|
+
15
|
|
4018
|
+
);
|
|
3654
4019
|
render(null, app._container);
|
|
3655
4020
|
{
|
|
3656
4021
|
app._instance = null;
|
|
@@ -4067,7 +4432,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
|
|
|
4067
4432
|
function assertType(value, type) {
|
|
4068
4433
|
let valid;
|
|
4069
4434
|
const expectedType = getType(type);
|
|
4070
|
-
if (
|
|
4435
|
+
if (expectedType === "null") {
|
|
4436
|
+
valid = value === null;
|
|
4437
|
+
} else if (isSimpleType(expectedType)) {
|
|
4071
4438
|
const t = typeof value;
|
|
4072
4439
|
valid = t === expectedType.toLowerCase();
|
|
4073
4440
|
if (!valid && t === "object") {
|
|
@@ -4077,8 +4444,6 @@ function assertType(value, type) {
|
|
|
4077
4444
|
valid = isObject(value);
|
|
4078
4445
|
} else if (expectedType === "Array") {
|
|
4079
4446
|
valid = isArray(value);
|
|
4080
|
-
} else if (expectedType === "null") {
|
|
4081
|
-
valid = value === null;
|
|
4082
4447
|
} else {
|
|
4083
4448
|
valid = value instanceof type;
|
|
4084
4449
|
}
|
|
@@ -5023,7 +5388,6 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5023
5388
|
} else {
|
|
5024
5389
|
instance.next = n2;
|
|
5025
5390
|
invalidateJob(instance.update);
|
|
5026
|
-
instance.effect.dirty = true;
|
|
5027
5391
|
instance.update();
|
|
5028
5392
|
}
|
|
5029
5393
|
} else {
|
|
@@ -5206,24 +5570,18 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5206
5570
|
}
|
|
5207
5571
|
}
|
|
5208
5572
|
};
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
);
|
|
5216
|
-
const update = instance.update = () => {
|
|
5217
|
-
if (effect.dirty) {
|
|
5218
|
-
effect.run();
|
|
5219
|
-
}
|
|
5220
|
-
};
|
|
5221
|
-
update.id = instance.uid;
|
|
5573
|
+
instance.scope.on();
|
|
5574
|
+
const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
|
|
5575
|
+
instance.scope.off();
|
|
5576
|
+
const update = instance.update = effect.run.bind(effect);
|
|
5577
|
+
const job = instance.job = effect.runIfDirty.bind(effect);
|
|
5578
|
+
job.id = instance.uid;
|
|
5579
|
+
effect.scheduler = () => queueJob(job);
|
|
5222
5580
|
toggleRecurse(instance, true);
|
|
5223
5581
|
{
|
|
5224
5582
|
effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
|
5225
5583
|
effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
|
5226
|
-
|
|
5584
|
+
job.ownerInstance = instance;
|
|
5227
5585
|
}
|
|
5228
5586
|
update();
|
|
5229
5587
|
};
|
|
@@ -5690,13 +6048,13 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5690
6048
|
if (instance.type.__hmrId) {
|
|
5691
6049
|
unregisterHMR(instance);
|
|
5692
6050
|
}
|
|
5693
|
-
const { bum, scope,
|
|
6051
|
+
const { bum, scope, job, subTree, um } = instance;
|
|
5694
6052
|
if (bum) {
|
|
5695
6053
|
invokeArrayFns(bum);
|
|
5696
6054
|
}
|
|
5697
6055
|
scope.stop();
|
|
5698
|
-
if (
|
|
5699
|
-
|
|
6056
|
+
if (job) {
|
|
6057
|
+
job.flags |= 8;
|
|
5700
6058
|
unmount(subTree, instance, parentSuspense, doRemove);
|
|
5701
6059
|
}
|
|
5702
6060
|
if (um) {
|
|
@@ -5777,8 +6135,14 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5777
6135
|
function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
|
5778
6136
|
return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
|
5779
6137
|
}
|
|
5780
|
-
function toggleRecurse({ effect,
|
|
5781
|
-
|
|
6138
|
+
function toggleRecurse({ effect, job }, allowed) {
|
|
6139
|
+
if (allowed) {
|
|
6140
|
+
effect.flags |= 32;
|
|
6141
|
+
job.flags |= 4;
|
|
6142
|
+
} else {
|
|
6143
|
+
effect.flags &= ~32;
|
|
6144
|
+
job.flags &= ~4;
|
|
6145
|
+
}
|
|
5782
6146
|
}
|
|
5783
6147
|
function needTransition(parentSuspense, transition) {
|
|
5784
6148
|
return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
|
@@ -6193,6 +6557,7 @@ function createComponentInstance$1(vnode, parent, suspense) {
|
|
|
6193
6557
|
effect: null,
|
|
6194
6558
|
update: null,
|
|
6195
6559
|
// will be set synchronously right after creation
|
|
6560
|
+
job: null,
|
|
6196
6561
|
scope: new EffectScope(
|
|
6197
6562
|
true
|
|
6198
6563
|
/* detached */
|
|
@@ -6596,7 +6961,7 @@ const computed = (getterOrOptions, debugOptions) => {
|
|
|
6596
6961
|
return c;
|
|
6597
6962
|
};
|
|
6598
6963
|
|
|
6599
|
-
const version = "3.
|
|
6964
|
+
const version = "3.5.0-alpha.2";
|
|
6600
6965
|
const warn = warn$1 ;
|
|
6601
6966
|
const _ssrUtils = {
|
|
6602
6967
|
createComponentInstance: createComponentInstance$1,
|
|
@@ -7587,12 +7952,6 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
7587
7952
|
if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) {
|
|
7588
7953
|
comp.ssrRender = ssrCompile(comp.template);
|
|
7589
7954
|
}
|
|
7590
|
-
for (const e of instance.scope.effects) {
|
|
7591
|
-
if (e.computed) {
|
|
7592
|
-
e.computed._dirty = true;
|
|
7593
|
-
e.computed._cacheable = true;
|
|
7594
|
-
}
|
|
7595
|
-
}
|
|
7596
7955
|
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
7597
7956
|
if (ssrRender) {
|
|
7598
7957
|
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|