@vue/compat 3.3.7 → 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.
@@ -419,117 +419,120 @@ function onScopeDispose(fn) {
419
419
  }
420
420
  }
421
421
 
422
- const createDep = (effects) => {
423
- const dep = new Set(effects);
424
- dep.w = 0;
425
- dep.n = 0;
426
- return dep;
427
- };
428
- const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
429
- const newTracked = (dep) => (dep.n & trackOpBit) > 0;
430
- const initDepMarkers = ({ deps }) => {
431
- if (deps.length) {
432
- for (let i = 0; i < deps.length; i++) {
433
- deps[i].w |= trackOpBit;
434
- }
435
- }
436
- };
437
- const finalizeDepMarkers = (effect) => {
438
- const { deps } = effect;
439
- if (deps.length) {
440
- let ptr = 0;
441
- for (let i = 0; i < deps.length; i++) {
442
- const dep = deps[i];
443
- if (wasTracked(dep) && !newTracked(dep)) {
444
- dep.delete(effect);
445
- } else {
446
- deps[ptr++] = dep;
447
- }
448
- dep.w &= ~trackOpBit;
449
- dep.n &= ~trackOpBit;
450
- }
451
- deps.length = ptr;
452
- }
453
- };
454
-
455
- const targetMap = /* @__PURE__ */ new WeakMap();
456
- let effectTrackDepth = 0;
457
- let trackOpBit = 1;
458
- const maxMarkerBits = 30;
459
422
  let activeEffect;
