@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
  **/
@@ -449,157 +449,280 @@ class EffectScope {
449
449
  function effectScope(detached) {
450
450
  return new EffectScope(detached);
451
451
  }
452
- function recordEffectScope(effect, scope = activeEffectScope) {
453
- if (scope && scope.active) {
454
- scope.effects.push(effect);
455
- }
456
- }
457
452
  function getCurrentScope() {
458
453
  return activeEffectScope;
459
454
  }
460
- function onScopeDispose(fn) {
455
+ function onScopeDispose(fn, failSilently = false) {
461
456
  if (activeEffectScope) {
462
457
  activeEffectScope.cleanups.push(fn);
463
- } else if (!!(process.env.NODE_ENV !== "production")) {
458
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
464
459
  warn$2(
465
460
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
466
461
  );
467
462
  }
468
463
  }
469
464
 
470
- let activeEffect;
465
+ let activeSub;
471
466
  class ReactiveEffect {
472
- constructor(fn, trigger, scheduler, scope) {
467
+ constructor(fn) {
473
468
  this.fn = fn;
474
- this.trigger = trigger;
475
- this.scheduler = scheduler;
476
- this.active = true;
477
- this.deps = [];
478
469
  /**
479
470
  * @internal
480
471
  */
481
- this._dirtyLevel = 4;
472
+ this.deps = void 0;
482
473
  /**
483
474
  * @internal
484
475
  */
485
- this._trackId = 0;
476
+ this.depsTail = void 0;
486
477
  /**
487
478
  * @internal
488
479
  */
489
- this._runnings = 0;
480
+ this.flags = 1 | 4;
490
481
  /**
491
482
  * @internal
492
483
  */
493
- this._shouldSchedule = false;
484
+ this.nextEffect = void 0;
494
485
  /**
495
486
  * @internal
496
487
  */
497
- this._depsLength = 0;
498
- recordEffectScope(this, scope);
499
- }
500
- get dirty() {
501
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
502
- this._dirtyLevel = 1;
503
- pauseTracking();
504
- for (let i = 0; i < this._depsLength; i++) {
505
- const dep = this.deps[i];
506
- if (dep.computed) {
507
- triggerComputed(dep.computed);
508
- if (this._dirtyLevel >= 4) {
509
- break;
510
- }
511
- }
512
- }
513
- if (this._dirtyLevel === 1) {
514
- this._dirtyLevel = 0;
515
- }
516
- resetTracking();
488
+ this.cleanup = void 0;
489
+ this.scheduler = void 0;
490
+ if (activeEffectScope && activeEffectScope.active) {
491
+ activeEffectScope.effects.push(this);
517
492
  }
518
- return this._dirtyLevel >= 4;
519
493
  }
520
- set dirty(v) {
521
- 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
+ }
522
509
  }
523
510
  run() {
524
- this._dirtyLevel = 0;
525
- if (!this.active) {
511
+ if (!(this.flags & 1)) {
526
512
  return this.fn();
527
513
  }
528
- let lastShouldTrack = shouldTrack;
529
- 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;
530
521
  try {
531
- shouldTrack = true;
532
- activeEffect = this;
533
- this._runnings++;
534
- preCleanupEffect(this);
535
522
  return this.fn();
536
523
  } finally {
537
- postCleanupEffect(this);
538
- this._runnings--;
539
- activeEffect = lastEffect;
540
- shouldTrack = lastShouldTrack;
524
+ if (!!(process.env.NODE_ENV !== "production") && 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;
541
533
  }
542
534
  }
543
535
  stop() {
544
- var _a;
545
- if (this.active) {
546
- preCleanupEffect(this);
547
- postCleanupEffect(this);
548
- (_a = this.onStop) == null ? void 0 : _a.call(this);
549
- this.active = false;
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);
542
+ this.onStop && this.onStop();
543
+ this.flags &= ~1;
550
544
  }
551
545
  }
546
+ trigger() {
547
+ if (this.scheduler) {
548
+ this.scheduler();
549
+ } else {
550
+ this.runIfDirty();
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
+ }
564
+ }
565
+ let batchDepth = 0;
566
+ let batchedEffect;
567
+ function startBatch() {
568
+ batchDepth++;
569
+ }
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;
597
+ }
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
+ }
552
604
  }
553
- function triggerComputed(computed) {
554
- return computed.value;
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;
616
+ }
617
+ link.dep.activeLink = link.prevActiveLink;
618
+ link.prevActiveLink = void 0;
619
+ }
620
+ sub.deps = head;
621
+ sub.depsTail = tail;
555
622
  }
556
- function preCleanupEffect(effect2) {
557
- effect2._trackId++;
558
- effect2._depsLength = 0;
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;
627
+ }
628
+ }
629
+ if (sub._dirty) {
630
+ return true;
631
+ }
632
+ return false;
559
633
  }
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);
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++;
564
662
  }
565
- effect2.deps.length = effect2._depsLength;
663
+ } catch (err) {
664
+ dep.version++;
665
+ throw err;
666
+ } finally {
667
+ activeSub = prevSub;
668
+ shouldTrack = prevShouldTrack;
669
+ cleanupDeps(computed);
670
+ computed.flags &= ~2;
566
671
  }
567
672
  }
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();
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);
574
690
  }
575
691
  }
576
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
+ }
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,418 @@ 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
  if (!!(process.env.NODE_ENV !== "production")) {
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
- if (!!(process.env.NODE_ENV !== "production")) {
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;
788
+ }
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;
806
+ }
652
807
  }
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);
808
+ }
809
+ if (!!(process.env.NODE_ENV !== "production") && 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 (!!(process.env.NODE_ENV !== "production")) {
830
+ for (let head = this.subsHead; head; head = head.nextSub) {
831
+ if (!!(process.env.NODE_ENV !== "production") && head.sub.onTrigger && !(head.sub.flags & 8)) {
832
+ head.sub.onTrigger(
833
+ extend(
834
+ {
835
+ effect: head.sub
836
+ },
837
+ debugInfo
838
+ )
839
+ );
840
+ }
658
841
  }
659
842
  }
843
+ for (let link = this.subs; link; link = link.prevSub) {
844
+ link.sub.notify();
845
+ }
846
+ } finally {
847
+ endBatch();
660
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 (!!(process.env.NODE_ENV !== "production") && 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(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
674
- const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
871
+ const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
872
+ const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
873
+ const ARRAY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "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
- !!(process.env.NODE_ENV !== "production") ? {
884
+ if (!!(process.env.NODE_ENV !== "production")) {
885
+ dep.track({
689
886
  target,
690
887
  type,
691
888
  key
692
- } : void 0
693
- );
889
+ });
890
+ } else {
891
+ dep.track();
892
+ }
694
893
  }
695
894
  }
696
895
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
697
896
  const depsMap = targetMap.get(target);
698
897
  if (!depsMap) {
898
+ globalVersion++;
699
899
  return;
700
900
  }
701
901
  let deps = [];
702
902
  if (type === "clear") {
703
903
  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
904
  } 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"));
905
+ const targetIsArray = isArray(target);
906
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
907
+ if (targetIsArray && key === "length") {
908
+ const newLength = Number(newValue);
909
+ depsMap.forEach((dep, key2) => {
910
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
911
+ deps.push(dep);
724
912
  }
725
- break;
726
- case "delete":
727
- if (!isArray(target)) {
728
- deps.push(depsMap.get(ITERATE_KEY));
913
+ });
914
+ } else {
915
+ const push = (dep) => dep && deps.push(dep);
916
+ if (key !== void 0) {
917
+ push(depsMap.get(key));
918
+ }
919
+ if (isArrayIndex) {
920
+ push(depsMap.get(ARRAY_ITERATE_KEY));
921
+ }
922
+ switch (type) {
923
+ case "add":
924
+ if (!targetIsArray) {
925
+ push(depsMap.get(ITERATE_KEY));
926
+ if (isMap(target)) {
927
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
928
+ }
929
+ } else if (isArrayIndex) {
930
+ push(depsMap.get("length"));
931
+ }
932
+ break;
933
+ case "delete":
934
+ if (!targetIsArray) {
935
+ push(depsMap.get(ITERATE_KEY));
936
+ if (isMap(target)) {
937
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
938
+ }
939
+ }
940
+ break;
941
+ case "set":
729
942
  if (isMap(target)) {
730
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
943
+ push(depsMap.get(ITERATE_KEY));
731
944
  }
732
- }
733
- break;
734
- case "set":
735
- if (isMap(target)) {
736
- deps.push(depsMap.get(ITERATE_KEY));
737
- }
738
- break;
945
+ break;
946
+ }
739
947
  }
740
948
  }
741
- pauseScheduling();
949
+ startBatch();
742
950
  for (const dep of deps) {
743
- if (dep) {
744
- triggerEffects(
745
- dep,
746
- 4,
747
- !!(process.env.NODE_ENV !== "production") ? {
748
- target,
749
- type,
750
- key,
751
- newValue,
752
- oldValue,
753
- oldTarget
754
- } : void 0
755
- );
951
+ if (!!(process.env.NODE_ENV !== "production")) {
952
+ dep.trigger({
953
+ target,
954
+ type,
955
+ key,
956
+ newValue,
957
+ oldValue,
958
+ oldTarget
959
+ });
960
+ } else {
961
+ dep.trigger();
756
962
  }
757
963
  }
758
- resetScheduling();
964
+ endBatch();
759
965
  }
760
966
  function getDepFromReactive(object, key) {
761
967
  var _a;
762
968
  return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
763
969
  }
764
970
 
