@vue/runtime-dom 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.
@@ -357,117 +357,120 @@ var VueRuntimeDOM = (function (exports) {
357
357
  }
358
358
  }
359
359
 
360
- const createDep = (effects) => {
361
- const dep = new Set(effects);
362
- dep.w = 0;
363
- dep.n = 0;
364
- return dep;
365
- };
366
- const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
367
- const newTracked = (dep) => (dep.n & trackOpBit) > 0;
368
- const initDepMarkers = ({ deps }) => {
369
- if (deps.length) {
370
- for (let i = 0; i < deps.length; i++) {
371
- deps[i].w |= trackOpBit;
372
- }
373
- }
374
- };
375
- const finalizeDepMarkers = (effect) => {
376
- const { deps } = effect;
377
- if (deps.length) {
378
- let ptr = 0;
379
- for (let i = 0; i < deps.length; i++) {
380
- const dep = deps[i];
381
- if (wasTracked(dep) && !newTracked(dep)) {
382
- dep.delete(effect);
383
- } else {
384
- deps[ptr++] = dep;
385
- }
386
- dep.w &= ~trackOpBit;
387
- dep.n &= ~trackOpBit;
388
- }
389
- deps.length = ptr;
390
- }
391
- };
392
-
393
- const targetMap = /* @__PURE__ */ new WeakMap();
394
- let effectTrackDepth = 0;
395
- let trackOpBit = 1;
396
- const maxMarkerBits = 30;
397
360
  let activeEffect;
