@vue/compat 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/compat v3.4.26
2
+ * @vue/compat v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -453,156 +453,280 @@ var Vue = (function () {
453
453
  function effectScope(detached) {
454
454
  return new EffectScope(detached);
455
455
  }
456
- function recordEffectScope(effect, scope = activeEffectScope) {
457
- if (scope && scope.active) {
458
- scope.effects.push(effect);
459
- }
460
- }
461
456
  function getCurrentScope() {
462
457
  return activeEffectScope;
463
458
  }
464
- function onScopeDispose(fn) {
459
+ function onScopeDispose(fn, failSilently = false) {
465
460
  if (activeEffectScope) {
466
461
  activeEffectScope.cleanups.push(fn);
467
- } else {
462
+ } else if (!failSilently) {
468
463
  warn$2(
469
464
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
470
465
  );
471
466
  }
472
467
  }
473
468
 
474
- let activeEffect;
469
+ let activeSub;
475
470
  class ReactiveEffect {
476
- constructor(fn, trigger, scheduler, scope) {
471
+ constructor(fn) {
477
472
  this.fn = fn;
478
- this.trigger = trigger;
479
- this.scheduler = scheduler;
480
- this.active = true;
481
- this.deps = [];
482
473
  /**
483
474
  * @internal
484
475
  */
485
- this._dirtyLevel = 4;
476
+ this.deps = void 0;
486
477
  /**
487
478
  * @internal
488
479
  */
489
- this._trackId = 0;
480
+ this.depsTail = void 0;
490
481
  /**
491
482
  * @internal
492
483
  */
493
- this._runnings = 0;
484
+ this.flags = 1 | 4;
494
485
  /**
495
486
  * @internal
496
487
  */
497
- this._shouldSchedule = false;
488
+ this.nextEffect = void 0;
498
489
  /**
499
490
  * @internal
500
491
  */
501
- this._depsLength = 0;
502
- recordEffectScope(this, scope);
503
- }
504
- get dirty() {
505
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
506
- this._dirtyLevel = 1;
507
- pauseTracking();
508
- for (let i = 0; i < this._depsLength; i++) {
509
- const dep = this.deps[i];
510
- if (dep.computed) {
511
- triggerComputed(dep.computed);
512
- if (this._dirtyLevel >= 4) {
513
- break;
514
- }
515
- }
516
- }
517
- if (this._dirtyLevel === 1) {
518
- this._dirtyLevel = 0;
519
- }
520
- resetTracking();
492
+ this.cleanup = void 0;
493
+ this.scheduler = void 0;
494
+ if (activeEffectScope && activeEffectScope.active) {
495
+ activeEffectScope.effects.push(this);
521
496
  }
522
- return this._dirtyLevel >= 4;
523
497
  }
524
- set dirty(v) {
525
- this._dirtyLevel = v ? 4 : 0;
498
+ /**
499
+ * @internal
500
+ */
501
+ notify() {
502
+ if (this.flags & 2 && !(this.flags & 32)) {
503
+ return;
504
+ }
505
+ if (this.flags & 64) {
506
+ return this.trigger();
507
+ }
508
+ if (!(this.flags & 8)) {
509
+ this.flags |= 8;
510
+ this.nextEffect = batchedEffect;
511
+ batchedEffect = this;
512
+ }
526
513
  }
527
514
  run() {
528
- this._dirtyLevel = 0;
529
- if (!this.active) {
515
+ if (!(this.flags & 1)) {
530
516
  return this.fn();
531
517
  }
532
- let lastShouldTrack = shouldTrack;
533
- let lastEffect = activeEffect;
518
+ this.flags |= 2;
519
+ cleanupEffect(this);
520
+ prepareDeps(this);
521
+ const prevEffect = activeSub;
522
+ const prevShouldTrack = shouldTrack;
523
+ activeSub = this;
524
+ shouldTrack = true;
534
525
  try {
535
- shouldTrack = true;
536
- activeEffect = this;
537
- this._runnings++;
538
- preCleanupEffect(this);
539
526
  return this.fn();
540
527
  } finally {
541
- postCleanupEffect(this);
542
- this._runnings--;
543
- activeEffect = lastEffect;
544
- shouldTrack = lastShouldTrack;
528
+ if (activeSub !== this) {
529
+ warn$2(
530
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
531
+ );
532
+ }
533
+ cleanupDeps(this);
534
+ activeSub = prevEffect;
535
+ shouldTrack = prevShouldTrack;
536
+ this.flags &= ~2;
545
537
  }
546
538
  }
547
539
  stop() {
548
- if (this.active) {
549
- preCleanupEffect(this);
550
- postCleanupEffect(this);
540
+ if (this.flags & 1) {
541
+ for (let link = this.deps; link; link = link.nextDep) {
542
+ removeSub(link);
543
+ }
544
+ this.deps = this.depsTail = void 0;
545
+ cleanupEffect(this);
551
546
  this.onStop && this.onStop();
552
- this.active = false;
547
+ this.flags &= ~1;
548
+ }
549
+ }
550
+ trigger() {
551
+ if (this.scheduler) {
552
+ this.scheduler();
553
+ } else {
554
+ this.runIfDirty();
553
555
  }
554
556
  }
557
+ /**
558
+ * @internal
559
+ */
560
+ runIfDirty() {
561
+ if (isDirty(this)) {
562
+ this.run();
563
+ }
564
+ }
565
+ get dirty() {
566
+ return isDirty(this);
567
+ }
568
+ }
569
+ let batchDepth = 0;
570
+ let batchedEffect;
571
+ function startBatch() {
572
+ batchDepth++;
573
+ }
574
+ function endBatch() {
575
+ if (batchDepth > 1) {
576
+ batchDepth--;
577
+ return;
578
+ }
579
+ let error;
580
+ while (batchedEffect) {
581
+ let e = batchedEffect;
582
+ batchedEffect = void 0;
583
+ while (e) {
584
+ const next = e.nextEffect;
585
+ e.nextEffect = void 0;
586
+ e.flags &= ~8;
587
+ if (e.flags & 1) {
588
+ try {
589
+ e.trigger();
590
+ } catch (err) {
591
+ if (!error)
592
+ error = err;
593
+ }
594
+ }
595
+ e = next;
596
+ }
597
+ }
598
+ batchDepth--;
599
+ if (error)
600
+ throw error;
601
+ }
602
+ function prepareDeps(sub) {
603
+ for (let link = sub.deps; link; link = link.nextDep) {
604
+ link.version = -1;
605
+ link.prevActiveLink = link.dep.activeLink;
606
+ link.dep.activeLink = link;
607
+ }
555
608
  }
556
- function triggerComputed(computed) {
557
- return computed.value;
609
+ function cleanupDeps(sub) {
610
+ let head;
611
+ let tail = sub.depsTail;
612
+ for (let link = tail; link; link = link.prevDep) {
613
+ if (link.version === -1) {
614
+ if (link === tail)
615
+ tail = link.prevDep;
616
+ removeSub(link);
617
+ removeDep(link);
618
+ } else {
619
+ head = link;
620
+ }
621
+ link.dep.activeLink = link.prevActiveLink;
622
+ link.prevActiveLink = void 0;
623
+ }
624
+ sub.deps = head;
625
+ sub.depsTail = tail;
558
626
  }
559
- function preCleanupEffect(effect2) {
560
- effect2._trackId++;
561
- effect2._depsLength = 0;
627
+ function isDirty(sub) {
628
+ for (let link = sub.deps; link; link = link.nextDep) {
629
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
630
+ return true;
631
+ }
632
+ }
633
+ if (sub._dirty) {
634
+ return true;
635
+ }
636
+ return false;
562
637
  }
563
- function postCleanupEffect(effect2) {
564
- if (effect2.deps.length > effect2._depsLength) {
565
- for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
566
- cleanupDepEffect(effect2.deps[i], effect2);
638
+ function refreshComputed(computed) {
639
+ if (computed.flags & 2) {
640
+ return false;
641
+ }
642
+ if (computed.flags & 4 && !(computed.flags & 16)) {
643
+ return;
644
+ }
645
+ computed.flags &= ~16;
646
+ if (computed.globalVersion === globalVersion) {
647
+ return;
648
+ }
649
+ computed.globalVersion = globalVersion;
650
+ const dep = computed.dep;
651
+ computed.flags |= 2;
652
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
653
+ computed.flags &= ~2;
654
+ return;
655
+ }
656
+ const prevSub = activeSub;
657
+ const prevShouldTrack = shouldTrack;
658
+ activeSub = computed;
659
+ shouldTrack = true;
660
+ try {
661
+ prepareDeps(computed);
662
+ const value = computed.fn();
663
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
664
+ computed._value = value;
665
+ dep.version++;
567
666
  }
568
- effect2.deps.length = effect2._depsLength;
667
+ } catch (err) {
668
+ dep.version++;
669
+ throw err;
670
+ } finally {
671
+ activeSub = prevSub;
672
+ shouldTrack = prevShouldTrack;
673
+ cleanupDeps(computed);
674
+ computed.flags &= ~2;
569
675
  }
570
676
  }
571
- function cleanupDepEffect(dep, effect2) {
572
- const trackId = dep.get(effect2);
573
- if (trackId !== void 0 && effect2._trackId !== trackId) {
574
- dep.delete(effect2);
575
- if (dep.size === 0) {
576
- dep.cleanup();
677
+ function removeSub(link) {
678
+ const { dep, prevSub, nextSub } = link;
679
+ if (prevSub) {
680
+ prevSub.nextSub = nextSub;
681
+ link.prevSub = void 0;
682
+ }
683
+ if (nextSub) {
684
+ nextSub.prevSub = prevSub;
685
+ link.nextSub = void 0;
686
+ }
687
+ if (dep.subs === link) {
688
+ dep.subs = prevSub;
689
+ }
690
+ if (!dep.subs && dep.computed) {
691
+ dep.computed.flags &= ~4;
692
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
693
+ removeSub(l);
577
694
  }
578
695
  }
579
696
  }
697
+ function removeDep(link) {
698
+ const { prevDep, nextDep } = link;
699
+ if (prevDep) {
700
+ prevDep.nextDep = nextDep;
701
+ link.prevDep = void 0;
702
+ }
703
+ if (nextDep) {
704
+ nextDep.prevDep = prevDep;
705
+ link.nextDep = void 0;
706
+ }
707
+ }
580
708
  function effect(fn, options) {
581
709
  if (fn.effect instanceof ReactiveEffect) {
582
710
  fn = fn.effect.fn;
583
711
  }
584
- const _effect = new ReactiveEffect(fn, NOOP, () => {
585
- if (_effect.dirty) {
586
- _effect.run();
587
- }
588
- });
712
+ const e = new ReactiveEffect(fn);
589
713
  if (options) {
590
- extend(_effect, options);
591
- if (options.scope)
592
- recordEffectScope(_effect, options.scope);
714
+ extend(e, options);
593
715
  }
594
- if (!options || !options.lazy) {
595
- _effect.run();
716
+ try {
717
+ e.run();
718
+ } catch (err) {
719
+ e.stop();
720
+ throw err;
596
721
  }
597
- const runner = _effect.run.bind(_effect);
598
- runner.effect = _effect;
722
+ const runner = e.run.bind(e);
723
+ runner.effect = e;
599
724
  return runner;
600
725
  }
601
726
  function stop(runner) {
602
727
  runner.effect.stop();
603
728
  }
604
729
  let shouldTrack = true;
605
- let pauseScheduleStack = 0;
606
730
  const trackStack = [];
607
731
  function pauseTracking() {
608
732
  trackStack.push(shouldTrack);
@@ -612,192 +736,414 @@ var Vue = (function () {
612
736
  const last = trackStack.pop();
613
737
  shouldTrack = last === void 0 ? true : last;
614
738
  }
615
- function pauseScheduling() {
616
- pauseScheduleStack++;
617
- }
618
- function resetScheduling() {
619
- pauseScheduleStack--;
620
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
621
- queueEffectSchedulers.shift()();
739
+ function cleanupEffect(e) {
740
+ const { cleanup } = e;
741
+ e.cleanup = void 0;
742
+ if (cleanup) {
743
+ const prevSub = activeSub;
744
+ activeSub = void 0;
745
+ try {
746
+ cleanup();
747
+ } finally {
748
+ activeSub = prevSub;
749
+ }
622
750
  }
623
751
  }
624
- function trackEffect(effect2, dep, debuggerEventExtraInfo) {
625
- var _a;
626
- if (dep.get(effect2) !== effect2._trackId) {
627
- dep.set(effect2, effect2._trackId);
628
- const oldDep = effect2.deps[effect2._depsLength];
629
- if (oldDep !== dep) {
630
- if (oldDep) {
631
- cleanupDepEffect(oldDep, effect2);
632
- }
633
- effect2.deps[effect2._depsLength++] = dep;
634
- } else {
635
- effect2._depsLength++;
636
- }
752
+
753
+ let globalVersion = 0;
754
+ class Dep {
755
+ constructor(computed) {
756
+ this.computed = computed;
757
+ this.version = 0;
758
+ /**
759
+ * Link between this dep and the current active effect
760
+ */
761
+ this.activeLink = void 0;
762
+ /**
763
+ * Doubly linked list representing the subscribing effects (tail)
764
+ */
765
+ this.subs = void 0;
637
766
  {
638
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
767
+ this.subsHead = void 0;
639
768
  }
640
769
  }
641
- }
642
- const queueEffectSchedulers = [];
643
- function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
644
- var _a;
645
- pauseScheduling();
646
- for (const effect2 of dep.keys()) {
647
- let tracking;
648
- if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
649
- effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
650
- effect2._dirtyLevel = dirtyLevel;
651
- }
652
- if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
653
- {
654
- (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
770
+ track(debugInfo) {
771
+ if (!activeSub || !shouldTrack) {
772
+ return;
773
+ }
774
+ let link = this.activeLink;
775
+ if (link === void 0 || link.sub !== activeSub) {
776
+ link = this.activeLink = {
777
+ dep: this,
778
+ sub: activeSub,
779
+ version: this.version,
780
+ nextDep: void 0,
781
+ prevDep: void 0,
782
+ nextSub: void 0,
783
+ prevSub: void 0,
784
+ prevActiveLink: void 0
785
+ };
786
+ if (!activeSub.deps) {
787
+ activeSub.deps = activeSub.depsTail = link;
788
+ } else {
789
+ link.prevDep = activeSub.depsTail;
790
+ activeSub.depsTail.nextDep = link;
791
+ activeSub.depsTail = link;
655
792
  }
656
- effect2.trigger();
657
- if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
658
- effect2._shouldSchedule = false;
659
- if (effect2.scheduler) {
660
- queueEffectSchedulers.push(effect2.scheduler);
793
+ if (activeSub.flags & 4) {
794
+ addSub(link);
795
+ }
796
+ } else if (link.version === -1) {
797
+ link.version = this.version;
798
+ if (link.nextDep) {
799
+ const next = link.nextDep;
800
+ next.prevDep = link.prevDep;
801
+ if (link.prevDep) {
802
+ link.prevDep.nextDep = next;
803
+ }
804
+ link.prevDep = activeSub.depsTail;
805
+ link.nextDep = void 0;
806
+ activeSub.depsTail.nextDep = link;
807
+ activeSub.depsTail = link;
808
+ if (activeSub.deps === link) {
809
+ activeSub.deps = next;
810
+ }
811
+ }
812
+ }
813
+ if (activeSub.onTrack) {
814
+ activeSub.onTrack(
815
+ extend(
816
+ {
817
+ effect: activeSub
818
+ },
819
+ debugInfo
820
+ )
821
+ );
822
+ }
823
+ return link;
824
+ }
825
+ trigger(debugInfo) {
826
+ this.version++;
827
+ globalVersion++;
828
+ this.notify(debugInfo);
829
+ }
830
+ notify(debugInfo) {
831
+ startBatch();
832
+ try {
833
+ if (true) {
834
+ for (let head = this.subsHead; head; head = head.nextSub) {
835
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
836
+ head.sub.onTrigger(
837
+ extend(
838
+ {
839
+ effect: head.sub
840
+ },
841
+ debugInfo
842
+ )
843
+ );
844
+ }
661
845
  }
662
846
  }
847
+ for (let link = this.subs; link; link = link.prevSub) {
848
+ link.sub.notify();
849
+ }
850
+ } finally {
851
+ endBatch();
663
852
  }
664
853
  }
665
- resetScheduling();
666
854
  }
667
-
668
- const createDep = (cleanup, computed) => {
669
- const dep = /* @__PURE__ */ new Map();
670
- dep.cleanup = cleanup;
671
- dep.computed = computed;
672
- return dep;
673
- };
674
-
855
+ function addSub(link) {
856
+ const computed = link.dep.computed;
857
+ if (computed && !link.dep.subs) {
858
+ computed.flags |= 4 | 16;
859
+ for (let l = computed.deps; l; l = l.nextDep) {
860
+ addSub(l);
861
+ }
862
+ }
863
+ const currentTail = link.dep.subs;
864
+ if (currentTail !== link) {
865
+ link.prevSub = currentTail;
866
+ if (currentTail)
867
+ currentTail.nextSub = link;
868
+ }
869
+ if (link.dep.subsHead === void 0) {
870
+ link.dep.subsHead = link;
871
+ }
872
+ link.dep.subs = link;
873
+ }
675
874
  const targetMap = /* @__PURE__ */ new WeakMap();
676
- const ITERATE_KEY = Symbol("iterate" );
677
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
875
+ const ITERATE_KEY = Symbol("Object iterate" );
876
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
877
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
678
878
  function track(target, type, key) {
679
- if (shouldTrack && activeEffect) {
879
+ if (shouldTrack && activeSub) {
680
880
  let depsMap = targetMap.get(target);
681
881
  if (!depsMap) {
682
882
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
683
883
  }
684
884
  let dep = depsMap.get(key);
685
885
  if (!dep) {
686
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
886
+ depsMap.set(key, dep = new Dep());
687
887
  }
688
- trackEffect(
689
- activeEffect,
690
- dep,
691
- {
888
+ {
889
+ dep.track({
692
890
  target,
693
891
  type,
694
892
  key
695
- }
696
- );
893
+ });
894
+ }
697
895
  }
698
896
  }
699
897
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
700
898
  const depsMap = targetMap.get(target);
701
899
  if (!depsMap) {
900
+ globalVersion++;
702
901
  return;
703
902
  }
704
903
  let deps = [];
705
904
  if (type === "clear") {
706
905
  deps = [...depsMap.values()];
707
- } else if (key === "length" && isArray(target)) {
708
- const newLength = Number(newValue);
709
- depsMap.forEach((dep, key2) => {
710
- if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
711
- deps.push(dep);
712
- }
713
- });
714
906
  } else {
715
- if (key !== void 0) {
716
- deps.push(depsMap.get(key));
717
- }
718
- switch (type) {
719
- case "add":
720
- if (!isArray(target)) {
721
- deps.push(depsMap.get(ITERATE_KEY));
722
- if (isMap(target)) {
723
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
724
- }
725
- } else if (isIntegerKey(key)) {
726
- deps.push(depsMap.get("length"));
907
+ const targetIsArray = isArray(target);
908
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
909
+ if (targetIsArray && key === "length") {
910
+ const newLength = Number(newValue);
911
+ depsMap.forEach((dep, key2) => {
912
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
913
+ deps.push(dep);
727
914
  }
728
- break;
729
- case "delete":
730
- if (!isArray(target)) {
731
- deps.push(depsMap.get(ITERATE_KEY));
915
+ });
916
+ } else {
917
+ const push = (dep) => dep && deps.push(dep);
918
+ if (key !== void 0) {
919
+ push(depsMap.get(key));
920
+ }
921
+ if (isArrayIndex) {
922
+ push(depsMap.get(ARRAY_ITERATE_KEY));
923
+ }
924
+ switch (type) {
925
+ case "add":
926
+ if (!targetIsArray) {
927
+ push(depsMap.get(ITERATE_KEY));
928
+ if (isMap(target)) {
929
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
930
+ }
931
+ } else if (isArrayIndex) {
932
+ push(depsMap.get("length"));
933
+ }
934
+ break;
935
+ case "delete":
936
+ if (!targetIsArray) {
937
+ push(depsMap.get(ITERATE_KEY));
938
+ if (isMap(target)) {
939
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
940
+ }
941
+ }
942
+ break;
943
+ case "set":
732
944
  if (isMap(target)) {
733
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
945
+ push(depsMap.get(ITERATE_KEY));
734
946
  }
735
- }
736
- break;
737
- case "set":
738
- if (isMap(target)) {
739
- deps.push(depsMap.get(ITERATE_KEY));
740
- }
741
- break;
947
+ break;
948
+ }
742
949
  }
743
950
  }
744
- pauseScheduling();
951
+ startBatch();
745
952
  for (const dep of deps) {
746
- if (dep) {
747
- triggerEffects(
748
- dep,
749
- 4,
750
- {
751
- target,
752
- type,
753
- key,
754
- newValue,
755
- oldValue,
756
- oldTarget
757
- }
758
- );
953
+ {
954
+ dep.trigger({
955
+ target,
956
+ type,
957
+ key,
958
+ newValue,
959
+ oldValue,
960
+ oldTarget
961
+ });
759
962
  }
760
963
  }
761
- resetScheduling();
964
+ endBatch();
762
965
  }
763
966
  function getDepFromReactive(object, key) {
764
- const depsMap = targetMap.get(object);
765
- return depsMap && depsMap.get(key);
967
+ var _a;
968
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
969
+ }
970
+
971
+ function reactiveReadArray(array) {
972
+ const raw = toRaw(array);
973
+ if (raw === array)
974
+ return raw;
975
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
976
+ return isShallow(array) ? raw : raw.map(toReactive);
977
+ }
978
+ function shallowReadArray(arr) {
979
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
980
+ return arr;
981
+ }
982
+ const arrayInstrumentations = {
983
+ __proto__: null,
984
+ [Symbol.iterator]() {
985
+ return iterator(this, Symbol.iterator, toReactive);
986
+ },
987
+ concat(...args) {
988
+ return reactiveReadArray(this).concat(
989
+ ...args.map((x) => reactiveReadArray(x))
990
+ );
991
+ },
992
+ entries() {
993
+ return iterator(this, "entries", (value) => {
994
+ value[1] = toReactive(value[1]);
995
+ return value;
996
+ });
997
+ },
998
+ every(fn, thisArg) {
999
+ return apply(this, "every", fn, thisArg);
1000
+ },
1001
+ filter(fn, thisArg) {
1002
+ const result = apply(this, "filter", fn, thisArg);
1003
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
1004
+ },
1005
+ find(fn, thisArg) {
1006
+ const result = apply(this, "find", fn, thisArg);
1007
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1008
+ },
1009
+ findIndex(fn, thisArg) {
1010
+ return apply(this, "findIndex", fn, thisArg);
1011
+ },
1012
+ findLast(fn, thisArg) {
1013
+ const result = apply(this, "findLast", fn, thisArg);
1014
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1015
+ },
1016
+ findLastIndex(fn, thisArg) {
1017
+ return apply(this, "findLastIndex", fn, thisArg);
1018
+ },
1019
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1020
+ forEach(fn, thisArg) {
1021
+ return apply(this, "forEach", fn, thisArg);
1022
+ },
1023
+ includes(...args) {
1024
+ return searchProxy(this, "includes", args);
1025
+ },
1026
+ indexOf(...args) {
1027
+ return searchProxy(this, "indexOf", args);
1028
+ },
1029
+ join(separator) {
1030
+ return reactiveReadArray(this).join(separator);
1031
+ },
1032
+ // keys() iterator only reads `length`, no optimisation required
1033
+ lastIndexOf(...args) {
1034
+ return searchProxy(this, "lastIndexOf", args);
1035
+ },
1036
+ map(fn, thisArg) {
1037
+ return apply(this, "map", fn, thisArg);
1038
+ },
1039
+ pop() {
1040
+ return noTracking(this, "pop");
1041
+ },
1042
+ push(...args) {
1043
+ return noTracking(this, "push", args);
1044
+ },
1045
+ reduce(fn, ...args) {
1046
+ return reduce(this, "reduce", fn, args);
1047
+ },
1048
+ reduceRight(fn, ...args) {
1049
+ return reduce(this, "reduceRight", fn, args);
1050
+ },
1051
+ shift() {
1052
+ return noTracking(this, "shift");
1053
+ },
1054
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1055
+ some(fn, thisArg) {
1056
+ return apply(this, "some", fn, thisArg);
1057
+ },
1058
+ splice(...args) {
1059
+ return noTracking(this, "splice", args);
1060
+ },
1061
+ toReversed() {
1062
+ return reactiveReadArray(this).toReversed();
1063
+ },
1064
+ toSorted(comparer) {
1065
+ return reactiveReadArray(this).toSorted(comparer);
1066
+ },
1067
+ toSpliced(...args) {
1068
+ return reactiveReadArray(this).toSpliced(...args);
1069
+ },
1070
+ unshift(...args) {
1071
+ return noTracking(this, "unshift", args);
1072
+ },
1073
+ values() {
1074
+ return iterator(this, "values", toReactive);
1075
+ }
1076
+ };
1077
+ function iterator(self, method, wrapValue) {
1078
+ const arr = shallowReadArray(self);
1079
+ const iter = arr[method]();
1080
+ if (arr !== self && !isShallow(self)) {
1081
+ iter._next = iter.next;
1082
+ iter.next = () => {
1083
+ const result = iter._next();
1084
+ if (result.value) {
1085
+ result.value = wrapValue(result.value);
1086
+ }
1087
+ return result;
1088
+ };
1089
+ }
1090
+ return iter;
1091
+ }
1092
+ function apply(self, method, fn, thisArg) {
1093
+ const arr = shallowReadArray(self);
1094
+ let wrappedFn = fn;
1095
+ if (arr !== self) {
1096
+ if (!isShallow(self)) {
1097
+ wrappedFn = function(item, index) {
1098
+ return fn.call(this, toReactive(item), index, self);
1099
+ };
1100
+ } else if (fn.length > 2) {
1101
+ wrappedFn = function(item, index) {
1102
+ return fn.call(this, item, index, self);
1103
+ };
1104
+ }
1105
+ }
1106
+ return arr[method](wrappedFn, thisArg);
1107
+ }
1108
+ function reduce(self, method, fn, args) {
1109
+ const arr = shallowReadArray(self);
1110
+ let wrappedFn = fn;
1111
+ if (arr !== self) {
1112
+ if (!isShallow(self)) {
1113
+ wrappedFn = function(acc, item, index) {
1114
+ return fn.call(this, acc, toReactive(item), index, self);
1115
+ };
1116
+ } else if (fn.length > 3) {
1117
+ wrappedFn = function(acc, item, index) {
1118
+ return fn.call(this, acc, item, index, self);
1119
+ };
1120
+ }
1121
+ }
1122
+ return arr[method](wrappedFn, ...args);
1123
+ }
1124
+ function searchProxy(self, method, args) {
1125
+ const arr = toRaw(self);
1126
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1127
+ const res = arr[method](...args);
1128
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1129
+ args[0] = toRaw(args[0]);
1130
+ return arr[method](...args);
1131
+ }
1132
+ return res;
1133
+ }
1134
+ function noTracking(self, method, args = []) {
1135
+ pauseTracking();
1136
+ startBatch();
1137
+ const res = toRaw(self)[method].apply(self, args);
1138
+ endBatch();
1139
+ resetTracking();
1140
+ return res;
766
1141
  }
767
1142
 
768
1143
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
769
1144
  const builtInSymbols = new Set(
770
1145
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
771
1146
  );
772
- const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
773
- function createArrayInstrumentations() {
774
- const instrumentations = {};
775
- ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
776
- instrumentations[key] = function(...args) {
777
- const arr = toRaw(this);
778
- for (let i = 0, l = this.length; i < l; i++) {
779
- track(arr, "get", i + "");
780
- }
781
- const res = arr[key](...args);
782
- if (res === -1 || res === false) {
783
- return arr[key](...args.map(toRaw));
784
- } else {
785
- return res;
786
- }
787
- };
788
- });
789
- ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
790
- instrumentations[key] = function(...args) {
791
- pauseTracking();
792
- pauseScheduling();
793
- const res = toRaw(this)[key].apply(this, args);
794
- resetScheduling();
795
- resetTracking();
796
- return res;
797
- };
798
- });
799
- return instrumentations;
800
- }
801
1147
  function hasOwnProperty(key) {
802
1148
  if (!isSymbol(key))
803
1149
  key = String(key);
@@ -828,14 +1174,22 @@ var Vue = (function () {
828
1174
  }
829
1175
  const targetIsArray = isArray(target);
830
1176
  if (!isReadonly2) {
831
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
832
- return Reflect.get(arrayInstrumentations, key, receiver);
1177
+ let fn;
1178
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1179
+ return fn;
833
1180
  }
834
1181
  if (key === "hasOwnProperty") {
835
1182
  return hasOwnProperty;
836
1183
  }
837
1184
  }
838
- const res = Reflect.get(target, key, receiver);
1185
+ const res = Reflect.get(
1186
+ target,
1187
+ key,
1188
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1189
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1190
+ // its class methods
1191
+ isRef(target) ? target : receiver
1192
+ );
839
1193
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
840
1194
  return res;
841
1195
  }
@@ -1334,110 +1688,8 @@ var Vue = (function () {
1334
1688
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1335
1689
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1336
1690
 
1337
- 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`;
1338
- class ComputedRefImpl {
1339
- constructor(getter, _setter, isReadonly, isSSR) {
1340
- this.getter = getter;
1341
- this._setter = _setter;
1342
- this.dep = void 0;
1343
- this.__v_isRef = true;
1344
- this["__v_isReadonly"] = false;
1345
- this.effect = new ReactiveEffect(
1346
- () => getter(this._value),
1347
- () => triggerRefValue(
1348
- this,
1349
- this.effect._dirtyLevel === 2 ? 2 : 3
1350
- )
1351
- );
1352
- this.effect.computed = this;
1353
- this.effect.active = this._cacheable = !isSSR;
1354
- this["__v_isReadonly"] = isReadonly;
1355
- }
1356
- get value() {
1357
- const self = toRaw(this);
1358
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1359
- triggerRefValue(self, 4);
1360
- }
1361
- trackRefValue(self);
1362
- if (self.effect._dirtyLevel >= 2) {
1363
- if (this._warnRecursive) {
1364
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1365
-
1366
- getter: `, this.getter);
1367
- }
1368
- triggerRefValue(self, 2);
1369
- }
1370
- return self._value;
1371
- }
1372
- set value(newValue) {
1373
- this._setter(newValue);
1374
- }
1375
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1376
- get _dirty() {
1377
- return this.effect.dirty;
1378
- }
1379
- set _dirty(v) {
1380
- this.effect.dirty = v;
1381
- }
1382
- // #endregion
1383
- }
1384
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1385
- let getter;
1386
- let setter;
1387
- const onlyGetter = isFunction(getterOrOptions);
1388
- if (onlyGetter) {
1389
- getter = getterOrOptions;
1390
- setter = () => {
1391
- warn$2("Write operation failed: computed value is readonly");
1392
- } ;
1393
- } else {
1394
- getter = getterOrOptions.get;
1395
- setter = getterOrOptions.set;
1396
- }
1397
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1398
- if (debugOptions && !isSSR) {
1399
- cRef.effect.onTrack = debugOptions.onTrack;
1400
- cRef.effect.onTrigger = debugOptions.onTrigger;
1401
- }
1402
- return cRef;
1403
- }
1404
-
1405
- function trackRefValue(ref2) {
1406
- var _a;
1407
- if (shouldTrack && activeEffect) {
1408
- ref2 = toRaw(ref2);
1409
- trackEffect(
1410
- activeEffect,
1411
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1412
- () => ref2.dep = void 0,
1413
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1414
- ),
1415
- {
1416
- target: ref2,
1417
- type: "get",
1418
- key: "value"
1419
- }
1420
- );
1421
- }
1422
- }
1423
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1424
- ref2 = toRaw(ref2);
1425
- const dep = ref2.dep;
1426
- if (dep) {
1427
- triggerEffects(
1428
- dep,
1429
- dirtyLevel,
1430
- {
1431
- target: ref2,
1432
- type: "set",
1433
- key: "value",
1434
- newValue: newVal
1435
- }
1436
- );
1437
- }
1438
- }
1439
1691
  function isRef(r) {
1440
- return !!(r && r.__v_isRef === true);
1692
+ return r ? r.__v_isRef === true : false;
1441
1693
  }
1442
1694
  function ref(value) {
1443
1695
  return createRef(value, false);
@@ -1454,27 +1706,49 @@ getter: `, this.getter);
1454
1706
  class RefImpl {
1455
1707
  constructor(value, __v_isShallow) {
1456
1708
  this.__v_isShallow = __v_isShallow;
1457
- this.dep = void 0;
1709
+ this.dep = new Dep();
1458
1710
  this.__v_isRef = true;
1459
1711
  this._rawValue = __v_isShallow ? value : toRaw(value);
1460
1712
  this._value = __v_isShallow ? value : toReactive(value);
1461
1713
  }
1462
1714
  get value() {
1463
- trackRefValue(this);
1715
+ {
1716
+ this.dep.track({
1717
+ target: this,
1718
+ type: "get",
1719
+ key: "value"
1720
+ });
1721
+ }
1464
1722
  return this._value;
1465
1723
  }
1466
- set value(newVal) {
1467
- const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
1468
- newVal = useDirectValue ? newVal : toRaw(newVal);
1469
- if (hasChanged(newVal, this._rawValue)) {
1470
- this._rawValue = newVal;
1471
- this._value = useDirectValue ? newVal : toReactive(newVal);
1472
- triggerRefValue(this, 4, newVal);
1724
+ set value(newValue) {
1725
+ const oldValue = this._rawValue;
1726
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1727
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1728
+ if (hasChanged(newValue, oldValue)) {
1729
+ this._rawValue = newValue;
1730
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1731
+ {
1732
+ this.dep.trigger({
1733
+ target: this,
1734
+ type: "set",
1735
+ key: "value",
1736
+ newValue,
1737
+ oldValue
1738
+ });
1739
+ }
1473
1740
  }
1474
1741
  }
1475
1742
  }
1476
1743
  function triggerRef(ref2) {
1477
- triggerRefValue(ref2, 4, ref2.value );
1744
+ {
1745
+ ref2.dep.trigger({
1746
+ target: ref2,
1747
+ type: "set",
1748
+ key: "value",
1749
+ newValue: ref2._value
1750
+ });
1751
+ }
1478
1752
  }
1479
1753
  function unref(ref2) {
1480
1754
  return isRef(ref2) ? ref2.value : ref2;
@@ -1499,12 +1773,9 @@ getter: `, this.getter);
1499
1773
  }
1500
1774
  class CustomRefImpl {
1501
1775
  constructor(factory) {
1502
- this.dep = void 0;
1503
1776
  this.__v_isRef = true;
1504
- const { get, set } = factory(
1505
- () => trackRefValue(this),
1506
- () => triggerRefValue(this)
1507
- );
1777
+ const dep = this.dep = new Dep();
1778
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1508
1779
  this._get = get;
1509
1780
  this._set = set;
1510
1781
  }
@@ -1572,6 +1843,90 @@ getter: `, this.getter);
1572
1843
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1573
1844
  }
1574
1845
 
1846
+ class ComputedRefImpl {
1847
+ constructor(fn, setter, isSSR) {
1848
+ this.fn = fn;
1849
+ this.setter = setter;
1850
+ /**
1851
+ * @internal
1852
+ */
1853
+ this._value = void 0;
1854
+ /**
1855
+ * @internal
1856
+ */
1857
+ this.dep = new Dep(this);
1858
+ /**
1859
+ * @internal
1860
+ */
1861
+ this.__v_isRef = true;
1862
+ // A computed is also a subscriber that tracks other deps
1863
+ /**
1864
+ * @internal
1865
+ */
1866
+ this.deps = void 0;
1867
+ /**
1868
+ * @internal
1869
+ */
1870
+ this.depsTail = void 0;
1871
+ /**
1872
+ * @internal
1873
+ */
1874
+ this.flags = 16;
1875
+ /**
1876
+ * @internal
1877
+ */
1878
+ this.globalVersion = globalVersion - 1;
1879
+ // for backwards compat
1880
+ this.effect = this;
1881
+ this.__v_isReadonly = !setter;
1882
+ this.isSSR = isSSR;
1883
+ }
1884
+ /**
1885
+ * @internal
1886
+ */
1887
+ notify() {
1888
+ if (activeSub !== this) {
1889
+ this.flags |= 16;
1890
+ this.dep.notify();
1891
+ }
1892
+ }
1893
+ get value() {
1894
+ const link = this.dep.track({
1895
+ target: this,
1896
+ type: "get",
1897
+ key: "value"
1898
+ }) ;
1899
+ refreshComputed(this);
1900
+ if (link) {
1901
+ link.version = this.dep.version;
1902
+ }
1903
+ return this._value;
1904
+ }
1905
+ set value(newValue) {
1906
+ if (this.setter) {
1907
+ this.setter(newValue);
1908
+ } else {
1909
+ warn$2("Write operation failed: computed value is readonly");
1910
+ }
1911
+ }
1912
+ }
1913
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1914
+ let getter;
1915
+ let setter;
1916
+ if (isFunction(getterOrOptions)) {
1917
+ getter = getterOrOptions;
1918
+ } else {
1919
+ getter = getterOrOptions.get;
1920
+ setter = getterOrOptions.set;
1921
+ }
1922
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1923
+ if (debugOptions && !isSSR) {
1924
+ cRef.onTrack = debugOptions.onTrack;
1925
+ cRef.onTrigger = debugOptions.onTrigger;
1926
+ }
1927
+ return cRef;
1928
+ }
1929
+
1575
1930
  const TrackOpTypes = {
1576
1931
  "GET": "get",
1577
1932
  "HAS": "has",
@@ -1731,7 +2086,9 @@ getter: `, this.getter);
1731
2086
  "ASYNC_COMPONENT_LOADER": 13,
1732
2087
  "13": "ASYNC_COMPONENT_LOADER",
1733
2088
  "SCHEDULER": 14,
1734
- "14": "SCHEDULER"
2089
+ "14": "SCHEDULER",
2090
+ "APP_UNMOUNT_CLEANUP": 15,
2091
+ "15": "APP_UNMOUNT_CLEANUP"
1735
2092
  };
1736
2093
  const ErrorTypeStrings$1 = {
1737
2094
  ["sp"]: "serverPrefetch hook",
@@ -1762,7 +2119,8 @@ getter: `, this.getter);
1762
2119
  [11]: "app warnHandler",
1763
2120
  [12]: "ref function",
1764
2121
  [13]: "async component loader",
1765
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2122
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2123
+ [15]: "app unmount cleanup function"
1766
2124
  };
1767
2125
  function callWithErrorHandling(fn, instance, type, args) {
1768
2126
  try {
@@ -1864,7 +2222,7 @@ getter: `, this.getter);
1864
2222
  const middle = start + end >>> 1;
1865
2223
  const middleJob = queue[middle];
1866
2224
  const middleJobId = getId(middleJob);
1867
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2225
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1868
2226
  start = middle + 1;
1869
2227
  } else {
1870
2228
  end = middle;
@@ -1873,15 +2231,21 @@ getter: `, this.getter);
1873
2231
  return start;
1874
2232
  }
1875
2233
  function queueJob(job) {
1876
- if (!queue.length || !queue.includes(
1877
- job,
1878
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1879
- )) {
2234
+ var _a;
2235
+ if (!(job.flags & 1)) {
1880
2236
  if (job.id == null) {
1881
2237
  queue.push(job);
2238
+ } else if (
2239
+ // fast path when the job id is larger than the tail
2240
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2241
+ ) {
2242
+ queue.push(job);
1882
2243
  } else {
1883
2244
  queue.splice(findInsertionIndex(job.id), 0, job);
1884
2245
  }
2246
+ if (!(job.flags & 4)) {
2247
+ job.flags |= 1;
2248
+ }
1885
2249
  queueFlush();
1886
2250
  }
1887
2251
  }
@@ -1899,11 +2263,11 @@ getter: `, this.getter);
1899
2263
  }
1900
2264
  function queuePostFlushCb(cb) {
1901
2265
  if (!isArray(cb)) {
1902
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1903
- cb,
1904
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1905
- )) {
2266
+ if (!(cb.flags & 1)) {
1906
2267
  pendingPostFlushCbs.push(cb);
2268
+ if (!(cb.flags & 4)) {
2269
+ cb.flags |= 1;
2270
+ }
1907
2271
  }
1908
2272
  } else {
1909
2273
  pendingPostFlushCbs.push(...cb);
@@ -1916,7 +2280,7 @@ getter: `, this.getter);
1916
2280
  }
1917
2281
  for (; i < queue.length; i++) {
1918
2282
  const cb = queue[i];
1919
- if (cb && cb.pre) {
2283
+ if (cb && cb.flags & 2) {
1920
2284
  if (instance && cb.id !== instance.uid) {
1921
2285
  continue;
1922
2286
  }
@@ -1926,6 +2290,7 @@ getter: `, this.getter);
1926
2290
  queue.splice(i, 1);
1927
2291
  i--;
1928
2292
  cb();
2293
+ cb.flags &= ~1;
1929
2294
  }
1930
2295
  }
1931
2296
  }
