@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 if (!!(process.env.NODE_ENV !== "production")) {
394
+ } else if (!!(process.env.NODE_ENV !== "production") && !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 (!!(process.env.NODE_ENV !== "production") && 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;
533
+ }
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;
552
+ }
553
+ link.dep.activeLink = link.prevActiveLink;
554
+ link.prevActiveLink = void 0;
555
+ }
556
+ sub.deps = head;
557
+ sub.depsTail = tail;
558
+ }
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;
563
+ }
564
+ }
565
+ if (sub._dirty) {
566
+ return true;
567
+ }
568
+ return false;
494
569
  }
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);
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++;
499
598
  }
500
- effect2.deps.length = effect2._depsLength;
599
+ } catch (err) {
600
+ dep.version++;
601
+ throw err;
602
+ } finally {
603
+ activeSub = prevSub;
604
+ shouldTrack = prevShouldTrack;
605
+ cleanupDeps(computed);
606
+ computed.flags &= ~2;
501
607
  }
502
608
  }
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();
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);
509
626
  }
510
627
  }
511
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
+ }
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,418 @@ 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
  if (!!(process.env.NODE_ENV !== "production")) {
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
- if (!!(process.env.NODE_ENV !== "production")) {
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);
727
+ }
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;
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
+ }
587
743
  }
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);
744
+ }
745
+ if (!!(process.env.NODE_ENV !== "production") && 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 (!!(process.env.NODE_ENV !== "production")) {
766
+ for (let head = this.subsHead; head; head = head.nextSub) {
767
+ if (!!(process.env.NODE_ENV !== "production") && head.sub.onTrigger && !(head.sub.flags & 8)) {
768
+ head.sub.onTrigger(
769
+ extend(
770
+ {
771
+ effect: head.sub
772
+ },
773
+ debugInfo
774
+ )
775
+ );
776
+ }
593
777
  }
594
778
  }
779
+ for (let link = this.subs; link; link = link.prevSub) {
780
+ link.sub.notify();
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 (!!(process.env.NODE_ENV !== "production") && 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(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
609
- const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
807
+ const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
808
+ const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
809
+ const ARRAY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "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
- !!(process.env.NODE_ENV !== "production") ? {
820
+ if (!!(process.env.NODE_ENV !== "production")) {
821
+ dep.track({
624
822
  target,
625
823
  type,
626
824
  key
627
- } : void 0
628
- );
825
+ });
826
+ } else {
827
+ dep.track();
828
+ }
629
829
  }
630
830
  }
631
831
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
632
832
  const depsMap = targetMap.get(target);
633
833
  if (!depsMap) {
834
+ globalVersion++;
634
835
  return;
635
836
  }
636
837
  let deps = [];
637
838
  if (type === "clear") {
638
839
  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
840
  } 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"));
841
+ const targetIsArray = isArray(target);
842
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
843
+ if (targetIsArray && key === "length") {
844
+ const newLength = Number(newValue);
845
+ depsMap.forEach((dep, key2) => {
846
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
847
+ deps.push(dep);
659
848
  }
660
- break;
661
- case "delete":
662
- if (!isArray(target)) {
663
- deps.push(depsMap.get(ITERATE_KEY));
849
+ });
850
+ } else {
851
+ const push = (dep) => dep && deps.push(dep);
852
+ if (key !== void 0) {
853
+ push(depsMap.get(key));
854
+ }
855
+ if (isArrayIndex) {
856
+ push(depsMap.get(ARRAY_ITERATE_KEY));
857
+ }
858
+ switch (type) {
859
+ case "add":
860
+ if (!targetIsArray) {
861
+ push(depsMap.get(ITERATE_KEY));
862
+ if (isMap(target)) {
863
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
864
+ }
865
+ } else if (isArrayIndex) {
866
+ push(depsMap.get("length"));
867
+ }
868
+ break;
869
+ case "delete":
870
+ if (!targetIsArray) {
871
+ push(depsMap.get(ITERATE_KEY));
872
+ if (isMap(target)) {
873
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
874
+ }
875
+ }
876
+ break;
877
+ case "set":
664
878
  if (isMap(target)) {
665
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
879
+ push(depsMap.get(ITERATE_KEY));
666
880
  }
667
- }
668
- break;
669
- case "set":
670
- if (isMap(target)) {
671
- deps.push(depsMap.get(ITERATE_KEY));
672
- }
673
- break;
881
+ break;
882
+ }
674
883
  }
675
884
  }
676
- pauseScheduling();
885
+ startBatch();
677
886
  for (const dep of deps) {
678
- if (dep) {
679
- triggerEffects(
680
- dep,
681
- 4,
682
- !!(process.env.NODE_ENV !== "production") ? {
683
- target,
684
- type,
685
- key,
686
- newValue,
687
- oldValue,
688
- oldTarget
689
- } : void 0
690
- );
887
+ if (!!(process.env.NODE_ENV !== "production")) {
888
+ dep.trigger({
889
+ target,
890
+ type,
891
+ key,
892
+ newValue,
893
+ oldValue,
894
+ oldTarget
895
+ });
896
+ } else {
897
+ dep.trigger();
691
898
  }
692
899
  }
693
- resetScheduling();
900
+ endBatch();
694
901
  }
