@vue/compat 3.4.25 → 3.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.4.25
2
+ * @vue/compat v3.5.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -500,157 +500,280 @@ class EffectScope {
500
500
  function effectScope(detached) {
501
501
  return new EffectScope(detached);
502
502
  }
503
- function recordEffectScope(effect, scope = activeEffectScope) {
504
- if (scope && scope.active) {
505
- scope.effects.push(effect);
506
- }
507
- }
508
503
  function getCurrentScope() {
509
504
  return activeEffectScope;
510
505
  }
511
- function onScopeDispose(fn) {
506
+ function onScopeDispose(fn, failSilently = false) {
512
507
  if (activeEffectScope) {
513
508
  activeEffectScope.cleanups.push(fn);
514
- } else {
509
+ } else if (!failSilently) {
515
510
  warn$2(
516
511
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
517
512
  );
518
513
  }
519
514
  }
520
515
 
521
- let activeEffect;
516
+ let activeSub;
522
517
  class ReactiveEffect {
523
- constructor(fn, trigger, scheduler, scope) {
518
+ constructor(fn) {
524
519
  this.fn = fn;
525
- this.trigger = trigger;
526
- this.scheduler = scheduler;
527
- this.active = true;
528
- this.deps = [];
529
520
  /**
530
521
  * @internal
531
522
  */
532
- this._dirtyLevel = 4;
523
+ this.deps = void 0;
533
524
  /**
534
525
  * @internal
535
526
  */
536
- this._trackId = 0;
527
+ this.depsTail = void 0;
537
528
  /**
538
529
  * @internal
539
530
  */
540
- this._runnings = 0;
531
+ this.flags = 1 | 4;
541
532
  /**
542
533
  * @internal
543
534
  */
544
- this._shouldSchedule = false;
535
+ this.nextEffect = void 0;
545
536
  /**
546
537
  * @internal
547
538
  */
548
- this._depsLength = 0;
549
- recordEffectScope(this, scope);
550
- }
551
- get dirty() {
552
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
553
- this._dirtyLevel = 1;
554
- pauseTracking();
555
- for (let i = 0; i < this._depsLength; i++) {
556
- const dep = this.deps[i];
557
- if (dep.computed) {
558
- triggerComputed(dep.computed);
559
- if (this._dirtyLevel >= 4) {
560
- break;
561
- }
562
- }
563
- }
564
- if (this._dirtyLevel === 1) {
565
- this._dirtyLevel = 0;
566
- }
567
- resetTracking();
539
+ this.cleanup = void 0;
540
+ this.scheduler = void 0;
541
+ if (activeEffectScope && activeEffectScope.active) {
542
+ activeEffectScope.effects.push(this);
568
543
  }
569
- return this._dirtyLevel >= 4;
570
544
  }
571
- set dirty(v) {
572
- this._dirtyLevel = v ? 4 : 0;
545
+ /**
546
+ * @internal
547
+ */
548
+ notify() {
549
+ if (this.flags & 2 && !(this.flags & 32)) {
550
+ return;
551
+ }
552
+ if (this.flags & 64) {
553
+ return this.trigger();
554
+ }
555
+ if (!(this.flags & 8)) {
556
+ this.flags |= 8;
557
+ this.nextEffect = batchedEffect;
558
+ batchedEffect = this;
559
+ }
573
560
  }
574
561
  run() {
575
- this._dirtyLevel = 0;
576
- if (!this.active) {
562
+ if (!(this.flags & 1)) {
577
563
  return this.fn();
578
564
  }
579
- let lastShouldTrack = shouldTrack;
580
- let lastEffect = activeEffect;
565
+ this.flags |= 2;
566
+ cleanupEffect(this);
567
+ prepareDeps(this);
568
+ const prevEffect = activeSub;
569
+ const prevShouldTrack = shouldTrack;
570
+ activeSub = this;
571
+ shouldTrack = true;
581
572
  try {
582
- shouldTrack = true;
583
- activeEffect = this;
584
- this._runnings++;
585
- preCleanupEffect(this);
586
573
  return this.fn();
587
574
  } finally {
588
- postCleanupEffect(this);
589
- this._runnings--;
590
- activeEffect = lastEffect;
591
- shouldTrack = lastShouldTrack;
575
+ if (activeSub !== this) {
576
+ warn$2(
577
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
578
+ );
579
+ }
580
+ cleanupDeps(this);
581
+ activeSub = prevEffect;
582
+ shouldTrack = prevShouldTrack;
583
+ this.flags &= ~2;
592
584
  }
593
585
  }
594
586
  stop() {
595
- var _a;
596
- if (this.active) {
597
- preCleanupEffect(this);
598
- postCleanupEffect(this);
599
- (_a = this.onStop) == null ? void 0 : _a.call(this);
600
- this.active = false;
587
+ if (this.flags & 1) {
588
+ for (let link = this.deps; link; link = link.nextDep) {
589
+ removeSub(link);
590
+ }
591
+ this.deps = this.depsTail = void 0;
592
+ cleanupEffect(this);
593
+ this.onStop && this.onStop();
594
+ this.flags &= ~1;
601
595
  }
602
596
  }
597
+ trigger() {
598
+ if (this.scheduler) {
599
+ this.scheduler();
600
+ } else {
601
+ this.runIfDirty();
602
+ }
603
+ }
604
+ /**
605
+ * @internal
606
+ */
607
+ runIfDirty() {
608
+ if (isDirty(this)) {
609
+ this.run();
610
+ }
611
+ }
612
+ get dirty() {
613
+ return isDirty(this);
614
+ }
615
+ }
616
+ let batchDepth = 0;
617
+ let batchedEffect;
618
+ function startBatch() {
619
+ batchDepth++;
603
620
  }
604
- function triggerComputed(computed) {
605
- return computed.value;
621
+ function endBatch() {
622
+ if (batchDepth > 1) {
623
+ batchDepth--;
624
+ return;
625
+ }
626
+ let error;
627
+ while (batchedEffect) {
628
+ let e = batchedEffect;
629
+ batchedEffect = void 0;
630
+ while (e) {
631
+ const next = e.nextEffect;
632
+ e.nextEffect = void 0;
633
+ e.flags &= ~8;
634
+ if (e.flags & 1) {
635
+ try {
636
+ e.trigger();
637
+ } catch (err) {
638
+ if (!error)
639
+ error = err;
640
+ }
641
+ }
642
+ e = next;
643
+ }
644
+ }
645
+ batchDepth--;
646
+ if (error)
647
+ throw error;
606
648
  }
607
- function preCleanupEffect(effect2) {
608
- effect2._trackId++;
609
- effect2._depsLength = 0;
649
+ function prepareDeps(sub) {
650
+ for (let link = sub.deps; link; link = link.nextDep) {
651
+ link.version = -1;
652
+ link.prevActiveLink = link.dep.activeLink;
653
+ link.dep.activeLink = link;
654
+ }
610
655
  }
611
- function postCleanupEffect(effect2) {
612
- if (effect2.deps.length > effect2._depsLength) {
613
- for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
614
- cleanupDepEffect(effect2.deps[i], effect2);
656
+ function cleanupDeps(sub) {
657
+ let head;
658
+ let tail = sub.depsTail;
659
+ for (let link = tail; link; link = link.prevDep) {
660
+ if (link.version === -1) {
661
+ if (link === tail)
662
+ tail = link.prevDep;
663
+ removeSub(link);
664
+ removeDep(link);
665
+ } else {
666
+ head = link;
615
667
  }
616
- effect2.deps.length = effect2._depsLength;
668
+ link.dep.activeLink = link.prevActiveLink;
669
+ link.prevActiveLink = void 0;
617
670
  }
671
+ sub.deps = head;
672
+ sub.depsTail = tail;
618
673
  }
619
- function cleanupDepEffect(dep, effect2) {
620
- const trackId = dep.get(effect2);
621
- if (trackId !== void 0 && effect2._trackId !== trackId) {
622
- dep.delete(effect2);
623
- if (dep.size === 0) {
624
- dep.cleanup();
674
+ function isDirty(sub) {
675
+ for (let link = sub.deps; link; link = link.nextDep) {
676
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
677
+ return true;
625
678
  }
626
679
  }
680
+ if (sub._dirty) {
681
+ return true;
682
+ }
683
+ return false;
684
+ }
685
+ function refreshComputed(computed) {
686
+ if (computed.flags & 2) {
687
+ return false;
688
+ }
689
+ if (computed.flags & 4 && !(computed.flags & 16)) {
690
+ return;
691
+ }
692
+ computed.flags &= ~16;
693
+ if (computed.globalVersion === globalVersion) {
694
+ return;
695
+ }
696
+ computed.globalVersion = globalVersion;
697
+ const dep = computed.dep;
698
+ computed.flags |= 2;
699
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
700
+ computed.flags &= ~2;
701
+ return;
702
+ }
703
+ const prevSub = activeSub;
704
+ const prevShouldTrack = shouldTrack;
705
+ activeSub = computed;
706
+ shouldTrack = true;
707
+ try {
708
+ prepareDeps(computed);
709
+ const value = computed.fn();
710
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
711
+ computed._value = value;
712
+ dep.version++;
713
+ }
714
+ } catch (err) {
715
+ dep.version++;
716
+ throw err;
717
+ } finally {
718
+ activeSub = prevSub;
719
+ shouldTrack = prevShouldTrack;
720
+ cleanupDeps(computed);
721
+ computed.flags &= ~2;
722
+ }
723
+ }
724
+ function removeSub(link) {
725
+ const { dep, prevSub, nextSub } = link;
726
+ if (prevSub) {
727
+ prevSub.nextSub = nextSub;
728
+ link.prevSub = void 0;
729
+ }
730
+ if (nextSub) {
731
+ nextSub.prevSub = prevSub;
732
+ link.nextSub = void 0;
733
+ }
734
+ if (dep.subs === link) {
735
+ dep.subs = prevSub;
736
+ }
737
+ if (!dep.subs && dep.computed) {
738
+ dep.computed.flags &= ~4;
739
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
740
+ removeSub(l);
741
+ }
742
+ }
743
+ }
744
+ function removeDep(link) {
745
+ const { prevDep, nextDep } = link;
746
+ if (prevDep) {
747
+ prevDep.nextDep = nextDep;
748
+ link.prevDep = void 0;
749
+ }
750
+ if (nextDep) {
751
+ nextDep.prevDep = prevDep;
752
+ link.nextDep = void 0;
753
+ }
627
754
  }
628
755
  function effect(fn, options) {
629
756
  if (fn.effect instanceof ReactiveEffect) {
630
757
  fn = fn.effect.fn;
631
758
  }
632
- const _effect = new ReactiveEffect(fn, NOOP, () => {
633
- if (_effect.dirty) {
634
- _effect.run();
635
- }
636
- });
759
+ const e = new ReactiveEffect(fn);
637
760
  if (options) {
638
- extend(_effect, options);
639
- if (options.scope)
640
- recordEffectScope(_effect, options.scope);
761
+ extend(e, options);
641
762
  }
642
- if (!options || !options.lazy) {
643
- _effect.run();
763
+ try {
764
+ e.run();
765
+ } catch (err) {
766
+ e.stop();
767
+ throw err;
644
768
  }
645
- const runner = _effect.run.bind(_effect);
646
- runner.effect = _effect;
769
+ const runner = e.run.bind(e);
770
+ runner.effect = e;
647
771
  return runner;
648
772
  }
649
773
  function stop(runner) {
650
774
  runner.effect.stop();
651
775
  }
652
776
  let shouldTrack = true;
653
- let pauseScheduleStack = 0;
654
777
  const trackStack = [];
655
778
  function pauseTracking() {
656
779
  trackStack.push(shouldTrack);
@@ -660,192 +783,414 @@ function resetTracking() {
660
783
  const last = trackStack.pop();
661
784
  shouldTrack = last === void 0 ? true : last;
662
785
  }
663
- function pauseScheduling() {
664
- pauseScheduleStack++;
665
- }
666
- function resetScheduling() {
667
- pauseScheduleStack--;
668
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
669
- queueEffectSchedulers.shift()();
786
+ function cleanupEffect(e) {
787
+ const { cleanup } = e;
788
+ e.cleanup = void 0;
789
+ if (cleanup) {
790
+ const prevSub = activeSub;
791
+ activeSub = void 0;
792
+ try {
793
+ cleanup();
794
+ } finally {
795
+ activeSub = prevSub;
796
+ }
670
797
  }
671
798
  }
672
- function trackEffect(effect2, dep, debuggerEventExtraInfo) {
673
- var _a;
674
- if (dep.get(effect2) !== effect2._trackId) {
675
- dep.set(effect2, effect2._trackId);
676
- const oldDep = effect2.deps[effect2._depsLength];
677
- if (oldDep !== dep) {
678
- if (oldDep) {
679
- cleanupDepEffect(oldDep, effect2);
680
- }
681
- effect2.deps[effect2._depsLength++] = dep;
682
- } else {
683
- effect2._depsLength++;
684
- }
799
+
800
+ let globalVersion = 0;
801
+ class Dep {
802
+ constructor(computed) {
803
+ this.computed = computed;
804
+ this.version = 0;
805
+ /**
806
+ * Link between this dep and the current active effect
807
+ */
808
+ this.activeLink = void 0;
809
+ /**
810
+ * Doubly linked list representing the subscribing effects (tail)
811
+ */
812
+ this.subs = void 0;
685
813
  {
686
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
814
+ this.subsHead = void 0;
687
815
  }
688
816
  }
689
- }
690
- const queueEffectSchedulers = [];
691
- function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
692
- var _a;
693
- pauseScheduling();
694
- for (const effect2 of dep.keys()) {
695
- let tracking;
696
- if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
697
- effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
698
- effect2._dirtyLevel = dirtyLevel;
699
- }
700
- if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
701
- {
702
- (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
817
+ track(debugInfo) {
818
+ if (!activeSub || !shouldTrack) {
819
+ return;
820
+ }
821
+ let link = this.activeLink;
822
+ if (link === void 0 || link.sub !== activeSub) {
823
+ link = this.activeLink = {
824
+ dep: this,
825
+ sub: activeSub,
826
+ version: this.version,
827
+ nextDep: void 0,
828
+ prevDep: void 0,
829
+ nextSub: void 0,
830
+ prevSub: void 0,
831
+ prevActiveLink: void 0
832
+ };
833
+ if (!activeSub.deps) {
834
+ activeSub.deps = activeSub.depsTail = link;
835
+ } else {
836
+ link.prevDep = activeSub.depsTail;
837
+ activeSub.depsTail.nextDep = link;
838
+ activeSub.depsTail = link;
839
+ }
840
+ if (activeSub.flags & 4) {
841
+ addSub(link);
842
+ }
843
+ } else if (link.version === -1) {
844
+ link.version = this.version;
845
+ if (link.nextDep) {
846
+ const next = link.nextDep;
847
+ next.prevDep = link.prevDep;
848
+ if (link.prevDep) {
849
+ link.prevDep.nextDep = next;
850
+ }
851
+ link.prevDep = activeSub.depsTail;
852
+ link.nextDep = void 0;
853
+ activeSub.depsTail.nextDep = link;
854
+ activeSub.depsTail = link;
855
+ if (activeSub.deps === link) {
856
+ activeSub.deps = next;
857
+ }
703
858
  }
704
- effect2.trigger();
705
- if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
706
- effect2._shouldSchedule = false;
707
- if (effect2.scheduler) {
708
- queueEffectSchedulers.push(effect2.scheduler);
859
+ }
860
+ if (activeSub.onTrack) {
861
+ activeSub.onTrack(
862
+ extend(
863
+ {
864
+ effect: activeSub
865
+ },
866
+ debugInfo
867
+ )
868
+ );
869
+ }
870
+ return link;
871
+ }
872
+ trigger(debugInfo) {
873
+ this.version++;
874
+ globalVersion++;
875
+ this.notify(debugInfo);
876
+ }
877
+ notify(debugInfo) {
878
+ startBatch();
879
+ try {
880
+ if (true) {
881
+ for (let head = this.subsHead; head; head = head.nextSub) {
882
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
883
+ head.sub.onTrigger(
884
+ extend(
885
+ {
886
+ effect: head.sub
887
+ },
888
+ debugInfo
889
+ )
890
+ );
891
+ }
709
892
  }
710
893
  }
894
+ for (let link = this.subs; link; link = link.prevSub) {
895
+ link.sub.notify();
896
+ }
897
+ } finally {
898
+ endBatch();
711
899
  }
712
900
  }
713
- resetScheduling();
714
901
  }
715
-
716
- const createDep = (cleanup, computed) => {
717
- const dep = /* @__PURE__ */ new Map();
718
- dep.cleanup = cleanup;
719
- dep.computed = computed;
720
- return dep;
721
- };
722
-
902
+ function addSub(link) {
903
+ const computed = link.dep.computed;
904
+ if (computed && !link.dep.subs) {
905
+ computed.flags |= 4 | 16;
906
+ for (let l = computed.deps; l; l = l.nextDep) {
907
+ addSub(l);
908
+ }
909
+ }
910
+ const currentTail = link.dep.subs;
911
+ if (currentTail !== link) {
912
+ link.prevSub = currentTail;
913
+ if (currentTail)
914
+ currentTail.nextSub = link;
915
+ }
916
+ if (link.dep.subsHead === void 0) {
917
+ link.dep.subsHead = link;
918
+ }
919
+ link.dep.subs = link;
920
+ }
723
921
  const targetMap = /* @__PURE__ */ new WeakMap();
724
- const ITERATE_KEY = Symbol("iterate" );
725
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
922
+ const ITERATE_KEY = Symbol("Object iterate" );
923
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
924
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
726
925
  function track(target, type, key) {
727
- if (shouldTrack && activeEffect) {
926
+ if (shouldTrack && activeSub) {
728
927
  let depsMap = targetMap.get(target);
729
928
  if (!depsMap) {
730
929
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
731
930
  }
732
931
  let dep = depsMap.get(key);
733
932
  if (!dep) {
734
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
933
+ depsMap.set(key, dep = new Dep());
735
934
  }
736
- trackEffect(
737
- activeEffect,
738
- dep,
739
- {
935
+ {
936
+ dep.track({
740
937
  target,
741
938
  type,
742
939
  key
743
- }
744
- );
940
+ });
941
+ }
745
942
  }
746
943
  }
747
944
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
748
945
  const depsMap = targetMap.get(target);
749
946
  if (!depsMap) {
947
+ globalVersion++;
750
948
  return;
751
949
  }
752
950
  let deps = [];
753
951
  if (type === "clear") {
754
952
  deps = [...depsMap.values()];
755
- } else if (key === "length" && isArray(target)) {
756
- const newLength = Number(newValue);
757
- depsMap.forEach((dep, key2) => {
758
- if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
759
- deps.push(dep);
760
- }
761
- });
762
953
  } else {
763
- if (key !== void 0) {
764
- deps.push(depsMap.get(key));
765
- }
766
- switch (type) {
767
- case "add":
768
- if (!isArray(target)) {
769
- deps.push(depsMap.get(ITERATE_KEY));
770
- if (isMap(target)) {
771
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
772
- }
773
- } else if (isIntegerKey(key)) {
774
- deps.push(depsMap.get("length"));
954
+ const targetIsArray = isArray(target);
955
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
956
+ if (targetIsArray && key === "length") {
957
+ const newLength = Number(newValue);
958
+ depsMap.forEach((dep, key2) => {
959
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
960
+ deps.push(dep);
775
961
  }
776
- break;
777
- case "delete":
778
- if (!isArray(target)) {
779
- deps.push(depsMap.get(ITERATE_KEY));
962
+ });
963
+ } else {
964
+ const push = (dep) => dep && deps.push(dep);
965
+ if (key !== void 0) {
966
+ push(depsMap.get(key));
967
+ }
968
+ if (isArrayIndex) {
969
+ push(depsMap.get(ARRAY_ITERATE_KEY));
970
+ }
971
+ switch (type) {
972
+ case "add":
973
+ if (!targetIsArray) {
974
+ push(depsMap.get(ITERATE_KEY));
975
+ if (isMap(target)) {
976
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
977
+ }
978
+ } else if (isArrayIndex) {
979
+ push(depsMap.get("length"));
980
+ }
981
+ break;
982
+ case "delete":
983
+ if (!targetIsArray) {
984
+ push(depsMap.get(ITERATE_KEY));
985
+ if (isMap(target)) {
986
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
987
+ }
988
+ }
989
+ break;
990
+ case "set":
780
991
  if (isMap(target)) {
781
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
992
+ push(depsMap.get(ITERATE_KEY));
782
993
  }
783
- }
784
- break;
785
- case "set":
786
- if (isMap(target)) {
787
- deps.push(depsMap.get(ITERATE_KEY));
788
- }
789
- break;
994
+ break;
995
+ }
790
996
  }
791
997
  }
792
- pauseScheduling();
998
+ startBatch();
793
999
  for (const dep of deps) {
794
- if (dep) {
795
- triggerEffects(
796
- dep,
797
- 4,
798
- {
799
- target,
800
- type,
801
- key,
802
- newValue,
803
- oldValue,
804
- oldTarget
805
- }
806
- );
1000
+ {
1001
+ dep.trigger({
1002
+ target,
1003
+ type,
1004
+ key,
1005
+ newValue,
1006
+ oldValue,
1007
+ oldTarget
1008
+ });
807
1009
  }
808
1010
  }
809
- resetScheduling();
1011
+ endBatch();
810
1012
  }
811
1013
  function getDepFromReactive(object, key) {
812
1014
  var _a;
813
1015
  return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
814
1016
  }
815
1017
 
1018
+ function reactiveReadArray(array) {
1019
+ const raw = toRaw(array);
1020
+ if (raw === array)
1021
+ return raw;
1022
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
1023
+ return isShallow(array) ? raw : raw.map(toReactive);
1024
+ }
1025
+ function shallowReadArray(arr) {
1026
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
1027
+ return arr;
1028
+ }
1029
+ const arrayInstrumentations = {
1030
+ __proto__: null,
1031
+ [Symbol.iterator]() {
1032
+ return iterator(this, Symbol.iterator, toReactive);
1033
+ },
1034
+ concat(...args) {
1035
+ return reactiveReadArray(this).concat(
1036
+ ...args.map((x) => reactiveReadArray(x))
1037
+ );
1038
+ },
1039
+ entries() {
1040
+ return iterator(this, "entries", (value) => {
1041
+ value[1] = toReactive(value[1]);
1042
+ return value;
1043
+ });
1044
+ },
1045
+ every(fn, thisArg) {
1046
+ return apply(this, "every", fn, thisArg);
1047
+ },
1048
+ filter(fn, thisArg) {
1049
+ const result = apply(this, "filter", fn, thisArg);
1050
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
1051
+ },
1052
+ find(fn, thisArg) {
1053
+ const result = apply(this, "find", fn, thisArg);
1054
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1055
+ },
1056
+ findIndex(fn, thisArg) {
1057
+ return apply(this, "findIndex", fn, thisArg);
1058
+ },
1059
+ findLast(fn, thisArg) {
1060
+ const result = apply(this, "findLast", fn, thisArg);
1061
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1062
+ },
1063
+ findLastIndex(fn, thisArg) {
1064
+ return apply(this, "findLastIndex", fn, thisArg);
1065
+ },
1066
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1067
+ forEach(fn, thisArg) {
1068
+ return apply(this, "forEach", fn, thisArg);
1069
+ },
1070
+ includes(...args) {
1071
+ return searchProxy(this, "includes", args);
1072
+ },
1073
+ indexOf(...args) {
1074
+ return searchProxy(this, "indexOf", args);
1075
+ },
1076
+ join(separator) {
1077
+ return reactiveReadArray(this).join(separator);
1078
+ },
1079
+ // keys() iterator only reads `length`, no optimisation required
1080
+ lastIndexOf(...args) {
1081
+ return searchProxy(this, "lastIndexOf", args);
1082
+ },
1083
+ map(fn, thisArg) {
1084
+ return apply(this, "map", fn, thisArg);
1085
+ },
1086
+ pop() {
1087
+ return noTracking(this, "pop");
1088
+ },
1089
+ push(...args) {
1090
+ return noTracking(this, "push", args);
1091
+ },
1092
+ reduce(fn, ...args) {
1093
+ return reduce(this, "reduce", fn, args);
1094
+ },
1095
+ reduceRight(fn, ...args) {
1096
+ return reduce(this, "reduceRight", fn, args);
1097
+ },
1098
+ shift() {
1099
+ return noTracking(this, "shift");
1100
+ },
1101
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1102
+ some(fn, thisArg) {
1103
+ return apply(this, "some", fn, thisArg);
1104
+ },
1105
+ splice(...args) {
1106
+ return noTracking(this, "splice", args);
1107
+ },
1108
+ toReversed() {
1109
+ return reactiveReadArray(this).toReversed();
1110
+ },
1111
+ toSorted(comparer) {
1112
+ return reactiveReadArray(this).toSorted(comparer);
1113
+ },
1114
+ toSpliced(...args) {
1115
+ return reactiveReadArray(this).toSpliced(...args);
1116
+ },
1117
+ unshift(...args) {
1118
+ return noTracking(this, "unshift", args);
1119
+ },
1120
+ values() {
1121
+ return iterator(this, "values", toReactive);
1122
+ }
1123
+ };
1124
+ function iterator(self, method, wrapValue) {
1125
+ const arr = shallowReadArray(self);
1126
+ const iter = arr[method]();
1127
+ if (arr !== self && !isShallow(self)) {
1128
+ iter._next = iter.next;
1129
+ iter.next = () => {
1130
+ const result = iter._next();
1131
+ if (result.value) {
1132
+ result.value = wrapValue(result.value);
1133
+ }
1134
+ return result;
1135
+ };
1136
+ }
1137
+ return iter;
1138
+ }
1139
+ function apply(self, method, fn, thisArg) {
1140
+ const arr = shallowReadArray(self);
1141
+ let wrappedFn = fn;
1142
+ if (arr !== self) {
1143
+ if (!isShallow(self)) {
1144
+ wrappedFn = function(item, index) {
1145
+ return fn.call(this, toReactive(item), index, self);
1146
+ };
1147
+ } else if (fn.length > 2) {
1148
+ wrappedFn = function(item, index) {
1149
+ return fn.call(this, item, index, self);
1150
+ };
1151
+ }
1152
+ }
1153
+ return arr[method](wrappedFn, thisArg);
1154
+ }
1155
+ function reduce(self, method, fn, args) {
1156
+ const arr = shallowReadArray(self);
1157
+ let wrappedFn = fn;
1158
+ if (arr !== self) {
1159
+ if (!isShallow(self)) {
1160
+ wrappedFn = function(acc, item, index) {
1161
+ return fn.call(this, acc, toReactive(item), index, self);
1162
+ };
1163
+ } else if (fn.length > 3) {
1164
+ wrappedFn = function(acc, item, index) {
1165
+ return fn.call(this, acc, item, index, self);
1166
+ };
1167
+ }
1168
+ }
1169
+ return arr[method](wrappedFn, ...args);
1170
+ }
1171
+ function searchProxy(self, method, args) {
1172
+ const arr = toRaw(self);
1173
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1174
+ const res = arr[method](...args);
1175
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1176
+ args[0] = toRaw(args[0]);
1177
+ return arr[method](...args);
1178
+ }
1179
+ return res;
1180
+ }
1181
+ function noTracking(self, method, args = []) {
1182
+ pauseTracking();
1183
+ startBatch();
1184
+ const res = toRaw(self)[method].apply(self, args);
1185
+ endBatch();
1186
+ resetTracking();
1187
+ return res;
1188
+ }
1189
+
816
1190
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
817
1191
  const builtInSymbols = new Set(
818
1192
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
819
1193
  );
820
- const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
821
- function createArrayInstrumentations() {
822
- const instrumentations = {};
823
- ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
824
- instrumentations[key] = function(...args) {
825
- const arr = toRaw(this);
826
- for (let i = 0, l = this.length; i < l; i++) {
827
- track(arr, "get", i + "");
828
- }
829
- const res = arr[key](...args);
830
- if (res === -1 || res === false) {
831
- return arr[key](...args.map(toRaw));
832
- } else {
833
- return res;
834
- }
835
- };
836
- });
837
- ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
838
- instrumentations[key] = function(...args) {
839
- pauseTracking();
840
- pauseScheduling();
841
- const res = toRaw(this)[key].apply(this, args);
842
- resetScheduling();
843
- resetTracking();
844
- return res;
845
- };
846
- });
847
- return instrumentations;
848
- }
849
1194
  function hasOwnProperty(key) {
850
1195
  if (!isSymbol(key))
851
1196
  key = String(key);
@@ -876,14 +1221,22 @@ class BaseReactiveHandler {
876
1221
  }
877
1222
  const targetIsArray = isArray(target);
878
1223
  if (!isReadonly2) {
879
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
880
- return Reflect.get(arrayInstrumentations, key, receiver);
1224
+ let fn;
1225
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1226
+ return fn;
881
1227
  }
882
1228
  if (key === "hasOwnProperty") {
883
1229
  return hasOwnProperty;
884
1230
  }
885
1231
  }
886
- const res = Reflect.get(target, key, receiver);
1232
+ const res = Reflect.get(
1233
+ target,
1234
+ key,
1235
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1236
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1237
+ // its class methods
1238
+ isRef(target) ? target : receiver
1239
+ );
887
1240
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
888
1241
  return res;
889
1242
  }
@@ -1382,110 +1735,8 @@ function markRaw(value) {
1382
1735
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1383
1736
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1384
1737
 
1385
- 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`;
1386
- class ComputedRefImpl {
1387
- constructor(getter, _setter, isReadonly, isSSR) {
1388
- this.getter = getter;
1389
- this._setter = _setter;
1390
- this.dep = void 0;
1391
- this.__v_isRef = true;
1392
- this["__v_isReadonly"] = false;
1393
- this.effect = new ReactiveEffect(
1394
- () => getter(this._value),
1395
- () => triggerRefValue(
1396
- this,
1397
- this.effect._dirtyLevel === 2 ? 2 : 3
1398
- )
1399
- );
1400
- this.effect.computed = this;
1401
- this.effect.active = this._cacheable = !isSSR;
1402
- this["__v_isReadonly"] = isReadonly;
1403
- }
1404
- get value() {
1405
- const self = toRaw(this);
1406
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1407
- triggerRefValue(self, 4);
1408
- }
1409
- trackRefValue(self);
1410
- if (self.effect._dirtyLevel >= 2) {
1411
- if (this._warnRecursive) {
1412
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1413
-
1414
- getter: `, this.getter);
1415
- }
1416
- triggerRefValue(self, 2);
1417
- }
1418
- return self._value;
1419
- }
1420
- set value(newValue) {
1421
- this._setter(newValue);
1422
- }
1423
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1424
- get _dirty() {
1425
- return this.effect.dirty;
1426
- }
1427
- set _dirty(v) {
1428
- this.effect.dirty = v;
1429
- }
1430
- // #endregion
1431
- }
1432
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1433
- let getter;
1434
- let setter;
1435
- const onlyGetter = isFunction(getterOrOptions);
1436
- if (onlyGetter) {
1437
- getter = getterOrOptions;
1438
- setter = () => {
1439
- warn$2("Write operation failed: computed value is readonly");
1440
- } ;
1441
- } else {
1442
- getter = getterOrOptions.get;
1443
- setter = getterOrOptions.set;
1444
- }
1445
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1446
- if (debugOptions && !isSSR) {
1447
- cRef.effect.onTrack = debugOptions.onTrack;
1448
- cRef.effect.onTrigger = debugOptions.onTrigger;
1449
- }
1450
- return cRef;
1451
- }
1452
-
1453
- function trackRefValue(ref2) {
1454
- var _a;
1455
- if (shouldTrack && activeEffect) {
1456
- ref2 = toRaw(ref2);
1457
- trackEffect(
1458
- activeEffect,
1459
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1460
- () => ref2.dep = void 0,
1461
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1462
- ),
1463
- {
1464
- target: ref2,
1465
- type: "get",
1466
- key: "value"
1467
- }
1468
- );
1469
- }
1470
- }
1471
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1472
- ref2 = toRaw(ref2);
1473
- const dep = ref2.dep;
1474
- if (dep) {
1475
- triggerEffects(
1476
- dep,
1477
- dirtyLevel,
1478
- {
1479
- target: ref2,
1480
- type: "set",
1481
- key: "value",
1482
- newValue: newVal
1483
- }
1484
- );
1485
- }
1486
- }
1487
1738
  function isRef(r) {
1488
- return !!(r && r.__v_isRef === true);
1739
+ return r ? r.__v_isRef === true : false;
1489
1740
  }
1490
1741
  function ref(value) {
1491
1742
  return createRef(value, false);
@@ -1502,27 +1753,49 @@ function createRef(rawValue, shallow) {
1502
1753
  class RefImpl {
1503
1754
  constructor(value, __v_isShallow) {
1504
1755
  this.__v_isShallow = __v_isShallow;
1505
- this.dep = void 0;
1756
+ this.dep = new Dep();
1506
1757
  this.__v_isRef = true;
1507
1758
  this._rawValue = __v_isShallow ? value : toRaw(value);
1508
1759
  this._value = __v_isShallow ? value : toReactive(value);
1509
1760
  }
1510
1761
  get value() {
1511
- trackRefValue(this);
1762
+ {
1763
+ this.dep.track({
1764
+ target: this,
1765
+ type: "get",
1766
+ key: "value"
1767
+ });
1768
+ }
1512
1769
  return this._value;
1513
1770
  }
1514
- set value(newVal) {
1515
- const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
1516
- newVal = useDirectValue ? newVal : toRaw(newVal);
1517
- if (hasChanged(newVal, this._rawValue)) {
1518
- this._rawValue = newVal;
1519
- this._value = useDirectValue ? newVal : toReactive(newVal);
1520
- triggerRefValue(this, 4, newVal);
1771
+ set value(newValue) {
1772
+ const oldValue = this._rawValue;
1773
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1774
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1775
+ if (hasChanged(newValue, oldValue)) {
1776
+ this._rawValue = newValue;
1777
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1778
+ {
1779
+ this.dep.trigger({
1780
+ target: this,
1781
+ type: "set",
1782
+ key: "value",
1783
+ newValue,
1784
+ oldValue
1785
+ });
1786
+ }
1521
1787
  }
1522
1788
  }
1523
1789
  }
1524
1790
  function triggerRef(ref2) {
1525
- triggerRefValue(ref2, 4, ref2.value );
1791
+ {
1792
+ ref2.dep.trigger({
1793
+ target: ref2,
1794
+ type: "set",
1795
+ key: "value",
1796
+ newValue: ref2._value
1797
+ });
1798
+ }
1526
1799
  }
1527
1800
  function unref(ref2) {
1528
1801
  return isRef(ref2) ? ref2.value : ref2;
@@ -1547,12 +1820,9 @@ function proxyRefs(objectWithRefs) {
1547
1820
  }
1548
1821
  class CustomRefImpl {
1549
1822
  constructor(factory) {
1550
- this.dep = void 0;
1551
1823
  this.__v_isRef = true;
1552
- const { get, set } = factory(
1553
- () => trackRefValue(this),
1554
- () => triggerRefValue(this)
1555
- );
1824
+ const dep = this.dep = new Dep();
1825
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1556
1826
  this._get = get;
1557
1827
  this._set = set;
1558
1828
  }
@@ -1620,6 +1890,90 @@ function propertyToRef(source, key, defaultValue) {
1620
1890
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1621
1891
  }
1622
1892
 
1893
+ class ComputedRefImpl {
1894
+ constructor(fn, setter, isSSR) {
1895
+ this.fn = fn;
1896
+ this.setter = setter;
1897
+ /**
1898
+ * @internal
1899
+ */
1900
+ this._value = void 0;
1901
+ /**
1902
+ * @internal
1903
+ */
1904
+ this.dep = new Dep(this);
1905
+ /**
1906
+ * @internal
1907
+ */
1908
+ this.__v_isRef = true;
1909
+ // A computed is also a subscriber that tracks other deps
1910
+ /**
1911
+ * @internal
1912
+ */
1913
+ this.deps = void 0;
1914
+ /**
1915
+ * @internal
1916
+ */
1917
+ this.depsTail = void 0;
1918
+ /**
1919
+ * @internal
1920
+ */
1921
+ this.flags = 16;
1922
+ /**
1923
+ * @internal
1924
+ */
1925
+ this.globalVersion = globalVersion - 1;
1926
+ // for backwards compat
1927
+ this.effect = this;
1928
+ this.__v_isReadonly = !setter;
1929
+ this.isSSR = isSSR;
1930
+ }
1931
+ /**
1932
+ * @internal
1933
+ */
1934
+ notify() {
1935
+ if (activeSub !== this) {
1936
+ this.flags |= 16;
1937
+ this.dep.notify();
1938
+ }
1939
+ }
1940
+ get value() {
1941
+ const link = this.dep.track({
1942
+ target: this,
1943
+ type: "get",
1944
+ key: "value"
1945
+ }) ;
1946
+ refreshComputed(this);
1947
+ if (link) {
1948
+ link.version = this.dep.version;
1949
+ }
1950
+ return this._value;
1951
+ }
1952
+ set value(newValue) {
1953
+ if (this.setter) {
1954
+ this.setter(newValue);
1955
+ } else {
1956
+ warn$2("Write operation failed: computed value is readonly");
1957
+ }
1958
+ }
1959
+ }
1960
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1961
+ let getter;
1962
+ let setter;
1963
+ if (isFunction(getterOrOptions)) {
1964
+ getter = getterOrOptions;
1965
+ } else {
1966
+ getter = getterOrOptions.get;
1967
+ setter = getterOrOptions.set;
1968
+ }
1969
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1970
+ if (debugOptions && !isSSR) {
1971
+ cRef.onTrack = debugOptions.onTrack;
1972
+ cRef.onTrigger = debugOptions.onTrigger;
1973
+ }
1974
+ return cRef;
1975
+ }
1976
+
1623
1977
  const TrackOpTypes = {
1624
1978
  "GET": "get",
1625
1979
  "HAS": "has",
@@ -1912,7 +2266,7 @@ function findInsertionIndex(id) {
1912
2266
  const middle = start + end >>> 1;
1913
2267
  const middleJob = queue[middle];
1914
2268
  const middleJobId = getId(middleJob);
1915
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2269
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1916
2270
  start = middle + 1;
1917
2271
  } else {
1918
2272
  end = middle;
@@ -1921,15 +2275,21 @@ function findInsertionIndex(id) {
1921
2275
  return start;
1922
2276
  }
1923
2277
  function queueJob(job) {
1924
- if (!queue.length || !queue.includes(
1925
- job,
1926
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1927
- )) {
2278
+ var _a;
2279
+ if (!(job.flags & 1)) {
1928
2280
  if (job.id == null) {
1929
2281
  queue.push(job);
2282
+ } else if (
2283
+ // fast path when the job id is larger than the tail
2284
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2285
+ ) {
2286
+ queue.push(job);
1930
2287
  } else {
1931
2288
  queue.splice(findInsertionIndex(job.id), 0, job);
1932
2289
  }
2290
+ if (!(job.flags & 4)) {
2291
+ job.flags |= 1;
2292
+ }
1933
2293
  queueFlush();
1934
2294
  }
1935
2295
  }
@@ -1947,11 +2307,11 @@ function invalidateJob(job) {
1947
2307
  }
1948
2308
  function queuePostFlushCb(cb) {
1949
2309
  if (!isArray(cb)) {
1950
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1951
- cb,
1952
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1953
- )) {
2310
+ if (!(cb.flags & 1)) {
1954
2311
  pendingPostFlushCbs.push(cb);
2312
+ if (!(cb.flags & 4)) {
2313
+ cb.flags |= 1;
2314
+ }
1955
2315
  }
1956
2316
  } else {
1957
2317
  pendingPostFlushCbs.push(...cb);
@@ -1964,7 +2324,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1964
2324
  }
1965
2325
  for (; i < queue.length; i++) {
1966
2326
  const cb = queue[i];
1967
- if (cb && cb.pre) {
2327
+ if (cb && cb.flags & 2) {
1968
2328
  if (instance && cb.id !== instance.uid) {
1969
2329
  continue;
1970
2330
  }
@@ -1974,6 +2334,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1974
2334
  queue.splice(i, 1);
1975
2335
  i--;
1976
2336
  cb();
2337
+ cb.flags &= ~1;
1977
2338
  }
1978
2339
  }
1979
2340
  }
@@ -1996,6 +2357,7 @@ function flushPostFlushCbs(seen) {
1996
2357
  continue;
1997
2358
  }
1998
2359
  activePostFlushCbs[postFlushIndex]();
2360
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1999
2361
  }
2000
2362
  activePostFlushCbs = null;
2001
2363
  postFlushIndex = 0;
@@ -2005,9 +2367,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
2005
2367
  const comparator = (a, b) => {
2006
2368
  const diff = getId(a) - getId(b);
2007
2369
  if (diff === 0) {
2008
- if (a.pre && !b.pre)
2370
+ const isAPre = a.flags & 2;
2371
+ const isBPre = b.flags & 2;
2372
+ if (isAPre && !isBPre)
2009
2373
  return -1;
2010
- if (b.pre && !a.pre)
2374
+ if (isBPre && !isAPre)
2011
2375
  return 1;
2012
2376
  }
2013
2377
  return diff;
@@ -2023,11 +2387,12 @@ function flushJobs(seen) {
2023
2387
  try {
2024
2388
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
2025
2389
  const job = queue[flushIndex];
2026
- if (job && job.active !== false) {
2390
+ if (job && !(job.flags & 8)) {
2027
2391
  if (check(job)) {
2028
2392
  continue;
2029
2393
  }
2030
2394
  callWithErrorHandling(job, null, 14);
2395
+ job.flags &= ~1;
2031
2396
  }
2032
2397
  }
2033
2398
  } finally {
@@ -2109,7 +2474,6 @@ function rerender(id, newRender) {
2109
2474
  }
2110
2475
  instance.renderCache = [];
2111
2476
  isHmrUpdating = true;
2112
- instance.effect.dirty = true;
2113
2477
  instance.update();
2114
2478
  isHmrUpdating = false;
2115
2479
  });
@@ -2137,7 +2501,6 @@ function reload(id, newComp) {
2137
2501
  instance.ceReload(newComp.styles);
2138
2502
  hmrDirtyComponents.delete(oldComp);
2139
2503
  } else if (instance.parent) {
2140
- instance.parent.effect.dirty = true;
2141
2504
  queueJob(instance.parent.update);
2142
2505
  } else if (instance.appContext.reload) {
2143
2506
  instance.appContext.reload();
@@ -4126,8 +4489,8 @@ function doWatch(source, cb, {
4126
4489
  }
4127
4490
  }
4128
4491
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4129
- const job = () => {
4130
- if (!effect.active || !effect.dirty) {
4492
+ const job = (immediateFirstRun) => {
4493
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4131
4494
  return;
4132
4495
  }
4133
4496
  if (cb) {
@@ -4148,19 +4511,22 @@ function doWatch(source, cb, {
4148
4511
  effect.run();
4149
4512
  }
4150
4513
  };
4151
- job.allowRecurse = !!cb;
4514
+ if (cb)
4515
+ job.flags |= 4;
4516
+ const effect = new ReactiveEffect(getter);
4152
4517
  let scheduler;
4153
4518
  if (flush === "sync") {
4519
+ effect.flags |= 64;
4154
4520
  scheduler = job;
4155
4521
  } else if (flush === "post") {
4156
4522
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4157
4523
  } else {
4158
- job.pre = true;
4524
+ job.flags |= 2;
4159
4525
  if (instance)
4160
4526
  job.id = instance.uid;
4161
4527
  scheduler = () => queueJob(job);
4162
4528
  }
4163
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4529
+ effect.scheduler = scheduler;
4164
4530
  const scope = getCurrentScope();
4165
4531
  const unwatch = () => {
4166
4532
  effect.stop();
@@ -4174,7 +4540,7 @@ function doWatch(source, cb, {
4174
4540
  }
4175
4541
  if (cb) {
4176
4542
  if (immediate) {
4177
- job();
4543
+ job(true);
4178
4544
  } else {
4179
4545
  oldValue = effect.run();
4180
4546
  }
@@ -4358,22 +4724,7 @@ const BaseTransitionImpl = {
4358
4724
  if (!children || !children.length) {
4359
4725
  return;
4360
4726
  }
4361
- let child = children[0];
4362
- if (children.length > 1) {
4363
- let hasFound = false;
4364
- for (const c of children) {
4365
- if (c.type !== Comment) {
4366
- if (hasFound) {
4367
- warn$1(
4368
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4369
- );
4370
- break;
4371
- }
4372
- child = c;
4373
- hasFound = true;
4374
- }
4375
- }
4376
- }
4727
+ const child = findNonCommentChild(children);
4377
4728
  const rawProps = toRaw(props);
4378
4729
  const { mode } = rawProps;
4379
4730
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4382,7 +4733,7 @@ const BaseTransitionImpl = {
4382
4733
  if (state.isLeaving) {
4383
4734
  return emptyPlaceholder(child);
4384
4735
  }
4385
- const innerChild = getKeepAliveChild(child);
4736
+ const innerChild = getInnerChild$1(child);
4386
4737
  if (!innerChild) {
4387
4738
  return emptyPlaceholder(child);
4388
4739
  }
@@ -4394,7 +4745,7 @@ const BaseTransitionImpl = {
4394
4745
  );
4395
4746
  setTransitionHooks(innerChild, enterHooks);
4396
4747
  const oldChild = instance.subTree;
4397
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4748
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4398
4749
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4399
4750
  const leavingHooks = resolveTransitionHooks(
4400
4751
  oldInnerChild,
@@ -4407,8 +4758,7 @@ const BaseTransitionImpl = {
4407
4758
  state.isLeaving = true;
4408
4759
  leavingHooks.afterLeave = () => {
4409
4760
  state.isLeaving = false;
4410
- if (instance.update.active !== false) {
4411
- instance.effect.dirty = true;
4761
+ if (!(instance.job.flags & 8)) {
4412
4762
  instance.update();
4413
4763
  }
4414
4764
  };
@@ -4436,6 +4786,25 @@ const BaseTransitionImpl = {
4436
4786
  {
4437
4787
  BaseTransitionImpl.__isBuiltIn = true;
4438
4788
  }
4789
+ function findNonCommentChild(children) {
4790
+ let child = children[0];
4791
+ if (children.length > 1) {
4792
+ let hasFound = false;
4793
+ for (const c of children) {
4794
+ if (c.type !== Comment) {
4795
+ if (hasFound) {
4796
+ warn$1(
4797
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4798
+ );
4799
+ break;
4800
+ }
4801
+ child = c;
4802
+ hasFound = true;
4803
+ }
4804
+ }
4805
+ }
4806
+ return child;
4807
+ }
4439
4808
  const BaseTransition = BaseTransitionImpl;
4440
4809
  function getLeavingNodesForType(state, vnode) {
4441
4810
  const { leavingVNodes } = state;
@@ -4590,8 +4959,11 @@ function emptyPlaceholder(vnode) {
4590
4959
  return vnode;
4591
4960
  }
4592
4961
  }
4593
- function getKeepAliveChild(vnode) {
4962
+ function getInnerChild$1(vnode) {
4594
4963
  if (!isKeepAlive(vnode)) {
4964
+ if (isTeleport(vnode.type) && vnode.children) {
4965
+ return findNonCommentChild(vnode.children);
4966
+ }
4595
4967
  return vnode;
4596
4968
  }
4597
4969
  if (vnode.component) {
@@ -4760,7 +5132,6 @@ function defineAsyncComponent(source) {
4760
5132
  load().then(() => {
4761
5133
  loaded.value = true;
4762
5134
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4763
- instance.parent.effect.dirty = true;
4764
5135
  queueJob(instance.parent.update);
4765
5136
  }
4766
5137
  }).catch((err) => {
@@ -5378,10 +5749,20 @@ function convertLegacyFunctionalComponent(comp) {
5378
5749
  function renderList(source, renderItem, cache, index) {
5379
5750
  let ret;
5380
5751
  const cached = cache && cache[index];
5381
- if (isArray(source) || isString(source)) {
5752
+ const sourceIsArray = isArray(source);
5753
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5754
+ if (sourceIsArray || isString(source)) {
5755
+ if (sourceIsReactiveArray) {
5756
+ source = shallowReadArray(source);
5757
+ }
5382
5758
  ret = new Array(source.length);
5383
5759
  for (let i = 0, l = source.length; i < l; i++) {
5384
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5760
+ ret[i] = renderItem(
5761
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5762
+ i,
5763
+ void 0,
5764
+ cached && cached[i]
5765
+ );
5385
5766
  }
5386
5767
  } else if (typeof source === "number") {
5387
5768
  if (!Number.isInteger(source)) {
@@ -5752,7 +6133,6 @@ const publicPropertiesMap = (
5752
6133
  $emit: (i) => i.emit,
5753
6134
  $options: (i) => resolveMergedOptions(i) ,
5754
6135
  $forceUpdate: (i) => i.f || (i.f = () => {
5755
- i.effect.dirty = true;
5756
6136
  queueJob(i.update);
5757
6137
  }),
5758
6138
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6623,7 +7003,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6623
7003
  return vm;
6624
7004
  }
6625
7005
  }
6626
- Vue.version = `2.6.14-compat:${"3.4.25"}`;
7006
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6627
7007
  Vue.config = singletonApp.config;
6628
7008
  Vue.use = (p, ...options) => {
6629
7009
  if (p && isFunction(p.install)) {
@@ -7641,7 +8021,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7641
8021
  function assertType(value, type) {
7642
8022
  let valid;
7643
8023
  const expectedType = getType(type);
7644
- if (isSimpleType(expectedType)) {
8024
+ if (expectedType === "null") {
8025
+ valid = value === null;
8026
+ } else if (isSimpleType(expectedType)) {
7645
8027
  const t = typeof value;
7646
8028
  valid = t === expectedType.toLowerCase();
7647
8029
  if (!valid && t === "object") {
@@ -7651,8 +8033,6 @@ function assertType(value, type) {
7651
8033
  valid = isObject(value);
7652
8034
  } else if (expectedType === "Array") {
7653
8035
  valid = isArray(value);
7654
- } else if (expectedType === "null") {
7655
- valid = value === null;
7656
8036
  } else {
7657
8037
  valid = value instanceof type;
7658
8038
  }
@@ -9177,7 +9557,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9177
9557
  } else {
9178
9558
  instance.next = n2;
9179
9559
  invalidateJob(instance.update);
9180
- instance.effect.dirty = true;
9181
9560
  instance.update();
9182
9561
  }
9183
9562
  } else {
@@ -9384,24 +9763,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9384
9763
  }
9385
9764
  }
9386
9765
  };
9387
- const effect = instance.effect = new ReactiveEffect(
9388
- componentUpdateFn,
9389
- NOOP,
9390
- () => queueJob(update),
9391
- instance.scope
9392
- // track it in component's effect scope
9393
- );
9394
- const update = instance.update = () => {
9395
- if (effect.dirty) {
9396
- effect.run();
9397
- }
9398
- };
9399
- update.id = instance.uid;
9766
+ instance.scope.on();
9767
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9768
+ instance.scope.off();
9769
+ const update = instance.update = effect.run.bind(effect);
9770
+ const job = instance.job = effect.runIfDirty.bind(effect);
9771
+ job.id = instance.uid;
9772
+ effect.scheduler = () => queueJob(job);
9400
9773
  toggleRecurse(instance, true);
9401
9774
  {
9402
9775
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9403
9776
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9404
- update.ownerInstance = instance;
9777
+ job.ownerInstance = instance;
9405
9778
  }
9406
9779
  update();
9407
9780
  };
@@ -9868,7 +10241,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9868
10241
  if (instance.type.__hmrId) {
9869
10242
  unregisterHMR(instance);
9870
10243
  }
9871
- const { bum, scope, update, subTree, um } = instance;
10244
+ const { bum, scope, job, subTree, um } = instance;
9872
10245
  if (bum) {
9873
10246
  invokeArrayFns(bum);
9874
10247
  }
@@ -9876,8 +10249,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9876
10249
  instance.emit("hook:beforeDestroy");
9877
10250
  }
9878
10251
  scope.stop();
9879
- if (update) {
9880
- update.active = false;
10252
+ if (job) {
10253
+ job.flags |= 8;
9881
10254
  unmount(subTree, instance, parentSuspense, doRemove);
9882
10255
  }
9883
10256
  if (um) {
@@ -9969,8 +10342,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9969
10342
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9970
10343
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9971
10344
  }
9972
- function toggleRecurse({ effect, update }, allowed) {
9973
- effect.allowRecurse = update.allowRecurse = allowed;
10345
+ function toggleRecurse({ effect, job }, allowed) {
10346
+ if (allowed) {
10347
+ effect.flags |= 32;
10348
+ job.flags |= 4;
10349
+ } else {
10350
+ effect.flags &= ~32;
10351
+ job.flags &= ~4;
10352
+ }
9974
10353
  }
9975
10354
  function needTransition(parentSuspense, transition) {
9976
10355
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10768,6 +11147,7 @@ function createComponentInstance(vnode, parent, suspense) {
10768
11147
  effect: null,
10769
11148
  update: null,
10770
11149
  // will be set synchronously right after creation
11150
+ job: null,
10771
11151
  scope: new EffectScope(
10772
11152
  true
10773
11153
  /* detached */
@@ -11290,7 +11670,8 @@ function initCustomFormatter() {
11290
11670
  {},
11291
11671
  ["span", vueStyle, genRefFlag(obj)],
11292
11672
  "<",
11293
- formatValue(obj.value),
11673
+ // avoid debugger accessing value affecting behavior
11674
+ formatValue("_value" in obj ? obj._value : obj),
11294
11675
  `>`
11295
11676
  ];
11296
11677
  } else if (isReactive(obj)) {
@@ -11470,7 +11851,7 @@ function isMemoSame(cached, memo) {
11470
11851
  return true;
11471
11852
  }
11472
11853
 
11473
- const version = "3.4.25";
11854
+ const version = "3.5.0-alpha.1";
11474
11855
  const warn = warn$1 ;
11475
11856
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11476
11857
  const devtools = devtools$1 ;
@@ -13025,7 +13406,9 @@ const withKeys = (fn, modifiers) => {
13025
13406
  return;
13026
13407
  }
13027
13408
  const eventKey = hyphenate(event.key);
13028
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13409
+ if (modifiers.some(
13410
+ (k) => k === eventKey || keyNames[k] === eventKey
13411
+ )) {
13029
13412
  return fn(event);
13030
13413
  }
13031
13414
  {
@@ -20167,9 +20550,183 @@ const ignoreSideEffectTags = (node, context) => {
20167
20550
  }
20168
20551
  };
20169
20552
 
20553
+ function isValidHTMLNesting(parent, child) {
20554
+ if (parent in onlyValidChildren) {
20555
+ return onlyValidChildren[parent].has(child);
20556
+ }
20557
+ if (child in onlyValidParents) {
20558
+ return onlyValidParents[child].has(parent);
20559
+ }
20560
+ if (parent in knownInvalidChildren) {
20561
+ if (knownInvalidChildren[parent].has(child))
20562
+ return false;
20563
+ }
20564
+ if (child in knownInvalidParents) {
20565
+ if (knownInvalidParents[child].has(parent))
20566
+ return false;
20567
+ }
20568
+ return true;
20569
+ }
20570
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
20571
+ const emptySet = /* @__PURE__ */ new Set([]);
20572
+ const onlyValidChildren = {
20573
+ head: /* @__PURE__ */ new Set([
20574
+ "base",
20575
+ "basefront",
20576
+ "bgsound",
20577
+ "link",
20578
+ "meta",
20579
+ "title",
20580
+ "noscript",
20581
+ "noframes",
20582
+ "style",
20583
+ "script",
20584
+ "template"
20585
+ ]),
20586
+ optgroup: /* @__PURE__ */ new Set(["option"]),
20587
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
20588
+ // table
20589
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
20590
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
20591
+ colgroup: /* @__PURE__ */ new Set(["col"]),
20592
+ tbody: /* @__PURE__ */ new Set(["tr"]),
20593
+ thead: /* @__PURE__ */ new Set(["tr"]),
20594
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
20595
+ // these elements can not have any children elements
20596
+ script: emptySet,
20597
+ iframe: emptySet,
20598
+ option: emptySet,
20599
+ textarea: emptySet,
20600
+ style: emptySet,
20601
+ title: emptySet
20602
+ };
20603
+ const onlyValidParents = {
20604
+ // sections
20605
+ html: emptySet,
20606
+ body: /* @__PURE__ */ new Set(["html"]),
20607
+ head: /* @__PURE__ */ new Set(["html"]),
20608
+ // table
20609
+ td: /* @__PURE__ */ new Set(["tr"]),
20610
+ colgroup: /* @__PURE__ */ new Set(["table"]),
20611
+ caption: /* @__PURE__ */ new Set(["table"]),
20612
+ tbody: /* @__PURE__ */ new Set(["table"]),
20613
+ tfoot: /* @__PURE__ */ new Set(["table"]),
20614
+ col: /* @__PURE__ */ new Set(["colgroup"]),
20615
+ th: /* @__PURE__ */ new Set(["tr"]),
20616
+ thead: /* @__PURE__ */ new Set(["table"]),
20617
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
20618
+ // data list
20619
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
20620
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
20621
+ // other
20622
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
20623
+ // li: new Set(["ul", "ol"]),
20624
+ summary: /* @__PURE__ */ new Set(["details"]),
20625
+ area: /* @__PURE__ */ new Set(["map"])
20626
+ };
20627
+ const knownInvalidChildren = {
20628
+ p: /* @__PURE__ */ new Set([
20629
+ "address",
20630
+ "article",
20631
+ "aside",
20632
+ "blockquote",
20633
+ "center",
20634
+ "details",
20635
+ "dialog",
20636
+ "dir",
20637
+ "div",
20638
+ "dl",
20639
+ "fieldset",
20640
+ "figure",
20641
+ "footer",
20642
+ "form",
20643
+ "h1",
20644
+ "h2",
20645
+ "h3",
20646
+ "h4",
20647
+ "h5",
20648
+ "h6",
20649
+ "header",
20650
+ "hgroup",
20651
+ "hr",
20652
+ "li",
20653
+ "main",
20654
+ "nav",
20655
+ "menu",
20656
+ "ol",
20657
+ "p",
20658
+ "pre",
20659
+ "section",
20660
+ "table",
20661
+ "ul"
20662
+ ]),
20663
+ svg: /* @__PURE__ */ new Set([
20664
+ "b",
20665
+ "blockquote",
20666
+ "br",
20667
+ "code",
20668
+ "dd",
20669
+ "div",
20670
+ "dl",
20671
+ "dt",
20672
+ "em",
20673
+ "embed",
20674
+ "h1",
20675
+ "h2",
20676
+ "h3",
20677
+ "h4",
20678
+ "h5",
20679
+ "h6",
20680
+ "hr",
20681
+ "i",
20682
+ "img",
20683
+ "li",
20684
+ "menu",
20685
+ "meta",
20686
+ "ol",
20687
+ "p",
20688
+ "pre",
20689
+ "ruby",
20690
+ "s",
20691
+ "small",
20692
+ "span",
20693
+ "strong",
20694
+ "sub",
20695
+ "sup",
20696
+ "table",
20697
+ "u",
20698
+ "ul",
20699
+ "var"
20700
+ ])
20701
+ };
20702
+ const knownInvalidParents = {
20703
+ a: /* @__PURE__ */ new Set(["a"]),
20704
+ button: /* @__PURE__ */ new Set(["button"]),
20705
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
20706
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
20707
+ form: /* @__PURE__ */ new Set(["form"]),
20708
+ li: /* @__PURE__ */ new Set(["li"]),
20709
+ h1: headings,
20710
+ h2: headings,
20711
+ h3: headings,
20712
+ h4: headings,
20713
+ h5: headings,
20714
+ h6: headings
20715
+ };
20716
+
20717
+ const validateHtmlNesting = (node, context) => {
20718
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
20719
+ const error = new SyntaxError(
20720
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
20721
+ );
20722
+ error.loc = node.loc;
20723
+ context.onWarn(error);
20724
+ }
20725
+ };
20726
+
20170
20727
  const DOMNodeTransforms = [
20171
20728
  transformStyle,
20172
- ...[transformTransition]
20729
+ ...[transformTransition, validateHtmlNesting]
20173
20730
  ];
20174
20731
  const DOMDirectiveTransforms = {
20175
20732
  cloak: noopDirectiveTransform,