@@ -1948,6 +2313,7 @@ getter: `, this.getter);
1948
2313
  continue;
1949
2314
  }
1950
2315
  activePostFlushCbs[postFlushIndex]();
2316
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1951
2317
  }
1952
2318
  activePostFlushCbs = null;
1953
2319
  postFlushIndex = 0;
@@ -1957,9 +2323,11 @@ getter: `, this.getter);
1957
2323
  const comparator = (a, b) => {
1958
2324
  const diff = getId(a) - getId(b);
1959
2325
  if (diff === 0) {
1960
- if (a.pre && !b.pre)
2326
+ const isAPre = a.flags & 2;
2327
+ const isBPre = b.flags & 2;
2328
+ if (isAPre && !isBPre)
1961
2329
  return -1;
1962
- if (b.pre && !a.pre)
2330
+ if (isBPre && !isAPre)
1963
2331
  return 1;
1964
2332
  }
1965
2333
  return diff;
@@ -1975,11 +2343,12 @@ getter: `, this.getter);
1975
2343
  try {
1976
2344
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1977
2345
  const job = queue[flushIndex];
1978
- if (job && job.active !== false) {
2346
+ if (job && !(job.flags & 8)) {
1979
2347
  if (check(job)) {
1980
2348
  continue;
1981
2349
  }
1982
2350
  callWithErrorHandling(job, null, 14);
2351
+ job.flags &= ~1;
1983
2352
  }
1984
2353
  }
1985
2354
  } finally {
@@ -2061,7 +2430,6 @@ getter: `, this.getter);
2061
2430
  }
