@vue/compat 3.4.26 → 3.5.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.4.26
2
+ * @vue/compat v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -385,156 +385,280 @@ class EffectScope {
385
385
  function effectScope(detached) {
386
386
  return new EffectScope(detached);
387
387
  }
388
- function recordEffectScope(effect, scope = activeEffectScope) {
389
- if (scope && scope.active) {
390
- scope.effects.push(effect);
391
- }
392
- }
393
388
  function getCurrentScope() {
394
389
  return activeEffectScope;
395
390
  }
396
- function onScopeDispose(fn) {
391
+ function onScopeDispose(fn, failSilently = false) {
397
392
  if (activeEffectScope) {
398
393
  activeEffectScope.cleanups.push(fn);
399
- } else {
394
+ } else if (!failSilently) {
400
395
  warn$2(
401
396
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
402
397
  );
403
398
  }
404
399
  }
405
400
 
406
- let activeEffect;
401
+ let activeSub;
407
402
  class ReactiveEffect {
408
- constructor(fn, trigger, scheduler, scope) {
403
+ constructor(fn) {
409
404
  this.fn = fn;
410
- this.trigger = trigger;
411
- this.scheduler = scheduler;
412
- this.active = true;
413
- this.deps = [];
414
405
  /**
415
406
  * @internal
416
407
  */
417
- this._dirtyLevel = 4;
408
+ this.deps = void 0;
418
409
  /**
419
410
  * @internal
420
411
  */
421
- this._trackId = 0;
412
+ this.depsTail = void 0;
422
413
  /**
423
414
  * @internal
424
415
  */
425
- this._runnings = 0;
416
+ this.flags = 1 | 4;
426
417
  /**
427
418
  * @internal
428
419
  */
429
- this._shouldSchedule = false;
420
+ this.nextEffect = void 0;
430
421
  /**
431
422
  * @internal
432
423
  */
433
- this._depsLength = 0;
434
- recordEffectScope(this, scope);
435
- }
436
- get dirty() {
437
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
438
- this._dirtyLevel = 1;
439
- pauseTracking();
440
- for (let i = 0; i < this._depsLength; i++) {
441
- const dep = this.deps[i];
442
- if (dep.computed) {
443
- triggerComputed(dep.computed);
444
- if (this._dirtyLevel >= 4) {
445
- break;
446
- }
447
- }
448
- }
449
- if (this._dirtyLevel === 1) {
450
- this._dirtyLevel = 0;
451
- }
452
- resetTracking();
424
+ this.cleanup = void 0;
425
+ this.scheduler = void 0;
426
+ if (activeEffectScope && activeEffectScope.active) {
427
+ activeEffectScope.effects.push(this);
453
428
  }
454
- return this._dirtyLevel >= 4;
455
429
  }
456
- set dirty(v) {
457
- this._dirtyLevel = v ? 4 : 0;
430
+ /**
431
+ * @internal
432
+ */
433
+ notify() {
434
+ if (this.flags & 2 && !(this.flags & 32)) {
435
+ return;
436
+ }
437
+ if (this.flags & 64) {
438
+ return this.trigger();
439
+ }
440
+ if (!(this.flags & 8)) {
441
+ this.flags |= 8;
442
+ this.nextEffect = batchedEffect;
443
+ batchedEffect = this;
444
+ }
458
445
  }
459
446
  run() {
460
- this._dirtyLevel = 0;
461
- if (!this.active) {
447
+ if (!(this.flags & 1)) {
462
448
  return this.fn();
463
449
  }
464
- let lastShouldTrack = shouldTrack;
465
- let lastEffect = activeEffect;
450
+ this.flags |= 2;
451
+ cleanupEffect(this);
452
+ prepareDeps(this);
453
+ const prevEffect = activeSub;
454
+ const prevShouldTrack = shouldTrack;
455
+ activeSub = this;
456
+ shouldTrack = true;
466
457
  try {
467
- shouldTrack = true;
468
- activeEffect = this;
469
- this._runnings++;
470
- preCleanupEffect(this);
471
458
  return this.fn();
472
459
  } finally {
473
- postCleanupEffect(this);
474
- this._runnings--;
475
- activeEffect = lastEffect;
476
- shouldTrack = lastShouldTrack;
460
+ if (activeSub !== this) {
461
+ warn$2(
462
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
463
+ );
464
+ }
465
+ cleanupDeps(this);
466
+ activeSub = prevEffect;
467
+ shouldTrack = prevShouldTrack;
468
+ this.flags &= ~2;
477
469
  }
478
470
  }
479
471
  stop() {
480
- if (this.active) {
481
- preCleanupEffect(this);
482
- postCleanupEffect(this);
472
+ if (this.flags & 1) {
473
+ for (let link = this.deps; link; link = link.nextDep) {
474
+ removeSub(link);
475
+ }
476
+ this.deps = this.depsTail = void 0;
477
+ cleanupEffect(this);
483
478
  this.onStop && this.onStop();
484
- this.active = false;
479
+ this.flags &= ~1;
485
480
  }
486
481
  }
482
+ trigger() {
483
+ if (this.scheduler) {
484
+ this.scheduler();
485
+ } else {
486
+ this.runIfDirty();
487
+ }
488
+ }
489
+ /**
490
+ * @internal
491
+ */
492
+ runIfDirty() {
493
+ if (isDirty(this)) {
494
+ this.run();
495
+ }
496
+ }
497
+ get dirty() {
498
+ return isDirty(this);
499
+ }
487
500
  }
488
- function triggerComputed(computed) {
489
- return computed.value;
501
+ let batchDepth = 0;
502
+ let batchedEffect;
503
+ function startBatch() {
504
+ batchDepth++;
490
505
  }
491
- function preCleanupEffect(effect2) {
492
- effect2._trackId++;
493
- effect2._depsLength = 0;
506
+ function endBatch() {
507
+ if (batchDepth > 1) {
508
+ batchDepth--;
509
+ return;
510
+ }
511
+ let error;
512
+ while (batchedEffect) {
513
+ let e = batchedEffect;
514
+ batchedEffect = void 0;
515
+ while (e) {
516
+ const next = e.nextEffect;
517
+ e.nextEffect = void 0;
518
+ e.flags &= ~8;
519
+ if (e.flags & 1) {
520
+ try {
521
+ e.trigger();
522
+ } catch (err) {
523
+ if (!error)
524
+ error = err;
525
+ }
526
+ }
527
+ e = next;
528
+ }
529
+ }
530
+ batchDepth--;
531
+ if (error)
532
+ throw error;
494
533
  }
495
- function postCleanupEffect(effect2) {
496
- if (effect2.deps.length > effect2._depsLength) {
497
- for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
498
- cleanupDepEffect(effect2.deps[i], effect2);
534
+ function prepareDeps(sub) {
535
+ for (let link = sub.deps; link; link = link.nextDep) {
536
+ link.version = -1;
537
+ link.prevActiveLink = link.dep.activeLink;
538
+ link.dep.activeLink = link;
539
+ }
540
+ }
541
+ function cleanupDeps(sub) {
542
+ let head;
543
+ let tail = sub.depsTail;
544
+ for (let link = tail; link; link = link.prevDep) {
545
+ if (link.version === -1) {
546
+ if (link === tail)
547
+ tail = link.prevDep;
548
+ removeSub(link);
549
+ removeDep(link);
550
+ } else {
551
+ head = link;
499
552
  }
500
- effect2.deps.length = effect2._depsLength;
553
+ link.dep.activeLink = link.prevActiveLink;
554
+ link.prevActiveLink = void 0;
501
555
  }
556
+ sub.deps = head;
557
+ sub.depsTail = tail;
502
558
  }
503
- function cleanupDepEffect(dep, effect2) {
504
- const trackId = dep.get(effect2);
505
- if (trackId !== void 0 && effect2._trackId !== trackId) {
506
- dep.delete(effect2);
507
- if (dep.size === 0) {
508
- dep.cleanup();
559
+ function isDirty(sub) {
560
+ for (let link = sub.deps; link; link = link.nextDep) {
561
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
562
+ return true;
509
563
  }
510
564
  }
565
+ if (sub._dirty) {
566
+ return true;
567
+ }
568
+ return false;
569
+ }
570
+ function refreshComputed(computed) {
571
+ if (computed.flags & 2) {
572
+ return false;
573
+ }
574
+ if (computed.flags & 4 && !(computed.flags & 16)) {
575
+ return;
576
+ }
577
+ computed.flags &= ~16;
578
+ if (computed.globalVersion === globalVersion) {
579
+ return;
580
+ }
581
+ computed.globalVersion = globalVersion;
582
+ const dep = computed.dep;
583
+ computed.flags |= 2;
584
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
585
+ computed.flags &= ~2;
586
+ return;
587
+ }
588
+ const prevSub = activeSub;
589
+ const prevShouldTrack = shouldTrack;
590
+ activeSub = computed;
591
+ shouldTrack = true;
592
+ try {
593
+ prepareDeps(computed);
594
+ const value = computed.fn();
595
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
596
+ computed._value = value;
597
+ dep.version++;
598
+ }
599
+ } catch (err) {
600
+ dep.version++;
601
+ throw err;
602
+ } finally {
603
+ activeSub = prevSub;
604
+ shouldTrack = prevShouldTrack;
605
+ cleanupDeps(computed);
606
+ computed.flags &= ~2;
607
+ }
608
+ }
609
+ function removeSub(link) {
610
+ const { dep, prevSub, nextSub } = link;
611
+ if (prevSub) {
612
+ prevSub.nextSub = nextSub;
613
+ link.prevSub = void 0;
614
+ }
615
+ if (nextSub) {
616
+ nextSub.prevSub = prevSub;
617
+ link.nextSub = void 0;
618
+ }
619
+ if (dep.subs === link) {
620
+ dep.subs = prevSub;
621
+ }
622
+ if (!dep.subs && dep.computed) {
623
+ dep.computed.flags &= ~4;
624
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
625
+ removeSub(l);
626
+ }
627
+ }
628
+ }
629
+ function removeDep(link) {
630
+ const { prevDep, nextDep } = link;
631
+ if (prevDep) {
632
+ prevDep.nextDep = nextDep;
633
+ link.prevDep = void 0;
634
+ }
635
+ if (nextDep) {
636
+ nextDep.prevDep = prevDep;
637
+ link.nextDep = void 0;
638
+ }
511
639
  }
512
640
  function effect(fn, options) {
513
641
  if (fn.effect instanceof ReactiveEffect) {
514
642
  fn = fn.effect.fn;
515
643
  }
516
- const _effect = new ReactiveEffect(fn, NOOP, () => {
517
- if (_effect.dirty) {
518
- _effect.run();
519
- }
520
- });
644
+ const e = new ReactiveEffect(fn);
521
645
  if (options) {
522
- extend(_effect, options);
523
- if (options.scope)
524
- recordEffectScope(_effect, options.scope);
646
+ extend(e, options);
525
647
  }
526
- if (!options || !options.lazy) {
527
- _effect.run();
648
+ try {
649
+ e.run();
650
+ } catch (err) {
651
+ e.stop();
652
+ throw err;
528
653
  }
529
- const runner = _effect.run.bind(_effect);
530
- runner.effect = _effect;
654
+ const runner = e.run.bind(e);
655
+ runner.effect = e;
531
656
  return runner;
532
657
  }
533
658
  function stop(runner) {
534
659
  runner.effect.stop();
535
660
  }
536
661
  let shouldTrack = true;
537
- let pauseScheduleStack = 0;
538
662
  const trackStack = [];
539
663
  function pauseTracking() {
540
664
  trackStack.push(shouldTrack);
@@ -544,192 +668,414 @@ function resetTracking() {
544
668
  const last = trackStack.pop();
545
669
  shouldTrack = last === void 0 ? true : last;
546
670
  }
547
- function pauseScheduling() {
548
- pauseScheduleStack++;
549
- }
550
- function resetScheduling() {
551
- pauseScheduleStack--;
552
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
553
- queueEffectSchedulers.shift()();
671
+ function cleanupEffect(e) {
672
+ const { cleanup } = e;
673
+ e.cleanup = void 0;
674
+ if (cleanup) {
675
+ const prevSub = activeSub;
676
+ activeSub = void 0;
677
+ try {
678
+ cleanup();
679
+ } finally {
680
+ activeSub = prevSub;
681
+ }
554
682
  }
555
683
  }
556
- function trackEffect(effect2, dep, debuggerEventExtraInfo) {
557
- var _a;
558
- if (dep.get(effect2) !== effect2._trackId) {
559
- dep.set(effect2, effect2._trackId);
560
- const oldDep = effect2.deps[effect2._depsLength];
561
- if (oldDep !== dep) {
562
- if (oldDep) {
563
- cleanupDepEffect(oldDep, effect2);
564
- }
565
- effect2.deps[effect2._depsLength++] = dep;
566
- } else {
567
- effect2._depsLength++;
568
- }
684
+
685
+ let globalVersion = 0;
686
+ class Dep {
687
+ constructor(computed) {
688
+ this.computed = computed;
689
+ this.version = 0;
690
+ /**
691
+ * Link between this dep and the current active effect
692
+ */
693
+ this.activeLink = void 0;
694
+ /**
695
+ * Doubly linked list representing the subscribing effects (tail)
696
+ */
697
+ this.subs = void 0;
569
698
  {
570
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
699
+ this.subsHead = void 0;
571
700
  }
572
701
  }
573
- }
574
- const queueEffectSchedulers = [];
575
- function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
576
- var _a;
577
- pauseScheduling();
578
- for (const effect2 of dep.keys()) {
579
- let tracking;
580
- if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
581
- effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
582
- effect2._dirtyLevel = dirtyLevel;
583
- }
584
- if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
585
- {
586
- (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
702
+ track(debugInfo) {
703
+ if (!activeSub || !shouldTrack) {
704
+ return;
705
+ }
706
+ let link = this.activeLink;
707
+ if (link === void 0 || link.sub !== activeSub) {
708
+ link = this.activeLink = {
709
+ dep: this,
710
+ sub: activeSub,
711
+ version: this.version,
712
+ nextDep: void 0,
713
+ prevDep: void 0,
714
+ nextSub: void 0,
715
+ prevSub: void 0,
716
+ prevActiveLink: void 0
717
+ };
718
+ if (!activeSub.deps) {
719
+ activeSub.deps = activeSub.depsTail = link;
720
+ } else {
721
+ link.prevDep = activeSub.depsTail;
722
+ activeSub.depsTail.nextDep = link;
723
+ activeSub.depsTail = link;
724
+ }
725
+ if (activeSub.flags & 4) {
726
+ addSub(link);
587
727
  }
588
- effect2.trigger();
589
- if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
590
- effect2._shouldSchedule = false;
591
- if (effect2.scheduler) {
592
- queueEffectSchedulers.push(effect2.scheduler);
728
+ } else if (link.version === -1) {
729
+ link.version = this.version;
730
+ if (link.nextDep) {
731
+ const next = link.nextDep;
732
+ next.prevDep = link.prevDep;
733
+ if (link.prevDep) {
734
+ link.prevDep.nextDep = next;
593
735
  }
736
+ link.prevDep = activeSub.depsTail;
737
+ link.nextDep = void 0;
738
+ activeSub.depsTail.nextDep = link;
739
+ activeSub.depsTail = link;
740
+ if (activeSub.deps === link) {
741
+ activeSub.deps = next;
742
+ }
743
+ }
744
+ }
745
+ if (activeSub.onTrack) {
746
+ activeSub.onTrack(
747
+ extend(
748
+ {
749
+ effect: activeSub
750
+ },
751
+ debugInfo
752
+ )
753
+ );
754
+ }
755
+ return link;
756
+ }
757
+ trigger(debugInfo) {
758
+ this.version++;
759
+ globalVersion++;
760
+ this.notify(debugInfo);
761
+ }
762
+ notify(debugInfo) {
763
+ startBatch();
764
+ try {
765
+ if (true) {
766
+ for (let head = this.subsHead; head; head = head.nextSub) {
767
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
768
+ head.sub.onTrigger(
769
+ extend(
770
+ {
771
+ effect: head.sub
772
+ },
773
+ debugInfo
774
+ )
775
+ );
776
+ }
777
+ }
778
+ }
779
+ for (let link = this.subs; link; link = link.prevSub) {
780
+ link.sub.notify();
594
781
  }
782
+ } finally {
783
+ endBatch();
595
784
  }
596
785
  }
597
- resetScheduling();
598
786
  }
599
-
600
- const createDep = (cleanup, computed) => {
601
- const dep = /* @__PURE__ */ new Map();
602
- dep.cleanup = cleanup;
603
- dep.computed = computed;
604
- return dep;
605
- };
606
-
787
+ function addSub(link) {
788
+ const computed = link.dep.computed;
789
+ if (computed && !link.dep.subs) {
790
+ computed.flags |= 4 | 16;
791
+ for (let l = computed.deps; l; l = l.nextDep) {
792
+ addSub(l);
793
+ }
794
+ }
795
+ const currentTail = link.dep.subs;
796
+ if (currentTail !== link) {
797
+ link.prevSub = currentTail;
798
+ if (currentTail)
799
+ currentTail.nextSub = link;
800
+ }
801
+ if (link.dep.subsHead === void 0) {
802
+ link.dep.subsHead = link;
803
+ }
804
+ link.dep.subs = link;
805
+ }
607
806
  const targetMap = /* @__PURE__ */ new WeakMap();
608
- const ITERATE_KEY = Symbol("iterate" );
609
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
807
+ const ITERATE_KEY = Symbol("Object iterate" );
808
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
809
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
610
810
  function track(target, type, key) {
611
- if (shouldTrack && activeEffect) {
811
+ if (shouldTrack && activeSub) {
612
812
  let depsMap = targetMap.get(target);
613
813
  if (!depsMap) {
614
814
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
615
815
  }
616
816
  let dep = depsMap.get(key);
617
817
  if (!dep) {
618
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
818
+ depsMap.set(key, dep = new Dep());
619
819
  }
620
- trackEffect(
621
- activeEffect,
622
- dep,
623
- {
820
+ {
821
+ dep.track({
624
822
  target,
625
823
  type,
626
824
  key
627
- }
628
- );
825
+ });
826
+ }
629
827
  }
630
828
  }
631
829
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
632
830
  const depsMap = targetMap.get(target);
633
831
  if (!depsMap) {
832
+ globalVersion++;
634
833
  return;
635
834
  }
636
835
  let deps = [];
637
836
  if (type === "clear") {
638
837
  deps = [...depsMap.values()];
639
- } else if (key === "length" && isArray(target)) {
640
- const newLength = Number(newValue);
641
- depsMap.forEach((dep, key2) => {
642
- if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
643
- deps.push(dep);
644
- }
645
- });
646
838
  } else {
647
- if (key !== void 0) {
648
- deps.push(depsMap.get(key));
649
- }
650
- switch (type) {
651
- case "add":
652
- if (!isArray(target)) {
653
- deps.push(depsMap.get(ITERATE_KEY));
654
- if (isMap(target)) {
655
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
656
- }
657
- } else if (isIntegerKey(key)) {
658
- deps.push(depsMap.get("length"));
839
+ const targetIsArray = isArray(target);
840
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
841
+ if (targetIsArray && key === "length") {
842
+ const newLength = Number(newValue);
843
+ depsMap.forEach((dep, key2) => {
844
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
845
+ deps.push(dep);
659
846
  }
660
- break;
661
- case "delete":
662
- if (!isArray(target)) {
663
- deps.push(depsMap.get(ITERATE_KEY));
847
+ });
848
+ } else {
849
+ const push = (dep) => dep && deps.push(dep);
850
+ if (key !== void 0) {
851
+ push(depsMap.get(key));
852
+ }
853
+ if (isArrayIndex) {
854
+ push(depsMap.get(ARRAY_ITERATE_KEY));
855
+ }
856
+ switch (type) {
857
+ case "add":
858
+ if (!targetIsArray) {
859
+ push(depsMap.get(ITERATE_KEY));
860
+ if (isMap(target)) {
861
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
862
+ }
863
+ } else if (isArrayIndex) {
864
+ push(depsMap.get("length"));
865
+ }
866
+ break;
867
+ case "delete":
868
+ if (!targetIsArray) {
869
+ push(depsMap.get(ITERATE_KEY));
870
+ if (isMap(target)) {
871
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
872
+ }
873
+ }
874
+ break;
875
+ case "set":
664
876
  if (isMap(target)) {
665
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
877
+ push(depsMap.get(ITERATE_KEY));
666
878
  }
667
- }
668
- break;
669
- case "set":
670
- if (isMap(target)) {
671
- deps.push(depsMap.get(ITERATE_KEY));
672
- }
673
- break;
879
+ break;
880
+ }
674
881
  }
675
882
  }
676
- pauseScheduling();
883
+ startBatch();
677
884
  for (const dep of deps) {
678
- if (dep) {
679
- triggerEffects(
680
- dep,
681
- 4,
682
- {
683
- target,
684
- type,
685
- key,
686
- newValue,
687
- oldValue,
688
- oldTarget
689
- }
690
- );
885
+ {
886
+ dep.trigger({
887
+ target,
888
+ type,
889
+ key,
890
+ newValue,
891
+ oldValue,
892
+ oldTarget
893
+ });
691
894
  }
692
895
  }
693
- resetScheduling();
896
+ endBatch();
694
897
  }
695
898
  function getDepFromReactive(object, key) {
696
- const depsMap = targetMap.get(object);
697
- return depsMap && depsMap.get(key);
899
+ var _a;
900
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
901
+ }
902
+
903
+ function reactiveReadArray(array) {
904
+ const raw = toRaw(array);
905
+ if (raw === array)
906
+ return raw;
907
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
908
+ return isShallow(array) ? raw : raw.map(toReactive);
909
+ }
910
+ function shallowReadArray(arr) {
911
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
912
+ return arr;
913
+ }
914
+ const arrayInstrumentations = {
915
+ __proto__: null,
916
+ [Symbol.iterator]() {
917
+ return iterator(this, Symbol.iterator, toReactive);
918
+ },
919
+ concat(...args) {
920
+ return reactiveReadArray(this).concat(
921
+ ...args.map((x) => reactiveReadArray(x))
922
+ );
923
+ },
924
+ entries() {
925
+ return iterator(this, "entries", (value) => {
926
+ value[1] = toReactive(value[1]);
927
+ return value;
928
+ });
929
+ },
930
+ every(fn, thisArg) {
931
+ return apply(this, "every", fn, thisArg);
932
+ },
933
+ filter(fn, thisArg) {
934
+ const result = apply(this, "filter", fn, thisArg);
935
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
936
+ },
937
+ find(fn, thisArg) {
938
+ const result = apply(this, "find", fn, thisArg);
939
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
940
+ },
941
+ findIndex(fn, thisArg) {
942
+ return apply(this, "findIndex", fn, thisArg);
943
+ },
944
+ findLast(fn, thisArg) {
945
+ const result = apply(this, "findLast", fn, thisArg);
946
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
947
+ },
948
+ findLastIndex(fn, thisArg) {
949
+ return apply(this, "findLastIndex", fn, thisArg);
950
+ },
951
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
952
+ forEach(fn, thisArg) {
953
+ return apply(this, "forEach", fn, thisArg);
954
+ },
955
+ includes(...args) {
956
+ return searchProxy(this, "includes", args);
957
+ },
958
+ indexOf(...args) {
959
+ return searchProxy(this, "indexOf", args);
960
+ },
961
+ join(separator) {
962
+ return reactiveReadArray(this).join(separator);
963
+ },
964
+ // keys() iterator only reads `length`, no optimisation required
965
+ lastIndexOf(...args) {
966
+ return searchProxy(this, "lastIndexOf", args);
967
+ },
968
+ map(fn, thisArg) {
969
+ return apply(this, "map", fn, thisArg);
970
+ },
971
+ pop() {
972
+ return noTracking(this, "pop");
973
+ },
974
+ push(...args) {
975
+ return noTracking(this, "push", args);
976
+ },
977
+ reduce(fn, ...args) {
978
+ return reduce(this, "reduce", fn, args);
979
+ },
980
+ reduceRight(fn, ...args) {
981
+ return reduce(this, "reduceRight", fn, args);
982
+ },
983
+ shift() {
984
+ return noTracking(this, "shift");
985
+ },
986
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
987
+ some(fn, thisArg) {
988
+ return apply(this, "some", fn, thisArg);
989
+ },
990
+ splice(...args) {
991
+ return noTracking(this, "splice", args);
992
+ },
993
+ toReversed() {
994
+ return reactiveReadArray(this).toReversed();
995
+ },
996
+ toSorted(comparer) {
997
+ return reactiveReadArray(this).toSorted(comparer);
998
+ },
999
+ toSpliced(...args) {
1000
+ return reactiveReadArray(this).toSpliced(...args);
1001
+ },
1002
+ unshift(...args) {
1003
+ return noTracking(this, "unshift", args);
1004
+ },
1005
+ values() {
1006
+ return iterator(this, "values", toReactive);
1007
+ }
1008
+ };
1009
+ function iterator(self, method, wrapValue) {
1010
+ const arr = shallowReadArray(self);
1011
+ const iter = arr[method]();
1012
+ if (arr !== self && !isShallow(self)) {
1013
+ iter._next = iter.next;
1014
+ iter.next = () => {
1015
+ const result = iter._next();
1016
+ if (result.value) {
1017
+ result.value = wrapValue(result.value);
1018
+ }
1019
+ return result;
1020
+ };
1021
+ }
1022
+ return iter;
1023
+ }
1024
+ function apply(self, method, fn, thisArg) {
1025
+ const arr = shallowReadArray(self);
1026
+ let wrappedFn = fn;
1027
+ if (arr !== self) {
1028
+ if (!isShallow(self)) {
1029
+ wrappedFn = function(item, index) {
1030
+ return fn.call(this, toReactive(item), index, self);
1031
+ };
1032
+ } else if (fn.length > 2) {
1033
+ wrappedFn = function(item, index) {
1034
+ return fn.call(this, item, index, self);
1035
+ };
1036
+ }
1037
+ }
1038
+ return arr[method](wrappedFn, thisArg);
1039
+ }
1040
+ function reduce(self, method, fn, args) {
1041
+ const arr = shallowReadArray(self);
1042
+ let wrappedFn = fn;
1043
+ if (arr !== self) {
1044
+ if (!isShallow(self)) {
1045
+ wrappedFn = function(acc, item, index) {
1046
+ return fn.call(this, acc, toReactive(item), index, self);
1047
+ };
1048
+ } else if (fn.length > 3) {
1049
+ wrappedFn = function(acc, item, index) {
1050
+ return fn.call(this, acc, item, index, self);
1051
+ };
1052
+ }
1053
+ }
1054
+ return arr[method](wrappedFn, ...args);
1055
+ }
1056
+ function searchProxy(self, method, args) {
1057
+ const arr = toRaw(self);
1058
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1059
+ const res = arr[method](...args);
1060
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1061
+ args[0] = toRaw(args[0]);
1062
+ return arr[method](...args);
1063
+ }
1064
+ return res;
1065
+ }
1066
+ function noTracking(self, method, args = []) {
1067
+ pauseTracking();
1068
+ startBatch();
1069
+ const res = toRaw(self)[method].apply(self, args);
1070
+ endBatch();
1071
+ resetTracking();
1072
+ return res;
698
1073
  }
699
1074
 
700
1075
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
701
1076
  const builtInSymbols = new Set(
702
1077
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
703
1078
  );
704
- const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
705
- function createArrayInstrumentations() {
706
- const instrumentations = {};
707
- ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
708
- instrumentations[key] = function(...args) {
709
- const arr = toRaw(this);
710
- for (let i = 0, l = this.length; i < l; i++) {
711
- track(arr, "get", i + "");
712
- }
713
- const res = arr[key](...args);
714
- if (res === -1 || res === false) {
715
- return arr[key](...args.map(toRaw));
716
- } else {
717
- return res;
718
- }
719
- };
720
- });
721
- ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
722
- instrumentations[key] = function(...args) {
723
- pauseTracking();
724
- pauseScheduling();
725
- const res = toRaw(this)[key].apply(this, args);
726
- resetScheduling();
727
- resetTracking();
728
- return res;
729
- };
730
- });
731
- return instrumentations;
732
- }
733
1079
  function hasOwnProperty(key) {
734
1080
  if (!isSymbol(key))
735
1081
  key = String(key);
@@ -760,14 +1106,22 @@ class BaseReactiveHandler {
760
1106
  }
761
1107
  const targetIsArray = isArray(target);
762
1108
  if (!isReadonly2) {
763
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
764
- return Reflect.get(arrayInstrumentations, key, receiver);
1109
+ let fn;
1110
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1111
+ return fn;
765
1112
  }
766
1113
  if (key === "hasOwnProperty") {
767
1114
  return hasOwnProperty;
768
1115
  }
769
1116
  }
770
- const res = Reflect.get(target, key, receiver);
1117
+ const res = Reflect.get(
1118
+ target,
1119
+ key,
1120
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1121
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1122
+ // its class methods
1123
+ isRef(target) ? target : receiver
1124
+ );
771
1125
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
772
1126
  return res;
773
1127
  }
@@ -1266,110 +1620,8 @@ function markRaw(value) {
1266
1620
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1267
1621
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1268
1622
 
1269
- 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`;
1270
- class ComputedRefImpl {
1271
- constructor(getter, _setter, isReadonly, isSSR) {
1272
- this.getter = getter;
1273
- this._setter = _setter;
1274
- this.dep = void 0;
1275
- this.__v_isRef = true;
1276
- this["__v_isReadonly"] = false;
1277
- this.effect = new ReactiveEffect(
1278
- () => getter(this._value),
1279
- () => triggerRefValue(
1280
- this,
1281
- this.effect._dirtyLevel === 2 ? 2 : 3
1282
- )
1283
- );
1284
- this.effect.computed = this;
1285
- this.effect.active = this._cacheable = !isSSR;
1286
- this["__v_isReadonly"] = isReadonly;
1287
- }
1288
- get value() {
1289
- const self = toRaw(this);
1290
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1291
- triggerRefValue(self, 4);
1292
- }
1293
- trackRefValue(self);
1294
- if (self.effect._dirtyLevel >= 2) {
1295
- if (this._warnRecursive) {
1296
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1297
-
1298
- getter: `, this.getter);
1299
- }
1300
- triggerRefValue(self, 2);
1301
- }
1302
- return self._value;
1303
- }
1304
- set value(newValue) {
1305
- this._setter(newValue);
1306
- }
1307
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1308
- get _dirty() {
1309
- return this.effect.dirty;
1310
- }
1311
- set _dirty(v) {
1312
- this.effect.dirty = v;
1313
- }
1314
- // #endregion
1315
- }
1316
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1317
- let getter;
1318
- let setter;
1319
- const onlyGetter = isFunction(getterOrOptions);
1320
- if (onlyGetter) {
1321
- getter = getterOrOptions;
1322
- setter = () => {
1323
- warn$2("Write operation failed: computed value is readonly");
1324
- } ;
1325
- } else {
1326
- getter = getterOrOptions.get;
1327
- setter = getterOrOptions.set;
1328
- }
1329
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1330
- if (debugOptions && !isSSR) {
1331
- cRef.effect.onTrack = debugOptions.onTrack;
1332
- cRef.effect.onTrigger = debugOptions.onTrigger;
1333
- }
1334
- return cRef;
1335
- }
1336
-
1337
- function trackRefValue(ref2) {
1338
- var _a;
1339
- if (shouldTrack && activeEffect) {
1340
- ref2 = toRaw(ref2);
1341
- trackEffect(
1342
- activeEffect,
1343
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1344
- () => ref2.dep = void 0,
1345
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1346
- ),
1347
- {
1348
- target: ref2,
1349
- type: "get",
1350
- key: "value"
1351
- }
1352
- );
1353
- }
1354
- }
1355
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1356
- ref2 = toRaw(ref2);
1357
- const dep = ref2.dep;
1358
- if (dep) {
1359
- triggerEffects(
1360
- dep,
1361
- dirtyLevel,
1362
- {
1363
- target: ref2,
1364
- type: "set",
1365
- key: "value",
1366
- newValue: newVal
1367
- }
1368
- );
1369
- }
1370
- }
1371
1623
  function isRef(r) {
1372
- return !!(r && r.__v_isRef === true);
1624
+ return r ? r.__v_isRef === true : false;
1373
1625
  }
1374
1626
  function ref(value) {
1375
1627
  return createRef(value, false);
@@ -1386,27 +1638,49 @@ function createRef(rawValue, shallow) {
1386
1638
  class RefImpl {
1387
1639
  constructor(value, __v_isShallow) {
1388
1640
  this.__v_isShallow = __v_isShallow;
1389
- this.dep = void 0;
1641
+ this.dep = new Dep();
1390
1642
  this.__v_isRef = true;
1391
1643
  this._rawValue = __v_isShallow ? value : toRaw(value);
1392
1644
  this._value = __v_isShallow ? value : toReactive(value);
1393
1645
  }
1394
1646
  get value() {
1395
- trackRefValue(this);
1647
+ {
1648
+ this.dep.track({
1649
+ target: this,
1650
+ type: "get",
1651
+ key: "value"
1652
+ });
1653
+ }
1396
1654
  return this._value;
1397
1655
  }
1398
- set value(newVal) {
1399
- const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
1400
- newVal = useDirectValue ? newVal : toRaw(newVal);
1401
- if (hasChanged(newVal, this._rawValue)) {
1402
- this._rawValue = newVal;
1403
- this._value = useDirectValue ? newVal : toReactive(newVal);
1404
- triggerRefValue(this, 4, newVal);
1656
+ set value(newValue) {
1657
+ const oldValue = this._rawValue;
1658
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1659
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1660
+ if (hasChanged(newValue, oldValue)) {
1661
+ this._rawValue = newValue;
1662
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1663
+ {
1664
+ this.dep.trigger({
1665
+ target: this,
1666
+ type: "set",
1667
+ key: "value",
1668
+ newValue,
1669
+ oldValue
1670
+ });
1671
+ }
1405
1672
  }
1406
1673
  }
1407
1674
  }
1408
1675
  function triggerRef(ref2) {
1409
- triggerRefValue(ref2, 4, ref2.value );
1676
+ {
1677
+ ref2.dep.trigger({
1678
+ target: ref2,
1679
+ type: "set",
1680
+ key: "value",
1681
+ newValue: ref2._value
1682
+ });
1683
+ }
1410
1684
  }
1411
1685
  function unref(ref2) {
1412
1686
  return isRef(ref2) ? ref2.value : ref2;
@@ -1431,12 +1705,9 @@ function proxyRefs(objectWithRefs) {
1431
1705
  }
1432
1706
  class CustomRefImpl {
1433
1707
  constructor(factory) {
1434
- this.dep = void 0;
1435
1708
  this.__v_isRef = true;
1436
- const { get, set } = factory(
1437
- () => trackRefValue(this),
1438
- () => triggerRefValue(this)
1439
- );
1709
+ const dep = this.dep = new Dep();
1710
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1440
1711
  this._get = get;
1441
1712
  this._set = set;
1442
1713
  }
@@ -1504,6 +1775,90 @@ function propertyToRef(source, key, defaultValue) {
1504
1775
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1505
1776
  }
1506
1777
 
1778
+ class ComputedRefImpl {
1779
+ constructor(fn, setter, isSSR) {
1780
+ this.fn = fn;
1781
+ this.setter = setter;
1782
+ /**
1783
+ * @internal
1784
+ */
1785
+ this._value = void 0;
1786
+ /**
1787
+ * @internal
1788
+ */
1789
+ this.dep = new Dep(this);
1790
+ /**
1791
+ * @internal
1792
+ */
1793
+ this.__v_isRef = true;
1794
+ // A computed is also a subscriber that tracks other deps
1795
+ /**
1796
+ * @internal
1797
+ */
1798
+ this.deps = void 0;
1799
+ /**
1800
+ * @internal
1801
+ */
1802
+ this.depsTail = void 0;
1803
+ /**
1804
+ * @internal
1805
+ */
1806
+ this.flags = 16;
1807
+ /**
1808
+ * @internal
1809
+ */
1810
+ this.globalVersion = globalVersion - 1;
1811
+ // for backwards compat
1812
+ this.effect = this;
1813
+ this.__v_isReadonly = !setter;
1814
+ this.isSSR = isSSR;
1815
+ }
1816
+ /**
1817
+ * @internal
1818
+ */
1819
+ notify() {
1820
+ if (activeSub !== this) {
1821
+ this.flags |= 16;
1822
+ this.dep.notify();
1823
+ }
1824
+ }
1825
+ get value() {
1826
+ const link = this.dep.track({
1827
+ target: this,
1828
+ type: "get",
1829
+ key: "value"
1830
+ }) ;
1831
+ refreshComputed(this);
1832
+ if (link) {
1833
+ link.version = this.dep.version;
1834
+ }
1835
+ return this._value;
1836
+ }
1837
+ set value(newValue) {
1838
+ if (this.setter) {
1839
+ this.setter(newValue);
1840
+ } else {
1841
+ warn$2("Write operation failed: computed value is readonly");
1842
+ }
1843
+ }
1844
+ }
1845
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1846
+ let getter;
1847
+ let setter;
1848
+ if (isFunction(getterOrOptions)) {
1849
+ getter = getterOrOptions;
1850
+ } else {
1851
+ getter = getterOrOptions.get;
1852
+ setter = getterOrOptions.set;
1853
+ }
1854
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1855
+ if (debugOptions && !isSSR) {
1856
+ cRef.onTrack = debugOptions.onTrack;
1857
+ cRef.onTrigger = debugOptions.onTrigger;
1858
+ }
1859
+ return cRef;
1860
+ }
1861
+
1507
1862
  const TrackOpTypes = {
1508
1863
  "GET": "get",
1509
1864
  "HAS": "has",
@@ -1663,7 +2018,9 @@ const ErrorCodes = {
1663
2018
  "ASYNC_COMPONENT_LOADER": 13,
1664
2019
  "13": "ASYNC_COMPONENT_LOADER",
1665
2020
  "SCHEDULER": 14,
1666
- "14": "SCHEDULER"
2021
+ "14": "SCHEDULER",
2022
+ "APP_UNMOUNT_CLEANUP": 15,
2023
+ "15": "APP_UNMOUNT_CLEANUP"
1667
2024
  };
1668
2025
  const ErrorTypeStrings$1 = {
1669
2026
  ["sp"]: "serverPrefetch hook",
@@ -1694,7 +2051,8 @@ const ErrorTypeStrings$1 = {
1694
2051
  [11]: "app warnHandler",
1695
2052
  [12]: "ref function",
1696
2053
  [13]: "async component loader",
1697
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2054
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2055
+ [15]: "app unmount cleanup function"
1698
2056
  };
1699
2057
  function callWithErrorHandling(fn, instance, type, args) {
1700
2058
  try {
@@ -1796,7 +2154,7 @@ function findInsertionIndex(id) {
1796
2154
  const middle = start + end >>> 1;
1797
2155
  const middleJob = queue[middle];
1798
2156
  const middleJobId = getId(middleJob);
1799
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2157
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1800
2158
  start = middle + 1;
1801
2159
  } else {
1802
2160
  end = middle;
@@ -1805,15 +2163,21 @@ function findInsertionIndex(id) {
1805
2163
  return start;
1806
2164
  }
1807
2165
  function queueJob(job) {
1808
- if (!queue.length || !queue.includes(
1809
- job,
1810
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1811
- )) {
2166
+ var _a;
2167
+ if (!(job.flags & 1)) {
1812
2168
  if (job.id == null) {
1813
2169
  queue.push(job);
2170
+ } else if (
2171
+ // fast path when the job id is larger than the tail
2172
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2173
+ ) {
2174
+ queue.push(job);
1814
2175
  } else {
1815
2176
  queue.splice(findInsertionIndex(job.id), 0, job);
1816
2177
  }
2178
+ if (!(job.flags & 4)) {
2179
+ job.flags |= 1;
2180
+ }
1817
2181
  queueFlush();
1818
2182
  }
1819
2183
  }
@@ -1831,11 +2195,11 @@ function invalidateJob(job) {
1831
2195
  }
1832
2196
  function queuePostFlushCb(cb) {
1833
2197
  if (!isArray(cb)) {
1834
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1835
- cb,
1836
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1837
- )) {
2198
+ if (!(cb.flags & 1)) {
1838
2199
  pendingPostFlushCbs.push(cb);
2200
+ if (!(cb.flags & 4)) {
2201
+ cb.flags |= 1;
2202
+ }
1839
2203
  }
1840
2204
  } else {
1841
2205
  pendingPostFlushCbs.push(...cb);
@@ -1848,7 +2212,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1848
2212
  }
1849
2213
  for (; i < queue.length; i++) {
1850
2214
  const cb = queue[i];
1851
- if (cb && cb.pre) {
2215
+ if (cb && cb.flags & 2) {
1852
2216
  if (instance && cb.id !== instance.uid) {
1853
2217
  continue;
1854
2218
  }
@@ -1858,6 +2222,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1858
2222
  queue.splice(i, 1);
1859
2223
  i--;
1860
2224
  cb();
2225
+ cb.flags &= ~1;
1861
2226
  }
1862
2227
  }
1863
2228
  }
@@ -1880,6 +2245,7 @@ function flushPostFlushCbs(seen) {
1880
2245
  continue;
1881
2246
  }
1882
2247
  activePostFlushCbs[postFlushIndex]();
2248
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1883
2249
  }
1884
2250
  activePostFlushCbs = null;
1885
2251
  postFlushIndex = 0;
@@ -1889,9 +2255,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
1889
2255
  const comparator = (a, b) => {
1890
2256
  const diff = getId(a) - getId(b);
1891
2257
  if (diff === 0) {
1892
- if (a.pre && !b.pre)
2258
+ const isAPre = a.flags & 2;
2259
+ const isBPre = b.flags & 2;
2260
+ if (isAPre && !isBPre)
1893
2261
  return -1;
1894
- if (b.pre && !a.pre)
2262
+ if (isBPre && !isAPre)
1895
2263
  return 1;
1896
2264
  }
1897
2265
  return diff;
@@ -1907,11 +2275,12 @@ function flushJobs(seen) {
1907
2275
  try {
1908
2276
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1909
2277
  const job = queue[flushIndex];
1910
- if (job && job.active !== false) {
2278
+ if (job && !(job.flags & 8)) {
1911
2279
  if (check(job)) {
1912
2280
  continue;
1913
2281
  }
1914
2282
  callWithErrorHandling(job, null, 14);
2283
+ job.flags &= ~1;
1915
2284
  }
1916
2285
  }
1917
2286
  } finally {
@@ -1993,7 +2362,6 @@ function rerender(id, newRender) {
1993
2362
  }
1994
2363
  instance.renderCache = [];
1995
2364
  isHmrUpdating = true;
1996
- instance.effect.dirty = true;
1997
2365
  instance.update();
1998
2366
  isHmrUpdating = false;
1999
2367
  });
@@ -2021,7 +2389,6 @@ function reload(id, newComp) {
2021
2389
  instance.ceReload(newComp.styles);
2022
2390
  hmrDirtyComponents.delete(oldComp);
2023
2391
  } else if (instance.parent) {
2024
- instance.parent.effect.dirty = true;
2025
2392
  queueJob(instance.parent.update);
2026
2393
  } else if (instance.appContext.reload) {
2027
2394
  instance.appContext.reload();
@@ -3996,8 +4363,8 @@ function doWatch(source, cb, {
3996
4363
  };
3997
4364
  };
3998
4365
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3999
- const job = () => {
4000
- if (!effect.active || !effect.dirty) {
4366
+ const job = (immediateFirstRun) => {
4367
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4001
4368
  return;
4002
4369
  }
4003
4370
  if (cb) {
@@ -4018,19 +4385,22 @@ function doWatch(source, cb, {
4018
4385
  effect.run();
4019
4386
  }
4020
4387
  };
4021
- job.allowRecurse = !!cb;
4388
+ if (cb)
4389
+ job.flags |= 4;
4390
+ const effect = new ReactiveEffect(getter);
4022
4391
  let scheduler;
4023
4392
  if (flush === "sync") {
4393
+ effect.flags |= 64;
4024
4394
  scheduler = job;
4025
4395
  } else if (flush === "post") {
4026
4396
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4027
4397
  } else {
4028
- job.pre = true;
4398
+ job.flags |= 2;
4029
4399
  if (instance)
4030
4400
  job.id = instance.uid;
4031
4401
  scheduler = () => queueJob(job);
4032
4402
  }
4033
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4403
+ effect.scheduler = scheduler;
4034
4404
  const scope = getCurrentScope();
4035
4405
  const unwatch = () => {
4036
4406
  effect.stop();
@@ -4044,7 +4414,7 @@ function doWatch(source, cb, {
4044
4414
  }
4045
4415
  if (cb) {
4046
4416
  if (immediate) {
4047
- job();
4417
+ job(true);
4048
4418
  } else {
4049
4419
  oldValue = effect.run();
4050
4420
  }
@@ -4221,22 +4591,7 @@ const BaseTransitionImpl = {
4221
4591
  if (!children || !children.length) {
4222
4592
  return;
4223
4593
  }
4224
- let child = children[0];
4225
- if (children.length > 1) {
4226
- let hasFound = false;
4227
- for (const c of children) {
4228
- if (c.type !== Comment) {
4229
- if (hasFound) {
4230
- warn$1(
4231
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4232
- );
4233
- break;
4234
- }
4235
- child = c;
4236
- hasFound = true;
4237
- }
4238
- }
4239
- }
4594
+ const child = findNonCommentChild(children);
4240
4595
  const rawProps = toRaw(props);
4241
4596
  const { mode } = rawProps;
4242
4597
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4245,7 +4600,7 @@ const BaseTransitionImpl = {
4245
4600
  if (state.isLeaving) {
4246
4601
  return emptyPlaceholder(child);
4247
4602
  }
4248
- const innerChild = getKeepAliveChild(child);
4603
+ const innerChild = getInnerChild$1(child);
4249
4604
  if (!innerChild) {
4250
4605
  return emptyPlaceholder(child);
4251
4606
  }
@@ -4257,7 +4612,7 @@ const BaseTransitionImpl = {
4257
4612
  );
4258
4613
  setTransitionHooks(innerChild, enterHooks);
4259
4614
  const oldChild = instance.subTree;
4260
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4615
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4261
4616
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4262
4617
  const leavingHooks = resolveTransitionHooks(
4263
4618
  oldInnerChild,
@@ -4270,8 +4625,7 @@ const BaseTransitionImpl = {
4270
4625
  state.isLeaving = true;
4271
4626
  leavingHooks.afterLeave = () => {
4272
4627
  state.isLeaving = false;
4273
- if (instance.update.active !== false) {
4274
- instance.effect.dirty = true;
4628
+ if (!(instance.job.flags & 8)) {
4275
4629
  instance.update();
4276
4630
  }
4277
4631
  };
@@ -4299,6 +4653,25 @@ const BaseTransitionImpl = {
4299
4653
  {
4300
4654
  BaseTransitionImpl.__isBuiltIn = true;
4301
4655
  }
4656
+ function findNonCommentChild(children) {
4657
+ let child = children[0];
4658
+ if (children.length > 1) {
4659
+ let hasFound = false;
4660
+ for (const c of children) {
4661
+ if (c.type !== Comment) {
4662
+ if (hasFound) {
4663
+ warn$1(
4664
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4665
+ );
4666
+ break;
4667
+ }
4668
+ child = c;
4669
+ hasFound = true;
4670
+ }
4671
+ }
4672
+ }
4673
+ return child;
4674
+ }
4302
4675
  const BaseTransition = BaseTransitionImpl;
4303
4676
  function getLeavingNodesForType(state, vnode) {
4304
4677
  const { leavingVNodes } = state;
@@ -4453,8 +4826,11 @@ function emptyPlaceholder(vnode) {
4453
4826
  return vnode;
4454
4827
  }
4455
4828
  }
4456
- function getKeepAliveChild(vnode) {
4829
+ function getInnerChild$1(vnode) {
4457
4830
  if (!isKeepAlive(vnode)) {
4831
+ if (isTeleport(vnode.type) && vnode.children) {
4832
+ return findNonCommentChild(vnode.children);
4833
+ }
4458
4834
  return vnode;
4459
4835
  }
4460
4836
  if (vnode.component) {
@@ -4623,7 +4999,6 @@ function defineAsyncComponent(source) {
4623
4999
  load().then(() => {
4624
5000
  loaded.value = true;
4625
5001
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4626
- instance.parent.effect.dirty = true;
4627
5002
  queueJob(instance.parent.update);
4628
5003
  }
4629
5004
  }).catch((err) => {
@@ -5235,10 +5610,20 @@ function convertLegacyFunctionalComponent(comp) {
5235
5610
  function renderList(source, renderItem, cache, index) {
5236
5611
  let ret;
5237
5612
  const cached = cache && cache[index];
5238
- if (isArray(source) || isString(source)) {
5613
+ const sourceIsArray = isArray(source);
5614
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5615
+ if (sourceIsArray || isString(source)) {
5616
+ if (sourceIsReactiveArray) {
5617
+ source = shallowReadArray(source);
5618
+ }
5239
5619
  ret = new Array(source.length);
5240
5620
  for (let i = 0, l = source.length; i < l; i++) {
5241
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5621
+ ret[i] = renderItem(
5622
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5623
+ i,
5624
+ void 0,
5625
+ cached && cached[i]
5626
+ );
5242
5627
  }
5243
5628
  } else if (typeof source === "number") {
5244
5629
  if (!Number.isInteger(source)) {
@@ -5609,7 +5994,6 @@ const publicPropertiesMap = (
5609
5994
  $emit: (i) => i.emit,
5610
5995
  $options: (i) => resolveMergedOptions(i) ,
5611
5996
  $forceUpdate: (i) => i.f || (i.f = () => {
5612
- i.effect.dirty = true;
5613
5997
  queueJob(i.update);
5614
5998
  }),
5615
5999
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6480,7 +6864,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6480
6864
  return vm;
6481
6865
  }
6482
6866
  }
6483
- Vue.version = `2.6.14-compat:${"3.4.26"}`;
6867
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.2"}`;
6484
6868
  Vue.config = singletonApp.config;
6485
6869
  Vue.use = (plugin, ...options) => {
6486
6870
  if (plugin && isFunction(plugin.install)) {
@@ -6885,6 +7269,7 @@ function createAppAPI(render, hydrate) {
6885
7269
  }
6886
7270
  const context = createAppContext();
6887
7271
  const installedPlugins = /* @__PURE__ */ new WeakSet();
7272
+ const pluginCleanupFns = [];
6888
7273
  let isMounted = false;
6889
7274
  const app = context.app = {
6890
7275
  _uid: uid$1++,
@@ -7002,8 +7387,21 @@ If you want to remount the same app, move your app creation logic into a factory
7002
7387
  );
7003
7388
  }
7004
7389
  },
7390
+ onUnmount(cleanupFn) {
7391
+ if (typeof cleanupFn !== "function") {
7392
+ warn$1(
7393
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
7394
+ );
7395
+ }
7396
+ pluginCleanupFns.push(cleanupFn);
7397
+ },
7005
7398
  unmount() {
7006
7399
  if (isMounted) {
7400
+ callWithAsyncErrorHandling(
7401
+ pluginCleanupFns,
7402
+ app._instance,
7403
+ 15
7404
+ );
7007
7405
  render(null, app._container);
7008
7406
  {
7009
7407
  app._instance = null;
@@ -7498,7 +7896,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7498
7896
  function assertType(value, type) {
7499
7897
  let valid;
7500
7898
  const expectedType = getType(type);
7501
- if (isSimpleType(expectedType)) {
7899
+ if (expectedType === "null") {
7900
+ valid = value === null;
7901
+ } else if (isSimpleType(expectedType)) {
7502
7902
  const t = typeof value;
7503
7903
  valid = t === expectedType.toLowerCase();
7504
7904
  if (!valid && t === "object") {
@@ -7508,8 +7908,6 @@ function assertType(value, type) {
7508
7908
  valid = isObject(value);
7509
7909
  } else if (expectedType === "Array") {
7510
7910
  valid = isArray(value);
7511
- } else if (expectedType === "null") {
7512
- valid = value === null;
7513
7911
  } else {
7514
7912
  valid = value instanceof type;
7515
7913
  }
@@ -9034,7 +9432,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9034
9432
  } else {
9035
9433
  instance.next = n2;
9036
9434
  invalidateJob(instance.update);
9037
- instance.effect.dirty = true;
9038
9435
  instance.update();
9039
9436
  }
9040
9437
  } else {
@@ -9241,24 +9638,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9241
9638
  }
9242
9639
  }
9243
9640
  };
9244
- const effect = instance.effect = new ReactiveEffect(
9245
- componentUpdateFn,
9246
- NOOP,
9247
- () => queueJob(update),
9248
- instance.scope
9249
- // track it in component's effect scope
9250
- );
9251
- const update = instance.update = () => {
9252
- if (effect.dirty) {
9253
- effect.run();
9254
- }
9255
- };
9256
- update.id = instance.uid;
9641
+ instance.scope.on();
9642
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9643
+ instance.scope.off();
9644
+ const update = instance.update = effect.run.bind(effect);
9645
+ const job = instance.job = effect.runIfDirty.bind(effect);
9646
+ job.id = instance.uid;
9647
+ effect.scheduler = () => queueJob(job);
9257
9648
  toggleRecurse(instance, true);
9258
9649
  {
9259
9650
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9260
9651
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9261
- update.ownerInstance = instance;
9652
+ job.ownerInstance = instance;
9262
9653
  }
9263
9654
  update();
9264
9655
  };
@@ -9725,7 +10116,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9725
10116
  if (instance.type.__hmrId) {
9726
10117
  unregisterHMR(instance);
9727
10118
  }
9728
- const { bum, scope, update, subTree, um } = instance;
10119
+ const { bum, scope, job, subTree, um } = instance;
9729
10120
  if (bum) {
9730
10121
  invokeArrayFns(bum);
9731
10122
  }
@@ -9733,8 +10124,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9733
10124
  instance.emit("hook:beforeDestroy");
9734
10125
  }
9735
10126
  scope.stop();
9736
- if (update) {
9737
- update.active = false;
10127
+ if (job) {
10128
+ job.flags |= 8;
9738
10129
  unmount(subTree, instance, parentSuspense, doRemove);
9739
10130
  }
9740
10131
  if (um) {
@@ -9826,8 +10217,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9826
10217
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9827
10218
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9828
10219
  }
9829
- function toggleRecurse({ effect, update }, allowed) {
9830
- effect.allowRecurse = update.allowRecurse = allowed;
10220
+ function toggleRecurse({ effect, job }, allowed) {
10221
+ if (allowed) {
10222
+ effect.flags |= 32;
10223
+ job.flags |= 4;
10224
+ } else {
10225
+ effect.flags &= ~32;
10226
+ job.flags &= ~4;
10227
+ }
9831
10228
  }
9832
10229
  function needTransition(parentSuspense, transition) {
9833
10230
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10628,6 +11025,7 @@ function createComponentInstance(vnode, parent, suspense) {
10628
11025
  effect: null,
10629
11026
  update: null,
10630
11027
  // will be set synchronously right after creation
11028
+ job: null,
10631
11029
  scope: new EffectScope(
10632
11030
  true
10633
11031
  /* detached */
@@ -11133,7 +11531,8 @@ function initCustomFormatter() {
11133
11531
  {},
11134
11532
  ["span", vueStyle, genRefFlag(obj)],
11135
11533
  "<",
11136
- formatValue(obj.value),
11534
+ // avoid debugger accessing value affecting behavior
11535
+ formatValue("_value" in obj ? obj._value : obj),
11137
11536
  `>`
11138
11537
  ];
11139
11538
  } else if (isReactive(obj)) {
@@ -11313,7 +11712,7 @@ function isMemoSame(cached, memo) {
11313
11712
  return true;
11314
11713
  }
11315
11714
 
11316
- const version = "3.4.26";
11715
+ const version = "3.5.0-alpha.2";
11317
11716
  const warn = warn$1 ;
11318
11717
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11319
11718
  const devtools = devtools$1 ;
@@ -12880,7 +13279,9 @@ const withKeys = (fn, modifiers) => {
12880
13279
  return;
12881
13280
  }
12882
13281
  const eventKey = hyphenate(event.key);
12883
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13282
+ if (modifiers.some(
13283
+ (k) => k === eventKey || keyNames[k] === eventKey
13284
+ )) {
12884
13285
  return fn(event);
12885
13286
  }
12886
13287
  {