@vue/runtime-dom 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/runtime-dom v3.4.26
2
+ * @vue/runtime-dom v3.5.0-alpha.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -388,156 +388,280 @@ var VueRuntimeDOM = (function (exports) {
388
388
  function effectScope(detached) {
389
389
  return new EffectScope(detached);
390
390
  }
391
- function recordEffectScope(effect, scope = activeEffectScope) {
392
- if (scope && scope.active) {
393
- scope.effects.push(effect);
394
- }
395
- }
396
391
  function getCurrentScope() {
397
392
  return activeEffectScope;
398
393
  }
399
- function onScopeDispose(fn) {
394
+ function onScopeDispose(fn, failSilently = false) {
400
395
  if (activeEffectScope) {
401
396
  activeEffectScope.cleanups.push(fn);
402
- } else {
397
+ } else if (!failSilently) {
403
398
  warn$2(
404
399
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
405
400
  );
406
401
  }
407
402
  }
408
403
 
409
- let activeEffect;
404
+ let activeSub;
410
405
  class ReactiveEffect {
411
- constructor(fn, trigger, scheduler, scope) {
406
+ constructor(fn) {
412
407
  this.fn = fn;
413
- this.trigger = trigger;
414
- this.scheduler = scheduler;
415
- this.active = true;
416
- this.deps = [];
417
408
  /**
418
409
  * @internal
419
410
  */
420
- this._dirtyLevel = 4;
411
+ this.deps = void 0;
421
412
  /**
422
413
  * @internal
423
414
  */
424
- this._trackId = 0;
415
+ this.depsTail = void 0;
425
416
  /**
426
417
  * @internal
427
418
  */
428
- this._runnings = 0;
419
+ this.flags = 1 | 4;
429
420
  /**
430
421
  * @internal
431
422
  */
432
- this._shouldSchedule = false;
423
+ this.nextEffect = void 0;
433
424
  /**
434
425
  * @internal
435
426
  */
436
- this._depsLength = 0;
437
- recordEffectScope(this, scope);
438
- }
439
- get dirty() {
440
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
441
- this._dirtyLevel = 1;
442
- pauseTracking();
443
- for (let i = 0; i < this._depsLength; i++) {
444
- const dep = this.deps[i];
445
- if (dep.computed) {
446
- triggerComputed(dep.computed);
447
- if (this._dirtyLevel >= 4) {
448
- break;
449
- }
450
- }
451
- }
452
- if (this._dirtyLevel === 1) {
453
- this._dirtyLevel = 0;
454
- }
455
- resetTracking();
427
+ this.cleanup = void 0;
428
+ this.scheduler = void 0;
429
+ if (activeEffectScope && activeEffectScope.active) {
430
+ activeEffectScope.effects.push(this);
456
431
  }
457
- return this._dirtyLevel >= 4;
458
432
  }
459
- set dirty(v) {
460
- this._dirtyLevel = v ? 4 : 0;
433
+ /**
434
+ * @internal
435
+ */
436
+ notify() {
437
+ if (this.flags & 2 && !(this.flags & 32)) {
438
+ return;
439
+ }
440
+ if (this.flags & 64) {
441
+ return this.trigger();
442
+ }
443
+ if (!(this.flags & 8)) {
444
+ this.flags |= 8;
445
+ this.nextEffect = batchedEffect;
446
+ batchedEffect = this;
447
+ }
461
448
  }
462
449
  run() {
463
- this._dirtyLevel = 0;
464
- if (!this.active) {
450
+ if (!(this.flags & 1)) {
465
451
  return this.fn();
466
452
  }
467
- let lastShouldTrack = shouldTrack;
468
- let lastEffect = activeEffect;
453
+ this.flags |= 2;
454
+ cleanupEffect(this);
455
+ prepareDeps(this);
456
+ const prevEffect = activeSub;
457
+ const prevShouldTrack = shouldTrack;
458
+ activeSub = this;
459
+ shouldTrack = true;
469
460
  try {
470
- shouldTrack = true;
471
- activeEffect = this;
472
- this._runnings++;
473
- preCleanupEffect(this);
474
461
  return this.fn();
475
462
  } finally {
476
- postCleanupEffect(this);
477
- this._runnings--;
478
- activeEffect = lastEffect;
479
- shouldTrack = lastShouldTrack;
463
+ if (activeSub !== this) {
464
+ warn$2(
465
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
466
+ );
467
+ }
468
+ cleanupDeps(this);
469
+ activeSub = prevEffect;
470
+ shouldTrack = prevShouldTrack;
471
+ this.flags &= ~2;
480
472
  }
481
473
  }
482
474
  stop() {
483
- if (this.active) {
484
- preCleanupEffect(this);
485
- postCleanupEffect(this);
475
+ if (this.flags & 1) {
476
+ for (let link = this.deps; link; link = link.nextDep) {
477
+ removeSub(link);
478
+ }
479
+ this.deps = this.depsTail = void 0;
480
+ cleanupEffect(this);
486
481
  this.onStop && this.onStop();
487
- this.active = false;
482
+ this.flags &= ~1;
488
483
  }
489
484
  }
485
+ trigger() {
486
+ if (this.scheduler) {
487
+ this.scheduler();
488
+ } else {
489
+ this.runIfDirty();
490
+ }
491
+ }
492
+ /**
493
+ * @internal
494
+ */
495
+ runIfDirty() {
496
+ if (isDirty(this)) {
497
+ this.run();
498
+ }
499
+ }
500
+ get dirty() {
501
+ return isDirty(this);
502
+ }
490
503
  }
491
- function triggerComputed(computed) {
492
- return computed.value;
504
+ let batchDepth = 0;
505
+ let batchedEffect;
506
+ function startBatch() {
507
+ batchDepth++;
493
508
  }
494
- function preCleanupEffect(effect2) {
495
- effect2._trackId++;
496
- effect2._depsLength = 0;
509
+ function endBatch() {
510
+ if (batchDepth > 1) {
511
+ batchDepth--;
512
+ return;
513
+ }
514
+ let error;
515
+ while (batchedEffect) {
516
+ let e = batchedEffect;
517
+ batchedEffect = void 0;
518
+ while (e) {
519
+ const next = e.nextEffect;
520
+ e.nextEffect = void 0;
521
+ e.flags &= ~8;
522
+ if (e.flags & 1) {
523
+ try {
524
+ e.trigger();
525
+ } catch (err) {
526
+ if (!error)
527
+ error = err;
528
+ }
529
+ }
530
+ e = next;
531
+ }
532
+ }
533
+ batchDepth--;
534
+ if (error)
535
+ throw error;
497
536
  }
498
- function postCleanupEffect(effect2) {
499
- if (effect2.deps.length > effect2._depsLength) {
500
- for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
501
- cleanupDepEffect(effect2.deps[i], effect2);
537
+ function prepareDeps(sub) {
538
+ for (let link = sub.deps; link; link = link.nextDep) {
539
+ link.version = -1;
540
+ link.prevActiveLink = link.dep.activeLink;
541
+ link.dep.activeLink = link;
542
+ }
543
+ }
544
+ function cleanupDeps(sub) {
545
+ let head;
546
+ let tail = sub.depsTail;
547
+ for (let link = tail; link; link = link.prevDep) {
548
+ if (link.version === -1) {
549
+ if (link === tail)
550
+ tail = link.prevDep;
551
+ removeSub(link);
552
+ removeDep(link);
553
+ } else {
554
+ head = link;
502
555
  }
503
- effect2.deps.length = effect2._depsLength;
556
+ link.dep.activeLink = link.prevActiveLink;
557
+ link.prevActiveLink = void 0;
504
558
  }
559
+ sub.deps = head;
560
+ sub.depsTail = tail;
505
561
  }
506
- function cleanupDepEffect(dep, effect2) {
507
- const trackId = dep.get(effect2);
508
- if (trackId !== void 0 && effect2._trackId !== trackId) {
509
- dep.delete(effect2);
510
- if (dep.size === 0) {
511
- dep.cleanup();
562
+ function isDirty(sub) {
563
+ for (let link = sub.deps; link; link = link.nextDep) {
564
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
565
+ return true;
512
566
  }
513
567
  }
568
+ if (sub._dirty) {
569
+ return true;
570
+ }
571
+ return false;
572
+ }
573
+ function refreshComputed(computed) {
574
+ if (computed.flags & 2) {
575
+ return false;
576
+ }
577
+ if (computed.flags & 4 && !(computed.flags & 16)) {
578
+ return;
579
+ }
580
+ computed.flags &= ~16;
581
+ if (computed.globalVersion === globalVersion) {
582
+ return;
583
+ }
584
+ computed.globalVersion = globalVersion;
585
+ const dep = computed.dep;
586
+ computed.flags |= 2;
587
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
588
+ computed.flags &= ~2;
589
+ return;
590
+ }
591
+ const prevSub = activeSub;
592
+ const prevShouldTrack = shouldTrack;
593
+ activeSub = computed;
594
+ shouldTrack = true;
595
+ try {
596
+ prepareDeps(computed);
597
+ const value = computed.fn();
598
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
599
+ computed._value = value;
600
+ dep.version++;
601
+ }
602
+ } catch (err) {
603
+ dep.version++;
604
+ throw err;
605
+ } finally {
606
+ activeSub = prevSub;
607
+ shouldTrack = prevShouldTrack;
608
+ cleanupDeps(computed);
609
+ computed.flags &= ~2;
610
+ }
611
+ }
612
+ function removeSub(link) {
613
+ const { dep, prevSub, nextSub } = link;
614
+ if (prevSub) {
615
+ prevSub.nextSub = nextSub;
616
+ link.prevSub = void 0;
617
+ }
618
+ if (nextSub) {
619
+ nextSub.prevSub = prevSub;
620
+ link.nextSub = void 0;
621
+ }
622
+ if (dep.subs === link) {
623
+ dep.subs = prevSub;
624
+ }
625
+ if (!dep.subs && dep.computed) {
626
+ dep.computed.flags &= ~4;
627
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
628
+ removeSub(l);
629
+ }
630
+ }
631
+ }
632
+ function removeDep(link) {
633
+ const { prevDep, nextDep } = link;
634
+ if (prevDep) {
635
+ prevDep.nextDep = nextDep;
636
+ link.prevDep = void 0;
637
+ }
638
+ if (nextDep) {
639
+ nextDep.prevDep = prevDep;
640
+ link.nextDep = void 0;
641
+ }
514
642
  }
515
643
  function effect(fn, options) {
516
644
  if (fn.effect instanceof ReactiveEffect) {
517
645
  fn = fn.effect.fn;
518
646
  }
519
- const _effect = new ReactiveEffect(fn, NOOP, () => {
520
- if (_effect.dirty) {
521
- _effect.run();
522
- }
523
- });
647
+ const e = new ReactiveEffect(fn);
524
648
  if (options) {
525
- extend(_effect, options);
526
- if (options.scope)
527
- recordEffectScope(_effect, options.scope);
649
+ extend(e, options);
528
650
  }
529
- if (!options || !options.lazy) {
530
- _effect.run();
651
+ try {
652
+ e.run();
653
+ } catch (err) {
654
+ e.stop();
655
+ throw err;
531
656
  }
532
- const runner = _effect.run.bind(_effect);
533
- runner.effect = _effect;
657
+ const runner = e.run.bind(e);
658
+ runner.effect = e;
534
659
  return runner;
535
660
  }
536
661
  function stop(runner) {
537
662
  runner.effect.stop();
538
663
  }
539
664
  let shouldTrack = true;
540
- let pauseScheduleStack = 0;
541
665
  const trackStack = [];
542
666
  function pauseTracking() {
543
667
  trackStack.push(shouldTrack);
@@ -547,192 +671,414 @@ var VueRuntimeDOM = (function (exports) {
547
671
  const last = trackStack.pop();
548
672
  shouldTrack = last === void 0 ? true : last;
549
673
  }
550
- function pauseScheduling() {
551
- pauseScheduleStack++;
552
- }
553
- function resetScheduling() {
554
- pauseScheduleStack--;
555
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
556
- queueEffectSchedulers.shift()();
674
+ function cleanupEffect(e) {
675
+ const { cleanup } = e;
676
+ e.cleanup = void 0;
677
+ if (cleanup) {
678
+ const prevSub = activeSub;
679
+ activeSub = void 0;
680
+ try {
681
+ cleanup();
682
+ } finally {
683
+ activeSub = prevSub;
684
+ }
557
685
  }
558
686
  }
559
- function trackEffect(effect2, dep, debuggerEventExtraInfo) {
560
- var _a;
561
- if (dep.get(effect2) !== effect2._trackId) {
562
- dep.set(effect2, effect2._trackId);
563
- const oldDep = effect2.deps[effect2._depsLength];
564
- if (oldDep !== dep) {
565
- if (oldDep) {
566
- cleanupDepEffect(oldDep, effect2);
567
- }
568
- effect2.deps[effect2._depsLength++] = dep;
569
- } else {
570
- effect2._depsLength++;
571
- }
687
+
688
+ let globalVersion = 0;
689
+ class Dep {
690
+ constructor(computed) {
691
+ this.computed = computed;
692
+ this.version = 0;
693
+ /**
694
+ * Link between this dep and the current active effect
695
+ */
696
+ this.activeLink = void 0;
697
+ /**
698
+ * Doubly linked list representing the subscribing effects (tail)
699
+ */
700
+ this.subs = void 0;
572
701
  {
573
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
702
+ this.subsHead = void 0;
574
703
  }
575
704
  }
576
- }
577
- const queueEffectSchedulers = [];
578
- function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
579
- var _a;
580
- pauseScheduling();
581
- for (const effect2 of dep.keys()) {
582
- let tracking;
583
- if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
584
- effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
585
- effect2._dirtyLevel = dirtyLevel;
586
- }
587
- if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
588
- {
589
- (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
705
+ track(debugInfo) {
706
+ if (!activeSub || !shouldTrack) {
707
+ return;
708
+ }
709
+ let link = this.activeLink;
710
+ if (link === void 0 || link.sub !== activeSub) {
711
+ link = this.activeLink = {
712
+ dep: this,
713
+ sub: activeSub,
714
+ version: this.version,
715
+ nextDep: void 0,
716
+ prevDep: void 0,
717
+ nextSub: void 0,
718
+ prevSub: void 0,
719
+ prevActiveLink: void 0
720
+ };
721
+ if (!activeSub.deps) {
722
+ activeSub.deps = activeSub.depsTail = link;
723
+ } else {
724
+ link.prevDep = activeSub.depsTail;
725
+ activeSub.depsTail.nextDep = link;
726
+ activeSub.depsTail = link;
727
+ }
728
+ if (activeSub.flags & 4) {
729
+ addSub(link);
590
730
  }
591
- effect2.trigger();
592
- if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
593
- effect2._shouldSchedule = false;
594
- if (effect2.scheduler) {
595
- queueEffectSchedulers.push(effect2.scheduler);
731
+ } else if (link.version === -1) {
732
+ link.version = this.version;
733
+ if (link.nextDep) {
734
+ const next = link.nextDep;
735
+ next.prevDep = link.prevDep;
736
+ if (link.prevDep) {
737
+ link.prevDep.nextDep = next;
738
+ }
739
+ link.prevDep = activeSub.depsTail;
740
+ link.nextDep = void 0;
741
+ activeSub.depsTail.nextDep = link;
742
+ activeSub.depsTail = link;
743
+ if (activeSub.deps === link) {
744
+ activeSub.deps = next;
596
745
  }
597
746
  }
598
747
  }
748
+ if (activeSub.onTrack) {
749
+ activeSub.onTrack(
750
+ extend(
751
+ {
752
+ effect: activeSub
753
+ },
754
+ debugInfo
755
+ )
756
+ );
757
+ }
758
+ return link;
759
+ }
760
+ trigger(debugInfo) {
761
+ this.version++;
762
+ globalVersion++;
763
+ this.notify(debugInfo);
764
+ }
765
+ notify(debugInfo) {
766
+ startBatch();
767
+ try {
768
+ if (true) {
769
+ for (let head = this.subsHead; head; head = head.nextSub) {
770
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
771
+ head.sub.onTrigger(
772
+ extend(
773
+ {
774
+ effect: head.sub
775
+ },
776
+ debugInfo
777
+ )
778
+ );
779
+ }
780
+ }
781
+ }
782
+ for (let link = this.subs; link; link = link.prevSub) {
783
+ link.sub.notify();
784
+ }
785
+ } finally {
786
+ endBatch();
787
+ }
599
788
  }
600
- resetScheduling();
601
789
  }
602
-
603
- const createDep = (cleanup, computed) => {
604
- const dep = /* @__PURE__ */ new Map();
605
- dep.cleanup = cleanup;
606
- dep.computed = computed;
607
- return dep;
608
- };
609
-
790
+ function addSub(link) {
791
+ const computed = link.dep.computed;
792
+ if (computed && !link.dep.subs) {
793
+ computed.flags |= 4 | 16;
794
+ for (let l = computed.deps; l; l = l.nextDep) {
795
+ addSub(l);
796
+ }
797
+ }
798
+ const currentTail = link.dep.subs;
799
+ if (currentTail !== link) {
800
+ link.prevSub = currentTail;
801
+ if (currentTail)
802
+ currentTail.nextSub = link;
803
+ }
804
+ if (link.dep.subsHead === void 0) {
805
+ link.dep.subsHead = link;
806
+ }
807
+ link.dep.subs = link;
808
+ }
610
809
  const targetMap = /* @__PURE__ */ new WeakMap();
611
- const ITERATE_KEY = Symbol("iterate" );
612
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
810
+ const ITERATE_KEY = Symbol("Object iterate" );
811
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
812
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
613
813
  function track(target, type, key) {
614
- if (shouldTrack && activeEffect) {
814
+ if (shouldTrack && activeSub) {
615
815
  let depsMap = targetMap.get(target);
616
816
  if (!depsMap) {
617
817
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
618
818
  }
619
819
  let dep = depsMap.get(key);
620
820
  if (!dep) {
621
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
821
+ depsMap.set(key, dep = new Dep());
622
822
  }
623
- trackEffect(
624
- activeEffect,
625
- dep,
626
- {
823
+ {
824
+ dep.track({
627
825
  target,
628
826
  type,
629
827
  key
630
- }
631
- );
828
+ });
829
+ }
632
830
  }
633
831
  }
634
832
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
635
833
  const depsMap = targetMap.get(target);
636
834
  if (!depsMap) {
835
+ globalVersion++;
637
836
  return;
638
837
  }
639
838
  let deps = [];
640
839
  if (type === "clear") {
641
840
  deps = [...depsMap.values()];
642
- } else if (key === "length" && isArray(target)) {
643
- const newLength = Number(newValue);
644
- depsMap.forEach((dep, key2) => {
645
- if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
646
- deps.push(dep);
647
- }
648
- });
649
841
  } else {
650
- if (key !== void 0) {
651
- deps.push(depsMap.get(key));
652
- }
653
- switch (type) {
654
- case "add":
655
- if (!isArray(target)) {
656
- deps.push(depsMap.get(ITERATE_KEY));
657
- if (isMap(target)) {
658
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
659
- }
660
- } else if (isIntegerKey(key)) {
661
- deps.push(depsMap.get("length"));
842
+ const targetIsArray = isArray(target);
843
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
844
+ if (targetIsArray && key === "length") {
845
+ const newLength = Number(newValue);
846
+ depsMap.forEach((dep, key2) => {
847
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
848
+ deps.push(dep);
662
849
  }
663
- break;
664
- case "delete":
665
- if (!isArray(target)) {
666
- deps.push(depsMap.get(ITERATE_KEY));
850
+ });
851
+ } else {
852
+ const push = (dep) => dep && deps.push(dep);
853
+ if (key !== void 0) {
854
+ push(depsMap.get(key));
855
+ }
856
+ if (isArrayIndex) {
857
+ push(depsMap.get(ARRAY_ITERATE_KEY));
858
+ }
859
+ switch (type) {
860
+ case "add":
861
+ if (!targetIsArray) {
862
+ push(depsMap.get(ITERATE_KEY));
863
+ if (isMap(target)) {
864
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
865
+ }
866
+ } else if (isArrayIndex) {
867
+ push(depsMap.get("length"));
868
+ }
869
+ break;
870
+ case "delete":
871
+ if (!targetIsArray) {
872
+ push(depsMap.get(ITERATE_KEY));
873
+ if (isMap(target)) {
874
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
875
+ }
876
+ }
877
+ break;
878
+ case "set":
667
879
  if (isMap(target)) {
668
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
880
+ push(depsMap.get(ITERATE_KEY));
669
881
  }
670
- }
671
- break;
672
- case "set":
673
- if (isMap(target)) {
674
- deps.push(depsMap.get(ITERATE_KEY));
675
- }
676
- break;
882
+ break;
883
+ }
677
884
  }
678
885
  }
679
- pauseScheduling();
886
+ startBatch();
680
887
  for (const dep of deps) {
681
- if (dep) {
682
- triggerEffects(
683
- dep,
684
- 4,
685
- {
686
- target,
687
- type,
688
- key,
689
- newValue,
690
- oldValue,
691
- oldTarget
692
- }
693
- );
888
+ {
889
+ dep.trigger({
890
+ target,
891
+ type,
892
+ key,
893
+ newValue,
894
+ oldValue,
895
+ oldTarget
896
+ });
694
897
  }
695
898
  }
696
- resetScheduling();
899
+ endBatch();
697
900
  }
698
901
  function getDepFromReactive(object, key) {
699
- const depsMap = targetMap.get(object);
700
- return depsMap && depsMap.get(key);
902
+ var _a;
903
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
904
+ }
905
+
906
+ function reactiveReadArray(array) {
907
+ const raw = toRaw(array);
908
+ if (raw === array)
909
+ return raw;
910
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
911
+ return isShallow(array) ? raw : raw.map(toReactive);
912
+ }
913
+ function shallowReadArray(arr) {
914
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
915
+ return arr;
916
+ }
917
+ const arrayInstrumentations = {
918
+ __proto__: null,
919
+ [Symbol.iterator]() {
920
+ return iterator(this, Symbol.iterator, toReactive);
921
+ },
922
+ concat(...args) {
923
+ return reactiveReadArray(this).concat(
924
+ ...args.map((x) => reactiveReadArray(x))
925
+ );
926
+ },
927
+ entries() {
928
+ return iterator(this, "entries", (value) => {
929
+ value[1] = toReactive(value[1]);
930
+ return value;
931
+ });
932
+ },
933
+ every(fn, thisArg) {
934
+ return apply(this, "every", fn, thisArg);
935
+ },
936
+ filter(fn, thisArg) {
937
+ const result = apply(this, "filter", fn, thisArg);
938
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
939
+ },
940
+ find(fn, thisArg) {
941
+ const result = apply(this, "find", fn, thisArg);
942
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
943
+ },
944
+ findIndex(fn, thisArg) {
945
+ return apply(this, "findIndex", fn, thisArg);
946
+ },
947
+ findLast(fn, thisArg) {
948
+ const result = apply(this, "findLast", fn, thisArg);
949
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
950
+ },
951
+ findLastIndex(fn, thisArg) {
952
+ return apply(this, "findLastIndex", fn, thisArg);
953
+ },
954
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
955
+ forEach(fn, thisArg) {
956
+ return apply(this, "forEach", fn, thisArg);
957
+ },
958
+ includes(...args) {
959
+ return searchProxy(this, "includes", args);
960
+ },
961
+ indexOf(...args) {
962
+ return searchProxy(this, "indexOf", args);
963
+ },
964
+ join(separator) {
965
+ return reactiveReadArray(this).join(separator);
966
+ },
967
+ // keys() iterator only reads `length`, no optimisation required
968
+ lastIndexOf(...args) {
969
+ return searchProxy(this, "lastIndexOf", args);
970
+ },
971
+ map(fn, thisArg) {
972
+ return apply(this, "map", fn, thisArg);
973
+ },
974
+ pop() {
975
+ return noTracking(this, "pop");
976
+ },
977
+ push(...args) {
978
+ return noTracking(this, "push", args);
979
+ },
980
+ reduce(fn, ...args) {
981
+ return reduce(this, "reduce", fn, args);
982
+ },
983
+ reduceRight(fn, ...args) {
984
+ return reduce(this, "reduceRight", fn, args);
985
+ },
986
+ shift() {
987
+ return noTracking(this, "shift");
988
+ },
989
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
990
+ some(fn, thisArg) {
991
+ return apply(this, "some", fn, thisArg);
992
+ },
993
+ splice(...args) {
994
+ return noTracking(this, "splice", args);
995
+ },
996
+ toReversed() {
997
+ return reactiveReadArray(this).toReversed();
998
+ },
999
+ toSorted(comparer) {
1000
+ return reactiveReadArray(this).toSorted(comparer);
1001
+ },
1002
+ toSpliced(...args) {
1003
+ return reactiveReadArray(this).toSpliced(...args);
1004
+ },
1005
+ unshift(...args) {
1006
+ return noTracking(this, "unshift", args);
1007
+ },
1008
+ values() {
1009
+ return iterator(this, "values", toReactive);
1010
+ }
1011
+ };
1012
+ function iterator(self, method, wrapValue) {
1013
+ const arr = shallowReadArray(self);
1014
+ const iter = arr[method]();
1015
+ if (arr !== self && !isShallow(self)) {
1016
+ iter._next = iter.next;
1017
+ iter.next = () => {
1018
+ const result = iter._next();
1019
+ if (result.value) {
1020
+ result.value = wrapValue(result.value);
1021
+ }
1022
+ return result;
1023
+ };
1024
+ }
1025
+ return iter;
1026
+ }
1027
+ function apply(self, method, fn, thisArg) {
1028
+ const arr = shallowReadArray(self);
1029
+ let wrappedFn = fn;
1030
+ if (arr !== self) {
1031
+ if (!isShallow(self)) {
1032
+ wrappedFn = function(item, index) {
1033
+ return fn.call(this, toReactive(item), index, self);
1034
+ };
1035
+ } else if (fn.length > 2) {
1036
+ wrappedFn = function(item, index) {
1037
+ return fn.call(this, item, index, self);
1038
+ };
1039
+ }
1040
+ }
1041
+ return arr[method](wrappedFn, thisArg);
1042
+ }
1043
+ function reduce(self, method, fn, args) {
1044
+ const arr = shallowReadArray(self);
1045
+ let wrappedFn = fn;
1046
+ if (arr !== self) {
1047
+ if (!isShallow(self)) {
1048
+ wrappedFn = function(acc, item, index) {
1049
+ return fn.call(this, acc, toReactive(item), index, self);
1050
+ };
1051
+ } else if (fn.length > 3) {
1052
+ wrappedFn = function(acc, item, index) {
1053
+ return fn.call(this, acc, item, index, self);
1054
+ };
1055
+ }
1056
+ }
1057
+ return arr[method](wrappedFn, ...args);
1058
+ }
1059
+ function searchProxy(self, method, args) {
1060
+ const arr = toRaw(self);
1061
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1062
+ const res = arr[method](...args);
1063
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1064
+ args[0] = toRaw(args[0]);
1065
+ return arr[method](...args);
1066
+ }
1067
+ return res;
1068
+ }
1069
+ function noTracking(self, method, args = []) {
1070
+ pauseTracking();
1071
+ startBatch();
1072
+ const res = toRaw(self)[method].apply(self, args);
1073
+ endBatch();
1074
+ resetTracking();
1075
+ return res;
701
1076
  }
702
1077
 
703
1078
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
704
1079
  const builtInSymbols = new Set(
705
1080
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
706
1081
  );
707
- const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
708
- function createArrayInstrumentations() {
709
- const instrumentations = {};
710
- ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
711
- instrumentations[key] = function(...args) {
712
- const arr = toRaw(this);
713
- for (let i = 0, l = this.length; i < l; i++) {
714
- track(arr, "get", i + "");
715
- }
716
- const res = arr[key](...args);
717
- if (res === -1 || res === false) {
718
- return arr[key](...args.map(toRaw));
719
- } else {
720
- return res;
721
- }
722
- };
723
- });
724
- ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
725
- instrumentations[key] = function(...args) {
726
- pauseTracking();
727
- pauseScheduling();
728
- const res = toRaw(this)[key].apply(this, args);
729
- resetScheduling();
730
- resetTracking();
731
- return res;
732
- };
733
- });
734
- return instrumentations;
735
- }
736
1082
  function hasOwnProperty(key) {
737
1083
  if (!isSymbol(key))
738
1084
  key = String(key);
@@ -763,14 +1109,22 @@ var VueRuntimeDOM = (function (exports) {
763
1109
  }
764
1110
  const targetIsArray = isArray(target);
765
1111
  if (!isReadonly2) {
766
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
767
- return Reflect.get(arrayInstrumentations, key, receiver);
1112
+ let fn;
1113
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1114
+ return fn;
768
1115
  }
769
1116
  if (key === "hasOwnProperty") {
770
1117
  return hasOwnProperty;
771
1118
  }
772
1119
  }
773
- const res = Reflect.get(target, key, receiver);
1120
+ const res = Reflect.get(
1121
+ target,
1122
+ key,
1123
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1124
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1125
+ // its class methods
1126
+ isRef(target) ? target : receiver
1127
+ );
774
1128
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
775
1129
  return res;
776
1130
  }
@@ -1269,110 +1623,8 @@ var VueRuntimeDOM = (function (exports) {
1269
1623
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1270
1624
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1271
1625
 
1272
- 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`;
1273
- class ComputedRefImpl {
1274
- constructor(getter, _setter, isReadonly, isSSR) {
1275
- this.getter = getter;
1276
- this._setter = _setter;
1277
- this.dep = void 0;
1278
- this.__v_isRef = true;
1279
- this["__v_isReadonly"] = false;
1280
- this.effect = new ReactiveEffect(
1281
- () => getter(this._value),
1282
- () => triggerRefValue(
1283
- this,
1284
- this.effect._dirtyLevel === 2 ? 2 : 3
1285
- )
1286
- );
1287
- this.effect.computed = this;
1288
- this.effect.active = this._cacheable = !isSSR;
1289
- this["__v_isReadonly"] = isReadonly;
1290
- }
1291
- get value() {
1292
- const self = toRaw(this);
1293
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1294
- triggerRefValue(self, 4);
1295
- }
1296
- trackRefValue(self);
1297
- if (self.effect._dirtyLevel >= 2) {
1298
- if (this._warnRecursive) {
1299
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1300
-
1301
- getter: `, this.getter);
1302
- }
1303
- triggerRefValue(self, 2);
1304
- }
1305
- return self._value;
1306
- }
1307
- set value(newValue) {
1308
- this._setter(newValue);
1309
- }
1310
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1311
- get _dirty() {
1312
- return this.effect.dirty;
1313
- }
1314
- set _dirty(v) {
1315
- this.effect.dirty = v;
1316
- }
1317
- // #endregion
1318
- }
1319
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1320
- let getter;
1321
- let setter;
1322
- const onlyGetter = isFunction(getterOrOptions);
1323
- if (onlyGetter) {
1324
- getter = getterOrOptions;
1325
- setter = () => {
1326
- warn$2("Write operation failed: computed value is readonly");
1327
- } ;
1328
- } else {
1329
- getter = getterOrOptions.get;
1330
- setter = getterOrOptions.set;
1331
- }
1332
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1333
- if (debugOptions && !isSSR) {
1334
- cRef.effect.onTrack = debugOptions.onTrack;
1335
- cRef.effect.onTrigger = debugOptions.onTrigger;
1336
- }
1337
- return cRef;
1338
- }
1339
-
1340
- function trackRefValue(ref2) {
1341
- var _a;
1342
- if (shouldTrack && activeEffect) {
1343
- ref2 = toRaw(ref2);
1344
- trackEffect(
1345
- activeEffect,
1346
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1347
- () => ref2.dep = void 0,
1348
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1349
- ),
1350
- {
1351
- target: ref2,
1352
- type: "get",
1353
- key: "value"
1354
- }
1355
- );
1356
- }
1357
- }
1358
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1359
- ref2 = toRaw(ref2);
1360
- const dep = ref2.dep;
1361
- if (dep) {
1362
- triggerEffects(
1363
- dep,
1364
- dirtyLevel,
1365
- {
1366
- target: ref2,
1367
- type: "set",
1368
- key: "value",
1369
- newValue: newVal
1370
- }
1371
- );
1372
- }
1373
- }
1374
1626
  function isRef(r) {
1375
- return !!(r && r.__v_isRef === true);
1627
+ return r ? r.__v_isRef === true : false;
1376
1628
  }
1377
1629
  function ref(value) {
1378
1630
  return createRef(value, false);
@@ -1389,27 +1641,49 @@ getter: `, this.getter);
1389
1641
  class RefImpl {
1390
1642
  constructor(value, __v_isShallow) {
1391
1643
  this.__v_isShallow = __v_isShallow;
1392
- this.dep = void 0;
1644
+ this.dep = new Dep();
1393
1645
  this.__v_isRef = true;
1394
1646
  this._rawValue = __v_isShallow ? value : toRaw(value);
1395
1647
  this._value = __v_isShallow ? value : toReactive(value);
1396
1648
  }
1397
1649
  get value() {
1398
- trackRefValue(this);
1650
+ {
1651
+ this.dep.track({
1652
+ target: this,
1653
+ type: "get",
1654
+ key: "value"
1655
+ });
1656
+ }
1399
1657
  return this._value;
1400
1658
  }
1401
- set value(newVal) {
1402
- const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
1403
- newVal = useDirectValue ? newVal : toRaw(newVal);
1404
- if (hasChanged(newVal, this._rawValue)) {
1405
- this._rawValue = newVal;
1406
- this._value = useDirectValue ? newVal : toReactive(newVal);
1407
- triggerRefValue(this, 4, newVal);
1659
+ set value(newValue) {
1660
+ const oldValue = this._rawValue;
1661
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1662
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1663
+ if (hasChanged(newValue, oldValue)) {
1664
+ this._rawValue = newValue;
1665
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1666
+ {
1667
+ this.dep.trigger({
1668
+ target: this,
1669
+ type: "set",
1670
+ key: "value",
1671
+ newValue,
1672
+ oldValue
1673
+ });
1674
+ }
1408
1675
  }
1409
1676
  }
1410
1677
  }
1411
1678
  function triggerRef(ref2) {
1412
- triggerRefValue(ref2, 4, ref2.value );
1679
+ {
1680
+ ref2.dep.trigger({
1681
+ target: ref2,
1682
+ type: "set",
1683
+ key: "value",
1684
+ newValue: ref2._value
1685
+ });
1686
+ }
1413
1687
  }
1414
1688
  function unref(ref2) {
1415
1689
  return isRef(ref2) ? ref2.value : ref2;
@@ -1434,12 +1708,9 @@ getter: `, this.getter);
1434
1708
  }
1435
1709
  class CustomRefImpl {
1436
1710
  constructor(factory) {
1437
- this.dep = void 0;
1438
1711
  this.__v_isRef = true;
1439
- const { get, set } = factory(
1440
- () => trackRefValue(this),
1441
- () => triggerRefValue(this)
1442
- );
1712
+ const dep = this.dep = new Dep();
1713
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1443
1714
  this._get = get;
1444
1715
  this._set = set;
1445
1716
  }
@@ -1507,6 +1778,90 @@ getter: `, this.getter);
1507
1778
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1508
1779
  }
1509
1780
 
1781
+ class ComputedRefImpl {
1782
+ constructor(fn, setter, isSSR) {
1783
+ this.fn = fn;
1784
+ this.setter = setter;
1785
+ /**
1786
+ * @internal
1787
+ */
1788
+ this._value = void 0;
1789
+ /**
1790
+ * @internal
1791
+ */
1792
+ this.dep = new Dep(this);
1793
+ /**
1794
+ * @internal
1795
+ */
1796
+ this.__v_isRef = true;
1797
+ // A computed is also a subscriber that tracks other deps
1798
+ /**
1799
+ * @internal
1800
+ */
1801
+ this.deps = void 0;
1802
+ /**
1803
+ * @internal
1804
+ */
1805
+ this.depsTail = void 0;
1806
+ /**
1807
+ * @internal
1808
+ */
1809
+ this.flags = 16;
1810
+ /**
1811
+ * @internal
1812
+ */
1813
+ this.globalVersion = globalVersion - 1;
1814
+ // for backwards compat
1815
+ this.effect = this;
1816
+ this.__v_isReadonly = !setter;
1817
+ this.isSSR = isSSR;
1818
+ }
1819
+ /**
1820
+ * @internal
1821
+ */
1822
+ notify() {
1823
+ if (activeSub !== this) {
1824
+ this.flags |= 16;
1825
+ this.dep.notify();
1826
+ }
1827
+ }
1828
+ get value() {
1829
+ const link = this.dep.track({
1830
+ target: this,
1831
+ type: "get",
1832
+ key: "value"
1833
+ }) ;
1834
+ refreshComputed(this);
1835
+ if (link) {
1836
+ link.version = this.dep.version;
1837
+ }
1838
+ return this._value;
1839
+ }
1840
+ set value(newValue) {
1841
+ if (this.setter) {
1842
+ this.setter(newValue);
1843
+ } else {
1844
+ warn$2("Write operation failed: computed value is readonly");
1845
+ }
1846
+ }
1847
+ }
1848
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1849
+ let getter;
1850
+ let setter;
1851
+ if (isFunction(getterOrOptions)) {
1852
+ getter = getterOrOptions;
1853
+ } else {
1854
+ getter = getterOrOptions.get;
1855
+ setter = getterOrOptions.set;
1856
+ }
1857
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1858
+ if (debugOptions && !isSSR) {
1859
+ cRef.onTrack = debugOptions.onTrack;
1860
+ cRef.onTrigger = debugOptions.onTrigger;
1861
+ }
1862
+ return cRef;
1863
+ }
1864
+
1510
1865
  const TrackOpTypes = {
1511
1866
  "GET": "get",
1512
1867
  "HAS": "has",
@@ -1666,7 +2021,9 @@ getter: `, this.getter);
1666
2021
  "ASYNC_COMPONENT_LOADER": 13,
1667
2022
  "13": "ASYNC_COMPONENT_LOADER",
1668
2023
  "SCHEDULER": 14,
1669
- "14": "SCHEDULER"
2024
+ "14": "SCHEDULER",
2025
+ "APP_UNMOUNT_CLEANUP": 15,
2026
+ "15": "APP_UNMOUNT_CLEANUP"
1670
2027
  };
1671
2028
  const ErrorTypeStrings$1 = {
1672
2029
  ["sp"]: "serverPrefetch hook",
@@ -1697,7 +2054,8 @@ getter: `, this.getter);
1697
2054
  [11]: "app warnHandler",
1698
2055
  [12]: "ref function",
1699
2056
  [13]: "async component loader",
1700
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
2057
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .",
2058
+ [15]: "app unmount cleanup function"
1701
2059
  };
1702
2060
  function callWithErrorHandling(fn, instance, type, args) {
1703
2061
  try {
@@ -1799,7 +2157,7 @@ getter: `, this.getter);
1799
2157
  const middle = start + end >>> 1;
1800
2158
  const middleJob = queue[middle];
1801
2159
  const middleJobId = getId(middleJob);
1802
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2160
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1803
2161
  start = middle + 1;
1804
2162
  } else {
1805
2163
  end = middle;
@@ -1808,15 +2166,21 @@ getter: `, this.getter);
1808
2166
  return start;
1809
2167
  }
1810
2168
  function queueJob(job) {
1811
- if (!queue.length || !queue.includes(
1812
- job,
1813
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1814
- )) {
2169
+ var _a;
2170
+ if (!(job.flags & 1)) {
1815
2171
  if (job.id == null) {
1816
2172
  queue.push(job);
2173
+ } else if (
2174
+ // fast path when the job id is larger than the tail
2175
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2176
+ ) {
2177
+ queue.push(job);
1817
2178
  } else {
1818
2179
  queue.splice(findInsertionIndex(job.id), 0, job);
1819
2180
  }
2181
+ if (!(job.flags & 4)) {
2182
+ job.flags |= 1;
2183
+ }
1820
2184
  queueFlush();
1821
2185
  }
1822
2186
  }
@@ -1834,11 +2198,11 @@ getter: `, this.getter);
1834
2198
  }
1835
2199
  function queuePostFlushCb(cb) {
1836
2200
  if (!isArray(cb)) {
1837
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1838
- cb,
1839
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1840
- )) {
2201
+ if (!(cb.flags & 1)) {
1841
2202
  pendingPostFlushCbs.push(cb);
2203
+ if (!(cb.flags & 4)) {
2204
+ cb.flags |= 1;
2205
+ }
1842
2206
  }
1843
2207
  } else {
1844
2208
  pendingPostFlushCbs.push(...cb);
@@ -1851,7 +2215,7 @@ getter: `, this.getter);
1851
2215
  }
1852
2216
  for (; i < queue.length; i++) {
1853
2217
  const cb = queue[i];
1854
- if (cb && cb.pre) {
2218
+ if (cb && cb.flags & 2) {
1855
2219
  if (instance && cb.id !== instance.uid) {
1856
2220
  continue;
1857
2221
  }
@@ -1861,6 +2225,7 @@ getter: `, this.getter);
1861
2225
  queue.splice(i, 1);
1862
2226
  i--;
1863
2227
  cb();
2228
+ cb.flags &= ~1;
1864
2229
  }
1865
2230
  }
1866
2231
  }
