@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 = !!(process.env.NODE_ENV !== "production") ? 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(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
396
- const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "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
+ if (!!(process.env.NODE_ENV !== "production")) {
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
+ if (!!(process.env.NODE_ENV !== "production")) {
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(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
554
+ const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "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 = !!(process.env.NODE_ENV !== "production") ? { effect: activeEffect, target, type, key } : void 0;
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 (!!(process.env.NODE_ENV !== "production") && activeEffect.onTrack) {
521
- activeEffect.onTrack(
522
- extend(
523
- {
524
- effect: activeEffect
525
- },
526
- debuggerEventExtraInfo
527
- )
528
- );
529
- }
563
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
564
+ }
565
+ trackEffect(
566
+ activeEffect,
567
+ dep,
568
+ !!(process.env.NODE_ENV !== "production") ? {
569
+ target,
570
+ type,
571
+ key
572
+ } : void 0
573
+ );
530
574
  }
531
575
  }
532
576
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -574,53 +618,24 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
574
618
  break;
575
619
  }
576
620
  }
577
- const eventInfo = !!(process.env.NODE_ENV !== "production") ? { target, type, key, newValue, oldValue, oldTarget } : void 0;
578
- if (deps.length === 1) {
579
- if (deps[0]) {
580
- if (!!(process.env.NODE_ENV !== "production")) {
581
- triggerEffects(deps[0], eventInfo);
582
- } else {
583
- triggerEffects(deps[0]);
584
- }
585
- }
586
- } else {
587
- const effects = [];
588
- for (const dep of deps) {
589
- if (dep) {
590
- effects.push(...dep);
591
- }
592
- }
593
- if (!!(process.env.NODE_ENV !== "production")) {
594
- triggerEffects(createDep(effects), eventInfo);
595
- } else {
596
- triggerEffects(createDep(effects));
597
- }
598
- }
599
- }
600
- function triggerEffects(dep, debuggerEventExtraInfo) {
601
- const effects = isArray(dep) ? dep : [...dep];
602
- for (const effect2 of effects) {
603
- if (effect2.computed) {
604
- triggerEffect(effect2, debuggerEventExtraInfo);
605
- }
606
- }
607
- for (const effect2 of effects) {
608
- if (!effect2.computed) {
609
- triggerEffect(effect2, debuggerEventExtraInfo);
610
- }
611
- }
612
- }
613
- function triggerEffect(effect2, debuggerEventExtraInfo) {
614
- if (effect2 !== activeEffect || effect2.allowRecurse) {
615
- if (!!(process.env.NODE_ENV !== "production") && effect2.onTrigger) {
616
- effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
617
- }
618
- if (effect2.scheduler) {
619
- effect2.scheduler();
620
- } else {
621
- effect2.run();
621
+ pauseScheduling();
622
+ for (const dep of deps) {
623
+ if (dep) {
624
+ triggerEffects(
625
+ dep,
626
+ 3,
627
+ !!(process.env.NODE_ENV !== "production") ? {
628
+ target,
629
+ type,
630
+ key,
631
+ newValue,
632
+ oldValue,
633
+ oldTarget
634
+ } : void 0
635
+ );
622
636
  }
623
637
  }
638
+ resetScheduling();
624
639
  }
625
640
  function getDepFromReactive(object, key) {
626
641
  var _a;
@@ -651,7 +666,9 @@ function createArrayInstrumentations() {
651
666
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
652
667
  instrumentations[key] = function(...args) {
653
668
  pauseTracking();
669
+ pauseScheduling();
654
670
  const res = toRaw(this)[key].apply(this, args);
671
+ resetScheduling();
655
672
  resetTracking();
656
673
  return res;
657
674
  };
@@ -1190,34 +1207,94 @@ function markRaw(value) {
1190
1207
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1191
1208
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1192
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 = !!(process.env.NODE_ENV !== "production") ? () => {
1253
+ console.warn("Write operation failed: computed value is readonly");
1254
+ } : NOOP;
1255
+ } else {
1256
+ getter = getterOrOptions.get;
1257
+ setter = getterOrOptions.set;
1258
+ }
1259
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1260
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1261
+ cRef.effect.onTrack = debugOptions.onTrack;
1262
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1263
+ }
1264
+ return cRef;
1265
+ }
1266
+
1193
1267
  function trackRefValue(ref2) {
1194
1268
  if (shouldTrack && activeEffect) {
1195
1269
  ref2 = toRaw(ref2);
1196
- if (!!(process.env.NODE_ENV !== "production")) {
1197
- 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
+ !!(process.env.NODE_ENV !== "production") ? {
1198
1277
  target: ref2,
1199
1278
  type: "get",
1200
1279
  key: "value"
1201
- });
1202
- } else {
1203
- trackEffects(ref2.dep || (ref2.dep = createDep()));
1204
- }
1280
+ } : void 0
1281
+ );
1205
1282
  }
