@vue/compat 3.4.25 → 3.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.4.25
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
  **/
@@ -384,157 +384,280 @@ class EffectScope {
384
384
  function effectScope(detached) {
385
385
  return new EffectScope(detached);
386
386
  }
387
- function recordEffectScope(effect, scope = activeEffectScope) {
388
- if (scope && scope.active) {
389
- scope.effects.push(effect);
390
- }
391
- }
392
387
  function getCurrentScope() {
393
388
  return activeEffectScope;
394
389
  }
395
- function onScopeDispose(fn) {
390
+ function onScopeDispose(fn, failSilently = false) {
396
391
  if (activeEffectScope) {
397
392
  activeEffectScope.cleanups.push(fn);
398
- } else if (!!(process.env.NODE_ENV !== "production")) {
393
+ } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
399
394
  warn$2(
400
395
  `onScopeDispose() is called when there is no active effect scope to be associated with.`
401
396
  );
402
397
  }
403
398
  }
404
399
 
405
- let activeEffect;
400
+ let activeSub;
406
401
  class ReactiveEffect {
407
- constructor(fn, trigger, scheduler, scope) {
402
+ constructor(fn) {
408
403
  this.fn = fn;
409
- this.trigger = trigger;
410
- this.scheduler = scheduler;
411
- this.active = true;
412
- this.deps = [];
413
404
  /**
414
405
  * @internal
415
406
  */
416
- this._dirtyLevel = 4;
407
+ this.deps = void 0;
417
408
  /**
418
409
  * @internal
419
410
  */
420
- this._trackId = 0;
411
+ this.depsTail = void 0;
421
412
  /**
422
413
  * @internal
423
414
  */
424
- this._runnings = 0;
415
+ this.flags = 1 | 4;
425
416
  /**
426
417
  * @internal
427
418
  */
428
- this._shouldSchedule = false;
419
+ this.nextEffect = void 0;
429
420
  /**
430
421
  * @internal
431
422
  */
432
- this._depsLength = 0;
433
- recordEffectScope(this, scope);
434
- }
435
- get dirty() {
436
- if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
437
- this._dirtyLevel = 1;
438
- pauseTracking();
439
- for (let i = 0; i < this._depsLength; i++) {
440
- const dep = this.deps[i];
441
- if (dep.computed) {
442
- triggerComputed(dep.computed);
443
- if (this._dirtyLevel >= 4) {
444
- break;
445
- }
446
- }
447
- }
448
- if (this._dirtyLevel === 1) {
449
- this._dirtyLevel = 0;
450
- }
451
- resetTracking();
423
+ this.cleanup = void 0;
424
+ this.scheduler = void 0;
425
+ if (activeEffectScope && activeEffectScope.active) {
426
+ activeEffectScope.effects.push(this);
452
427
  }
453
- return this._dirtyLevel >= 4;
454
428
  }
455
- set dirty(v) {
456
- 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
+ }
457
444
  }
458
445
  run() {
459
- this._dirtyLevel = 0;
460
- if (!this.active) {
446
+ if (!(this.flags & 1)) {
461
447
  return this.fn();
462
448
  }
463
- let lastShouldTrack = shouldTrack;
464
- 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;
465
456
  try {
466
- shouldTrack = true;
467
- activeEffect = this;
468
- this._runnings++;
469
- preCleanupEffect(this);
470
457
  return this.fn();
471
458
  } finally {
472
- postCleanupEffect(this);
473
- this._runnings--;
474
- activeEffect = lastEffect;
475
- shouldTrack = lastShouldTrack;
459
+ if (!!(process.env.NODE_ENV !== "production") && 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;
476
468
  }
477
469
  }
478
470
  stop() {
479
- var _a;
480
- if (this.active) {
481
- preCleanupEffect(this);
482
- postCleanupEffect(this);
483
- (_a = this.onStop) == null ? void 0 : _a.call(this);
484
- this.active = false;
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);
477
+ this.onStop && this.onStop();
478
+ this.flags &= ~1;
485
479
  }
486
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();
494
+ }
495
+ }
496
+ get dirty() {
497
+ return isDirty(this);
498
+ }
487
499
  }
488
- function triggerComputed(computed) {
489
- return computed.value;
500
+ let batchDepth = 0;
501
+ let batchedEffect;
502
+ function startBatch() {
503
+ batchDepth++;
490
504
  }
491
- function preCleanupEffect(effect2) {
492
- effect2._trackId++;
493
- effect2._depsLength = 0;
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;
494
532
  }
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);
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
+ }
539
+ }
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,418 @@ 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
  if (!!(process.env.NODE_ENV !== "production")) {
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
- if (!!(process.env.NODE_ENV !== "production")) {
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 (!!(process.env.NODE_ENV !== "production") && 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 (!!(process.env.NODE_ENV !== "production")) {
765
+ for (let head = this.subsHead; head; head = head.nextSub) {
766
+ if (!!(process.env.NODE_ENV !== "production") && 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 (!!(process.env.NODE_ENV !== "production") && 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(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
609
- const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
806
+ const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
807
+ const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
808
+ const ARRAY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "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
- !!(process.env.NODE_ENV !== "production") ? {
819
+ if (!!(process.env.NODE_ENV !== "production")) {
820
+ dep.track({
624
821
  target,
625
822
  type,
626
823
  key
627
- } : void 0
628
- );
824
+ });
825
+ } else {
826
+ dep.track();
827
+ }
629
828
  }
630
829
  }
631
830
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
632
831
  const depsMap = targetMap.get(target);
633
832
  if (!depsMap) {
833
+ globalVersion++;
634
834
  return;
635
835
  }
636
836
  let deps = [];
637
837
  if (type === "clear") {
638
838
  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
839
  } 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"));
840
+ const targetIsArray = isArray(target);
841
+ const isArrayIndex = targetIsArray && isIntegerKey(key);
842
+ if (targetIsArray && key === "length") {
843
+ const newLength = Number(newValue);
844
+ depsMap.forEach((dep, key2) => {
845
+ if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
846
+ deps.push(dep);
659
847
  }
660
- break;
661
- case "delete":
662
- if (!isArray(target)) {
663
- deps.push(depsMap.get(ITERATE_KEY));
848
+ });
849
+ } else {
850
+ const push = (dep) => dep && deps.push(dep);
851
+ if (key !== void 0) {
852
+ push(depsMap.get(key));
853
+ }
854
+ if (isArrayIndex) {
855
+ push(depsMap.get(ARRAY_ITERATE_KEY));
856
+ }
857
+ switch (type) {
858
+ case "add":
859
+ if (!targetIsArray) {
860
+ push(depsMap.get(ITERATE_KEY));
861
+ if (isMap(target)) {
862
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
863
+ }
864
+ } else if (isArrayIndex) {
865
+ push(depsMap.get("length"));
866
+ }
867
+ break;
868
+ case "delete":
869
+ if (!targetIsArray) {
870
+ push(depsMap.get(ITERATE_KEY));
871
+ if (isMap(target)) {
872
+ push(depsMap.get(MAP_KEY_ITERATE_KEY));
873
+ }
874
+ }
875
+ break;
876
+ case "set":
664
877
  if (isMap(target)) {
665
- deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
878
+ push(depsMap.get(ITERATE_KEY));
666
879
  }
667
- }
668
- break;
669
- case "set":
670
- if (isMap(target)) {
671
- deps.push(depsMap.get(ITERATE_KEY));
672
- }
673
- break;
880
+ break;
881
+ }
674
882
  }
675
883
  }
676
- pauseScheduling();
884
+ startBatch();
677
885
  for (const dep of deps) {
678
- if (dep) {
679
- triggerEffects(
680
- dep,
681
- 4,
682
- !!(process.env.NODE_ENV !== "production") ? {
683
- target,
684
- type,
685
- key,
686
- newValue,
687
- oldValue,
688
- oldTarget
689
- } : void 0
690
- );
886
+ if (!!(process.env.NODE_ENV !== "production")) {
887
+ dep.trigger({
888
+ target,
889
+ type,
890
+ key,
891
+ newValue,
892
+ oldValue,
893
+ oldTarget
894
+ });
895
+ } else {
896
+ dep.trigger();
691
897
  }
692
898
  }
693
- resetScheduling();
899
+ endBatch();
694
900
  }
695
901
  function getDepFromReactive(object, key) {
696
902
  var _a;
697
903
  return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
698
904
  }
699
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;
1076
+ }
1077
+
700
1078
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
701
1079
  const builtInSymbols = new Set(
702
1080
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
703
1081
  );
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
1082
  function hasOwnProperty(key) {
734
1083
  if (!isSymbol(key))
735
1084
  key = String(key);
@@ -760,14 +1109,22 @@ class BaseReactiveHandler {
760
1109
  }
761
1110
  const targetIsArray = isArray(target);
762
1111
  if (!isReadonly2) {
763
- if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
764
- return Reflect.get(arrayInstrumentations, key, receiver);
1112
+ let fn;
1113
+ if (targetIsArray && (fn = arrayInstrumentations[key])) {
1114
+ return fn;
765
1115
  }
766
1116
  if (key === "hasOwnProperty") {
767
1117
  return hasOwnProperty;
768
1118
  }
769
1119
  }
770
- 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
+ );
771
1128
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
772
1129
  return res;
773
1130
  }
@@ -1266,110 +1623,8 @@ function markRaw(value) {
1266
1623
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1267
1624
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1268
1625
 
1269
- const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
1270
- class ComputedRefImpl {
1271
- constructor(getter, _setter, isReadonly, isSSR) {
1272
- this.getter = getter;
1273
- this._setter = _setter;
1274
- this.dep = void 0;
1275
- this.__v_isRef = true;
1276
- this["__v_isReadonly"] = false;
1277
- this.effect = new ReactiveEffect(
1278
- () => getter(this._value),
1279
- () => triggerRefValue(
1280
- this,
1281
- this.effect._dirtyLevel === 2 ? 2 : 3
1282
- )
1283
- );
1284
- this.effect.computed = this;
1285
- this.effect.active = this._cacheable = !isSSR;
1286
- this["__v_isReadonly"] = isReadonly;
1287
- }
1288
- get value() {
1289
- const self = toRaw(this);
1290
- if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) {
1291
- triggerRefValue(self, 4);
1292
- }
1293
- trackRefValue(self);
1294
- if (self.effect._dirtyLevel >= 2) {
1295
- if (!!(process.env.NODE_ENV !== "production") && this._warnRecursive) {
1296
- warn$2(COMPUTED_SIDE_EFFECT_WARN, `
1297
-
1298
- getter: `, this.getter);
1299
- }
1300
- triggerRefValue(self, 2);
1301
- }
1302
- return self._value;
1303
- }
1304
- set value(newValue) {
1305
- this._setter(newValue);
1306
- }
1307
- // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1308
- get _dirty() {
1309
- return this.effect.dirty;
1310
- }
1311
- set _dirty(v) {
1312
- this.effect.dirty = v;
1313
- }
1314
- // #endregion
1315
- }
1316
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1317
- let getter;
1318
- let setter;
1319
- const onlyGetter = isFunction(getterOrOptions);
1320
- if (onlyGetter) {
1321
- getter = getterOrOptions;
1322
- setter = !!(process.env.NODE_ENV !== "production") ? () => {
1323
- warn$2("Write operation failed: computed value is readonly");
1324
- } : NOOP;
1325
- } else {
1326
- getter = getterOrOptions.get;
1327
- setter = getterOrOptions.set;
1328
- }
1329
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1330
- if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1331
- cRef.effect.onTrack = debugOptions.onTrack;
1332
- cRef.effect.onTrigger = debugOptions.onTrigger;
1333
- }
1334
- return cRef;
1335
- }
1336
-
1337
- function trackRefValue(ref2) {
1338
- var _a;
1339
- if (shouldTrack && activeEffect) {
1340
- ref2 = toRaw(ref2);
1341
- trackEffect(
1342
- activeEffect,
1343
- (_a = ref2.dep) != null ? _a : ref2.dep = createDep(
1344
- () => ref2.dep = void 0,
1345
- ref2 instanceof ComputedRefImpl ? ref2 : void 0
1346
- ),
1347
- !!(process.env.NODE_ENV !== "production") ? {
1348
- target: ref2,
1349
- type: "get",
1350
- key: "value"
1351
- } : void 0
1352
- );
1353
- }
1354
- }
1355
- function triggerRefValue(ref2, dirtyLevel = 4, newVal) {
1356
- ref2 = toRaw(ref2);
1357
- const dep = ref2.dep;
1358
- if (dep) {
1359
- triggerEffects(
1360
- dep,
1361
- dirtyLevel,
1362
- !!(process.env.NODE_ENV !== "production") ? {
1363
- target: ref2,
1364
- type: "set",
1365
- key: "value",
1366
- newValue: newVal
1367
- } : void 0
1368
- );
1369
- }
1370
- }
1371
1626
  function isRef(r) {
1372
- return !!(r && r.__v_isRef === true);
1627
+ return r ? r.__v_isRef === true : false;
1373
1628
  }
1374
1629
  function ref(value) {
1375
1630
  return createRef(value, false);
@@ -1386,27 +1641,55 @@ function createRef(rawValue, shallow) {
1386
1641
  class RefImpl {
1387
1642
  constructor(value, __v_isShallow) {
1388
1643
  this.__v_isShallow = __v_isShallow;
1389
- this.dep = void 0;
1644
+ this.dep = new Dep();
1390
1645
  this.__v_isRef = true;
1391
1646
  this._rawValue = __v_isShallow ? value : toRaw(value);
1392
1647
  this._value = __v_isShallow ? value : toReactive(value);
1393
1648
  }
1394
1649
  get value() {
1395
- trackRefValue(this);
1650
+ if (!!(process.env.NODE_ENV !== "production")) {
1651
+ this.dep.track({
1652
+ target: this,
1653
+ type: "get",
1654
+ key: "value"
1655
+ });
1656
+ } else {
1657
+ this.dep.track();
1658
+ }
1396
1659
  return this._value;
1397
1660
  }
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);
1661
+ set value(newValue) {
1662
+ const oldValue = this._rawValue;
1663
+ const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue);
1664
+ newValue = useDirectValue ? newValue : toRaw(newValue);
1665
+ if (hasChanged(newValue, oldValue)) {
1666
+ this._rawValue = newValue;
1667
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1668
+ if (!!(process.env.NODE_ENV !== "production")) {
1669
+ this.dep.trigger({
1670
+ target: this,
1671
+ type: "set",
1672
+ key: "value",
1673
+ newValue,
1674
+ oldValue
1675
+ });
1676
+ } else {
1677
+ this.dep.trigger();
1678
+ }
1405
1679
  }
1406
1680
  }
1407
1681
  }
1408
1682
  function triggerRef(ref2) {
1409
- triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1683
+ if (!!(process.env.NODE_ENV !== "production")) {
1684
+ ref2.dep.trigger({
1685
+ target: ref2,
1686
+ type: "set",
1687
+ key: "value",
1688
+ newValue: ref2._value
1689
+ });
1690
+ } else {
1691
+ ref2.dep.trigger();
1692
+ }
1410
1693
  }
1411
1694
  function unref(ref2) {
1412
1695
  return isRef(ref2) ? ref2.value : ref2;
@@ -1431,12 +1714,9 @@ function proxyRefs(objectWithRefs) {
1431
1714
  }
1432
1715
  class CustomRefImpl {
1433
1716
  constructor(factory) {
1434
- this.dep = void 0;
1435
1717
  this.__v_isRef = true;
1436
- const { get, set } = factory(
1437
- () => trackRefValue(this),
1438
- () => triggerRefValue(this)
1439
- );
1718
+ const dep = this.dep = new Dep();
1719
+ const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1440
1720
  this._get = get;
1441
1721
  this._set = set;
1442
1722
  }
@@ -1504,6 +1784,90 @@ function propertyToRef(source, key, defaultValue) {
1504
1784
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1505
1785
  }
1506
1786
 
1787
+ class ComputedRefImpl {
1788
+ constructor(fn, setter, isSSR) {
1789
+ this.fn = fn;
1790
+ this.setter = setter;
1791
+ /**
1792
+ * @internal
1793
+ */
1794
+ this._value = void 0;
1795
+ /**
1796
+ * @internal
1797
+ */
1798
+ this.dep = new Dep(this);
1799
+ /**
1800
+ * @internal
1801
+ */
1802
+ this.__v_isRef = true;
1803
+ // A computed is also a subscriber that tracks other deps
1804
+ /**
1805
+ * @internal
1806
+ */
1807
+ this.deps = void 0;
1808
+ /**
1809
+ * @internal
1810
+ */
1811
+ this.depsTail = void 0;
1812
+ /**
1813
+ * @internal
1814
+ */
1815
+ this.flags = 16;
1816
+ /**
1817
+ * @internal
1818
+ */
1819
+ this.globalVersion = globalVersion - 1;
1820
+ // for backwards compat
1821
+ this.effect = this;
1822
+ this.__v_isReadonly = !setter;
1823
+ this.isSSR = isSSR;
1824
+ }
1825
+ /**
1826
+ * @internal
1827
+ */
1828
+ notify() {
1829
+ if (activeSub !== this) {
1830
+ this.flags |= 16;
1831
+ this.dep.notify();
1832
+ } else if (!!(process.env.NODE_ENV !== "production")) ;
1833
+ }
1834
+ get value() {
1835
+ const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
1836
+ target: this,
1837
+ type: "get",
1838
+ key: "value"
1839
+ }) : this.dep.track();
1840
+ refreshComputed(this);
1841
+ if (link) {
1842
+ link.version = this.dep.version;
1843
+ }
1844
+ return this._value;
1845
+ }
1846
+ set value(newValue) {
1847
+ if (this.setter) {
1848
+ this.setter(newValue);
1849
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1850
+ warn$2("Write operation failed: computed value is readonly");
1851
+ }
1852
+ }
1853
+ }
1854
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1855
+ let getter;
1856
+ let setter;
1857
+ if (isFunction(getterOrOptions)) {
1858
+ getter = getterOrOptions;
1859
+ } else {
1860
+ getter = getterOrOptions.get;
1861
+ setter = getterOrOptions.set;
1862
+ }
1863
+ const cRef = new ComputedRefImpl(getter, setter, isSSR);
1864
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1865
+ cRef.onTrack = debugOptions.onTrack;
1866
+ cRef.onTrigger = debugOptions.onTrigger;
1867
+ }
1868
+ return cRef;
1869
+ }
1870
+
1507
1871
  const TrackOpTypes = {
1508
1872
  "GET": "get",
1509
1873
  "HAS": "has",
@@ -1800,7 +2164,7 @@ function findInsertionIndex(id) {
1800
2164
  const middle = start + end >>> 1;
1801
2165
  const middleJob = queue[middle];
1802
2166
  const middleJobId = getId(middleJob);
1803
- if (middleJobId < id || middleJobId === id && middleJob.pre) {
2167
+ if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
1804
2168
  start = middle + 1;
1805
2169
  } else {
1806
2170
  end = middle;
@@ -1809,15 +2173,21 @@ function findInsertionIndex(id) {
1809
2173
  return start;
1810
2174
  }
1811
2175
  function queueJob(job) {
1812
- if (!queue.length || !queue.includes(
1813
- job,
1814
- isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
1815
- )) {
2176
+ var _a;
2177
+ if (!(job.flags & 1)) {
1816
2178
  if (job.id == null) {
1817
2179
  queue.push(job);
2180
+ } else if (
2181
+ // fast path when the job id is larger than the tail
2182
+ !(job.flags & 2) && job.id >= (((_a = queue[queue.length - 1]) == null ? void 0 : _a.id) || 0)
2183
+ ) {
2184
+ queue.push(job);
1818
2185
  } else {
1819
2186
  queue.splice(findInsertionIndex(job.id), 0, job);
1820
2187
  }
2188
+ if (!(job.flags & 4)) {
2189
+ job.flags |= 1;
2190
+ }
1821
2191
  queueFlush();
1822
2192
  }
1823
2193
  }
@@ -1835,11 +2205,11 @@ function invalidateJob(job) {
1835
2205
  }
1836
2206
  function queuePostFlushCb(cb) {
1837
2207
  if (!isArray(cb)) {
1838
- if (!activePostFlushCbs || !activePostFlushCbs.includes(
1839
- cb,
1840
- cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
1841
- )) {
2208
+ if (!(cb.flags & 1)) {
1842
2209
  pendingPostFlushCbs.push(cb);
2210
+ if (!(cb.flags & 4)) {
2211
+ cb.flags |= 1;
2212
+ }
1843
2213
  }
1844
2214
  } else {
1845
2215
  pendingPostFlushCbs.push(...cb);
@@ -1852,7 +2222,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1852
2222
  }
1853
2223
  for (; i < queue.length; i++) {
1854
2224
  const cb = queue[i];
1855
- if (cb && cb.pre) {
2225
+ if (cb && cb.flags & 2) {
1856
2226
  if (instance && cb.id !== instance.uid) {
1857
2227
  continue;
1858
2228
  }
@@ -1862,6 +2232,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1862
2232
  queue.splice(i, 1);
1863
2233
  i--;
1864
2234
  cb();
2235
+ cb.flags &= ~1;
1865
2236
  }
1866
2237
  }
1867
2238
  }
@@ -1884,6 +2255,7 @@ function flushPostFlushCbs(seen) {
1884
2255
  continue;
1885
2256
  }
1886
2257
  activePostFlushCbs[postFlushIndex]();
2258
+ activePostFlushCbs[postFlushIndex].flags &= ~1;
1887
2259
  }
1888
2260
  activePostFlushCbs = null;
1889
2261
  postFlushIndex = 0;
@@ -1893,9 +2265,11 @@ const getId = (job) => job.id == null ? Infinity : job.id;
1893
2265
  const comparator = (a, b) => {
1894
2266
  const diff = getId(a) - getId(b);
1895
2267
  if (diff === 0) {
1896
- if (a.pre && !b.pre)
2268
+ const isAPre = a.flags & 2;
2269
+ const isBPre = b.flags & 2;
2270
+ if (isAPre && !isBPre)
1897
2271
  return -1;
1898
- if (b.pre && !a.pre)
2272
+ if (isBPre && !isAPre)
1899
2273
  return 1;
1900
2274
  }
1901
2275
  return diff;
@@ -1911,11 +2285,12 @@ function flushJobs(seen) {
1911
2285
  try {
1912
2286
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1913
2287
  const job = queue[flushIndex];
1914
- if (job && job.active !== false) {
2288
+ if (job && !(job.flags & 8)) {
1915
2289
  if (!!(process.env.NODE_ENV !== "production") && check(job)) {
1916
2290
  continue;
1917
2291
  }
1918
2292
  callWithErrorHandling(job, null, 14);
2293
+ job.flags &= ~1;
1919
2294
  }
1920
2295
  }
1921
2296
  } finally {
@@ -1997,7 +2372,6 @@ function rerender(id, newRender) {
1997
2372
  }
1998
2373
  instance.renderCache = [];
1999
2374
  isHmrUpdating = true;
2000
- instance.effect.dirty = true;
2001
2375
  instance.update();
2002
2376
  isHmrUpdating = false;
2003
2377
  });
@@ -2025,7 +2399,6 @@ function reload(id, newComp) {
2025
2399
  instance.ceReload(newComp.styles);
2026
2400
  hmrDirtyComponents.delete(oldComp);
2027
2401
  } else if (instance.parent) {
2028
- instance.parent.effect.dirty = true;
2029
2402
  queueJob(instance.parent.update);
2030
2403
  } else if (instance.appContext.reload) {
2031
2404
  instance.appContext.reload();
@@ -4017,8 +4390,8 @@ function doWatch(source, cb, {
4017
4390
  }
4018
4391
  }
4019
4392
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
4020
- const job = () => {
4021
- if (!effect.active || !effect.dirty) {
4393
+ const job = (immediateFirstRun) => {
4394
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
4022
4395
  return;
4023
4396
  }
4024
4397
  if (cb) {
@@ -4039,19 +4412,22 @@ function doWatch(source, cb, {
4039
4412
  effect.run();
4040
4413
  }
4041
4414
  };
4042
- job.allowRecurse = !!cb;
4415
+ if (cb)
4416
+ job.flags |= 4;
4417
+ const effect = new ReactiveEffect(getter);
4043
4418
  let scheduler;
4044
4419
  if (flush === "sync") {
4420
+ effect.flags |= 64;
4045
4421
  scheduler = job;
4046
4422
  } else if (flush === "post") {
4047
4423
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
4048
4424
  } else {
4049
- job.pre = true;
4425
+ job.flags |= 2;
4050
4426
  if (instance)
4051
4427
  job.id = instance.uid;
4052
4428
  scheduler = () => queueJob(job);
4053
4429
  }
4054
- const effect = new ReactiveEffect(getter, NOOP, scheduler);
4430
+ effect.scheduler = scheduler;
4055
4431
  const scope = getCurrentScope();
4056
4432
  const unwatch = () => {
4057
4433
  effect.stop();
@@ -4065,7 +4441,7 @@ function doWatch(source, cb, {
4065
4441
  }
4066
4442
  if (cb) {
4067
4443
  if (immediate) {
4068
- job();
4444
+ job(true);
4069
4445
  } else {
4070
4446
  oldValue = effect.run();
4071
4447
  }
@@ -4249,24 +4625,7 @@ const BaseTransitionImpl = {
4249
4625
  if (!children || !children.length) {
4250
4626
  return;
4251
4627
  }
4252
- let child = children[0];
4253
- if (children.length > 1) {
4254
- let hasFound = false;
4255
- for (const c of children) {
4256
- if (c.type !== Comment) {
4257
- if (!!(process.env.NODE_ENV !== "production") && hasFound) {
4258
- warn$1(
4259
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4260
- );
4261
- break;
4262
- }
4263
- child = c;
4264
- hasFound = true;
4265
- if (!!!(process.env.NODE_ENV !== "production"))
4266
- break;
4267
- }
4268
- }
4269
- }
4628
+ const child = findNonCommentChild(children);
4270
4629
  const rawProps = toRaw(props);
4271
4630
  const { mode } = rawProps;
4272
4631
  if (!!(process.env.NODE_ENV !== "production") && mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
@@ -4275,7 +4634,7 @@ const BaseTransitionImpl = {
4275
4634
  if (state.isLeaving) {
4276
4635
  return emptyPlaceholder(child);
4277
4636
  }
4278
- const innerChild = getKeepAliveChild(child);
4637
+ const innerChild = getInnerChild$1(child);
4279
4638
  if (!innerChild) {
4280
4639
  return emptyPlaceholder(child);
4281
4640
  }
@@ -4287,7 +4646,7 @@ const BaseTransitionImpl = {
4287
4646
  );
4288
4647
  setTransitionHooks(innerChild, enterHooks);
4289
4648
  const oldChild = instance.subTree;
4290
- const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
4649
+ const oldInnerChild = oldChild && getInnerChild$1(oldChild);
4291
4650
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild)) {
4292
4651
  const leavingHooks = resolveTransitionHooks(
4293
4652
  oldInnerChild,
@@ -4300,8 +4659,7 @@ const BaseTransitionImpl = {
4300
4659
  state.isLeaving = true;
4301
4660
  leavingHooks.afterLeave = () => {
4302
4661
  state.isLeaving = false;
4303
- if (instance.update.active !== false) {
4304
- instance.effect.dirty = true;
4662
+ if (!(instance.job.flags & 8)) {
4305
4663
  instance.update();
4306
4664
  }
4307
4665
  };
@@ -4329,6 +4687,27 @@ const BaseTransitionImpl = {
4329
4687
  {
4330
4688
  BaseTransitionImpl.__isBuiltIn = true;
4331
4689
  }
4690
+ function findNonCommentChild(children) {
4691
+ let child = children[0];
4692
+ if (children.length > 1) {
4693
+ let hasFound = false;
4694
+ for (const c of children) {
4695
+ if (c.type !== Comment) {
4696
+ if (!!(process.env.NODE_ENV !== "production") && hasFound) {
4697
+ warn$1(
4698
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
4699
+ );
4700
+ break;
4701
+ }
4702
+ child = c;
4703
+ hasFound = true;
4704
+ if (!!!(process.env.NODE_ENV !== "production"))
4705
+ break;
4706
+ }
4707
+ }
4708
+ }
4709
+ return child;
4710
+ }
4332
4711
  const BaseTransition = BaseTransitionImpl;
4333
4712
  function getLeavingNodesForType(state, vnode) {
4334
4713
  const { leavingVNodes } = state;
@@ -4483,8 +4862,11 @@ function emptyPlaceholder(vnode) {
4483
4862
  return vnode;
4484
4863
  }
4485
4864
  }
4486
- function getKeepAliveChild(vnode) {
4865
+ function getInnerChild$1(vnode) {
4487
4866
  if (!isKeepAlive(vnode)) {
4867
+ if (isTeleport(vnode.type) && vnode.children) {
4868
+ return findNonCommentChild(vnode.children);
4869
+ }
4488
4870
  return vnode;
4489
4871
  }
4490
4872
  if (!!(process.env.NODE_ENV !== "production") && vnode.component) {
@@ -4653,7 +5035,6 @@ function defineAsyncComponent(source) {
4653
5035
  load().then(() => {
4654
5036
  loaded.value = true;
4655
5037
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4656
- instance.parent.effect.dirty = true;
4657
5038
  queueJob(instance.parent.update);
4658
5039
  }
4659
5040
  }).catch((err) => {
@@ -5271,10 +5652,20 @@ function convertLegacyFunctionalComponent(comp) {
5271
5652
  function renderList(source, renderItem, cache, index) {
5272
5653
  let ret;
5273
5654
  const cached = cache && cache[index];
5274
- if (isArray(source) || isString(source)) {
5655
+ const sourceIsArray = isArray(source);
5656
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5657
+ if (sourceIsArray || isString(source)) {
5658
+ if (sourceIsReactiveArray) {
5659
+ source = shallowReadArray(source);
5660
+ }
5275
5661
  ret = new Array(source.length);
5276
5662
  for (let i = 0, l = source.length; i < l; i++) {
5277
- ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
5663
+ ret[i] = renderItem(
5664
+ sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5665
+ i,
5666
+ void 0,
5667
+ cached && cached[i]
5668
+ );
5278
5669
  }
5279
5670
  } else if (typeof source === "number") {
5280
5671
  if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
@@ -5645,7 +6036,6 @@ const publicPropertiesMap = (
5645
6036
  $emit: (i) => i.emit,
5646
6037
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
5647
6038
  $forceUpdate: (i) => i.f || (i.f = () => {
5648
- i.effect.dirty = true;
5649
6039
  queueJob(i.update);
5650
6040
  }),
5651
6041
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
@@ -6518,7 +6908,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6518
6908
  return vm;
6519
6909
  }
6520
6910
  }
6521
- Vue.version = `2.6.14-compat:${"3.4.25"}`;
6911
+ Vue.version = `2.6.14-compat:${"3.5.0-alpha.1"}`;
6522
6912
  Vue.config = singletonApp.config;
6523
6913
  Vue.use = (p, ...options) => {
6524
6914
  if (p && isFunction(p.install)) {
@@ -7539,7 +7929,9 @@ const isSimpleType = /* @__PURE__ */ makeMap(
7539
7929
  function assertType(value, type) {
7540
7930
  let valid;
7541
7931
  const expectedType = getType(type);
7542
- if (isSimpleType(expectedType)) {
7932
+ if (expectedType === "null") {
7933
+ valid = value === null;
7934
+ } else if (isSimpleType(expectedType)) {
7543
7935
  const t = typeof value;
7544
7936
  valid = t === expectedType.toLowerCase();
7545
7937
  if (!valid && t === "object") {
@@ -7549,8 +7941,6 @@ function assertType(value, type) {
7549
7941
  valid = isObject(value);
7550
7942
  } else if (expectedType === "Array") {
7551
7943
  valid = isArray(value);
7552
- } else if (expectedType === "null") {
7553
- valid = value === null;
7554
7944
  } else {
7555
7945
  valid = value instanceof type;
7556
7946
  }
@@ -9123,7 +9513,6 @@ function baseCreateRenderer(options, createHydrationFns) {
9123
9513
  } else {
9124
9514
  instance.next = n2;
9125
9515
  invalidateJob(instance.update);
9126
- instance.effect.dirty = true;
9127
9516
  instance.update();
9128
9517
  }
9129
9518
  } else {
@@ -9330,24 +9719,18 @@ function baseCreateRenderer(options, createHydrationFns) {
9330
9719
  }
9331
9720
  }
9332
9721
  };
9333
- const effect = instance.effect = new ReactiveEffect(
9334
- componentUpdateFn,
9335
- NOOP,
9336
- () => queueJob(update),
9337
- instance.scope
9338
- // track it in component's effect scope
9339
- );
9340
- const update = instance.update = () => {
9341
- if (effect.dirty) {
9342
- effect.run();
9343
- }
9344
- };
9345
- update.id = instance.uid;
9722
+ instance.scope.on();
9723
+ const effect = instance.effect = new ReactiveEffect(componentUpdateFn);
9724
+ instance.scope.off();
9725
+ const update = instance.update = effect.run.bind(effect);
9726
+ const job = instance.job = effect.runIfDirty.bind(effect);
9727
+ job.id = instance.uid;
9728
+ effect.scheduler = () => queueJob(job);
9346
9729
  toggleRecurse(instance, true);
9347
9730
  if (!!(process.env.NODE_ENV !== "production")) {
9348
9731
  effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
9349
9732
  effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
9350
- update.ownerInstance = instance;
9733
+ job.ownerInstance = instance;
9351
9734
  }
9352
9735
  update();
9353
9736
  };
@@ -9814,7 +10197,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9814
10197
  if (!!(process.env.NODE_ENV !== "production") && instance.type.__hmrId) {
9815
10198
  unregisterHMR(instance);
9816
10199
  }
9817
- const { bum, scope, update, subTree, um } = instance;
10200
+ const { bum, scope, job, subTree, um } = instance;
9818
10201
  if (bum) {
9819
10202
  invokeArrayFns(bum);
9820
10203
  }
@@ -9822,8 +10205,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9822
10205
  instance.emit("hook:beforeDestroy");
9823
10206
  }
9824
10207
  scope.stop();
9825
- if (update) {
9826
- update.active = false;
10208
+ if (job) {
10209
+ job.flags |= 8;
9827
10210
  unmount(subTree, instance, parentSuspense, doRemove);
9828
10211
  }
9829
10212
  if (um) {
@@ -9915,8 +10298,14 @@ function baseCreateRenderer(options, createHydrationFns) {
9915
10298
  function resolveChildrenNamespace({ type, props }, currentNamespace) {
9916
10299
  return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
9917
10300
  }
9918
- function toggleRecurse({ effect, update }, allowed) {
9919
- effect.allowRecurse = update.allowRecurse = allowed;
10301
+ function toggleRecurse({ effect, job }, allowed) {
10302
+ if (allowed) {
10303
+ effect.flags |= 32;
10304
+ job.flags |= 4;
10305
+ } else {
10306
+ effect.flags &= ~32;
10307
+ job.flags &= ~4;
10308
+ }
9920
10309
  }
9921
10310
  function needTransition(parentSuspense, transition) {
9922
10311
  return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
@@ -10714,6 +11103,7 @@ function createComponentInstance(vnode, parent, suspense) {
10714
11103
  effect: null,
10715
11104
  update: null,
10716
11105
  // will be set synchronously right after creation
11106
+ job: null,
10717
11107
  scope: new EffectScope(
10718
11108
  true
10719
11109
  /* detached */
@@ -11250,7 +11640,8 @@ function initCustomFormatter() {
11250
11640
  {},
11251
11641
  ["span", vueStyle, genRefFlag(obj)],
11252
11642
  "<",
11253
- formatValue(obj.value),
11643
+ // avoid debugger accessing value affecting behavior
11644
+ formatValue("_value" in obj ? obj._value : obj),
11254
11645
  `>`
11255
11646
  ];
11256
11647
  } else if (isReactive(obj)) {
@@ -11430,7 +11821,7 @@ function isMemoSame(cached, memo) {
11430
11821
  return true;
11431
11822
  }
11432
11823
 
11433
- const version = "3.4.25";
11824
+ const version = "3.5.0-alpha.1";
11434
11825
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
11435
11826
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11436
11827
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13046,7 +13437,9 @@ const withKeys = (fn, modifiers) => {
13046
13437
  return;
13047
13438
  }
13048
13439
  const eventKey = hyphenate(event.key);
13049
- if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
13440
+ if (modifiers.some(
13441
+ (k) => k === eventKey || keyNames[k] === eventKey
13442
+ )) {
13050
13443
  return fn(event);
13051
13444
  }
13052
13445
  {