460
- const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
461
- const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
462
423
  class ReactiveEffect {
463
- constructor(fn, scheduler = null, scope) {
424
+ constructor(fn, trigger, scheduler, scope) {
464
425
  this.fn = fn;
426
+ this.trigger = trigger;
465
427
  this.scheduler = scheduler;
466
428
  this.active = true;
467
429
  this.deps = [];
468
- this.parent = void 0;
430
+ /**
431
+ * @internal
432
+ */
433
+ this._dirtyLevel = 3;
434
+ /**
435
+ * @internal
436
+ */
437
+ this._trackId = 0;
438
+ /**
439
+ * @internal
440
+ */
441
+ this._runnings = 0;
442
+ /**
443
+ * @internal
444
+ */
445
+ this._queryings = 0;
446
+ /**
447
+ * @internal
448
+ */
449
+ this._depsLength = 0;
469
450
  recordEffectScope(this, scope);
470
451
  }
452
+ get dirty() {
453
+ if (this._dirtyLevel === 1) {
454
+ this._dirtyLevel = 0;
455
+ this._queryings++;
456
+ pauseTracking();
457
+ for (const dep of this.deps) {
458
+ if (dep.computed) {
459
+ triggerComputed(dep.computed);
460
+ if (this._dirtyLevel >= 2) {
461
+ break;
462
+ }
463
+ }
464
+ }
465
+ resetTracking();
466
+ this._queryings--;
467
+ }
468
+ return this._dirtyLevel >= 2;
469
+ }
470
+ set dirty(v) {
471
+ this._dirtyLevel = v ? 3 : 0;
472
+ }
471
473
  run() {
474
+ this._dirtyLevel = 0;
472
475
  if (!this.active) {
473
476
  return this.fn();
474
477
  }
475
- let parent = activeEffect;
476
478
  let lastShouldTrack = shouldTrack;
477
- while (parent) {
478
- if (parent === this) {
479
- return;
480
- }
481
- parent = parent.parent;
482
- }
479
+ let lastEffect = activeEffect;
483
480
  try {
484
- this.parent = activeEffect;
485
- activeEffect = this;
486
481
  shouldTrack = true;
487
- trackOpBit = 1 << ++effectTrackDepth;
488
- if (effectTrackDepth <= maxMarkerBits) {
489
- initDepMarkers(this);
490
- } else {
491
- cleanupEffect(this);
492
- }
482
+ activeEffect = this;
483
+ this._runnings++;
484
+ preCleanupEffect(this);
493
485
  return this.fn();
494
486
  } finally {
495
- if (effectTrackDepth <= maxMarkerBits) {
496
- finalizeDepMarkers(this);
497
- }
498
- trackOpBit = 1 << --effectTrackDepth;
499
- activeEffect = this.parent;
487
+ postCleanupEffect(this);
488
+ this._runnings--;
489
+ activeEffect = lastEffect;
500
490
  shouldTrack = lastShouldTrack;
501
- this.parent = void 0;
502
- if (this.deferStop) {
503
- this.stop();
504
- }
505
491
  }
506
492
  }
507
493
  stop() {
508
- if (activeEffect === this) {
509
- this.deferStop = true;
510
- } else if (this.active) {
511
- cleanupEffect(this);
512
- if (this.onStop) {
513
- this.onStop();
514
- }
494
+ var _a;
495
+ if (this.active) {
496
+ preCleanupEffect(this);
497
+ postCleanupEffect(this);
498
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
515
499
  this.active = false;
516
500
  }
517
501
  }
518
502
  }
519
- function cleanupEffect(effect2) {
520
- const { deps } = effect2;
521
- if (deps.length) {
522
- for (let i = 0; i < deps.length; i++) {
523
- deps[i].delete(effect2);
503
+ function triggerComputed(computed) {
504
+ return computed.value;
505
+ }
506
+ function preCleanupEffect(effect2) {
507
+ effect2._trackId++;
508
+ effect2._depsLength = 0;
509
+ }
510
+ function postCleanupEffect(effect2) {
511
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
512
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
513
+ cleanupDepEffect(effect2.deps[i], effect2);
514
+ }
515
+ effect2.deps.length = effect2._depsLength;
516
+ }
517
+ }
518
+ function cleanupDepEffect(dep, effect2) {
519
+ const trackId = dep.get(effect2);
520
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
521
+ dep.delete(effect2);
522
+ if (dep.size === 0) {
523
+ dep.cleanup();
524
524
  }
525
- deps.length = 0;
526
525
  }
527
526
  }
528
527
  function effect(fn, options) {
529
528
  if (fn.effect instanceof ReactiveEffect) {
530
529
  fn = fn.effect.fn;
531
530
  }
532
- const _effect = new ReactiveEffect(fn);
531
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
532
+ if (_effect.dirty) {
533
+ _effect.run();
534
+ }
535
+ });
533
536
  if (options) {
534
537
  extend(_effect, options);
535
538
  if (options.scope)
@@ -546,6 +549,7 @@ function stop(runner) {
546
549
  runner.effect.stop();
547
550
  }
548
551
  let shouldTrack = true;
552
+ let pauseScheduleStack = 0;
549
553
  const trackStack = [];
550
554
  function pauseTracking() {
551
555
  trackStack.push(shouldTrack);
@@ -555,6 +559,68 @@ function resetTracking() {
555
559
  const last = trackStack.pop();
556
560
  shouldTrack = last === void 0 ? true : last;
557
561
  }
562
+ function pauseScheduling() {
563
+ pauseScheduleStack++;
564
+ }
565
+ function resetScheduling() {
566
+ pauseScheduleStack--;
567
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
568
+ queueEffectSchedulers.shift()();
569
+ }
570
+ }
571
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
572
+ var _a;
573
+ if (dep.get(effect2) !== effect2._trackId) {
574
+ dep.set(effect2, effect2._trackId);
575
+ const oldDep = effect2.deps[effect2._depsLength];
576
+ if (oldDep !== dep) {
577
+ if (oldDep) {
578
+ cleanupDepEffect(oldDep, effect2);
579
+ }
580
+ effect2.deps[effect2._depsLength++] = dep;
581
+ } else {
582
+ effect2._depsLength++;
583
+ }
584
+ if (!!(process.env.NODE_ENV !== "production")) {
585
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
586
+ }
587
+ }
588
+ }
589
+ const queueEffectSchedulers = [];
590
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
591
+ var _a;
592
+ pauseScheduling();
593
+ for (const effect2 of dep.keys()) {
594
+ if (!effect2.allowRecurse && effect2._runnings) {
595
+ continue;
596
+ }
597
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
598
+ const lastDirtyLevel = effect2._dirtyLevel;
599
+ effect2._dirtyLevel = dirtyLevel;
600
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
601
+ if (!!(process.env.NODE_ENV !== "production")) {
602
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
603
+ }
604
+ effect2.trigger();
605
+ if (effect2.scheduler) {
606
+ queueEffectSchedulers.push(effect2.scheduler);
607
+ }
608
+ }
609
+ }
610
+ }
611
+ resetScheduling();
612
+ }
613
+
614
+ const createDep = (cleanup, computed) => {
615
+ const dep = /* @__PURE__ */ new Map();
616
+ dep.cleanup = cleanup;
617
+ dep.computed = computed;
618
+ return dep;
619
+ };
620
+
621
+ const targetMap = /* @__PURE__ */ new WeakMap();
622
+ const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
623
+ const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
558
624
  function track(target, type, key) {
559
625
  if (shouldTrack && activeEffect) {
560
626
  let depsMap = targetMap.get(target);
@@ -563,35 +629,17 @@ function track(target, type, key) {
563
629
  }
564
630
  let dep = depsMap.get(key);
565
631
  if (!dep) {
566
- depsMap.set(key, dep = createDep());
567
- }
568
- const eventInfo = !!(process.env.NODE_ENV !== "production") ? { effect: activeEffect, target, type, key } : void 0;
569
- trackEffects(dep, eventInfo);
570
- }
571
- }
572
- function trackEffects(dep, debuggerEventExtraInfo) {
573
- let shouldTrack2 = false;
574
- if (effectTrackDepth <= maxMarkerBits) {
575
- if (!newTracked(dep)) {
576
- dep.n |= trackOpBit;
577
- shouldTrack2 = !wasTracked(dep);
578
- }
579
- } else {
580
- shouldTrack2 = !dep.has(activeEffect);
581
- }
582
- if (shouldTrack2) {
583
- dep.add(activeEffect);
584
- activeEffect.deps.push(dep);
585
- if (!!(process.env.NODE_ENV !== "production") && activeEffect.onTrack) {
586
- activeEffect.onTrack(
587
- extend(
588
- {
589
- effect: activeEffect
590
- },
591
- debuggerEventExtraInfo
592
- )
593
- );
594
- }
632
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
633
+ }
634
+ trackEffect(
635
+ activeEffect,
636
+ dep,
637
+ !!(process.env.NODE_ENV !== "production") ? {
638
+ target,
639
+ type,
640
+ key
641
+ } : void 0
642
+ );
595
643
  }