2062
2431
  instance.renderCache = [];
2063
2432
  isHmrUpdating = true;
2064
- instance.effect.dirty = true;
2065
2433
  instance.update();
2066
2434
  isHmrUpdating = false;
2067
2435
  });
@@ -2089,7 +2457,6 @@ getter: `, this.getter);
2089
2457
  instance.ceReload(newComp.styles);
2090
2458
  hmrDirtyComponents.delete(oldComp);
2091
2459
  } else if (instance.parent) {
2092
- instance.parent.effect.dirty = true;
2093
2460
  queueJob(instance.parent.update);
2094
2461
  } else if (instance.appContext.reload) {
2095
2462
  instance.appContext.reload();
@@ -4058,8 +4425,8 @@ If this is a native custom element, make sure to exclude it from component resol
4058
4425
  };
4059
4426
  };
4060
4427
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4061
- const job = () => {
4062
- if (!effect.active || !effect.dirty) {
4428
+ const job = (immediateFirstRun) => {
4429
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4063
4430
  return;
4064
4431
  }
4065
4432
  if (cb) {
@@ -4080,19 +4447,22 @@ If this is a native custom element, make sure to exclude it from component resol
4080
4447
  effect.run();
4081
4448
  }
4082
4449
  };
4083
- job.allowRecurse = !!cb;
4450
+ if (cb)
4451
+ job.flags |= 4;
4452
+ const effect = new ReactiveEffect(getter);
4084
4453
  let scheduler;
4085
4454
  if (flush === "sync") {
4455
+ effect.flags |= 64;
4086
4456
  scheduler = job;
4087
4457
  } else if (flush === "post") {
4088
4458
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4089
4459
  } else {
4090
- job.pre = true;
4460
+ job.flags |= 2;
4091
4461
  if (instance)
4092
4462
  job.id = instance.uid;
4093
4463
  scheduler = () => queueJob(job);
4094
4464
  }
4095
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4465
+ effect.scheduler = scheduler;
4096
4466
  const scope = getCurrentScope();
4097
4467
  const unwatch = () => {
4098
4468
  effect.stop();
@@ -4106,7 +4476,7 @@ If this is a native custom element, make sure to exclude it from component resol
4106
4476
  }
4107
4477
  if (cb) {
4108
4478
  if (immediate) {
4109
- job();
4479
+ job(true);
4110
4480
  } else {
4111
4481
  oldValue = effect.run();
4112
4482
  }
@@ -4283,22 +4653,7 @@ If this is a native custom element, make sure to exclude it from component resol
4283
4653
  if (!children || !children.length) {
4284
4654
  return;
4285
4655
  }
4286
- let child = children[0];
4287
- if (children.length > 1) {
4288
- let hasFound = false;
4289
- for (const c of children) {
4290
- if (c.type !== Comment) {
4291
- if (hasFound) {
4292
- warn$1(
4293
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4294
- );
4295
- break;
4296
- }
4297
- child = c;
4298
- hasFound = true;
4299
- }
4300
- }
4301
- }
4656
+ const child = findNonCommentChild(children);
4302
4657
  const rawProps = toRaw(props);
4303
4658
  const { mode } = rawProps;
4304
4659
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4307,7 +4662,7 @@ If this is a native custom element, make sure to exclude it from component resol
4307
4662
  if (state.isLeaving) {
4308
4663
  return emptyPlaceholder(child);
4309
4664
  }
4310
- const innerChild = getKeepAliveChild(child);
4665
+ const innerChild = getInnerChild$1(child);
4311
4666
  if (!innerChild) {
4312
4667
  return emptyPlaceholder(child);
4313
4668
  }
@@ -4319,7 +4674,7 @@ If this is a native custom element, make sure to exclude it from component resol
4319
4674
  );
4320
4675
  setTransitionHooks(innerChild, enterHooks);
4321
4676
  const oldChild = instance.subTree;
4322
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4677
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4323
4678
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4324
4679
  const leavingHooks = resolveTransitionHooks(
4325
4680
  oldInnerChild,
@@ -4332,8 +4687,7 @@ If this is a native custom element, make sure to exclude it from component resol
4332
4687
  state.isLeaving = true;
4333
4688
  leavingHooks.afterLeave = () => {
4334
4689
  state.isLeaving = false;
4335
- if (instance.update.active !== false) {
4336
- instance.effect.dirty = true;
4690
+ if (!(instance.job.flags & 8)) {
4337
4691
  instance.update();
4338
4692
  }
4339
4693
  };
@@ -4361,6 +4715,25 @@ If this is a native custom element, make sure to exclude it from component resol
4361
4715
  {
4362
4716
  BaseTransitionImpl.__isBuiltIn = true;
4363
4717
  }
4718
+ function findNonCommentChild(children) {
4719
+ let child = children[0];
4720
+ if (children.length > 1) {
4721
+ let hasFound = false;
4722
+ for (const c of children) {
4723
+ if (c.type !== Comment) {
4724
+ if (hasFound) {
4725
+ warn$1(
4726
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4727
+ );
4728
+ break;
4729
+ }
4730
+ child = c;
4731
+ hasFound = true;
4732
+ }
4733
+ }
4734
+ }
4735
+ return child;
4736
+ }
4364
4737
  const BaseTransition = BaseTransitionImpl;
4365
4738
  function getLeavingNodesForType(state, vnode) {
4366
4739
  const { leavingVNodes } = state;
@@ -4515,8 +4888,11 @@ If this is a native custom element, make sure to exclude it from component resol
4515
4888
  return vnode;
4516
4889
  }
4517
4890
  }
4518
- function getKeepAliveChild(vnode) {
4891
+ function getInnerChild$1(vnode) {
4519
4892
  if (!isKeepAlive(vnode)) {
4893
+ if (isTeleport(vnode.type) && vnode.children) {
4894
+ return findNonCommentChild(vnode.children);
4895
+ }
4520
4896
  return vnode;
4521
4897
  }
4522
4898
  if (vnode.component) {
@@ -4685,7 +5061,6 @@ If this is a native custom element, make sure to exclude it from component resol
4685
5061
  load().then(() => {
4686
5062
  loaded.value = true;
4687
5063
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4688
- instance.parent.effect.dirty = true;
4689
5064
  queueJob(instance.parent.update);
4690
5065
  }
4691
5066
  }).catch((err) => {
@@ -5297,10 +5672,20 @@ If this is a native custom element, make sure to exclude it from component resol
5297
5672
  function renderList(source, renderItem, cache, index) {
5298
5673
  let ret;
5299
5674
  const cached = cache && cache[index];
5300
- if (isArray(source) || isString(source)) {
5675
+ const sourceIsArray = isArray(source);
5676
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5677
+ if (sourceIsArray || isString(source)) {
5678
+ if (sourceIsReactiveArray) {
5679
+ source = shallowReadArray(source);
5680
+ }
5301
5681
  ret = new Array(source.length);
5302
5682
  for (let i = 0, l = source.length; i < l; i++) {
5303
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5683
+ ret[i] = renderItem(
5684
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5685
+ i,
5686
+ void 0,
5687
+ cached && cached[i]
5688
+ );
5304
5689
  }
5305
5690
  } else if (typeof source === "number") {
5306
5691
  if (!Number.isInteger(source)) {
@@ -5671,7 +6056,6 @@ If this is a native custom element, make sure to exclude it from component resol
5671
6056
  $emit: (i) => i.emit,
5672
6057
  $options: (i) => resolveMergedOptions(i) ,
5673
6058
  $forceUpdate: (i) => i.f || (i.f = () => {
5674
- i.effect.dirty = true;
5675
6059
  queueJob(i.update);
5676
6060
  }),
5677
6061
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6542,7 +6926,7 @@ If this is a native custom element, make sure to exclude it from component resol
6542
6926
  return vm;
6543
6927
  }
6544
6928
  }
6545
- Vue.version = `2.6.14-compat:${"3.4.26"}`;
6929
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.2"}`;
6546
6930
  Vue.config = singletonApp.config;