971
+ function reactiveReadArray(array) {
972
+ const raw = toRaw(array);
973
+ if (raw === array)
974
+ return raw;
975
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
976
+ return isShallow(array) ? raw : raw.map(toReactive);
977
+ }
978
+ function shallowReadArray(arr) {
979
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
980
+ return arr;
981
+ }
982
+ const arrayInstrumentations = {
983
+ __proto__: null,
984
+ [Symbol.iterator]() {
985
+ return iterator(this, Symbol.iterator, toReactive);
986
+ },
987
+ concat(...args) {
988
+ return reactiveReadArray(this).concat(
989
+ ...args.map((x) => reactiveReadArray(x))
990
+ );
991
+ },
992
+ entries() {
993
+ return iterator(this, "entries", (value) => {
994
+ value[1] = toReactive(value[1]);
995
+ return value;
996
+ });
997
+ },
998
+ every(fn, thisArg) {
999
+ return apply(this, "every", fn, thisArg);
1000
+ },
1001
+ filter(fn, thisArg) {
1002
+ const result = apply(this, "filter", fn, thisArg);
1003
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
1004
+ },
1005
+ find(fn, thisArg) {
1006
+ const result = apply(this, "find", fn, thisArg);
1007
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1008
+ },
1009
+ findIndex(fn, thisArg) {
1010
+ return apply(this, "findIndex", fn, thisArg);
1011
+ },
1012
+ findLast(fn, thisArg) {
1013
+ const result = apply(this, "findLast", fn, thisArg);
1014
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
1015
+ },
1016
+ findLastIndex(fn, thisArg) {
1017
+ return apply(this, "findLastIndex", fn, thisArg);
1018
+ },
1019
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1020
+ forEach(fn, thisArg) {
1021
+ return apply(this, "forEach", fn, thisArg);
1022
+ },
1023
+ includes(...args) {
1024
+ return searchProxy(this, "includes", args);
1025
+ },
1026
+ indexOf(...args) {
1027
+ return searchProxy(this, "indexOf", args);
1028
+ },
1029
+ join(separator) {
1030
+ return reactiveReadArray(this).join(separator);
1031
+ },
1032
+ // keys() iterator only reads `length`, no optimisation required
1033
+ lastIndexOf(...args) {
1034
+ return searchProxy(this, "lastIndexOf", args);
1035
+ },
1036
+ map(fn, thisArg) {
1037
+ return apply(this, "map", fn, thisArg);
1038
+ },
1039
+ pop() {
1040
+ return noTracking(this, "pop");
1041
+ },
1042
+ push(...args) {
1043
+ return noTracking(this, "push", args);
1044
+ },
1045
+ reduce(fn, ...args) {
1046
+ return reduce(this, "reduce", fn, args);
1047
+ },
1048
+ reduceRight(fn, ...args) {
1049
+ return reduce(this, "reduceRight", fn, args);
1050
+ },
1051
+ shift() {
1052
+ return noTracking(this, "shift");
1053
+ },
1054
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1055
+ some(fn, thisArg) {
1056
+ return apply(this, "some", fn, thisArg);
1057
+ },
1058
+ splice(...args) {
1059
+ return noTracking(this, "splice", args);
1060
+ },
1061
+ toReversed() {
1062
+ return reactiveReadArray(this).toReversed();
1063
+ },
1064
+ toSorted(comparer) {
1065
+ return reactiveReadArray(this).toSorted(comparer);
1066
+ },
1067
+ toSpliced(...args) {
1068
+ return reactiveReadArray(this).toSpliced(...args);
1069
+ },
1070
+ unshift(...args) {
1071
+ return noTracking(this, "unshift", args);
1072
+ },
1073
+ values() {
1074
+ return iterator(this, "values", toReactive);
1075
+ }
1076
+ };
1077
+ function iterator(self, method, wrapValue) {
1078
+ const arr = shallowReadArray(self);
1079
+ const iter = arr[method]();
1080
+ if (arr !== self && !isShallow(self)) {
1081
+ iter._next = iter.next;
1082
+ iter.next = () => {
1083
+ const result = iter._next();
1084
+ if (result.value) {
1085
+ result.value = wrapValue(result.value);
1086
+ }
1087
+ return result;
1088
+ };
1089
+ }
1090
+ return iter;
1091
+ }
1092
+ function apply(self, method, fn, thisArg) {
1093
+ const arr = shallowReadArray(self);
1094
+ let wrappedFn = fn;
1095
+ if (arr !== self) {
1096
+ if (!isShallow(self)) {
1097
+ wrappedFn = function(item, index) {
1098
+ return fn.call(this, toReactive(item), index, self);
1099
+ };
1100
+ } else if (fn.length > 2) {
1101
+ wrappedFn = function(item, index) {
1102
+ return fn.call(this, item, index, self);
1103
+ };
1104
+ }
1105
+ }
1106
+ return arr[method](wrappedFn, thisArg);
1107
+ }
1108
+ function reduce(self, method, fn, args) {
1109
+ const arr = shallowReadArray(self);
1110
+ let wrappedFn = fn;
1111
+ if (arr !== self) {
1112
+ if (!isShallow(self)) {
1113
+ wrappedFn = function(acc, item, index) {
1114
+ return fn.call(this, acc, toReactive(item), index, self);
1115
+ };
1116
+ } else if (fn.length > 3) {
1117
+ wrappedFn = function(acc, item, index) {
1118
+ return fn.call(this, acc, item, index, self);
1119
+ };
1120
+ }
1121
+ }
1122
+ return arr[method](wrappedFn, ...args);
1123
+ }
1124
+ function searchProxy(self, method, args) {
1125
+ const arr = toRaw(self);
1126
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1127
+ const res = arr[method](...args);
1128
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1129
+ args[0] = toRaw(args[0]);
1130
+ return arr[method](...args);
1131
+ }
1132
+ return res;
1133
+ }
1134
+ function noTracking(self, method, args = []) {
1135
+ pauseTracking();
1136
+ startBatch();
1137
+ const res = toRaw(self)[method].apply(self, args);
1138
+ endBatch();
1139
+ resetTracking();
1140
+ return res;
1141
+ }
1142
+
765
1143
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
766
1144
  const builtInSymbols = new Set(
767
1145
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
768
1146
  );
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
1147
  function hasOwnProperty(key) {
799
1148
  if (!isSymbol(key))
800
1149
  key = String(key);
@@ -825,14 +1174,22 @@ class BaseReactiveHandler {
825
1174
  }
826
1175
  const targetIsArray = isArray(target);
827
1176
  if (!isReadonly2) {
828
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
829
- return Reflect.get(arrayInstrumentations, key, receiver);
1177
+ let fn;
1178
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1179
+ return fn;
830
1180
  }
831
1181
  if (key === "hasOwnProperty") {
832
1182
  return hasOwnProperty;
833
1183
  }
834
1184
  }
835
- const res = Reflect.get(target, key, receiver);
1185
+ const res = Reflect.get(
1186
+ target,
1187
+ key,
1188
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1189
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1190
+ // its class methods
1191
+ isRef(target) ? target : receiver
1192
+ );
836
1193
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
837
1194
  return res;
838
1195
  }
@@ -1331,110 +1688,8 @@ function markRaw(value) {
1331
1688
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1332
1689
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1333
1690
 
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 (!!(process.env.NODE_ENV !== "production") && 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 = !!(process.env.NODE_ENV !== "production") ? () => {
1388
- warn$2("Write operation failed: computed value is readonly");
1389
- } : NOOP;
1390
- } else {
1391
- getter = getterOrOptions.get;
1392
- setter = getterOrOptions.set;
1393
- }
1394
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1395
- if (!!(process.env.NODE_ENV !== "production") && 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
- !!(process.env.NODE_ENV !== "production") ? {
1413
- target: ref2,
1414
- type: "get",
1415
- key: "value"
1416
- } : void 0
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
- !!(process.env.NODE_ENV !== "production") ? {
1428
- target: ref2,
1429
- type: "set",
1430
- key: "value",
1431
- newValue: newVal
1432
- } : void 0
1433
- );
1434
- }
1435
- }
1436
1691
  function isRef(r) {
1437
- return !!(r && r.__v_isRef === true);
1692
+ return r ? r.__v_isRef === true : false;
1438
1693
  }
