@vue/compat 3.3.6 → 3.4.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.
package/dist/vue.cjs.js CHANGED
@@ -492,117 +492,120 @@ function onScopeDispose(fn) {
492
492
  }
493
493
  }
494
494
 
495
- const createDep = (effects) => {
496
- const dep = new Set(effects);
497
- dep.w = 0;
498
- dep.n = 0;
499
- return dep;
500
- };
501
- const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
502
- const newTracked = (dep) => (dep.n & trackOpBit) > 0;
503
- const initDepMarkers = ({ deps }) => {
504
- if (deps.length) {
505
- for (let i = 0; i < deps.length; i++) {
506
- deps[i].w |= trackOpBit;
507
- }
508
- }
509
- };
510
- const finalizeDepMarkers = (effect) => {
511
- const { deps } = effect;
512
- if (deps.length) {
513
- let ptr = 0;
514
- for (let i = 0; i < deps.length; i++) {
515
- const dep = deps[i];
516
- if (wasTracked(dep) && !newTracked(dep)) {
517
- dep.delete(effect);
518
- } else {
519
- deps[ptr++] = dep;
520
- }
521
- dep.w &= ~trackOpBit;
522
- dep.n &= ~trackOpBit;
523
- }
524
- deps.length = ptr;
525
- }
526
- };
527
-
528
- const targetMap = /* @__PURE__ */ new WeakMap();
529
- let effectTrackDepth = 0;
530
- let trackOpBit = 1;
531
- const maxMarkerBits = 30;
532
495
  let activeEffect;
