@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.
@@ -354,117 +354,120 @@ function onScopeDispose(fn) {
354
354
  }
355
355
  }
356
356
 
357
- const createDep = (effects) => {
358
- const dep = new Set(effects);
359
- dep.w = 0;
360
- dep.n = 0;
361
- return dep;
362
- };
363
- const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
364
- const newTracked = (dep) => (dep.n & trackOpBit) > 0;
365
- const initDepMarkers = ({ deps }) => {
366
- if (deps.length) {
367
- for (let i = 0; i < deps.length; i++) {
368
- deps[i].w |= trackOpBit;
369
- }
370
- }
371
- };
372
- const finalizeDepMarkers = (effect) => {
373
- const { deps } = effect;
374
- if (deps.length) {
375
- let ptr = 0;
376
- for (let i = 0; i < deps.length; i++) {
377
- const dep = deps[i];
378
- if (wasTracked(dep) && !newTracked(dep)) {
379
- dep.delete(effect);
380
- } else {
381
- deps[ptr++] = dep;
382
- }
383
- dep.w &= ~trackOpBit;
384
- dep.n &= ~trackOpBit;
385
- }
386
- deps.length = ptr;
387
- }
388
- };
389
-
390
- const targetMap = /* @__PURE__ */ new WeakMap();
391
- let effectTrackDepth = 0;
392
- let trackOpBit = 1;
393
- const maxMarkerBits = 30;
394
357
  let activeEffect;
