@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.
@@ -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
  **/
@@ -452,157 +452,280 @@ var Vue = (function () {
452
452
  function effectScope(detached) {
453
453
  return new EffectScope(detached);
454
454
  }
455
- function recordEffectScope(effect, scope = activeEffectScope) {
456
- if (scope && scope.active) {
457
- scope.effects.push(effect);
458
- }
459
- }
460
455
  function getCurrentScope() {
461
456
  return activeEffectScope;
462
457
  }
463
- function onScopeDispose(fn) {
458
+ function onScopeDispose(fn, failSilently = false) {
464
459
  if (activeEffectScope) {
465
460
  activeEffectScope.cleanups.push(fn);
466
- } else {
461
+ } else if (!failSilently) {
467
462
  warn$2(
468
463
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
469
464
  );
470
465
  }
471
466
  }
472
467
 
473
- let activeEffect;
468
+ let activeSub;
474
469
  class ReactiveEffect {
475
- constructor(fn, trigger, scheduler, scope) {
470
+ constructor(fn) {
476
471
  this.fn = fn;
477
- this.trigger = trigger;
478
- this.scheduler = scheduler;
479
- this.active = true;
480
- this.deps = [];
481
472
  /**
482
473
  * @internal
483
474
  */
484
- this._dirtyLevel = 4;
475
+ this.deps = void 0;
485
476
  /**
486
477
  * @internal
487
478
  */
488
- this._trackId = 0;
479
+ this.depsTail = void 0;
489
480
  /**
490
481
  * @internal
491
482
  */
492
- this._runnings = 0;
483
+ this.flags = 1 | 4;
493
484
  /**
494
485
  * @internal
495
486
  */
496
- this._shouldSchedule = false;
487
+ this.nextEffect = void 0;
497
488
  /**
498
489
  * @internal
499
490
  */
500
- this._depsLength = 0;
501
- recordEffectScope(this, scope);
502
- }
503
- get dirty() {
504
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
505
- this._dirtyLevel = 1;
506
- pauseTracking();
507
- for (let i = 0; i < this._depsLength; i++) {
508
- const dep = this.deps[i];
509
- if (dep.computed) {
510
- triggerComputed(dep.computed);
511
- if (this._dirtyLevel >= 4) {
512
- break;
513
- }
514
- }
515
- }
516
- if (this._dirtyLevel === 1) {
517
- this._dirtyLevel = 0;
518
- }
519
- resetTracking();
491
+ this.cleanup = void 0;
492
+ this.scheduler = void 0;
493
+ if (activeEffectScope && activeEffectScope.active) {
494
+ activeEffectScope.effects.push(this);
520
495
  }
521
- return this._dirtyLevel >= 4;
522
496
  }
523
- set dirty(v) {
524
- this._dirtyLevel = v ? 4 : 0;
497
+ /**
498
+ * @internal
499
+ */
500
+ notify() {
501
+ if (this.flags & 2 && !(this.flags & 32)) {
502
+ return;
503
+ }
504
+ if (this.flags & 64) {
505
+ return this.trigger();
506
+ }
507
+ if (!(this.flags & 8)) {
508
+ this.flags |= 8;
509
+ this.nextEffect = batchedEffect;
510
+ batchedEffect = this;
511
+ }
525
512
  }
526
513
  run() {
527
- this._dirtyLevel = 0;
528
- if (!this.active) {
514
+ if (!(this.flags & 1)) {
529
515
  return this.fn();
530
516
  }
531
- let lastShouldTrack = shouldTrack;
532
- let lastEffect = activeEffect;
517
+ this.flags |= 2;
518
+ cleanupEffect(this);
519
+ prepareDeps(this);
520
+ const prevEffect = activeSub;
521
+ const prevShouldTrack = shouldTrack;
522
+ activeSub = this;
523
+ shouldTrack = true;
533
524
  try {
534
- shouldTrack = true;
535
- activeEffect = this;
536
- this._runnings++;
537
- preCleanupEffect(this);
538
525
  return this.fn();
539
526
  } finally {
540
- postCleanupEffect(this);
541
- this._runnings--;
542
- activeEffect = lastEffect;
543
- shouldTrack = lastShouldTrack;
527
+ if (activeSub !== this) {
528
+ warn$2(
529
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
530
+ );
531
+ }
532
+ cleanupDeps(this);
533
+ activeSub = prevEffect;
534
+ shouldTrack = prevShouldTrack;
535
+ this.flags &= ~2;
544
536
  }
545
537
  }
546
538
  stop() {
547
- var _a;
548
- if (this.active) {
549
- preCleanupEffect(this);
550
- postCleanupEffect(this);
551
- (_a = this.onStop) == null ? void 0 : _a.call(this);
552
- this.active = false;
539
+ if (this.flags & 1) {
540
+ for (let link = this.deps; link; link = link.nextDep) {
541
+ removeSub(link);
542
+ }
543
+ this.deps = this.depsTail = void 0;
544
+ cleanupEffect(this);
545
+ this.onStop && this.onStop();
546
+ this.flags &= ~1;
553
547
  }
554
548
  }
549
+ trigger() {
550
+ if (this.scheduler) {
551
+ this.scheduler();
552
+ } else {
553
+ this.runIfDirty();
554
+ }
555
+ }
556
+ /**
557
+ * @internal
558
+ */
559
+ runIfDirty() {
560
+ if (isDirty(this)) {
561
+ this.run();
562
+ }
563
+ }
564
+ get dirty() {
565
+ return isDirty(this);
566
+ }
567
+ }
568
+ let batchDepth = 0;
569
+ let batchedEffect;
570
+ function startBatch() {
571
+ batchDepth++;
555
572
  }
556
- function triggerComputed(computed) {
557
- return computed.value;
573
+ function endBatch() {
574
+ if (batchDepth > 1) {
575
+ batchDepth--;
576
+ return;
577
+ }
578
+ let error;
579
+ while (batchedEffect) {
580
+ let e = batchedEffect;
581
+ batchedEffect = void 0;
582
+ while (e) {
583
+ const next = e.nextEffect;
584
+ e.nextEffect = void 0;
585
+ e.flags &= ~8;
586
+ if (e.flags & 1) {
587
+ try {
588
+ e.trigger();
589
+ } catch (err) {
590
+ if (!error)
591
+ error = err;
592
+ }
593
+ }
594
+ e = next;
595
+ }
596
+ }
597
+ batchDepth--;
598
+ if (error)
599
+ throw error;
558
600
  }
559
- function preCleanupEffect(effect2) {
560
- effect2._trackId++;
561
- effect2._depsLength = 0;
601
+ function prepareDeps(sub) {
602
+ for (let link = sub.deps; link; link = link.nextDep) {
603
+ link.version = -1;
604
+ link.prevActiveLink = link.dep.activeLink;
605
+ link.dep.activeLink = link;
606
+ }
562
607
  }
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);
608
+ function cleanupDeps(sub) {
609
+ let head;
610
+ let tail = sub.depsTail;
611
+ for (let link = tail; link; link = link.prevDep) {
612
+ if (link.version === -1) {
613
+ if (link === tail)
614
+ tail = link.prevDep;
615
+ removeSub(link);
616
+ removeDep(link);
617
+ } else {
618
+ head = link;
567
619
  }
568
- effect2.deps.length = effect2._depsLength;
620
+ link.dep.activeLink = link.prevActiveLink;
621
+ link.prevActiveLink = void 0;
569
622
  }
623
+ sub.deps = head;
624
+ sub.depsTail = tail;
570
625
  }
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();
626
+ function isDirty(sub) {
627
+ for (let link = sub.deps; link; link = link.nextDep) {
628
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
629
+ return true;
577
630
  }
578
631
  }
632
+ if (sub._dirty) {
633
+ return true;
634
+ }
635
+ return false;
636
+ }
637
+ function refreshComputed(computed) {
638
+ if (computed.flags & 2) {
639
+ return false;
640
+ }
641
+ if (computed.flags & 4 && !(computed.flags & 16)) {
642
+ return;
643
+ }
644
+ computed.flags &= ~16;
645
+ if (computed.globalVersion === globalVersion) {
646
+ return;
647
+ }
648
+ computed.globalVersion = globalVersion;
649
+ const dep = computed.dep;
650
+ computed.flags |= 2;
651
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
652
+ computed.flags &= ~2;
653
+ return;
654
+ }
655
+ const prevSub = activeSub;
656
+ const prevShouldTrack = shouldTrack;
657
+ activeSub = computed;
658
+ shouldTrack = true;
659
+ try {
660
+ prepareDeps(computed);
661
+ const value = computed.fn();
662
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
663
+ computed._value = value;
664
+ dep.version++;
665
+ }
666
+ } catch (err) {
667
+ dep.version++;
668
+ throw err;
669
+ } finally {
670
+ activeSub = prevSub;
671
+ shouldTrack = prevShouldTrack;
672
+ cleanupDeps(computed);
673
+ computed.flags &= ~2;
674
+ }
675
+ }
676
+ function removeSub(link) {
677
+ const { dep, prevSub, nextSub } = link;
678
+ if (prevSub) {
679
+ prevSub.nextSub = nextSub;
680
+ link.prevSub = void 0;
681
+ }
682
+ if (nextSub) {
683
+ nextSub.prevSub = prevSub;
684
+ link.nextSub = void 0;
685
+ }
686
+ if (dep.subs === link) {
687
+ dep.subs = prevSub;
688
+ }
689
+ if (!dep.subs && dep.computed) {
690
+ dep.computed.flags &= ~4;
691
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
692
+ removeSub(l);
693
+ }
694
+ }
695
+ }
696
+ function removeDep(link) {
697
+ const { prevDep, nextDep } = link;
698
+ if (prevDep) {
699
+ prevDep.nextDep = nextDep;
700
+ link.prevDep = void 0;
701
+ }
702
+ if (nextDep) {
703
+ nextDep.prevDep = prevDep;
704
+ link.nextDep = void 0;
705
+ }
579
706
  }
580
707
  function effect(fn, options) {
581
708
  if (fn.effect instanceof ReactiveEffect) {
582
709
  fn = fn.effect.fn;
583
710
  }
584
- const _effect = new ReactiveEffect(fn, NOOP, () => {
585
- if (_effect.dirty) {
586
- _effect.run();
587
- }
588
- });
711
+ const e = new ReactiveEffect(fn);
589
712
  if (options) {
590
- extend(_effect, options);
591
- if (options.scope)
592
- recordEffectScope(_effect, options.scope);
713
+ extend(e, options);
593
714
  }
594
- if (!options || !options.lazy) {
595
- _effect.run();
715
+ try {
716
+ e.run();
717
+ } catch (err) {
718
+ e.stop();
719
+ throw err;
596
720
  }
597
- const runner = _effect.run.bind(_effect);
598
- runner.effect = _effect;
721
+ const runner = e.run.bind(e);
722
+ runner.effect = e;
599
723
  return runner;
600
724
  }
601
725
  function stop(runner) {
602
726
  runner.effect.stop();
603
727
  }
604
728
  let shouldTrack = true;
605
- let pauseScheduleStack = 0;
606
729
  const trackStack = [];
607
730
  function pauseTracking() {
608
731
  trackStack.push(shouldTrack);
@@ -612,192 +735,414 @@ var Vue = (function () {
612
735
  const last = trackStack.pop();
613
736
  shouldTrack = last === void 0 ? true : last;
614
737
  }
615
- function pauseScheduling() {
616
- pauseScheduleStack++;
617
- }
618
- function resetScheduling() {
619
- pauseScheduleStack--;
620
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
621
- queueEffectSchedulers.shift()();
738
+ function cleanupEffect(e) {
739
+ const { cleanup } = e;
740
+ e.cleanup = void 0;
741
+ if (cleanup) {
742
+ const prevSub = activeSub;
743
+ activeSub = void 0;
744
+ try {
745
+ cleanup();
746
+ } finally {
747
+ activeSub = prevSub;
748
+ }
622
749
  }
623
750
  }
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
- }
751
+
752
+ let globalVersion = 0;
753
+ class Dep {
754
+ constructor(computed) {
755
+ this.computed = computed;
756
+ this.version = 0;
757
+ /**
758
+ * Link between this dep and the current active effect
759
+ */
760
+ this.activeLink = void 0;
761
+ /**
762
+ * Doubly linked list representing the subscribing effects (tail)
763
+ */
764
+ this.subs = void 0;
637
765
  {
638
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
766
+ this.subsHead = void 0;
639
767
  }
640
768
  }
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));
769
+ track(debugInfo) {
770
+ if (!activeSub || !shouldTrack) {
771
+ return;
772
+ }
773
+ let link = this.activeLink;
774
+ if (link === void 0 || link.sub !== activeSub) {
775
+ link = this.activeLink = {
776
+ dep: this,
777
+ sub: activeSub,
778
+ version: this.version,
779
+ nextDep: void 0,
780
+ prevDep: void 0,
781
+ nextSub: void 0,
782
+ prevSub: void 0,
783
+ prevActiveLink: void 0
784
+ };
785
+ if (!activeSub.deps) {
786
+ activeSub.deps = activeSub.depsTail = link;
787
+ } else {
788
+ link.prevDep = activeSub.depsTail;
789
+ activeSub.depsTail.nextDep = link;
790
+ activeSub.depsTail = link;
791
+ }
792
+ if (activeSub.flags & 4) {
793
+ addSub(link);
794
+ }
795
+ } else if (link.version === -1) {
796
+ link.version = this.version;
797
+ if (link.nextDep) {
798
+ const next = link.nextDep;
799
+ next.prevDep = link.prevDep;
800
+ if (link.prevDep) {
801
+ link.prevDep.nextDep = next;
802
+ }
803
+ link.prevDep = activeSub.depsTail;
804
+ link.nextDep = void 0;
805
+ activeSub.depsTail.nextDep = link;
806
+ activeSub.depsTail = link;
807
+ if (activeSub.deps === link) {
808
+ activeSub.deps = next;
809
+ }
655
810
  }
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);
811
+ }
812
+ if (activeSub.onTrack) {
813
+ activeSub.onTrack(
814
+ extend(
815
+ {
816
+ effect: activeSub
817
+ },
818
+ debugInfo
819
+ )
820
+ );
821
+ }
822
+ return link;
823
+ }
824
+ trigger(debugInfo) {
825
+ this.version++;
826
+ globalVersion++;
827
+ this.notify(debugInfo);
828
+ }
829
+ notify(debugInfo) {
830
+ startBatch();
831
+ try {
832
+ if (true) {
833
+ for (let head = this.subsHead; head; head = head.nextSub) {
834
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
835
+ head.sub.onTrigger(
836
+ extend(
837
+ {
838
+ effect: head.sub
839
+ },
840
+ debugInfo
841
+ )
842
+ );
843
+ }
661
844
  }
662
845
  }
846
+ for (let link = this.subs; link; link = link.prevSub) {
847
+ link.sub.notify();
848
+ }
849
+ } finally {
850
+ endBatch();
663
851
  }
664
852
  }
665
- resetScheduling();
666
853
  }
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
-
854
+ function addSub(link) {
855
+ const computed = link.dep.computed;
856
+ if (computed && !link.dep.subs) {
857
+ computed.flags |= 4 | 16;
858
+ for (let l = computed.deps; l; l = l.nextDep) {
859
+ addSub(l);
860
+ }
861
+ }
862
+ const currentTail = link.dep.subs;
863
+ if (currentTail !== link) {
864
+ link.prevSub = currentTail;
865
+ if (currentTail)
866
+ currentTail.nextSub = link;
867
+ }
868
+ if (link.dep.subsHead === void 0) {
869
+ link.dep.subsHead = link;
870
+ }
871
+ link.dep.subs = link;
872
+ }
675
873
  const targetMap = /* @__PURE__ */ new WeakMap();
676
- const ITERATE_KEY = Symbol("iterate" );
677
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
874
+ const ITERATE_KEY = Symbol("Object iterate" );
875
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
876
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
678
877
  function track(target, type, key) {
679
- if (shouldTrack && activeEffect) {
878
+ if (shouldTrack && activeSub) {
680
879
  let depsMap = targetMap.get(target);
681
880
  if (!depsMap) {
682
881
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
683
882
  }
684
883
  let dep = depsMap.get(key);
685
884
  if (!dep) {
686
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
885
+ depsMap.set(key, dep = new Dep());
687
886
  }
688
- trackEffect(
689
- activeEffect,
690
- dep,
691
- {
887
+ {
888
+ dep.track({
692
889
  target,
693
890
  type,
694
891
  key
695
- }
696
- );
892
+ });
893
+ }
697
894
  }
698
895
  }
699
896
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
700
897
  const depsMap = targetMap.get(target);
701
898
  if (!depsMap) {
899
+ globalVersion++;
702
900
  return;
703
901
  }
704
902
  let deps = [];
705
903
  if (type === "clear") {
706
904
  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
905
  } 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"));
906
+ const targetIsArray = isArray(target);
907
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
908
+ if (targetIsArray && key === "length") {
909
+ const newLength = Number(newValue);
910
+ depsMap.forEach((dep, key2) => {
911
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
912
+ deps.push(dep);
727
913
  }
728
- break;
729
- case "delete":
730
- if (!isArray(target)) {
731
- deps.push(depsMap.get(ITERATE_KEY));
914
+ });
915
+ } else {
916
+ const push = (dep) => dep && deps.push(dep);
917
+ if (key !== void 0) {
918
+ push(depsMap.get(key));
919
+ }
920
+ if (isArrayIndex) {
921
+ push(depsMap.get(ARRAY_ITERATE_KEY));
922
+ }
923
+ switch (type) {
924
+ case "add":
925
+ if (!targetIsArray) {
926
+ push(depsMap.get(ITERATE_KEY));
927
+ if (isMap(target)) {
928
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
929
+ }
930
+ } else if (isArrayIndex) {
931
+ push(depsMap.get("length"));
932
+ }
933
+ break;
934
+ case "delete":
935
+ if (!targetIsArray) {
936
+ push(depsMap.get(ITERATE_KEY));
937
+ if (isMap(target)) {
938
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
939
+ }
940
+ }
941
+ break;
942
+ case "set":
732
943
  if (isMap(target)) {
733
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
944
+ push(depsMap.get(ITERATE_KEY));
734
945
  }
735
- }
736
- break;
737
- case "set":
738
- if (isMap(target)) {
739
- deps.push(depsMap.get(ITERATE_KEY));
740
- }
741
- break;
946
+ break;
947
+ }
742
948
  }
743
949
  }
744
- pauseScheduling();
950
+ startBatch();
745
951
  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
- );
952
+ {
953
+ dep.trigger({
954
+ target,
955
+ type,
956
+ key,
957
+ newValue,
958
+ oldValue,
959
+ oldTarget
960
+ });
759
961
  }
760
962
  }