596
644
  }
597
645
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -639,53 +687,24 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
639
687
  break;
640
688
  }
641
689
  }
642
- const eventInfo = !!(process.env.NODE_ENV !== "production") ? { target, type, key, newValue, oldValue, oldTarget } : void 0;
643
- if (deps.length === 1) {
644
- if (deps[0]) {
645
- if (!!(process.env.NODE_ENV !== "production")) {
646
- triggerEffects(deps[0], eventInfo);
647
- } else {
648
- triggerEffects(deps[0]);
649
- }
650
- }
651
- } else {
652
- const effects = [];
653
- for (const dep of deps) {
654
- if (dep) {
655
- effects.push(...dep);
656
- }
657
- }
658
- if (!!(process.env.NODE_ENV !== "production")) {
659
- triggerEffects(createDep(effects), eventInfo);
660
- } else {
661
- triggerEffects(createDep(effects));
662
- }
663
- }
664
- }
665
- function triggerEffects(dep, debuggerEventExtraInfo) {
666
- const effects = isArray(dep) ? dep : [...dep];
667
- for (const effect2 of effects) {
668
- if (effect2.computed) {
669
- triggerEffect(effect2, debuggerEventExtraInfo);
670
- }
671
- }
672
- for (const effect2 of effects) {
673
- if (!effect2.computed) {
674
- triggerEffect(effect2, debuggerEventExtraInfo);
675
- }
676
- }
677
- }
678
- function triggerEffect(effect2, debuggerEventExtraInfo) {
679
- if (effect2 !== activeEffect || effect2.allowRecurse) {
680
- if (!!(process.env.NODE_ENV !== "production") && effect2.onTrigger) {
681
- effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
682
- }
683
- if (effect2.scheduler) {
684
- effect2.scheduler();
685
- } else {
686
- effect2.run();
690
+ pauseScheduling();
691
+ for (const dep of deps) {
692
+ if (dep) {
693
+ triggerEffects(
694
+ dep,
695
+ 3,
696
+ !!(process.env.NODE_ENV !== "production") ? {
697
+ target,
698
+ type,
699
+ key,
700
+ newValue,
701
+ oldValue,
702
+ oldTarget
703
+ } : void 0
704
+ );
687
705
  }
688
706
  }
707
+ resetScheduling();
689
708
  }
690
709
  function getDepFromReactive(object, key) {
691
710
  var _a;
@@ -716,7 +735,9 @@ function createArrayInstrumentations() {
716
735
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
717
736
  instrumentations[key] = function(...args) {
718
737
  pauseTracking();
738
+ pauseScheduling();
719
739
  const res = toRaw(this)[key].apply(this, args);
740
+ resetScheduling();
720
741
  resetTracking();
721
742
  return res;
722
743
  };
@@ -1255,34 +1276,93 @@ function markRaw(value) {
1255
1276
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1256
1277
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1257
1278
 
1279
+ class ComputedRefImpl {
1280
+ constructor(getter, _setter, isReadonly, isSSR) {
1281
+ this._setter = _setter;
1282
+ this.dep = void 0;
1283
+ this.__v_isRef = true;
1284
+ this["__v_isReadonly"] = false;
1285
+ this.effect = new ReactiveEffect(getter, () => {
1286
+ triggerRefValue(this, 1);
1287
+ });
1288
+ this.effect.computed = this;
1289
+ this.effect.active = this._cacheable = !isSSR;
1290
+ this["__v_isReadonly"] = isReadonly;
1291
+ }
1292
+ get value() {
1293
+ const self = toRaw(this);
1294
+ trackRefValue(self);
1295
+ if (!self._cacheable || self.effect.dirty) {
1296
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1297
+ triggerRefValue(self, 2);
1298
+ }
1299
+ }
1300
+ return self._value;
1301
+ }
1302
+ set value(newValue) {
1303
+ this._setter(newValue);
1304
+ }
1305
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1306
+ get _dirty() {
1307
+ return this.effect.dirty;
1308
+ }
1309
+ set _dirty(v) {
1310
+ this.effect.dirty = v;
1311
+ }
1312
+ // #endregion
1313
+ }
1314
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1315
+ let getter;
1316
+ let setter;
1317
+ const onlyGetter = isFunction(getterOrOptions);
1318
+ if (onlyGetter) {
1319
+ getter = getterOrOptions;
1320
+ setter = !!(process.env.NODE_ENV !== "production") ? () => {
1321
+ console.warn("Write operation failed: computed value is readonly");
1322
+ } : NOOP;
1323
+ } else {
1324
+ getter = getterOrOptions.get;
1325
+ setter = getterOrOptions.set;
1326
+ }
1327
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1328
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1329
+ cRef.effect.onTrack = debugOptions.onTrack;
1330
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1331
+ }
1332
+ return cRef;
1333
+ }
1334
+
1258
1335
  function trackRefValue(ref2) {
1259
1336
  if (shouldTrack && activeEffect) {
1260
1337
  ref2 = toRaw(ref2);
1261
- if (!!(process.env.NODE_ENV !== "production")) {
1262
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1338
+ trackEffect(
1339
+ activeEffect,
1340
+ ref2.dep || (ref2.dep = createDep(
1341
+ () => ref2.dep = void 0,
1342
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1343
+ )),
1344
+ !!(process.env.NODE_ENV !== "production") ? {
1263
1345
  target: ref2,
1264
1346
  type: "get",
1265
1347
  key: "value"
1266
- });
1267
- } else {
1268
- trackEffects(ref2.dep || (ref2.dep = createDep()));
1269
- }
1348
+ } : void 0
1349
+ );
1270
1350
  }
1271
1351
  }