695
902
  function getDepFromReactive(object, key) {
696
- const depsMap = targetMap.get(object);
697
- return depsMap && depsMap.get(key);
903
+ var _a;
904
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
905
+ }
906
+
907
+ function reactiveReadArray(array) {
908
+ const raw = toRaw(array);
909
+ if (raw === array)
910
+ return raw;
911
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
912
+ return isShallow(array) ? raw : raw.map(toReactive);
913
+ }
914
+ function shallowReadArray(arr) {
915
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
916
+ return arr;
917
+ }
918
+ const arrayInstrumentations = {
919
+ __proto__: null,
920
+ [Symbol.iterator]() {
921
+ return iterator(this, Symbol.iterator, toReactive);
922
+ },
923
+ concat(...args) {
924
+ return reactiveReadArray(this).concat(
925
+ ...args.map((x) => reactiveReadArray(x))
926
+ );
927
+ },
928
+ entries() {
929
+ return iterator(this, "entries", (value) => {
930
+ value[1] = toReactive(value[1]);
931
+ return value;
932
+ });
933
+ },
934
+ every(fn, thisArg) {
935
+ return apply(this, "every", fn, thisArg);
936
+ },
937
+ filter(fn, thisArg) {
938
+ const result = apply(this, "filter", fn, thisArg);
939
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
940
+ },
941
+ find(fn, thisArg) {
942
+ const result = apply(this, "find", fn, thisArg);
943
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
944
+ },
945
+ findIndex(fn, thisArg) {
946
+ return apply(this, "findIndex", fn, thisArg);
947
+ },
948
+ findLast(fn, thisArg) {
949
+ const result = apply(this, "findLast", fn, thisArg);
950
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
951
+ },
952
+ findLastIndex(fn, thisArg) {
953
+ return apply(this, "findLastIndex", fn, thisArg);
954
+ },
955
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
956
+ forEach(fn, thisArg) {
957
+ return apply(this, "forEach", fn, thisArg);
958
+ },
959
+ includes(...args) {
960
+ return searchProxy(this, "includes", args);
961
+ },
962
+ indexOf(...args) {
963
+ return searchProxy(this, "indexOf", args);
964
+ },
965
+ join(separator) {
966
+ return reactiveReadArray(this).join(separator);
967
+ },
968
+ // keys() iterator only reads `length`, no optimisation required
969
+ lastIndexOf(...args) {
970
+ return searchProxy(this, "lastIndexOf", args);
971
+ },
972
+ map(fn, thisArg) {
973
+ return apply(this, "map", fn, thisArg);
974
+ },
975
+ pop() {
976
+ return noTracking(this, "pop");
977
+ },
978
+ push(...args) {
979
+ return noTracking(this, "push", args);
980
+ },
981
+ reduce(fn, ...args) {
982
+ return reduce(this, "reduce", fn, args);
983
+ },
984
+ reduceRight(fn, ...args) {
985
+ return reduce(this, "reduceRight", fn, args);
986
+ },
987
+ shift() {
988
+ return noTracking(this, "shift");
989
+ },
990
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
991
+ some(fn, thisArg) {
992
+ return apply(this, "some", fn, thisArg);
993
+ },
994
+ splice(...args) {
995
+ return noTracking(this, "splice", args);
996
+ },
997
+ toReversed() {
998
+ return reactiveReadArray(this).toReversed();
999
+ },
1000
+ toSorted(comparer) {
1001
+ return reactiveReadArray(this).toSorted(comparer);
1002
+ },
1003
+ toSpliced(...args) {
1004
+ return reactiveReadArray(this).toSpliced(...args);
1005
+ },
1006
+ unshift(...args) {
1007
+ return noTracking(this, "unshift", args);
1008
+ },
1009
+ values() {
1010
+ return iterator(this, "values", toReactive);
1011
+ }
1012
+ };
1013
+ function iterator(self, method, wrapValue) {
1014
+ const arr = shallowReadArray(self);
1015
+ const iter = arr[method]();
1016
+ if (arr !== self && !isShallow(self)) {
1017
+ iter._next = iter.next;
1018
+ iter.next = () => {
1019
+ const result = iter._next();
1020
+ if (result.value) {
1021
+ result.value = wrapValue(result.value);
1022
+ }
1023
+ return result;
1024
+ };
1025
+ }
1026
+ return iter;
1027
+ }
1028
+ function apply(self, method, fn, thisArg) {
1029
+ const arr = shallowReadArray(self);
1030
+ let wrappedFn = fn;
1031
+ if (arr !== self) {
1032
+ if (!isShallow(self)) {
1033
+ wrappedFn = function(item, index) {
1034
+ return fn.call(this, toReactive(item), index, self);
1035
+ };
1036
+ } else if (fn.length > 2) {
1037
+ wrappedFn = function(item, index) {
1038
+ return fn.call(this, item, index, self);
1039
+ };
1040
+ }
1041
+ }
1042
+ return arr[method](wrappedFn, thisArg);
1043
+ }
1044
+ function reduce(self, method, fn, args) {
1045
+ const arr = shallowReadArray(self);
1046
+ let wrappedFn = fn;
1047
+ if (arr !== self) {
1048
+ if (!isShallow(self)) {
1049
+ wrappedFn = function(acc, item, index) {
1050
+ return fn.call(this, acc, toReactive(item), index, self);
1051
+ };
1052
+ } else if (fn.length > 3) {
1053
+ wrappedFn = function(acc, item, index) {
1054
+ return fn.call(this, acc, item, index, self);
1055
+ };
1056
+ }
1057
+ }
1058
+ return arr[method](wrappedFn, ...args);
1059
+ }
1060
+ function searchProxy(self, method, args) {
1061
+ const arr = toRaw(self);
1062
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1063
+ const res = arr[method](...args);
1064
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1065
+ args[0] = toRaw(args[0]);
1066
+ return arr[method](...args);
1067
+ }
1068
+ return res;
1069
+ }
1070
+ function noTracking(self, method, args = []) {
1071
+ pauseTracking();
1072
+ startBatch();
1073
+ const res = toRaw(self)[method].apply(self, args);
1074
+ endBatch();
1075
+ resetTracking();
1076
+ return res;
698
1077
  }