1206
1283
  }
1207
- function triggerRefValue(ref2, newVal) {
1284
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1208
1285
  ref2 = toRaw(ref2);
1209
1286
  const dep = ref2.dep;
1210
1287
  if (dep) {
1211
- if (!!(process.env.NODE_ENV !== "production")) {
1212
- triggerEffects(dep, {
1288
+ triggerEffects(
1289
+ dep,
1290
+ dirtyLevel,
1291
+ !!(process.env.NODE_ENV !== "production") ? {
1213
1292
  target: ref2,
1214
1293
  type: "set",
1215
1294
  key: "value",
1216
1295
  newValue: newVal
1217
- });
1218
- } else {
1219
- triggerEffects(dep);
1220
- }
1296
+ } : void 0
1297
+ );
1221
1298
  }
1222
1299
  }
1223
1300
  function isRef(r) {
@@ -1253,12 +1330,12 @@ class RefImpl {
1253
1330
  if (hasChanged(newVal, this._rawValue)) {
1254
1331
  this._rawValue = newVal;
1255
1332
  this._value = useDirectValue ? newVal : toReactive(newVal);
1256
- triggerRefValue(this, newVal);
1333
+ triggerRefValue(this, 3, newVal);
1257
1334
  }
1258
1335
  }
1259
1336
  }