1272
- function triggerRefValue(ref2, newVal) {
1352
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1273
1353
  ref2 = toRaw(ref2);
1274
1354
  const dep = ref2.dep;
1275
1355
  if (dep) {
1276
- if (!!(process.env.NODE_ENV !== "production")) {
1277
- triggerEffects(dep, {
1356
+ triggerEffects(
1357
+ dep,
1358
+ dirtyLevel,
1359
+ !!(process.env.NODE_ENV !== "production") ? {
1278
1360
  target: ref2,
1279
1361
  type: "set",
1280
1362
  key: "value",
1281
1363
  newValue: newVal
1282
- });
1283
- } else {
1284
- triggerEffects(dep);
1285
- }
1364
+ } : void 0
1365
+ );
1286
1366
  }
1287
1367
  }
1288
1368
  function isRef(r) {
@@ -1318,12 +1398,12 @@ class RefImpl {
1318
1398
  if (hasChanged(newVal, this._rawValue)) {
1319
1399
  this._rawValue = newVal;
1320
1400
  this._value = useDirectValue ? newVal : toReactive(newVal);
1321
- triggerRefValue(this, newVal);
1401
+ triggerRefValue(this, 3, newVal);
1322
1402
  }
1323
1403
  }
1324
1404
  }
1325
1405
  function triggerRef(ref2) {
1326
- triggerRefValue(ref2, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1406
+ triggerRefValue(ref2, 3, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1327
1407
  }
1328
1408
  function unref(ref2) {
1329
1409
  return isRef(ref2) ? ref2.value : ref2;
@@ -1421,57 +1501,6 @@ function propertyToRef(source, key, defaultValue) {
1421
1501
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1422
1502
  }
1423
1503
 
1424
- class ComputedRefImpl {
1425
- constructor(getter, _setter, isReadonly, isSSR) {
1426
- this._setter = _setter;
1427
- this.dep = void 0;
1428
- this.__v_isRef = true;
1429
- this["__v_isReadonly"] = false;
1430
- this._dirty = true;
1431
- this.effect = new ReactiveEffect(getter, () => {
1432
- if (!this._dirty) {
1433
- this._dirty = true;
1434
- triggerRefValue(this);
1435
- }
1436
- });
1437
- this.effect.computed = this;
1438
- this.effect.active = this._cacheable = !isSSR;
1439
- this["__v_isReadonly"] = isReadonly;
1440
- }
1441
- get value() {
1442
- const self = toRaw(this);
1443
- trackRefValue(self);
1444
- if (self._dirty || !self._cacheable) {
1445
- self._dirty = false;
1446
- self._value = self.effect.run();
1447
- }
1448
- return self._value;
1449
- }
1450
- set value(newValue) {
1451
- this._setter(newValue);
1452
- }
1453
- }
1454
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1455
- let getter;
1456
- let setter;
1457
- const onlyGetter = isFunction(getterOrOptions);
1458
- if (onlyGetter) {
1459
- getter = getterOrOptions;
1460
- setter = !!(process.env.NODE_ENV !== "production") ? () => {
1461
- console.warn("Write operation failed: computed value is readonly");
1462
- } : NOOP;
1463
- } else {
1464
- getter = getterOrOptions.get;
1465
- setter = getterOrOptions.set;
1466
- }
1467
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1468
- if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1469
- cRef.effect.onTrack = debugOptions.onTrack;
1470
- cRef.effect.onTrigger = debugOptions.onTrigger;
1471
- }
1472
- return cRef;
1473
- }
1474
-
1475
1504
  const stack = [];
1476
1505
  function pushWarningContext(vnode) {
1477
1506
  stack.push(vnode);
@@ -1590,7 +1619,7 @@ function assertNumber(val, type) {
1590
1619
  }
1591
1620
  }
1592
1621
 
1593
- const ErrorTypeStrings = {
1622
+ const ErrorTypeStrings$1 = {
1594
1623
  ["sp"]: "serverPrefetch hook",
1595
1624
  ["bc"]: "beforeCreate hook",
1596
1625
  ["c"]: "created hook",
@@ -1651,7 +1680,7 @@ function handleError(err, instance, type, throwInDev = true) {
1651
1680
  if (instance) {
1652
1681
  let cur = instance.parent;
1653
1682
  const exposedInstance = instance.proxy;
1654
- const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : type;
1683
+ const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : type;
1655
1684
  while (cur) {
1656
1685
  const errorCapturedHooks = cur.ec;
1657
1686
  if (errorCapturedHooks) {
@@ -1678,7 +1707,7 @@ function handleError(err, instance, type, throwInDev = true) {
1678
1707
  }
1679
1708
  function logError(err, type, contextVNode, throwInDev = true) {
1680
1709
  if (!!(process.env.NODE_ENV !== "production")) {
1681
- const info = ErrorTypeStrings[type];
1710
+ const info = ErrorTypeStrings$1[type];
1682
1711
  if (contextVNode) {
1683
1712
  pushWarningContext(contextVNode);
1684
1713
  }
@@ -1908,6 +1937,7 @@ function rerender(id, newRender) {
1908
1937
  }
1909
1938
  instance.renderCache = [];
1910
1939
  isHmrUpdating = true;
1940
+ instance.effect.dirty = true;
1911
1941
  instance.update();
1912
1942
  isHmrUpdating = false;
1913
1943
  });
@@ -1935,6 +1965,7 @@ function reload(id, newComp) {
1935
1965
  instance.ceReload(newComp.styles);
1936
1966
  hmrDirtyComponents.delete(oldComp);
1937
1967
  } else if (instance.parent) {
1968
+ instance.parent.effect.dirty = true;
1938
1969
  queueJob(instance.parent.update);
1939
1970
  } else if (instance.appContext.reload) {
1940
1971
  instance.appContext.reload();
@@ -3633,8 +3664,15 @@ function watch(source, cb, options) {
3633
3664
  }
3634
3665
  return doWatch(source, cb, options);
3635
3666
  }
3636
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3667
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3637
3668
  var _a;
3669
+ if (cb && once) {
3670
+ const _cb = cb;
3671
+ cb = (...args) => {
3672
+ _cb(...args);
3673
+ unwatch();
3674
+ };
3675
+ }
3638
3676
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
3639
3677
  if (immediate !== void 0) {
3640
3678
  warn(
@@ -3646,6 +3684,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3646
3684
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3647
3685
  );
3648
3686
  }
3687
+ if (once !== void 0) {
3688
+ warn(
3689
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3690
+ );
3691
+ }
3649
3692
  }
3650
3693
  const warnInvalidSource = (s) => {
3651
3694
  warn(
@@ -3742,7 +3785,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3742
3785
  }
3743
3786
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3744
3787
  const job = () => {
3745
- if (!effect.active) {
3788
+ if (!effect.active || !effect.dirty) {
3746
3789
  return;
3747
3790
  }
3748
3791
  if (cb) {
@@ -3775,7 +3818,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3775
3818
  job.id = instance.uid;
3776
3819
  scheduler = () => queueJob(job);
3777
3820
  }
3778
- const effect = new ReactiveEffect(getter, scheduler);
3821
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3822
+ const unwatch = () => {
3823
+ effect.stop();
3824
+ if (instance && instance.scope) {
3825
+ remove(instance.scope.effects, effect);
3826
+ }
3827
+ };
3779
3828
  if (!!(process.env.NODE_ENV !== "production")) {
3780
3829
  effect.onTrack = onTrack;
3781
3830
  effect.onTrigger = onTrigger;
@@ -3794,12 +3843,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3794
3843
  } else {
3795
3844
  effect.run();
3796
3845
  }
3797
- const unwatch = () => {
3798
- effect.stop();
3799
- if (instance && instance.scope) {
3800
- remove(instance.scope.effects, effect);
3801
- }
3802
- };
3803
3846
  if (ssrCleanup)
3804
3847
  ssrCleanup.push(unwatch);
3805
3848
  return unwatch;
@@ -4036,6 +4079,7 @@ const BaseTransitionImpl = {
4036
4079
  leavingHooks.afterLeave = () => {
4037
4080
  state.isLeaving = false;
4038
4081
  if (instance.update.active !== false) {
4082
+ instance.effect.dirty = true;
4039
4083
  instance.update();
4040
4084
  }
4041
4085
  };
@@ -4374,6 +4418,7 @@ function defineAsyncComponent(source) {
4374
4418
  load().then(() => {
4375
4419
  loaded.value = true;
4376
4420
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4421
+ instance.parent.effect.dirty = true;
4377
4422
  queueJob(instance.parent.update);
4378
4423
  }
4379
4424
  }).catch((err) => {
@@ -4677,7 +4722,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4677
4722
  }
4678
4723
  return wrappedHook;
4679
4724
  } else if (!!(process.env.NODE_ENV !== "production")) {
4680
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4725
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4681
4726
  warn(
4682
4727
  `${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.` )
4683
4728
  );
@@ -5399,7 +5444,10 @@ const publicPropertiesMap = (
5399
5444
  $root: (i) => getPublicInstance(i.root),
5400
5445
  $emit: (i) => i.emit,
5401
5446
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
5402
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5447
+ $forceUpdate: (i) => i.f || (i.f = () => {
5448
+ i.effect.dirty = true;
5449
+ queueJob(i.update);
5450
+ }),
5403
5451
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5404
5452
  $watch: (i) => __VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP
5405
5453
  })
@@ -6302,7 +6350,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6302
6350
  return vm;
6303
6351
  }
6304
6352
  }
6305
- Vue.version = `2.6.14-compat:${"3.3.7"}`;
6353
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6306
6354
  Vue.config = singletonApp.config;
6307
6355
  Vue.use = (p, ...options) => {
6308
6356
  if (p && isFunction(p.install)) {
@@ -8745,6 +8793,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8745
8793
  } else {
8746
8794
  instance.next = n2;
8747
8795
  invalidateJob(instance.update);
8796
+ instance.effect.dirty = true;
8748
8797
  instance.update();
8749
8798
  }
8750
8799
  } else {
@@ -8938,11 +8987,16 @@ function baseCreateRenderer(options, createHydrationFns) {
8938
8987
  };
8939
8988
  const effect = instance.effect = new ReactiveEffect(
8940
8989
  componentUpdateFn,
8990
+ NOOP,
8941
8991
  () => queueJob(update),
8942
8992
  instance.scope
8943
8993
  // track it in component's effect scope
8944
8994
  );
8945
- const update = instance.update = () => effect.run();
8995
+ const update = instance.update = () => {
8996
+ if (effect.dirty) {
8997
+ effect.run();
8998
+ }
8999
+ };
8946
9000
  update.id = instance.uid;
8947
9001
  toggleRecurse(instance, true);
8948
9002
  if (!!(process.env.NODE_ENV !== "production")) {
@@ -10942,7 +10996,8 @@ function isMemoSame(cached, memo) {
10942
10996
  return true;
10943
10997
  }
10944
10998
 
10945
- const version = "3.3.7";
10999
+ const version = "3.4.0-alpha.1";
11000
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10946
11001
  const _ssrUtils = {
10947
11002
  createComponentInstance,
10948
11003
  setupComponent,
@@ -12634,6 +12689,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12634
12689
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12635
12690
  Comment: Comment,
12636
12691
  EffectScope: EffectScope,
12692
+ ErrorTypeStrings: ErrorTypeStrings,
12637
12693
  Fragment: Fragment,
12638
12694
  KeepAlive: KeepAlive,
12639
12695
  ReactiveEffect: ReactiveEffect,
@@ -17833,4 +17889,4 @@ var Vue$1 = Vue;
17833
17889
 
17834
17890
  const { configureCompat } = Vue$1;
17835
17891
 
17836
- 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 };
17892
+ 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 };