@vue/compat 3.4.26 → 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.26
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
  **/
@@ -81,11 +81,10 @@ const invokeArrayFns = (fns, arg) => {
81
81
  fns[i](arg);
82
82
  }
83
83
  };
84
- const def = (obj, key, value, writable = false) => {
84
+ const def = (obj, key, value) => {
85
85
  Object.defineProperty(obj, key, {
86
86
  configurable: true,
87
87
  enumerable: false,
88
- writable,
89
88
  value
90
89
  });
91
90
  };
@@ -450,156 +449,280 @@ class EffectScope {
450
449
  function effectScope(detached) {
451
450
  return new EffectScope(detached);
452
451
  }
453
- function recordEffectScope(effect, scope = activeEffectScope) {
454
- if (scope && scope.active) {
455
- scope.effects.push(effect);
456
- }
457
- }
458
452
  function getCurrentScope() {
459
453
  return activeEffectScope;
460
454
  }
461
- function onScopeDispose(fn) {
455
+ function onScopeDispose(fn, failSilently = false) {
462
456
  if (activeEffectScope) {
463
457
  activeEffectScope.cleanups.push(fn);
464
- } else {
458
+ } else if (!failSilently) {
465
459
  warn$2(
466
460
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
467
461
  );
468
462
  }
469
463
  }
470
464
 
471
- let activeEffect;
465
+ let activeSub;
472
466
  class ReactiveEffect {
473
- constructor(fn, trigger, scheduler, scope) {
467
+ constructor(fn) {
474
468
  this.fn = fn;
475
- this.trigger = trigger;
476
- this.scheduler = scheduler;
477
- this.active = true;
478
- this.deps = [];
479
469
  /**
480
470
  * @internal
481
471
  */
482
- this._dirtyLevel = 4;
472
+ this.deps = void 0;
483
473
  /**
484
474
  * @internal
485
475
  */
486
- this._trackId = 0;
476
+ this.depsTail = void 0;
487
477
  /**
488
478
  * @internal
489
479
  */
490
- this._runnings = 0;
480
+ this.flags = 1 | 4;
491
481
  /**
492
482
  * @internal
493
483
  */
494
- this._shouldSchedule = false;
484
+ this.nextEffect = void 0;
495
485
  /**
496
486
  * @internal
497
487
  */
498
- this._depsLength = 0;
499
- recordEffectScope(this, scope);
500
- }
501
- get dirty() {
502
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
503
- this._dirtyLevel = 1;
504
- pauseTracking();
505
- for (let i = 0; i < this._depsLength; i++) {
506
- const dep = this.deps[i];
507
- if (dep.computed) {
508
- triggerComputed(dep.computed);
509
- if (this._dirtyLevel >= 4) {
510
- break;
511
- }
512
- }
513
- }
514
- if (this._dirtyLevel === 1) {
515
- this._dirtyLevel = 0;
516
- }
517
- resetTracking();
488
+ this.cleanup = void 0;
489
+ this.scheduler = void 0;
490
+ if (activeEffectScope && activeEffectScope.active) {
491
+ activeEffectScope.effects.push(this);
518
492
  }
519
- return this._dirtyLevel >= 4;
520
493
  }
521
- set dirty(v) {
522
- this._dirtyLevel = v ? 4 : 0;
494
+ /**
495
+ * @internal
496
+ */
497
+ notify() {
498
+ if (this.flags & 2 && !(this.flags & 32)) {
499
+ return;
500
+ }
501
+ if (this.flags & 64) {
502
+ return this.trigger();
503
+ }
504
+ if (!(this.flags & 8)) {
505
+ this.flags |= 8;
506
+ this.nextEffect = batchedEffect;
507
+ batchedEffect = this;
508
+ }
523
509
  }
524
510
  run() {
525
- this._dirtyLevel = 0;
526
- if (!this.active) {
511
+ if (!(this.flags & 1)) {
527
512
  return this.fn();
528
513
  }
529
- let lastShouldTrack = shouldTrack;
530
- let lastEffect = activeEffect;
514
+ this.flags |= 2;
515
+ cleanupEffect(this);
516
+ prepareDeps(this);
517
+ const prevEffect = activeSub;
518
+ const prevShouldTrack = shouldTrack;
519
+ activeSub = this;
520
+ shouldTrack = true;
531
521
  try {
532
- shouldTrack = true;
533
- activeEffect = this;
534
- this._runnings++;
535
- preCleanupEffect(this);
536
522
  return this.fn();
537
523
  } finally {
538
- postCleanupEffect(this);
539
- this._runnings--;
540
- activeEffect = lastEffect;
541
- shouldTrack = lastShouldTrack;
524
+ if (activeSub !== this) {
525
+ warn$2(
526
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
527
+ );
528
+ }
529
+ cleanupDeps(this);
530
+ activeSub = prevEffect;
531
+ shouldTrack = prevShouldTrack;
532
+ this.flags &= ~2;
542
533
  }
543
534
  }
544
535
  stop() {
545
- if (this.active) {
546
- preCleanupEffect(this);
547
- postCleanupEffect(this);
536
+ if (this.flags & 1) {
537
+ for (let link = this.deps; link; link = link.nextDep) {
538
+ removeSub(link);
539
+ }
540
+ this.deps = this.depsTail = void 0;
541
+ cleanupEffect(this);
548
542
  this.onStop && this.onStop();
549
- this.active = false;
543
+ this.flags &= ~1;
544
+ }
545
+ }
546
+ trigger() {
547
+ if (this.scheduler) {
548
+ this.scheduler();
549
+ } else {
550
+ this.runIfDirty();
550
551
  }
551
552
  }
553
+ /**
554
+ * @internal
555
+ */
556
+ runIfDirty() {
557
+ if (isDirty(this)) {
558
+ this.run();
559
+ }
560
+ }
561
+ get dirty() {
562
+ return isDirty(this);
563
+ }
552
564
  }
553
- function triggerComputed(computed) {
554
- return computed.value;
565
+ let batchDepth = 0;
566
+ let batchedEffect;
567
+ function startBatch() {
568
+ batchDepth++;
555
569
  }
556
- function preCleanupEffect(effect2) {
557
- effect2._trackId++;
558
- effect2._depsLength = 0;
570
+ function endBatch() {
571
+ if (batchDepth > 1) {
572
+ batchDepth--;
573
+ return;
574
+ }
575
+ let error;
576
+ while (batchedEffect) {
577
+ let e = batchedEffect;
578
+ batchedEffect = void 0;
579
+ while (e) {
580
+ const next = e.nextEffect;
581
+ e.nextEffect = void 0;
582
+ e.flags &= ~8;
583
+ if (e.flags & 1) {
584
+ try {
585
+ e.trigger();
586
+ } catch (err) {
587
+ if (!error)
588
+ error = err;
589
+ }
590
+ }
591
+ e = next;
592
+ }
593
+ }
594
+ batchDepth--;
595
+ if (error)
596
+ throw error;
559
597
  }
560
- function postCleanupEffect(effect2) {
561
- if (effect2.deps.length > effect2._depsLength) {
562
- for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
563
- cleanupDepEffect(effect2.deps[i], effect2);
598
+ function prepareDeps(sub) {
599
+ for (let link = sub.deps; link; link = link.nextDep) {
600
+ link.version = -1;
601
+ link.prevActiveLink = link.dep.activeLink;
602
+ link.dep.activeLink = link;
603
+ }
604
+ }
605
+ function cleanupDeps(sub) {
606
+ let head;
607
+ let tail = sub.depsTail;
608
+ for (let link = tail; link; link = link.prevDep) {
609
+ if (link.version === -1) {
610
+ if (link === tail)
611
+ tail = link.prevDep;
612
+ removeSub(link);
613
+ removeDep(link);
614
+ } else {
615
+ head = link;
564
616
  }
565
- effect2.deps.length = effect2._depsLength;
617
+ link.dep.activeLink = link.prevActiveLink;
618
+ link.prevActiveLink = void 0;
566
619
  }
620
+ sub.deps = head;
621
+ sub.depsTail = tail;
567
622
  }
568
- function cleanupDepEffect(dep, effect2) {
569
- const trackId = dep.get(effect2);
570
- if (trackId !== void 0 && effect2._trackId !== trackId) {
571
- dep.delete(effect2);
572
- if (dep.size === 0) {
573
- dep.cleanup();
623
+ function isDirty(sub) {
624
+ for (let link = sub.deps; link; link = link.nextDep) {
625
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
626
+ return true;
574
627
  }
575
628
  }
629
+ if (sub._dirty) {
630
+ return true;
631
+ }
632
+ return false;
633
+ }
634
+ function refreshComputed(computed) {
635
+ if (computed.flags & 2) {
636
+ return false;
637
+ }
638
+ if (computed.flags & 4 && !(computed.flags & 16)) {
639
+ return;
640
+ }
641
+ computed.flags &= ~16;
642
+ if (computed.globalVersion === globalVersion) {
643
+ return;
644
+ }
645
+ computed.globalVersion = globalVersion;
646
+ const dep = computed.dep;
647
+ computed.flags |= 2;
648
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
649
+ computed.flags &= ~2;
650
+ return;
651
+ }
652
+ const prevSub = activeSub;
653
+ const prevShouldTrack = shouldTrack;
654
+ activeSub = computed;
655
+ shouldTrack = true;
656
+ try {
657
+ prepareDeps(computed);
658
+ const value = computed.fn();
659
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
660
+ computed._value = value;
661
+ dep.version++;
662
+ }
663
+ } catch (err) {
664
+ dep.version++;
665
+ throw err;
666
+ } finally {
667
+ activeSub = prevSub;
668
+ shouldTrack = prevShouldTrack;
669
+ cleanupDeps(computed);
670
+ computed.flags &= ~2;
671
+ }
672
+ }
673
+ function removeSub(link) {
674
+ const { dep, prevSub, nextSub } = link;
675
+ if (prevSub) {
676
+ prevSub.nextSub = nextSub;
677
+ link.prevSub = void 0;
678
+ }
679
+ if (nextSub) {
680
+ nextSub.prevSub = prevSub;
681
+ link.nextSub = void 0;
682
+ }
683
+ if (dep.subs === link) {
684
+ dep.subs = prevSub;
685
+ }
686
+ if (!dep.subs && dep.computed) {
687
+ dep.computed.flags &= ~4;
688
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
689
+ removeSub(l);
690
+ }
691
+ }
692
+ }
693
+ function removeDep(link) {
694
+ const { prevDep, nextDep } = link;
695
+ if (prevDep) {
696
+ prevDep.nextDep = nextDep;
697
+ link.prevDep = void 0;
698
+ }
699
+ if (nextDep) {
700
+ nextDep.prevDep = prevDep;
701
+ link.nextDep = void 0;
702
+ }
576
703
  }
577
704
  function effect(fn, options) {
578
705
  if (fn.effect instanceof ReactiveEffect) {
579
706
  fn = fn.effect.fn;
580
707
  }
581
- const _effect = new ReactiveEffect(fn, NOOP, () => {
582
- if (_effect.dirty) {
583
- _effect.run();
584
- }
585
- });
708
+ const e = new ReactiveEffect(fn);
586
709
  if (options) {
587
- extend(_effect, options);
588
- if (options.scope)
589
- recordEffectScope(_effect, options.scope);
710
+ extend(e, options);
590
711
  }
591
- if (!options || !options.lazy) {
592
- _effect.run();
712
+ try {
713
+ e.run();
714
+ } catch (err) {
715
+ e.stop();
716
+ throw err;
593
717
  }
594
- const runner = _effect.run.bind(_effect);
595
- runner.effect = _effect;
718
+ const runner = e.run.bind(e);
719
+ runner.effect = e;
596
720
  return runner;
597
721
  }
598
722
  function stop(runner) {
599
723
  runner.effect.stop();
600
724
  }
601
725
  let shouldTrack = true;
602
- let pauseScheduleStack = 0;
603
726
  const trackStack = [];
604
727
  function pauseTracking() {
605
728
  trackStack.push(shouldTrack);
@@ -609,192 +732,414 @@ function resetTracking() {
609
732
  const last = trackStack.pop();
610
733
  shouldTrack = last === void 0 ? true : last;
611
734
  }
612
- function pauseScheduling() {
613
- pauseScheduleStack++;
614
- }
615
- function resetScheduling() {
616
- pauseScheduleStack--;
617
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
618
- queueEffectSchedulers.shift()();
735
+ function cleanupEffect(e) {
736
+ const { cleanup } = e;
737
+ e.cleanup = void 0;
738
+ if (cleanup) {
739
+ const prevSub = activeSub;
740
+ activeSub = void 0;
741
+ try {
742
+ cleanup();
743
+ } finally {
744
+ activeSub = prevSub;
745
+ }
619
746
  }
620
747
  }
621
- function trackEffect(effect2, dep, debuggerEventExtraInfo) {
622
- var _a;
623
- if (dep.get(effect2) !== effect2._trackId) {
624
- dep.set(effect2, effect2._trackId);
625
- const oldDep = effect2.deps[effect2._depsLength];
626
- if (oldDep !== dep) {
627
- if (oldDep) {
628
- cleanupDepEffect(oldDep, effect2);
629
- }
630
- effect2.deps[effect2._depsLength++] = dep;
631
- } else {
632
- effect2._depsLength++;
633
- }
748
+
749
+ let globalVersion = 0;
750
+ class Dep {
751
+ constructor(computed) {
752
+ this.computed = computed;
753
+ this.version = 0;
754
+ /**
755
+ * Link between this dep and the current active effect
756
+ */
757
+ this.activeLink = void 0;
758
+ /**
759
+ * Doubly linked list representing the subscribing effects (tail)
760
+ */
761
+ this.subs = void 0;
634
762
  {
635
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
763
+ this.subsHead = void 0;
636
764
  }
637
765
  }
638
- }
639
- const queueEffectSchedulers = [];
640
- function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
641
- var _a;
642
- pauseScheduling();
643
- for (const effect2 of dep.keys()) {
644
- let tracking;
645
- if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
646
- effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
647
- effect2._dirtyLevel = dirtyLevel;
648
- }
649
- if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
650
- {
651
- (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
766
+ track(debugInfo) {
767
+ if (!activeSub || !shouldTrack) {
768
+ return;
769
+ }
770
+ let link = this.activeLink;
771
+ if (link === void 0 || link.sub !== activeSub) {
772
+ link = this.activeLink = {
773
+ dep: this,
774
+ sub: activeSub,
775
+ version: this.version,
776
+ nextDep: void 0,
777
+ prevDep: void 0,
778
+ nextSub: void 0,
779
+ prevSub: void 0,
780
+ prevActiveLink: void 0
781
+ };
782
+ if (!activeSub.deps) {
783
+ activeSub.deps = activeSub.depsTail = link;
784
+ } else {
785
+ link.prevDep = activeSub.depsTail;
786
+ activeSub.depsTail.nextDep = link;
787
+ activeSub.depsTail = link;
652
788
  }
653
- effect2.trigger();
654
- if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
655
- effect2._shouldSchedule = false;
656
- if (effect2.scheduler) {
657
- queueEffectSchedulers.push(effect2.scheduler);
789
+ if (activeSub.flags & 4) {
790
+ addSub(link);
791
+ }
792
+ } else if (link.version === -1) {
793
+ link.version = this.version;
794
+ if (link.nextDep) {
795
+ const next = link.nextDep;
796
+ next.prevDep = link.prevDep;
797
+ if (link.prevDep) {
798
+ link.prevDep.nextDep = next;
799
+ }
800
+ link.prevDep = activeSub.depsTail;
801
+ link.nextDep = void 0;
802
+ activeSub.depsTail.nextDep = link;
803
+ activeSub.depsTail = link;
804
+ if (activeSub.deps === link) {
805
+ activeSub.deps = next;
658
806
  }
659
807
  }
660
808
  }
809
+ if (activeSub.onTrack) {
810
+ activeSub.onTrack(
811
+ extend(
812
+ {
813
+ effect: activeSub
814
+ },
815
+ debugInfo
816
+ )
817
+ );
818
+ }
819
+ return link;
820
+ }
821
+ trigger(debugInfo) {
822
+ this.version++;
823
+ globalVersion++;
824
+ this.notify(debugInfo);
825
+ }
826
+ notify(debugInfo) {
827
+ startBatch();
828
+ try {
829
+ if (true) {
830
+ for (let head = this.subsHead; head; head = head.nextSub) {
831
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
832
+ head.sub.onTrigger(
833
+ extend(
834
+ {
835
+ effect: head.sub
836
+ },
837
+ debugInfo
838
+ )
839
+ );
840
+ }
841
+ }
842
+ }
843
+ for (let link = this.subs; link; link = link.prevSub) {
844
+ link.sub.notify();
845
+ }
846
+ } finally {
847
+ endBatch();
848
+ }
661
849
  }
662
- resetScheduling();
663
850
  }
664
-
665
- const createDep = (cleanup, computed) => {
666
- const dep = /* @__PURE__ */ new Map();
667
- dep.cleanup = cleanup;
668
- dep.computed = computed;
669
- return dep;
670
- };
671
-
851
+ function addSub(link) {
852
+ const computed = link.dep.computed;
853
+ if (computed && !link.dep.subs) {
854
+ computed.flags |= 4 | 16;
855
+ for (let l = computed.deps; l; l = l.nextDep) {
856
+ addSub(l);
857
+ }
858
+ }
859
+ const currentTail = link.dep.subs;
860
+ if (currentTail !== link) {
861
+ link.prevSub = currentTail;
862
+ if (currentTail)
863
+ currentTail.nextSub = link;
864
+ }
865
+ if (link.dep.subsHead === void 0) {
866
+ link.dep.subsHead = link;
867
+ }
868
+ link.dep.subs = link;
869
+ }
672
870
  const targetMap = /* @__PURE__ */ new WeakMap();
673
- const ITERATE_KEY = Symbol("iterate" );
674
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
871
+ const ITERATE_KEY = Symbol("Object iterate" );
872
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
873
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
675
874
  function track(target, type, key) {
676
- if (shouldTrack && activeEffect) {
875
+ if (shouldTrack && activeSub) {
677
876
  let depsMap = targetMap.get(target);
678
877
  if (!depsMap) {
679
878
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
680
879
  }
681
880
  let dep = depsMap.get(key);
682
881
  if (!dep) {
683
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
882
+ depsMap.set(key, dep = new Dep());
684
883
  }
685
- trackEffect(
686
- activeEffect,
687
- dep,
688
- {
884
+ {
885
+ dep.track({
689
886
  target,
690
887
  type,
691
888
  key
692
- }
693
- );
889
+ });
890
+ }
694
891
  }
695
892
  }
696
893
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
697
894
  const depsMap = targetMap.get(target);
698
895
  if (!depsMap) {
896
+ globalVersion++;
699
897
  return;
700
898
  }
701
899
  let deps = [];
702
900
  if (type === "clear") {
703
901
  deps = [...depsMap.values()];
704
- } else if (key === "length" && isArray(target)) {
705
- const newLength = Number(newValue);
706
- depsMap.forEach((dep, key2) => {
707
- if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
708
- deps.push(dep);
709
- }
710
- });
711
902
  } else {
712
- if (key !== void 0) {
713
- deps.push(depsMap.get(key));
714
- }
715
- switch (type) {
716
- case "add":
717
- if (!isArray(target)) {
718
- deps.push(depsMap.get(ITERATE_KEY));
719
- if (isMap(target)) {
720
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
721
- }
722
- } else if (isIntegerKey(key)) {
723
- deps.push(depsMap.get("length"));
903
+ const targetIsArray = isArray(target);
904
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
905
+ if (targetIsArray && key === "length") {
906
+ const newLength = Number(newValue);
907
+ depsMap.forEach((dep, key2) => {
908
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
909
+ deps.push(dep);
724
910
  }
725
- break;
726
- case "delete":
727
- if (!isArray(target)) {
728
- deps.push(depsMap.get(ITERATE_KEY));
911
+ });
912
+ } else {
913
+ const push = (dep) => dep && deps.push(dep);
914
+ if (key !== void 0) {
915
+ push(depsMap.get(key));
916
+ }
917
+ if (isArrayIndex) {
918
+ push(depsMap.get(ARRAY_ITERATE_KEY));
919
+ }
920
+ switch (type) {
921
+ case "add":
922
+ if (!targetIsArray) {
923
+ push(depsMap.get(ITERATE_KEY));
924
+ if (isMap(target)) {
925
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
926
+ }
927
+ } else if (isArrayIndex) {
928
+ push(depsMap.get("length"));
929
+ }
930
+ break;
931
+ case "delete":
932
+ if (!targetIsArray) {
933
+ push(depsMap.get(ITERATE_KEY));
934
+ if (isMap(target)) {
935
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
936
+ }
937
+ }
938
+ break;
939
+ case "set":
729
940
  if (isMap(target)) {
730
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
941
+ push(depsMap.get(ITERATE_KEY));
731
942
  }
732
- }
733
- break;
734
- case "set":
735
- if (isMap(target)) {
736
- deps.push(depsMap.get(ITERATE_KEY));
737
- }
738
- break;
943
+ break;
944
+ }
739
945
  }
740
946
  }
741
- pauseScheduling();
947
+ startBatch();
742
948
  for (const dep of deps) {
743
- if (dep) {
744
- triggerEffects(
745
- dep,
746
- 4,
747
- {
748
- target,
749
- type,
750
- key,
751
- newValue,
752
- oldValue,
753
- oldTarget
754
- }
755
- );
949
+ {
950
+ dep.trigger({
951
+ target,
952
+ type,
953
+ key,
954
+ newValue,
955
+ oldValue,
956
+ oldTarget
957
+ });
756
958
  }
757
959
  }
758
- resetScheduling();
960
+ endBatch();
759
961
  }
760
962
  function getDepFromReactive(object, key) {
761
- const depsMap = targetMap.get(object);
762
- return depsMap && depsMap.get(key);
963
+ var _a;
964
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
965
+ }
966
+
967
+ function reactiveReadArray(array) {
968
+ const raw = toRaw(array);
969
+ if (raw === array)
970
+ return raw;
971
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
972
+ return isShallow(array) ? raw : raw.map(toReactive);
973
+ }
974
+ function shallowReadArray(arr) {
975
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
976
+ return arr;
977
+ }
978
+ const arrayInstrumentations = {
979
+ __proto__: null,
980
+ [Symbol.iterator]() {
981
+ return iterator(this, Symbol.iterator, toReactive);
982
+ },
983
+ concat(...args) {
984
+ return reactiveReadArray(this).concat(
985
+ ...args.map((x) => reactiveReadArray(x))
986
+ );
987
+ },
988
+ entries() {
989
+ return iterator(this, "entries", (value) => {
990
+ value[1] = toReactive(value[1]);
991
+ return value;
992
+ });
993
+ },
994
+ every(fn, thisArg) {
995
+ return apply(this, "every", fn, thisArg);
996
+ },
997
+ filter(fn, thisArg) {
998
+ const result = apply(this, "filter", fn, thisArg);
999
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
1000
+ },
1001
+ find(fn, thisArg) {
1002
+ const result = apply(this, "find", fn, thisArg);
1003
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1004
+ },
1005
+ findIndex(fn, thisArg) {
1006
+ return apply(this, "findIndex", fn, thisArg);
1007
+ },
1008
+ findLast(fn, thisArg) {
1009
+ const result = apply(this, "findLast", fn, thisArg);
1010
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1011
+ },
1012
+ findLastIndex(fn, thisArg) {
1013
+ return apply(this, "findLastIndex", fn, thisArg);
1014
+ },
1015
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1016
+ forEach(fn, thisArg) {
1017
+ return apply(this, "forEach", fn, thisArg);
1018
+ },
1019
+ includes(...args) {
1020
+ return searchProxy(this, "includes", args);
1021
+ },
1022
+ indexOf(...args) {
1023
+ return searchProxy(this, "indexOf", args);
1024
+ },
1025
+ join(separator) {
1026
+ return reactiveReadArray(this).join(separator);
1027
+ },
1028
+ // keys() iterator only reads `length`, no optimisation required
1029
+ lastIndexOf(...args) {
1030
+ return searchProxy(this, "lastIndexOf", args);
1031
+ },
1032
+ map(fn, thisArg) {
1033
+ return apply(this, "map", fn, thisArg);
1034
+ },
1035
+ pop() {
1036
+ return noTracking(this, "pop");
1037
+ },
1038
+ push(...args) {
1039
+ return noTracking(this, "push", args);
1040
+ },
1041
+ reduce(fn, ...args) {
1042
+ return reduce(this, "reduce", fn, args);
1043
+ },
1044
+ reduceRight(fn, ...args) {
1045
+ return reduce(this, "reduceRight", fn, args);
1046
+ },
1047
+ shift() {
1048
+ return noTracking(this, "shift");
1049
+ },
1050
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1051
+ some(fn, thisArg) {
1052
+ return apply(this, "some", fn, thisArg);
1053
+ },
1054
+ splice(...args) {
1055
+ return noTracking(this, "splice", args);
1056
+ },
1057
+ toReversed() {
1058
+ return reactiveReadArray(this).toReversed();
1059
+ },
1060
+ toSorted(comparer) {
1061
+ return reactiveReadArray(this).toSorted(comparer);
1062
+ },
1063
+ toSpliced(...args) {
1064
+ return reactiveReadArray(this).toSpliced(...args);
1065
+ },
1066
+ unshift(...args) {
1067
+ return noTracking(this, "unshift", args);
1068
+ },
1069
+ values() {
1070
+ return iterator(this, "values", toReactive);
1071
+ }
1072
+ };
1073
+ function iterator(self, method, wrapValue) {
1074
+ const arr = shallowReadArray(self);
1075
+ const iter = arr[method]();
1076
+ if (arr !== self && !isShallow(self)) {
1077
+ iter._next = iter.next;
1078
+ iter.next = () => {
1079
+ const result = iter._next();
1080
+ if (result.value) {
1081
+ result.value = wrapValue(result.value);
1082
+ }
1083
+ return result;
1084
+ };
1085
+ }
1086
+ return iter;
1087
+ }
1088
+ function apply(self, method, fn, thisArg) {
1089
+ const arr = shallowReadArray(self);
1090
+ let wrappedFn = fn;
1091
+ if (arr !== self) {
1092
+ if (!isShallow(self)) {
1093
+ wrappedFn = function(item, index) {
1094
+ return fn.call(this, toReactive(item), index, self);
1095
+ };
1096
+ } else if (fn.length > 2) {
1097
+ wrappedFn = function(item, index) {
1098
+ return fn.call(this, item, index, self);
1099
+ };
1100
+ }
1101
+ }
1102
+ return arr[method](wrappedFn, thisArg);
1103
+ }
1104
+ function reduce(self, method, fn, args) {
1105
+ const arr = shallowReadArray(self);
1106
+ let wrappedFn = fn;
1107
+ if (arr !== self) {
1108
+ if (!isShallow(self)) {
1109
+ wrappedFn = function(acc, item, index) {
1110
+ return fn.call(this, acc, toReactive(item), index, self);
1111
+ };
1112
+ } else if (fn.length > 3) {
1113
+ wrappedFn = function(acc, item, index) {
1114
+ return fn.call(this, acc, item, index, self);
1115
+ };
1116
+ }
1117
+ }
1118
+ return arr[method](wrappedFn, ...args);
1119
+ }
1120
+ function searchProxy(self, method, args) {
1121
+ const arr = toRaw(self);
1122
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1123
+ const res = arr[method](...args);
1124
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1125
+ args[0] = toRaw(args[0]);
1126
+ return arr[method](...args);
1127
+ }
1128
+ return res;
1129
+ }
1130
+ function noTracking(self, method, args = []) {
1131
+ pauseTracking();
1132
+ startBatch();
1133
+ const res = toRaw(self)[method].apply(self, args);
1134
+ endBatch();
1135
+ resetTracking();
1136
+ return res;
763
1137
  }
764
1138
 
765
1139
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
766
1140
  const builtInSymbols = new Set(
767
1141
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
768
1142
  );
769
- const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
770
- function createArrayInstrumentations() {
771
- const instrumentations = {};
772
- ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
773
- instrumentations[key] = function(...args) {
774
- const arr = toRaw(this);
775
- for (let i = 0, l = this.length; i < l; i++) {
776
- track(arr, "get", i + "");
777
- }
778
- const res = arr[key](...args);
779
- if (res === -1 || res === false) {
780
- return arr[key](...args.map(toRaw));
781
- } else {
782
- return res;
783
- }
784
- };
785
- });
786
- ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
787
- instrumentations[key] = function(...args) {
788
- pauseTracking();
789
- pauseScheduling();
790
- const res = toRaw(this)[key].apply(this, args);
791
- resetScheduling();
792
- resetTracking();
793
- return res;
794
- };
795
- });
796
- return instrumentations;
797
- }
798
1143
  function hasOwnProperty(key) {
799
1144
  if (!isSymbol(key))
800
1145
  key = String(key);
@@ -825,14 +1170,22 @@ class BaseReactiveHandler {
825
1170
  }
826
1171
  const targetIsArray = isArray(target);
827
1172
  if (!isReadonly2) {
828
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
829
- return Reflect.get(arrayInstrumentations, key, receiver);
1173
+ let fn;
1174
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1175
+ return fn;
830
1176
  }
831
1177
  if (key === "hasOwnProperty") {
832
1178
  return hasOwnProperty;
833
1179
  }
834
1180
  }
835
- const res = Reflect.get(target, key, receiver);
1181
+ const res = Reflect.get(
1182
+ target,
1183
+ key,
1184
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1185
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1186
+ // its class methods
1187
+ isRef(target) ? target : receiver
1188
+ );
836
1189
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
837
1190
  return res;
838
1191
  }
@@ -1331,110 +1684,8 @@ function markRaw(value) {
1331
1684
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1332
1685
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1333
1686
 
1334
- 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`;
1335
- class ComputedRefImpl {
1336
- constructor(getter, _setter, isReadonly, isSSR) {
1337
- this.getter = getter;
1338
- this._setter = _setter;
1339
- this.dep = void 0;
1340
- this.__v_isRef = true;
1341
- this["__v_isReadonly"] = false;
1342
- this.effect = new ReactiveEffect(
1343
- () => getter(this._value),
1344
- () => triggerRefValue(
1345
- this,
1346
- this.effect._dirtyLevel === 2 ? 2 : 3
1347
- )
1348
- );
1349
- this.effect.computed = this;
1350
- this.effect.active = this._cacheable = !isSSR;
1351
- this["__v_isReadonly"] = isReadonly;
1352
- }
1353
- get value() {
1354
- const self = toRaw(this);
1355
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1356
- triggerRefValue(self, 4);
1357
- }
1358
- trackRefValue(self);
1359
- if (self.effect._dirtyLevel >= 2) {
1360
- if (this._warnRecursive) {
1361
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1362
-
1363
- getter: `, this.getter);
1364
- }
1365
- triggerRefValue(self, 2);
1366
- }
1367
- return self._value;
1368
- }
1369
- set value(newValue) {
1370
- this._setter(newValue);
1371
- }
1372
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1373
- get _dirty() {
1374
- return this.effect.dirty;
1375
- }
1376
- set _dirty(v) {
1377
- this.effect.dirty = v;
1378
- }
1379
- // #endregion
1380
- }
1381
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1382
- let getter;
1383
- let setter;
1384
- const onlyGetter = isFunction(getterOrOptions);
1385
- if (onlyGetter) {
1386
- getter = getterOrOptions;
1387
- setter = () => {
1388
- warn$2("Write operation failed: computed value is readonly");
1389
- } ;
1390
- } else {
1391
- getter = getterOrOptions.get;
1392
- setter = getterOrOptions.set;
1393
- }
1394
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1395
- if (debugOptions && !isSSR) {
1396
- cRef.effect.onTrack = debugOptions.onTrack;
1397
- cRef.effect.onTrigger = debugOptions.onTrigger;
1398
- }
1399
- return cRef;
1400
- }
1401
-
1402
- function trackRefValue(ref2) {
1403
- var _a;
1404
- if (shouldTrack && activeEffect) {
1405
- ref2 = toRaw(ref2);
1406
- trackEffect(
1407
- activeEffect,
1408
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1409
- () => ref2.dep = void 0,
1410
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1411
- ),
1412
- {
1413
- target: ref2,
1414
- type: "get",
1415
- key: "value"
1416
- }
1417
- );
1418
- }
1419
- }
1420
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1421
- ref2 = toRaw(ref2);
1422
- const dep = ref2.dep;
1423
- if (dep) {
1424
- triggerEffects(
1425
- dep,
1426
- dirtyLevel,
1427
- {
1428
- target: ref2,
1429
- type: "set",
1430
- key: "value",
1431
- newValue: newVal
1432
- }
1433
- );
1434
- }
1435
- }
1436
1687
  function isRef(r) {
1437
- return !!(r && r.__v_isRef === true);
1688
+ return r ? r.__v_isRef === true : false;
1438
1689
  }
1439
1690
  function ref(value) {
1440
1691
  return createRef(value, false);
@@ -1451,27 +1702,49 @@ function createRef(rawValue, shallow) {
1451
1702
  class RefImpl {
1452
1703
  constructor(value, __v_isShallow) {
1453
1704
  this.__v_isShallow = __v_isShallow;
1454
- this.dep = void 0;
1705
+ this.dep = new Dep();
1455
1706
  this.__v_isRef = true;
1456
1707
  this._rawValue = __v_isShallow ? value : toRaw(value);
1457
1708
  this._value = __v_isShallow ? value : toReactive(value);
1458
1709
  }
1459
1710
  get value() {
1460
- trackRefValue(this);
1711
+ {
1712
+ this.dep.track({
1713
+ target: this,
1714
+ type: "get",
1715
+ key: "value"
1716
+ });
1717
+ }
1461
1718
  return this._value;
1462
1719
  }
1463
- set value(newVal) {
1464
- const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
1465
- newVal = useDirectValue ? newVal : toRaw(newVal);
1466
- if (hasChanged(newVal, this._rawValue)) {
1467
- this._rawValue = newVal;
1468
- this._value = useDirectValue ? newVal : toReactive(newVal);
1469
- triggerRefValue(this, 4, newVal);
1720
+ set value(newValue) {
1721
+ const oldValue = this._rawValue;
1722
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1723
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1724
+ if (hasChanged(newValue, oldValue)) {
1725
+ this._rawValue = newValue;
1726
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1727
+ {
1728
+ this.dep.trigger({
1729
+ target: this,
1730
+ type: "set",
1731
+ key: "value",
1732
+ newValue,
1733
+ oldValue
1734
+ });
1735
+ }
1470
1736
  }
1471
1737
  }
1472
1738
  }
1473
1739
  function triggerRef(ref2) {
1474
- triggerRefValue(ref2, 4, ref2.value );
1740
+ {
1741
+ ref2.dep.trigger({
1742
+ target: ref2,
1743
+ type: "set",
1744
+ key: "value",
1745
+ newValue: ref2._value
1746
+ });
1747
+ }
1475
1748
  }
1476
1749
  function unref(ref2) {
1477
1750
  return isRef(ref2) ? ref2.value : ref2;
@@ -1496,12 +1769,9 @@ function proxyRefs(objectWithRefs) {
1496
1769
  }
1497
1770
  class CustomRefImpl {
1498
1771
  constructor(factory) {
1499
- this.dep = void 0;
1500
1772
  this.__v_isRef = true;
1501
- const { get, set } = factory(
1502
- () => trackRefValue(this),
1503
- () => triggerRefValue(this)
1504
- );
1773
+ const dep = this.dep = new Dep();
1774
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1505
1775
  this._get = get;
1506
1776
  this._set = set;
1507
1777
  }
@@ -1569,6 +1839,90 @@ function propertyToRef(source, key, defaultValue) {
1569
1839
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1570
1840
  }
1571
1841
 
1842
+ class ComputedRefImpl {
1843
+ constructor(fn, setter, isSSR) {
1844
+ this.fn = fn;
1845
+ this.setter = setter;
1846
+ /**
1847
+ * @internal
1848
+ */
1849
+ this._value = void 0;
1850
+ /**
1851
+ * @internal
1852
+ */
1853
+ this.dep = new Dep(this);
1854
+ /**
1855
+ * @internal
1856
+ */
1857
+ this.__v_isRef = true;
1858
+ // A computed is also a subscriber that tracks other deps
1859
+ /**
1860
+ * @internal
1861
+ */
1862
+ this.deps = void 0;
1863
+ /**
1864
+ * @internal
1865
+ */
1866
+ this.depsTail = void 0;
1867
+ /**
1868
+ * @internal
1869
+ */
1870
+ this.flags = 16;
1871
+ /**
1872
+ * @internal
1873
+ */
1874
+ this.globalVersion = globalVersion - 1;
1875
+ // for backwards compat
1876
+ this.effect = this;
1877
+ this.__v_isReadonly = !setter;
1878
+ this.isSSR = isSSR;
1879
+ }
1880
+ /**
1881
+ * @internal
1882
+ */
1883
+ notify() {
1884
+ if (activeSub !== this) {
1885
+ this.flags |= 16;
1886
+ this.dep.notify();
1887
+ }
1888
+ }
1889
+ get value() {
1890
+ const link = this.dep.track({
1891
+ target: this,
1892
+ type: "get",
1893
+ key: "value"
1894
+ }) ;
1895
+ refreshComputed(this);
1896
+ if (link) {
1897
+ link.version = this.dep.version;
1898
+ }
1899
+ return this._value;
1900
+ }
1901
+ set value(newValue) {
1902
+ if (this.setter) {
1903
+ this.setter(newValue);
1904
+ } else {
1905
+ warn$2("Write operation failed: computed value is readonly");
1906
+ }
1907
+ }
1908
+ }
1909
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1910
+ let getter;
1911
+ let setter;
1912
+ if (isFunction(getterOrOptions)) {
1913
+ getter = getterOrOptions;
1914
+ } else {
1915
+ getter = getterOrOptions.get;
1916
+ setter = getterOrOptions.set;
1917
+ }
1918
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1919
+ if (debugOptions && !isSSR) {
1920
+ cRef.onTrack = debugOptions.onTrack;
1921
+ cRef.onTrigger = debugOptions.onTrigger;
1922
+ }
1923
+ return cRef;
1924
+ }
1925
+
1572
1926
  const TrackOpTypes = {
1573
1927
  "GET": "get",
1574
1928
  "HAS": "has",
@@ -1861,7 +2215,7 @@ function findInsertionIndex(id) {
1861
2215
  const middle = start + end >>> 1;
1862
2216
  const middleJob = queue[middle];
1863
2217
  const middleJobId = getId(middleJob);
1864
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2218
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1865
2219
  start = middle + 1;
1866
2220
  } else {
1867
2221
  end = middle;
@@ -1870,15 +2224,21 @@ function findInsertionIndex(id) {
1870
2224
  return start;
1871
2225
  }
1872
2226
  function queueJob(job) {
1873
- if (!queue.length || !queue.includes(
1874
- job,
1875
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1876
- )) {
2227
+ var _a;
2228
+ if (!(job.flags & 1)) {
1877
2229
  if (job.id == null) {
1878
2230
  queue.push(job);
2231
+ } else if (
2232
+ // fast path when the job id is larger than the tail
2233
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2234
+ ) {
2235
+ queue.push(job);
1879
2236
  } else {
1880
2237
  queue.splice(findInsertionIndex(job.id), 0, job);
1881
2238
  }
2239
+ if (!(job.flags & 4)) {
2240
+ job.flags |= 1;
2241
+ }
1882
2242
  queueFlush();
1883
2243
  }
1884
2244
  }
@@ -1896,11 +2256,11 @@ function invalidateJob(job) {
1896
2256
  }
1897
2257
  function queuePostFlushCb(cb) {
1898
2258
  if (!isArray(cb)) {
1899
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1900
- cb,
1901
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1902
- )) {
2259
+ if (!(cb.flags & 1)) {
1903
2260
  pendingPostFlushCbs.push(cb);
2261
+ if (!(cb.flags & 4)) {
2262
+ cb.flags |= 1;
2263
+ }
1904
2264
  }
1905
2265
  } else {
1906
2266
  pendingPostFlushCbs.push(...cb);
@@ -1913,7 +2273,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1913
2273
  }
1914
2274
  for (; i < queue.length; i++) {
1915
2275
  const cb = queue[i];
1916
- if (cb && cb.pre) {
2276
+ if (cb && cb.flags & 2) {
1917
2277
  if (instance && cb.id !== instance.uid) {
1918
2278
  continue;
1919
2279
  }
@@ -1923,6 +2283,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1923
2283
  queue.splice(i, 1);
1924
2284
  i--;
1925
2285
  cb();
2286
+ cb.flags &= ~1;
1926
2287
  }
1927
2288
  }
1928
2289
  }
@@ -1945,6 +2306,7 @@ function flushPostFlushCbs(seen) {
1945
2306
  continue;
1946
2307
  }
1947
2308
  activePostFlushCbs[postFlushIndex]();
2309
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1948
2310
  }
1949
2311
  activePostFlushCbs = null;
1950
2312
  postFlushIndex = 0;
@@ -1954,9 +2316,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
1954
2316
  const comparator = (a, b) => {
1955
2317
  const diff = getId(a) - getId(b);
1956
2318
  if (diff === 0) {
1957
- if (a.pre && !b.pre)
2319
+ const isAPre = a.flags & 2;
2320
+ const isBPre = b.flags & 2;
2321
+ if (isAPre && !isBPre)
1958
2322
  return -1;
1959
- if (b.pre && !a.pre)
2323
+ if (isBPre && !isAPre)
1960
2324
  return 1;
1961
2325
  }
1962
2326
  return diff;
@@ -1972,11 +2336,12 @@ function flushJobs(seen) {
1972
2336
  try {
1973
2337
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1974
2338
  const job = queue[flushIndex];
1975
- if (job && job.active !== false) {
2339
+ if (job && !(job.flags & 8)) {
1976
2340
  if (check(job)) {
1977
2341
  continue;
1978
2342
  }
1979
2343
  callWithErrorHandling(job, null, 14);
2344
+ job.flags &= ~1;
1980
2345
  }
1981
2346
  }
1982
2347
  } finally {
@@ -2058,7 +2423,6 @@ function rerender(id, newRender) {
2058
2423
  }
2059
2424
  instance.renderCache = [];
2060
2425
  isHmrUpdating = true;
2061
- instance.effect.dirty = true;
2062
2426
  instance.update();
2063
2427
  isHmrUpdating = false;
2064
2428
  });
@@ -2086,7 +2450,6 @@ function reload(id, newComp) {
2086
2450
  instance.ceReload(newComp.styles);
2087
2451
  hmrDirtyComponents.delete(oldComp);
2088
2452
  } else if (instance.parent) {
2089
- instance.parent.effect.dirty = true;
2090
2453
  queueJob(instance.parent.update);
2091
2454
  } else if (instance.appContext.reload) {
2092
2455
  instance.appContext.reload();
@@ -2971,7 +3334,7 @@ function renderComponentRoot(instance) {
2971
3334
  true ? {
2972
3335
  get attrs() {
2973
3336
  markAttrsAccessed();
2974
- return shallowReadonly(attrs);
3337
+ return attrs;
2975
3338
  },
2976
3339
  slots,
2977
3340
  emit
@@ -3004,7 +3367,7 @@ function renderComponentRoot(instance) {
3004
3367
  propsOptions
3005
3368
  );
3006
3369
  }
3007
- root = cloneVNode(root, fallthroughAttrs, false, true);
3370
+ root = cloneVNode(root, fallthroughAttrs);
3008
3371
  } else if (!accessedAttrs && root.type !== Comment) {
3009
3372
  const allAttrs = Object.keys(attrs);
3010
3373
  const eventAttrs = [];
@@ -3042,15 +3405,10 @@ function renderComponentRoot(instance) {
3042
3405
  getComponentName(instance.type)
3043
3406
  );
3044
3407
  }
3045
- root = cloneVNode(
3046
- root,
3047
- {
3048
- class: cls,
3049
- style
3050
- },
3051
- false,
3052
- true
3053
- );
3408
+ root = cloneVNode(root, {
3409
+ class: cls,
3410
+ style
3411
+ });
3054
3412
  }
3055
3413
  }
3056
3414
  if (vnode.dirs) {
@@ -3059,7 +3417,7 @@ function renderComponentRoot(instance) {
3059
3417
  `Runtime directive used on component with non-element root node. The directives will not function as intended.`
3060
3418
  );
3061
3419
  }
3062
- root = cloneVNode(root, null, false, true);
3420
+ root = cloneVNode(root);
3063
3421
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3064
3422
  }
3065
3423
  if (vnode.transition) {
@@ -3554,7 +3912,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3554
3912
  let parentSuspenseId;
3555
3913
  const isSuspensible = isVNodeSuspensible(vnode);
3556
3914
  if (isSuspensible) {
3557
- if (parentSuspense && parentSuspense.pendingBranch) {
3915
+ if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
3558
3916
  parentSuspenseId = parentSuspense.pendingId;
3559
3917
  parentSuspense.deps++;
3560
3918
  }
@@ -3866,8 +4224,8 @@ function setActiveBranch(suspense, branch) {
3866
4224
  }
3867
4225
  }
3868
4226
  function isVNodeSuspensible(vnode) {
3869
- const suspensible = vnode.props && vnode.props.suspensible;
3870
- return suspensible != null && suspensible !== false;
4227
+ var _a;
4228
+ return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
3871
4229
  }
3872
4230
 
3873
4231
  const legacyDirectiveHookMap = {
@@ -4061,8 +4419,8 @@ function doWatch(source, cb, {
4061
4419
  };
4062
4420
  };
4063
4421
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4064
- const job = () => {
4065
- if (!effect.active || !effect.dirty) {
4422
+ const job = (immediateFirstRun) => {
4423
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4066
4424
  return;
4067
4425
  }
4068
4426
  if (cb) {
@@ -4083,19 +4441,22 @@ function doWatch(source, cb, {
4083
4441
  effect.run();
4084
4442
  }
4085
4443
  };
4086
- job.allowRecurse = !!cb;
4444
+ if (cb)
4445
+ job.flags |= 4;
4446
+ const effect = new ReactiveEffect(getter);
4087
4447
  let scheduler;
4088
4448
  if (flush === "sync") {
4449
+ effect.flags |= 64;
4089
4450
  scheduler = job;
4090
4451
  } else if (flush === "post") {
4091
4452
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4092
4453
  } else {
4093
- job.pre = true;
4454
+ job.flags |= 2;
4094
4455
  if (instance)
4095
4456
  job.id = instance.uid;
4096
4457
  scheduler = () => queueJob(job);
4097
4458
  }
4098
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4459
+ effect.scheduler = scheduler;
4099
4460
  const scope = getCurrentScope();
4100
4461
  const unwatch = () => {
4101
4462
  effect.stop();
@@ -4109,7 +4470,7 @@ function doWatch(source, cb, {
4109
4470
  }
4110
4471
  if (cb) {
4111
4472
  if (immediate) {
4112
- job();
4473
+ job(true);
4113
4474
  } else {
4114
4475
  oldValue = effect.run();
4115
4476
  }
@@ -4148,29 +4509,34 @@ function createPathGetter(ctx, path) {
4148
4509
  return cur;
4149
4510
  };
4150
4511
  }
4151
- function traverse(value, depth = Infinity, seen) {
4152
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
4512
+ function traverse(value, depth, currentDepth = 0, seen) {
4513
+ if (!isObject(value) || value["__v_skip"]) {
4153
4514
  return value;
4154
4515
  }
4516
+ if (depth && depth > 0) {
4517
+ if (currentDepth >= depth) {
4518
+ return value;
4519
+ }
4520
+ currentDepth++;
4521
+ }
4155
4522
  seen = seen || /* @__PURE__ */ new Set();
4156
4523
  if (seen.has(value)) {
4157
4524
  return value;
4158
4525
  }
4159
4526
  seen.add(value);
4160
- depth--;
4161
4527
  if (isRef(value)) {
4162
- traverse(value.value, depth, seen);
4528
+ traverse(value.value, depth, currentDepth, seen);
4163
4529
  } else if (isArray(value)) {
4164
4530
  for (let i = 0; i < value.length; i++) {
4165
- traverse(value[i], depth, seen);
4531
+ traverse(value[i], depth, currentDepth, seen);
4166
4532
  }
4167
4533
  } else if (isSet(value) || isMap(value)) {
4168
4534
  value.forEach((v) => {
4169
- traverse(v, depth, seen);
4535
+ traverse(v, depth, currentDepth, seen);
4170
4536
  });
4171
4537
  } else if (isPlainObject(value)) {
4172
4538
  for (const key in value) {
4173
- traverse(value[key], depth, seen);
4539
+ traverse(value[key], depth, currentDepth, seen);
4174
4540
  }
4175
4541
  }
4176
4542
  return value;
@@ -4286,22 +4652,7 @@ const BaseTransitionImpl = {
4286
4652
  if (!children || !children.length) {
4287
4653
  return;
4288
4654
  }
4289
- let child = children[0];
4290
- if (children.length > 1) {
4291
- let hasFound = false;
4292
- for (const c of children) {
4293
- if (c.type !== Comment) {
4294
- if (hasFound) {
4295
- warn$1(
4296
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4297
- );
4298
- break;
4299
- }
4300
- child = c;
4301
- hasFound = true;
4302
- }
4303
- }
4304
- }
4655
+ const child = findNonCommentChild(children);
4305
4656
  const rawProps = toRaw(props);
4306
4657
  const { mode } = rawProps;
4307
4658
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4310,7 +4661,7 @@ const BaseTransitionImpl = {
4310
4661
  if (state.isLeaving) {
4311
4662
  return emptyPlaceholder(child);
4312
4663
  }
4313
- const innerChild = getKeepAliveChild(child);
4664
+ const innerChild = getInnerChild$1(child);
4314
4665
  if (!innerChild) {
4315
4666
  return emptyPlaceholder(child);
4316
4667
  }
@@ -4322,7 +4673,7 @@ const BaseTransitionImpl = {
4322
4673
  );
4323
4674
  setTransitionHooks(innerChild, enterHooks);
4324
4675
  const oldChild = instance.subTree;
4325
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4676
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4326
4677
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4327
4678
  const leavingHooks = resolveTransitionHooks(
4328
4679
  oldInnerChild,
@@ -4331,12 +4682,11 @@ const BaseTransitionImpl = {
4331
4682
  instance
4332
4683
  );
4333
4684
  setTransitionHooks(oldInnerChild, leavingHooks);
4334
- if (mode === "out-in" && innerChild.type !== Comment) {
4685
+ if (mode === "out-in") {
4335
4686
  state.isLeaving = true;
4336
4687
  leavingHooks.afterLeave = () => {
4337
4688
  state.isLeaving = false;
4338
- if (instance.update.active !== false) {
4339
- instance.effect.dirty = true;
4689
+ if (!(instance.job.flags & 8)) {
4340
4690
  instance.update();
4341
4691
  }
4342
4692
  };
@@ -4364,6 +4714,25 @@ const BaseTransitionImpl = {
4364
4714
  {
4365
4715
  BaseTransitionImpl.__isBuiltIn = true;
4366
4716
  }
4717
+ function findNonCommentChild(children) {
4718
+ let child = children[0];
4719
+ if (children.length > 1) {
4720
+ let hasFound = false;
4721
+ for (const c of children) {
4722
+ if (c.type !== Comment) {
4723
+ if (hasFound) {
4724
+ warn$1(
4725
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4726
+ );
4727
+ break;
4728
+ }
4729
+ child = c;
4730
+ hasFound = true;
4731
+ }
4732
+ }
4733
+ }
4734
+ return child;
4735
+ }
4367
4736
  const BaseTransition = BaseTransitionImpl;
4368
4737
  function getLeavingNodesForType(state, vnode) {
4369
4738
  const { leavingVNodes } = state;
@@ -4518,8 +4887,11 @@ function emptyPlaceholder(vnode) {
4518
4887
  return vnode;
4519
4888
  }
4520
4889
  }
4521
- function getKeepAliveChild(vnode) {
4890
+ function getInnerChild$1(vnode) {
4522
4891
  if (!isKeepAlive(vnode)) {
4892
+ if (isTeleport(vnode.type) && vnode.children) {
4893
+ return findNonCommentChild(vnode.children);
4894
+ }
4523
4895
  return vnode;
4524
4896
  }
4525
4897
  if (vnode.component) {
@@ -4688,7 +5060,6 @@ function defineAsyncComponent(source) {
4688
5060
  load().then(() => {
4689
5061
  loaded.value = true;
4690
5062
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4691
- instance.parent.effect.dirty = true;
4692
5063
  queueJob(instance.parent.update);
4693
5064
  }
4694
5065
  }).catch((err) => {
@@ -4849,7 +5220,7 @@ const KeepAliveImpl = {
4849
5220
  return () => {
4850
5221
  pendingCacheKey = null;
4851
5222
  if (!slots.default) {
4852
- return null;
5223
+ return current = null;
4853
5224
  }
4854
5225
  const children = slots.default();
4855
5226
  const rawVNode = children[0];
@@ -5300,10 +5671,20 @@ function convertLegacyFunctionalComponent(comp) {
5300
5671
  function renderList(source, renderItem, cache, index) {
5301
5672
  let ret;
5302
5673
  const cached = cache && cache[index];
5303
- if (isArray(source) || isString(source)) {
5674
+ const sourceIsArray = isArray(source);
5675
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5676
+ if (sourceIsArray || isString(source)) {
5677
+ if (sourceIsReactiveArray) {
5678
+ source = shallowReadArray(source);
5679
+ }
5304
5680
  ret = new Array(source.length);
5305
5681
  for (let i = 0, l = source.length; i < l; i++) {
5306
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5682
+ ret[i] = renderItem(
5683
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5684
+ i,
5685
+ void 0,
5686
+ cached && cached[i]
5687
+ );
5307
5688
  }
5308
5689
  } else if (typeof source === "number") {
5309
5690
  if (!Number.isInteger(source)) {
@@ -5674,7 +6055,6 @@ const publicPropertiesMap = (
5674
6055
  $emit: (i) => i.emit,
5675
6056
  $options: (i) => resolveMergedOptions(i) ,
5676
6057
  $forceUpdate: (i) => i.f || (i.f = () => {
5677
- i.effect.dirty = true;
5678
6058
  queueJob(i.update);
5679
6059
  }),
5680
6060
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6545,13 +6925,13 @@ function createCompatVue$1(createApp, createSingletonApp) {
6545
6925
  return vm;
6546
6926
  }
6547
6927
  }
6548
- Vue.version = `2.6.14-compat:${"3.4.26"}`;
6928
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6549
6929
  Vue.config = singletonApp.config;
6550
- Vue.use = (plugin, ...options) => {
6551
- if (plugin && isFunction(plugin.install)) {
6552
- plugin.install(Vue, ...options);
6553
- } else if (isFunction(plugin)) {
6554
- plugin(Vue, ...options);
6930
+ Vue.use = (p, ...options) => {
6931
+ if (p && isFunction(p.install)) {
6932
+ p.install(Vue, ...options);
6933
+ } else if (isFunction(p)) {
6934
+ p(Vue, ...options);
6555
6935
  }
6556
6936
  return Vue;
6557
6937
  };
@@ -7563,7 +7943,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7563
7943
  function assertType(value, type) {
7564
7944
  let valid;
7565
7945
  const expectedType = getType(type);
7566
- if (isSimpleType(expectedType)) {
7946
+ if (expectedType === "null") {
7947
+ valid = value === null;
7948
+ } else if (isSimpleType(expectedType)) {
7567
7949
  const t = typeof value;
7568
7950
  valid = t === expectedType.toLowerCase();
7569
7951
  if (!valid && t === "object") {
@@ -7573,8 +7955,6 @@ function assertType(value, type) {
7573
7955
  valid = isObject(value);
7574
7956
  } else if (expectedType === "Array") {
7575
7957
  valid = isArray(value);
7576
- } else if (expectedType === "null") {
7577
- valid = value === null;
7578
7958
  } else {
7579
7959
  valid = value instanceof type;
7580
7960
  }
@@ -7669,7 +8049,7 @@ const initSlots = (instance, children) => {
7669
8049
  const type = children._;
7670
8050
  if (type) {
7671
8051
  extend(slots, children);
7672
- def(slots, "_", type, true);
8052
+ def(slots, "_", type);
7673
8053
  } else {
7674
8054
  normalizeObjectSlots(children, slots, instance);
7675
8055
  }
@@ -9099,7 +9479,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9099
9479
  } else {
9100
9480
  instance.next = n2;
9101
9481
  invalidateJob(instance.update);
9102
- instance.effect.dirty = true;
9103
9482
  instance.update();
9104
9483
  }
9105
9484
  } else {
@@ -9306,24 +9685,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9306
9685
  }
9307
9686
  }
9308
9687
  };
9309
- const effect = instance.effect = new ReactiveEffect(
9310
- componentUpdateFn,
9311
- NOOP,
9312
- () => queueJob(update),
9313
- instance.scope
9314
- // track it in component's effect scope
9315
- );
9316
- const update = instance.update = () => {
9317
- if (effect.dirty) {
9318
- effect.run();
9319
- }
9320
- };
9321
- update.id = instance.uid;
9688
+ instance.scope.on();
9689
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9690
+ instance.scope.off();
9691
+ const update = instance.update = effect.run.bind(effect);
9692
+ const job = instance.job = effect.runIfDirty.bind(effect);
9693
+ job.id = instance.uid;
9694
+ effect.scheduler = () => queueJob(job);
9322
9695
  toggleRecurse(instance, true);
9323
9696
  {
9324
9697
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9325
9698
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9326
- update.ownerInstance = instance;
9699
+ job.ownerInstance = instance;
9327
9700
  }
9328
9701
  update();
9329
9702
  };
@@ -9790,7 +10163,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9790
10163
  if (instance.type.__hmrId) {
9791
10164
  unregisterHMR(instance);
9792
10165
  }
9793
- const { bum, scope, update, subTree, um } = instance;
10166
+ const { bum, scope, job, subTree, um } = instance;
9794
10167
  if (bum) {
9795
10168
  invokeArrayFns(bum);
9796
10169
  }
@@ -9798,8 +10171,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9798
10171
  instance.emit("hook:beforeDestroy");
9799
10172
  }
9800
10173
  scope.stop();
9801
- if (update) {
9802
- update.active = false;
10174
+ if (job) {
10175
+ job.flags |= 8;
9803
10176
  unmount(subTree, instance, parentSuspense, doRemove);
9804
10177
  }
9805
10178
  if (um) {
@@ -9891,8 +10264,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9891
10264
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9892
10265
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9893
10266
  }
9894
- function toggleRecurse({ effect, update }, allowed) {
9895
- effect.allowRecurse = update.allowRecurse = allowed;
10267
+ function toggleRecurse({ effect, job }, allowed) {
10268
+ if (allowed) {
10269
+ effect.flags |= 32;
10270
+ job.flags |= 4;
10271
+ } else {
10272
+ effect.flags &= ~32;
10273
+ job.flags &= ~4;
10274
+ }
9896
10275
  }
9897
10276
  function needTransition(parentSuspense, transition) {
9898
10277
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10508,8 +10887,8 @@ function guardReactiveProps(props) {
10508
10887
  return null;
10509
10888
  return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
10510
10889
  }
10511
- function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
10512
- const { props, ref, patchFlag, children, transition } = vnode;
10890
+ function cloneVNode(vnode, extraProps, mergeRef = false) {
10891
+ const { props, ref, patchFlag, children } = vnode;
10513
10892
  const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
10514
10893
  const cloned = {
10515
10894
  __v_isVNode: true,
@@ -10539,7 +10918,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
10539
10918
  dynamicChildren: vnode.dynamicChildren,
10540
10919
  appContext: vnode.appContext,
10541
10920
  dirs: vnode.dirs,
10542
- transition,
10921
+ transition: vnode.transition,
10543
10922
  // These should technically only be non-null on mounted VNodes. However,
10544
10923
  // they *should* be copied for kept-alive vnodes. So we just always copy
10545
10924
  // them since them being non-null during a mount doesn't affect the logic as
@@ -10553,9 +10932,6 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
10553
10932
  ctx: vnode.ctx,
10554
10933
  ce: vnode.ce
10555
10934
  };
10556
- if (transition && cloneTransition) {
10557
- cloned.transition = transition.clone(cloned);
10558
- }
10559
10935
  {
10560
10936
  defineLegacyVNodeProperties(cloned);
10561
10937
  }
@@ -10693,6 +11069,7 @@ function createComponentInstance(vnode, parent, suspense) {
10693
11069
  effect: null,
10694
11070
  update: null,
10695
11071
  // will be set synchronously right after creation
11072
+ job: null,
10696
11073
  scope: new EffectScope(
10697
11074
  true
10698
11075
  /* detached */
@@ -11198,7 +11575,8 @@ function initCustomFormatter() {
11198
11575
  {},
11199
11576
  ["span", vueStyle, genRefFlag(obj)],
11200
11577
  "<",
11201
- formatValue(obj.value),
11578
+ // avoid debugger accessing value affecting behavior
11579
+ formatValue("_value" in obj ? obj._value : obj),
11202
11580
  `>`
11203
11581
  ];
11204
11582
  } else if (isReactive(obj)) {
@@ -11378,7 +11756,7 @@ function isMemoSame(cached, memo) {
11378
11756
  return true;
11379
11757
  }
11380
11758
 
11381
- const version = "3.4.26";
11759
+ const version = "3.5.0-alpha.1";
11382
11760
  const warn = warn$1 ;
11383
11761
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11384
11762
  const devtools = devtools$1 ;
@@ -12945,7 +13323,9 @@ const withKeys = (fn, modifiers) => {
12945
13323
  return;
12946
13324
  }
12947
13325
  const eventKey = hyphenate(event.key);
12948
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13326
+ if (modifiers.some(
13327
+ (k) => k === eventKey || keyNames[k] === eventKey
13328
+ )) {
12949
13329
  return fn(event);
12950
13330
  }
12951
13331
  {
@@ -14804,10 +15184,11 @@ const tokenizer = new Tokenizer(stack, {
14804
15184
  }
14805
15185
  },
14806
15186
  onselfclosingtag(end) {
15187
+ var _a;
14807
15188
  const name = currentOpenTag.tag;
14808
15189
  currentOpenTag.isSelfClosing = true;
14809
15190
  endOpenTag(end);
14810
- if (stack[0] && stack[0].tag === name) {
15191
+ if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
14811
15192
  onCloseTag(stack.shift(), end);
14812
15193
  }
14813
15194
  },
@@ -15118,15 +15499,16 @@ function endOpenTag(end) {
15118
15499
  currentOpenTag = null;
15119
15500
  }
15120
15501
  function onText(content, start, end) {
15502
+ var _a;
15121
15503
  {
15122
- const tag = stack[0] && stack[0].tag;
15504
+ const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
15123
15505
  if (tag !== "script" && tag !== "style" && content.includes("&")) {
15124
15506
  content = currentOptions.decodeEntities(content, false);
15125
15507
  }
15126
15508
  }
15127
15509
  const parent = stack[0] || currentRoot;
15128
15510
  const lastNode = parent.children[parent.children.length - 1];
15129
- if (lastNode && lastNode.type === 2) {
15511
+ if ((lastNode == null ? void 0 : lastNode.type) === 2) {
15130
15512
  lastNode.content += content;
15131
15513
  setLocEnd(lastNode.loc, end);
15132
15514
  } else {
@@ -15260,10 +15642,11 @@ function isFragmentTemplate({ tag, props }) {
15260
15642
  return false;
15261
15643
  }
15262
15644
  function isComponent({ tag, props }) {
15645
+ var _a;
15263
15646
  if (currentOptions.isCustomElement(tag)) {
15264
15647
  return false;
15265
15648
  }
15266
- if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
15649
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
15267
15650
  return true;
15268
15651
  }
15269
15652
  for (let i = 0; i < props.length; i++) {
@@ -15296,6 +15679,7 @@ function isUpperCase(c) {
15296
15679
  }
15297
15680
  const windowsNewlineRE = /\r\n/g;
15298
15681
  function condenseWhitespace(nodes, tag) {
15682
+ var _a, _b;
15299
15683
  const shouldCondense = currentOptions.whitespace !== "preserve";
15300
15684
  let removedWhitespace = false;
15301
15685
  for (let i = 0; i < nodes.length; i++) {
@@ -15303,8 +15687,8 @@ function condenseWhitespace(nodes, tag) {
15303
15687
  if (node.type === 2) {
15304
15688
  if (!inPre) {
15305
15689
  if (isAllWhitespace(node.content)) {
15306
- const prev = nodes[i - 1] && nodes[i - 1].type;
15307
- const next = nodes[i + 1] && nodes[i + 1].type;
15690
+ const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
15691
+ const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
15308
15692
  if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
15309
15693
  removedWhitespace = true;
15310
15694
  nodes[i] = null;
@@ -15442,7 +15826,7 @@ function baseParse(input, options) {
15442
15826
  }
15443
15827
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
15444
15828
  tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
15445
- const delimiters = options && options.delimiters;
15829
+ const delimiters = options == null ? void 0 : options.delimiters;
15446
15830
  if (delimiters) {
15447
15831
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
15448
15832
  tokenizer.delimiterClose = toCharCodes(delimiters[1]);
@@ -18922,9 +19306,183 @@ const ignoreSideEffectTags = (node, context) => {
18922
19306
  }
18923
19307
  };
18924
19308
 
19309
+ function isValidHTMLNesting(parent, child) {
19310
+ if (parent in onlyValidChildren) {
19311
+ return onlyValidChildren[parent].has(child);
19312
+ }
19313
+ if (child in onlyValidParents) {
19314
+ return onlyValidParents[child].has(parent);
19315
+ }
19316
+ if (parent in knownInvalidChildren) {
19317
+ if (knownInvalidChildren[parent].has(child))
19318
+ return false;
19319
+ }
19320
+ if (child in knownInvalidParents) {
19321
+ if (knownInvalidParents[child].has(parent))
19322
+ return false;
19323
+ }
19324
+ return true;
19325
+ }
19326
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
19327
+ const emptySet = /* @__PURE__ */ new Set([]);
19328
+ const onlyValidChildren = {
19329
+ head: /* @__PURE__ */ new Set([
19330
+ "base",
19331
+ "basefront",
19332
+ "bgsound",
19333
+ "link",
19334
+ "meta",
19335
+ "title",
19336
+ "noscript",
19337
+ "noframes",
19338
+ "style",
19339
+ "script",
19340
+ "template"
19341
+ ]),
19342
+ optgroup: /* @__PURE__ */ new Set(["option"]),
19343
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
19344
+ // table
19345
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
19346
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
19347
+ colgroup: /* @__PURE__ */ new Set(["col"]),
19348
+ tbody: /* @__PURE__ */ new Set(["tr"]),
19349
+ thead: /* @__PURE__ */ new Set(["tr"]),
19350
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
19351
+ // these elements can not have any children elements
19352
+ script: emptySet,
19353
+ iframe: emptySet,
19354
+ option: emptySet,
19355
+ textarea: emptySet,
19356
+ style: emptySet,
19357
+ title: emptySet
19358
+ };
19359
+ const onlyValidParents = {
19360
+ // sections
19361
+ html: emptySet,
19362
+ body: /* @__PURE__ */ new Set(["html"]),
19363
+ head: /* @__PURE__ */ new Set(["html"]),
19364
+ // table
19365
+ td: /* @__PURE__ */ new Set(["tr"]),
19366
+ colgroup: /* @__PURE__ */ new Set(["table"]),
19367
+ caption: /* @__PURE__ */ new Set(["table"]),
19368
+ tbody: /* @__PURE__ */ new Set(["table"]),
19369
+ tfoot: /* @__PURE__ */ new Set(["table"]),
19370
+ col: /* @__PURE__ */ new Set(["colgroup"]),
19371
+ th: /* @__PURE__ */ new Set(["tr"]),
19372
+ thead: /* @__PURE__ */ new Set(["table"]),
19373
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
19374
+ // data list
19375
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
19376
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
19377
+ // other
19378
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
19379
+ // li: new Set(["ul", "ol"]),
19380
+ summary: /* @__PURE__ */ new Set(["details"]),
19381
+ area: /* @__PURE__ */ new Set(["map"])
19382
+ };
19383
+ const knownInvalidChildren = {
19384
+ p: /* @__PURE__ */ new Set([
19385
+ "address",
19386
+ "article",
19387
+ "aside",
19388
+ "blockquote",
19389
+ "center",
19390
+ "details",
19391
+ "dialog",
19392
+ "dir",
19393
+ "div",
19394
+ "dl",
19395
+ "fieldset",
19396
+ "figure",
19397
+ "footer",
19398
+ "form",
19399
+ "h1",
19400
+ "h2",
19401
+ "h3",
19402
+ "h4",
19403
+ "h5",
19404
+ "h6",
19405
+ "header",
19406
+ "hgroup",
19407
+ "hr",
19408
+ "li",
19409
+ "main",
19410
+ "nav",
19411
+ "menu",
19412
+ "ol",
19413
+ "p",
19414
+ "pre",
19415
+ "section",
19416
+ "table",
19417
+ "ul"
19418
+ ]),
19419
+ svg: /* @__PURE__ */ new Set([
19420
+ "b",
19421
+ "blockquote",
19422
+ "br",
19423
+ "code",
19424
+ "dd",
19425
+ "div",
19426
+ "dl",
19427
+ "dt",
19428
+ "em",
19429
+ "embed",
19430
+ "h1",
19431
+ "h2",
19432
+ "h3",
19433
+ "h4",
19434
+ "h5",
19435
+ "h6",
19436
+ "hr",
19437
+ "i",
19438
+ "img",
19439
+ "li",
19440
+ "menu",
19441
+ "meta",
19442
+ "ol",
19443
+ "p",
19444
+ "pre",
19445
+ "ruby",
19446
+ "s",
19447
+ "small",
19448
+ "span",
19449
+ "strong",
19450
+ "sub",
19451
+ "sup",
19452
+ "table",
19453
+ "u",
19454
+ "ul",
19455
+ "var"
19456
+ ])
19457
+ };
19458
+ const knownInvalidParents = {
19459
+ a: /* @__PURE__ */ new Set(["a"]),
19460
+ button: /* @__PURE__ */ new Set(["button"]),
19461
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
19462
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
19463
+ form: /* @__PURE__ */ new Set(["form"]),
19464
+ li: /* @__PURE__ */ new Set(["li"]),
19465
+ h1: headings,
19466
+ h2: headings,
19467
+ h3: headings,
19468
+ h4: headings,
19469
+ h5: headings,
19470
+ h6: headings
19471
+ };
19472
+
19473
+ const validateHtmlNesting = (node, context) => {
19474
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
19475
+ const error = new SyntaxError(
19476
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
19477
+ );
19478
+ error.loc = node.loc;
19479
+ context.onWarn(error);
19480
+ }
19481
+ };
19482
+
18925
19483
  const DOMNodeTransforms = [
18926
19484
  transformStyle,
18927
- ...[transformTransition]
19485
+ ...[transformTransition, validateHtmlNesting]
18928
19486
  ];
18929
19487
  const DOMDirectiveTransforms = {
18930
19488
  cloak: noopDirectiveTransform,