761
- resetScheduling();
963
+ endBatch();
762
964
  }
763
965
  function getDepFromReactive(object, key) {
764
966
  var _a;
765
967
  return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
766
968
  }
767
969
 
970
+ function reactiveReadArray(array) {
971
+ const raw = toRaw(array);
972
+ if (raw === array)
973
+ return raw;
974
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
975
+ return isShallow(array) ? raw : raw.map(toReactive);
976
+ }
977
+ function shallowReadArray(arr) {
978
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
979
+ return arr;
980
+ }
981
+ const arrayInstrumentations = {
982
+ __proto__: null,
983
+ [Symbol.iterator]() {
984
+ return iterator(this, Symbol.iterator, toReactive);
985
+ },
986
+ concat(...args) {
987
+ return reactiveReadArray(this).concat(
988
+ ...args.map((x) => reactiveReadArray(x))
989
+ );
990
+ },
991
+ entries() {
992
+ return iterator(this, "entries", (value) => {
993
+ value[1] = toReactive(value[1]);
994
+ return value;
995
+ });
996
+ },
997
+ every(fn, thisArg) {
998
+ return apply(this, "every", fn, thisArg);
999
+ },
1000
+ filter(fn, thisArg) {
1001
+ const result = apply(this, "filter", fn, thisArg);
1002
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
1003
+ },
1004
+ find(fn, thisArg) {
1005
+ const result = apply(this, "find", fn, thisArg);
1006
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1007
+ },
1008
+ findIndex(fn, thisArg) {
1009
+ return apply(this, "findIndex", fn, thisArg);
1010
+ },
1011
+ findLast(fn, thisArg) {
1012
+ const result = apply(this, "findLast", fn, thisArg);
1013
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1014
+ },
1015
+ findLastIndex(fn, thisArg) {
1016
+ return apply(this, "findLastIndex", fn, thisArg);
1017
+ },
1018
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1019
+ forEach(fn, thisArg) {
1020
+ return apply(this, "forEach", fn, thisArg);
1021
+ },
1022
+ includes(...args) {
1023
+ return searchProxy(this, "includes", args);
1024
+ },
1025
+ indexOf(...args) {
1026
+ return searchProxy(this, "indexOf", args);
1027
+ },
1028
+ join(separator) {
1029
+ return reactiveReadArray(this).join(separator);
1030
+ },
1031
+ // keys() iterator only reads `length`, no optimisation required
1032
+ lastIndexOf(...args) {
1033
+ return searchProxy(this, "lastIndexOf", args);
1034
+ },
1035
+ map(fn, thisArg) {
1036
+ return apply(this, "map", fn, thisArg);
1037
+ },
1038
+ pop() {
1039
+ return noTracking(this, "pop");
1040
+ },
1041
+ push(...args) {
1042
+ return noTracking(this, "push", args);
1043
+ },
1044
+ reduce(fn, ...args) {
1045
+ return reduce(this, "reduce", fn, args);
1046
+ },
1047
+ reduceRight(fn, ...args) {
1048
+ return reduce(this, "reduceRight", fn, args);
1049
+ },
1050
+ shift() {
1051
+ return noTracking(this, "shift");
1052
+ },
1053
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1054
+ some(fn, thisArg) {
1055
+ return apply(this, "some", fn, thisArg);
1056
+ },
1057
+ splice(...args) {
1058
+ return noTracking(this, "splice", args);
1059
+ },
1060
+ toReversed() {
1061
+ return reactiveReadArray(this).toReversed();
1062
+ },
1063
+ toSorted(comparer) {
1064
+ return reactiveReadArray(this).toSorted(comparer);
1065
+ },
1066
+ toSpliced(...args) {
1067
+ return reactiveReadArray(this).toSpliced(...args);
1068
+ },
1069
+ unshift(...args) {
1070
+ return noTracking(this, "unshift", args);
1071
+ },
1072
+ values() {
1073
+ return iterator(this, "values", toReactive);
1074
+ }
1075
+ };
1076
+ function iterator(self, method, wrapValue) {
1077
+ const arr = shallowReadArray(self);
1078
+ const iter = arr[method]();
1079
+ if (arr !== self && !isShallow(self)) {
1080
+ iter._next = iter.next;
1081
+ iter.next = () => {
1082
+ const result = iter._next();
1083
+ if (result.value) {
1084
+ result.value = wrapValue(result.value);
1085
+ }
1086
+ return result;
1087
+ };
1088
+ }
1089
+ return iter;
1090
+ }
1091
+ function apply(self, method, fn, thisArg) {
1092
+ const arr = shallowReadArray(self);
1093
+ let wrappedFn = fn;
1094
+ if (arr !== self) {
1095
+ if (!isShallow(self)) {
1096
+ wrappedFn = function(item, index) {
1097
+ return fn.call(this, toReactive(item), index, self);
1098
+ };
1099
+ } else if (fn.length > 2) {
1100
+ wrappedFn = function(item, index) {
1101
+ return fn.call(this, item, index, self);
1102
+ };
1103
+ }
1104
+ }
1105
+ return arr[method](wrappedFn, thisArg);
1106
+ }
1107
+ function reduce(self, method, fn, args) {
1108
+ const arr = shallowReadArray(self);
1109
+ let wrappedFn = fn;
1110
+ if (arr !== self) {
1111
+ if (!isShallow(self)) {
1112
+ wrappedFn = function(acc, item, index) {
1113
+ return fn.call(this, acc, toReactive(item), index, self);
1114
+ };
1115
+ } else if (fn.length > 3) {
1116
+ wrappedFn = function(acc, item, index) {
1117
+ return fn.call(this, acc, item, index, self);
1118
+ };
1119
+ }
1120
+ }
1121
+ return arr[method](wrappedFn, ...args);
1122
+ }
1123
+ function searchProxy(self, method, args) {
1124
+ const arr = toRaw(self);
1125
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1126
+ const res = arr[method](...args);
1127
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1128
+ args[0] = toRaw(args[0]);
1129
+ return arr[method](...args);
1130
+ }
1131
+ return res;
1132
+ }
1133
+ function noTracking(self, method, args = []) {
1134
+ pauseTracking();
1135
+ startBatch();
1136
+ const res = toRaw(self)[method].apply(self, args);
1137
+ endBatch();
1138
+ resetTracking();
1139
+ return res;
1140
+ }
1141
+
768
1142
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
769
1143
  const builtInSymbols = new Set(
770
1144
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
771
1145
  );
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
1146
  function hasOwnProperty(key) {
802
1147
  if (!isSymbol(key))
803
1148
  key = String(key);
@@ -828,14 +1173,22 @@ var Vue = (function () {
828
1173
  }
829
1174
  const targetIsArray = isArray(target);
830
1175
  if (!isReadonly2) {
831
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
832
- return Reflect.get(arrayInstrumentations, key, receiver);
1176
+ let fn;
1177
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1178
+ return fn;
833
1179
  }
834
1180
  if (key === "hasOwnProperty") {
835
1181
  return hasOwnProperty;
836
1182
  }
837
1183
  }
838
- const res = Reflect.get(target, key, receiver);
1184
+ const res = Reflect.get(
1185
+ target,
1186
+ key,
1187
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1188
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1189
+ // its class methods
1190
+ isRef(target) ? target : receiver
1191
+ );
839
1192
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
840
1193
  return res;
841
1194
  }
