@vue/compat 3.3.9 → 3.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,6 @@
1
1
  function makeMap(str, expectsLowerCase) {
2
- const map = /* @__PURE__ */ Object.create(null);
3
- const list = str.split(",");
4
- for (let i = 0; i < list.length; i++) {
5
- map[list[i]] = true;
6
- }
7
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
2
+ const set = new Set(str.split(","));
3
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
8
4
  }
9
5
 
10
6
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -354,117 +350,120 @@ function onScopeDispose(fn) {
354
350
  }
355
351
  }
356
352
 
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
353
  let activeEffect;
395
- const ITERATE_KEY = Symbol("iterate" );
396
- const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
397
354
  class ReactiveEffect {
398
- constructor(fn, scheduler = null, scope) {
355
+ constructor(fn, trigger, scheduler, scope) {
399
356
  this.fn = fn;
357
+ this.trigger = trigger;
400
358
  this.scheduler = scheduler;
401
359
  this.active = true;
402
360
  this.deps = [];
403
- this.parent = void 0;
361
+ /**
362
+ * @internal
363
+ */
364
+ this._dirtyLevel = 3;
365
+ /**
366
+ * @internal
367
+ */
368
+ this._trackId = 0;
369
+ /**
370
+ * @internal
371
+ */
372
+ this._runnings = 0;
373
+ /**
374
+ * @internal
375
+ */
376
+ this._queryings = 0;
377
+ /**
378
+ * @internal
379
+ */
380
+ this._depsLength = 0;
404
381
  recordEffectScope(this, scope);
405
382
  }
383
+ get dirty() {
384
+ if (this._dirtyLevel === 1) {
385
+ this._dirtyLevel = 0;
386
+ this._queryings++;
387
+ pauseTracking();
388
+ for (const dep of this.deps) {
389
+ if (dep.computed) {
390
+ triggerComputed(dep.computed);
391
+ if (this._dirtyLevel >= 2) {
392
+ break;
393
+ }
394
+ }
395
+ }
396
+ resetTracking();
397
+ this._queryings--;
398
+ }
399
+ return this._dirtyLevel >= 2;
400
+ }
401
+ set dirty(v) {
402
+ this._dirtyLevel = v ? 3 : 0;
403
+ }
406
404
  run() {
405
+ this._dirtyLevel = 0;
407
406
  if (!this.active) {
408
407
  return this.fn();
409
408
  }
410
- let parent = activeEffect;
411
409
  let lastShouldTrack = shouldTrack;
412
- while (parent) {
413
- if (parent === this) {
414
- return;
415
- }
416
- parent = parent.parent;
417
- }
410
+ let lastEffect = activeEffect;
418
411
  try {
419
- this.parent = activeEffect;
420
- activeEffect = this;
421
412
  shouldTrack = true;
422
- trackOpBit = 1 << ++effectTrackDepth;
423
- if (effectTrackDepth <= maxMarkerBits) {
424
- initDepMarkers(this);
425
- } else {
426
- cleanupEffect(this);
427
- }
413
+ activeEffect = this;
414
+ this._runnings++;
415
+ preCleanupEffect(this);
428
416
  return this.fn();
429
417
  } finally {
430
- if (effectTrackDepth <= maxMarkerBits) {
431
- finalizeDepMarkers(this);
432
- }
433
- trackOpBit = 1 << --effectTrackDepth;
434
- activeEffect = this.parent;
418
+ postCleanupEffect(this);
419
+ this._runnings--;
420
+ activeEffect = lastEffect;
435
421
  shouldTrack = lastShouldTrack;
436
- this.parent = void 0;
437
- if (this.deferStop) {
438
- this.stop();
439
- }
440
422
  }
441
423
  }
442
424
  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
- }
425
+ var _a;
426
+ if (this.active) {
427
+ preCleanupEffect(this);
428
+ postCleanupEffect(this);
429
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
450
430
  this.active = false;
451
431
  }
452
432
  }
453
433
  }
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);
434
+ function triggerComputed(computed) {
435
+ return computed.value;
436
+ }
437
+ function preCleanupEffect(effect2) {
438
+ effect2._trackId++;
439
+ effect2._depsLength = 0;
440
+ }
441
+ function postCleanupEffect(effect2) {
442
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
443
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
444
+ cleanupDepEffect(effect2.deps[i], effect2);
445
+ }
446
+ effect2.deps.length = effect2._depsLength;
447
+ }
448
+ }
449
+ function cleanupDepEffect(dep, effect2) {
450
+ const trackId = dep.get(effect2);
451
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
452
+ dep.delete(effect2);
453
+ if (dep.size === 0) {
454
+ dep.cleanup();
459
455
  }
460
- deps.length = 0;
461
456
  }