699
1078
 
700
1079
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
701
1080
  const builtInSymbols = new Set(
702
1081
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
703
1082
  );
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
1083
  function hasOwnProperty(key) {
734
1084
  if (!isSymbol(key))
735
1085
  key = String(key);
@@ -760,14 +1110,22 @@ class BaseReactiveHandler {
760
1110
  }
761
1111
  const targetIsArray = isArray(target);
762
1112
  if (!isReadonly2) {
763
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
764
- return Reflect.get(arrayInstrumentations, key, receiver);
1113
+ let fn;
1114
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1115
+ return fn;
765
1116
  }
766
1117
  if (key === "hasOwnProperty") {
767
1118
  return hasOwnProperty;
768
1119
  }
769
1120
  }
770
- const res = Reflect.get(target, key, receiver);
1121
+ const res = Reflect.get(
1122
+ target,
1123
+ key,
1124
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1125
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1126
+ // its class methods
1127
+ isRef(target) ? target : receiver
1128
+ );
771
1129
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
772
1130
  return res;
773
1131
  }
@@ -1266,110 +1624,8 @@ function markRaw(value) {
1266
1624
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1267
1625
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1268
1626
 
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 (!!(process.env.NODE_ENV !== "production") && 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 = !!(process.env.NODE_ENV !== "production") ? () => {
1323
- warn$2("Write operation failed: computed value is readonly");
1324
- } : NOOP;
1325
- } else {
1326
- getter = getterOrOptions.get;
1327
- setter = getterOrOptions.set;
1328
- }
1329
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1330
- if (!!(process.env.NODE_ENV !== "production") && 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
- !!(process.env.NODE_ENV !== "production") ? {
1348
- target: ref2,
1349
- type: "get",
1350
- key: "value"
1351
- } : void 0
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
- !!(process.env.NODE_ENV !== "production") ? {
1363
- target: ref2,
1364
- type: "set",
1365
- key: "value",
1366
- newValue: newVal
1367
- } : void 0
1368
- );
1369
- }
1370
- }
1371
1627
  function isRef(r) {
1372
- return !!(r && r.__v_isRef === true);
1628
+ return r ? r.__v_isRef === true : false;
1373
1629
  }