395
- const ITERATE_KEY = Symbol("iterate" );
396
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
397
358
  class ReactiveEffect {
398
- constructor(fn, scheduler = null, scope) {
359
+ constructor(fn, trigger, scheduler, scope) {
399
360
  this.fn = fn;
361
+ this.trigger = trigger;
400
362
  this.scheduler = scheduler;
401
363
  this.active = true;
402
364
  this.deps = [];
403
- this.parent = void 0;
365
+ /**
366
+ * @internal
367
+ */
368
+ this._dirtyLevel = 3;
369
+ /**
370
+ * @internal
371
+ */
372
+ this._trackId = 0;
373
+ /**
374
+ * @internal
375
+ */
376
+ this._runnings = 0;
377
+ /**
378
+ * @internal
379
+ */
380
+ this._queryings = 0;
381
+ /**
382
+ * @internal
383
+ */
384
+ this._depsLength = 0;
404
385
  recordEffectScope(this, scope);
405
386
  }
387
+ get dirty() {
388
+ if (this._dirtyLevel === 1) {
389
+ this._dirtyLevel = 0;
390
+ this._queryings++;
391
+ pauseTracking();
392
+ for (const dep of this.deps) {
393
+ if (dep.computed) {
394
+ triggerComputed(dep.computed);
395
+ if (this._dirtyLevel >= 2) {
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ resetTracking();
401
+ this._queryings--;
402
+ }
403
+ return this._dirtyLevel >= 2;
404
+ }
405
+ set dirty(v) {
406
+ this._dirtyLevel = v ? 3 : 0;
407
+ }
406
408
  run() {
409
+ this._dirtyLevel = 0;
407
410
  if (!this.active) {
408
411
  return this.fn();
409
412
  }
410
- let parent = activeEffect;
411
413
  let lastShouldTrack = shouldTrack;
412
- while (parent) {
413
- if (parent === this) {
414
- return;
415
- }
416
- parent = parent.parent;
417
- }
414
+ let lastEffect = activeEffect;
418
415
  try {
419
- this.parent = activeEffect;
420
- activeEffect = this;
421
416
  shouldTrack = true;
422
- trackOpBit = 1 << ++effectTrackDepth;
423
- if (effectTrackDepth <= maxMarkerBits) {
424
- initDepMarkers(this);
425
- } else {
426
- cleanupEffect(this);
427
- }
417
+ activeEffect = this;
418
+ this._runnings++;
419
+ preCleanupEffect(this);
428
420
  return this.fn();
429
421
  } finally {
430
- if (effectTrackDepth <= maxMarkerBits) {
431
- finalizeDepMarkers(this);
432
- }
433
- trackOpBit = 1 << --effectTrackDepth;
434
- activeEffect = this.parent;
422
+ postCleanupEffect(this);
423
+ this._runnings--;
424
+ activeEffect = lastEffect;
435
425
  shouldTrack = lastShouldTrack;
436
- this.parent = void 0;
437
- if (this.deferStop) {
438
- this.stop();
439
- }
440
426
  }
441
427
  }
442
428
  stop() {
443
- if (activeEffect === this) {
444
- this.deferStop = true;
445
- } else if (this.active) {
446
- cleanupEffect(this);
447
- if (this.onStop) {
448
- this.onStop();
449
- }
429
+ var _a;
430
+ if (this.active) {
431
+ preCleanupEffect(this);
432
+ postCleanupEffect(this);
433
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
450
434
  this.active = false;
451
435
  }
452
436
  }
453
437
  }
454
- function cleanupEffect(effect2) {
455
- const { deps } = effect2;
456
- if (deps.length) {
457
- for (let i = 0; i < deps.length; i++) {
458
- deps[i].delete(effect2);
438
+ function triggerComputed(computed) {
439
+ return computed.value;
440
+ }
441
+ function preCleanupEffect(effect2) {
442
+ effect2._trackId++;
443
+ effect2._depsLength = 0;
444
+ }
445
+ function postCleanupEffect(effect2) {
446
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
447
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
448
+ cleanupDepEffect(effect2.deps[i], effect2);
449
+ }
450
+ effect2.deps.length = effect2._depsLength;
451
+ }
452
+ }
453
+ function cleanupDepEffect(dep, effect2) {
454
+ const trackId = dep.get(effect2);
455
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
456
+ dep.delete(effect2);
457
+ if (dep.size === 0) {
458
+ dep.cleanup();
459
459
  }
460
- deps.length = 0;
461
460
  }
462
461
  }
463
462
  function effect(fn, options) {
464
463
  if (fn.effect instanceof ReactiveEffect) {
465
464
  fn = fn.effect.fn;
466
465
  }
467
- const _effect = new ReactiveEffect(fn);
466
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
467
+ if (_effect.dirty) {
468
+ _effect.run();
469
+ }
470
+ });
468
471
  if (options) {
469
472
  extend(_effect, options);
470
473
  if (options.scope)
@@ -481,6 +484,7 @@ function stop(runner) {
481
484
  runner.effect.stop();
482
485
  }
483
486
  let shouldTrack = true;
487
+ let pauseScheduleStack = 0;
484
488
  const trackStack = [];
485
489
  function pauseTracking() {
486
490
  trackStack.push(shouldTrack);
@@ -490,6 +494,68 @@ function resetTracking() {
490
494
  const last = trackStack.pop();
491
495
  shouldTrack = last === void 0 ? true : last;
492
496
  }
497
+ function pauseScheduling() {
498
+ pauseScheduleStack++;
499
+ }
500
+ function resetScheduling() {
501
+ pauseScheduleStack--;
502
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
503
+ queueEffectSchedulers.shift()();
504
+ }
505
+ }
506
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
507
+ var _a;
508
+ if (dep.get(effect2) !== effect2._trackId) {
509
+ dep.set(effect2, effect2._trackId);
510
+ const oldDep = effect2.deps[effect2._depsLength];
511
+ if (oldDep !== dep) {
512
+ if (oldDep) {
513
+ cleanupDepEffect(oldDep, effect2);
514
+ }
515
+ effect2.deps[effect2._depsLength++] = dep;
516
+ } else {
517
+ effect2._depsLength++;
518
+ }
519
+ {
520
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
521
+ }
522
+ }
523
+ }
524
+ const queueEffectSchedulers = [];
525
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
526
+ var _a;
527
+ pauseScheduling();
528
+ for (const effect2 of dep.keys()) {
529
+ if (!effect2.allowRecurse && effect2._runnings) {
530
+ continue;
531
+ }
532
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
533
+ const lastDirtyLevel = effect2._dirtyLevel;
534
+ effect2._dirtyLevel = dirtyLevel;
535
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
536
+ {
537
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
538
+ }
539
+ effect2.trigger();
540
+ if (effect2.scheduler) {
541
+ queueEffectSchedulers.push(effect2.scheduler);
542
+ }
543
+ }
544
+ }
545
+ }
546
+ resetScheduling();
547
+ }
548
+
549
+ const createDep = (cleanup, computed) => {
550
+ const dep = /* @__PURE__ */ new Map();
551
+ dep.cleanup = cleanup;
552
+ dep.computed = computed;
553
+ return dep;
554
+ };
555
+
556
+ const targetMap = /* @__PURE__ */ new WeakMap();
557
+ const ITERATE_KEY = Symbol("iterate" );
558
+ const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
493
559
  function track(target, type, key) {
494
560
  if (shouldTrack && activeEffect) {
495
561
  let depsMap = targetMap.get(target);
@@ -498,35 +564,17 @@ function track(target, type, key) {
498
564
  }
499
565
  let dep = depsMap.get(key);
500
566
  if (!dep) {
501
- depsMap.set(key, dep = createDep());
502
- }
503
- const eventInfo = { effect: activeEffect, target, type, key } ;
504
- trackEffects(dep, eventInfo);
505
- }
506
- }
507
- function trackEffects(dep, debuggerEventExtraInfo) {
508
- let shouldTrack2 = false;
509
- if (effectTrackDepth <= maxMarkerBits) {
510
- if (!newTracked(dep)) {
511
- dep.n |= trackOpBit;
512
- shouldTrack2 = !wasTracked(dep);
513
- }
514
- } else {
515
- shouldTrack2 = !dep.has(activeEffect);
516
- }
517
- if (shouldTrack2) {
518
- dep.add(activeEffect);
519
- activeEffect.deps.push(dep);
520
- if (activeEffect.onTrack) {
521
- activeEffect.onTrack(
522
- extend(
523
- {
524
- effect: activeEffect
525
- },
526
- debuggerEventExtraInfo
527
- )
528
- );
567
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
529
568
  }
569
+ trackEffect(
570
+ activeEffect,
571
+ dep,
572
+ {
573
+ target,
574
+ type,
575
+ key
576
+ }
577
+ );
530
578
  }
531
579
  }
532
580
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -540,7 +588,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
540
588
  } else if (key === "length" && isArray(target)) {
541
589
  const newLength = Number(newValue);
542
590
  depsMap.forEach((dep, key2) => {
543
- if (key2 === "length" || key2 >= newLength) {
591
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
544
592
  deps.push(dep);
545
593
  }
546
594
  });
@@ -574,49 +622,24 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
574
622
  break;
575
623
  }