462
457
  }
463
458
  function effect(fn, options) {
464
459
  if (fn.effect instanceof ReactiveEffect) {
465
460
  fn = fn.effect.fn;
466
461
  }
467
- const _effect = new ReactiveEffect(fn);
462
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
463
+ if (_effect.dirty) {
464
+ _effect.run();
465
+ }
466
+ });
468
467
  if (options) {
469
468
  extend(_effect, options);
470
469
  if (options.scope)
@@ -481,6 +480,7 @@ function stop(runner) {
481
480
  runner.effect.stop();
482
481
  }
483
482
  let shouldTrack = true;
483
+ let pauseScheduleStack = 0;
484
484
  const trackStack = [];
485
485
  function pauseTracking() {
486
486
  trackStack.push(shouldTrack);
@@ -490,6 +490,68 @@ function resetTracking() {
490
490
  const last = trackStack.pop();
491
491
  shouldTrack = last === void 0 ? true : last;
492
492
  }
493
+ function pauseScheduling() {
494
+ pauseScheduleStack++;
495
+ }
496
+ function resetScheduling() {
497
+ pauseScheduleStack--;
498
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
499
+ queueEffectSchedulers.shift()();
500
+ }
501
+ }
502
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
503
+ var _a;
504
+ if (dep.get(effect2) !== effect2._trackId) {
505
+ dep.set(effect2, effect2._trackId);
506
+ const oldDep = effect2.deps[effect2._depsLength];
507
+ if (oldDep !== dep) {
508
+ if (oldDep) {
509
+ cleanupDepEffect(oldDep, effect2);
510
+ }
511
+ effect2.deps[effect2._depsLength++] = dep;
512
+ } else {
513
+ effect2._depsLength++;
514
+ }
515
+ {
516
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
517
+ }
518
+ }
519
+ }
520
+ const queueEffectSchedulers = [];
521
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
522
+ var _a;
523
+ pauseScheduling();
524
+ for (const effect2 of dep.keys()) {
525
+ if (!effect2.allowRecurse && effect2._runnings) {
526
+ continue;
527
+ }
528
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
529
+ const lastDirtyLevel = effect2._dirtyLevel;
530
+ effect2._dirtyLevel = dirtyLevel;
531
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
532
+ {
533
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
534
+ }
535
+ effect2.trigger();
536
+ if (effect2.scheduler) {
537
+ queueEffectSchedulers.push(effect2.scheduler);
538
+ }
539
+ }
540
+ }
541
+ }
542
+ resetScheduling();
543
+ }
544
+
545
+ const createDep = (cleanup, computed) => {
546
+ const dep = /* @__PURE__ */ new Map();
547
+ dep.cleanup = cleanup;
548
+ dep.computed = computed;
549
+ return dep;
550
+ };
551
+
552
+ const targetMap = /* @__PURE__ */ new WeakMap();
553
+ const ITERATE_KEY = Symbol("iterate" );
554
+ const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
493
555
  function track(target, type, key) {
494
556
  if (shouldTrack && activeEffect) {
495
557
  let depsMap = targetMap.get(target);
@@ -498,35 +560,17 @@ function track(target, type, key) {
498
560
  }
499
561
  let dep = depsMap.get(key);
500
562
  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
- );
563
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
529
564
  }
565
+ trackEffect(
566
+ activeEffect,
567
+ dep,
568
+ {
569
+ target,
570
+ type,
571
+ key
572
+ }
573
+ );
530
574
  }
531
575
  }
532
576
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -574,49 +618,24 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
574
618
  break;
575
619
  }
576
620
  }
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();
621
+ pauseScheduling();
622
+ for (const dep of deps) {
623
+ if (dep) {
624
+ triggerEffects(
625
+ dep,
626
+ 3,
627
+ {
628
+ target,
629
+ type,
630
+ key,
631
+ newValue,
632
+ oldValue,
633
+ oldTarget
634
+ }
635
+ );
618
636
  }
619
637
  }
638
+ resetScheduling();
620
639
  }
