@vue/compat 3.4.26 → 3.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.4.26
2
+ * @vue/compat v3.5.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -81,11 +81,10 @@ const invokeArrayFns = (fns, arg) => {
81
81
  fns[i](arg);
82
82
  }
83
83
  };
84
- const def = (obj, key, value, writable = false) => {
84
+ const def = (obj, key, value) => {
85
85
  Object.defineProperty(obj, key, {
86
86
  configurable: true,
87
87
  enumerable: false,
88
- writable,
89
88
  value
90
89
  });
91
90
  };
@@ -385,156 +384,280 @@ class EffectScope {
385
384
  function effectScope(detached) {
386
385
  return new EffectScope(detached);
387
386
  }
388
- function recordEffectScope(effect, scope = activeEffectScope) {
389
- if (scope && scope.active) {
390
- scope.effects.push(effect);
391
- }
392
- }
393
387
  function getCurrentScope() {
394
388
  return activeEffectScope;
395
389
  }
396
- function onScopeDispose(fn) {
390
+ function onScopeDispose(fn, failSilently = false) {
397
391
  if (activeEffectScope) {
398
392
  activeEffectScope.cleanups.push(fn);
399
- } else {
393
+ } else if (!failSilently) {
400
394
  warn$2(
401
395
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
402
396
  );
403
397
  }
404
398
  }
405
399
 
406
- let activeEffect;
400
+ let activeSub;
407
401
  class ReactiveEffect {
408
- constructor(fn, trigger, scheduler, scope) {
402
+ constructor(fn) {
409
403
  this.fn = fn;
410
- this.trigger = trigger;
411
- this.scheduler = scheduler;
412
- this.active = true;
413
- this.deps = [];
414
404
  /**
415
405
  * @internal
416
406
  */
417
- this._dirtyLevel = 4;
407
+ this.deps = void 0;
418
408
  /**
419
409
  * @internal
420
410
  */
421
- this._trackId = 0;
411
+ this.depsTail = void 0;
422
412
  /**
423
413
  * @internal
424
414
  */
425
- this._runnings = 0;
415
+ this.flags = 1 | 4;
426
416
  /**
427
417
  * @internal
428
418
  */
429
- this._shouldSchedule = false;
419
+ this.nextEffect = void 0;
430
420
  /**
431
421
  * @internal
432
422
  */
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();
423
+ this.cleanup = void 0;
424
+ this.scheduler = void 0;
425
+ if (activeEffectScope && activeEffectScope.active) {
426
+ activeEffectScope.effects.push(this);
453
427
  }
454
- return this._dirtyLevel >= 4;
455
428
  }
456
- set dirty(v) {
457
- this._dirtyLevel = v ? 4 : 0;
429
+ /**
430
+ * @internal
431
+ */
432
+ notify() {
433
+ if (this.flags & 2 && !(this.flags & 32)) {
434
+ return;
435
+ }
436
+ if (this.flags & 64) {
437
+ return this.trigger();
438
+ }
439
+ if (!(this.flags & 8)) {
440
+ this.flags |= 8;
441
+ this.nextEffect = batchedEffect;
442
+ batchedEffect = this;
443
+ }
458
444
  }
459
445
  run() {
460
- this._dirtyLevel = 0;
461
- if (!this.active) {
446
+ if (!(this.flags & 1)) {
462
447
  return this.fn();
463
448
  }
464
- let lastShouldTrack = shouldTrack;
465
- let lastEffect = activeEffect;
449
+ this.flags |= 2;
450
+ cleanupEffect(this);
451
+ prepareDeps(this);
452
+ const prevEffect = activeSub;
453
+ const prevShouldTrack = shouldTrack;
454
+ activeSub = this;
455
+ shouldTrack = true;
466
456
  try {
467
- shouldTrack = true;
468
- activeEffect = this;
469
- this._runnings++;
470
- preCleanupEffect(this);
471
457
  return this.fn();
472
458
  } finally {
473
- postCleanupEffect(this);
474
- this._runnings--;
475
- activeEffect = lastEffect;
476
- shouldTrack = lastShouldTrack;
459
+ if (activeSub !== this) {
460
+ warn$2(
461
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
462
+ );
463
+ }
464
+ cleanupDeps(this);
465
+ activeSub = prevEffect;
466
+ shouldTrack = prevShouldTrack;
467
+ this.flags &= ~2;
477
468
  }
478
469
  }
479
470
  stop() {
480
- if (this.active) {
481
- preCleanupEffect(this);
482
- postCleanupEffect(this);
471
+ if (this.flags & 1) {
472
+ for (let link = this.deps; link; link = link.nextDep) {
473
+ removeSub(link);
474
+ }
475
+ this.deps = this.depsTail = void 0;
476
+ cleanupEffect(this);
483
477
  this.onStop && this.onStop();
484
- this.active = false;
478
+ this.flags &= ~1;
479
+ }
480
+ }
481
+ trigger() {
482
+ if (this.scheduler) {
483
+ this.scheduler();
484
+ } else {
485
+ this.runIfDirty();
486
+ }
487
+ }
488
+ /**
489
+ * @internal
490
+ */
491
+ runIfDirty() {
492
+ if (isDirty(this)) {
493
+ this.run();
485
494
  }
486
495
  }
496
+ get dirty() {
497
+ return isDirty(this);
498
+ }
499
+ }
500
+ let batchDepth = 0;
501
+ let batchedEffect;
502
+ function startBatch() {
503
+ batchDepth++;
487
504
  }
488
- function triggerComputed(computed) {
489
- return computed.value;
505
+ function endBatch() {
506
+ if (batchDepth > 1) {
507
+ batchDepth--;
508
+ return;
509
+ }
510
+ let error;
511
+ while (batchedEffect) {
512
+ let e = batchedEffect;
513
+ batchedEffect = void 0;
514
+ while (e) {
515
+ const next = e.nextEffect;
516
+ e.nextEffect = void 0;
517
+ e.flags &= ~8;
518
+ if (e.flags & 1) {
519
+ try {
520
+ e.trigger();
521
+ } catch (err) {
522
+ if (!error)
523
+ error = err;
524
+ }
525
+ }
526
+ e = next;
527
+ }
528
+ }
529
+ batchDepth--;
530
+ if (error)
531
+ throw error;
490
532
  }
491
- function preCleanupEffect(effect2) {
492
- effect2._trackId++;
493
- effect2._depsLength = 0;
533
+ function prepareDeps(sub) {
534
+ for (let link = sub.deps; link; link = link.nextDep) {
535
+ link.version = -1;
536
+ link.prevActiveLink = link.dep.activeLink;
537
+ link.dep.activeLink = link;
538
+ }
494
539
  }
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);
540
+ function cleanupDeps(sub) {
541
+ let head;
542
+ let tail = sub.depsTail;
543
+ for (let link = tail; link; link = link.prevDep) {
544
+ if (link.version === -1) {
545
+ if (link === tail)
546
+ tail = link.prevDep;
547
+ removeSub(link);
548
+ removeDep(link);
549
+ } else {
550
+ head = link;
499
551
  }
500
- effect2.deps.length = effect2._depsLength;
552
+ link.dep.activeLink = link.prevActiveLink;
553
+ link.prevActiveLink = void 0;
501
554
  }
555
+ sub.deps = head;
556
+ sub.depsTail = tail;
502
557
  }
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();
558
+ function isDirty(sub) {
559
+ for (let link = sub.deps; link; link = link.nextDep) {
560
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
561
+ return true;
509
562
  }
510
563
  }
564
+ if (sub._dirty) {
565
+ return true;
566
+ }
567
+ return false;
568
+ }
569
+ function refreshComputed(computed) {
570
+ if (computed.flags & 2) {
571
+ return false;
572
+ }
573
+ if (computed.flags & 4 && !(computed.flags & 16)) {
574
+ return;
575
+ }
576
+ computed.flags &= ~16;
577
+ if (computed.globalVersion === globalVersion) {
578
+ return;
579
+ }
580
+ computed.globalVersion = globalVersion;
581
+ const dep = computed.dep;
582
+ computed.flags |= 2;
583
+ if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
584
+ computed.flags &= ~2;
585
+ return;
586
+ }
587
+ const prevSub = activeSub;
588
+ const prevShouldTrack = shouldTrack;
589
+ activeSub = computed;
590
+ shouldTrack = true;
591
+ try {
592
+ prepareDeps(computed);
593
+ const value = computed.fn();
594
+ if (dep.version === 0 || hasChanged(value, computed._value)) {
595
+ computed._value = value;
596
+ dep.version++;
597
+ }
598
+ } catch (err) {
599
+ dep.version++;
600
+ throw err;
601
+ } finally {
602
+ activeSub = prevSub;
603
+ shouldTrack = prevShouldTrack;
604
+ cleanupDeps(computed);
605
+ computed.flags &= ~2;
606
+ }
607
+ }
608
+ function removeSub(link) {
609
+ const { dep, prevSub, nextSub } = link;
610
+ if (prevSub) {
611
+ prevSub.nextSub = nextSub;
612
+ link.prevSub = void 0;
613
+ }
614
+ if (nextSub) {
615
+ nextSub.prevSub = prevSub;
616
+ link.nextSub = void 0;
617
+ }
618
+ if (dep.subs === link) {
619
+ dep.subs = prevSub;
620
+ }
621
+ if (!dep.subs && dep.computed) {
622
+ dep.computed.flags &= ~4;
623
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
624
+ removeSub(l);
625
+ }
626
+ }
627
+ }
628
+ function removeDep(link) {
629
+ const { prevDep, nextDep } = link;
630
+ if (prevDep) {
631
+ prevDep.nextDep = nextDep;
632
+ link.prevDep = void 0;
633
+ }
634
+ if (nextDep) {
635
+ nextDep.prevDep = prevDep;
636
+ link.nextDep = void 0;
637
+ }
511
638
  }
512
639
  function effect(fn, options) {
513
640
  if (fn.effect instanceof ReactiveEffect) {
514
641
  fn = fn.effect.fn;
515
642
  }
516
- const _effect = new ReactiveEffect(fn, NOOP, () => {
517
- if (_effect.dirty) {
518
- _effect.run();
519
- }
520
- });
643
+ const e = new ReactiveEffect(fn);
521
644
  if (options) {
522
- extend(_effect, options);
523
- if (options.scope)
524
- recordEffectScope(_effect, options.scope);
645
+ extend(e, options);
525
646
  }
526
- if (!options || !options.lazy) {
527
- _effect.run();
647
+ try {
648
+ e.run();
649
+ } catch (err) {
650
+ e.stop();
651
+ throw err;
528
652
  }
529
- const runner = _effect.run.bind(_effect);
530
- runner.effect = _effect;
653
+ const runner = e.run.bind(e);
654
+ runner.effect = e;
531
655
  return runner;
532
656
  }
533
657
  function stop(runner) {
534
658
  runner.effect.stop();
535
659
  }
536
660
  let shouldTrack = true;
537
- let pauseScheduleStack = 0;
538
661
  const trackStack = [];
539
662
  function pauseTracking() {
540
663
  trackStack.push(shouldTrack);
@@ -544,192 +667,414 @@ function resetTracking() {
544
667
  const last = trackStack.pop();
545
668
  shouldTrack = last === void 0 ? true : last;
546
669
  }
547
- function pauseScheduling() {
548
- pauseScheduleStack++;
549
- }
550
- function resetScheduling() {
551
- pauseScheduleStack--;
552
- while (!pauseScheduleStack && queueEffectSchedulers.length) {
553
- queueEffectSchedulers.shift()();
670
+ function cleanupEffect(e) {
671
+ const { cleanup } = e;
672
+ e.cleanup = void 0;
673
+ if (cleanup) {
674
+ const prevSub = activeSub;
675
+ activeSub = void 0;
676
+ try {
677
+ cleanup();
678
+ } finally {
679
+ activeSub = prevSub;
680
+ }
554
681
  }
555
682
  }
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
- }
683
+
684
+ let globalVersion = 0;
685
+ class Dep {
686
+ constructor(computed) {
687
+ this.computed = computed;
688
+ this.version = 0;
689
+ /**
690
+ * Link between this dep and the current active effect
691
+ */
692
+ this.activeLink = void 0;
693
+ /**
694
+ * Doubly linked list representing the subscribing effects (tail)
695
+ */
696
+ this.subs = void 0;
569
697
  {
570
- (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
698
+ this.subsHead = void 0;
571
699
  }
572
700
  }
573
- }
574
- const queueEffectSchedulers = [];
575
- function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
576
- var _a;
577
- pauseScheduling();
578
- for (const effect2 of dep.keys()) {
579
- let tracking;
580
- if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
581
- effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
582
- effect2._dirtyLevel = dirtyLevel;
583
- }
584
- if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
585
- {
586
- (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
701
+ track(debugInfo) {
702
+ if (!activeSub || !shouldTrack) {
703
+ return;
704
+ }
705
+ let link = this.activeLink;
706
+ if (link === void 0 || link.sub !== activeSub) {
707
+ link = this.activeLink = {
708
+ dep: this,
709
+ sub: activeSub,
710
+ version: this.version,
711
+ nextDep: void 0,
712
+ prevDep: void 0,
713
+ nextSub: void 0,
714
+ prevSub: void 0,
715
+ prevActiveLink: void 0
716
+ };
717
+ if (!activeSub.deps) {
718
+ activeSub.deps = activeSub.depsTail = link;
719
+ } else {
720
+ link.prevDep = activeSub.depsTail;
721
+ activeSub.depsTail.nextDep = link;
722
+ activeSub.depsTail = link;
723
+ }
724
+ if (activeSub.flags & 4) {
725
+ addSub(link);
587
726
  }
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);
727
+ } else if (link.version === -1) {
728
+ link.version = this.version;
729
+ if (link.nextDep) {
730
+ const next = link.nextDep;
731
+ next.prevDep = link.prevDep;
732
+ if (link.prevDep) {
733
+ link.prevDep.nextDep = next;
734
+ }
735
+ link.prevDep = activeSub.depsTail;
736
+ link.nextDep = void 0;
737
+ activeSub.depsTail.nextDep = link;
738
+ activeSub.depsTail = link;
739
+ if (activeSub.deps === link) {
740
+ activeSub.deps = next;
593
741
  }
594
742
  }
595
743
  }
744
+ if (activeSub.onTrack) {
745
+ activeSub.onTrack(
746
+ extend(
747
+ {
748
+ effect: activeSub
749
+ },
750
+ debugInfo
751
+ )
752
+ );
753
+ }
754
+ return link;
755
+ }
756
+ trigger(debugInfo) {
757
+ this.version++;
758
+ globalVersion++;
759
+ this.notify(debugInfo);
760
+ }
761
+ notify(debugInfo) {
762
+ startBatch();
763
+ try {
764
+ if (true) {
765
+ for (let head = this.subsHead; head; head = head.nextSub) {
766
+ if (head.sub.onTrigger && !(head.sub.flags & 8)) {
767
+ head.sub.onTrigger(
768
+ extend(
769
+ {
770
+ effect: head.sub
771
+ },
772
+ debugInfo
773
+ )
774
+ );
775
+ }
776
+ }
777
+ }
778
+ for (let link = this.subs; link; link = link.prevSub) {
779
+ link.sub.notify();
780
+ }
781
+ } finally {
782
+ endBatch();
783
+ }
596
784
  }
597
- resetScheduling();
598
785
  }
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
-
786
+ function addSub(link) {
787
+ const computed = link.dep.computed;
788
+ if (computed && !link.dep.subs) {
789
+ computed.flags |= 4 | 16;
790
+ for (let l = computed.deps; l; l = l.nextDep) {
791
+ addSub(l);
792
+ }
793
+ }
794
+ const currentTail = link.dep.subs;
795
+ if (currentTail !== link) {
796
+ link.prevSub = currentTail;
797
+ if (currentTail)
798
+ currentTail.nextSub = link;
799
+ }
800
+ if (link.dep.subsHead === void 0) {
801
+ link.dep.subsHead = link;
802
+ }
803
+ link.dep.subs = link;
804
+ }
607
805
  const targetMap = /* @__PURE__ */ new WeakMap();
608
- const ITERATE_KEY = Symbol("iterate" );
609
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
806
+ const ITERATE_KEY = Symbol("Object iterate" );
807
+ const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
808
+ const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
610
809
  function track(target, type, key) {
611
- if (shouldTrack && activeEffect) {
810
+ if (shouldTrack && activeSub) {
612
811
  let depsMap = targetMap.get(target);
613
812
  if (!depsMap) {
614
813
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
615
814
  }
616
815
  let dep = depsMap.get(key);
617
816
  if (!dep) {
618
- depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
817
+ depsMap.set(key, dep = new Dep());
619
818
  }
620
- trackEffect(
621
- activeEffect,
622
- dep,
623
- {
819
+ {
820
+ dep.track({
624
821
  target,
625
822
  type,
626
823
  key
627
- }
628
- );
824
+ });
825
+ }
629
826
  }
630
827
  }
631
828
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
632
829
  const depsMap = targetMap.get(target);
633
830
  if (!depsMap) {
831
+ globalVersion++;
634
832
  return;
635
833
  }
636
834
  let deps = [];
637
835
  if (type === "clear") {
638
836
  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
837
  } 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"));
838
+ const targetIsArray = isArray(target);
839
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
840
+ if (targetIsArray && key === "length") {
841
+ const newLength = Number(newValue);
842
+ depsMap.forEach((dep, key2) => {
843
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
844
+ deps.push(dep);
659
845
  }
660
- break;
661
- case "delete":
662
- if (!isArray(target)) {
663
- deps.push(depsMap.get(ITERATE_KEY));
846
+ });
847
+ } else {
848
+ const push = (dep) => dep && deps.push(dep);
849
+ if (key !== void 0) {
850
+ push(depsMap.get(key));
851
+ }
852
+ if (isArrayIndex) {
853
+ push(depsMap.get(ARRAY_ITERATE_KEY));
854
+ }
855
+ switch (type) {
856
+ case "add":
857
+ if (!targetIsArray) {
858
+ push(depsMap.get(ITERATE_KEY));
859
+ if (isMap(target)) {
860
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
861
+ }
862
+ } else if (isArrayIndex) {
863
+ push(depsMap.get("length"));
864
+ }
865
+ break;
866
+ case "delete":
867
+ if (!targetIsArray) {
868
+ push(depsMap.get(ITERATE_KEY));
869
+ if (isMap(target)) {
870
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
871
+ }
872
+ }
873
+ break;
874
+ case "set":
664
875
  if (isMap(target)) {
665
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
876
+ push(depsMap.get(ITERATE_KEY));
666
877
  }
667
- }
668
- break;
669
- case "set":
670
- if (isMap(target)) {
671
- deps.push(depsMap.get(ITERATE_KEY));
672
- }
673
- break;
878
+ break;
879
+ }
674
880
  }
675
881
  }
676
- pauseScheduling();
882
+ startBatch();
677
883
  for (const dep of deps) {
678
- if (dep) {
679
- triggerEffects(
680
- dep,
681
- 4,
682
- {
683
- target,
684
- type,
685
- key,
686
- newValue,
687
- oldValue,
688
- oldTarget
689
- }
690
- );
884
+ {
885
+ dep.trigger({
886
+ target,
887
+ type,
888
+ key,
889
+ newValue,
890
+ oldValue,
891
+ oldTarget
892
+ });
691
893
  }
692
894
  }
693
- resetScheduling();
895
+ endBatch();
694
896
  }
695
897
  function getDepFromReactive(object, key) {
696
- const depsMap = targetMap.get(object);
697
- return depsMap && depsMap.get(key);
898
+ var _a;
899
+ return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
900
+ }
901
+
902
+ function reactiveReadArray(array) {
903
+ const raw = toRaw(array);
904
+ if (raw === array)
905
+ return raw;
906
+ track(raw, "iterate", ARRAY_ITERATE_KEY);
907
+ return isShallow(array) ? raw : raw.map(toReactive);
908
+ }
909
+ function shallowReadArray(arr) {
910
+ track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
911
+ return arr;
912
+ }
913
+ const arrayInstrumentations = {
914
+ __proto__: null,
915
+ [Symbol.iterator]() {
916
+ return iterator(this, Symbol.iterator, toReactive);
917
+ },
918
+ concat(...args) {
919
+ return reactiveReadArray(this).concat(
920
+ ...args.map((x) => reactiveReadArray(x))
921
+ );
922
+ },
923
+ entries() {
924
+ return iterator(this, "entries", (value) => {
925
+ value[1] = toReactive(value[1]);
926
+ return value;
927
+ });
928
+ },
929
+ every(fn, thisArg) {
930
+ return apply(this, "every", fn, thisArg);
931
+ },
932
+ filter(fn, thisArg) {
933
+ const result = apply(this, "filter", fn, thisArg);
934
+ return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
935
+ },
936
+ find(fn, thisArg) {
937
+ const result = apply(this, "find", fn, thisArg);
938
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
939
+ },
940
+ findIndex(fn, thisArg) {
941
+ return apply(this, "findIndex", fn, thisArg);
942
+ },
943
+ findLast(fn, thisArg) {
944
+ const result = apply(this, "findLast", fn, thisArg);
945
+ return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
946
+ },
947
+ findLastIndex(fn, thisArg) {
948
+ return apply(this, "findLastIndex", fn, thisArg);
949
+ },
950
+ // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
951
+ forEach(fn, thisArg) {
952
+ return apply(this, "forEach", fn, thisArg);
953
+ },
954
+ includes(...args) {
955
+ return searchProxy(this, "includes", args);
956
+ },
957
+ indexOf(...args) {
958
+ return searchProxy(this, "indexOf", args);
959
+ },
960
+ join(separator) {
961
+ return reactiveReadArray(this).join(separator);
962
+ },
963
+ // keys() iterator only reads `length`, no optimisation required
964
+ lastIndexOf(...args) {
965
+ return searchProxy(this, "lastIndexOf", args);
966
+ },
967
+ map(fn, thisArg) {
968
+ return apply(this, "map", fn, thisArg);
969
+ },
970
+ pop() {
971
+ return noTracking(this, "pop");
972
+ },
973
+ push(...args) {
974
+ return noTracking(this, "push", args);
975
+ },
976
+ reduce(fn, ...args) {
977
+ return reduce(this, "reduce", fn, args);
978
+ },
979
+ reduceRight(fn, ...args) {
980
+ return reduce(this, "reduceRight", fn, args);
981
+ },
982
+ shift() {
983
+ return noTracking(this, "shift");
984
+ },
985
+ // slice could use ARRAY_ITERATE but also seems to beg for range tracking
986
+ some(fn, thisArg) {
987
+ return apply(this, "some", fn, thisArg);
988
+ },
989
+ splice(...args) {
990
+ return noTracking(this, "splice", args);
991
+ },
992
+ toReversed() {
993
+ return reactiveReadArray(this).toReversed();
994
+ },
995
+ toSorted(comparer) {
996
+ return reactiveReadArray(this).toSorted(comparer);
997
+ },
998
+ toSpliced(...args) {
999
+ return reactiveReadArray(this).toSpliced(...args);
1000
+ },
1001
+ unshift(...args) {
1002
+ return noTracking(this, "unshift", args);
1003
+ },
1004
+ values() {
1005
+ return iterator(this, "values", toReactive);
1006
+ }
1007
+ };
1008
+ function iterator(self, method, wrapValue) {
1009
+ const arr = shallowReadArray(self);
1010
+ const iter = arr[method]();
1011
+ if (arr !== self && !isShallow(self)) {
1012
+ iter._next = iter.next;
1013
+ iter.next = () => {
1014
+ const result = iter._next();
1015
+ if (result.value) {
1016
+ result.value = wrapValue(result.value);
1017
+ }
1018
+ return result;
1019
+ };
1020
+ }
1021
+ return iter;
1022
+ }
1023
+ function apply(self, method, fn, thisArg) {
1024
+ const arr = shallowReadArray(self);
1025
+ let wrappedFn = fn;
1026
+ if (arr !== self) {
1027
+ if (!isShallow(self)) {
1028
+ wrappedFn = function(item, index) {
1029
+ return fn.call(this, toReactive(item), index, self);
1030
+ };
1031
+ } else if (fn.length > 2) {
1032
+ wrappedFn = function(item, index) {
1033
+ return fn.call(this, item, index, self);
1034
+ };
1035
+ }
1036
+ }
1037
+ return arr[method](wrappedFn, thisArg);
1038
+ }
1039
+ function reduce(self, method, fn, args) {
1040
+ const arr = shallowReadArray(self);
1041
+ let wrappedFn = fn;
1042
+ if (arr !== self) {
1043
+ if (!isShallow(self)) {
1044
+ wrappedFn = function(acc, item, index) {
1045
+ return fn.call(this, acc, toReactive(item), index, self);
1046
+ };
1047
+ } else if (fn.length > 3) {
1048
+ wrappedFn = function(acc, item, index) {
1049
+ return fn.call(this, acc, item, index, self);
1050
+ };
1051
+ }
1052
+ }
1053
+ return arr[method](wrappedFn, ...args);
1054
+ }
1055
+ function searchProxy(self, method, args) {
1056
+ const arr = toRaw(self);
1057
+ track(arr, "iterate", ARRAY_ITERATE_KEY);
1058
+ const res = arr[method](...args);
1059
+ if ((res === -1 || res === false) && isProxy(args[0])) {
1060
+ args[0] = toRaw(args[0]);
1061
+ return arr[method](...args);
1062
+ }
1063
+ return res;
1064
+ }
1065
+ function noTracking(self, method, args = []) {
1066
+ pauseTracking();
1067
+ startBatch();
1068
+ const res = toRaw(self)[method].apply(self, args);
1069
+ endBatch();
1070
+ resetTracking();
1071
+ return res;
698
1072
  }
699
1073
 
700
1074
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
701
1075
  const builtInSymbols = new Set(
702
1076
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
703
1077
  );
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
1078
  function hasOwnProperty(key) {
734
1079
  if (!isSymbol(key))
735
1080
  key = String(key);
@@ -760,14 +1105,22 @@ class BaseReactiveHandler {
760
1105
  }
761
1106
  const targetIsArray = isArray(target);
762
1107
  if (!isReadonly2) {
763
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
764
- return Reflect.get(arrayInstrumentations, key, receiver);
1108
+ let fn;
1109
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1110
+ return fn;
765
1111
  }
766
1112
  if (key === "hasOwnProperty") {
767
1113
  return hasOwnProperty;
768
1114
  }
769
1115
  }
770
- const res = Reflect.get(target, key, receiver);
1116
+ const res = Reflect.get(
1117
+ target,
1118
+ key,
1119
+ // if this is a proxy wrapping a ref, return methods using the raw ref
1120
+ // as receiver so that we don't have to call `toRaw` on the ref in all
1121
+ // its class methods
1122
+ isRef(target) ? target : receiver
1123
+ );
771
1124
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
772
1125
  return res;
773
1126
  }
@@ -1266,110 +1619,8 @@ function markRaw(value) {
1266
1619
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1267
1620
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1268
1621
 
1269
- const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
1270
- class ComputedRefImpl {
1271
- constructor(getter, _setter, isReadonly, isSSR) {
1272
- this.getter = getter;
1273
- this._setter = _setter;
1274
- this.dep = void 0;
1275
- this.__v_isRef = true;
1276
- this["__v_isReadonly"] = false;
1277
- this.effect = new ReactiveEffect(
1278
- () => getter(this._value),
1279
- () => triggerRefValue(
1280
- this,
1281
- this.effect._dirtyLevel === 2 ? 2 : 3
1282
- )
1283
- );
1284
- this.effect.computed = this;
1285
- this.effect.active = this._cacheable = !isSSR;
1286
- this["__v_isReadonly"] = isReadonly;
1287
- }
1288
- get value() {
1289
- const self = toRaw(this);
1290
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1291
- triggerRefValue(self, 4);
1292
- }
1293
- trackRefValue(self);
1294
- if (self.effect._dirtyLevel >= 2) {
1295
- if (this._warnRecursive) {
1296
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1297
-
1298
- getter: `, this.getter);
1299
- }
1300
- triggerRefValue(self, 2);
1301
- }
1302
- return self._value;
1303
- }
1304
- set value(newValue) {
1305
- this._setter(newValue);
1306
- }
1307
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1308
- get _dirty() {
1309
- return this.effect.dirty;
1310
- }
1311
- set _dirty(v) {
1312
- this.effect.dirty = v;
1313
- }
1314
- // #endregion
1315
- }
1316
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1317
- let getter;
1318
- let setter;
1319
- const onlyGetter = isFunction(getterOrOptions);
1320
- if (onlyGetter) {
1321
- getter = getterOrOptions;
1322
- setter = () => {
1323
- warn$2("Write operation failed: computed value is readonly");
1324
- } ;
1325
- } else {
1326
- getter = getterOrOptions.get;
1327
- setter = getterOrOptions.set;
1328
- }
1329
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1330
- if (debugOptions && !isSSR) {
1331
- cRef.effect.onTrack = debugOptions.onTrack;
1332
- cRef.effect.onTrigger = debugOptions.onTrigger;
1333
- }
1334
- return cRef;
1335
- }
1336
-
1337
- function trackRefValue(ref2) {
1338
- var _a;
1339
- if (shouldTrack && activeEffect) {
1340
- ref2 = toRaw(ref2);
1341
- trackEffect(
1342
- activeEffect,
1343
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1344
- () => ref2.dep = void 0,
1345
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1346
- ),
1347
- {
1348
- target: ref2,
1349
- type: "get",
1350
- key: "value"
1351
- }
1352
- );
1353
- }
1354
- }
1355
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1356
- ref2 = toRaw(ref2);
1357
- const dep = ref2.dep;
1358
- if (dep) {
1359
- triggerEffects(
1360
- dep,
1361
- dirtyLevel,
1362
- {
1363
- target: ref2,
1364
- type: "set",
1365
- key: "value",
1366
- newValue: newVal
1367
- }
1368
- );
1369
- }
1370
- }
1371
1622
  function isRef(r) {
1372
- return !!(r && r.__v_isRef === true);
1623
+ return r ? r.__v_isRef === true : false;
1373
1624
  }
1374
1625
  function ref(value) {
1375
1626
  return createRef(value, false);
@@ -1386,27 +1637,49 @@ function createRef(rawValue, shallow) {
1386
1637
  class RefImpl {
1387
1638
  constructor(value, __v_isShallow) {
1388
1639
  this.__v_isShallow = __v_isShallow;
1389
- this.dep = void 0;
1640
+ this.dep = new Dep();
1390
1641
  this.__v_isRef = true;
1391
1642
  this._rawValue = __v_isShallow ? value : toRaw(value);
1392
1643
  this._value = __v_isShallow ? value : toReactive(value);
1393
1644
  }
1394
1645
  get value() {
1395
- trackRefValue(this);
1646
+ {
1647
+ this.dep.track({
1648
+ target: this,
1649
+ type: "get",
1650
+ key: "value"
1651
+ });
1652
+ }
1396
1653
  return this._value;
1397
1654
  }
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);
1655
+ set value(newValue) {
1656
+ const oldValue = this._rawValue;
1657
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1658
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1659
+ if (hasChanged(newValue, oldValue)) {
1660
+ this._rawValue = newValue;
1661
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1662
+ {
1663
+ this.dep.trigger({
1664
+ target: this,
1665
+ type: "set",
1666
+ key: "value",
1667
+ newValue,
1668
+ oldValue
1669
+ });
1670
+ }
1405
1671
  }
1406
1672
  }
1407
1673
  }
1408
1674
  function triggerRef(ref2) {
1409
- triggerRefValue(ref2, 4, ref2.value );
1675
+ {
1676
+ ref2.dep.trigger({
1677
+ target: ref2,
1678
+ type: "set",
1679
+ key: "value",
1680
+ newValue: ref2._value
1681
+ });
1682
+ }
1410
1683
  }
1411
1684
  function unref(ref2) {
1412
1685
  return isRef(ref2) ? ref2.value : ref2;
@@ -1431,12 +1704,9 @@ function proxyRefs(objectWithRefs) {
1431
1704
  }
1432
1705
  class CustomRefImpl {
1433
1706
  constructor(factory) {
1434
- this.dep = void 0;
1435
1707
  this.__v_isRef = true;
1436
- const { get, set } = factory(
1437
- () => trackRefValue(this),
1438
- () => triggerRefValue(this)
1439
- );
1708
+ const dep = this.dep = new Dep();
1709
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1440
1710
  this._get = get;
1441
1711
  this._set = set;
1442
1712
  }
@@ -1504,6 +1774,90 @@ function propertyToRef(source, key, defaultValue) {
1504
1774
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1505
1775
  }
1506
1776
 
1777
+ class ComputedRefImpl {
1778
+ constructor(fn, setter, isSSR) {
1779
+ this.fn = fn;
1780
+ this.setter = setter;
1781
+ /**
1782
+ * @internal
1783
+ */
1784
+ this._value = void 0;
1785
+ /**
1786
+ * @internal
1787
+ */
1788
+ this.dep = new Dep(this);
1789
+ /**
1790
+ * @internal
1791
+ */
1792
+ this.__v_isRef = true;
1793
+ // A computed is also a subscriber that tracks other deps
1794
+ /**
1795
+ * @internal
1796
+ */
1797
+ this.deps = void 0;
1798
+ /**
1799
+ * @internal
1800
+ */
1801
+ this.depsTail = void 0;
1802
+ /**
1803
+ * @internal
1804
+ */
1805
+ this.flags = 16;
1806
+ /**
1807
+ * @internal
1808
+ */
1809
+ this.globalVersion = globalVersion - 1;
1810
+ // for backwards compat
1811
+ this.effect = this;
1812
+ this.__v_isReadonly = !setter;
1813
+ this.isSSR = isSSR;
1814
+ }
1815
+ /**
1816
+ * @internal
1817
+ */
1818
+ notify() {
1819
+ if (activeSub !== this) {
1820
+ this.flags |= 16;
1821
+ this.dep.notify();
1822
+ }
1823
+ }
1824
+ get value() {
1825
+ const link = this.dep.track({
1826
+ target: this,
1827
+ type: "get",
1828
+ key: "value"
1829
+ }) ;
1830
+ refreshComputed(this);
1831
+ if (link) {
1832
+ link.version = this.dep.version;
1833
+ }
1834
+ return this._value;
1835
+ }
1836
+ set value(newValue) {
1837
+ if (this.setter) {
1838
+ this.setter(newValue);
1839
+ } else {
1840
+ warn$2("Write operation failed: computed value is readonly");
1841
+ }
1842
+ }
1843
+ }
1844
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1845
+ let getter;
1846
+ let setter;
1847
+ if (isFunction(getterOrOptions)) {
1848
+ getter = getterOrOptions;
1849
+ } else {
1850
+ getter = getterOrOptions.get;
1851
+ setter = getterOrOptions.set;
1852
+ }
1853
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1854
+ if (debugOptions && !isSSR) {
1855
+ cRef.onTrack = debugOptions.onTrack;
1856
+ cRef.onTrigger = debugOptions.onTrigger;
1857
+ }
1858
+ return cRef;
1859
+ }
1860
+
1507
1861
  const TrackOpTypes = {
1508
1862
  "GET": "get",
1509
1863
  "HAS": "has",
@@ -1796,7 +2150,7 @@ function findInsertionIndex(id) {
1796
2150
  const middle = start + end >>> 1;
1797
2151
  const middleJob = queue[middle];
1798
2152
  const middleJobId = getId(middleJob);
1799
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2153
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1800
2154
  start = middle + 1;
1801
2155
  } else {
1802
2156
  end = middle;
@@ -1805,15 +2159,21 @@ function findInsertionIndex(id) {
1805
2159
  return start;
1806
2160
  }
1807
2161
  function queueJob(job) {
1808
- if (!queue.length || !queue.includes(
1809
- job,
1810
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1811
- )) {
2162
+ var _a;
2163
+ if (!(job.flags & 1)) {
1812
2164
  if (job.id == null) {
1813
2165
  queue.push(job);
2166
+ } else if (
2167
+ // fast path when the job id is larger than the tail
2168
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2169
+ ) {
2170
+ queue.push(job);
1814
2171
  } else {
1815
2172
  queue.splice(findInsertionIndex(job.id), 0, job);
1816
2173
  }
2174
+ if (!(job.flags & 4)) {
2175
+ job.flags |= 1;
2176
+ }
1817
2177
  queueFlush();
1818
2178
  }
1819
2179
  }
@@ -1831,11 +2191,11 @@ function invalidateJob(job) {
1831
2191
  }
1832
2192
  function queuePostFlushCb(cb) {
1833
2193
  if (!isArray(cb)) {
1834
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1835
- cb,
1836
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1837
- )) {
2194
+ if (!(cb.flags & 1)) {
1838
2195
  pendingPostFlushCbs.push(cb);
2196
+ if (!(cb.flags & 4)) {
2197
+ cb.flags |= 1;
2198
+ }
1839
2199
  }
1840
2200
  } else {
1841
2201
  pendingPostFlushCbs.push(...cb);
@@ -1848,7 +2208,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1848
2208
  }
1849
2209
  for (; i < queue.length; i++) {
1850
2210
  const cb = queue[i];
1851
- if (cb && cb.pre) {
2211
+ if (cb && cb.flags & 2) {
1852
2212
  if (instance && cb.id !== instance.uid) {
1853
2213
  continue;
1854
2214
  }
@@ -1858,6 +2218,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1858
2218
  queue.splice(i, 1);
1859
2219
  i--;
1860
2220
  cb();
2221
+ cb.flags &= ~1;
1861
2222
  }
1862
2223
  }
1863
2224
  }
@@ -1880,6 +2241,7 @@ function flushPostFlushCbs(seen) {
1880
2241
  continue;
1881
2242
  }
1882
2243
  activePostFlushCbs[postFlushIndex]();
2244
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1883
2245
  }
1884
2246
  activePostFlushCbs = null;
1885
2247
  postFlushIndex = 0;
@@ -1889,9 +2251,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
1889
2251
  const comparator = (a, b) => {
1890
2252
  const diff = getId(a) - getId(b);
1891
2253
  if (diff === 0) {
1892
- if (a.pre && !b.pre)
2254
+ const isAPre = a.flags & 2;
2255
+ const isBPre = b.flags & 2;
2256
+ if (isAPre && !isBPre)
1893
2257
  return -1;
1894
- if (b.pre && !a.pre)
2258
+ if (isBPre && !isAPre)
1895
2259
  return 1;
1896
2260
  }
1897
2261
  return diff;
@@ -1907,11 +2271,12 @@ function flushJobs(seen) {
1907
2271
  try {
1908
2272
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1909
2273
  const job = queue[flushIndex];
1910
- if (job && job.active !== false) {
2274
+ if (job && !(job.flags & 8)) {
1911
2275
  if (check(job)) {
1912
2276
  continue;
1913
2277
  }
1914
2278
  callWithErrorHandling(job, null, 14);
2279
+ job.flags &= ~1;
1915
2280
  }
1916
2281
  }
1917
2282
  } finally {
@@ -1993,7 +2358,6 @@ function rerender(id, newRender) {
1993
2358
  }
1994
2359
  instance.renderCache = [];
1995
2360
  isHmrUpdating = true;
1996
- instance.effect.dirty = true;
1997
2361
  instance.update();
1998
2362
  isHmrUpdating = false;
1999
2363
  });
@@ -2021,7 +2385,6 @@ function reload(id, newComp) {
2021
2385
  instance.ceReload(newComp.styles);
2022
2386
  hmrDirtyComponents.delete(oldComp);
2023
2387
  } else if (instance.parent) {
2024
- instance.parent.effect.dirty = true;
2025
2388
  queueJob(instance.parent.update);
2026
2389
  } else if (instance.appContext.reload) {
2027
2390
  instance.appContext.reload();
@@ -2906,7 +3269,7 @@ function renderComponentRoot(instance) {
2906
3269
  true ? {
2907
3270
  get attrs() {
2908
3271
  markAttrsAccessed();
2909
- return shallowReadonly(attrs);
3272
+ return attrs;
2910
3273
  },
2911
3274
  slots,
2912
3275
  emit
@@ -2939,7 +3302,7 @@ function renderComponentRoot(instance) {
2939
3302
  propsOptions
2940
3303
  );
2941
3304
  }
2942
- root = cloneVNode(root, fallthroughAttrs, false, true);
3305
+ root = cloneVNode(root, fallthroughAttrs);
2943
3306
  } else if (!accessedAttrs && root.type !== Comment) {
2944
3307
  const allAttrs = Object.keys(attrs);
2945
3308
  const eventAttrs = [];
@@ -2977,15 +3340,10 @@ function renderComponentRoot(instance) {
2977
3340
  getComponentName(instance.type)
2978
3341
  );
2979
3342
  }
2980
- root = cloneVNode(
2981
- root,
2982
- {
2983
- class: cls,
2984
- style
2985
- },
2986
- false,
2987
- true
2988
- );
3343
+ root = cloneVNode(root, {
3344
+ class: cls,
3345
+ style
3346
+ });
2989
3347
  }
2990
3348
  }
2991
3349
  if (vnode.dirs) {
@@ -2994,7 +3352,7 @@ function renderComponentRoot(instance) {
2994
3352
  `Runtime directive used on component with non-element root node. The directives will not function as intended.`
2995
3353
  );
2996
3354
  }
2997
- root = cloneVNode(root, null, false, true);
3355
+ root = cloneVNode(root);
2998
3356
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2999
3357
  }
3000
3358
  if (vnode.transition) {
@@ -3489,7 +3847,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3489
3847
  let parentSuspenseId;
3490
3848
  const isSuspensible = isVNodeSuspensible(vnode);
3491
3849
  if (isSuspensible) {
3492
- if (parentSuspense && parentSuspense.pendingBranch) {
3850
+ if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
3493
3851
  parentSuspenseId = parentSuspense.pendingId;
3494
3852
  parentSuspense.deps++;
3495
3853
  }
@@ -3801,8 +4159,8 @@ function setActiveBranch(suspense, branch) {
3801
4159
  }
3802
4160
  }
3803
4161
  function isVNodeSuspensible(vnode) {
3804
- const suspensible = vnode.props && vnode.props.suspensible;
3805
- return suspensible != null && suspensible !== false;
4162
+ var _a;
4163
+ return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
3806
4164
  }
3807
4165
 
3808
4166
  const legacyDirectiveHookMap = {
@@ -3996,8 +4354,8 @@ function doWatch(source, cb, {
3996
4354
  };
3997
4355
  };
3998
4356
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3999
- const job = () => {
4000
- if (!effect.active || !effect.dirty) {
4357
+ const job = (immediateFirstRun) => {
4358
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4001
4359
  return;
4002
4360
  }
4003
4361
  if (cb) {
@@ -4018,19 +4376,22 @@ function doWatch(source, cb, {
4018
4376
  effect.run();
4019
4377
  }
4020
4378
  };
4021
- job.allowRecurse = !!cb;
4379
+ if (cb)
4380
+ job.flags |= 4;
4381
+ const effect = new ReactiveEffect(getter);
4022
4382
  let scheduler;
4023
4383
  if (flush === "sync") {
4384
+ effect.flags |= 64;
4024
4385
  scheduler = job;
4025
4386
  } else if (flush === "post") {
4026
4387
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4027
4388
  } else {
4028
- job.pre = true;
4389
+ job.flags |= 2;
4029
4390
  if (instance)
4030
4391
  job.id = instance.uid;
4031
4392
  scheduler = () => queueJob(job);
4032
4393
  }
4033
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4394
+ effect.scheduler = scheduler;
4034
4395
  const scope = getCurrentScope();
4035
4396
  const unwatch = () => {
4036
4397
  effect.stop();
@@ -4044,7 +4405,7 @@ function doWatch(source, cb, {
4044
4405
  }
4045
4406
  if (cb) {
4046
4407
  if (immediate) {
4047
- job();
4408
+ job(true);
4048
4409
  } else {
4049
4410
  oldValue = effect.run();
4050
4411
  }
@@ -4083,29 +4444,34 @@ function createPathGetter(ctx, path) {
4083
4444
  return cur;
4084
4445
  };
4085
4446
  }
4086
- function traverse(value, depth = Infinity, seen) {
4087
- if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
4447
+ function traverse(value, depth, currentDepth = 0, seen) {
4448
+ if (!isObject(value) || value["__v_skip"]) {
4088
4449
  return value;
4089
4450
  }
4451
+ if (depth && depth > 0) {
4452
+ if (currentDepth >= depth) {
4453
+ return value;
4454
+ }
4455
+ currentDepth++;
4456
+ }
4090
4457
  seen = seen || /* @__PURE__ */ new Set();
4091
4458
  if (seen.has(value)) {
4092
4459
  return value;
4093
4460
  }
4094
4461
  seen.add(value);
4095
- depth--;
4096
4462
  if (isRef(value)) {
4097
- traverse(value.value, depth, seen);
4463
+ traverse(value.value, depth, currentDepth, seen);
4098
4464
  } else if (isArray(value)) {
4099
4465
  for (let i = 0; i < value.length; i++) {
4100
- traverse(value[i], depth, seen);
4466
+ traverse(value[i], depth, currentDepth, seen);
4101
4467
  }
4102
4468
  } else if (isSet(value) || isMap(value)) {
4103
4469
  value.forEach((v) => {
4104
- traverse(v, depth, seen);
4470
+ traverse(v, depth, currentDepth, seen);
4105
4471
  });
4106
4472
  } else if (isPlainObject(value)) {
4107
4473
  for (const key in value) {
4108
- traverse(value[key], depth, seen);
4474
+ traverse(value[key], depth, currentDepth, seen);
4109
4475
  }
4110
4476
  }
4111
4477
  return value;
@@ -4221,22 +4587,7 @@ const BaseTransitionImpl = {
4221
4587
  if (!children || !children.length) {
4222
4588
  return;
4223
4589
  }
4224
- let child = children[0];
4225
- if (children.length > 1) {
4226
- let hasFound = false;
4227
- for (const c of children) {
4228
- if (c.type !== Comment) {
4229
- if (hasFound) {
4230
- warn$1(
4231
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4232
- );
4233
- break;
4234
- }
4235
- child = c;
4236
- hasFound = true;
4237
- }
4238
- }
4239
- }
4590
+ const child = findNonCommentChild(children);
4240
4591
  const rawProps = toRaw(props);
4241
4592
  const { mode } = rawProps;
4242
4593
  if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4245,7 +4596,7 @@ const BaseTransitionImpl = {
4245
4596
  if (state.isLeaving) {
4246
4597
  return emptyPlaceholder(child);
4247
4598
  }
4248
- const innerChild = getKeepAliveChild(child);
4599
+ const innerChild = getInnerChild$1(child);
4249
4600
  if (!innerChild) {
4250
4601
  return emptyPlaceholder(child);
4251
4602
  }
@@ -4257,7 +4608,7 @@ const BaseTransitionImpl = {
4257
4608
  );
4258
4609
  setTransitionHooks(innerChild, enterHooks);
4259
4610
  const oldChild = instance.subTree;
4260
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4611
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4261
4612
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4262
4613
  const leavingHooks = resolveTransitionHooks(
4263
4614
  oldInnerChild,
@@ -4266,12 +4617,11 @@ const BaseTransitionImpl = {
4266
4617
  instance
4267
4618
  );
4268
4619
  setTransitionHooks(oldInnerChild, leavingHooks);
4269
- if (mode === "out-in" && innerChild.type !== Comment) {
4620
+ if (mode === "out-in") {
4270
4621
  state.isLeaving = true;
4271
4622
  leavingHooks.afterLeave = () => {
4272
4623
  state.isLeaving = false;
4273
- if (instance.update.active !== false) {
4274
- instance.effect.dirty = true;
4624
+ if (!(instance.job.flags & 8)) {
4275
4625
  instance.update();
4276
4626
  }
4277
4627
  };
@@ -4299,6 +4649,25 @@ const BaseTransitionImpl = {
4299
4649
  {
4300
4650
  BaseTransitionImpl.__isBuiltIn = true;
4301
4651
  }
4652
+ function findNonCommentChild(children) {
4653
+ let child = children[0];
4654
+ if (children.length > 1) {
4655
+ let hasFound = false;
4656
+ for (const c of children) {
4657
+ if (c.type !== Comment) {
4658
+ if (hasFound) {
4659
+ warn$1(
4660
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4661
+ );
4662
+ break;
4663
+ }
4664
+ child = c;
4665
+ hasFound = true;
4666
+ }
4667
+ }
4668
+ }
4669
+ return child;
4670
+ }
4302
4671
  const BaseTransition = BaseTransitionImpl;
4303
4672
  function getLeavingNodesForType(state, vnode) {
4304
4673
  const { leavingVNodes } = state;
@@ -4453,8 +4822,11 @@ function emptyPlaceholder(vnode) {
4453
4822
  return vnode;
4454
4823
  }
4455
4824
  }
4456
- function getKeepAliveChild(vnode) {
4825
+ function getInnerChild$1(vnode) {
4457
4826
  if (!isKeepAlive(vnode)) {
4827
+ if (isTeleport(vnode.type) && vnode.children) {
4828
+ return findNonCommentChild(vnode.children);
4829
+ }
4458
4830
  return vnode;
4459
4831
  }
4460
4832
  if (vnode.component) {
@@ -4623,7 +4995,6 @@ function defineAsyncComponent(source) {
4623
4995
  load().then(() => {
4624
4996
  loaded.value = true;
4625
4997
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4626
- instance.parent.effect.dirty = true;
4627
4998
  queueJob(instance.parent.update);
4628
4999
  }
4629
5000
  }).catch((err) => {
@@ -4784,7 +5155,7 @@ const KeepAliveImpl = {
4784
5155
  return () => {
4785
5156
  pendingCacheKey = null;
4786
5157
  if (!slots.default) {
4787
- return null;
5158
+ return current = null;
4788
5159
  }
4789
5160
  const children = slots.default();
4790
5161
  const rawVNode = children[0];
@@ -5235,10 +5606,20 @@ function convertLegacyFunctionalComponent(comp) {
5235
5606
  function renderList(source, renderItem, cache, index) {
5236
5607
  let ret;
5237
5608
  const cached = cache && cache[index];
5238
- if (isArray(source) || isString(source)) {
5609
+ const sourceIsArray = isArray(source);
5610
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5611
+ if (sourceIsArray || isString(source)) {
5612
+ if (sourceIsReactiveArray) {
5613
+ source = shallowReadArray(source);
5614
+ }
5239
5615
  ret = new Array(source.length);
5240
5616
  for (let i = 0, l = source.length; i < l; i++) {
5241
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5617
+ ret[i] = renderItem(
5618
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5619
+ i,
5620
+ void 0,
5621
+ cached && cached[i]
5622
+ );
5242
5623
  }
5243
5624
  } else if (typeof source === "number") {
5244
5625
  if (!Number.isInteger(source)) {
@@ -5609,7 +5990,6 @@ const publicPropertiesMap = (
5609
5990
  $emit: (i) => i.emit,
5610
5991
  $options: (i) => resolveMergedOptions(i) ,
5611
5992
  $forceUpdate: (i) => i.f || (i.f = () => {
5612
- i.effect.dirty = true;
5613
5993
  queueJob(i.update);
5614
5994
  }),
5615
5995
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6480,13 +6860,13 @@ function createCompatVue$1(createApp, createSingletonApp) {
6480
6860
  return vm;
6481
6861
  }
6482
6862
  }
6483
- Vue.version = `2.6.14-compat:${"3.4.26"}`;
6863
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6484
6864
  Vue.config = singletonApp.config;
6485
- Vue.use = (plugin, ...options) => {
6486
- if (plugin && isFunction(plugin.install)) {
6487
- plugin.install(Vue, ...options);
6488
- } else if (isFunction(plugin)) {
6489
- plugin(Vue, ...options);
6865
+ Vue.use = (p, ...options) => {
6866
+ if (p && isFunction(p.install)) {
6867
+ p.install(Vue, ...options);
6868
+ } else if (isFunction(p)) {
6869
+ p(Vue, ...options);
6490
6870
  }
6491
6871
  return Vue;
6492
6872
  };
@@ -7498,7 +7878,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7498
7878
  function assertType(value, type) {
7499
7879
  let valid;
7500
7880
  const expectedType = getType(type);
7501
- if (isSimpleType(expectedType)) {
7881
+ if (expectedType === "null") {
7882
+ valid = value === null;
7883
+ } else if (isSimpleType(expectedType)) {
7502
7884
  const t = typeof value;
7503
7885
  valid = t === expectedType.toLowerCase();
7504
7886
  if (!valid && t === "object") {
@@ -7508,8 +7890,6 @@ function assertType(value, type) {
7508
7890
  valid = isObject(value);
7509
7891
  } else if (expectedType === "Array") {
7510
7892
  valid = isArray(value);
7511
- } else if (expectedType === "null") {
7512
- valid = value === null;
7513
7893
  } else {
7514
7894
  valid = value instanceof type;
7515
7895
  }
@@ -7604,7 +7984,7 @@ const initSlots = (instance, children) => {
7604
7984
  const type = children._;
7605
7985
  if (type) {
7606
7986
  extend(slots, children);
7607
- def(slots, "_", type, true);
7987
+ def(slots, "_", type);
7608
7988
  } else {
7609
7989
  normalizeObjectSlots(children, slots, instance);
7610
7990
  }
@@ -9034,7 +9414,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9034
9414
  } else {
9035
9415
  instance.next = n2;
9036
9416
  invalidateJob(instance.update);
9037
- instance.effect.dirty = true;
9038
9417
  instance.update();
9039
9418
  }
9040
9419
  } else {
@@ -9241,24 +9620,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9241
9620
  }
9242
9621
  }
9243
9622
  };
9244
- const effect = instance.effect = new ReactiveEffect(
9245
- componentUpdateFn,
9246
- NOOP,
9247
- () => queueJob(update),
9248
- instance.scope
9249
- // track it in component's effect scope
9250
- );
9251
- const update = instance.update = () => {
9252
- if (effect.dirty) {
9253
- effect.run();
9254
- }
9255
- };
9256
- update.id = instance.uid;
9623
+ instance.scope.on();
9624
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9625
+ instance.scope.off();
9626
+ const update = instance.update = effect.run.bind(effect);
9627
+ const job = instance.job = effect.runIfDirty.bind(effect);
9628
+ job.id = instance.uid;
9629
+ effect.scheduler = () => queueJob(job);
9257
9630
  toggleRecurse(instance, true);
9258
9631
  {
9259
9632
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9260
9633
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9261
- update.ownerInstance = instance;
9634
+ job.ownerInstance = instance;
9262
9635
  }
9263
9636
  update();
9264
9637
  };
@@ -9725,7 +10098,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9725
10098
  if (instance.type.__hmrId) {
9726
10099
  unregisterHMR(instance);
9727
10100
  }
9728
- const { bum, scope, update, subTree, um } = instance;
10101
+ const { bum, scope, job, subTree, um } = instance;
9729
10102
  if (bum) {
9730
10103
  invokeArrayFns(bum);
9731
10104
  }
@@ -9733,8 +10106,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9733
10106
  instance.emit("hook:beforeDestroy");
9734
10107
  }
9735
10108
  scope.stop();
9736
- if (update) {
9737
- update.active = false;
10109
+ if (job) {
10110
+ job.flags |= 8;
9738
10111
  unmount(subTree, instance, parentSuspense, doRemove);
9739
10112
  }
9740
10113
  if (um) {
@@ -9826,8 +10199,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9826
10199
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9827
10200
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9828
10201
  }
9829
- function toggleRecurse({ effect, update }, allowed) {
9830
- effect.allowRecurse = update.allowRecurse = allowed;
10202
+ function toggleRecurse({ effect, job }, allowed) {
10203
+ if (allowed) {
10204
+ effect.flags |= 32;
10205
+ job.flags |= 4;
10206
+ } else {
10207
+ effect.flags &= ~32;
10208
+ job.flags &= ~4;
10209
+ }
9831
10210
  }
9832
10211
  function needTransition(parentSuspense, transition) {
9833
10212
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10443,8 +10822,8 @@ function guardReactiveProps(props) {
10443
10822
  return null;
10444
10823
  return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
10445
10824
  }
10446
- function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
10447
- const { props, ref, patchFlag, children, transition } = vnode;
10825
+ function cloneVNode(vnode, extraProps, mergeRef = false) {
10826
+ const { props, ref, patchFlag, children } = vnode;
10448
10827
  const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
10449
10828
  const cloned = {
10450
10829
  __v_isVNode: true,
@@ -10474,7 +10853,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
10474
10853
  dynamicChildren: vnode.dynamicChildren,
10475
10854
  appContext: vnode.appContext,
10476
10855
  dirs: vnode.dirs,
10477
- transition,
10856
+ transition: vnode.transition,
10478
10857
  // These should technically only be non-null on mounted VNodes. However,
10479
10858
  // they *should* be copied for kept-alive vnodes. So we just always copy
10480
10859
  // them since them being non-null during a mount doesn't affect the logic as
@@ -10488,9 +10867,6 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
10488
10867
  ctx: vnode.ctx,
10489
10868
  ce: vnode.ce
10490
10869
  };
10491
- if (transition && cloneTransition) {
10492
- cloned.transition = transition.clone(cloned);
10493
- }
10494
10870
  {
10495
10871
  defineLegacyVNodeProperties(cloned);
10496
10872
  }
@@ -10628,6 +11004,7 @@ function createComponentInstance(vnode, parent, suspense) {
10628
11004
  effect: null,
10629
11005
  update: null,
10630
11006
  // will be set synchronously right after creation
11007
+ job: null,
10631
11008
  scope: new EffectScope(
10632
11009
  true
10633
11010
  /* detached */
@@ -11133,7 +11510,8 @@ function initCustomFormatter() {
11133
11510
  {},
11134
11511
  ["span", vueStyle, genRefFlag(obj)],
11135
11512
  "<",
11136
- formatValue(obj.value),
11513
+ // avoid debugger accessing value affecting behavior
11514
+ formatValue("_value" in obj ? obj._value : obj),
11137
11515
  `>`
11138
11516
  ];
11139
11517
  } else if (isReactive(obj)) {
@@ -11313,7 +11691,7 @@ function isMemoSame(cached, memo) {
11313
11691
  return true;
11314
11692
  }
11315
11693
 
11316
- const version = "3.4.26";
11694
+ const version = "3.5.0-alpha.1";
11317
11695
  const warn = warn$1 ;
11318
11696
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11319
11697
  const devtools = devtools$1 ;
@@ -12880,7 +13258,9 @@ const withKeys = (fn, modifiers) => {
12880
13258
  return;
12881
13259
  }
12882
13260
  const eventKey = hyphenate(event.key);
12883
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13261
+ if (modifiers.some(
13262
+ (k) => k === eventKey || keyNames[k] === eventKey
13263
+ )) {
12884
13264
  return fn(event);
12885
13265
  }
12886
13266
  {