vue 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 v3.4.25
2
+ * vue 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 {
458
+ } else if (!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 (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++;
552
569
  }
553
- function triggerComputed(computed) {
554
- return computed.value;
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;
555
597
  }
556
- function preCleanupEffect(effect2) {
557
- effect2._trackId++;
558
- effect2._depsLength = 0;
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
+ }
559
604
  }
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);
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;
788
+ }
789
+ if (activeSub.flags & 4) {
790
+ addSub(link);
652
791
  }
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);
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
963
  var _a;
762
964
  return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
763
965
  }
764
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;
1137
+ }
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();
@@ -3492,8 +3855,8 @@ function doWatch(source, cb, {
3492
3855
  };
3493
3856
  };
3494
3857
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3495
- const job = () => {
3496
- if (!effect.active || !effect.dirty) {
3858
+ const job = (immediateFirstRun) => {
3859
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
3497
3860
  return;
3498
3861
  }
3499
3862
  if (cb) {
@@ -3514,19 +3877,22 @@ function doWatch(source, cb, {
3514
3877
  effect.run();
3515
3878
  }
3516
3879
  };
3517
- job.allowRecurse = !!cb;
3880
+ if (cb)
3881
+ job.flags |= 4;
3882
+ const effect = new ReactiveEffect(getter);
3518
3883
  let scheduler;
3519
3884
  if (flush === "sync") {
3885
+ effect.flags |= 64;
3520
3886
  scheduler = job;
3521
3887
  } else if (flush === "post") {
3522
3888
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
3523
3889
  } else {
3524
- job.pre = true;
3890
+ job.flags |= 2;
3525
3891
  if (instance)
3526
3892
  job.id = instance.uid;
3527
3893
  scheduler = () => queueJob(job);
3528
3894
  }
3529
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
3895
+ effect.scheduler = scheduler;
3530
3896
  const scope = getCurrentScope();
3531
3897
  const unwatch = () => {
3532
3898
  effect.stop();
@@ -3540,7 +3906,7 @@ function doWatch(source, cb, {
3540
3906
  }
3541
3907
  if (cb) {
3542
3908
  if (immediate) {
3543
- job();
3909
+ job(true);
3544
3910
  } else {
3545
3911
  oldValue = effect.run();
3546
3912
  }
@@ -3719,22 +4085,7 @@ const BaseTransitionImpl = {
3719
4085
  if (!children || !children.length) {
3720
4086
  return;
3721
4087
  }
3722
- let child = children[0];
3723
- if (children.length > 1) {
3724
- let hasFound = false;
3725
- for (const c of children) {
3726
- if (c.type !== Comment) {
3727
- if (hasFound) {
3728
- warn$1(
3729
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
3730
- );
3731
- break;
3732
- }
3733
- child = c;
3734
- hasFound = true;
3735
- }
3736
- }
3737
- }
4088
+ const child = findNonCommentChild(children);
3738
4089
  const rawProps = toRaw(props);
3739
4090
  const { mode } = rawProps;
3740
4091
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -3743,7 +4094,7 @@ const BaseTransitionImpl = {
3743
4094
  if (state.isLeaving) {
3744
4095
  return emptyPlaceholder(child);
3745
4096
  }
3746
- const innerChild = getKeepAliveChild(child);
4097
+ const innerChild = getInnerChild$1(child);
3747
4098
  if (!innerChild) {
3748
4099
  return emptyPlaceholder(child);
3749
4100
  }
@@ -3755,7 +4106,7 @@ const BaseTransitionImpl = {
3755
4106
  );
3756
4107
  setTransitionHooks(innerChild, enterHooks);
3757
4108
  const oldChild = instance.subTree;
3758
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4109
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
3759
4110
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
3760
4111
  const leavingHooks = resolveTransitionHooks(
3761
4112
  oldInnerChild,
@@ -3768,8 +4119,7 @@ const BaseTransitionImpl = {
3768
4119
  state.isLeaving = true;
3769
4120
  leavingHooks.afterLeave = () => {
3770
4121
  state.isLeaving = false;
3771
- if (instance.update.active !== false) {
3772
- instance.effect.dirty = true;
4122
+ if (!(instance.job.flags & 8)) {
3773
4123
  instance.update();
3774
4124
  }
3775
4125
  };
@@ -3794,6 +4144,25 @@ const BaseTransitionImpl = {
3794
4144
  };
3795
4145
  }
3796
4146
  };
4147
+ function findNonCommentChild(children) {
4148
+ let child = children[0];
4149
+ if (children.length > 1) {
4150
+ let hasFound = false;
4151
+ for (const c of children) {
4152
+ if (c.type !== Comment) {
4153
+ if (hasFound) {
4154
+ warn$1(
4155
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4156
+ );
4157
+ break;
4158
+ }
4159
+ child = c;
4160
+ hasFound = true;
4161
+ }
4162
+ }
4163
+ }
4164
+ return child;
4165
+ }
3797
4166
  const BaseTransition = BaseTransitionImpl;
3798
4167
  function getLeavingNodesForType(state, vnode) {
3799
4168
  const { leavingVNodes } = state;
@@ -3948,8 +4317,11 @@ function emptyPlaceholder(vnode) {
3948
4317
  return vnode;
3949
4318
  }
3950
4319
  }
3951
- function getKeepAliveChild(vnode) {
4320
+ function getInnerChild$1(vnode) {
3952
4321
  if (!isKeepAlive(vnode)) {
4322
+ if (isTeleport(vnode.type) && vnode.children) {
4323
+ return findNonCommentChild(vnode.children);
4324
+ }
3953
4325
  return vnode;
3954
4326
  }
3955
4327
  if (vnode.component) {
@@ -4118,7 +4490,6 @@ function defineAsyncComponent(source) {
4118
4490
  load().then(() => {
4119
4491
  loaded.value = true;
4120
4492
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4121
- instance.parent.effect.dirty = true;
4122
4493
  queueJob(instance.parent.update);
4123
4494
  }
4124
4495
  }).catch((err) => {
@@ -4443,10 +4814,20 @@ function onErrorCaptured(hook, target = currentInstance) {
4443
4814
  function renderList(source, renderItem, cache, index) {
4444
4815
  let ret;
4445
4816
  const cached = cache && cache[index];
4446
- if (isArray(source) || isString(source)) {
4817
+ const sourceIsArray = isArray(source);
4818
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
4819
+ if (sourceIsArray || isString(source)) {
4820
+ if (sourceIsReactiveArray) {
4821
+ source = shallowReadArray(source);
4822
+ }
4447
4823
  ret = new Array(source.length);
4448
4824
  for (let i = 0, l = source.length; i < l; i++) {
4449
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
4825
+ ret[i] = renderItem(
4826
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
4827
+ i,
4828
+ void 0,
4829
+ cached && cached[i]
4830
+ );
4450
4831
  }
4451
4832
  } else if (typeof source === "number") {
4452
4833
  if (!Number.isInteger(source)) {
@@ -4581,7 +4962,6 @@ const publicPropertiesMap = (
4581
4962
  $emit: (i) => i.emit,
4582
4963
  $options: (i) => resolveMergedOptions(i) ,
4583
4964
  $forceUpdate: (i) => i.f || (i.f = () => {
4584
- i.effect.dirty = true;
4585
4965
  queueJob(i.update);
4586
4966
  }),
4587
4967
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -5914,7 +6294,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
5914
6294
  function assertType(value, type) {
5915
6295
  let valid;
5916
6296
  const expectedType = getType(type);
5917
- if (isSimpleType(expectedType)) {
6297
+ if (expectedType === "null") {
6298
+ valid = value === null;
6299
+ } else if (isSimpleType(expectedType)) {
5918
6300
  const t = typeof value;
5919
6301
  valid = t === expectedType.toLowerCase();
5920
6302
  if (!valid && t === "object") {
@@ -5924,8 +6306,6 @@ function assertType(value, type) {
5924
6306
  valid = isObject(value);
5925
6307
  } else if (expectedType === "Array") {
5926
6308
  valid = isArray(value);
5927
- } else if (expectedType === "null") {
5928
- valid = value === null;
5929
6309
  } else {
5930
6310
  valid = value instanceof type;
5931
6311
  }
@@ -7449,7 +7829,6 @@ function baseCreateRenderer(options, createHydrationFns) {
7449
7829
  } else {
7450
7830
  instance.next = n2;
7451
7831
  invalidateJob(instance.update);
7452
- instance.effect.dirty = true;
7453
7832
  instance.update();
7454
7833
  }
7455
7834
  } else {
@@ -7632,24 +8011,18 @@ function baseCreateRenderer(options, createHydrationFns) {
7632
8011
  }
7633
8012
  }
7634
8013
  };
7635
- const effect = instance.effect = new ReactiveEffect(
7636
- componentUpdateFn,
7637
- NOOP,
7638
- () => queueJob(update),
7639
- instance.scope
7640
- // track it in component's effect scope
7641
- );
7642
- const update = instance.update = () => {
7643
- if (effect.dirty) {
7644
- effect.run();
7645
- }
7646
- };
7647
- update.id = instance.uid;
8014
+ instance.scope.on();
8015
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
8016
+ instance.scope.off();
8017
+ const update = instance.update = effect.run.bind(effect);
8018
+ const job = instance.job = effect.runIfDirty.bind(effect);
8019
+ job.id = instance.uid;
8020
+ effect.scheduler = () => queueJob(job);
7648
8021
  toggleRecurse(instance, true);
7649
8022
  {
7650
8023
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
7651
8024
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
7652
- update.ownerInstance = instance;
8025
+ job.ownerInstance = instance;
7653
8026
  }
7654
8027
  update();
7655
8028
  };
@@ -8116,13 +8489,13 @@ function baseCreateRenderer(options, createHydrationFns) {
8116
8489
  if (instance.type.__hmrId) {
8117
8490
  unregisterHMR(instance);
8118
8491
  }
8119
- const { bum, scope, update, subTree, um } = instance;
8492
+ const { bum, scope, job, subTree, um } = instance;
8120
8493
  if (bum) {
8121
8494
  invokeArrayFns(bum);
8122
8495
  }
8123
8496
  scope.stop();
8124
- if (update) {
8125
- update.active = false;
8497
+ if (job) {
8498
+ job.flags |= 8;
8126
8499
  unmount(subTree, instance, parentSuspense, doRemove);
8127
8500
  }
8128
8501
  if (um) {
@@ -8208,8 +8581,14 @@ function baseCreateRenderer(options, createHydrationFns) {
8208
8581
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
8209
8582
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
8210
8583
  }
8211
- function toggleRecurse({ effect, update }, allowed) {
8212
- effect.allowRecurse = update.allowRecurse = allowed;
8584
+ function toggleRecurse({ effect, job }, allowed) {
8585
+ if (allowed) {
8586
+ effect.flags |= 32;
8587
+ job.flags |= 4;
8588
+ } else {
8589
+ effect.flags &= ~32;
8590
+ job.flags &= ~4;
8591
+ }
8213
8592
  }
8214
8593
  function needTransition(parentSuspense, transition) {
8215
8594
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -8946,6 +9325,7 @@ function createComponentInstance(vnode, parent, suspense) {
8946
9325
  effect: null,
8947
9326
  update: null,
8948
9327
  // will be set synchronously right after creation
9328
+ job: null,
8949
9329
  scope: new EffectScope(
8950
9330
  true
8951
9331
  /* detached */
@@ -9439,7 +9819,8 @@ function initCustomFormatter() {
9439
9819
  {},
9440
9820
  ["span", vueStyle, genRefFlag(obj)],
9441
9821
  "<",
9442
- formatValue(obj.value),
9822
+ // avoid debugger accessing value affecting behavior
9823
+ formatValue("_value" in obj ? obj._value : obj),
9443
9824
  `>`
9444
9825
  ];
9445
9826
  } else if (isReactive(obj)) {
@@ -9619,7 +10000,7 @@ function isMemoSame(cached, memo) {
9619
10000
  return true;
9620
10001
  }
9621
10002
 
9622
- const version = "3.4.25";
10003
+ const version = "3.5.0-alpha.1";
9623
10004
  const warn = warn$1 ;
9624
10005
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9625
10006
  const devtools = devtools$1 ;
@@ -11074,7 +11455,9 @@ const withKeys = (fn, modifiers) => {
11074
11455
  return;
11075
11456
  }
11076
11457
  const eventKey = hyphenate(event.key);
11077
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
11458
+ if (modifiers.some(
11459
+ (k) => k === eventKey || keyNames[k] === eventKey
11460
+ )) {
11078
11461
  return fn(event);
11079
11462
  }
11080
11463
  });
@@ -16645,9 +17028,183 @@ const ignoreSideEffectTags = (node, context) => {
16645
17028
  }
16646
17029
  };
16647
17030
 
17031
+ function isValidHTMLNesting(parent, child) {
17032
+ if (parent in onlyValidChildren) {
17033
+ return onlyValidChildren[parent].has(child);
17034
+ }
17035
+ if (child in onlyValidParents) {
17036
+ return onlyValidParents[child].has(parent);
17037
+ }
17038
+ if (parent in knownInvalidChildren) {
17039
+ if (knownInvalidChildren[parent].has(child))
17040
+ return false;
17041
+ }
17042
+ if (child in knownInvalidParents) {
17043
+ if (knownInvalidParents[child].has(parent))
17044
+ return false;
17045
+ }
17046
+ return true;
17047
+ }
17048
+ const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
17049
+ const emptySet = /* @__PURE__ */ new Set([]);
17050
+ const onlyValidChildren = {
17051
+ head: /* @__PURE__ */ new Set([
17052
+ "base",
17053
+ "basefront",
17054
+ "bgsound",
17055
+ "link",
17056
+ "meta",
17057
+ "title",
17058
+ "noscript",
17059
+ "noframes",
17060
+ "style",
17061
+ "script",
17062
+ "template"
17063
+ ]),
17064
+ optgroup: /* @__PURE__ */ new Set(["option"]),
17065
+ select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
17066
+ // table
17067
+ table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
17068
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
17069
+ colgroup: /* @__PURE__ */ new Set(["col"]),
17070
+ tbody: /* @__PURE__ */ new Set(["tr"]),
17071
+ thead: /* @__PURE__ */ new Set(["tr"]),
17072
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
17073
+ // these elements can not have any children elements
17074
+ script: emptySet,
17075
+ iframe: emptySet,
17076
+ option: emptySet,
17077
+ textarea: emptySet,
17078
+ style: emptySet,
17079
+ title: emptySet
17080
+ };
17081
+ const onlyValidParents = {
17082
+ // sections
17083
+ html: emptySet,
17084
+ body: /* @__PURE__ */ new Set(["html"]),
17085
+ head: /* @__PURE__ */ new Set(["html"]),
17086
+ // table
17087
+ td: /* @__PURE__ */ new Set(["tr"]),
17088
+ colgroup: /* @__PURE__ */ new Set(["table"]),
17089
+ caption: /* @__PURE__ */ new Set(["table"]),
17090
+ tbody: /* @__PURE__ */ new Set(["table"]),
17091
+ tfoot: /* @__PURE__ */ new Set(["table"]),
17092
+ col: /* @__PURE__ */ new Set(["colgroup"]),
17093
+ th: /* @__PURE__ */ new Set(["tr"]),
17094
+ thead: /* @__PURE__ */ new Set(["table"]),
17095
+ tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
17096
+ // data list
17097
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
17098
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
17099
+ // other
17100
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
17101
+ // li: new Set(["ul", "ol"]),
17102
+ summary: /* @__PURE__ */ new Set(["details"]),
17103
+ area: /* @__PURE__ */ new Set(["map"])
17104
+ };
17105
+ const knownInvalidChildren = {
17106
+ p: /* @__PURE__ */ new Set([
17107
+ "address",
17108
+ "article",
17109
+ "aside",
17110
+ "blockquote",
17111
+ "center",
17112
+ "details",
17113
+ "dialog",
17114
+ "dir",
17115
+ "div",
17116
+ "dl",
17117
+ "fieldset",
17118
+ "figure",
17119
+ "footer",
17120
+ "form",
17121
+ "h1",
17122
+ "h2",
17123
+ "h3",
17124
+ "h4",
17125
+ "h5",
17126
+ "h6",
17127
+ "header",
17128
+ "hgroup",
17129
+ "hr",
17130
+ "li",
17131
+ "main",
17132
+ "nav",
17133
+ "menu",
17134
+ "ol",
17135
+ "p",
17136
+ "pre",
17137
+ "section",
17138
+ "table",
17139
+ "ul"
17140
+ ]),
17141
+ svg: /* @__PURE__ */ new Set([
17142
+ "b",
17143
+ "blockquote",
17144
+ "br",
17145
+ "code",
17146
+ "dd",
17147
+ "div",
17148
+ "dl",
17149
+ "dt",
17150
+ "em",
17151
+ "embed",
17152
+ "h1",
17153
+ "h2",
17154
+ "h3",
17155
+ "h4",
17156
+ "h5",
17157
+ "h6",
17158
+ "hr",
17159
+ "i",
17160
+ "img",
17161
+ "li",
17162
+ "menu",
17163
+ "meta",
17164
+ "ol",
17165
+ "p",
17166
+ "pre",
17167
+ "ruby",
17168
+ "s",
17169
+ "small",
17170
+ "span",
17171
+ "strong",
17172
+ "sub",
17173
+ "sup",
17174
+ "table",
17175
+ "u",
17176
+ "ul",
17177
+ "var"
17178
+ ])
17179
+ };
17180
+ const knownInvalidParents = {
17181
+ a: /* @__PURE__ */ new Set(["a"]),
17182
+ button: /* @__PURE__ */ new Set(["button"]),
17183
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
17184
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
17185
+ form: /* @__PURE__ */ new Set(["form"]),
17186
+ li: /* @__PURE__ */ new Set(["li"]),
17187
+ h1: headings,
17188
+ h2: headings,
17189
+ h3: headings,
17190
+ h4: headings,
17191
+ h5: headings,
17192
+ h6: headings
17193
+ };
17194
+
17195
+ const validateHtmlNesting = (node, context) => {
17196
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
17197
+ const error = new SyntaxError(
17198
+ `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
17199
+ );
17200
+ error.loc = node.loc;
17201
+ context.onWarn(error);
17202
+ }
17203
+ };
17204
+
16648
17205
  const DOMNodeTransforms = [
16649
17206
  transformStyle,
16650
- ...[transformTransition]
17207
+ ...[transformTransition, validateHtmlNesting]
16651
17208
  ];
16652
17209
  const DOMDirectiveTransforms = {
16653
17210
  cloak: noopDirectiveTransform,