621
640
  function getDepFromReactive(object, key) {
622
641
  var _a;
@@ -647,7 +666,9 @@ function createArrayInstrumentations() {
647
666
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
648
667
  instrumentations[key] = function(...args) {
649
668
  pauseTracking();
669
+ pauseScheduling();
650
670
  const res = toRaw(this)[key].apply(this, args);
671
+ resetScheduling();
651
672
  resetTracking();
652
673
  return res;
653
674
  };
@@ -1186,30 +1207,94 @@ function markRaw(value) {
1186
1207
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1187
1208
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1188
1209
 
1210
+ class ComputedRefImpl {
1211
+ constructor(getter, _setter, isReadonly, isSSR) {
1212
+ this._setter = _setter;
1213
+ this.dep = void 0;
1214
+ this.__v_isRef = true;
1215
+ this["__v_isReadonly"] = false;
1216
+ this.effect = new ReactiveEffect(
1217
+ () => getter(this._value),
1218
+ () => triggerRefValue(this, 1)
1219
+ );
1220
+ this.effect.computed = this;
1221
+ this.effect.active = this._cacheable = !isSSR;
1222
+ this["__v_isReadonly"] = isReadonly;
1223
+ }
1224
+ get value() {
1225
+ const self = toRaw(this);
1226
+ trackRefValue(self);
1227
+ if (!self._cacheable || self.effect.dirty) {
1228
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1229
+ triggerRefValue(self, 2);
1230
+ }
1231
+ }
1232
+ return self._value;
1233
+ }
1234
+ set value(newValue) {
1235
+ this._setter(newValue);
1236
+ }
1237
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1238
+ get _dirty() {
1239
+ return this.effect.dirty;
1240
+ }
1241
+ set _dirty(v) {
1242
+ this.effect.dirty = v;
1243
+ }
1244
+ // #endregion
1245
+ }
1246
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1247
+ let getter;
1248
+ let setter;
1249
+ const onlyGetter = isFunction(getterOrOptions);
1250
+ if (onlyGetter) {
1251
+ getter = getterOrOptions;
1252
+ setter = () => {
1253
+ console.warn("Write operation failed: computed value is readonly");
1254
+ } ;
1255
+ } else {
1256
+ getter = getterOrOptions.get;
1257
+ setter = getterOrOptions.set;
1258
+ }
1259
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1260
+ if (debugOptions && !isSSR) {
1261
+ cRef.effect.onTrack = debugOptions.onTrack;
1262
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1263
+ }
1264
+ return cRef;
1265
+ }
1266
+
1189
1267
  function trackRefValue(ref2) {
1190
1268
  if (shouldTrack && activeEffect) {
1191
1269
  ref2 = toRaw(ref2);
1192
- {
1193
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1270
+ trackEffect(
1271
+ activeEffect,
1272
+ ref2.dep || (ref2.dep = createDep(
1273
+ () => ref2.dep = void 0,
1274
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1275
+ )),
1276
+ {
1194
1277
  target: ref2,
1195
1278
  type: "get",
1196
1279
  key: "value"
1197
- });
1198
- }
1280
+ }
1281
+ );
1199
1282
  }
1200
1283
  }
1201
- function triggerRefValue(ref2, newVal) {
1284
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1202
1285
  ref2 = toRaw(ref2);
1203
1286
  const dep = ref2.dep;
1204
1287
  if (dep) {
1205
- {
1206
- triggerEffects(dep, {
1288
+ triggerEffects(
1289
+ dep,
1290
+ dirtyLevel,
1291
+ {
1207
1292
  target: ref2,
1208
1293
  type: "set",
1209
1294
  key: "value",
1210
1295
  newValue: newVal
1211
- });
1212
- }
1296
+ }
1297
+ );
1213
1298
  }
1214
1299
  }
1215
1300
  function isRef(r) {
@@ -1245,12 +1330,12 @@ class RefImpl {
1245
1330
  if (hasChanged(newVal, this._rawValue)) {
1246
1331
  this._rawValue = newVal;
1247
1332
  this._value = useDirectValue ? newVal : toReactive(newVal);
1248
- triggerRefValue(this, newVal);
1333
+ triggerRefValue(this, 3, newVal);
1249
1334
  }
1250
1335
  }
1251
1336
  }
1252
1337
  function triggerRef(ref2) {
1253
- triggerRefValue(ref2, ref2.value );
1338
+ triggerRefValue(ref2, 3, ref2.value );
1254
1339
  }