6547
6931
  Vue.use = (plugin, ...options) => {
6548
6932
  if (plugin && isFunction(plugin.install)) {
@@ -6947,6 +7331,7 @@ If this is a native custom element, make sure to exclude it from component resol
6947
7331
  }
6948
7332
  const context = createAppContext();
6949
7333
  const installedPlugins = /* @__PURE__ */ new WeakSet();
7334
+ const pluginCleanupFns = [];
6950
7335
  let isMounted = false;
6951
7336
  const app = context.app = {
6952
7337
  _uid: uid$1++,
@@ -7064,8 +7449,21 @@ If you want to remount the same app, move your app creation logic into a factory
7064
7449
  );
7065
7450
  }
7066
7451
  },
7452
+ onUnmount(cleanupFn) {
7453
+ if (typeof cleanupFn !== "function") {
7454
+ warn$1(
7455
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
7456
+ );
7457
+ }
7458
+ pluginCleanupFns.push(cleanupFn);
7459
+ },
7067
7460
  unmount() {
7068
7461
  if (isMounted) {
7462
+ callWithAsyncErrorHandling(
7463
+ pluginCleanupFns,
7464
+ app._instance,
7465
+ 15
7466
+ );
7069
7467
  render(null, app._container);
7070
7468
  {
7071
7469
  app._instance = null;
@@ -7560,7 +7958,9 @@ If you want to remount the same app, move your app creation logic into a factory
7560
7958
  function assertType(value, type) {
7561
7959
  let valid;
7562
7960
  const expectedType = getType(type);
7563
- if (isSimpleType(expectedType)) {
7961
+ if (expectedType === "null") {
7962
+ valid = value === null;
7963
+ } else if (isSimpleType(expectedType)) {
7564
7964
  const t = typeof value;
7565
7965
  valid = t === expectedType.toLowerCase();
7566
7966
  if (!valid && t === "object") {
@@ -7570,8 +7970,6 @@ If you want to remount the same app, move your app creation logic into a factory
7570
7970
  valid = isObject(value);
7571
7971
  } else if (expectedType === "Array") {
7572
7972
  valid = isArray(value);
7573
- } else if (expectedType === "null") {
7574
- valid = value === null;
7575
7973
  } else {
7576
7974
  valid = value instanceof type;
7577
7975
  }
@@ -9096,7 +9494,6 @@ Server rendered element contains fewer child nodes than client vdom.`
9096
9494
  } else {
9097
9495
  instance.next = n2;
9098
9496
  invalidateJob(instance.update);
9099
- instance.effect.dirty = true;
9100
9497
  instance.update();
9101
9498
  }
9102
9499
  } else {
@@ -9303,24 +9700,18 @@ Server rendered element contains fewer child nodes than client vdom.`
9303
9700
  }
9304
9701
  }
9305
9702
  };
9306
- const effect = instance.effect = new ReactiveEffect(
9307
- componentUpdateFn,
9308
- NOOP,
9309
- () => queueJob(update),
9310
- instance.scope
9311
- // track it in component's effect scope
9312
- );
9313
- const update = instance.update = () => {
9314
- if (effect.dirty) {
9315
- effect.run();
9316
- }
9317
- };
9318
- update.id = instance.uid;
9703
+ instance.scope.on();
9704
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9705
+ instance.scope.off();
9706
+ const update = instance.update = effect.run.bind(effect);
9707
+ const job = instance.job = effect.runIfDirty.bind(effect);
9708
+ job.id = instance.uid;
9709
+ effect.scheduler = () => queueJob(job);
9319
9710
  toggleRecurse(instance, true);
9320
9711
  {
9321
9712
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9322
9713
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9323
- update.ownerInstance = instance;
9714
+ job.ownerInstance = instance;
9324
9715
  }
9325
9716
  update();
9326
9717
  };
@@ -9787,7 +10178,7 @@ Server rendered element contains fewer child nodes than client vdom.`
9787
10178
  if (instance.type.__hmrId) {
9788
10179
  unregisterHMR(instance);
9789
10180
  }
9790
- const { bum, scope, update, subTree, um } = instance;
10181
+ const { bum, scope, job, subTree, um } = instance;
9791
10182
  if (bum) {
9792
10183
  invokeArrayFns(bum);
9793
10184
  }
@@ -9795,8 +10186,8 @@ Server rendered element contains fewer child nodes than client vdom.`
9795
10186
  instance.emit("hook:beforeDestroy");
9796
10187
  }
9797
10188
  scope.stop();
9798
- if (update) {
9799
- update.active = false;
10189
+ if (job) {
10190
+ job.flags |= 8;
9800
10191
  unmount(subTree, instance, parentSuspense, doRemove);
9801
10192
  }
9802
10193
  if (um) {
@@ -9888,8 +10279,14 @@ Server rendered element contains fewer child nodes than client vdom.`
9888
10279
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9889
10280
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9890
10281
  }
9891
- function toggleRecurse({ effect, update }, allowed) {
9892
- effect.allowRecurse = update.allowRecurse = allowed;
10282
+ function toggleRecurse({ effect, job }, allowed) {
10283
+ if (allowed) {
10284
+ effect.flags |= 32;
10285
+ job.flags |= 4;
10286
+ } else {
10287
+ effect.flags &= ~32;
10288
+ job.flags &= ~4;
10289
+ }
9893
10290
  }
9894
10291
  function needTransition(parentSuspense, transition) {
9895
10292
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10690,6 +11087,7 @@ Component that was made reactive: `,
10690
11087
  effect: null,
10691
11088
  update: null,
10692
11089
  // will be set synchronously right after creation
11090
+ job: null,
10693
11091
  scope: new EffectScope(
10694
11092
  true
10695
11093
  /* detached */
@@ -11195,7 +11593,8 @@ Component that was made reactive: `,
11195
11593
  {},
11196
11594
  ["span", vueStyle, genRefFlag(obj)],
11197
11595
  "<",
11198
- formatValue(obj.value),
11596
+ // avoid debugger accessing value affecting behavior
11597
+ formatValue("_value" in obj ? obj._value : obj),
11199
11598
  `>`
11200
11599
  ];
11201
11600
  } else if (isReactive(obj)) {
@@ -11375,7 +11774,7 @@ Component that was made reactive: `,
11375
11774
  return true;
11376
11775
  }
11377
11776
 
11378
- const version = "3.4.26";
11777
+ const version = "3.5.0-alpha.2";
11379
11778
  const warn = warn$1 ;
11380
11779
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11381
11780
  const devtools = devtools$1 ;
@@ -12930,7 +13329,9 @@ Expected function or array of functions, received type ${typeof value}.`
12930
13329
  return;
12931
13330
  }
12932
13331
  const eventKey = hyphenate(event.key);
12933
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13332
+ if (modifiers.some(
13333
+ (k) => k === eventKey || keyNames[k] === eventKey
13334
+ )) {
12934
13335
  return fn(event);
12935
13336
  }
12936
13337
  {
@@ -18907,9 +19308,183 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
18907
19308
  }
18908
19309
  };
18909
19310
 
19311
+ function isValidHTMLNesting(parent, child) {
19312
+ if (parent in onlyValidChildren) {
19313
+ return onlyValidChildren[parent].has(child);
19314
+ }
19315
+ if (child in onlyValidParents) {
19316
+ return onlyValidParents[child].has(parent);
19317
+ }
19318
+ if (parent in knownInvalidChildren) {
19319
+ if (knownInvalidChildren[parent].has(child))
19320
+ return false;
19321
+ }
19322
+ if (child in knownInvalidParents) {
19323
+ if (knownInvalidParents[child].has(parent))
19324
+ return false;
19325
+ }
19326
+ return true;
19327
+ }
19328
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
19329
+ const emptySet = /* @__PURE__ */ new Set([]);
19330
+ const onlyValidChildren = {
19331
+ head: /* @__PURE__ */ new Set([
19332
+ "base",
19333
+ "basefront",
19334
+ "bgsound",
19335
+ "link",
19336
+ "meta",
19337
+ "title",
19338
+ "noscript",
19339
+ "noframes",
19340
+ "style",
19341
+ "script",
19342
+ "template"
19343
+ ]),
19344
+ optgroup: /* @__PURE__ */ new Set(["option"]),
19345
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
19346
+ // table
19347
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
19348
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
19349
+ colgroup: /* @__PURE__ */ new Set(["col"]),
19350
+ tbody: /* @__PURE__ */ new Set(["tr"]),
19351
+ thead: /* @__PURE__ */ new Set(["tr"]),
19352
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
19353
+ // these elements can not have any children elements
19354
+ script: emptySet,
19355
+ iframe: emptySet,
19356
+ option: emptySet,
19357
+ textarea: emptySet,
19358
+ style: emptySet,
19359
+ title: emptySet
19360
+ };
19361
+ const onlyValidParents = {
19362
+ // sections
19363
+ html: emptySet,
19364
+ body: /* @__PURE__ */ new Set(["html"]),
19365
+ head: /* @__PURE__ */ new Set(["html"]),
19366
+ // table
19367
+ td: /* @__PURE__ */ new Set(["tr"]),
19368
+ colgroup: /* @__PURE__ */ new Set(["table"]),
19369
+ caption: /* @__PURE__ */ new Set(["table"]),
19370
+ tbody: /* @__PURE__ */ new Set(["table"]),
19371
+ tfoot: /* @__PURE__ */ new Set(["table"]),
19372
+ col: /* @__PURE__ */ new Set(["colgroup"]),
19373
+ th: /* @__PURE__ */ new Set(["tr"]),
19374
+ thead: /* @__PURE__ */ new Set(["table"]),
19375
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
19376
+ // data list
19377
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
19378
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
19379
+ // other
19380
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
19381
+ // li: new Set(["ul", "ol"]),
19382
+ summary: /* @__PURE__ */ new Set(["details"]),
19383
+ area: /* @__PURE__ */ new Set(["map"])
19384
+ };
19385
+ const knownInvalidChildren = {
19386
+ p: /* @__PURE__ */ new Set([
19387
+ "address",
19388
+ "article",
19389
+ "aside",
19390
+ "blockquote",
19391
+ "center",
19392
+ "details",
19393
+ "dialog",
19394
+ "dir",
19395
+ "div",
19396
+ "dl",
19397
+ "fieldset",
19398
+ "figure",
19399
+ "footer",
19400
+ "form",
19401
+ "h1",
19402
+ "h2",
19403
+ "h3",
19404
+ "h4",
19405
+ "h5",
19406
+ "h6",
19407
+ "header",
19408
+ "hgroup",
19409
+ "hr",
19410
+ "li",
19411
+ "main",
19412
+ "nav",
19413
+ "menu",
19414
+ "ol",
19415
+ "p",
19416
+ "pre",
19417
+ "section",
19418
+ "table",
19419
+ "ul"
19420
+ ]),
19421
+ svg: /* @__PURE__ */ new Set([
19422
+ "b",
19423
+ "blockquote",
19424
+ "br",
19425
+ "code",
19426
+ "dd",
19427
+ "div",
19428
+ "dl",
19429
+ "dt",
19430
+ "em",
19431
+ "embed",
19432
+ "h1",
19433
+ "h2",
19434
+ "h3",
19435
+ "h4",
19436
+ "h5",
19437
+ "h6",
19438
+ "hr",
19439
+ "i",
19440
+ "img",
19441
+ "li",
19442
+ "menu",
19443
+ "meta",
19444
+ "ol",
19445
+ "p",
19446
+ "pre",
19447
+ "ruby",
19448
+ "s",
19449
+ "small",
19450
+ "span",
19451
+ "strong",
19452
+ "sub",
19453
+ "sup",
19454
+ "table",
19455
+ "u",
19456
+ "ul",
19457
+ "var"
19458
+ ])
19459
+ };
19460
+ const knownInvalidParents = {
19461
+ a: /* @__PURE__ */ new Set(["a"]),
19462
+ button: /* @__PURE__ */ new Set(["button"]),
19463
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
19464
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
19465
+ form: /* @__PURE__ */ new Set(["form"]),
19466
+ li: /* @__PURE__ */ new Set(["li"]),
19467
+ h1: headings,
19468
+ h2: headings,
19469
+ h3: headings,
19470
+ h4: headings,
19471
+ h5: headings,
19472
+ h6: headings
19473
+ };
19474
+
19475
+ const validateHtmlNesting = (node, context) => {
19476
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
19477
+ const error = new SyntaxError(
19478
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
19479
+ );
19480
+ error.loc = node.loc;
19481
+ context.onWarn(error);
19482
+ }
19483
+ };
19484
+
18910
19485
  const DOMNodeTransforms = [
18911
19486
  transformStyle,
18912
- ...[transformTransition]
19487
+ ...[transformTransition, validateHtmlNesting]
18913
19488
  ];
18914
19489
  const DOMDirectiveTransforms = {
18915
19490
  cloak: noopDirectiveTransform,