1260
1337
  function triggerRef(ref2) {
1261
- triggerRefValue(ref2, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1338
+ triggerRefValue(ref2, 3, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1262
1339
  }
1263
1340
  function unref(ref2) {
1264
1341
  return isRef(ref2) ? ref2.value : ref2;
@@ -1356,57 +1433,6 @@ function propertyToRef(source, key, defaultValue) {
1356
1433
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1357
1434
  }
1358
1435
 
1359
- class ComputedRefImpl {
1360
- constructor(getter, _setter, isReadonly, isSSR) {
1361
- this._setter = _setter;
1362
- this.dep = void 0;
1363
- this.__v_isRef = true;
1364
- this["__v_isReadonly"] = false;
1365
- this._dirty = true;
1366
- this.effect = new ReactiveEffect(getter, () => {
1367
- if (!this._dirty) {
1368
- this._dirty = true;
1369
- triggerRefValue(this);
1370
- }
1371
- });
1372
- this.effect.computed = this;
1373
- this.effect.active = this._cacheable = !isSSR;
1374
- this["__v_isReadonly"] = isReadonly;
1375
- }
1376
- get value() {
1377
- const self = toRaw(this);
1378
- trackRefValue(self);
1379
- if (self._dirty || !self._cacheable) {
1380
- self._dirty = false;
1381
- self._value = self.effect.run();
1382
- }
1383
- return self._value;
1384
- }
1385
- set value(newValue) {
1386
- this._setter(newValue);
1387
- }
1388
- }
1389
- function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1390
- let getter;
1391
- let setter;
1392
- const onlyGetter = isFunction(getterOrOptions);
1393
- if (onlyGetter) {
1394
- getter = getterOrOptions;
1395
- setter = !!(process.env.NODE_ENV !== "production") ? () => {
1396
- console.warn("Write operation failed: computed value is readonly");
1397
- } : NOOP;
1398
- } else {
1399
- getter = getterOrOptions.get;
1400
- setter = getterOrOptions.set;
1401
- }
1402
- const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1403
- if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1404
- cRef.effect.onTrack = debugOptions.onTrack;
1405
- cRef.effect.onTrigger = debugOptions.onTrigger;
1406
- }
1407
- return cRef;
1408
- }
1409
-
1410
1436
  const stack = [];
1411
1437
  function pushWarningContext(vnode) {
1412
1438
  stack.push(vnode);
@@ -1525,7 +1551,7 @@ function assertNumber(val, type) {
1525
1551
  }
1526
1552
  }
1527
1553
 
1528
- const ErrorTypeStrings = {
1554
+ const ErrorTypeStrings$1 = {
1529
1555
  ["sp"]: "serverPrefetch hook",
1530
1556
  ["bc"]: "beforeCreate hook",
1531
1557
  ["c"]: "created hook",
@@ -1586,7 +1612,7 @@ function handleError(err, instance, type, throwInDev = true) {
1586
1612
  if (instance) {
1587
1613
  let cur = instance.parent;
1588
1614
  const exposedInstance = instance.proxy;
1589
- const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : type;
1615
+ const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : type;
1590
1616
  while (cur) {
1591
1617
  const errorCapturedHooks = cur.ec;
1592
1618
  if (errorCapturedHooks) {
@@ -1613,7 +1639,7 @@ function handleError(err, instance, type, throwInDev = true) {
1613
1639
  }
1614
1640
  function logError(err, type, contextVNode, throwInDev = true) {
1615
1641
  if (!!(process.env.NODE_ENV !== "production")) {
1616
- const info = ErrorTypeStrings[type];
1642
+ const info = ErrorTypeStrings$1[type];
1617
1643
  if (contextVNode) {
1618
1644
  pushWarningContext(contextVNode);
1619
1645
  }
@@ -1843,6 +1869,7 @@ function rerender(id, newRender) {
1843
1869
  }
1844
1870
  instance.renderCache = [];
1845
1871
  isHmrUpdating = true;
1872
+ instance.effect.dirty = true;
1846
1873
  instance.update();
1847
1874
  isHmrUpdating = false;
1848
1875
  });
@@ -1870,6 +1897,7 @@ function reload(id, newComp) {
1870
1897
  instance.ceReload(newComp.styles);
1871
1898
  hmrDirtyComponents.delete(oldComp);
1872
1899
  } else if (instance.parent) {
1900
+ instance.parent.effect.dirty = true;
1873
1901
  queueJob(instance.parent.update);
1874
1902
  } else if (instance.appContext.reload) {
1875
1903
  instance.appContext.reload();
@@ -3637,8 +3665,15 @@ function watch(source, cb, options) {
3637
3665
  }
3638
3666
  return doWatch(source, cb, options);
3639
3667
  }
3640
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3668
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3641
3669
  var _a;
3670
+ if (cb && once) {
3671
+ const _cb = cb;
3672
+ cb = (...args) => {
3673
+ _cb(...args);
3674
+ unwatch();
3675
+ };
3676
+ }
3642
3677
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
3643
3678
  if (immediate !== void 0) {
3644
3679
  warn(
@@ -3650,6 +3685,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3650
3685
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3651
3686
  );
3652
3687
  }
3688
+ if (once !== void 0) {
3689
+ warn(
3690
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3691
+ );
3692
+ }
3653
3693
  }
3654
3694
  const warnInvalidSource = (s) => {
3655
3695
  warn(
@@ -3747,7 +3787,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3747
3787
  }
3748
3788
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3749
3789
  const job = () => {
3750
- if (!effect.active) {
3790
+ if (!effect.active || !effect.dirty) {
3751
3791
  return;
3752
3792
  }
3753
3793
  if (cb) {
@@ -3780,7 +3820,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3780
3820
  job.id = instance.uid;
3781
3821
  scheduler = () => queueJob(job);
3782
3822
  }
3783
- const effect = new ReactiveEffect(getter, scheduler);
3823
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3824
+ const unwatch = () => {
3825
+ effect.stop();
3826
+ if (instance && instance.scope) {
3827
+ remove(instance.scope.effects, effect);
3828
+ }
3829
+ };
3784
3830
  if (!!(process.env.NODE_ENV !== "production")) {
3785
3831
  effect.onTrack = onTrack;
3786
3832
  effect.onTrigger = onTrigger;
@@ -3799,12 +3845,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3799
3845
  } else {
3800
3846
  effect.run();
3801
3847
  }
3802
- const unwatch = () => {
3803
- effect.stop();
3804
- if (instance && instance.scope) {
3805
- remove(instance.scope.effects, effect);
3806
- }
3807
- };
3808
3848
  if (ssrCleanup)
3809
3849
  ssrCleanup.push(unwatch);
3810
3850
  return unwatch;
@@ -4041,6 +4081,7 @@ const BaseTransitionImpl = {
4041
4081
  leavingHooks.afterLeave = () => {
4042
4082
  state.isLeaving = false;
4043
4083
  if (instance.update.active !== false) {
4084
+ instance.effect.dirty = true;
4044
4085
  instance.update();
4045
4086
  }
4046
4087
  };
@@ -4383,6 +4424,7 @@ function defineAsyncComponent(source) {
4383
4424
  load().then(() => {
4384
4425
  loaded.value = true;
4385
4426
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4427
+ instance.parent.effect.dirty = true;
4386
4428
  queueJob(instance.parent.update);
4387
4429
  }
4388
4430
  }).catch((err) => {
@@ -4686,7 +4728,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4686
4728
  }
4687
4729
  return wrappedHook;
4688
4730
  } else if (!!(process.env.NODE_ENV !== "production")) {
4689
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4731
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4690
4732
  warn(
4691
4733
  `${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.` )
4692
4734
  );
@@ -5349,7 +5391,10 @@ const publicPropertiesMap = (
5349
5391
  $root: (i) => getPublicInstance(i.root),
5350
5392
  $emit: (i) => i.emit,
5351
5393
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
5352
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5394
+ $forceUpdate: (i) => i.f || (i.f = () => {
5395
+ i.effect.dirty = true;
5396
+ queueJob(i.update);
5397
+ }),
5353
5398
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5354
5399
  $watch: (i) => __VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP
5355
5400
  })
@@ -6252,7 +6297,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6252
6297
  return vm;
6253
6298
  }
6254
6299
  }
6255
- Vue.version = `2.6.14-compat:${"3.3.9"}`;
6300
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.2"}`;
6256
6301
  Vue.config = singletonApp.config;
6257
6302
  Vue.use = (p, ...options) => {
6258
6303
  if (p && isFunction(p.install)) {
@@ -8712,6 +8757,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8712
8757
  } else {
8713
8758
  instance.next = n2;
8714
8759
  invalidateJob(instance.update);
8760
+ instance.effect.dirty = true;
8715
8761
  instance.update();
8716
8762
  }
8717
8763
  } else {
@@ -8905,11 +8951,16 @@ function baseCreateRenderer(options, createHydrationFns) {
8905
8951
  };
8906
8952
  const effect = instance.effect = new ReactiveEffect(
8907
8953
  componentUpdateFn,
8954
+ NOOP,
8908
8955
  () => queueJob(update),
8909
8956
  instance.scope
8910
8957
  // track it in component's effect scope
8911
8958
  );
8912
- const update = instance.update = () => effect.run();
8959
+ const update = instance.update = () => {
8960
+ if (effect.dirty) {
8961
+ effect.run();
8962
+ }
8963
+ };
8913
8964
  update.id = instance.uid;
8914
8965
  toggleRecurse(instance, true);
8915
8966
  if (!!(process.env.NODE_ENV !== "production")) {
@@ -10910,7 +10961,8 @@ function isMemoSame(cached, memo) {
10910
10961
  return true;
10911
10962
  }
10912
10963
 
10913
- const version = "3.3.9";
10964
+ const version = "3.4.0-alpha.2";
10965
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10914
10966
  const _ssrUtils = {
10915
10967
  createComponentInstance,
10916
10968
  setupComponent,
@@ -12601,6 +12653,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12601
12653
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12602
12654
  Comment: Comment,
12603
12655
  EffectScope: EffectScope,
12656
+ ErrorTypeStrings: ErrorTypeStrings,
12604
12657
  Fragment: Fragment,
12605
12658
  KeepAlive: KeepAlive,
12606
12659
  ReactiveEffect: ReactiveEffect,
@@ -12791,4 +12844,4 @@ var Vue$1 = Vue;
12791
12844
 
12792
12845
  const { configureCompat } = Vue$1;
12793
12846
 
12794
- 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 };
12847
+ 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 };