398
- const ITERATE_KEY = Symbol("iterate" );
399
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
400
361
  class ReactiveEffect {
401
- constructor(fn, scheduler = null, scope) {
362
+ constructor(fn, trigger, scheduler, scope) {
402
363
  this.fn = fn;
364
+ this.trigger = trigger;
403
365
  this.scheduler = scheduler;
404
366
  this.active = true;
405
367
  this.deps = [];
406
- this.parent = void 0;
368
+ /**
369
+ * @internal
370
+ */
371
+ this._dirtyLevel = 3;
372
+ /**
373
+ * @internal
374
+ */
375
+ this._trackId = 0;
376
+ /**
377
+ * @internal
378
+ */
379
+ this._runnings = 0;
380
+ /**
381
+ * @internal
382
+ */
383
+ this._queryings = 0;
384
+ /**
385
+ * @internal
386
+ */
387
+ this._depsLength = 0;
407
388
  recordEffectScope(this, scope);
408
389
  }
390
+ get dirty() {
391
+ if (this._dirtyLevel === 1) {
392
+ this._dirtyLevel = 0;
393
+ this._queryings++;
394
+ pauseTracking();
395
+ for (const dep of this.deps) {
396
+ if (dep.computed) {
397
+ triggerComputed(dep.computed);
398
+ if (this._dirtyLevel >= 2) {
399
+ break;
400
+ }
401
+ }
402
+ }
403
+ resetTracking();
404
+ this._queryings--;
405
+ }
406
+ return this._dirtyLevel >= 2;
407
+ }
408
+ set dirty(v) {
409
+ this._dirtyLevel = v ? 3 : 0;
410
+ }
409
411
  run() {
412
+ this._dirtyLevel = 0;
410
413
  if (!this.active) {
411
414
  return this.fn();
412
415
  }
413
- let parent = activeEffect;
414
416
  let lastShouldTrack = shouldTrack;
415
- while (parent) {
416
- if (parent === this) {
417
- return;
418
- }
419
- parent = parent.parent;
420
- }
417
+ let lastEffect = activeEffect;
421
418
  try {
422
- this.parent = activeEffect;
423
- activeEffect = this;
424
419
  shouldTrack = true;
425
- trackOpBit = 1 << ++effectTrackDepth;
426
- if (effectTrackDepth <= maxMarkerBits) {
427
- initDepMarkers(this);
428
- } else {
429
- cleanupEffect(this);
430
- }
420
+ activeEffect = this;
421
+ this._runnings++;
422
+ preCleanupEffect(this);
431
423
  return this.fn();
432
424
  } finally {
433
- if (effectTrackDepth <= maxMarkerBits) {
434
- finalizeDepMarkers(this);
435
- }
436
- trackOpBit = 1 << --effectTrackDepth;
437
- activeEffect = this.parent;
425
+ postCleanupEffect(this);
426
+ this._runnings--;
427
+ activeEffect = lastEffect;
438
428
  shouldTrack = lastShouldTrack;
439
- this.parent = void 0;
440
- if (this.deferStop) {
441
- this.stop();
442
- }
443
429
  }
444
430
  }
445
431
  stop() {
446
- if (activeEffect === this) {
447
- this.deferStop = true;
448
- } else if (this.active) {
449
- cleanupEffect(this);
450
- if (this.onStop) {
451
- this.onStop();
452
- }
432
+ var _a;
433
+ if (this.active) {
434
+ preCleanupEffect(this);
435
+ postCleanupEffect(this);
436
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
453
437
  this.active = false;
454
438
  }
455
439
  }
456
440
  }
457
- function cleanupEffect(effect2) {
458
- const { deps } = effect2;
459
- if (deps.length) {
460
- for (let i = 0; i < deps.length; i++) {
461
- deps[i].delete(effect2);
441
+ function triggerComputed(computed) {
442
+ return computed.value;
443
+ }
444
+ function preCleanupEffect(effect2) {
445
+ effect2._trackId++;
446
+ effect2._depsLength = 0;
447
+ }
448
+ function postCleanupEffect(effect2) {
449
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
450
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
451
+ cleanupDepEffect(effect2.deps[i], effect2);
452
+ }
453
+ effect2.deps.length = effect2._depsLength;
454
+ }
455
+ }
456
+ function cleanupDepEffect(dep, effect2) {
457
+ const trackId = dep.get(effect2);
458
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
459
+ dep.delete(effect2);
460
+ if (dep.size === 0) {
461
+ dep.cleanup();
462
462
  }
463
- deps.length = 0;
464
463
  }
465
464
  }
466
465
  function effect(fn, options) {
467
466
  if (fn.effect instanceof ReactiveEffect) {
468
467
  fn = fn.effect.fn;
469
468
  }
470
- const _effect = new ReactiveEffect(fn);
469
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
470
+ if (_effect.dirty) {
471
+ _effect.run();
472
+ }
473
+ });
471
474
  if (options) {
472
475
  extend(_effect, options);
473
476
  if (options.scope)
@@ -484,6 +487,7 @@ var VueRuntimeDOM = (function (exports) {
484
487
  runner.effect.stop();
485
488
  }
486
489
  let shouldTrack = true;
490
+ let pauseScheduleStack = 0;
487
491
  const trackStack = [];
488
492
  function pauseTracking() {
489
493
  trackStack.push(shouldTrack);
@@ -493,6 +497,68 @@ var VueRuntimeDOM = (function (exports) {
493
497
  const last = trackStack.pop();
494
498
  shouldTrack = last === void 0 ? true : last;
495
499
  }
500
+ function pauseScheduling() {
501
+ pauseScheduleStack++;
502
+ }
503
+ function resetScheduling() {
504
+ pauseScheduleStack--;
505
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
506
+ queueEffectSchedulers.shift()();
507
+ }
508
+ }
509
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
510
+ var _a;
511
+ if (dep.get(effect2) !== effect2._trackId) {
512
+ dep.set(effect2, effect2._trackId);
513
+ const oldDep = effect2.deps[effect2._depsLength];
514
+ if (oldDep !== dep) {
515
+ if (oldDep) {
516
+ cleanupDepEffect(oldDep, effect2);
517
+ }
518
+ effect2.deps[effect2._depsLength++] = dep;
519
+ } else {
520
+ effect2._depsLength++;
521
+ }
522
+ {
523
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
524
+ }
525
+ }
526
+ }
527
+ const queueEffectSchedulers = [];
528
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
529
+ var _a;
530
+ pauseScheduling();
531
+ for (const effect2 of dep.keys()) {
532
+ if (!effect2.allowRecurse && effect2._runnings) {
533
+ continue;
534
+ }
535
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
536
+ const lastDirtyLevel = effect2._dirtyLevel;
537
+ effect2._dirtyLevel = dirtyLevel;
538
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
539
+ {
540
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
541
+ }
542
+ effect2.trigger();
543
+ if (effect2.scheduler) {
544
+ queueEffectSchedulers.push(effect2.scheduler);
545
+ }
546
+ }
547
+ }
548
+ }
549
+ resetScheduling();
550
+ }
551
+
552
+ const createDep = (cleanup, computed) => {
553
+ const dep = /* @__PURE__ */ new Map();
554
+ dep.cleanup = cleanup;
555
+ dep.computed = computed;
556
+ return dep;
557
+ };
558
+
559
+ const targetMap = /* @__PURE__ */ new WeakMap();
560
+ const ITERATE_KEY = Symbol("iterate" );
561
+ const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
496
562
  function track(target, type, key) {
497
563
  if (shouldTrack && activeEffect) {
498
564
  let depsMap = targetMap.get(target);
@@ -501,35 +567,17 @@ var VueRuntimeDOM = (function (exports) {
501
567
  }
502
568
  let dep = depsMap.get(key);
503
569
  if (!dep) {
504
- depsMap.set(key, dep = createDep());
505
- }
506
- const eventInfo = { effect: activeEffect, target, type, key } ;
507
- trackEffects(dep, eventInfo);
508
- }
509
- }
510
- function trackEffects(dep, debuggerEventExtraInfo) {
511
- let shouldTrack2 = false;
512
- if (effectTrackDepth <= maxMarkerBits) {
513
- if (!newTracked(dep)) {
514
- dep.n |= trackOpBit;
515
- shouldTrack2 = !wasTracked(dep);
516
- }
517
- } else {
518
- shouldTrack2 = !dep.has(activeEffect);
519
- }
520
- if (shouldTrack2) {
521
- dep.add(activeEffect);
522
- activeEffect.deps.push(dep);
523
- if (activeEffect.onTrack) {
524
- activeEffect.onTrack(
525
- extend(
526
- {
527
- effect: activeEffect
528
- },
529
- debuggerEventExtraInfo
530
- )
531
- );
570
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
532
571
  }
572
+ trackEffect(
573
+ activeEffect,
574
+ dep,
575
+ {
576
+ target,
577
+ type,
578
+ key
579
+ }
580
+ );
533
581
  }
534
582
  }
535
583
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -543,7 +591,7 @@ var VueRuntimeDOM = (function (exports) {
543
591
  } else if (key === "length" && isArray(target)) {
544
592
  const newLength = Number(newValue);
545
593
  depsMap.forEach((dep, key2) => {
546
- if (key2 === "length" || key2 >= newLength) {
594
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
547
595
  deps.push(dep);
548
596
  }
549
597
  });
@@ -577,49 +625,24 @@ var VueRuntimeDOM = (function (exports) {
577
625
  break;
578
626
  }
579
627
  }
580
- const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
581
- if (deps.length === 1) {
582
- if (deps[0]) {
583
- {
584
- triggerEffects(deps[0], eventInfo);
585
- }
586
- }
587
- } else {
588
- const effects = [];
589
- for (const dep of deps) {
590
- if (dep) {
591
- effects.push(...dep);
592
- }
593
- }
594
- {
595
- triggerEffects(createDep(effects), eventInfo);
596
- }
597
- }
598
- }
599
- function triggerEffects(dep, debuggerEventExtraInfo) {
600
- const effects = isArray(dep) ? dep : [...dep];
601
- for (const effect2 of effects) {
602
- if (effect2.computed) {
603
- triggerEffect(effect2, debuggerEventExtraInfo);
604
- }
605
- }
606
- for (const effect2 of effects) {
607
- if (!effect2.computed) {
608
- triggerEffect(effect2, debuggerEventExtraInfo);
609
- }
610
- }
611
- }
612
- function triggerEffect(effect2, debuggerEventExtraInfo) {
613
- if (effect2 !== activeEffect || effect2.allowRecurse) {
614
- if (effect2.onTrigger) {
615
- effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
616
- }
617
- if (effect2.scheduler) {
618
- effect2.scheduler();
619
- } else {
620
- effect2.run();
628
+ pauseScheduling();
629
+ for (const dep of deps) {
630
+ if (dep) {
631
+ triggerEffects(
632
+ dep,
633
+ 3,
634
+ {
635
+ target,
636
+ type,
637
+ key,
638
+ newValue,
639
+ oldValue,
640
+ oldTarget
641
+ }
642
+ );
621
643
  }
622
644
  }
645
+ resetScheduling();
623
646
  }
624
647
  function getDepFromReactive(object, key) {
625
648
  var _a;
@@ -650,7 +673,9 @@ var VueRuntimeDOM = (function (exports) {
650
673
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
651
674
  instrumentations[key] = function(...args) {
652
675
  pauseTracking();
676
+ pauseScheduling();
653
677
  const res = toRaw(this)[key].apply(this, args);
678
+ resetScheduling();
654
679
  resetTracking();
655
680
  return res;
656
681
  };
@@ -1189,30 +1214,93 @@ var VueRuntimeDOM = (function (exports) {
1189
1214
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1190
1215
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1191
1216
 
1217
+ class ComputedRefImpl {
1218
+ constructor(getter, _setter, isReadonly, isSSR) {
1219
+ this._setter = _setter;
1220
+ this.dep = void 0;
1221
+ this.__v_isRef = true;
1222
+ this["__v_isReadonly"] = false;
1223
+ this.effect = new ReactiveEffect(getter, () => {
1224
+ triggerRefValue(this, 1);
1225
+ });
1226
+ this.effect.computed = this;
1227
+ this.effect.active = this._cacheable = !isSSR;
1228
+ this["__v_isReadonly"] = isReadonly;
1229
+ }
1230
+ get value() {
1231
+ const self = toRaw(this);
1232
+ trackRefValue(self);
1233
+ if (!self._cacheable || self.effect.dirty) {
1234
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1235
+ triggerRefValue(self, 2);
1236
+ }
1237
+ }
1238
+ return self._value;
1239
+ }
1240
+ set value(newValue) {
1241
+ this._setter(newValue);
1242
+ }
1243
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1244
+ get _dirty() {
1245
+ return this.effect.dirty;
1246
+ }
1247
+ set _dirty(v) {
1248
+ this.effect.dirty = v;
1249
+ }
1250
+ // #endregion
1251
+ }
1252
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1253
+ let getter;
1254
+ let setter;
1255
+ const onlyGetter = isFunction(getterOrOptions);
1256
+ if (onlyGetter) {
1257
+ getter = getterOrOptions;
1258
+ setter = () => {
1259
+ console.warn("Write operation failed: computed value is readonly");
1260
+ } ;
1261
+ } else {
1262
+ getter = getterOrOptions.get;
1263
+ setter = getterOrOptions.set;
1264
+ }
1265
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1266
+ if (debugOptions && !isSSR) {
1267
+ cRef.effect.onTrack = debugOptions.onTrack;
1268
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1269
+ }
1270
+ return cRef;
1271
+ }
1272
+
1192
1273
  function trackRefValue(ref2) {
1193
1274
  if (shouldTrack && activeEffect) {
1194
1275
  ref2 = toRaw(ref2);
1195
- {
1196
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1276
+ trackEffect(
1277
+ activeEffect,
1278
+ ref2.dep || (ref2.dep = createDep(
1279
+ () => ref2.dep = void 0,
1280
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1281
+ )),
1282
+ {
1197
1283
  target: ref2,
1198
1284
  type: "get",
1199
1285
  key: "value"
1200
- });
1201
- }
1286
+ }
1287
+ );
1202
1288
  }
1203
1289
  }
1204
- function triggerRefValue(ref2, newVal) {
1290
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1205
1291
  ref2 = toRaw(ref2);
1206
1292
  const dep = ref2.dep;
1207
1293
  if (dep) {
1208
- {
1209
- triggerEffects(dep, {
1294
+ triggerEffects(
1295
+ dep,
1296
+ dirtyLevel,
1297
+ {
1210
1298
  target: ref2,
1211
1299
  type: "set",
1212
1300
  key: "value",
1213
1301
  newValue: newVal
1214
- });
1215
- }
1302
+ }
1303
+ );
1216
1304
  }
1217
1305
  }
1218
1306
  function isRef(r) {
@@ -1248,12 +1336,12 @@ var VueRuntimeDOM = (function (exports) {
1248
1336
  if (hasChanged(newVal, this._rawValue)) {
1249
1337
  this._rawValue = newVal;
1250
1338
  this._value = useDirectValue ? newVal : toReactive(newVal);
1251
- triggerRefValue(this, newVal);
1339
+ triggerRefValue(this, 3, newVal);
1252
1340
  }
1253
1341
  }
1254
1342
  }
1255
1343
  function triggerRef(ref2) {
1256
- triggerRefValue(ref2, ref2.value );
1344
+ triggerRefValue(ref2, 3, ref2.value );
1257
1345
  }
1258
1346
  function unref(ref2) {
1259
1347
  return isRef(ref2) ? ref2.value : ref2;
@@ -1351,57 +1439,6 @@ var VueRuntimeDOM = (function (exports) {
1351
1439
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1352
1440
  }
1353
1441
 
1354
- class ComputedRefImpl {
1355
- constructor(getter, _setter, isReadonly, isSSR) {
1356
- this._setter = _setter;
1357
- this.dep = void 0;
1358
- this.__v_isRef = true;
1359
- this["__v_isReadonly"] = false;
1360
- this._dirty = true;
1361
- this.effect = new ReactiveEffect(getter, () => {
1362
- if (!this._dirty) {
1363
- this._dirty = true;
1364
- triggerRefValue(this);
1365
- }
1366
- });
1367
- this.effect.computed = this;
1368
- this.effect.active = this._cacheable = !isSSR;
1369
- this["__v_isReadonly"] = isReadonly;
1370
- }
1371
- get value() {
1372
- const self = toRaw(this);
1373
- trackRefValue(self);
1374
- if (self._dirty || !self._cacheable) {
1375
- self._dirty = false;
1376
- self._value = self.effect.run();
1377
- }
1378
- return self._value;
1379
- }
1380
- set value(newValue) {
1381
- this._setter(newValue);
1382
- }
1383
- }
1384
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1385
- let getter;
1386
- let setter;
1387
- const onlyGetter = isFunction(getterOrOptions);
1388
- if (onlyGetter) {
1389
- getter = getterOrOptions;
1390
- setter = () => {
1391
- console.warn("Write operation failed: computed value is readonly");
1392
- } ;
1393
- } else {
1394
- getter = getterOrOptions.get;
1395
- setter = getterOrOptions.set;
1396
- }
1397
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1398
- if (debugOptions && !isSSR) {
1399
- cRef.effect.onTrack = debugOptions.onTrack;
1400
- cRef.effect.onTrigger = debugOptions.onTrigger;
1401
- }
1402
- return cRef;
1403
- }
1404
-
1405
1442
  const stack = [];
1406
1443
  function pushWarningContext(vnode) {
1407
1444
  stack.push(vnode);
@@ -1516,7 +1553,7 @@ var VueRuntimeDOM = (function (exports) {
1516
1553
  }
1517
1554
  }
1518
1555
 
1519
- const ErrorTypeStrings = {
1556
+ const ErrorTypeStrings$1 = {
1520
1557
  ["sp"]: "serverPrefetch hook",
1521
1558
  ["bc"]: "beforeCreate hook",
1522
1559
  ["c"]: "created hook",
@@ -1577,7 +1614,7 @@ var VueRuntimeDOM = (function (exports) {
1577
1614
  if (instance) {
1578
1615
  let cur = instance.parent;
1579
1616
  const exposedInstance = instance.proxy;
1580
- const errorInfo = ErrorTypeStrings[type] ;
1617
+ const errorInfo = ErrorTypeStrings$1[type] ;
1581
1618
  while (cur) {
1582
1619
  const errorCapturedHooks = cur.ec;
1583
1620
  if (errorCapturedHooks) {
@@ -1604,7 +1641,7 @@ var VueRuntimeDOM = (function (exports) {
1604
1641
  }
1605
1642
  function logError(err, type, contextVNode, throwInDev = true) {
1606
1643
  {
1607
- const info = ErrorTypeStrings[type];
1644
+ const info = ErrorTypeStrings$1[type];
1608
1645
  if (contextVNode) {
1609
1646
  pushWarningContext(contextVNode);
1610
1647
  }
@@ -1639,8 +1676,13 @@ var VueRuntimeDOM = (function (exports) {
1639
1676
  let end = queue.length;
1640
1677
  while (start < end) {
1641
1678
  const middle = start + end >>> 1;
1642
- const middleJobId = getId(queue[middle]);
1643
- middleJobId < id ? start = middle + 1 : end = middle;
1679
+ const middleJob = queue[middle];
1680
+ const middleJobId = getId(middleJob);
1681
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1682
+ start = middle + 1;
1683
+ } else {
1684
+ end = middle;
1685
+ }
1644
1686
  }
1645
1687
  return start;
1646
1688
  }
@@ -1827,6 +1869,7 @@ var VueRuntimeDOM = (function (exports) {
1827
1869
  }
1828
1870
  instance.renderCache = [];
1829
1871
  isHmrUpdating = true;
1872
+ instance.effect.dirty = true;
1830
1873
  instance.update();
1831
1874
  isHmrUpdating = false;
1832
1875
  });
@@ -1854,6 +1897,7 @@ var VueRuntimeDOM = (function (exports) {
1854
1897
  instance.ceReload(newComp.styles);
1855
1898
  hmrDirtyComponents.delete(oldComp);
1856
1899
  } else if (instance.parent) {
1900
+ instance.parent.effect.dirty = true;
1857
1901
  queueJob(instance.parent.update);
1858
1902
  } else if (instance.appContext.reload) {
1859
1903
  instance.appContext.reload();
@@ -2755,14 +2799,16 @@ var VueRuntimeDOM = (function (exports) {
2755
2799
  parentComponent: parentComponent2,
2756
2800
  container: container2
2757
2801
  } = suspense;
2802
+ let delayEnter = false;
2758
2803
  if (suspense.isHydrating) {
2759
2804
  suspense.isHydrating = false;
2760
2805
  } else if (!resume) {
2761
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
2806
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
2762
2807
  if (delayEnter) {
2763
2808
  activeBranch.transition.afterLeave = () => {
2764
2809
  if (pendingId === suspense.pendingId) {
2765
2810
  move(pendingBranch, container2, anchor2, 0);
2811
+ queuePostFlushCb(effects);
2766
2812
  }
2767
2813
  };
2768
2814
  }
@@ -2788,7 +2834,7 @@ var VueRuntimeDOM = (function (exports) {
2788
2834
  }
2789
2835
  parent = parent.parent;
2790
2836
  }
2791
- if (!hasUnresolvedAncestor) {
2837
+ if (!hasUnresolvedAncestor && !delayEnter) {
2792
2838
  queuePostFlushCb(effects);
2793
2839
  }
2794
2840
  suspense.effects = [];
@@ -3036,8 +3082,15 @@ var VueRuntimeDOM = (function (exports) {
3036
3082
  }
3037
3083
  return doWatch(source, cb, options);
3038
3084
  }
3039
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3085
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3040
3086
  var _a;
3087
+ if (cb && once) {
3088
+ const _cb = cb;
3089
+ cb = (...args) => {
3090
+ _cb(...args);
3091
+ unwatch();
3092
+ };
3093
+ }
3041
3094
  if (!cb) {
3042
3095
  if (immediate !== void 0) {
3043
3096
  warn(
@@ -3049,6 +3102,11 @@ var VueRuntimeDOM = (function (exports) {
3049
3102
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3050
3103
  );
3051
3104
  }
3105
+ if (once !== void 0) {
3106
+ warn(
3107
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3108
+ );
3109
+ }
3052
3110
  }
3053
3111
  const warnInvalidSource = (s) => {
3054
3112
  warn(
@@ -3116,7 +3174,7 @@ var VueRuntimeDOM = (function (exports) {
3116
3174
  };
3117
3175
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3118
3176
  const job = () => {
3119
- if (!effect.active) {
3177
+ if (!effect.active || !effect.dirty) {
3120
3178
  return;
3121
3179
  }
3122
3180
  if (cb) {
@@ -3149,7 +3207,13 @@ var VueRuntimeDOM = (function (exports) {
3149
3207
  job.id = instance.uid;
3150
3208
  scheduler = () => queueJob(job);
3151
3209
  }
3152
- const effect = new ReactiveEffect(getter, scheduler);
3210
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3211
+ const unwatch = () => {
3212
+ effect.stop();
3213
+ if (instance && instance.scope) {
3214
+ remove(instance.scope.effects, effect);
3215
+ }
3216
+ };
3153
3217
  {
3154
3218
  effect.onTrack = onTrack;
3155
3219
  effect.onTrigger = onTrigger;
@@ -3168,12 +3232,6 @@ var VueRuntimeDOM = (function (exports) {
3168
3232
  } else {
3169
3233
  effect.run();
3170
3234
  }
3171
- const unwatch = () => {
3172
- effect.stop();
3173
- if (instance && instance.scope) {
3174
- remove(instance.scope.effects, effect);
3175
- }
3176
- };
3177
3235
  return unwatch;
3178
3236
  }
3179
3237
  function instanceWatch(source, value, options) {
@@ -3403,6 +3461,7 @@ var VueRuntimeDOM = (function (exports) {
3403
3461
  leavingHooks.afterLeave = () => {
3404
3462
  state.isLeaving = false;
3405
3463
  if (instance.update.active !== false) {
3464
+ instance.effect.dirty = true;
3406
3465
  instance.update();
3407
3466
  }
3408
3467
  };
@@ -3738,6 +3797,7 @@ var VueRuntimeDOM = (function (exports) {
3738
3797
  load().then(() => {
3739
3798
  loaded.value = true;
3740
3799
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
3800
+ instance.parent.effect.dirty = true;
3741
3801
  queueJob(instance.parent.update);
3742
3802
  }
3743
3803
  }).catch((err) => {
@@ -4032,7 +4092,7 @@ var VueRuntimeDOM = (function (exports) {
4032
4092
  }
4033
4093
  return wrappedHook;
4034
4094
  } else {
4035
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4095
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4036
4096
  warn(
4037
4097
  `${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.` )
4038
4098
  );
@@ -4254,7 +4314,10 @@ If this is a native custom element, make sure to exclude it from component resol
4254
4314
  $root: (i) => getPublicInstance(i.root),
4255
4315
  $emit: (i) => i.emit,
4256
4316
  $options: (i) => resolveMergedOptions(i) ,
4257
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
4317
+ $forceUpdate: (i) => i.f || (i.f = () => {
4318
+ i.effect.dirty = true;
4319
+ queueJob(i.update);
4320
+ }),
4258
4321
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
4259
4322
  $watch: (i) => instanceWatch.bind(i)
4260
4323
  })
@@ -5930,7 +5993,14 @@ If you want to remount the same app, move your app creation logic into a factory
5930
5993
  break;
5931
5994
  case Comment:
5932
5995
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
5933
- nextNode = onMismatch();
5996
+ if (node.tagName.toLowerCase() === "template") {
5997
+ const content = vnode.el.content.firstChild;
5998
+ replaceNode(content, node, parentComponent);
5999
+ vnode.el = node = content;
6000
+ nextNode = nextSibling(node);
6001
+ } else {
6002
+ nextNode = onMismatch();
6003
+ }
5934
6004
  } else {
5935
6005
  nextNode = nextSibling(node);
5936
6006
  }
@@ -5972,7 +6042,7 @@ If you want to remount the same app, move your app creation logic into a factory
5972
6042
  break;
5973
6043
  default:
5974
6044
  if (shapeFlag & 1) {
5975
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
6045
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
5976
6046
  nextNode = onMismatch();
5977
6047
  } else {
5978
6048
  nextNode = hydrateElement(
@@ -5987,6 +6057,13 @@ If you want to remount the same app, move your app creation logic into a factory
5987
6057
  } else if (shapeFlag & 6) {
5988
6058
  vnode.slotScopeIds = slotScopeIds;
5989
6059
  const container = parentNode(node);
6060
+ if (isFragmentStart) {
6061
+ nextNode = locateClosingAnchor(node);
6062
+ } else if (isComment(node) && node.data === "teleport start") {
6063
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
6064
+ } else {
6065
+ nextNode = nextSibling(node);
6066
+ }
5990
6067
  mountComponent(
5991
6068
  vnode,
5992
6069
  container,
@@ -5996,10 +6073,6 @@ If you want to remount the same app, move your app creation logic into a factory
5996
6073
  isSVGContainer(container),
5997
6074
  optimized
5998
6075
  );
5999
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
6000
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
6001
- nextNode = nextSibling(nextNode);
6002
- }
6003
6076
  if (isAsyncWrapper(vnode)) {
6004
6077
  let subTree;
6005
6078
  if (isFragmentStart) {
@@ -6049,7 +6122,7 @@ If you want to remount the same app, move your app creation logic into a factory
6049
6122
  };
6050
6123
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6051
6124
  optimized = optimized || !!vnode.dynamicChildren;
6052
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
6125
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6053
6126
  const forcePatchValue = type === "input" && dirs || type === "option";
6054
6127
  {
6055
6128
  if (dirs) {
@@ -6086,12 +6159,23 @@ If you want to remount the same app, move your app creation logic into a factory
6086
6159
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
6087
6160
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
6088
6161
  }
6162
+ let needCallTransitionHooks = false;
6163
+ if (isTemplateNode(el)) {
6164
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
6165
+ const content = el.content.firstChild;
6166
+ if (needCallTransitionHooks) {
6167
+ transition.beforeEnter(content);
6168
+ }
6169
+ replaceNode(content, el, parentComponent);
6170
+ vnode.el = el = content;
6171
+ }
6089
6172
  if (dirs) {
6090
6173
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
6091
6174
  }
6092
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
6175
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
6093
6176
  queueEffectWithSuspense(() => {
6094
6177
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
6178
+ needCallTransitionHooks && transition.enter(el);
6095
6179
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
6096
6180
  }, parentSuspense);
6097
6181
  }
@@ -6209,7 +6293,7 @@ If you want to remount the same app, move your app creation logic into a factory
6209
6293
  );
6210
6294
  vnode.el = null;
6211
6295
  if (isFragment) {
6212
- const end = locateClosingAsyncAnchor(node);
6296
+ const end = locateClosingAnchor(node);
6213
6297
  while (true) {
6214
6298
  const next2 = nextSibling(node);
6215
6299
  if (next2 && next2 !== end) {
@@ -6234,14 +6318,14 @@ If you want to remount the same app, move your app creation logic into a factory
6234
6318
  );
6235
6319
  return next;
6236
6320
  };
6237
- const locateClosingAsyncAnchor = (node) => {
6321
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
6238
6322
  let match = 0;
6239
6323
  while (node) {
6240
6324
  node = nextSibling(node);
6241
6325
  if (node && isComment(node)) {
6242
- if (node.data === "[")
6326
+ if (node.data === open)
6243
6327
  match++;
6244
- if (node.data === "]") {
6328
+ if (node.data === close) {
6245
6329
  if (match === 0) {
6246
6330
  return nextSibling(node);
6247
6331
  } else {
@@ -6252,6 +6336,23 @@ If you want to remount the same app, move your app creation logic into a factory
6252
6336
  }
6253
6337
  return node;
6254
6338
  };
6339
+ const replaceNode = (newNode, oldNode, parentComponent) => {
6340
+ const parentNode2 = oldNode.parentNode;
6341
+ if (parentNode2) {
6342
+ parentNode2.replaceChild(newNode, oldNode);
6343
+ }
6344
+ let parent = parentComponent;
6345
+ while (parent) {
6346
+ if (parent.vnode.el === oldNode) {
6347
+ parent.vnode.el = newNode;
6348
+ parent.subTree.el = newNode;
6349
+ }
6350
+ parent = parent.parent;
6351
+ }
6352
+ };
6353
+ const isTemplateNode = (node) => {
6354
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
6355
+ };
6255
6356
  return [hydrate, hydrateNode];
6256
6357
  }
6257
6358
 
@@ -6579,7 +6680,7 @@ If you want to remount the same app, move your app creation logic into a factory
6579
6680
  if (dirs) {
6580
6681
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
6581
6682
  }
6582
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
6683
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
6583
6684
  if (needCallTransitionHooks) {
6584
6685
  transition.beforeEnter(el);
6585
6686
  }
@@ -6967,6 +7068,7 @@ If you want to remount the same app, move your app creation logic into a factory
6967
7068
  } else {
6968
7069
  instance.next = n2;
6969
7070
  invalidateJob(instance.update);
7071
+ instance.effect.dirty = true;
6970
7072
  instance.update();
6971
7073
  }
6972
7074
  } else {
@@ -7136,11 +7238,16 @@ If you want to remount the same app, move your app creation logic into a factory
7136
7238
  };
7137
7239
  const effect = instance.effect = new ReactiveEffect(
7138
7240
  componentUpdateFn,
7241
+ NOOP,
7139
7242
  () => queueJob(update),
7140
7243
  instance.scope
7141
7244
  // track it in component's effect scope
7142
7245
  );
7143
- const update = instance.update = () => effect.run();
7246
+ const update = instance.update = () => {
7247
+ if (effect.dirty) {
7248
+ effect.run();
7249
+ }
7250
+ };
7144
7251
  update.id = instance.uid;
7145
7252
  toggleRecurse(instance, true);
7146
7253
  {
@@ -7471,8 +7578,8 @@ If you want to remount the same app, move your app creation logic into a factory
7471
7578
  moveStaticNode(vnode, container, anchor);
7472
7579
  return;
7473
7580
  }
7474
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
7475
- if (needTransition) {
7581
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
7582
+ if (needTransition2) {
7476
7583
  if (moveType === 0) {
7477
7584
  transition.beforeEnter(el);
7478
7585
  hostInsert(el, container, anchor);
@@ -7692,6 +7799,9 @@ If you want to remount the same app, move your app creation logic into a factory
7692
7799
  function toggleRecurse({ effect, update }, allowed) {
7693
7800
  effect.allowRecurse = update.allowRecurse = allowed;
7694
7801
  }
7802
+ function needTransition(parentSuspense, transition) {
7803
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
7804
+ }
7695
7805
  function traverseStaticChildren(n1, n2, shallow = false) {
7696
7806
  const ch1 = n1.children;
7697
7807
  const ch2 = n2.children;
@@ -9021,7 +9131,8 @@ Component that was made reactive: `,
9021
9131
  return true;
9022
9132
  }
9023
9133
 
9024
- const version = "3.3.6";
9134
+ const version = "3.4.0-alpha.1";
9135
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
9025
9136
  const ssrUtils = null;
9026
9137
  const resolveFilter = null;
9027
9138
  const compatUtils = null;
@@ -10499,6 +10610,7 @@ Component that was made reactive: `,
10499
10610
  exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
10500
10611
  exports.Comment = Comment;
10501
10612
  exports.EffectScope = EffectScope;
10613
+ exports.ErrorTypeStrings = ErrorTypeStrings;
10502
10614
  exports.Fragment = Fragment;
10503
10615
  exports.KeepAlive = KeepAlive;
10504
10616
  exports.ReactiveEffect = ReactiveEffect;