@@ -1334,110 +1687,8 @@ var Vue = (function () {
1334
1687
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1335
1688
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1336
1689
 
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
1690
  function isRef(r) {
1440
- return !!(r && r.__v_isRef === true);
1691
+ return r ? r.__v_isRef === true : false;
1441
1692
  }
1442
1693
  function ref(value) {
1443
1694
  return createRef(value, false);
@@ -1454,27 +1705,49 @@ getter: `, this.getter);
1454
1705
  class RefImpl {
1455
1706
  constructor(value, __v_isShallow) {
1456
1707
  this.__v_isShallow = __v_isShallow;
1457
- this.dep = void 0;
1708
+ this.dep = new Dep();
1458
1709
  this.__v_isRef = true;
1459
1710
  this._rawValue = __v_isShallow ? value : toRaw(value);
1460
1711
  this._value = __v_isShallow ? value : toReactive(value);
1461
1712
  }
1462
1713
  get value() {
1463
- trackRefValue(this);
1714
+ {
1715
+ this.dep.track({
1716
+ target: this,
1717
+ type: "get",
1718
+ key: "value"
1719
+ });
1720
+ }
1464
1721
  return this._value;
1465
1722
  }
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);
1723
+ set value(newValue) {
1724
+ const oldValue = this._rawValue;
1725
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1726
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1727
+ if (hasChanged(newValue, oldValue)) {
1728
+ this._rawValue = newValue;
1729
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1730
+ {
1731
+ this.dep.trigger({
1732
+ target: this,
1733
+ type: "set",
1734
+ key: "value",
1735
+ newValue,
1736
+ oldValue
1737
+ });
1738
+ }
1473
1739
  }
1474
1740
  }
1475
1741
  }
1476
1742
  function triggerRef(ref2) {
1477
- triggerRefValue(ref2, 4, ref2.value );
1743
+ {
1744
+ ref2.dep.trigger({
1745
+ target: ref2,
1746
+ type: "set",
1747
+ key: "value",
1748
+ newValue: ref2._value
1749
+ });
1750
+ }
1478
1751
  }
1479
1752
  function unref(ref2) {
1480
1753
  return isRef(ref2) ? ref2.value : ref2;
@@ -1499,12 +1772,9 @@ getter: `, this.getter);
1499
1772
  }
1500
1773
  class CustomRefImpl {
1501
1774
  constructor(factory) {
1502
- this.dep = void 0;
1503
1775
  this.__v_isRef = true;
1504
- const { get, set } = factory(
1505
- () => trackRefValue(this),
1506
- () => triggerRefValue(this)
1507
- );
1776
+ const dep = this.dep = new Dep();
1777
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1508
1778
  this._get = get;
1509
1779
  this._set = set;
1510
1780
  }
@@ -1572,6 +1842,90 @@ getter: `, this.getter);
1572
1842
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1573
1843
  }
1574
1844
 
1845
+ class ComputedRefImpl {
1846
+ constructor(fn, setter, isSSR) {
1847
+ this.fn = fn;
1848
+ this.setter = setter;
1849
+ /**
1850
+ * @internal
1851
+ */
1852
+ this._value = void 0;
1853
+ /**
1854
+ * @internal
1855
+ */
1856
+ this.dep = new Dep(this);
1857
+ /**
1858
+ * @internal
1859
+ */
1860
+ this.__v_isRef = true;
1861
+ // A computed is also a subscriber that tracks other deps
1862
+ /**
1863
+ * @internal
1864
+ */
1865
+ this.deps = void 0;
1866
+ /**
1867
+ * @internal
1868
+ */
1869
+ this.depsTail = void 0;
1870
+ /**
1871
+ * @internal
1872
+ */
1873
+ this.flags = 16;
1874
+ /**
1875
+ * @internal
1876
+ */
1877
+ this.globalVersion = globalVersion - 1;
1878
+ // for backwards compat
1879
+ this.effect = this;
1880
+ this.__v_isReadonly = !setter;
1881
+ this.isSSR = isSSR;
1882
+ }
1883
+ /**
1884
+ * @internal
1885
+ */
1886
+ notify() {
1887
+ if (activeSub !== this) {
1888
+ this.flags |= 16;
1889
+ this.dep.notify();
1890
+ }
1891
+ }
1892
+ get value() {
1893
+ const link = this.dep.track({
1894
+ target: this,
1895
+ type: "get",
1896
+ key: "value"
1897
+ }) ;
1898
+ refreshComputed(this);
1899
+ if (link) {
1900
+ link.version = this.dep.version;
1901
+ }
1902
+ return this._value;
1903
+ }
1904
+ set value(newValue) {
1905
+ if (this.setter) {
1906
+ this.setter(newValue);
1907
+ } else {
1908
+ warn$2("Write operation failed: computed value is readonly");
1909
+ }
1910
+ }
1911
+ }
1912
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1913
+ let getter;
1914
+ let setter;
1915
+ if (isFunction(getterOrOptions)) {
1916
+ getter = getterOrOptions;
1917
+ } else {
1918
+ getter = getterOrOptions.get;
1919
+ setter = getterOrOptions.set;
1920
+ }
1921
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1922
+ if (debugOptions && !isSSR) {
1923
+ cRef.onTrack = debugOptions.onTrack;
1924
+ cRef.onTrigger = debugOptions.onTrigger;
1925
+ }
1926
+ return cRef;
1927
+ }
1928
+
1575
1929
  const TrackOpTypes = {
1576
1930
  "GET": "get",
1577
1931
  "HAS": "has",
@@ -1864,7 +2218,7 @@ getter: `, this.getter);
1864
2218
  const middle = start + end >>> 1;
1865
2219
  const middleJob = queue[middle];
1866
2220
  const middleJobId = getId(middleJob);
1867
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2221
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1868
2222
  start = middle + 1;
1869
2223
  } else {
1870
2224
  end = middle;
@@ -1873,15 +2227,21 @@ getter: `, this.getter);
1873
2227
  return start;
1874
2228
  }
1875
2229
  function queueJob(job) {
1876
- if (!queue.length || !queue.includes(
1877
- job,
1878
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1879
- )) {
2230
+ var _a;
2231
+ if (!(job.flags & 1)) {
1880
2232
  if (job.id == null) {
1881
2233
  queue.push(job);
2234
+ } else if (
2235
+ // fast path when the job id is larger than the tail
2236
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2237
+ ) {
2238
+ queue.push(job);
1882
2239
  } else {
1883
2240
  queue.splice(findInsertionIndex(job.id), 0, job);
1884
2241
  }
2242
+ if (!(job.flags & 4)) {
2243
+ job.flags |= 1;
2244
+ }
1885
2245
  queueFlush();
1886
2246
  }
1887
2247
  }
@@ -1899,11 +2259,11 @@ getter: `, this.getter);
1899
2259
  }
1900
2260
  function queuePostFlushCb(cb) {
1901
2261
  if (!isArray(cb)) {
1902
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1903
- cb,
1904
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1905
- )) {
2262
+ if (!(cb.flags & 1)) {
1906
2263
  pendingPostFlushCbs.push(cb);
2264
+ if (!(cb.flags & 4)) {
2265
+ cb.flags |= 1;
2266
+ }
1907
2267
  }
1908
2268
  } else {
1909
2269
  pendingPostFlushCbs.push(...cb);
@@ -1916,7 +2276,7 @@ getter: `, this.getter);
1916
2276
  }
1917
2277
  for (; i < queue.length; i++) {
1918
2278
  const cb = queue[i];
1919
- if (cb && cb.pre) {
2279
+ if (cb && cb.flags & 2) {
1920
2280
  if (instance && cb.id !== instance.uid) {
1921
2281
  continue;
1922
2282
  }
@@ -1926,6 +2286,7 @@ getter: `, this.getter);
1926
2286
  queue.splice(i, 1);
1927
2287
  i--;
1928
2288
  cb();
2289
+ cb.flags &= ~1;
1929
2290
  }
1930
2291
  }
1931
2292
  }
@@ -1948,6 +2309,7 @@ getter: `, this.getter);
1948
2309
  continue;
1949
2310
  }
1950
2311
  activePostFlushCbs[postFlushIndex]();
2312
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1951
2313
  }
1952
2314
  activePostFlushCbs = null;
1953
2315
  postFlushIndex = 0;
@@ -1957,9 +2319,11 @@ getter: `, this.getter);
1957
2319
  const comparator = (a, b) => {
1958
2320
  const diff = getId(a) - getId(b);
1959
2321
  if (diff === 0) {
1960
- if (a.pre && !b.pre)
2322
+ const isAPre = a.flags & 2;
2323
+ const isBPre = b.flags & 2;
2324
+ if (isAPre && !isBPre)
1961
2325
  return -1;
1962
- if (b.pre && !a.pre)
2326
+ if (isBPre && !isAPre)
1963
2327
  return 1;
1964
2328
  }
1965
2329
  return diff;
@@ -1975,11 +2339,12 @@ getter: `, this.getter);
1975
2339
  try {
1976
2340
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1977
2341
  const job = queue[flushIndex];
1978
- if (job && job.active !== false) {
2342
+ if (job && !(job.flags & 8)) {
1979
2343
  if (check(job)) {
1980
2344
  continue;
1981
2345
  }
1982
2346
  callWithErrorHandling(job, null, 14);
2347
+ job.flags &= ~1;
1983
2348
  }
1984
2349
  }
1985
2350
  } finally {
@@ -2061,7 +2426,6 @@ getter: `, this.getter);
2061
2426
  }
2062
2427
  instance.renderCache = [];
2063
2428
  isHmrUpdating = true;
2064
- instance.effect.dirty = true;
2065
2429
  instance.update();
2066
2430
  isHmrUpdating = false;
2067
2431
  });
@@ -2089,7 +2453,6 @@ getter: `, this.getter);
2089
2453
  instance.ceReload(newComp.styles);
2090
2454
  hmrDirtyComponents.delete(oldComp);
2091
2455
  } else if (instance.parent) {
2092
- instance.parent.effect.dirty = true;
2093
2456
  queueJob(instance.parent.update);
2094
2457
  } else if (instance.appContext.reload) {
2095
2458
  instance.appContext.reload();
@@ -4053,8 +4416,8 @@ If this is a native custom element, make sure to exclude it from component resol
4053
4416
  };
4054
4417
  };
4055
4418
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4056
- const job = () => {
4057
- if (!effect.active || !effect.dirty) {
4419
+ const job = (immediateFirstRun) => {
4420
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4058
4421
  return;
4059
4422
  }
4060
4423
  if (cb) {
@@ -4075,19 +4438,22 @@ If this is a native custom element, make sure to exclude it from component resol
4075
4438
  effect.run();
4076
4439
  }
4077
4440
  };
4078
- job.allowRecurse = !!cb;
4441
+ if (cb)
4442
+ job.flags |= 4;
4443
+ const effect = new ReactiveEffect(getter);
4079
4444
  let scheduler;
4080
4445
  if (flush === "sync") {
4446
+ effect.flags |= 64;
4081
4447
  scheduler = job;
4082
4448
  } else if (flush === "post") {
4083
4449
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4084
4450
  } else {
4085
- job.pre = true;
4451
+ job.flags |= 2;
4086
4452
  if (instance)
4087
4453
  job.id = instance.uid;
4088
4454
  scheduler = () => queueJob(job);
4089
4455
  }
4090
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4456
+ effect.scheduler = scheduler;
4091
4457
  const scope = getCurrentScope();
4092
4458
  const unwatch = () => {
4093
4459
  effect.stop();
@@ -4101,7 +4467,7 @@ If this is a native custom element, make sure to exclude it from component resol
4101
4467
  }
4102
4468
  if (cb) {
4103
4469
  if (immediate) {
4104
- job();
4470
+ job(true);
4105
4471
  } else {
4106
4472
  oldValue = effect.run();
4107
4473
  }
@@ -4283,22 +4649,7 @@ If this is a native custom element, make sure to exclude it from component resol
4283
4649
  if (!children || !children.length) {
4284
4650
  return;
4285
4651
  }
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
- }
4652
+ const child = findNonCommentChild(children);
4302
4653
  const rawProps = toRaw(props);
4303
4654
  const { mode } = rawProps;
4304
4655
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4307,7 +4658,7 @@ If this is a native custom element, make sure to exclude it from component resol
4307
4658
  if (state.isLeaving) {
4308
4659
  return emptyPlaceholder(child);
4309
4660
  }
4310
- const innerChild = getKeepAliveChild(child);
4661
+ const innerChild = getInnerChild$1(child);
4311
4662
  if (!innerChild) {
4312
4663
  return emptyPlaceholder(child);
4313
4664
  }
@@ -4319,7 +4670,7 @@ If this is a native custom element, make sure to exclude it from component resol
4319
4670
  );
4320
4671
  setTransitionHooks(innerChild, enterHooks);
4321
4672
  const oldChild = instance.subTree;
4322
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4673
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4323
4674
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4324
4675
  const leavingHooks = resolveTransitionHooks(
4325
4676
  oldInnerChild,
@@ -4332,8 +4683,7 @@ If this is a native custom element, make sure to exclude it from component resol
4332
4683
  state.isLeaving = true;
4333
4684
  leavingHooks.afterLeave = () => {
4334
4685
  state.isLeaving = false;
4335
- if (instance.update.active !== false) {
4336
- instance.effect.dirty = true;
4686
+ if (!(instance.job.flags & 8)) {
4337
4687
  instance.update();
4338
4688
  }
4339
4689
  };
@@ -4361,6 +4711,25 @@ If this is a native custom element, make sure to exclude it from component resol
4361
4711
  {
4362
4712
  BaseTransitionImpl.__isBuiltIn = true;
4363
4713
  }
4714
+ function findNonCommentChild(children) {
4715
+ let child = children[0];
4716
+ if (children.length > 1) {
4717
+ let hasFound = false;
4718
+ for (const c of children) {
4719
+ if (c.type !== Comment) {
4720
+ if (hasFound) {
4721
+ warn$1(
4722
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4723
+ );
4724
+ break;
4725
+ }
4726
+ child = c;
4727
+ hasFound = true;
4728
+ }
4729
+ }
4730
+ }
4731
+ return child;
4732
+ }
4364
4733
  const BaseTransition = BaseTransitionImpl;
4365
4734
  function getLeavingNodesForType(state, vnode) {
4366
4735
  const { leavingVNodes } = state;
@@ -4515,8 +4884,11 @@ If this is a native custom element, make sure to exclude it from component resol
4515
4884
  return vnode;
4516
4885
  }
4517
4886
  }
4518
- function getKeepAliveChild(vnode) {
4887
+ function getInnerChild$1(vnode) {
4519
4888
  if (!isKeepAlive(vnode)) {
4889
+ if (isTeleport(vnode.type) && vnode.children) {
4890
+ return findNonCommentChild(vnode.children);
4891
+ }
4520
4892
  return vnode;
4521
4893
  }
4522
4894
  if (vnode.component) {
@@ -4685,7 +5057,6 @@ If this is a native custom element, make sure to exclude it from component resol
4685
5057
  load().then(() => {
4686
5058
  loaded.value = true;
4687
5059
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4688
- instance.parent.effect.dirty = true;
4689
5060
  queueJob(instance.parent.update);
4690
5061
  }
4691
5062
  }).catch((err) => {
@@ -5297,10 +5668,20 @@ If this is a native custom element, make sure to exclude it from component resol
5297
5668
  function renderList(source, renderItem, cache, index) {
5298
5669
  let ret;
5299
5670
  const cached = cache && cache[index];
5300
- if (isArray(source) || isString(source)) {
5671
+ const sourceIsArray = isArray(source);
5672
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5673
+ if (sourceIsArray || isString(source)) {
5674
+ if (sourceIsReactiveArray) {
5675
+ source = shallowReadArray(source);
5676
+ }
5301
5677
  ret = new Array(source.length);
5302
5678
  for (let i = 0, l = source.length; i < l; i++) {
5303
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5679
+ ret[i] = renderItem(
5680
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5681
+ i,
5682
+ void 0,
5683
+ cached && cached[i]
5684
+ );
5304
5685
  }
5305
5686
  } else if (typeof source === "number") {
5306
5687
  if (!Number.isInteger(source)) {
@@ -5671,7 +6052,6 @@ If this is a native custom element, make sure to exclude it from component resol
5671
6052
  $emit: (i) => i.emit,
5672
6053
  $options: (i) => resolveMergedOptions(i) ,
5673
6054
  $forceUpdate: (i) => i.f || (i.f = () => {
5674
- i.effect.dirty = true;
5675
6055
  queueJob(i.update);
5676
6056
  }),
5677
6057
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6542,7 +6922,7 @@ If this is a native custom element, make sure to exclude it from component resol
6542
6922
  return vm;
6543
6923
  }
6544
6924
  }
6545
- Vue.version = `2.6.14-compat:${"3.4.25"}`;
6925
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6546
6926
  Vue.config = singletonApp.config;
6547
6927
  Vue.use = (p, ...options) => {
6548
6928
  if (p && isFunction(p.install)) {
@@ -7560,7 +7940,9 @@ If you want to remount the same app, move your app creation logic into a factory
7560
7940
  function assertType(value, type) {
7561
7941
  let valid;
7562
7942
  const expectedType = getType(type);
7563
- if (isSimpleType(expectedType)) {
7943
+ if (expectedType === "null") {
7944
+ valid = value === null;
7945
+ } else if (isSimpleType(expectedType)) {
7564
7946
  const t = typeof value;
7565
7947
  valid = t === expectedType.toLowerCase();
7566
7948
  if (!valid && t === "object") {
@@ -7570,8 +7952,6 @@ If you want to remount the same app, move your app creation logic into a factory
7570
7952
  valid = isObject(value);
7571
7953
  } else if (expectedType === "Array") {
7572
7954
  valid = isArray(value);
7573
- } else if (expectedType === "null") {
7574
- valid = value === null;
7575
7955
  } else {
7576
7956
  valid = value instanceof type;
7577
7957
  }
@@ -9096,7 +9476,6 @@ Server rendered element contains fewer child nodes than client vdom.`
9096
9476
  } else {
9097
9477
  instance.next = n2;
9098
9478
  invalidateJob(instance.update);
9099
- instance.effect.dirty = true;
9100
9479
  instance.update();
9101
9480
  }
9102
9481
  } else {
@@ -9303,24 +9682,18 @@ Server rendered element contains fewer child nodes than client vdom.`
9303
9682
  }
9304
9683
  }
9305
9684
  };
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;
9685
+ instance.scope.on();
9686
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9687
+ instance.scope.off();
9688
+ const update = instance.update = effect.run.bind(effect);
9689
+ const job = instance.job = effect.runIfDirty.bind(effect);
9690
+ job.id = instance.uid;
9691
+ effect.scheduler = () => queueJob(job);
9319
9692
  toggleRecurse(instance, true);
9320
9693
  {
9321
9694
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9322
9695
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9323
- update.ownerInstance = instance;
9696
+ job.ownerInstance = instance;
9324
9697
  }
9325
9698
  update();
9326
9699
  };
@@ -9787,7 +10160,7 @@ Server rendered element contains fewer child nodes than client vdom.`
9787
10160
  if (instance.type.__hmrId) {
9788
10161
  unregisterHMR(instance);
9789
10162
  }
9790
- const { bum, scope, update, subTree, um } = instance;
10163
+ const { bum, scope, job, subTree, um } = instance;
9791
10164
  if (bum) {
9792
10165
  invokeArrayFns(bum);
9793
10166
  }
@@ -9795,8 +10168,8 @@ Server rendered element contains fewer child nodes than client vdom.`
9795
10168
  instance.emit("hook:beforeDestroy");
9796
10169
  }
9797
10170
  scope.stop();
9798
- if (update) {
9799
- update.active = false;
10171
+ if (job) {
10172
+ job.flags |= 8;
9800
10173
  unmount(subTree, instance, parentSuspense, doRemove);
9801
10174
  }
9802
10175
  if (um) {
@@ -9888,8 +10261,14 @@ Server rendered element contains fewer child nodes than client vdom.`
9888
10261
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9889
10262
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9890
10263
  }
9891
- function toggleRecurse({ effect, update }, allowed) {
9892
- effect.allowRecurse = update.allowRecurse = allowed;
10264
+ function toggleRecurse({ effect, job }, allowed) {
10265
+ if (allowed) {
10266
+ effect.flags |= 32;
10267
+ job.flags |= 4;
10268
+ } else {
10269
+ effect.flags &= ~32;
10270
+ job.flags &= ~4;
10271
+ }
9893
10272
  }
9894
10273
  function needTransition(parentSuspense, transition) {
9895
10274
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10687,6 +11066,7 @@ Component that was made reactive: `,
10687
11066
  effect: null,
10688
11067
  update: null,
10689
11068
  // will be set synchronously right after creation
11069
+ job: null,
10690
11070
  scope: new EffectScope(
10691
11071
  true
10692
11072
  /* detached */
@@ -11192,7 +11572,8 @@ Component that was made reactive: `,
11192
11572
  {},
11193
11573
  ["span", vueStyle, genRefFlag(obj)],
11194
11574
  "<",
11195
- formatValue(obj.value),
11575
+ // avoid debugger accessing value affecting behavior
11576
+ formatValue("_value" in obj ? obj._value : obj),
11196
11577
  `>`
11197
11578
  ];
11198
11579
  } else if (isReactive(obj)) {
@@ -11372,7 +11753,7 @@ Component that was made reactive: `,
11372
11753
  return true;
11373
11754
  }
11374
11755
 
11375
- const version = "3.4.25";
11756
+ const version = "3.5.0-alpha.1";
11376
11757
  const warn = warn$1 ;
11377
11758
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11378
11759
  const devtools = devtools$1 ;
@@ -12927,7 +13308,9 @@ Expected function or array of functions, received type ${typeof value}.`
12927
13308
  return;
12928
13309
  }
12929
13310
  const eventKey = hyphenate(event.key);
12930
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13311
+ if (modifiers.some(
13312
+ (k) => k === eventKey || keyNames[k] === eventKey
13313
+ )) {
12931
13314
  return fn(event);
12932
13315
  }
12933
13316
  {
@@ -18908,9 +19291,183 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
18908
19291
  }
18909
19292
  };
18910
19293
 
19294
+ function isValidHTMLNesting(parent, child) {
19295
+ if (parent in onlyValidChildren) {
19296
+ return onlyValidChildren[parent].has(child);
19297
+ }
19298
+ if (child in onlyValidParents) {
19299
+ return onlyValidParents[child].has(parent);
19300
+ }
19301
+ if (parent in knownInvalidChildren) {
19302
+ if (knownInvalidChildren[parent].has(child))
19303
+ return false;
19304
+ }
19305
+ if (child in knownInvalidParents) {
19306
+ if (knownInvalidParents[child].has(parent))
19307
+ return false;
19308
+ }
19309
+ return true;
19310
+ }
19311
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
19312
+ const emptySet = /* @__PURE__ */ new Set([]);
19313
+ const onlyValidChildren = {
19314
+ head: /* @__PURE__ */ new Set([
19315
+ "base",
19316
+ "basefront",
19317
+ "bgsound",
19318
+ "link",
19319
+ "meta",
19320
+ "title",
19321
+ "noscript",
19322
+ "noframes",
19323
+ "style",
19324
+ "script",
19325
+ "template"
19326
+ ]),
19327
+ optgroup: /* @__PURE__ */ new Set(["option"]),
19328
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
19329
+ // table
19330
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
19331
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
19332
+ colgroup: /* @__PURE__ */ new Set(["col"]),
19333
+ tbody: /* @__PURE__ */ new Set(["tr"]),
19334
+ thead: /* @__PURE__ */ new Set(["tr"]),
19335
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
19336
+ // these elements can not have any children elements
19337
+ script: emptySet,
19338
+ iframe: emptySet,
19339
+ option: emptySet,
19340
+ textarea: emptySet,
19341
+ style: emptySet,
19342
+ title: emptySet
19343
+ };
19344
+ const onlyValidParents = {
19345
+ // sections
19346
+ html: emptySet,
19347
+ body: /* @__PURE__ */ new Set(["html"]),
19348
+ head: /* @__PURE__ */ new Set(["html"]),
19349
+ // table
19350
+ td: /* @__PURE__ */ new Set(["tr"]),
19351
+ colgroup: /* @__PURE__ */ new Set(["table"]),
19352
+ caption: /* @__PURE__ */ new Set(["table"]),
19353
+ tbody: /* @__PURE__ */ new Set(["table"]),
19354
+ tfoot: /* @__PURE__ */ new Set(["table"]),
19355
+ col: /* @__PURE__ */ new Set(["colgroup"]),
19356
+ th: /* @__PURE__ */ new Set(["tr"]),
19357
+ thead: /* @__PURE__ */ new Set(["table"]),
19358
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
19359
+ // data list
19360
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
19361
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
19362
+ // other
19363
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
19364
+ // li: new Set(["ul", "ol"]),
19365
+ summary: /* @__PURE__ */ new Set(["details"]),
19366
+ area: /* @__PURE__ */ new Set(["map"])
19367
+ };
19368
+ const knownInvalidChildren = {
19369
+ p: /* @__PURE__ */ new Set([
19370
+ "address",
19371
+ "article",
19372
+ "aside",
19373
+ "blockquote",
19374
+ "center",
19375
+ "details",
19376
+ "dialog",
19377
+ "dir",
19378
+ "div",
19379
+ "dl",
19380
+ "fieldset",
19381
+ "figure",
19382
+ "footer",
19383
+ "form",
19384
+ "h1",
19385
+ "h2",
19386
+ "h3",
19387
+ "h4",
19388
+ "h5",
19389
+ "h6",
19390
+ "header",
19391
+ "hgroup",
19392
+ "hr",
19393
+ "li",
19394
+ "main",
19395
+ "nav",
19396
+ "menu",
19397
+ "ol",
19398
+ "p",
19399
+ "pre",
19400
+ "section",
19401
+ "table",
19402
+ "ul"
19403
+ ]),
19404
+ svg: /* @__PURE__ */ new Set([
19405
+ "b",
19406
+ "blockquote",
19407
+ "br",
19408
+ "code",
19409
+ "dd",
19410
+ "div",
19411
+ "dl",
19412
+ "dt",
19413
+ "em",
19414
+ "embed",
19415
+ "h1",
19416
+ "h2",
19417
+ "h3",
19418
+ "h4",
19419
+ "h5",
19420
+ "h6",
19421
+ "hr",
19422
+ "i",
19423
+ "img",
19424
+ "li",
19425
+ "menu",
19426
+ "meta",
19427
+ "ol",
19428
+ "p",
19429
+ "pre",
19430
+ "ruby",
19431
+ "s",
19432
+ "small",
19433
+ "span",
19434
+ "strong",
19435
+ "sub",
19436
+ "sup",
19437
+ "table",
19438
+ "u",
19439
+ "ul",
19440
+ "var"
19441
+ ])
19442
+ };
19443
+ const knownInvalidParents = {
19444
+ a: /* @__PURE__ */ new Set(["a"]),
19445
+ button: /* @__PURE__ */ new Set(["button"]),
19446
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
19447
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
19448
+ form: /* @__PURE__ */ new Set(["form"]),
19449
+ li: /* @__PURE__ */ new Set(["li"]),
19450
+ h1: headings,
19451
+ h2: headings,
19452
+ h3: headings,
19453
+ h4: headings,
19454
+ h5: headings,
19455
+ h6: headings
19456
+ };
19457
+
19458
+ const validateHtmlNesting = (node, context) => {
19459
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
19460
+ const error = new SyntaxError(
19461
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
19462
+ );
19463
+ error.loc = node.loc;
19464
+ context.onWarn(error);
19465
+ }
19466
+ };
19467
+
18911
19468
  const DOMNodeTransforms = [
18912
19469
  transformStyle,
18913
- ...[transformTransition]
19470
+ ...[transformTransition, validateHtmlNesting]
18914
19471
  ];
18915
19472
  const DOMDirectiveTransforms = {
18916
19473
  cloak: noopDirectiveTransform,