1374
1630
  function ref(value) {
1375
1631
  return createRef(value, false);
@@ -1386,27 +1642,55 @@ function createRef(rawValue, shallow) {
1386
1642
  class RefImpl {
1387
1643
  constructor(value, __v_isShallow) {
1388
1644
  this.__v_isShallow = __v_isShallow;
1389
- this.dep = void 0;
1645
+ this.dep = new Dep();
1390
1646
  this.__v_isRef = true;
1391
1647
  this._rawValue = __v_isShallow ? value : toRaw(value);
1392
1648
  this._value = __v_isShallow ? value : toReactive(value);
1393
1649
  }
1394
1650
  get value() {
1395
- trackRefValue(this);
1651
+ if (!!(process.env.NODE_ENV !== "production")) {
1652
+ this.dep.track({
1653
+ target: this,
1654
+ type: "get",
1655
+ key: "value"
1656
+ });
1657
+ } else {
1658
+ this.dep.track();
1659
+ }
1396
1660
  return this._value;
1397
1661
  }
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);
1662
+ set value(newValue) {
1663
+ const oldValue = this._rawValue;
1664
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1665
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1666
+ if (hasChanged(newValue, oldValue)) {
1667
+ this._rawValue = newValue;
1668
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1669
+ if (!!(process.env.NODE_ENV !== "production")) {
1670
+ this.dep.trigger({
1671
+ target: this,
1672
+ type: "set",
1673
+ key: "value",
1674
+ newValue,
1675
+ oldValue
1676
+ });
1677
+ } else {
1678
+ this.dep.trigger();
1679
+ }
1405
1680
  }
1406
1681
  }
1407
1682
  }
1408
1683
  function triggerRef(ref2) {
1409
- triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1684
+ if (!!(process.env.NODE_ENV !== "production")) {
1685
+ ref2.dep.trigger({
1686
+ target: ref2,
1687
+ type: "set",
1688
+ key: "value",
1689
+ newValue: ref2._value
1690
+ });
1691
+ } else {
1692
+ ref2.dep.trigger();
1693
+ }
1410
1694
  }
1411
1695
  function unref(ref2) {
1412
1696
  return isRef(ref2) ? ref2.value : ref2;
@@ -1431,12 +1715,9 @@ function proxyRefs(objectWithRefs) {
1431
1715
  }
1432
1716
  class CustomRefImpl {
1433
1717
  constructor(factory) {
1434
- this.dep = void 0;
1435
1718
  this.__v_isRef = true;
1436
- const { get, set } = factory(
1437
- () => trackRefValue(this),
1438
- () => triggerRefValue(this)
1439
- );
1719
+ const dep = this.dep = new Dep();
1720
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1440
1721
  this._get = get;
1441
1722
  this._set = set;
1442
1723
  }
@@ -1504,6 +1785,90 @@ function propertyToRef(source, key, defaultValue) {
1504
1785
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1505
1786
  }
1506
1787
 
1788
+ class ComputedRefImpl {
1789
+ constructor(fn, setter, isSSR) {
1790
+ this.fn = fn;
1791
+ this.setter = setter;
1792
+ /**
1793
+ * @internal
1794
+ */
1795
+ this._value = void 0;
1796
+ /**
1797
+ * @internal
1798
+ */
1799
+ this.dep = new Dep(this);
1800
+ /**
1801
+ * @internal
1802
+ */
1803
+ this.__v_isRef = true;
1804
+ // A computed is also a subscriber that tracks other deps
1805
+ /**
1806
+ * @internal
1807
+ */
1808
+ this.deps = void 0;
1809
+ /**
1810
+ * @internal
1811
+ */
1812
+ this.depsTail = void 0;
1813
+ /**
1814
+ * @internal
1815
+ */
1816
+ this.flags = 16;
1817
+ /**
1818
+ * @internal
1819
+ */
1820
+ this.globalVersion = globalVersion - 1;
1821
+ // for backwards compat
1822
+ this.effect = this;
1823
+ this.__v_isReadonly = !setter;
1824
+ this.isSSR = isSSR;
1825
+ }
1826
+ /**
1827
+ * @internal
1828
+ */
1829
+ notify() {
1830
+ if (activeSub !== this) {
1831
+ this.flags |= 16;
1832
+ this.dep.notify();
1833
+ } else if (!!(process.env.NODE_ENV !== "production")) ;
1834
+ }
1835
+ get value() {
1836
+ const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1837
+ target: this,
1838
+ type: "get",
1839
+ key: "value"
1840
+ }) : this.dep.track();
1841
+ refreshComputed(this);
1842
+ if (link) {
1843
+ link.version = this.dep.version;
1844
+ }
1845
+ return this._value;
1846
+ }
1847
+ set value(newValue) {
1848
+ if (this.setter) {
1849
+ this.setter(newValue);
1850
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1851
+ warn$2("Write operation failed: computed value is readonly");
1852
+ }
1853
+ }
1854
+ }
1855
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1856
+ let getter;
1857
+ let setter;
1858
+ if (isFunction(getterOrOptions)) {
1859
+ getter = getterOrOptions;
1860
+ } else {
1861
+ getter = getterOrOptions.get;
1862
+ setter = getterOrOptions.set;
1863
+ }
1864
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1865
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1866
+ cRef.onTrack = debugOptions.onTrack;
1867
+ cRef.onTrigger = debugOptions.onTrigger;
1868
+ }
1869
+ return cRef;
1870
+ }
1871
+
1507
1872
  const TrackOpTypes = {
1508
1873
  "GET": "get",
1509
1874
  "HAS": "has",
@@ -1665,7 +2030,9 @@ const ErrorCodes = {
1665
2030
  "ASYNC_COMPONENT_LOADER": 13,
1666
2031
  "13": "ASYNC_COMPONENT_LOADER",
1667
2032
  "SCHEDULER": 14,
1668
- "14": "SCHEDULER"
2033
+ "14": "SCHEDULER",
2034
+ "APP_UNMOUNT_CLEANUP": 15,
2035
+ "15": "APP_UNMOUNT_CLEANUP"
1669
2036
  };
1670
2037
  const ErrorTypeStrings$1 = {
1671
2038
  ["sp"]: "serverPrefetch hook",
@@ -1696,7 +2063,8 @@ const ErrorTypeStrings$1 = {
1696
2063
  [11]: "app warnHandler",
1697
2064
  [12]: "ref function",
1698
2065
  [13]: "async component loader",
1699
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2066
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2067
+ [15]: "app unmount cleanup function"
1700
2068
  };
1701
2069
  function callWithErrorHandling(fn, instance, type, args) {
1702
2070
  try {
@@ -1800,7 +2168,7 @@ function findInsertionIndex(id) {
1800
2168
  const middle = start + end >>> 1;
1801
2169
  const middleJob = queue[middle];
1802
2170
  const middleJobId = getId(middleJob);
1803
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2171
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1804
2172
  start = middle + 1;
1805
2173
  } else {
1806
2174
  end = middle;
@@ -1809,15 +2177,21 @@ function findInsertionIndex(id) {
1809
2177
  return start;
1810
2178
  }
1811
2179
  function queueJob(job) {
1812
- if (!queue.length || !queue.includes(
1813
- job,
1814
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1815
- )) {
2180
+ var _a;
2181
+ if (!(job.flags & 1)) {
1816
2182
  if (job.id == null) {
1817
2183
  queue.push(job);
2184
+ } else if (
2185
+ // fast path when the job id is larger than the tail
2186
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2187
+ ) {
2188
+ queue.push(job);
1818
2189
  } else {
1819
2190
  queue.splice(findInsertionIndex(job.id), 0, job);
1820
2191
  }
2192
+ if (!(job.flags & 4)) {
2193
+ job.flags |= 1;
2194
+ }
1821
2195
  queueFlush();
1822
2196
  }
1823
2197
  }
@@ -1835,11 +2209,11 @@ function invalidateJob(job) {
1835
2209
  }
1836
2210
  function queuePostFlushCb(cb) {
1837
2211
  if (!isArray(cb)) {
1838
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1839
- cb,
1840
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1841
- )) {
2212
+ if (!(cb.flags & 1)) {
1842
2213
  pendingPostFlushCbs.push(cb);
2214
+ if (!(cb.flags & 4)) {
2215
+ cb.flags |= 1;
2216
+ }
1843
2217
  }
1844
2218
  } else {
1845
2219
  pendingPostFlushCbs.push(...cb);
@@ -1852,7 +2226,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1852
2226
  }
1853
2227
  for (; i < queue.length; i++) {
1854
2228
  const cb = queue[i];
1855
- if (cb && cb.pre) {
2229
+ if (cb && cb.flags & 2) {
1856
2230
  if (instance && cb.id !== instance.uid) {
1857
2231
  continue;
1858
2232
  }
@@ -1862,6 +2236,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1862
2236
  queue.splice(i, 1);
1863
2237
  i--;
1864
2238
  cb();
2239
+ cb.flags &= ~1;
1865
2240
  }
1866
2241
  }
1867
2242
  }
@@ -1884,6 +2259,7 @@ function flushPostFlushCbs(seen) {
1884
2259
  continue;
1885
2260
  }
1886
2261
  activePostFlushCbs[postFlushIndex]();
2262
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1887
2263
  }
1888
2264
  activePostFlushCbs = null;
1889
2265
  postFlushIndex = 0;
@@ -1893,9 +2269,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
1893
2269
  const comparator = (a, b) => {
1894
2270
  const diff = getId(a) - getId(b);
1895
2271
  if (diff === 0) {
1896
- if (a.pre && !b.pre)
2272
+ const isAPre = a.flags & 2;
2273
+ const isBPre = b.flags & 2;
2274
+ if (isAPre && !isBPre)
1897
2275
  return -1;
1898
- if (b.pre && !a.pre)
2276
+ if (isBPre && !isAPre)
1899
2277
  return 1;
1900
2278
  }
1901
2279
  return diff;
@@ -1911,11 +2289,12 @@ function flushJobs(seen) {
1911
2289
  try {
1912
2290
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1913
2291
  const job = queue[flushIndex];
1914
- if (job && job.active !== false) {
2292
+ if (job && !(job.flags & 8)) {
1915
2293
  if (!!(process.env.NODE_ENV !== "production") && check(job)) {
1916
2294
  continue;
1917
2295
  }
1918
2296
  callWithErrorHandling(job, null, 14);
2297
+ job.flags &= ~1;
1919
2298
  }
1920
2299
  }
1921
2300
  } finally {
@@ -1997,7 +2376,6 @@ function rerender(id, newRender) {
1997
2376
  }
1998
2377
  instance.renderCache = [];
1999
2378
  isHmrUpdating = true;
2000
- instance.effect.dirty = true;
2001
2379
  instance.update();
2002
2380
  isHmrUpdating = false;
2003
2381
  });
@@ -2025,7 +2403,6 @@ function reload(id, newComp) {
2025
2403
  instance.ceReload(newComp.styles);
2026
2404
  hmrDirtyComponents.delete(oldComp);
2027
2405
  } else if (instance.parent) {
2028
- instance.parent.effect.dirty = true;
2029
2406
  queueJob(instance.parent.update);
2030
2407
  } else if (instance.appContext.reload) {
2031
2408
  instance.appContext.reload();
@@ -4022,8 +4399,8 @@ function doWatch(source, cb, {
4022
4399
  }
4023
4400
  }
4024
4401
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4025
- const job = () => {
4026
- if (!effect.active || !effect.dirty) {
4402
+ const job = (immediateFirstRun) => {
4403
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4027
4404
  return;
4028
4405
  }
4029
4406
  if (cb) {
@@ -4044,19 +4421,22 @@ function doWatch(source, cb, {
4044
4421
  effect.run();
4045
4422
  }
4046
4423
  };
4047
- job.allowRecurse = !!cb;
4424
+ if (cb)
4425
+ job.flags |= 4;
4426
+ const effect = new ReactiveEffect(getter);
4048
4427
  let scheduler;
4049
4428
  if (flush === "sync") {
4429
+ effect.flags |= 64;
4050
4430
  scheduler = job;
4051
4431
  } else if (flush === "post") {
4052
4432
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4053
4433
  } else {
4054
- job.pre = true;
4434
+ job.flags |= 2;
4055
4435
  if (instance)
4056
4436
  job.id = instance.uid;
4057
4437
  scheduler = () => queueJob(job);
4058
4438
  }
4059
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4439
+ effect.scheduler = scheduler;
4060
4440
  const scope = getCurrentScope();
4061
4441
  const unwatch = () => {
4062
4442
  effect.stop();
@@ -4070,7 +4450,7 @@ function doWatch(source, cb, {
4070
4450
  }
4071
4451
  if (cb) {
4072
4452
  if (immediate) {
4073
- job();
4453
+ job(true);
4074
4454
  } else {
4075
4455
  oldValue = effect.run();
4076
4456
  }
@@ -4249,24 +4629,7 @@ const BaseTransitionImpl = {
4249
4629
  if (!children || !children.length) {
4250
4630
  return;
4251
4631
  }
4252
- let child = children[0];
4253
- if (children.length > 1) {
4254
- let hasFound = false;
4255
- for (const c of children) {
4256
- if (c.type !== Comment) {
4257
- if (!!(process.env.NODE_ENV !== "production") && hasFound) {
4258
- warn$1(
4259
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4260
- );
4261
- break;
4262
- }
4263
- child = c;
4264
- hasFound = true;
4265
- if (!!!(process.env.NODE_ENV !== "production"))
4266
- break;
4267
- }
4268
- }
4269
- }
4632
+ const child = findNonCommentChild(children);
4270
4633
  const rawProps = toRaw(props);
4271
4634
  const { mode } = rawProps;
4272
4635
  if (!!(process.env.NODE_ENV !== "production") && mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4275,7 +4638,7 @@ const BaseTransitionImpl = {
4275
4638
  if (state.isLeaving) {
4276
4639
  return emptyPlaceholder(child);
4277
4640
  }
4278
- const innerChild = getKeepAliveChild(child);
4641
+ const innerChild = getInnerChild$1(child);
4279
4642
  if (!innerChild) {
4280
4643
  return emptyPlaceholder(child);
4281
4644
  }
@@ -4287,7 +4650,7 @@ const BaseTransitionImpl = {
4287
4650
  );
4288
4651
  setTransitionHooks(innerChild, enterHooks);
4289
4652
  const oldChild = instance.subTree;
4290
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4653
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4291
4654
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4292
4655
  const leavingHooks = resolveTransitionHooks(
4293
4656
  oldInnerChild,
@@ -4300,8 +4663,7 @@ const BaseTransitionImpl = {
4300
4663
  state.isLeaving = true;
4301
4664
  leavingHooks.afterLeave = () => {
4302
4665
  state.isLeaving = false;
4303
- if (instance.update.active !== false) {
4304
- instance.effect.dirty = true;
4666
+ if (!(instance.job.flags & 8)) {
4305
4667
  instance.update();
4306
4668
  }
4307
4669
  };
@@ -4329,6 +4691,27 @@ const BaseTransitionImpl = {
4329
4691
  {
4330
4692
  BaseTransitionImpl.__isBuiltIn = true;
4331
4693
  }
4694
+ function findNonCommentChild(children) {
4695
+ let child = children[0];
4696
+ if (children.length > 1) {
4697
+ let hasFound = false;
4698
+ for (const c of children) {
4699
+ if (c.type !== Comment) {
4700
+ if (!!(process.env.NODE_ENV !== "production") && hasFound) {
4701
+ warn$1(
4702
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4703
+ );
4704
+ break;
4705
+ }
4706
+ child = c;
4707
+ hasFound = true;
4708
+ if (!!!(process.env.NODE_ENV !== "production"))
4709
+ break;
4710
+ }
4711
+ }
4712
+ }
4713
+ return child;
4714
+ }
4332
4715
  const BaseTransition = BaseTransitionImpl;
4333
4716
  function getLeavingNodesForType(state, vnode) {
4334
4717
  const { leavingVNodes } = state;
@@ -4483,8 +4866,11 @@ function emptyPlaceholder(vnode) {
4483
4866
  return vnode;
4484
4867
  }
4485
4868
  }
4486
- function getKeepAliveChild(vnode) {
4869
+ function getInnerChild$1(vnode) {
4487
4870
  if (!isKeepAlive(vnode)) {
4871
+ if (isTeleport(vnode.type) && vnode.children) {
4872
+ return findNonCommentChild(vnode.children);
4873
+ }
4488
4874
  return vnode;
4489
4875
  }
4490
4876
  if (!!(process.env.NODE_ENV !== "production") && vnode.component) {
@@ -4653,7 +5039,6 @@ function defineAsyncComponent(source) {
4653
5039
  load().then(() => {
4654
5040
  loaded.value = true;
4655
5041
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4656
- instance.parent.effect.dirty = true;
4657
5042
  queueJob(instance.parent.update);
4658
5043
  }
4659
5044
  }).catch((err) => {
@@ -5271,10 +5656,20 @@ function convertLegacyFunctionalComponent(comp) {
5271
5656
  function renderList(source, renderItem, cache, index) {
5272
5657
  let ret;
5273
5658
  const cached = cache && cache[index];
5274
- if (isArray(source) || isString(source)) {
5659
+ const sourceIsArray = isArray(source);
5660
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5661
+ if (sourceIsArray || isString(source)) {
5662
+ if (sourceIsReactiveArray) {
5663
+ source = shallowReadArray(source);
5664
+ }
5275
5665
  ret = new Array(source.length);
5276
5666
  for (let i = 0, l = source.length; i < l; i++) {
5277
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5667
+ ret[i] = renderItem(
5668
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5669
+ i,
5670
+ void 0,
5671
+ cached && cached[i]
5672
+ );
5278
5673
  }
5279
5674
  } else if (typeof source === "number") {
5280
5675
  if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
@@ -5645,7 +6040,6 @@ const publicPropertiesMap = (
5645
6040
  $emit: (i) => i.emit,
5646
6041
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
5647
6042
  $forceUpdate: (i) => i.f || (i.f = () => {
5648
- i.effect.dirty = true;
5649
6043
  queueJob(i.update);
5650
6044
  }),
5651
6045
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6518,7 +6912,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6518
6912
  return vm;
6519
6913
  }
6520
6914
  }
6521
- Vue.version = `2.6.14-compat:${"3.4.26"}`;
6915
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.2"}`;
6522
6916
  Vue.config = singletonApp.config;
6523
6917
  Vue.use = (plugin, ...options) => {
6524
6918
  if (plugin && isFunction(plugin.install)) {
@@ -6924,6 +7318,7 @@ function createAppAPI(render, hydrate) {
6924
7318
  }
6925
7319
  const context = createAppContext();
6926
7320
  const installedPlugins = /* @__PURE__ */ new WeakSet();
7321
+ const pluginCleanupFns = [];
6927
7322
  let isMounted = false;
6928
7323
  const app = context.app = {
6929
7324
  _uid: uid$1++,
@@ -7043,8 +7438,21 @@ If you want to remount the same app, move your app creation logic into a factory
7043
7438
  );
7044
7439
  }
7045
7440
  },
7441
+ onUnmount(cleanupFn) {
7442
+ if (!!(process.env.NODE_ENV !== "production") && typeof cleanupFn !== "function") {
7443
+ warn$1(
7444
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
7445
+ );
7446
+ }
7447
+ pluginCleanupFns.push(cleanupFn);
7448
+ },
7046
7449
  unmount() {
7047
7450
  if (isMounted) {
7451
+ callWithAsyncErrorHandling(
7452
+ pluginCleanupFns,
7453
+ app._instance,
7454
+ 15
7455
+ );
7048
7456
  render(null, app._container);
7049
7457
  if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
7050
7458
  app._instance = null;
@@ -7539,7 +7947,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7539
7947
  function assertType(value, type) {
7540
7948
  let valid;
7541
7949
  const expectedType = getType(type);
7542
- if (isSimpleType(expectedType)) {
7950
+ if (expectedType === "null") {
7951
+ valid = value === null;
7952
+ } else if (isSimpleType(expectedType)) {
7543
7953
  const t = typeof value;
7544
7954
  valid = t === expectedType.toLowerCase();
7545
7955
  if (!valid && t === "object") {
@@ -7549,8 +7959,6 @@ function assertType(value, type) {
7549
7959
  valid = isObject(value);
7550
7960
  } else if (expectedType === "Array") {
7551
7961
  valid = isArray(value);
7552
- } else if (expectedType === "null") {
7553
- valid = value === null;
7554
7962
  } else {
7555
7963
  valid = value instanceof type;
7556
7964
  }
@@ -9123,7 +9531,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9123
9531
  } else {
9124
9532
  instance.next = n2;
9125
9533
  invalidateJob(instance.update);
9126
- instance.effect.dirty = true;
9127
9534
  instance.update();
9128
9535
  }
9129
9536
  } else {
@@ -9330,24 +9737,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9330
9737
  }
9331
9738
  }
9332
9739
  };
9333
- const effect = instance.effect = new ReactiveEffect(
9334
- componentUpdateFn,
9335
- NOOP,
9336
- () => queueJob(update),
9337
- instance.scope
9338
- // track it in component's effect scope
9339
- );
9340
- const update = instance.update = () => {
9341
- if (effect.dirty) {
9342
- effect.run();
9343
- }
9344
- };
9345
- update.id = instance.uid;
9740
+ instance.scope.on();
9741
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9742
+ instance.scope.off();
9743
+ const update = instance.update = effect.run.bind(effect);
9744
+ const job = instance.job = effect.runIfDirty.bind(effect);
9745
+ job.id = instance.uid;
9746
+ effect.scheduler = () => queueJob(job);
9346
9747
  toggleRecurse(instance, true);
9347
9748
  if (!!(process.env.NODE_ENV !== "production")) {
9348
9749
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9349
9750
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9350
- update.ownerInstance = instance;
9751
+ job.ownerInstance = instance;
9351
9752
  }
9352
9753
  update();
9353
9754
  };
@@ -9814,7 +10215,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9814
10215
  if (!!(process.env.NODE_ENV !== "production") && instance.type.__hmrId) {
9815
10216
  unregisterHMR(instance);
9816
10217
  }
9817
- const { bum, scope, update, subTree, um } = instance;
10218
+ const { bum, scope, job, subTree, um } = instance;
9818
10219
  if (bum) {
9819
10220
  invokeArrayFns(bum);
9820
10221
  }
@@ -9822,8 +10223,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9822
10223
  instance.emit("hook:beforeDestroy");
9823
10224
  }
9824
10225
  scope.stop();
9825
- if (update) {
9826
- update.active = false;
10226
+ if (job) {
10227
+ job.flags |= 8;
9827
10228
  unmount(subTree, instance, parentSuspense, doRemove);
9828
10229
  }
9829
10230
  if (um) {
@@ -9915,8 +10316,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9915
10316
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9916
10317
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9917
10318
  }
9918
- function toggleRecurse({ effect, update }, allowed) {
9919
- effect.allowRecurse = update.allowRecurse = allowed;
10319
+ function toggleRecurse({ effect, job }, allowed) {
10320
+ if (allowed) {
10321
+ effect.flags |= 32;
10322
+ job.flags |= 4;
10323
+ } else {
10324
+ effect.flags &= ~32;
10325
+ job.flags &= ~4;
10326
+ }
9920
10327
  }
9921
10328
  function needTransition(parentSuspense, transition) {
9922
10329
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10717,6 +11124,7 @@ function createComponentInstance(vnode, parent, suspense) {
10717
11124
  effect: null,
10718
11125
  update: null,
10719
11126
  // will be set synchronously right after creation
11127
+ job: null,
10720
11128
  scope: new EffectScope(
10721
11129
  true
10722
11130
  /* detached */
@@ -11253,7 +11661,8 @@ function initCustomFormatter() {
11253
11661
  {},
11254
11662
  ["span", vueStyle, genRefFlag(obj)],
11255
11663
  "<",
11256
- formatValue(obj.value),
11664
+ // avoid debugger accessing value affecting behavior
11665
+ formatValue("_value" in obj ? obj._value : obj),
11257
11666
  `>`
11258
11667
  ];
11259
11668
  } else if (isReactive(obj)) {
@@ -11433,7 +11842,7 @@ function isMemoSame(cached, memo) {
11433
11842
  return true;
11434
11843
  }
11435
11844
 
11436
- const version = "3.4.26";
11845
+ const version = "3.5.0-alpha.2";
11437
11846
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
11438
11847
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11439
11848
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13049,7 +13458,9 @@ const withKeys = (fn, modifiers) => {
13049
13458
  return;
13050
13459
  }
13051
13460
  const eventKey = hyphenate(event.key);
13052
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13461
+ if (modifiers.some(
13462
+ (k) => k === eventKey || keyNames[k] === eventKey
13463
+ )) {
13053
13464
  return fn(event);
13054
13465
  }
13055
13466
  {