533
- const ITERATE_KEY = Symbol("iterate" );
534
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
535
496
  class ReactiveEffect {
536
- constructor(fn, scheduler = null, scope) {
497
+ constructor(fn, trigger, scheduler, scope) {
537
498
  this.fn = fn;
499
+ this.trigger = trigger;
538
500
  this.scheduler = scheduler;
539
501
  this.active = true;
540
502
  this.deps = [];
541
- this.parent = void 0;
503
+ /**
504
+ * @internal
505
+ */
506
+ this._dirtyLevel = 3;
507
+ /**
508
+ * @internal
509
+ */
510
+ this._trackId = 0;
511
+ /**
512
+ * @internal
513
+ */
514
+ this._runnings = 0;
515
+ /**
516
+ * @internal
517
+ */
518
+ this._queryings = 0;
519
+ /**
520
+ * @internal
521
+ */
522
+ this._depsLength = 0;
542
523
  recordEffectScope(this, scope);
543
524
  }
525
+ get dirty() {
526
+ if (this._dirtyLevel === 1) {
527
+ this._dirtyLevel = 0;
528
+ this._queryings++;
529
+ pauseTracking();
530
+ for (const dep of this.deps) {
531
+ if (dep.computed) {
532
+ triggerComputed(dep.computed);
533
+ if (this._dirtyLevel >= 2) {
534
+ break;
535
+ }
536
+ }
537
+ }
538
+ resetTracking();
539
+ this._queryings--;
540
+ }
541
+ return this._dirtyLevel >= 2;
542
+ }
543
+ set dirty(v) {
544
+ this._dirtyLevel = v ? 3 : 0;
545
+ }
544
546
  run() {
547
+ this._dirtyLevel = 0;
545
548
  if (!this.active) {
546
549
  return this.fn();
547
550
  }
548
- let parent = activeEffect;
549
551
  let lastShouldTrack = shouldTrack;
550
- while (parent) {
551
- if (parent === this) {
552
- return;
553
- }
554
- parent = parent.parent;
555
- }
552
+ let lastEffect = activeEffect;
556
553
  try {
557
- this.parent = activeEffect;
558
- activeEffect = this;
559
554
  shouldTrack = true;
560
- trackOpBit = 1 << ++effectTrackDepth;
561
- if (effectTrackDepth <= maxMarkerBits) {
562
- initDepMarkers(this);
563
- } else {
564
- cleanupEffect(this);
565
- }
555
+ activeEffect = this;
556
+ this._runnings++;
557
+ preCleanupEffect(this);
566
558
  return this.fn();
567
559
  } finally {
568
- if (effectTrackDepth <= maxMarkerBits) {
569
- finalizeDepMarkers(this);
570
- }
571
- trackOpBit = 1 << --effectTrackDepth;
572
- activeEffect = this.parent;
560
+ postCleanupEffect(this);
561
+ this._runnings--;
562
+ activeEffect = lastEffect;
573
563
  shouldTrack = lastShouldTrack;
574
- this.parent = void 0;
575
- if (this.deferStop) {
576
- this.stop();
577
- }
578
564
  }
579
565
  }
580
566
  stop() {
581
- if (activeEffect === this) {
582
- this.deferStop = true;
583
- } else if (this.active) {
584
- cleanupEffect(this);
585
- if (this.onStop) {
586
- this.onStop();
587
- }
567
+ var _a;
568
+ if (this.active) {
569
+ preCleanupEffect(this);
570
+ postCleanupEffect(this);
571
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
588
572
  this.active = false;
589
573
  }
590
574
  }
591
575
  }
592
- function cleanupEffect(effect2) {
593
- const { deps } = effect2;
594
- if (deps.length) {
595
- for (let i = 0; i < deps.length; i++) {
596
- deps[i].delete(effect2);
576
+ function triggerComputed(computed) {
577
+ return computed.value;
578
+ }
579
+ function preCleanupEffect(effect2) {
580
+ effect2._trackId++;
581
+ effect2._depsLength = 0;
582
+ }
583
+ function postCleanupEffect(effect2) {
584
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
585
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
586
+ cleanupDepEffect(effect2.deps[i], effect2);
587
+ }
588
+ effect2.deps.length = effect2._depsLength;
589
+ }
590
+ }
591
+ function cleanupDepEffect(dep, effect2) {
592
+ const trackId = dep.get(effect2);
593
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
594
+ dep.delete(effect2);
595
+ if (dep.size === 0) {
596
+ dep.cleanup();
597
597
  }
598
- deps.length = 0;
599
598
  }
600
599
  }
601
600
  function effect(fn, options) {
602
601
  if (fn.effect instanceof ReactiveEffect) {
603
602
  fn = fn.effect.fn;
604
603
  }
605
- const _effect = new ReactiveEffect(fn);
604
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
605
+ if (_effect.dirty) {
606
+ _effect.run();
607
+ }
608
+ });
606
609
  if (options) {
607
610
  extend(_effect, options);
608
611
  if (options.scope)
@@ -619,6 +622,7 @@ function stop(runner) {
619
622
  runner.effect.stop();
620
623
  }
621
624
  let shouldTrack = true;
625
+ let pauseScheduleStack = 0;
622
626
  const trackStack = [];
623
627
  function pauseTracking() {
624
628
  trackStack.push(shouldTrack);
@@ -628,6 +632,68 @@ function resetTracking() {
628
632
  const last = trackStack.pop();
629
633
  shouldTrack = last === void 0 ? true : last;
630
634
  }
635
+ function pauseScheduling() {
636
+ pauseScheduleStack++;
637
+ }
638
+ function resetScheduling() {
639
+ pauseScheduleStack--;
640
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
641
+ queueEffectSchedulers.shift()();
642
+ }
643
+ }
644
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
645
+ var _a;
646
+ if (dep.get(effect2) !== effect2._trackId) {
647
+ dep.set(effect2, effect2._trackId);
648
+ const oldDep = effect2.deps[effect2._depsLength];
649
+ if (oldDep !== dep) {
650
+ if (oldDep) {
651
+ cleanupDepEffect(oldDep, effect2);
652
+ }
653
+ effect2.deps[effect2._depsLength++] = dep;
654
+ } else {
655
+ effect2._depsLength++;
656
+ }
657
+ {
658
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
659
+ }
660
+ }
661
+ }
662
+ const queueEffectSchedulers = [];
663
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
664
+ var _a;
665
+ pauseScheduling();
666
+ for (const effect2 of dep.keys()) {
667
+ if (!effect2.allowRecurse && effect2._runnings) {
668
+ continue;
669
+ }
670
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
671
+ const lastDirtyLevel = effect2._dirtyLevel;
672
+ effect2._dirtyLevel = dirtyLevel;
673
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
674
+ {
675
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
676
+ }
677
+ effect2.trigger();
678
+ if (effect2.scheduler) {
679
+ queueEffectSchedulers.push(effect2.scheduler);
680
+ }
681
+ }
682
+ }
683
+ }
684
+ resetScheduling();
685
+ }
686
+
687
+ const createDep = (cleanup, computed) => {
688
+ const dep = /* @__PURE__ */ new Map();
689
+ dep.cleanup = cleanup;
690
+ dep.computed = computed;
691
+ return dep;
692
+ };
693
+
694
+ const targetMap = /* @__PURE__ */ new WeakMap();
695
+ const ITERATE_KEY = Symbol("iterate" );
696
+ const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
631
697
  function track(target, type, key) {
632
698
  if (shouldTrack && activeEffect) {
633
699
  let depsMap = targetMap.get(target);
@@ -636,35 +702,17 @@ function track(target, type, key) {
636
702
  }
637
703
  let dep = depsMap.get(key);
638
704
  if (!dep) {
639
- depsMap.set(key, dep = createDep());
640
- }
641
- const eventInfo = { effect: activeEffect, target, type, key } ;
642
- trackEffects(dep, eventInfo);
643
- }
644
- }
645
- function trackEffects(dep, debuggerEventExtraInfo) {
646
- let shouldTrack2 = false;
647
- if (effectTrackDepth <= maxMarkerBits) {
648
- if (!newTracked(dep)) {
649
- dep.n |= trackOpBit;
650
- shouldTrack2 = !wasTracked(dep);
651
- }
652
- } else {
653
- shouldTrack2 = !dep.has(activeEffect);
654
- }
655
- if (shouldTrack2) {
656
- dep.add(activeEffect);
657
- activeEffect.deps.push(dep);
658
- if (activeEffect.onTrack) {
659
- activeEffect.onTrack(
660
- extend(
661
- {
662
- effect: activeEffect
663
- },
664
- debuggerEventExtraInfo
665
- )
666
- );
705
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
667
706
  }
707
+ trackEffect(
708
+ activeEffect,
709
+ dep,
710
+ {
711
+ target,
712
+ type,
713
+ key
714
+ }
715
+ );
668
716
  }
669
717
  }