1255
1340
  function unref(ref2) {
1256
1341
  return isRef(ref2) ? ref2.value : ref2;
@@ -1348,57 +1433,6 @@ function propertyToRef(source, key, defaultValue) {
1348
1433
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1349
1434
  }
1350
1435
 
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
1436
  const stack = [];
1403
1437
  function pushWarningContext(vnode) {
1404
1438
  stack.push(vnode);
@@ -1513,7 +1547,7 @@ function assertNumber(val, type) {
1513
1547
  }
1514
1548
  }
1515
1549
 
1516
- const ErrorTypeStrings = {
1550
+ const ErrorTypeStrings$1 = {
1517
1551
  ["sp"]: "serverPrefetch hook",
1518
1552
  ["bc"]: "beforeCreate hook",
1519
1553
  ["c"]: "created hook",
@@ -1574,7 +1608,7 @@ function handleError(err, instance, type, throwInDev = true) {
1574
1608
  if (instance) {
1575
1609
  let cur = instance.parent;
1576
1610
  const exposedInstance = instance.proxy;
1577
- const errorInfo = ErrorTypeStrings[type] ;
1611
+ const errorInfo = ErrorTypeStrings$1[type] ;
1578
1612
  while (cur) {
1579
1613
  const errorCapturedHooks = cur.ec;
1580
1614
  if (errorCapturedHooks) {
@@ -1601,7 +1635,7 @@ function handleError(err, instance, type, throwInDev = true) {
1601
1635
  }
1602
1636
  function logError(err, type, contextVNode, throwInDev = true) {
1603
1637
  {
1604
- const info = ErrorTypeStrings[type];
1638
+ const info = ErrorTypeStrings$1[type];
1605
1639
  if (contextVNode) {
1606
1640
  pushWarningContext(contextVNode);
1607
1641
  }
@@ -1829,6 +1863,7 @@ function rerender(id, newRender) {
1829
1863
  }
1830
1864
  instance.renderCache = [];
1831
1865
  isHmrUpdating = true;
1866
+ instance.effect.dirty = true;
1832
1867
  instance.update();
1833
1868
  isHmrUpdating = false;
1834
1869
  });
@@ -1856,6 +1891,7 @@ function reload(id, newComp) {
1856
1891
  instance.ceReload(newComp.styles);
1857
1892
  hmrDirtyComponents.delete(oldComp);
1858
1893
  } else if (instance.parent) {
1894
+ instance.parent.effect.dirty = true;
1859
1895
  queueJob(instance.parent.update);
1860
1896
  } else if (instance.appContext.reload) {
1861
1897
  instance.appContext.reload();
@@ -3620,8 +3656,15 @@ function watch(source, cb, options) {
3620
3656
  }
3621
3657
  return doWatch(source, cb, options);
3622
3658
  }
3623
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3659
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3624
3660
  var _a;
3661
+ if (cb && once) {
3662
+ const _cb = cb;
3663
+ cb = (...args) => {
3664
+ _cb(...args);
3665
+ unwatch();
3666
+ };
3667
+ }
3625
3668
  if (!cb) {
3626
3669
  if (immediate !== void 0) {
3627
3670
  warn(
@@ -3633,6 +3676,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3633
3676
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3634
3677
  );
3635
3678
  }
3679
+ if (once !== void 0) {
3680
+ warn(
3681
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3682
+ );
3683
+ }
3636
3684
  }
3637
3685
  const warnInvalidSource = (s) => {
3638
3686
  warn(
@@ -3711,7 +3759,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3711
3759
  };
3712
3760
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3713
3761
  const job = () => {
3714
- if (!effect.active) {
3762
+ if (!effect.active || !effect.dirty) {
3715
3763
  return;
3716
3764
  }
3717
3765
  if (cb) {
@@ -3744,7 +3792,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3744
3792
  job.id = instance.uid;
3745
3793
  scheduler = () => queueJob(job);
3746
3794
  }
3747
- const effect = new ReactiveEffect(getter, scheduler);
3795
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3796
+ const unwatch = () => {
3797
+ effect.stop();
3798
+ if (instance && instance.scope) {
3799
+ remove(instance.scope.effects, effect);
3800
+ }
3801
+ };
3748
3802
  {
3749
3803
  effect.onTrack = onTrack;
3750
3804
  effect.onTrigger = onTrigger;
@@ -3763,12 +3817,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3763
3817
  } else {
3764
3818
  effect.run();
3765
3819
  }
3766
- const unwatch = () => {
3767
- effect.stop();
3768
- if (instance && instance.scope) {
3769
- remove(instance.scope.effects, effect);
3770
- }
3771
- };
3772
3820
  return unwatch;
3773
3821
  }
3774
3822
  function instanceWatch(source, value, options) {
@@ -4001,6 +4049,7 @@ const BaseTransitionImpl = {
4001
4049
  leavingHooks.afterLeave = () => {
4002
4050
  state.isLeaving = false;
4003
4051
  if (instance.update.active !== false) {
4052
+ instance.effect.dirty = true;
4004
4053
  instance.update();
4005
4054
  }
4006
4055
  };
@@ -4343,6 +4392,7 @@ function defineAsyncComponent(source) {
4343
4392
  load().then(() => {
4344
4393
  loaded.value = true;
4345
4394
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4395
+ instance.parent.effect.dirty = true;
4346
4396
  queueJob(instance.parent.update);
4347
4397
  }
4348
4398
  }).catch((err) => {
@@ -4640,7 +4690,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4640
4690
  }
4641
4691
  return wrappedHook;
4642
4692
  } else {
4643
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4693
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4644
4694
  warn(
4645
4695
  `${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.` )
4646
4696
  );
@@ -5303,7 +5353,10 @@ const publicPropertiesMap = (
5303
5353
  $root: (i) => getPublicInstance(i.root),
5304
5354
  $emit: (i) => i.emit,
5305
5355
  $options: (i) => resolveMergedOptions(i) ,
5306
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5356
+ $forceUpdate: (i) => i.f || (i.f = () => {
5357
+ i.effect.dirty = true;
5358
+ queueJob(i.update);
5359
+ }),
5307
5360
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5308
5361
  $watch: (i) => instanceWatch.bind(i)
5309
5362
  })
@@ -6204,7 +6257,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6204
6257
  return vm;
6205
6258
  }
6206
6259
  }
6207
- Vue.version = `2.6.14-compat:${"3.3.9"}`;
6260
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.2"}`;
6208
6261
  Vue.config = singletonApp.config;
6209
6262
  Vue.use = (p, ...options) => {
6210
6263
  if (p && isFunction(p.install)) {
@@ -8627,6 +8680,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8627
8680
  } else {
8628
8681
  instance.next = n2;
8629
8682
  invalidateJob(instance.update);
8683
+ instance.effect.dirty = true;
8630
8684
  instance.update();
8631
8685
  }
8632
8686
  } else {
@@ -8820,11 +8874,16 @@ function baseCreateRenderer(options, createHydrationFns) {
8820
8874
  };
8821
8875
  const effect = instance.effect = new ReactiveEffect(
8822
8876
  componentUpdateFn,
8877
+ NOOP,
8823
8878
  () => queueJob(update),
8824
8879
  instance.scope
8825
8880
  // track it in component's effect scope
8826
8881
  );
8827
- const update = instance.update = () => effect.run();
8882
+ const update = instance.update = () => {
8883
+ if (effect.dirty) {
8884
+ effect.run();
8885
+ }
8886
+ };
8828
8887
  update.id = instance.uid;
8829
8888
  toggleRecurse(instance, true);
8830
8889
  {
@@ -10797,7 +10856,8 @@ function isMemoSame(cached, memo) {
10797
10856
  return true;
10798
10857
  }
10799
10858
 
10800
- const version = "3.3.9";
10859
+ const version = "3.4.0-alpha.2";
10860
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10801
10861
  const ssrUtils = null;
10802
10862
  const resolveFilter = resolveFilter$1 ;
10803
10863
  const _compatUtils = {
@@ -12432,6 +12492,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12432
12492
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12433
12493
  Comment: Comment,
12434
12494
  EffectScope: EffectScope,
12495
+ ErrorTypeStrings: ErrorTypeStrings,
12435
12496
  Fragment: Fragment,
12436
12497
  KeepAlive: KeepAlive,
12437
12498
  ReactiveEffect: ReactiveEffect,
@@ -12628,4 +12689,4 @@ var Vue$1 = Vue;
12628
12689
 
12629
12690
  const { configureCompat } = Vue$1;
12630
12691
 
12631
- 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 };
12692
+ 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 };