@@ -1883,6 +2248,7 @@ getter: `, this.getter);
1883
2248
  continue;
1884
2249
  }
1885
2250
  activePostFlushCbs[postFlushIndex]();
2251
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1886
2252
  }
1887
2253
  activePostFlushCbs = null;
1888
2254
  postFlushIndex = 0;
@@ -1892,9 +2258,11 @@ getter: `, this.getter);
1892
2258
  const comparator = (a, b) => {
1893
2259
  const diff = getId(a) - getId(b);
1894
2260
  if (diff === 0) {
1895
- if (a.pre && !b.pre)
2261
+ const isAPre = a.flags & 2;
2262
+ const isBPre = b.flags & 2;
2263
+ if (isAPre && !isBPre)
1896
2264
  return -1;
1897
- if (b.pre && !a.pre)
2265
+ if (isBPre && !isAPre)
1898
2266
  return 1;
1899
2267
  }
1900
2268
  return diff;
@@ -1910,11 +2278,12 @@ getter: `, this.getter);
1910
2278
  try {
1911
2279
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1912
2280
  const job = queue[flushIndex];
1913
- if (job && job.active !== false) {
2281
+ if (job && !(job.flags & 8)) {
1914
2282
  if (check(job)) {
1915
2283
  continue;
1916
2284
  }
1917
2285
  callWithErrorHandling(job, null, 14);
2286
+ job.flags &= ~1;
1918
2287
  }
1919
2288
  }
1920
2289
  } finally {
@@ -1996,7 +2365,6 @@ getter: `, this.getter);
1996
2365
  }