670
718
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -678,7 +726,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
678
726
  } else if (key === "length" && isArray(target)) {
679
727
  const newLength = Number(newValue);
680
728
  depsMap.forEach((dep, key2) => {
681
- if (key2 === "length" || key2 >= newLength) {
729
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
682
730
  deps.push(dep);
683
731
  }
684
732
  });
@@ -712,49 +760,24 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
712
760
  break;
713
761
  }
714
762
  }
715
- const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
716
- if (deps.length === 1) {
717
- if (deps[0]) {
718
- {
719
- triggerEffects(deps[0], eventInfo);
720
- }
721
- }
722
- } else {
723
- const effects = [];
724
- for (const dep of deps) {
725
- if (dep) {
726
- effects.push(...dep);
727
- }
728
- }
729
- {
730
- triggerEffects(createDep(effects), eventInfo);
731
- }
732
- }
733
- }
734
- function triggerEffects(dep, debuggerEventExtraInfo) {
735
- const effects = isArray(dep) ? dep : [...dep];
736
- for (const effect2 of effects) {
737
- if (effect2.computed) {
738
- triggerEffect(effect2, debuggerEventExtraInfo);
739
- }
740
- }
741
- for (const effect2 of effects) {
742
- if (!effect2.computed) {
743
- triggerEffect(effect2, debuggerEventExtraInfo);
744
- }
745
- }
746
- }
747
- function triggerEffect(effect2, debuggerEventExtraInfo) {
748
- if (effect2 !== activeEffect || effect2.allowRecurse) {
749
- if (effect2.onTrigger) {
750
- effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
751
- }
752
- if (effect2.scheduler) {
753
- effect2.scheduler();
754
- } else {
755
- effect2.run();
763
+ pauseScheduling();
764
+ for (const dep of deps) {
765
+ if (dep) {
766
+ triggerEffects(
767
+ dep,
768
+ 3,
769
+ {
770
+ target,
771
+ type,
772
+ key,
773
+ newValue,
774
+ oldValue,
775
+ oldTarget
776
+ }
777
+ );
756
778
  }
757
779
  }
780
+ resetScheduling();
758
781
  }
759
782
  function getDepFromReactive(object, key) {
760
783
  var _a;
@@ -785,7 +808,9 @@ function createArrayInstrumentations() {
785
808
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
786
809
  instrumentations[key] = function(...args) {
787
810
  pauseTracking();
811
+ pauseScheduling();
788
812
  const res = toRaw(this)[key].apply(this, args);
813
+ resetScheduling();
789
814
  resetTracking();
790
815
  return res;
791
816
  };
@@ -1324,30 +1349,93 @@ function markRaw(value) {
1324
1349
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1325
1350
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1326
1351
 
1352
+ class ComputedRefImpl {
1353
+ constructor(getter, _setter, isReadonly, isSSR) {
1354
+ this._setter = _setter;
1355
+ this.dep = void 0;
1356
+ this.__v_isRef = true;
1357
+ this["__v_isReadonly"] = false;
1358
+ this.effect = new ReactiveEffect(getter, () => {
1359
+ triggerRefValue(this, 1);
1360
+ });
1361
+ this.effect.computed = this;
1362
+ this.effect.active = this._cacheable = !isSSR;
1363
+ this["__v_isReadonly"] = isReadonly;
1364
+ }
1365
+ get value() {
1366
+ const self = toRaw(this);
1367
+ trackRefValue(self);
1368
+ if (!self._cacheable || self.effect.dirty) {
1369
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1370
+ triggerRefValue(self, 2);
1371
+ }
1372
+ }
1373
+ return self._value;
1374
+ }
1375
+ set value(newValue) {
1376
+ this._setter(newValue);
1377
+ }
1378
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1379
+ get _dirty() {
1380
+ return this.effect.dirty;
1381
+ }
1382
+ set _dirty(v) {
1383
+ this.effect.dirty = v;
1384
+ }
1385
+ // #endregion
1386
+ }
1387
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1388
+ let getter;
1389
+ let setter;
1390
+ const onlyGetter = isFunction(getterOrOptions);
1391
+ if (onlyGetter) {
1392
+ getter = getterOrOptions;
1393
+ setter = () => {
1394
+ console.warn("Write operation failed: computed value is readonly");
1395
+ } ;
1396
+ } else {
1397
+ getter = getterOrOptions.get;
1398
+ setter = getterOrOptions.set;
1399
+ }
1400
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1401
+ if (debugOptions && !isSSR) {
1402
+ cRef.effect.onTrack = debugOptions.onTrack;
1403
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1404
+ }
1405
+ return cRef;
1406
+ }
1407
+
1327
1408
  function trackRefValue(ref2) {
1328
1409
  if (shouldTrack && activeEffect) {
1329
1410
  ref2 = toRaw(ref2);
1330
- {
1331
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1411
+ trackEffect(
1412
+ activeEffect,
1413
+ ref2.dep || (ref2.dep = createDep(
1414
+ () => ref2.dep = void 0,
1415
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1416
+ )),
1417
+ {
1332
1418
  target: ref2,
1333
1419
  type: "get",
1334
1420
  key: "value"
1335
- });
1336
- }
1421
+ }
1422
+ );
1337
1423
  }
1338
1424
  }
1339
- function triggerRefValue(ref2, newVal) {
1425
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1340
1426
  ref2 = toRaw(ref2);
1341
1427
  const dep = ref2.dep;
1342
1428
  if (dep) {
1343
- {
1344
- triggerEffects(dep, {
1429
+ triggerEffects(
1430
+ dep,
1431
+ dirtyLevel,
1432
+ {
1345
1433
  target: ref2,
1346
1434
  type: "set",
1347
1435
  key: "value",
1348
1436
  newValue: newVal
1349
- });
1350
- }
1437
+ }
1438
+ );
1351
1439
  }
1352
1440
  }
1353
1441
  function isRef(r) {
@@ -1383,12 +1471,12 @@ class RefImpl {
1383
1471
  if (hasChanged(newVal, this._rawValue)) {
1384
1472
  this._rawValue = newVal;
1385
1473
  this._value = useDirectValue ? newVal : toReactive(newVal);
1386
- triggerRefValue(this, newVal);
1474
+ triggerRefValue(this, 3, newVal);
1387
1475
  }
1388
1476
  }
1389
1477
  }
1390
1478
  function triggerRef(ref2) {
1391
- triggerRefValue(ref2, ref2.value );
1479
+ triggerRefValue(ref2, 3, ref2.value );
1392
1480
  }
1393
1481
  function unref(ref2) {
1394
1482
  return isRef(ref2) ? ref2.value : ref2;
@@ -1486,57 +1574,6 @@ function propertyToRef(source, key, defaultValue) {
1486
1574
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1487
1575
  }
1488
1576
 
1489
- class ComputedRefImpl {
1490
- constructor(getter, _setter, isReadonly, isSSR) {
1491
- this._setter = _setter;
1492
- this.dep = void 0;
1493
- this.__v_isRef = true;
1494
- this["__v_isReadonly"] = false;
1495
- this._dirty = true;
1496
- this.effect = new ReactiveEffect(getter, () => {
1497
- if (!this._dirty) {
1498
- this._dirty = true;
1499
- triggerRefValue(this);
1500
- }
1501
- });
1502
- this.effect.computed = this;
1503
- this.effect.active = this._cacheable = !isSSR;
1504
- this["__v_isReadonly"] = isReadonly;
1505
- }
1506
- get value() {
1507
- const self = toRaw(this);
1508
- trackRefValue(self);
1509
- if (self._dirty || !self._cacheable) {
1510
- self._dirty = false;
1511
- self._value = self.effect.run();
1512
- }
1513
- return self._value;
1514
- }
1515
- set value(newValue) {
1516
- this._setter(newValue);
1517
- }
1518
- }
1519
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1520
- let getter;
1521
- let setter;
1522
- const onlyGetter = isFunction(getterOrOptions);
1523
- if (onlyGetter) {
1524
- getter = getterOrOptions;
1525
- setter = () => {
1526
- console.warn("Write operation failed: computed value is readonly");
1527
- } ;
1528
- } else {
1529
- getter = getterOrOptions.get;
1530
- setter = getterOrOptions.set;
1531
- }
1532
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1533
- if (debugOptions && !isSSR) {
1534
- cRef.effect.onTrack = debugOptions.onTrack;
1535
- cRef.effect.onTrigger = debugOptions.onTrigger;
1536
- }
1537
- return cRef;
1538
- }
1539
-
1540
1577
  const stack = [];
1541
1578
  function pushWarningContext(vnode) {
1542
1579
  stack.push(vnode);
@@ -1651,7 +1688,7 @@ function assertNumber(val, type) {
1651
1688
  }
1652
1689
  }
1653
1690
 
1654
- const ErrorTypeStrings = {
1691
+ const ErrorTypeStrings$1 = {
1655
1692
  ["sp"]: "serverPrefetch hook",
1656
1693
  ["bc"]: "beforeCreate hook",
1657
1694
  ["c"]: "created hook",
@@ -1712,7 +1749,7 @@ function handleError(err, instance, type, throwInDev = true) {
1712
1749
  if (instance) {
1713
1750
  let cur = instance.parent;
1714
1751
  const exposedInstance = instance.proxy;
1715
- const errorInfo = ErrorTypeStrings[type] ;
1752
+ const errorInfo = ErrorTypeStrings$1[type] ;
1716
1753
  while (cur) {
1717
1754
  const errorCapturedHooks = cur.ec;
1718
1755
  if (errorCapturedHooks) {
@@ -1739,7 +1776,7 @@ function handleError(err, instance, type, throwInDev = true) {
1739
1776
  }
1740
1777
  function logError(err, type, contextVNode, throwInDev = true) {
1741
1778
  {
1742
- const info = ErrorTypeStrings[type];
1779
+ const info = ErrorTypeStrings$1[type];
1743
1780
  if (contextVNode) {
1744
1781
  pushWarningContext(contextVNode);
1745
1782
  }
@@ -1774,8 +1811,13 @@ function findInsertionIndex(id) {
1774
1811
  let end = queue.length;
1775
1812
  while (start < end) {
1776
1813
  const middle = start + end >>> 1;
1777
- const middleJobId = getId(queue[middle]);
1778
- middleJobId < id ? start = middle + 1 : end = middle;
1814
+ const middleJob = queue[middle];
1815
+ const middleJobId = getId(middleJob);
1816
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1817
+ start = middle + 1;
1818
+ } else {
1819
+ end = middle;
1820
+ }
1779
1821
  }
1780
1822
  return start;
1781
1823
  }
@@ -1962,6 +2004,7 @@ function rerender(id, newRender) {
1962
2004
  }
1963
2005
  instance.renderCache = [];
1964
2006
  isHmrUpdating = true;
2007
+ instance.effect.dirty = true;
1965
2008
  instance.update();
1966
2009
  isHmrUpdating = false;
1967
2010
  });
@@ -1989,6 +2032,7 @@ function reload(id, newComp) {
1989
2032
  instance.ceReload(newComp.styles);
1990
2033
  hmrDirtyComponents.delete(oldComp);
1991
2034
  } else if (instance.parent) {
2035
+ instance.parent.effect.dirty = true;
1992
2036
  queueJob(instance.parent.update);
1993
2037
  } else if (instance.appContext.reload) {
1994
2038
  instance.appContext.reload();
@@ -3363,14 +3407,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3363
3407
  parentComponent: parentComponent2,
3364
3408
  container: container2
3365
3409
  } = suspense;
3410
+ let delayEnter = false;
3366
3411
  if (suspense.isHydrating) {
3367
3412
  suspense.isHydrating = false;
3368
3413
  } else if (!resume) {
3369
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3414
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3370
3415
  if (delayEnter) {
3371
3416
  activeBranch.transition.afterLeave = () => {
3372
3417
  if (pendingId === suspense.pendingId) {
3373
3418
  move(pendingBranch, container2, anchor2, 0);
3419
+ queuePostFlushCb(effects);
3374
3420
  }
3375
3421
  };
3376
3422
  }
@@ -3396,7 +3442,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3396
3442
  }
3397
3443
  parent = parent.parent;
3398
3444
  }
3399
- if (!hasUnresolvedAncestor) {
3445
+ if (!hasUnresolvedAncestor && !delayEnter) {
3400
3446
  queuePostFlushCb(effects);
3401
3447
  }
3402
3448
  suspense.effects = [];
@@ -3682,8 +3728,15 @@ function watch(source, cb, options) {
3682
3728
  }
3683
3729
  return doWatch(source, cb, options);
3684
3730
  }
3685
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3731
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3686
3732
  var _a;
3733
+ if (cb && once) {
3734
+ const _cb = cb;
3735
+ cb = (...args) => {
3736
+ _cb(...args);
3737
+ unwatch();
3738
+ };
3739
+ }
3687
3740
  if (!cb) {
3688
3741
  if (immediate !== void 0) {
3689
3742
  warn(
@@ -3695,6 +3748,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3695
3748
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3696
3749
  );
3697
3750
  }
3751
+ if (once !== void 0) {
3752
+ warn(
3753
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3754
+ );
3755
+ }
3698
3756
  }
3699
3757
  const warnInvalidSource = (s) => {
3700
3758
  warn(
@@ -3791,7 +3849,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3791
3849
  }
3792
3850
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3793
3851
  const job = () => {
3794
- if (!effect.active) {
3852
+ if (!effect.active || !effect.dirty) {
3795
3853
  return;
3796
3854
  }
3797
3855
  if (cb) {
@@ -3824,7 +3882,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3824
3882
  job.id = instance.uid;
3825
3883
  scheduler = () => queueJob(job);
3826
3884
  }
3827
- const effect = new ReactiveEffect(getter, scheduler);
3885
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3886
+ const unwatch = () => {
3887
+ effect.stop();
3888
+ if (instance && instance.scope) {
3889
+ remove(instance.scope.effects, effect);
3890
+ }
3891
+ };
3828
3892
  {
3829
3893
  effect.onTrack = onTrack;
3830
3894
  effect.onTrigger = onTrigger;
@@ -3843,12 +3907,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3843
3907
  } else {
3844
3908
  effect.run();
3845
3909
  }
3846
- const unwatch = () => {
3847
- effect.stop();
3848
- if (instance && instance.scope) {
3849
- remove(instance.scope.effects, effect);
3850
- }
3851
- };
3852
3910
  if (ssrCleanup)
3853
3911
  ssrCleanup.push(unwatch);
3854
3912
  return unwatch;
@@ -4083,6 +4141,7 @@ const BaseTransitionImpl = {
4083
4141
  leavingHooks.afterLeave = () => {
4084
4142
  state.isLeaving = false;
4085
4143
  if (instance.update.active !== false) {
4144
+ instance.effect.dirty = true;
4086
4145
  instance.update();
4087
4146
  }
4088
4147
  };
@@ -4421,6 +4480,7 @@ function defineAsyncComponent(source) {
4421
4480
  load().then(() => {
4422
4481
  loaded.value = true;
4423
4482
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4483
+ instance.parent.effect.dirty = true;
4424
4484
  queueJob(instance.parent.update);
4425
4485
  }
4426
4486
  }).catch((err) => {
@@ -4724,7 +4784,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4724
4784
  }
4725
4785
  return wrappedHook;
4726
4786
  } else {
4727
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4787
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4728
4788
  warn(
4729
4789
  `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
4730
4790
  );
@@ -5446,7 +5506,10 @@ const publicPropertiesMap = (
5446
5506
  $root: (i) => getPublicInstance(i.root),
5447
5507
  $emit: (i) => i.emit,
5448
5508
  $options: (i) => resolveMergedOptions(i) ,
5449
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5509
+ $forceUpdate: (i) => i.f || (i.f = () => {
5510
+ i.effect.dirty = true;
5511
+ queueJob(i.update);
5512
+ }),
5450
5513
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5451
5514
  $watch: (i) => instanceWatch.bind(i)
5452
5515
  })
@@ -6347,7 +6410,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6347
6410
  return vm;
6348
6411
  }
6349
6412
  }
6350
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
6413
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6351
6414
  Vue.config = singletonApp.config;
6352
6415
  Vue.use = (p, ...options) => {
6353
6416
  if (p && isFunction(p.install)) {
@@ -7677,7 +7740,14 @@ function createHydrationFunctions(rendererInternals) {
7677
7740
  break;
7678
7741
  case Comment:
7679
7742
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7680
- nextNode = onMismatch();
7743
+ if (node.tagName.toLowerCase() === "template") {
7744
+ const content = vnode.el.content.firstChild;
7745
+ replaceNode(content, node, parentComponent);
7746
+ vnode.el = node = content;
7747
+ nextNode = nextSibling(node);
7748
+ } else {
7749
+ nextNode = onMismatch();
7750
+ }
7681
7751
  } else {
7682
7752
  nextNode = nextSibling(node);
7683
7753
  }
@@ -7719,7 +7789,7 @@ function createHydrationFunctions(rendererInternals) {
7719
7789
  break;
7720
7790
  default:
7721
7791
  if (shapeFlag & 1) {
7722
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
7792
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
7723
7793
  nextNode = onMismatch();
7724
7794
  } else {
7725
7795
  nextNode = hydrateElement(
@@ -7734,6 +7804,13 @@ function createHydrationFunctions(rendererInternals) {
7734
7804
  } else if (shapeFlag & 6) {
7735
7805
  vnode.slotScopeIds = slotScopeIds;
7736
7806
  const container = parentNode(node);
7807
+ if (isFragmentStart) {
7808
+ nextNode = locateClosingAnchor(node);
7809
+ } else if (isComment(node) && node.data === "teleport start") {
7810
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
7811
+ } else {
7812
+ nextNode = nextSibling(node);
7813
+ }
7737
7814
  mountComponent(
7738
7815
  vnode,
7739
7816
  container,
@@ -7743,10 +7820,6 @@ function createHydrationFunctions(rendererInternals) {
7743
7820
  isSVGContainer(container),
7744
7821
  optimized
7745
7822
  );
7746
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
7747
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
7748
- nextNode = nextSibling(nextNode);
7749
- }
7750
7823
  if (isAsyncWrapper(vnode)) {
7751
7824
  let subTree;
7752
7825
  if (isFragmentStart) {
@@ -7796,7 +7869,7 @@ function createHydrationFunctions(rendererInternals) {
7796
7869
  };
7797
7870
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7798
7871
  optimized = optimized || !!vnode.dynamicChildren;
7799
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
7872
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7800
7873
  const forcePatchValue = type === "input" && dirs || type === "option";
7801
7874
  {
7802
7875
  if (dirs) {
@@ -7833,12 +7906,23 @@ function createHydrationFunctions(rendererInternals) {
7833
7906
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
7834
7907
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7835
7908
  }
7909
+ let needCallTransitionHooks = false;
7910
+ if (isTemplateNode(el)) {
7911
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
7912
+ const content = el.content.firstChild;
7913
+ if (needCallTransitionHooks) {
7914
+ transition.beforeEnter(content);
7915
+ }
7916
+ replaceNode(content, el, parentComponent);
7917
+ vnode.el = el = content;
7918
+ }
7836
7919
  if (dirs) {
7837
7920
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7838
7921
  }
7839
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
7922
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
7840
7923
  queueEffectWithSuspense(() => {
7841
7924
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7925
+ needCallTransitionHooks && transition.enter(el);
7842
7926
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7843
7927
  }, parentSuspense);
7844
7928
  }
@@ -7956,7 +8040,7 @@ function createHydrationFunctions(rendererInternals) {
7956
8040
  );
7957
8041
  vnode.el = null;
7958
8042
  if (isFragment) {
7959
- const end = locateClosingAsyncAnchor(node);
8043
+ const end = locateClosingAnchor(node);
7960
8044
  while (true) {
7961
8045
  const next2 = nextSibling(node);
7962
8046
  if (next2 && next2 !== end) {
@@ -7981,14 +8065,14 @@ function createHydrationFunctions(rendererInternals) {
7981
8065
  );
7982
8066
  return next;
7983
8067
  };
7984
- const locateClosingAsyncAnchor = (node) => {
8068
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
7985
8069
  let match = 0;
7986
8070
  while (node) {
7987
8071
  node = nextSibling(node);
7988
8072
  if (node && isComment(node)) {
7989
- if (node.data === "[")
8073
+ if (node.data === open)
7990
8074
  match++;
7991
- if (node.data === "]") {
8075
+ if (node.data === close) {
7992
8076
  if (match === 0) {
7993
8077
  return nextSibling(node);
7994
8078
  } else {
@@ -7999,6 +8083,23 @@ function createHydrationFunctions(rendererInternals) {
7999
8083
  }
8000
8084
  return node;
8001
8085
  };
8086
+ const replaceNode = (newNode, oldNode, parentComponent) => {
8087
+ const parentNode2 = oldNode.parentNode;
8088
+ if (parentNode2) {
8089
+ parentNode2.replaceChild(newNode, oldNode);
8090
+ }
8091
+ let parent = parentComponent;
8092
+ while (parent) {
8093
+ if (parent.vnode.el === oldNode) {
8094
+ parent.vnode.el = newNode;
8095
+ parent.subTree.el = newNode;
8096
+ }
8097
+ parent = parent.parent;
8098
+ }
8099
+ };
8100
+ const isTemplateNode = (node) => {
8101
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
8102
+ };
8002
8103
  return [hydrate, hydrateNode];
8003
8104
  }
8004
8105
 
@@ -8326,7 +8427,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8326
8427
  if (dirs) {
8327
8428
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
8328
8429
  }
8329
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8430
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
8330
8431
  if (needCallTransitionHooks) {
8331
8432
  transition.beforeEnter(el);
8332
8433
  }
@@ -8715,6 +8816,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8715
8816
  } else {
8716
8817
  instance.next = n2;
8717
8818
  invalidateJob(instance.update);
8819
+ instance.effect.dirty = true;
8718
8820
  instance.update();
8719
8821
  }
8720
8822
  } else {
@@ -8908,11 +9010,16 @@ function baseCreateRenderer(options, createHydrationFns) {
8908
9010
  };
8909
9011
  const effect = instance.effect = new ReactiveEffect(
8910
9012
  componentUpdateFn,
9013
+ NOOP,
8911
9014
  () => queueJob(update),
8912
9015
  instance.scope
8913
9016
  // track it in component's effect scope
8914
9017
  );
8915
- const update = instance.update = () => effect.run();
9018
+ const update = instance.update = () => {
9019
+ if (effect.dirty) {
9020
+ effect.run();
9021
+ }
9022
+ };
8916
9023
  update.id = instance.uid;
8917
9024
  toggleRecurse(instance, true);
8918
9025
  {
@@ -9243,8 +9350,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9243
9350
  moveStaticNode(vnode, container, anchor);
9244
9351
  return;
9245
9352
  }
9246
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
9247
- if (needTransition) {
9353
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
9354
+ if (needTransition2) {
9248
9355
  if (moveType === 0) {
9249
9356
  transition.beforeEnter(el);
9250
9357
  hostInsert(el, container, anchor);
@@ -9473,6 +9580,9 @@ function baseCreateRenderer(options, createHydrationFns) {
9473
9580
  function toggleRecurse({ effect, update }, allowed) {
9474
9581
  effect.allowRecurse = update.allowRecurse = allowed;
9475
9582
  }
9583
+ function needTransition(parentSuspense, transition) {
9584
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
9585
+ }
9476
9586
  function traverseStaticChildren(n1, n2, shallow = false) {
9477
9587
  const ch1 = n1.children;
9478
9588
  const ch2 = n2.children;
@@ -10893,7 +11003,8 @@ function isMemoSame(cached, memo) {
10893
11003
  return true;
10894
11004
  }
10895
11005
 
10896
- const version = "3.3.6";
11006
+ const version = "3.4.0-alpha.1";
11007
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10897
11008
  const _ssrUtils = {
10898
11009
  createComponentInstance,
10899
11010
  setupComponent,
@@ -12530,6 +12641,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12530
12641
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12531
12642
  Comment: Comment,
12532
12643
  EffectScope: EffectScope,
12644
+ ErrorTypeStrings: ErrorTypeStrings,
12533
12645
  Fragment: Fragment,
12534
12646
  KeepAlive: KeepAlive,
12535
12647
  ReactiveEffect: ReactiveEffect,
@@ -14168,9 +14280,13 @@ function walk(node, context, doNotHoistNode = false) {
14168
14280
  context.transformHoist(children, context, node);
14169
14281
  }
14170
14282
  if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
14171
- node.codegenNode.children = context.hoist(
14283
+ const hoisted = context.hoist(
14172
14284
  createArrayExpression(node.codegenNode.children)
14173
14285
  );
14286
+ if (context.hmr) {
14287
+ hoisted.content = `[...${hoisted.content}]`;
14288
+ }
14289
+ node.codegenNode.children = hoisted;
14174
14290
  }
14175
14291
  }
14176
14292
  function getConstantType(node, context) {
@@ -14343,6 +14459,7 @@ function createTransformContext(root, {
14343
14459
  filename = "",
14344
14460
  prefixIdentifiers = false,
14345
14461
  hoistStatic: hoistStatic2 = false,
14462
+ hmr = false,
14346
14463
  cacheHandlers = false,
14347
14464
  nodeTransforms = [],
14348
14465
  directiveTransforms = {},
@@ -14368,6 +14485,7 @@ function createTransformContext(root, {
14368
14485
  selfName: nameMatch && capitalize(camelize(nameMatch[1])),
14369
14486
  prefixIdentifiers,
14370
14487
  hoistStatic: hoistStatic2,
14488
+ hmr,
14371
14489
  cacheHandlers,
14372
14490
  nodeTransforms,
14373
14491
  directiveTransforms,
@@ -16412,7 +16530,7 @@ const trackVForSlotScopes = (node, context) => {
16412
16530
  }
16413
16531
  }
16414
16532
  };
16415
- const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
16533
+ const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
16416
16534
  props,
16417
16535
  children,
16418
16536
  false,
@@ -16437,7 +16555,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16437
16555
  slotsProperties.push(
16438
16556
  createObjectProperty(
16439
16557
  arg || createSimpleExpression("default", true),
16440
- buildSlotFn(exp, children, loc)
16558
+ buildSlotFn(exp, void 0, children, loc)
16441
16559
  )
16442
16560
  );
16443
16561
  }
@@ -16474,10 +16592,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16474
16592
  } else {
16475
16593
  hasDynamicSlots = true;
16476
16594
  }
16477
- const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
16595
+ const vFor = findDir(slotElement, "for");
16596
+ const slotFunction = buildSlotFn(
16597
+ slotProps,
16598
+ vFor == null ? void 0 : vFor.exp,
16599
+ slotChildren,
16600
+ slotLoc
16601
+ );
16478
16602
  let vIf;
16479
16603
  let vElse;
16480
- let vFor;
16481
16604
  if (vIf = findDir(slotElement, "if")) {
16482
16605
  hasDynamicSlots = true;
16483
16606
  dynamicSlots.push(
@@ -16522,7 +16645,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16522
16645
  createCompilerError(30, vElse.loc)
16523
16646
  );
16524
16647
  }
16525
- } else if (vFor = findDir(slotElement, "for")) {
16648
+ } else if (vFor) {
16526
16649
  hasDynamicSlots = true;
16527
16650
  const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
16528
16651
  if (parseResult) {
@@ -16563,7 +16686,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16563
16686
  }
16564
16687
  if (!onComponentSlot) {
16565
16688
  const buildDefaultSlotProperty = (props, children2) => {
16566
- const fn = buildSlotFn(props, children2, loc);
16689
+ const fn = buildSlotFn(props, void 0, children2, loc);
16567
16690
  if (context.compatConfig) {
16568
16691
  fn.isNonScopedSlot = true;
16569
16692
  }