1439
1694
  function ref(value) {
1440
1695
  return createRef(value, false);
@@ -1451,27 +1706,55 @@ function createRef(rawValue, shallow) {
1451
1706
  class RefImpl {
1452
1707
  constructor(value, __v_isShallow) {
1453
1708
  this.__v_isShallow = __v_isShallow;
1454
- this.dep = void 0;
1709
+ this.dep = new Dep();
1455
1710
  this.__v_isRef = true;
1456
1711
  this._rawValue = __v_isShallow ? value : toRaw(value);
1457
1712
  this._value = __v_isShallow ? value : toReactive(value);
1458
1713
  }
1459
1714
  get value() {
1460
- trackRefValue(this);
1715
+ if (!!(process.env.NODE_ENV !== "production")) {
1716
+ this.dep.track({
1717
+ target: this,
1718
+ type: "get",
1719
+ key: "value"
1720
+ });
1721
+ } else {
1722
+ this.dep.track();
1723
+ }
1461
1724
  return this._value;
1462
1725
  }
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);
1726
+ set value(newValue) {
1727
+ const oldValue = this._rawValue;
1728
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1729
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1730
+ if (hasChanged(newValue, oldValue)) {
1731
+ this._rawValue = newValue;
1732
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1733
+ if (!!(process.env.NODE_ENV !== "production")) {
1734
+ this.dep.trigger({
1735
+ target: this,
1736
+ type: "set",
1737
+ key: "value",
1738
+ newValue,
1739
+ oldValue
1740
+ });
1741
+ } else {
1742
+ this.dep.trigger();
1743
+ }
1470
1744
  }
1471
1745
  }
1472
1746
  }
1473
1747
  function triggerRef(ref2) {
1474
- triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1748
+ if (!!(process.env.NODE_ENV !== "production")) {
1749
+ ref2.dep.trigger({
1750
+ target: ref2,
1751
+ type: "set",
1752
+ key: "value",
1753
+ newValue: ref2._value
1754
+ });
1755
+ } else {
1756
+ ref2.dep.trigger();
1757
+ }
1475
1758
  }
1476
1759
  function unref(ref2) {
1477
1760
  return isRef(ref2) ? ref2.value : ref2;
@@ -1496,12 +1779,9 @@ function proxyRefs(objectWithRefs) {
1496
1779
  }
1497
1780
  class CustomRefImpl {
1498
1781
  constructor(factory) {
1499
- this.dep = void 0;
1500
1782
  this.__v_isRef = true;
1501
- const { get, set } = factory(
1502
- () => trackRefValue(this),
1503
- () => triggerRefValue(this)
1504
- );
1783
+ const dep = this.dep = new Dep();
1784
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1505
1785
  this._get = get;
1506
1786
  this._set = set;
1507
1787
  }
@@ -1569,6 +1849,90 @@ function propertyToRef(source, key, defaultValue) {
1569
1849
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1570
1850
  }
1571
1851
 
1852
+ class ComputedRefImpl {
1853
+ constructor(fn, setter, isSSR) {
1854
+ this.fn = fn;
1855
+ this.setter = setter;
1856
+ /**
1857
+ * @internal
1858
+ */
1859
+ this._value = void 0;
1860
+ /**
1861
+ * @internal
1862
+ */
1863
+ this.dep = new Dep(this);
1864
+ /**
1865
+ * @internal
1866
+ */
1867
+ this.__v_isRef = true;
1868
+ // A computed is also a subscriber that tracks other deps
1869
+ /**
1870
+ * @internal
1871
+ */
1872
+ this.deps = void 0;
1873
+ /**
1874
+ * @internal
1875
+ */
1876
+ this.depsTail = void 0;
1877
+ /**
1878
+ * @internal
1879
+ */
1880
+ this.flags = 16;
1881
+ /**
1882
+ * @internal
1883
+ */
1884
+ this.globalVersion = globalVersion - 1;
1885
+ // for backwards compat
1886
+ this.effect = this;
1887
+ this.__v_isReadonly = !setter;
1888
+ this.isSSR = isSSR;
1889
+ }
1890
+ /**
1891
+ * @internal
1892
+ */
1893
+ notify() {
1894
+ if (activeSub !== this) {
1895
+ this.flags |= 16;
1896
+ this.dep.notify();
1897
+ } else if (!!(process.env.NODE_ENV !== "production")) ;
1898
+ }
1899
+ get value() {
1900
+ const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1901
+ target: this,
1902
+ type: "get",
1903
+ key: "value"
1904
+ }) : this.dep.track();
1905
+ refreshComputed(this);
1906
+ if (link) {
1907
+ link.version = this.dep.version;
1908
+ }
1909
+ return this._value;
1910
+ }
1911
+ set value(newValue) {
1912
+ if (this.setter) {
1913
+ this.setter(newValue);
1914
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1915
+ warn$2("Write operation failed: computed value is readonly");
1916
+ }
1917
+ }
1918
+ }
1919
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1920
+ let getter;
1921
+ let setter;
1922
+ if (isFunction(getterOrOptions)) {
1923
+ getter = getterOrOptions;
1924
+ } else {
1925
+ getter = getterOrOptions.get;
1926
+ setter = getterOrOptions.set;
1927
+ }
1928
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1929
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1930
+ cRef.onTrack = debugOptions.onTrack;
1931
+ cRef.onTrigger = debugOptions.onTrigger;
1932
+ }
1933
+ return cRef;
1934
+ }
1935
+
1572
1936
  const TrackOpTypes = {
1573
1937
  "GET": "get",
1574
1938
  "HAS": "has",
@@ -1865,7 +2229,7 @@ function findInsertionIndex(id) {
1865
2229
  const middle = start + end >>> 1;
1866
2230
  const middleJob = queue[middle];
1867
2231
  const middleJobId = getId(middleJob);
1868
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2232
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1869
2233
  start = middle + 1;
1870
2234
  } else {
1871
2235
  end = middle;
@@ -1874,15 +2238,21 @@ function findInsertionIndex(id) {
1874
2238
  return start;
1875
2239
  }
1876
2240
  function queueJob(job) {
1877
- if (!queue.length || !queue.includes(
1878
- job,
1879
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1880
- )) {
2241
+ var _a;
2242
+ if (!(job.flags & 1)) {
1881
2243
  if (job.id == null) {
1882
2244
  queue.push(job);
2245
+ } else if (
2246
+ // fast path when the job id is larger than the tail
2247
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2248
+ ) {
2249
+ queue.push(job);
1883
2250
  } else {
1884
2251
  queue.splice(findInsertionIndex(job.id), 0, job);
1885
2252
  }
2253
+ if (!(job.flags & 4)) {
2254
+ job.flags |= 1;
2255
+ }
1886
2256
  queueFlush();
1887
2257
  }
1888
2258
  }
@@ -1900,11 +2270,11 @@ function invalidateJob(job) {
1900
2270
  }
1901
2271
  function queuePostFlushCb(cb) {
1902
2272
  if (!isArray(cb)) {
1903
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1904
- cb,
1905
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1906
- )) {
2273
+ if (!(cb.flags & 1)) {
1907
2274
  pendingPostFlushCbs.push(cb);
2275
+ if (!(cb.flags & 4)) {
2276
+ cb.flags |= 1;
2277
+ }
1908
2278
  }
1909
2279
  } else {
1910
2280
  pendingPostFlushCbs.push(...cb);
@@ -1917,7 +2287,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1917
2287
  }
1918
2288
  for (; i < queue.length; i++) {
1919
2289
  const cb = queue[i];
1920
- if (cb && cb.pre) {
2290
+ if (cb && cb.flags & 2) {
1921
2291
  if (instance && cb.id !== instance.uid) {
1922
2292
  continue;
1923
2293
  }
@@ -1927,6 +2297,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1927
2297
  queue.splice(i, 1);
1928
2298
  i--;
1929
2299
  cb();
2300
+ cb.flags &= ~1;
1930
2301
  }
1931
2302
  }
1932
2303
  }
@@ -1949,6 +2320,7 @@ function flushPostFlushCbs(seen) {
1949
2320
  continue;
1950
2321
  }
1951
2322
  activePostFlushCbs[postFlushIndex]();
2323
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1952
2324
  }
1953
2325
  activePostFlushCbs = null;
1954
2326
  postFlushIndex = 0;
@@ -1958,9 +2330,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
1958
2330
  const comparator = (a, b) => {
1959
2331
  const diff = getId(a) - getId(b);
1960
2332
  if (diff === 0) {
1961
- if (a.pre && !b.pre)
2333
+ const isAPre = a.flags & 2;
2334
+ const isBPre = b.flags & 2;
2335
+ if (isAPre && !isBPre)
1962
2336
  return -1;
1963
- if (b.pre && !a.pre)
2337
+ if (isBPre && !isAPre)
1964
2338
  return 1;
1965
2339
  }
1966
2340
  return diff;
@@ -1976,11 +2350,12 @@ function flushJobs(seen) {
1976
2350
  try {
1977
2351
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1978
2352
  const job = queue[flushIndex];
1979
- if (job && job.active !== false) {
2353
+ if (job && !(job.flags & 8)) {
1980
2354
  if (!!(process.env.NODE_ENV !== "production") && check(job)) {
1981
2355
  continue;
1982
2356
  }
1983
2357
  callWithErrorHandling(job, null, 14);
2358
+ job.flags &= ~1;
1984
2359
  }
1985
2360
  }
1986
2361
  } finally {
@@ -2062,7 +2437,6 @@ function rerender(id, newRender) {
2062
2437
  }
2063
2438
  instance.renderCache = [];
2064
2439
  isHmrUpdating = true;
2065
- instance.effect.dirty = true;
2066
2440
  instance.update();
2067
2441
  isHmrUpdating = false;
2068
2442
  });
@@ -2090,7 +2464,6 @@ function reload(id, newComp) {
2090
2464
  instance.ceReload(newComp.styles);
2091
2465
  hmrDirtyComponents.delete(oldComp);
2092
2466
  } else if (instance.parent) {
2093
- instance.parent.effect.dirty = true;
2094
2467
  queueJob(instance.parent.update);
2095
2468
  } else if (instance.appContext.reload) {
2096
2469
  instance.appContext.reload();
@@ -4082,8 +4455,8 @@ function doWatch(source, cb, {
4082
4455
  }
4083
4456
  }
4084
4457
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4085
- const job = () => {
4086
- if (!effect.active || !effect.dirty) {
4458
+ const job = (immediateFirstRun) => {
4459
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4087
4460
  return;
4088
4461
  }
4089
4462
  if (cb) {
@@ -4104,19 +4477,22 @@ function doWatch(source, cb, {
4104
4477
  effect.run();
4105
4478
  }
4106
4479
  };
4107
- job.allowRecurse = !!cb;
4480
+ if (cb)
4481
+ job.flags |= 4;
4482
+ const effect = new ReactiveEffect(getter);
4108
4483
  let scheduler;
4109
4484
  if (flush === "sync") {
4485
+ effect.flags |= 64;
4110
4486
  scheduler = job;
4111
4487
  } else if (flush === "post") {
4112
4488
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4113
4489
  } else {
4114
- job.pre = true;
4490
+ job.flags |= 2;
4115
4491
  if (instance)
4116
4492
  job.id = instance.uid;
4117
4493
  scheduler = () => queueJob(job);
4118
4494
  }
4119
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4495
+ effect.scheduler = scheduler;
4120
4496
  const scope = getCurrentScope();
4121
4497
  const unwatch = () => {
4122
4498
  effect.stop();
@@ -4130,7 +4506,7 @@ function doWatch(source, cb, {
4130
4506
  }
4131
4507
  if (cb) {
4132
4508
  if (immediate) {
4133
- job();
4509
+ job(true);
4134
4510
  } else {
4135
4511
  oldValue = effect.run();
4136
4512
  }
@@ -4314,24 +4690,7 @@ const BaseTransitionImpl = {
4314
4690
  if (!children || !children.length) {
4315
4691
  return;
4316
4692
  }
4317
- let child = children[0];
4318
- if (children.length > 1) {
4319
- let hasFound = false;
4320
- for (const c of children) {
4321
- if (c.type !== Comment) {
4322
- if (!!(process.env.NODE_ENV !== "production") && hasFound) {
4323
- warn$1(
4324
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4325
- );
4326
- break;
4327
- }
4328
- child = c;
4329
- hasFound = true;
4330
- if (!!!(process.env.NODE_ENV !== "production"))
4331
- break;
4332
- }
4333
- }
4334
- }
4693
+ const child = findNonCommentChild(children);
4335
4694
  const rawProps = toRaw(props);
4336
4695
  const { mode } = rawProps;
4337
4696
  if (!!(process.env.NODE_ENV !== "production") && mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4340,7 +4699,7 @@ const BaseTransitionImpl = {
4340
4699
  if (state.isLeaving) {
4341
4700
  return emptyPlaceholder(child);
4342
4701
  }
4343
- const innerChild = getKeepAliveChild(child);
4702
+ const innerChild = getInnerChild$1(child);
4344
4703
  if (!innerChild) {
4345
4704
  return emptyPlaceholder(child);
4346
4705
  }
@@ -4352,7 +4711,7 @@ const BaseTransitionImpl = {
4352
4711
  );
4353
4712
  setTransitionHooks(innerChild, enterHooks);
4354
4713
  const oldChild = instance.subTree;
4355
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4714
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4356
4715
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4357
4716
  const leavingHooks = resolveTransitionHooks(
4358
4717
  oldInnerChild,
@@ -4365,8 +4724,7 @@ const BaseTransitionImpl = {
4365
4724
  state.isLeaving = true;
4366
4725
  leavingHooks.afterLeave = () => {
4367
4726
  state.isLeaving = false;
4368
- if (instance.update.active !== false) {
4369
- instance.effect.dirty = true;
4727
+ if (!(instance.job.flags & 8)) {
4370
4728
  instance.update();
4371
4729
  }
4372
4730
  };
@@ -4394,6 +4752,27 @@ const BaseTransitionImpl = {
4394
4752
  {
4395
4753
  BaseTransitionImpl.__isBuiltIn = true;
4396
4754
  }
4755
+ function findNonCommentChild(children) {
4756
+ let child = children[0];
4757
+ if (children.length > 1) {
4758
+ let hasFound = false;
4759
+ for (const c of children) {
4760
+ if (c.type !== Comment) {
4761
+ if (!!(process.env.NODE_ENV !== "production") && hasFound) {
4762
+ warn$1(
4763
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4764
+ );
4765
+ break;
4766
+ }
4767
+ child = c;
4768
+ hasFound = true;
4769
+ if (!!!(process.env.NODE_ENV !== "production"))
4770
+ break;
4771
+ }
4772
+ }
4773
+ }
4774
+ return child;
4775
+ }
4397
4776
  const BaseTransition = BaseTransitionImpl;
4398
4777
  function getLeavingNodesForType(state, vnode) {
4399
4778
  const { leavingVNodes } = state;
@@ -4548,8 +4927,11 @@ function emptyPlaceholder(vnode) {
4548
4927
  return vnode;
4549
4928
  }
4550
4929
  }
4551
- function getKeepAliveChild(vnode) {
4930
+ function getInnerChild$1(vnode) {
4552
4931
  if (!isKeepAlive(vnode)) {
4932
+ if (isTeleport(vnode.type) && vnode.children) {
4933
+ return findNonCommentChild(vnode.children);
4934
+ }
4553
4935
  return vnode;
4554
4936
  }
4555
4937
  if (!!(process.env.NODE_ENV !== "production") && vnode.component) {
@@ -4718,7 +5100,6 @@ function defineAsyncComponent(source) {
4718
5100
  load().then(() => {
4719
5101
  loaded.value = true;
4720
5102
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4721
- instance.parent.effect.dirty = true;
4722
5103
  queueJob(instance.parent.update);
4723
5104
  }
4724
5105
  }).catch((err) => {
@@ -5336,10 +5717,20 @@ function convertLegacyFunctionalComponent(comp) {
5336
5717
  function renderList(source, renderItem, cache, index) {
5337
5718
  let ret;
5338
5719
  const cached = cache && cache[index];
5339
- if (isArray(source) || isString(source)) {
5720
+ const sourceIsArray = isArray(source);
5721
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5722
+ if (sourceIsArray || isString(source)) {
5723
+ if (sourceIsReactiveArray) {
5724
+ source = shallowReadArray(source);
5725
+ }
5340
5726
  ret = new Array(source.length);
5341
5727
  for (let i = 0, l = source.length; i < l; i++) {
5342
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5728
+ ret[i] = renderItem(
5729
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5730
+ i,
5731
+ void 0,
5732
+ cached && cached[i]
5733
+ );
5343
5734
  }
5344
5735
  } else if (typeof source === "number") {
5345
5736
  if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
@@ -5710,7 +6101,6 @@ const publicPropertiesMap = (
5710
6101
  $emit: (i) => i.emit,
5711
6102
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
5712
6103
  $forceUpdate: (i) => i.f || (i.f = () => {
5713
- i.effect.dirty = true;
5714
6104
  queueJob(i.update);
5715
6105
  }),
5716
6106
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6583,7 +6973,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6583
6973
  return vm;
6584
6974
  }
6585
6975
  }
6586
- Vue.version = `2.6.14-compat:${"3.4.25"}`;
6976
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6587
6977
  Vue.config = singletonApp.config;
6588
6978
  Vue.use = (p, ...options) => {
6589
6979
  if (p && isFunction(p.install)) {
@@ -7604,7 +7994,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7604
7994
  function assertType(value, type) {
7605
7995
  let valid;
7606
7996
  const expectedType = getType(type);
7607
- if (isSimpleType(expectedType)) {
7997
+ if (expectedType === "null") {
7998
+ valid = value === null;
7999
+ } else if (isSimpleType(expectedType)) {
7608
8000
  const t = typeof value;
7609
8001
  valid = t === expectedType.toLowerCase();
7610
8002
  if (!valid && t === "object") {
@@ -7614,8 +8006,6 @@ function assertType(value, type) {
7614
8006
  valid = isObject(value);
7615
8007
  } else if (expectedType === "Array") {
7616
8008
  valid = isArray(value);
7617
- } else if (expectedType === "null") {
7618
- valid = value === null;
7619
8009
  } else {
7620
8010
  valid = value instanceof type;
7621
8011
  }
@@ -9188,7 +9578,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9188
9578
  } else {
9189
9579
  instance.next = n2;
9190
9580
  invalidateJob(instance.update);
9191
- instance.effect.dirty = true;
9192
9581
  instance.update();
9193
9582
  }
9194
9583
  } else {
@@ -9395,24 +9784,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9395
9784
  }
9396
9785
  }
9397
9786
  };
9398
- const effect = instance.effect = new ReactiveEffect(
9399
- componentUpdateFn,
9400
- NOOP,
9401
- () => queueJob(update),
9402
- instance.scope
9403
- // track it in component's effect scope
9404
- );
9405
- const update = instance.update = () => {
9406
- if (effect.dirty) {
9407
- effect.run();
9408
- }
9409
- };
9410
- update.id = instance.uid;
9787
+ instance.scope.on();
9788
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9789
+ instance.scope.off();
9790
+ const update = instance.update = effect.run.bind(effect);
9791
+ const job = instance.job = effect.runIfDirty.bind(effect);
9792
+ job.id = instance.uid;
9793
+ effect.scheduler = () => queueJob(job);
9411
9794
  toggleRecurse(instance, true);
9412
9795
  if (!!(process.env.NODE_ENV !== "production")) {
9413
9796
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9414
9797
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9415
- update.ownerInstance = instance;
9798
+ job.ownerInstance = instance;
9416
9799
  }
9417
9800
  update();
9418
9801
  };
@@ -9879,7 +10262,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9879
10262
  if (!!(process.env.NODE_ENV !== "production") && instance.type.__hmrId) {
9880
10263
  unregisterHMR(instance);
9881
10264
  }
9882
- const { bum, scope, update, subTree, um } = instance;
10265
+ const { bum, scope, job, subTree, um } = instance;
9883
10266
  if (bum) {
9884
10267
  invokeArrayFns(bum);
9885
10268
  }
@@ -9887,8 +10270,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9887
10270
  instance.emit("hook:beforeDestroy");
9888
10271
  }
9889
10272
  scope.stop();
9890
- if (update) {
9891
- update.active = false;
10273
+ if (job) {
10274
+ job.flags |= 8;
9892
10275
  unmount(subTree, instance, parentSuspense, doRemove);
9893
10276
  }
9894
10277
  if (um) {
@@ -9980,8 +10363,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9980
10363
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9981
10364
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9982
10365
  }
9983
- function toggleRecurse({ effect, update }, allowed) {
9984
- effect.allowRecurse = update.allowRecurse = allowed;
10366
+ function toggleRecurse({ effect, job }, allowed) {
10367
+ if (allowed) {
10368
+ effect.flags |= 32;
10369
+ job.flags |= 4;
10370
+ } else {
10371
+ effect.flags &= ~32;
10372
+ job.flags &= ~4;
10373
+ }
9985
10374
  }
9986
10375
  function needTransition(parentSuspense, transition) {
9987
10376
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10779,6 +11168,7 @@ function createComponentInstance(vnode, parent, suspense) {
10779
11168
  effect: null,
10780
11169
  update: null,
10781
11170
  // will be set synchronously right after creation
11171
+ job: null,
10782
11172
  scope: new EffectScope(
10783
11173
  true
10784
11174
  /* detached */
@@ -11315,7 +11705,8 @@ function initCustomFormatter() {
11315
11705
  {},
11316
11706
  ["span", vueStyle, genRefFlag(obj)],
11317
11707
  "<",
11318
- formatValue(obj.value),
11708
+ // avoid debugger accessing value affecting behavior
11709
+ formatValue("_value" in obj ? obj._value : obj),
11319
11710
  `>`
11320
11711
  ];
11321
11712
  } else if (isReactive(obj)) {
@@ -11495,7 +11886,7 @@ function isMemoSame(cached, memo) {
11495
11886
  return true;
11496
11887
  }
11497
11888
 
11498
- const version = "3.4.25";
11889
+ const version = "3.5.0-alpha.1";
11499
11890
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
11500
11891
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11501
11892
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13111,7 +13502,9 @@ const withKeys = (fn, modifiers) => {
13111
13502
  return;
13112
13503
  }
13113
13504
  const eventKey = hyphenate(event.key);
13114
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13505
+ if (modifiers.some(
13506
+ (k) => k === eventKey || keyNames[k] === eventKey
13507
+ )) {
13115
13508
  return fn(event);
13116
13509
  }
13117
13510
  {
@@ -19096,9 +19489,183 @@ const ignoreSideEffectTags = (node, context) => {
19096
19489
  }
19097
19490
  };
19098
19491
 
19492
+ function isValidHTMLNesting(parent, child) {
19493
+ if (parent in onlyValidChildren) {
19494
+ return onlyValidChildren[parent].has(child);
19495
+ }
19496
+ if (child in onlyValidParents) {
19497
+ return onlyValidParents[child].has(parent);
19498
+ }
19499
+ if (parent in knownInvalidChildren) {
19500
+ if (knownInvalidChildren[parent].has(child))
19501
+ return false;
19502
+ }
19503
+ if (child in knownInvalidParents) {
19504
+ if (knownInvalidParents[child].has(parent))
19505
+ return false;
19506
+ }
19507
+ return true;
19508
+ }
19509
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
19510
+ const emptySet = /* @__PURE__ */ new Set([]);
19511
+ const onlyValidChildren = {
19512
+ head: /* @__PURE__ */ new Set([
19513
+ "base",
19514
+ "basefront",
19515
+ "bgsound",
19516
+ "link",
19517
+ "meta",
19518
+ "title",
19519
+ "noscript",
19520
+ "noframes",
19521
+ "style",
19522
+ "script",
19523
+ "template"
19524
+ ]),
19525
+ optgroup: /* @__PURE__ */ new Set(["option"]),
19526
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
19527
+ // table
19528
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
19529
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
19530
+ colgroup: /* @__PURE__ */ new Set(["col"]),
19531
+ tbody: /* @__PURE__ */ new Set(["tr"]),
19532
+ thead: /* @__PURE__ */ new Set(["tr"]),
19533
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
19534
+ // these elements can not have any children elements
19535
+ script: emptySet,
19536
+ iframe: emptySet,
19537
+ option: emptySet,
19538
+ textarea: emptySet,
19539
+ style: emptySet,
19540
+ title: emptySet
19541
+ };
19542
+ const onlyValidParents = {
19543
+ // sections
19544
+ html: emptySet,
19545
+ body: /* @__PURE__ */ new Set(["html"]),
19546
+ head: /* @__PURE__ */ new Set(["html"]),
19547
+ // table
19548
+ td: /* @__PURE__ */ new Set(["tr"]),
19549
+ colgroup: /* @__PURE__ */ new Set(["table"]),
19550
+ caption: /* @__PURE__ */ new Set(["table"]),
19551
+ tbody: /* @__PURE__ */ new Set(["table"]),
19552
+ tfoot: /* @__PURE__ */ new Set(["table"]),
19553
+ col: /* @__PURE__ */ new Set(["colgroup"]),
19554
+ th: /* @__PURE__ */ new Set(["tr"]),
19555
+ thead: /* @__PURE__ */ new Set(["table"]),
19556
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
19557
+ // data list
19558
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
19559
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
19560
+ // other
19561
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
19562
+ // li: new Set(["ul", "ol"]),
19563
+ summary: /* @__PURE__ */ new Set(["details"]),
19564
+ area: /* @__PURE__ */ new Set(["map"])
19565
+ };
19566
+ const knownInvalidChildren = {
19567
+ p: /* @__PURE__ */ new Set([
19568
+ "address",
19569
+ "article",
19570
+ "aside",
19571
+ "blockquote",
19572
+ "center",
19573
+ "details",
19574
+ "dialog",
19575
+ "dir",
19576
+ "div",
19577
+ "dl",
19578
+ "fieldset",
19579
+ "figure",
19580
+ "footer",
19581
+ "form",
19582
+ "h1",
19583
+ "h2",
19584
+ "h3",
19585
+ "h4",
19586
+ "h5",
19587
+ "h6",
19588
+ "header",
19589
+ "hgroup",
19590
+ "hr",
19591
+ "li",
19592
+ "main",
19593
+ "nav",
19594
+ "menu",
19595
+ "ol",
19596
+ "p",
19597
+ "pre",
19598
+ "section",
19599
+ "table",
19600
+ "ul"
19601
+ ]),
19602
+ svg: /* @__PURE__ */ new Set([
19603
+ "b",
19604
+ "blockquote",
19605
+ "br",
19606
+ "code",
19607
+ "dd",
19608
+ "div",
19609
+ "dl",
19610
+ "dt",
19611
+ "em",
19612
+ "embed",
19613
+ "h1",
19614
+ "h2",
19615
+ "h3",
19616
+ "h4",
19617
+ "h5",
19618
+ "h6",
19619
+ "hr",
19620
+ "i",
19621
+ "img",
19622
+ "li",
19623
+ "menu",
19624
+ "meta",
19625
+ "ol",
19626
+ "p",
19627
+ "pre",
19628
+ "ruby",
19629
+ "s",
19630
+ "small",
19631
+ "span",
19632
+ "strong",
19633
+ "sub",
19634
+ "sup",
19635
+ "table",
19636
+ "u",
19637
+ "ul",
19638
+ "var"
19639
+ ])
19640
+ };
19641
+ const knownInvalidParents = {
19642
+ a: /* @__PURE__ */ new Set(["a"]),
19643
+ button: /* @__PURE__ */ new Set(["button"]),
19644
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
19645
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
19646
+ form: /* @__PURE__ */ new Set(["form"]),
19647
+ li: /* @__PURE__ */ new Set(["li"]),
19648
+ h1: headings,
19649
+ h2: headings,
19650
+ h3: headings,
19651
+ h4: headings,
19652
+ h5: headings,
19653
+ h6: headings
19654
+ };
19655
+
19656
+ const validateHtmlNesting = (node, context) => {
19657
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
19658
+ const error = new SyntaxError(
19659
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
19660
+ );
19661
+ error.loc = node.loc;
19662
+ context.onWarn(error);
19663
+ }
19664
+ };
19665
+
19099
19666
  const DOMNodeTransforms = [
19100
19667
  transformStyle,
19101
- ...!!(process.env.NODE_ENV !== "production") ? [transformTransition] : []
19668
+ ...!!(process.env.NODE_ENV !== "production") ? [transformTransition, validateHtmlNesting] : []
19102
19669
  ];
19103
19670
  const DOMDirectiveTransforms = {
19104
19671
  cloak: noopDirectiveTransform,