1997
2366
  instance.renderCache = [];
1998
2367
  isHmrUpdating = true;
1999
- instance.effect.dirty = true;
2000
2368
  instance.update();
2001
2369
  isHmrUpdating = false;
2002
2370
  });
@@ -2024,7 +2392,6 @@ getter: `, this.getter);
2024
2392
  instance.ceReload(newComp.styles);
2025
2393
  hmrDirtyComponents.delete(oldComp);
2026
2394
  } else if (instance.parent) {
2027
- instance.parent.effect.dirty = true;
2028
2395
  queueJob(instance.parent.update);
2029
2396
  } else if (instance.appContext.reload) {
2030
2397
  instance.appContext.reload();
@@ -3424,8 +3791,8 @@ If this is a native custom element, make sure to exclude it from component resol
3424
3791
  };
3425
3792
  };
3426
3793
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3427
- const job = () => {
3428
- if (!effect.active || !effect.dirty) {
3794
+ const job = (immediateFirstRun) => {
3795
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
3429
3796
  return;
3430
3797
  }
3431
3798
  if (cb) {
@@ -3446,19 +3813,22 @@ If this is a native custom element, make sure to exclude it from component resol
3446
3813
  effect.run();
3447
3814
  }
3448
3815
  };
3449
- job.allowRecurse = !!cb;
3816
+ if (cb)
3817
+ job.flags |= 4;
3818
+ const effect = new ReactiveEffect(getter);
3450
3819
  let scheduler;
3451
3820
  if (flush === "sync") {
3821
+ effect.flags |= 64;
3452
3822
  scheduler = job;
3453
3823
  } else if (flush === "post") {
3454
3824
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
3455
3825
  } else {
3456
- job.pre = true;
3826
+ job.flags |= 2;
3457
3827
  if (instance)
3458
3828
  job.id = instance.uid;
3459
3829
  scheduler = () => queueJob(job);
3460
3830
  }
3461
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
3831
+ effect.scheduler = scheduler;
3462
3832
  const scope = getCurrentScope();
3463
3833
  const unwatch = () => {
3464
3834
  effect.stop();
@@ -3472,7 +3842,7 @@ If this is a native custom element, make sure to exclude it from component resol
3472
3842
  }
3473
3843
  if (cb) {
3474
3844
  if (immediate) {
3475
- job();
3845
+ job(true);
3476
3846
  } else {
3477
3847
  oldValue = effect.run();
3478
3848
  }
@@ -3646,22 +4016,7 @@ If this is a native custom element, make sure to exclude it from component resol
3646
4016
  if (!children || !children.length) {
3647
4017
  return;
3648
4018
  }
3649
- let child = children[0];
3650
- if (children.length > 1) {
3651
- let hasFound = false;
3652
- for (const c of children) {
3653
- if (c.type !== Comment) {
3654
- if (hasFound) {
3655
- warn$1(
3656
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
3657
- );
3658
- break;
3659
- }
3660
- child = c;
3661
- hasFound = true;
3662
- }
3663
- }
3664
- }
4019
+ const child = findNonCommentChild(children);
3665
4020
  const rawProps = toRaw(props);
3666
4021
  const { mode } = rawProps;
3667
4022
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -3670,7 +4025,7 @@ If this is a native custom element, make sure to exclude it from component resol
3670
4025
  if (state.isLeaving) {
3671
4026
  return emptyPlaceholder(child);
3672
4027
  }
3673
- const innerChild = getKeepAliveChild(child);
4028
+ const innerChild = getInnerChild$1(child);
3674
4029
  if (!innerChild) {
3675
4030
  return emptyPlaceholder(child);
3676
4031
  }
@@ -3682,7 +4037,7 @@ If this is a native custom element, make sure to exclude it from component resol
3682
4037
  );
3683
4038
  setTransitionHooks(innerChild, enterHooks);
3684
4039
  const oldChild = instance.subTree;
3685
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4040
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
3686
4041
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
3687
4042
  const leavingHooks = resolveTransitionHooks(
3688
4043
  oldInnerChild,
@@ -3695,8 +4050,7 @@ If this is a native custom element, make sure to exclude it from component resol
3695
4050
  state.isLeaving = true;
3696
4051
  leavingHooks.afterLeave = () => {
3697
4052
  state.isLeaving = false;
3698
- if (instance.update.active !== false) {
3699
- instance.effect.dirty = true;
4053
+ if (!(instance.job.flags & 8)) {
3700
4054
  instance.update();
3701
4055
  }
3702
4056
  };
@@ -3721,6 +4075,25 @@ If this is a native custom element, make sure to exclude it from component resol
3721
4075
  };
3722
4076
  }
3723
4077
  };
4078
+ function findNonCommentChild(children) {
4079
+ let child = children[0];
4080
+ if (children.length > 1) {
4081
+ let hasFound = false;
4082
+ for (const c of children) {
4083
+ if (c.type !== Comment) {
4084
+ if (hasFound) {
4085
+ warn$1(
4086
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4087
+ );
4088
+ break;
4089
+ }
4090
+ child = c;
4091
+ hasFound = true;
4092
+ }
4093
+ }
4094
+ }
4095
+ return child;
4096
+ }
3724
4097
  const BaseTransition = BaseTransitionImpl;
3725
4098
  function getLeavingNodesForType(state, vnode) {
3726
4099
  const { leavingVNodes } = state;
@@ -3875,8 +4248,11 @@ If this is a native custom element, make sure to exclude it from component resol
3875
4248
  return vnode;
3876
4249
  }
3877
4250
  }
3878
- function getKeepAliveChild(vnode) {
4251
+ function getInnerChild$1(vnode) {
3879
4252
  if (!isKeepAlive(vnode)) {
4253
+ if (isTeleport(vnode.type) && vnode.children) {
4254
+ return findNonCommentChild(vnode.children);
4255
+ }
3880
4256
  return vnode;
3881
4257
  }
3882
4258
  if (vnode.component) {
@@ -4045,7 +4421,6 @@ If this is a native custom element, make sure to exclude it from component resol
4045
4421
  load().then(() => {
4046
4422
  loaded.value = true;
4047
4423
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4048
- instance.parent.effect.dirty = true;
4049
4424
  queueJob(instance.parent.update);
4050
4425
  }
4051
4426
  }).catch((err) => {
@@ -4370,10 +4745,20 @@ If this is a native custom element, make sure to exclude it from component resol
4370
4745
  function renderList(source, renderItem, cache, index) {
4371
4746
  let ret;
4372
4747
  const cached = cache && cache[index];
4373
- if (isArray(source) || isString(source)) {
4748
+ const sourceIsArray = isArray(source);
4749
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
4750
+ if (sourceIsArray || isString(source)) {
4751
+ if (sourceIsReactiveArray) {
4752
+ source = shallowReadArray(source);
4753
+ }
4374
4754
  ret = new Array(source.length);
4375
4755
  for (let i = 0, l = source.length; i < l; i++) {
4376
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
4756
+ ret[i] = renderItem(
4757
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
4758
+ i,
4759
+ void 0,
4760
+ cached && cached[i]
4761
+ );
4377
4762
  }
4378
4763
  } else if (typeof source === "number") {
4379
4764
  if (!Number.isInteger(source)) {
@@ -4508,7 +4893,6 @@ If this is a native custom element, make sure to exclude it from component resol
4508
4893
  $emit: (i) => i.emit,
4509
4894
  $options: (i) => resolveMergedOptions(i) ,
4510
4895
  $forceUpdate: (i) => i.f || (i.f = () => {
4511
- i.effect.dirty = true;
4512
4896
  queueJob(i.update);
4513
4897
  }),
4514
4898
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -5303,6 +5687,7 @@ If this is a native custom element, make sure to exclude it from component resol
5303
5687
  }
5304
5688
  const context = createAppContext();
5305
5689
  const installedPlugins = /* @__PURE__ */ new WeakSet();
5690
+ const pluginCleanupFns = [];
5306
5691
  let isMounted = false;
5307
5692
  const app = context.app = {
5308
5693
  _uid: uid$1++,
@@ -5420,8 +5805,21 @@ If you want to remount the same app, move your app creation logic into a factory
5420
5805
  );
5421
5806
  }
5422
5807
  },
5808
+ onUnmount(cleanupFn) {
5809
+ if (typeof cleanupFn !== "function") {
5810
+ warn$1(
5811
+ `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
5812
+ );
5813
+ }
5814
+ pluginCleanupFns.push(cleanupFn);
5815
+ },
5423
5816
  unmount() {
5424
5817
  if (isMounted) {
5818
+ callWithAsyncErrorHandling(
5819
+ pluginCleanupFns,
5820
+ app._instance,
5821
+ 15
5822
+ );
5425
5823
  render(null, app._container);
5426
5824
  {
5427
5825
  app._instance = null;
@@ -5841,7 +6239,9 @@ If you want to remount the same app, move your app creation logic into a factory
5841
6239
  function assertType(value, type) {
5842
6240
  let valid;
5843
6241
  const expectedType = getType(type);
5844
- if (isSimpleType(expectedType)) {
6242
+ if (expectedType === "null") {
6243
+ valid = value === null;
6244
+ } else if (isSimpleType(expectedType)) {
5845
6245
  const t = typeof value;
5846
6246
  valid = t === expectedType.toLowerCase();
5847
6247
  if (!valid && t === "object") {
@@ -5851,8 +6251,6 @@ If you want to remount the same app, move your app creation logic into a factory
5851
6251
  valid = isObject(value);
5852
6252
  } else if (expectedType === "Array") {
5853
6253
  valid = isArray(value);
5854
- } else if (expectedType === "null") {
5855
- valid = value === null;
5856
6254
  } else {
5857
6255
  valid = value instanceof type;
5858
6256
  }
@@ -7376,7 +7774,6 @@ Server rendered element contains fewer child nodes than client vdom.`
7376
7774
  } else {
7377
7775
  instance.next = n2;
7378
7776
  invalidateJob(instance.update);
7379
- instance.effect.dirty = true;
7380
7777
  instance.update();
7381
7778
  }
7382
7779
  } else {
@@ -7559,24 +7956,18 @@ Server rendered element contains fewer child nodes than client vdom.`
7559
7956
  }
7560
7957
  }
7561
7958
  };
7562
- const effect = instance.effect = new ReactiveEffect(
7563
- componentUpdateFn,
7564
- NOOP,
7565
- () => queueJob(update),
7566
- instance.scope
7567
- // track it in component's effect scope
7568
- );
7569
- const update = instance.update = () => {
7570
- if (effect.dirty) {
7571
- effect.run();
7572
- }
7573
- };
7574
- update.id = instance.uid;
7959
+ instance.scope.on();
7960
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
7961
+ instance.scope.off();
7962
+ const update = instance.update = effect.run.bind(effect);
7963
+ const job = instance.job = effect.runIfDirty.bind(effect);
7964
+ job.id = instance.uid;
7965
+ effect.scheduler = () => queueJob(job);
7575
7966
  toggleRecurse(instance, true);
7576
7967
  {
7577
7968
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
7578
7969
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
7579
- update.ownerInstance = instance;
7970
+ job.ownerInstance = instance;
7580
7971
  }
7581
7972
  update();
7582
7973
  };
@@ -8043,13 +8434,13 @@ Server rendered element contains fewer child nodes than client vdom.`
8043
8434
  if (instance.type.__hmrId) {
8044
8435
  unregisterHMR(instance);
8045
8436
  }
8046
- const { bum, scope, update, subTree, um } = instance;
8437
+ const { bum, scope, job, subTree, um } = instance;
8047
8438
  if (bum) {
8048
8439
  invokeArrayFns(bum);
8049
8440
  }
8050
8441
  scope.stop();
8051
- if (update) {
8052
- update.active = false;
8442
+ if (job) {
8443
+ job.flags |= 8;
8053
8444
  unmount(subTree, instance, parentSuspense, doRemove);
8054
8445
  }
8055
8446
  if (um) {
@@ -8135,8 +8526,14 @@ Server rendered element contains fewer child nodes than client vdom.`
8135
8526
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
8136
8527
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
8137
8528
  }
8138
- function toggleRecurse({ effect, update }, allowed) {
8139
- effect.allowRecurse = update.allowRecurse = allowed;
8529
+ function toggleRecurse({ effect, job }, allowed) {
8530
+ if (allowed) {
8531
+ effect.flags |= 32;
8532
+ job.flags |= 4;
8533
+ } else {
8534
+ effect.flags &= ~32;
8535
+ job.flags &= ~4;
8536
+ }
8140
8537
  }
8141
8538
  function needTransition(parentSuspense, transition) {
8142
8539
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -8876,6 +9273,7 @@ Component that was made reactive: `,
8876
9273
  effect: null,
8877
9274
  update: null,
8878
9275
  // will be set synchronously right after creation
9276
+ job: null,
8879
9277
  scope: new EffectScope(
8880
9278
  true
8881
9279
  /* detached */
@@ -9369,7 +9767,8 @@ Component that was made reactive: `,
9369
9767
  {},
9370
9768
  ["span", vueStyle, genRefFlag(obj)],
9371
9769
  "<",
9372
- formatValue(obj.value),
9770
+ // avoid debugger accessing value affecting behavior
9771
+ formatValue("_value" in obj ? obj._value : obj),
9373
9772
  `>`
9374
9773
  ];
9375
9774
  } else if (isReactive(obj)) {
@@ -9549,7 +9948,7 @@ Component that was made reactive: `,
9549
9948
  return true;
9550
9949
  }
9551
9950
 
9552
- const version = "3.4.26";
9951
+ const version = "3.5.0-alpha.2";
9553
9952
  const warn = warn$1 ;
9554
9953
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9555
9954
  const devtools = devtools$1 ;
@@ -10992,7 +11391,9 @@ Expected function or array of functions, received type ${typeof value}.`
10992
11391
  return;
10993
11392
  }
10994
11393
  const eventKey = hyphenate(event.key);
10995
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
11394
+ if (modifiers.some(
11395
+ (k) => k === eventKey || keyNames[k] === eventKey
11396
+ )) {
10996
11397
  return fn(event);
10997
11398
  }
10998
11399
  });