576
624
  }
577
- const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
578
- if (deps.length === 1) {
579
- if (deps[0]) {
580
- {
581
- triggerEffects(deps[0], eventInfo);
582
- }
583
- }
584
- } else {
585
- const effects = [];
586
- for (const dep of deps) {
587
- if (dep) {
588
- effects.push(...dep);
589
- }
590
- }
591
- {
592
- triggerEffects(createDep(effects), eventInfo);
593
- }
594
- }
595
- }
596
- function triggerEffects(dep, debuggerEventExtraInfo) {
597
- const effects = isArray(dep) ? dep : [...dep];
598
- for (const effect2 of effects) {
599
- if (effect2.computed) {
600
- triggerEffect(effect2, debuggerEventExtraInfo);
601
- }
602
- }
603
- for (const effect2 of effects) {
604
- if (!effect2.computed) {
605
- triggerEffect(effect2, debuggerEventExtraInfo);
606
- }
607
- }
608
- }
609
- function triggerEffect(effect2, debuggerEventExtraInfo) {
610
- if (effect2 !== activeEffect || effect2.allowRecurse) {
611
- if (effect2.onTrigger) {
612
- effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
613
- }
614
- if (effect2.scheduler) {
615
- effect2.scheduler();
616
- } else {
617
- effect2.run();
625
+ pauseScheduling();
626
+ for (const dep of deps) {
627
+ if (dep) {
628
+ triggerEffects(
629
+ dep,
630
+ 3,
631
+ {
632
+ target,
633
+ type,
634
+ key,
635
+ newValue,
636
+ oldValue,
637
+ oldTarget
638
+ }
639
+ );
618
640
  }
619
641
  }
642
+ resetScheduling();
620
643
  }
621
644
  function getDepFromReactive(object, key) {
622
645
  var _a;
@@ -647,7 +670,9 @@ function createArrayInstrumentations() {
647
670
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
648
671
  instrumentations[key] = function(...args) {
649
672
  pauseTracking();
673
+ pauseScheduling();
650
674
  const res = toRaw(this)[key].apply(this, args);
675
+ resetScheduling();
651
676
  resetTracking();
652
677
  return res;
653
678
  };
@@ -1186,30 +1211,93 @@ function markRaw(value) {
1186
1211
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1187
1212
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1188
1213
 
1214
+ class ComputedRefImpl {
1215
+ constructor(getter, _setter, isReadonly, isSSR) {
1216
+ this._setter = _setter;
1217
+ this.dep = void 0;
1218
+ this.__v_isRef = true;
1219
+ this["__v_isReadonly"] = false;
1220
+ this.effect = new ReactiveEffect(getter, () => {
1221
+ triggerRefValue(this, 1);
1222
+ });
1223
+ this.effect.computed = this;
1224
+ this.effect.active = this._cacheable = !isSSR;
1225
+ this["__v_isReadonly"] = isReadonly;
1226
+ }
1227
+ get value() {
1228
+ const self = toRaw(this);
1229
+ trackRefValue(self);
1230
+ if (!self._cacheable || self.effect.dirty) {
1231
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1232
+ triggerRefValue(self, 2);
1233
+ }
1234
+ }
1235
+ return self._value;
1236
+ }
1237
+ set value(newValue) {
1238
+ this._setter(newValue);
1239
+ }
1240
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1241
+ get _dirty() {
1242
+ return this.effect.dirty;
1243
+ }
1244
+ set _dirty(v) {
1245
+ this.effect.dirty = v;
1246
+ }
1247
+ // #endregion
1248
+ }
1249
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1250
+ let getter;
1251
+ let setter;
1252
+ const onlyGetter = isFunction(getterOrOptions);
1253
+ if (onlyGetter) {
1254
+ getter = getterOrOptions;
1255
+ setter = () => {
1256
+ console.warn("Write operation failed: computed value is readonly");
1257
+ } ;
1258
+ } else {
1259
+ getter = getterOrOptions.get;
1260
+ setter = getterOrOptions.set;
1261
+ }
1262
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1263
+ if (debugOptions && !isSSR) {
1264
+ cRef.effect.onTrack = debugOptions.onTrack;
1265
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1266
+ }
1267
+ return cRef;
1268
+ }
1269
+
1189
1270
  function trackRefValue(ref2) {
1190
1271
  if (shouldTrack && activeEffect) {
1191
1272
  ref2 = toRaw(ref2);
1192
- {
1193
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1273
+ trackEffect(
1274
+ activeEffect,
1275
+ ref2.dep || (ref2.dep = createDep(
1276
+ () => ref2.dep = void 0,
1277
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1278
+ )),
1279
+ {
1194
1280
  target: ref2,
1195
1281
  type: "get",
1196
1282
  key: "value"
1197
- });
1198
- }
1283
+ }
1284
+ );
1199
1285
  }
1200
1286
  }
1201
- function triggerRefValue(ref2, newVal) {
1287
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1202
1288
  ref2 = toRaw(ref2);
1203
1289
  const dep = ref2.dep;
1204
1290
  if (dep) {
1205
- {
1206
- triggerEffects(dep, {
1291
+ triggerEffects(
1292
+ dep,
1293
+ dirtyLevel,
1294
+ {
1207
1295
  target: ref2,
1208
1296
  type: "set",
1209
1297
  key: "value",
1210
1298
  newValue: newVal
1211
- });
1212
- }
1299
+ }
1300
+ );
1213
1301
  }
1214
1302
  }
1215
1303
  function isRef(r) {
@@ -1245,12 +1333,12 @@ class RefImpl {
1245
1333
  if (hasChanged(newVal, this._rawValue)) {
1246
1334
  this._rawValue = newVal;
1247
1335
  this._value = useDirectValue ? newVal : toReactive(newVal);
1248
- triggerRefValue(this, newVal);
1336
+ triggerRefValue(this, 3, newVal);
1249
1337
  }
1250
1338
  }
1251
1339
  }
1252
1340
  function triggerRef(ref2) {
1253
- triggerRefValue(ref2, ref2.value );
1341
+ triggerRefValue(ref2, 3, ref2.value );
1254
1342
  }
1255
1343
  function unref(ref2) {
1256
1344
  return isRef(ref2) ? ref2.value : ref2;
@@ -1348,57 +1436,6 @@ function propertyToRef(source, key, defaultValue) {
1348
1436
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1349
1437
  }
1350
1438
 
1351
- class ComputedRefImpl {
1352
- constructor(getter, _setter, isReadonly, isSSR) {
1353
- this._setter = _setter;
1354
- this.dep = void 0;
1355
- this.__v_isRef = true;
1356
- this["__v_isReadonly"] = false;
1357
- this._dirty = true;
1358
- this.effect = new ReactiveEffect(getter, () => {
1359
- if (!this._dirty) {
1360
- this._dirty = true;
1361
- triggerRefValue(this);
1362
- }
1363
- });
1364
- this.effect.computed = this;
1365
- this.effect.active = this._cacheable = !isSSR;
1366
- this["__v_isReadonly"] = isReadonly;
1367
- }
1368
- get value() {
1369
- const self = toRaw(this);
1370
- trackRefValue(self);
1371
- if (self._dirty || !self._cacheable) {
1372
- self._dirty = false;
1373
- self._value = self.effect.run();
1374
- }
1375
- return self._value;
1376
- }
1377
- set value(newValue) {
1378
- this._setter(newValue);
1379
- }
1380
- }
1381
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1382
- let getter;
1383
- let setter;
1384
- const onlyGetter = isFunction(getterOrOptions);
1385
- if (onlyGetter) {
1386
- getter = getterOrOptions;
1387
- setter = () => {
1388
- console.warn("Write operation failed: computed value is readonly");
1389
- } ;
1390
- } else {
1391
- getter = getterOrOptions.get;
1392
- setter = getterOrOptions.set;
1393
- }
1394
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1395
- if (debugOptions && !isSSR) {
1396
- cRef.effect.onTrack = debugOptions.onTrack;
1397
- cRef.effect.onTrigger = debugOptions.onTrigger;
1398
- }
1399
- return cRef;
1400
- }
1401
-
1402
1439
  const stack = [];
1403
1440
  function pushWarningContext(vnode) {
1404
1441
  stack.push(vnode);
@@ -1513,7 +1550,7 @@ function assertNumber(val, type) {
1513
1550
  }
1514
1551
  }
1515
1552
 
1516
- const ErrorTypeStrings = {
1553
+ const ErrorTypeStrings$1 = {
1517
1554
  ["sp"]: "serverPrefetch hook",
1518
1555
  ["bc"]: "beforeCreate hook",
1519
1556
  ["c"]: "created hook",
@@ -1574,7 +1611,7 @@ function handleError(err, instance, type, throwInDev = true) {
1574
1611
  if (instance) {
1575
1612
  let cur = instance.parent;
1576
1613
  const exposedInstance = instance.proxy;
1577
- const errorInfo = ErrorTypeStrings[type] ;
1614
+ const errorInfo = ErrorTypeStrings$1[type] ;
1578
1615
  while (cur) {
1579
1616
  const errorCapturedHooks = cur.ec;
1580
1617
  if (errorCapturedHooks) {
@@ -1601,7 +1638,7 @@ function handleError(err, instance, type, throwInDev = true) {
1601
1638
  }
1602
1639
  function logError(err, type, contextVNode, throwInDev = true) {
1603
1640
  {
1604
- const info = ErrorTypeStrings[type];
1641
+ const info = ErrorTypeStrings$1[type];
1605
1642
  if (contextVNode) {
1606
1643
  pushWarningContext(contextVNode);
1607
1644
  }
@@ -1636,8 +1673,13 @@ function findInsertionIndex(id) {
1636
1673
  let end = queue.length;
1637
1674
  while (start < end) {
1638
1675
  const middle = start + end >>> 1;
1639
- const middleJobId = getId(queue[middle]);
1640
- middleJobId < id ? start = middle + 1 : end = middle;
1676
+ const middleJob = queue[middle];
1677
+ const middleJobId = getId(middleJob);
1678
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1679
+ start = middle + 1;
1680
+ } else {
1681
+ end = middle;
1682
+ }
1641
1683
  }
1642
1684
  return start;
1643
1685
  }
@@ -1824,6 +1866,7 @@ function rerender(id, newRender) {
1824
1866
  }
1825
1867
  instance.renderCache = [];
1826
1868
  isHmrUpdating = true;
1869
+ instance.effect.dirty = true;
1827
1870
  instance.update();
1828
1871
  isHmrUpdating = false;
1829
1872
  });
@@ -1851,6 +1894,7 @@ function reload(id, newComp) {
1851
1894
  instance.ceReload(newComp.styles);
1852
1895
  hmrDirtyComponents.delete(oldComp);
1853
1896
  } else if (instance.parent) {
1897
+ instance.parent.effect.dirty = true;
1854
1898
  queueJob(instance.parent.update);
1855
1899
  } else if (instance.appContext.reload) {
1856
1900
  instance.appContext.reload();
@@ -3225,14 +3269,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3225
3269
  parentComponent: parentComponent2,
3226
3270
  container: container2
3227
3271
  } = suspense;
3272
+ let delayEnter = false;
3228
3273
  if (suspense.isHydrating) {
3229
3274
  suspense.isHydrating = false;
3230
3275
  } else if (!resume) {
3231
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3276
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3232
3277
  if (delayEnter) {
3233
3278
  activeBranch.transition.afterLeave = () => {
3234
3279
  if (pendingId === suspense.pendingId) {
3235
3280
  move(pendingBranch, container2, anchor2, 0);
3281
+ queuePostFlushCb(effects);
3236
3282
  }
3237
3283
  };
3238
3284
  }
@@ -3258,7 +3304,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3258
3304
  }
3259
3305
  parent = parent.parent;
3260
3306
  }
3261
- if (!hasUnresolvedAncestor) {
3307
+ if (!hasUnresolvedAncestor && !delayEnter) {
3262
3308
  queuePostFlushCb(effects);
3263
3309
  }
3264
3310
  suspense.effects = [];
@@ -3544,8 +3590,15 @@ function watch(source, cb, options) {
3544
3590
  }
3545
3591
  return doWatch(source, cb, options);
3546
3592
  }
3547
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3593
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3548
3594
  var _a;
3595
+ if (cb && once) {
3596
+ const _cb = cb;
3597
+ cb = (...args) => {
3598
+ _cb(...args);
3599
+ unwatch();
3600
+ };
3601
+ }
3549
3602
  if (!cb) {
3550
3603
  if (immediate !== void 0) {
3551
3604
  warn(
@@ -3557,6 +3610,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3557
3610
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3558
3611
  );
3559
3612
  }
3613
+ if (once !== void 0) {
3614
+ warn(
3615
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3616
+ );
3617
+ }
3560
3618
  }
3561
3619
  const warnInvalidSource = (s) => {
3562
3620
  warn(
@@ -3634,7 +3692,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3634
3692
  };
3635
3693
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3636
3694
  const job = () => {
3637
- if (!effect.active) {
3695
+ if (!effect.active || !effect.dirty) {
3638
3696
  return;
3639
3697
  }
3640
3698
  if (cb) {
@@ -3667,7 +3725,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3667
3725
  job.id = instance.uid;
3668
3726
  scheduler = () => queueJob(job);
3669
3727
  }
3670
- const effect = new ReactiveEffect(getter, scheduler);
3728
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3729
+ const unwatch = () => {
3730
+ effect.stop();
3731
+ if (instance && instance.scope) {
3732
+ remove(instance.scope.effects, effect);
3733
+ }
3734
+ };
3671
3735
  {
3672
3736
  effect.onTrack = onTrack;
3673
3737
  effect.onTrigger = onTrigger;
@@ -3686,12 +3750,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3686
3750
  } else {
3687
3751
  effect.run();
3688
3752
  }
3689
- const unwatch = () => {
3690
- effect.stop();
3691
- if (instance && instance.scope) {
3692
- remove(instance.scope.effects, effect);
3693
- }
3694
- };
3695
3753
  return unwatch;
3696
3754
  }
3697
3755
  function instanceWatch(source, value, options) {
@@ -3924,6 +3982,7 @@ const BaseTransitionImpl = {
3924
3982
  leavingHooks.afterLeave = () => {
3925
3983
  state.isLeaving = false;
3926
3984
  if (instance.update.active !== false) {
3985
+ instance.effect.dirty = true;
3927
3986
  instance.update();
3928
3987
  }
3929
3988
  };
@@ -4262,6 +4321,7 @@ function defineAsyncComponent(source) {
4262
4321
  load().then(() => {
4263
4322
  loaded.value = true;
4264
4323
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4324
+ instance.parent.effect.dirty = true;
4265
4325
  queueJob(instance.parent.update);
4266
4326
  }
4267
4327
  }).catch((err) => {
@@ -4559,7 +4619,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4559
4619
  }
4560
4620
  return wrappedHook;
4561
4621
  } else {
4562
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4622
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4563
4623
  warn(
4564
4624
  `${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.` )
4565
4625
  );
@@ -5281,7 +5341,10 @@ const publicPropertiesMap = (
5281
5341
  $root: (i) => getPublicInstance(i.root),
5282
5342
  $emit: (i) => i.emit,
5283
5343
  $options: (i) => resolveMergedOptions(i) ,
5284
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5344
+ $forceUpdate: (i) => i.f || (i.f = () => {
5345
+ i.effect.dirty = true;
5346
+ queueJob(i.update);
5347
+ }),
5285
5348
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5286
5349
  $watch: (i) => instanceWatch.bind(i)
5287
5350
  })
@@ -6182,7 +6245,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6182
6245
  return vm;
6183
6246
  }
6184
6247
  }
6185
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
6248
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6186
6249
  Vue.config = singletonApp.config;
6187
6250
  Vue.use = (p, ...options) => {
6188
6251
  if (p && isFunction(p.install)) {
@@ -7512,7 +7575,14 @@ function createHydrationFunctions(rendererInternals) {
7512
7575
  break;
7513
7576
  case Comment:
7514
7577
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7515
- nextNode = onMismatch();
7578
+ if (node.tagName.toLowerCase() === "template") {
7579
+ const content = vnode.el.content.firstChild;
7580
+ replaceNode(content, node, parentComponent);
7581
+ vnode.el = node = content;
7582
+ nextNode = nextSibling(node);
7583
+ } else {
7584
+ nextNode = onMismatch();
7585
+ }
7516
7586
  } else {
7517
7587
  nextNode = nextSibling(node);
7518
7588
  }
@@ -7554,7 +7624,7 @@ function createHydrationFunctions(rendererInternals) {
7554
7624
  break;
7555
7625
  default:
7556
7626
  if (shapeFlag & 1) {
7557
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
7627
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
7558
7628
  nextNode = onMismatch();
7559
7629
  } else {
7560
7630
  nextNode = hydrateElement(
@@ -7569,6 +7639,13 @@ function createHydrationFunctions(rendererInternals) {
7569
7639
  } else if (shapeFlag & 6) {
7570
7640
  vnode.slotScopeIds = slotScopeIds;
7571
7641
  const container = parentNode(node);
7642
+ if (isFragmentStart) {
7643
+ nextNode = locateClosingAnchor(node);
7644
+ } else if (isComment(node) && node.data === "teleport start") {
7645
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
7646
+ } else {
7647
+ nextNode = nextSibling(node);
7648
+ }
7572
7649
  mountComponent(
7573
7650
  vnode,
7574
7651
  container,
@@ -7578,10 +7655,6 @@ function createHydrationFunctions(rendererInternals) {
7578
7655
  isSVGContainer(container),
7579
7656
  optimized
7580
7657
  );
7581
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
7582
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
7583
- nextNode = nextSibling(nextNode);
7584
- }
7585
7658
  if (isAsyncWrapper(vnode)) {
7586
7659
  let subTree;
7587
7660
  if (isFragmentStart) {
@@ -7631,7 +7704,7 @@ function createHydrationFunctions(rendererInternals) {
7631
7704
  };
7632
7705
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7633
7706
  optimized = optimized || !!vnode.dynamicChildren;
7634
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
7707
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7635
7708
  const forcePatchValue = type === "input" && dirs || type === "option";
7636
7709
  {
7637
7710
  if (dirs) {
@@ -7668,12 +7741,23 @@ function createHydrationFunctions(rendererInternals) {
7668
7741
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
7669
7742
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7670
7743
  }
7744
+ let needCallTransitionHooks = false;
7745
+ if (isTemplateNode(el)) {
7746
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
7747
+ const content = el.content.firstChild;
7748
+ if (needCallTransitionHooks) {
7749
+ transition.beforeEnter(content);
7750
+ }
7751
+ replaceNode(content, el, parentComponent);
7752
+ vnode.el = el = content;
7753
+ }
7671
7754
  if (dirs) {
7672
7755
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7673
7756
  }
7674
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
7757
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
7675
7758
  queueEffectWithSuspense(() => {
7676
7759
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7760
+ needCallTransitionHooks && transition.enter(el);
7677
7761
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7678
7762
  }, parentSuspense);
7679
7763
  }
@@ -7791,7 +7875,7 @@ function createHydrationFunctions(rendererInternals) {
7791
7875
  );
7792
7876
  vnode.el = null;
7793
7877
  if (isFragment) {
7794
- const end = locateClosingAsyncAnchor(node);
7878
+ const end = locateClosingAnchor(node);
7795
7879
  while (true) {
7796
7880
  const next2 = nextSibling(node);
7797
7881
  if (next2 && next2 !== end) {
@@ -7816,14 +7900,14 @@ function createHydrationFunctions(rendererInternals) {
7816
7900
  );
7817
7901
  return next;
7818
7902
  };
7819
- const locateClosingAsyncAnchor = (node) => {
7903
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
7820
7904
  let match = 0;
7821
7905
  while (node) {
7822
7906
  node = nextSibling(node);
7823
7907
  if (node && isComment(node)) {
7824
- if (node.data === "[")
7908
+ if (node.data === open)
7825
7909
  match++;
7826
- if (node.data === "]") {
7910
+ if (node.data === close) {
7827
7911
  if (match === 0) {
7828
7912
  return nextSibling(node);
7829
7913
  } else {
@@ -7834,6 +7918,23 @@ function createHydrationFunctions(rendererInternals) {
7834
7918
  }
7835
7919
  return node;
7836
7920
  };
7921
+ const replaceNode = (newNode, oldNode, parentComponent) => {
7922
+ const parentNode2 = oldNode.parentNode;
7923
+ if (parentNode2) {
7924
+ parentNode2.replaceChild(newNode, oldNode);
7925
+ }
7926
+ let parent = parentComponent;
7927
+ while (parent) {
7928
+ if (parent.vnode.el === oldNode) {
7929
+ parent.vnode.el = newNode;
7930
+ parent.subTree.el = newNode;
7931
+ }
7932
+ parent = parent.parent;
7933
+ }
7934
+ };
7935
+ const isTemplateNode = (node) => {
7936
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
7937
+ };
7837
7938
  return [hydrate, hydrateNode];
7838
7939
  }
7839
7940
 
@@ -8161,7 +8262,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8161
8262
  if (dirs) {
8162
8263
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
8163
8264
  }
8164
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8265
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
8165
8266
  if (needCallTransitionHooks) {
8166
8267
  transition.beforeEnter(el);
8167
8268
  }
@@ -8550,6 +8651,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8550
8651
  } else {
8551
8652
  instance.next = n2;
8552
8653
  invalidateJob(instance.update);
8654
+ instance.effect.dirty = true;
8553
8655
  instance.update();
8554
8656
  }
8555
8657
  } else {
@@ -8743,11 +8845,16 @@ function baseCreateRenderer(options, createHydrationFns) {
8743
8845
  };
8744
8846
  const effect = instance.effect = new ReactiveEffect(
8745
8847
  componentUpdateFn,
8848
+ NOOP,
8746
8849
  () => queueJob(update),
8747
8850
  instance.scope
8748
8851
  // track it in component's effect scope
8749
8852
  );
8750
- const update = instance.update = () => effect.run();
8853
+ const update = instance.update = () => {
8854
+ if (effect.dirty) {
8855
+ effect.run();
8856
+ }
8857
+ };
8751
8858
  update.id = instance.uid;
8752
8859
  toggleRecurse(instance, true);
8753
8860
  {
@@ -9078,8 +9185,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9078
9185
  moveStaticNode(vnode, container, anchor);
9079
9186
  return;
9080
9187
  }
9081
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
9082
- if (needTransition) {
9188
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
9189
+ if (needTransition2) {
9083
9190
  if (moveType === 0) {
9084
9191
  transition.beforeEnter(el);
9085
9192
  hostInsert(el, container, anchor);
@@ -9308,6 +9415,9 @@ function baseCreateRenderer(options, createHydrationFns) {
9308
9415
  function toggleRecurse({ effect, update }, allowed) {
9309
9416
  effect.allowRecurse = update.allowRecurse = allowed;
9310
9417
  }
9418
+ function needTransition(parentSuspense, transition) {
9419
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
9420
+ }
9311
9421
  function traverseStaticChildren(n1, n2, shallow = false) {
9312
9422
  const ch1 = n1.children;
9313
9423
  const ch2 = n2.children;
@@ -10716,7 +10826,8 @@ function isMemoSame(cached, memo) {
10716
10826
  return true;
10717
10827
  }
10718
10828
 
10719
- const version = "3.3.6";
10829
+ const version = "3.4.0-alpha.1";
10830
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10720
10831
  const ssrUtils = null;
10721
10832
  const resolveFilter = resolveFilter$1 ;
10722
10833
  const _compatUtils = {
@@ -12352,6 +12463,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12352
12463
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12353
12464
  Comment: Comment,
12354
12465
  EffectScope: EffectScope,
12466
+ ErrorTypeStrings: ErrorTypeStrings,
12355
12467
  Fragment: Fragment,
12356
12468
  KeepAlive: KeepAlive,
12357
12469
  ReactiveEffect: ReactiveEffect,
@@ -12548,4 +12660,4 @@ var Vue$1 = Vue;
12548
12660
 
12549
12661
  const { configureCompat } = Vue$1;
12550
12662
 
12551
- export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue$1 as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useModel, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
12663
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, ErrorTypeStrings, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue$1 as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useModel, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };